diff --git a/package-lock.json b/package-lock.json index 5ae1a263..e90e0261 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,7 +31,7 @@ "express-session": "^1.18.1", "fast-glob": "^3.3.3", "fast-json-patch": "^3.1.1", - "fs-extra": "^11.2.0", + "fs-extra": "^11.3.0", "glob": "^11.0.1", "gltf-bounding-box": "^0.4.1", "gltf-pipeline": "^4.1.0", @@ -55,8 +55,8 @@ "socket.io": "^4.8.1", "swagger-jsdoc": "^6.2.8", "swagger-ui-express": "^5.0.1", - "three": "0.172.0", - "three-custom-shader-material": "6.2.1", + "three": "0.173.0", + "three-custom-shader-material": "6.3.0", "three-mesh-bvh": "0.9.0", "webdav-server": "^2.6.2", "ws": "^8.18.0", @@ -710,20 +710,19 @@ "license": "BSD-3-Clause" }, "node_modules/@react-three/fiber": { - "version": "8.17.12", - "resolved": "https://registry.npmjs.org/@react-three/fiber/-/fiber-8.17.12.tgz", - "integrity": "sha512-rjV/ZtCr69y+aWEOsAhBQzsxYyvZHUanYfo9eMXNp/dxTj3ZrRvK44DkIdSLV1xcPidq8p2YeU2oWP2czY+ZVA==", + "version": "8.17.14", + "resolved": "https://registry.npmjs.org/@react-three/fiber/-/fiber-8.17.14.tgz", + "integrity": "sha512-Al2Zdhn5vRefK0adJXNDputuM8hwRNh3goH8MCzf06gezZBbEsdmjt5IrHQQ8Rpr7l/znx/ipLUQuhiiVhxifQ==", "license": "MIT", "dependencies": { "@babel/runtime": "^7.17.8", - "@types/debounce": "^1.2.1", "@types/react-reconciler": "^0.26.7", "@types/webxr": "*", "base64-js": "^1.5.1", "buffer": "^6.0.3", - "debounce": "^1.2.1", "its-fine": "^1.0.6", "react-reconciler": "^0.27.0", + "react-use-measure": "^2.1.7", "scheduler": "^0.21.0", "suspend-react": "^0.1.3", "zustand": "^3.7.1" @@ -777,6 +776,25 @@ "three": ">= 0.138.0" } }, + "node_modules/@react-three/postprocessing/node_modules/n8ao": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/n8ao/-/n8ao-1.9.4.tgz", + "integrity": "sha512-gbpAorQecZn2oGK/rheHxPTNwOxVsEC6216+Jr9tXHUk9L5VCE2q/uxsSrQpfNkZDoCmQHf7oSg3SYFWCAt0wg==", + "license": "ISC", + "peerDependencies": { + "postprocessing": ">=6.30.0", + "three": ">=0.137" + } + }, + "node_modules/@react-three/postprocessing/node_modules/postprocessing": { + "version": "6.36.6", + "resolved": "https://registry.npmjs.org/postprocessing/-/postprocessing-6.36.6.tgz", + "integrity": "sha512-mjJjoXbC97XMV6iQVhOZYNjD5X93o3+/zpYm9oRmsyjP3LjfwedT8PgusECTk+s5DZeZoJ8vA9htdWuH8JH+mQ==", + "license": "Zlib", + "peerDependencies": { + "three": ">= 0.157.0 < 0.173.0" + } + }, "node_modules/@scarf/scarf": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/@scarf/scarf/-/scarf-1.4.0.tgz", @@ -790,41 +808,6 @@ "integrity": "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==", "license": "MIT" }, - "node_modules/@takram/three-atmosphere": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/@takram/three-atmosphere/-/three-atmosphere-0.6.0.tgz", - "integrity": "sha512-UVLhexKdlM90t9s9BXaA5CKAsNxayD+/BuVPRse+XCpOLJIY416RME7RxKaki6XqkKvbvDoiEMQGA6OGbIsFTg==", - "license": "MIT", - "dependencies": { - "@takram/three-geospatial": "0.0.1-alpha.5", - "astronomy-engine": "^2.1.19", - "react-merge-refs": "^2.1.1", - "tiny-invariant": "^1.3.3", - "url-join": "^5.0.0" - }, - "peerDependencies": { - "@react-three/drei": ">=9.117.3", - "@react-three/fiber": ">=8.17.10", - "@react-three/postprocessing": ">=2.16.3", - "postprocessing": ">=6.36.4", - "react": ">=18.0", - "three": ">=0.170.0" - }, - "peerDependenciesMeta": { - "@react-three/drei": { - "optional": true - }, - "@react-three/fiber": { - "optional": true - }, - "@react-three/postprocessing": { - "optional": true - }, - "react": { - "optional": true - } - } - }, "node_modules/@takram/three-geospatial": { "version": "0.0.1-alpha.5", "resolved": "https://registry.npmjs.org/@takram/three-geospatial/-/three-geospatial-0.0.1-alpha.5.tgz", @@ -842,33 +825,6 @@ "three": ">=0.170.0" } }, - "node_modules/@takram/three-geospatial-effects": { - "version": "0.0.1-alpha.5", - "resolved": "https://registry.npmjs.org/@takram/three-geospatial-effects/-/three-geospatial-effects-0.0.1-alpha.5.tgz", - "integrity": "sha512-lnezTH3W9X7KduQhn0zrE/yowMHaS5u1MvECzKMbZrryq5TLlpLpK9JBAv4CTMIQNsSEfKrp5mGlBjXyMrPEMQ==", - "dependencies": { - "@takram/three-geospatial": "0.0.1-alpha.5", - "n8ao": "^1.9.4" - }, - "peerDependencies": { - "@react-three/fiber": ">=8.17.10", - "@react-three/postprocessing": ">=2.16.3", - "postprocessing": ">=6.36.4", - "react": ">=18.0", - "three": ">=0.170.0" - }, - "peerDependenciesMeta": { - "@react-three/fiber": { - "optional": true - }, - "@react-three/postprocessing": { - "optional": true - }, - "react": { - "optional": true - } - } - }, "node_modules/@tweenjs/tween.js": { "version": "23.1.3", "resolved": "https://registry.npmjs.org/@tweenjs/tween.js/-/tween.js-23.1.3.tgz", @@ -885,12 +841,6 @@ "@types/node": "*" } }, - "node_modules/@types/debounce": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@types/debounce/-/debounce-1.2.4.tgz", - "integrity": "sha512-jBqiORIzKDOToaF63Fm//haOCHuwQuLa2202RK4MozpA6lh93eCBc+/8+wZn5OzjJt3ySdc+74SXWXB55Ewtyw==", - "license": "MIT" - }, "node_modules/@types/draco3d": { "version": "1.4.10", "resolved": "https://registry.npmjs.org/@types/draco3d/-/draco3d-1.4.10.tgz", @@ -913,9 +863,9 @@ "license": "MIT" }, "node_modules/@types/lodash": { - "version": "4.17.14", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.14.tgz", - "integrity": "sha512-jsxagdikDiDBeIRaPYtArcT8my4tN1og7MtMRquFT3XNA6axxyHDRUemqDz/taRDdOUn0GnGHRCuff4q48sW9A==", + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-w/P33JFeySuhN6JLkysYUK2gEmy9kHHFN7E8ro0tkfmlDOgxBDzWEZ/J8cWA+fHqFevpswDTFZnDx+R9lbL6xw==", "license": "MIT" }, "node_modules/@types/lodash-es": { @@ -934,9 +884,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.10.10", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.10.tgz", - "integrity": "sha512-X47y/mPNzxviAGY5TcYPtYL8JsY3kAq2n8fMmKoRCxq/c4v4pyGNCzM2R6+M5/umG4ZfHuT+sgqDYqWc9rJ6ww==", + "version": "22.13.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.0.tgz", + "integrity": "sha512-ClIbNe36lawluuvq3+YYhnIN2CELi+6q8NpnM7PYp4hBn/TatfboPgVSm2rwKRfnV2M+Ty9GWDFI64KEe+kysA==", "license": "MIT", "dependencies": { "undici-types": "~6.20.0" @@ -974,9 +924,9 @@ "peer": true }, "node_modules/@types/three": { - "version": "0.172.0", - "resolved": "https://registry.npmjs.org/@types/three/-/three-0.172.0.tgz", - "integrity": "sha512-LrUtP3FEG26Zg5WiF0nbg8VoXiKokBLTcqM2iLvM9vzcfEiYmmBAPGdBgV0OYx9fvWlY3R/3ERTZcD9X5sc0NA==", + "version": "0.173.0", + "resolved": "https://registry.npmjs.org/@types/three/-/three-0.173.0.tgz", + "integrity": "sha512-KtNjfI/CRB6JVKIVeZM1R3GYDX2wkoV2itNcQu2j4d7qkhjGOuB+s2oF6jl9mztycDLGMtrAnJQYxInC8Bb20A==", "license": "MIT", "peer": true, "dependencies": { @@ -1002,16 +952,16 @@ "license": "MIT" }, "node_modules/@webgpu/types": { - "version": "0.1.53", - "resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.53.tgz", - "integrity": "sha512-x+BLw/opaz9LiVyrMsP75nO1Rg0QfrACUYIbVSfGwY/w0DiWIPYYrpte6us//KZXinxFAOJl0+C17L1Vi2vmDw==", + "version": "0.1.54", + "resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.54.tgz", + "integrity": "sha512-81oaalC8LFrXjhsczomEQ0u3jG+TqE6V9QHLA8GNZq/Rnot0KDugu3LhSYSlie8tSdooAN1Hov05asrUUp9qgg==", "license": "BSD-3-Clause", "peer": true }, "node_modules/@zip.js/zip.js": { - "version": "2.7.54", - "resolved": "https://registry.npmjs.org/@zip.js/zip.js/-/zip.js-2.7.54.tgz", - "integrity": "sha512-qMrJVg2hoEsZJjMJez9yI2+nZlBUxgYzGV3mqcb2B/6T1ihXp0fWBDYlVHlHquuorgNUQP5a8qSmX6HF5rFJNg==", + "version": "2.7.57", + "resolved": "https://registry.npmjs.org/@zip.js/zip.js/-/zip.js-2.7.57.tgz", + "integrity": "sha512-BtonQ1/jDnGiMed6OkV6rZYW78gLmLswkHOzyMrMb+CAR7CZO8phOHO6c2qw6qb1g1betN7kwEHhhZk30dv+NA==", "license": "BSD-3-Clause", "engines": { "bun": ">=0.7.0", @@ -1040,6 +990,87 @@ "three": ">=0.166.0" } }, + "node_modules/3d-tiles-renderer/node_modules/@takram/three-atmosphere": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@takram/three-atmosphere/-/three-atmosphere-0.6.0.tgz", + "integrity": "sha512-UVLhexKdlM90t9s9BXaA5CKAsNxayD+/BuVPRse+XCpOLJIY416RME7RxKaki6XqkKvbvDoiEMQGA6OGbIsFTg==", + "license": "MIT", + "dependencies": { + "@takram/three-geospatial": "0.0.1-alpha.5", + "astronomy-engine": "^2.1.19", + "react-merge-refs": "^2.1.1", + "tiny-invariant": "^1.3.3", + "url-join": "^5.0.0" + }, + "peerDependencies": { + "@react-three/drei": ">=9.117.3", + "@react-three/fiber": ">=8.17.10", + "@react-three/postprocessing": ">=2.16.3", + "postprocessing": ">=6.36.4", + "react": ">=18.0", + "three": ">=0.170.0" + }, + "peerDependenciesMeta": { + "@react-three/drei": { + "optional": true + }, + "@react-three/fiber": { + "optional": true + }, + "@react-three/postprocessing": { + "optional": true + }, + "react": { + "optional": true + } + } + }, + "node_modules/3d-tiles-renderer/node_modules/@takram/three-geospatial-effects": { + "version": "0.0.1-alpha.5", + "resolved": "https://registry.npmjs.org/@takram/three-geospatial-effects/-/three-geospatial-effects-0.0.1-alpha.5.tgz", + "integrity": "sha512-lnezTH3W9X7KduQhn0zrE/yowMHaS5u1MvECzKMbZrryq5TLlpLpK9JBAv4CTMIQNsSEfKrp5mGlBjXyMrPEMQ==", + "dependencies": { + "@takram/three-geospatial": "0.0.1-alpha.5", + "n8ao": "^1.9.4" + }, + "peerDependencies": { + "@react-three/fiber": ">=8.17.10", + "@react-three/postprocessing": ">=2.16.3", + "postprocessing": ">=6.36.4", + "react": ">=18.0", + "three": ">=0.170.0" + }, + "peerDependenciesMeta": { + "@react-three/fiber": { + "optional": true + }, + "@react-three/postprocessing": { + "optional": true + }, + "react": { + "optional": true + } + } + }, + "node_modules/3d-tiles-renderer/node_modules/n8ao": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/n8ao/-/n8ao-1.9.4.tgz", + "integrity": "sha512-gbpAorQecZn2oGK/rheHxPTNwOxVsEC6216+Jr9tXHUk9L5VCE2q/uxsSrQpfNkZDoCmQHf7oSg3SYFWCAt0wg==", + "license": "ISC", + "peerDependencies": { + "postprocessing": ">=6.30.0", + "three": ">=0.137" + } + }, + "node_modules/3d-tiles-renderer/node_modules/postprocessing": { + "version": "6.36.6", + "resolved": "https://registry.npmjs.org/postprocessing/-/postprocessing-6.36.6.tgz", + "integrity": "sha512-mjJjoXbC97XMV6iQVhOZYNjD5X93o3+/zpYm9oRmsyjP3LjfwedT8PgusECTk+s5DZeZoJ8vA9htdWuH8JH+mQ==", + "license": "Zlib", + "peerDependencies": { + "three": ">= 0.157.0 < 0.173.0" + } + }, "node_modules/accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", @@ -1851,12 +1882,6 @@ "uniq": "^1.0.0" } }, - "node_modules/debounce": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/debounce/-/debounce-1.2.1.tgz", - "integrity": "sha512-XRRe6Glud4rd/ZGQfiV1ruXSfbvfJedlV9Y6zOlP+2K04vBYiJEte6stfFkCP03aMnY5tsipamumUjL14fofug==", - "license": "MIT" - }, "node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -1941,9 +1966,9 @@ } }, "node_modules/dompurify": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.2.3.tgz", - "integrity": "sha512-U1U5Hzc2MO0oW3DF+G9qYN0aT7atAou4AgI0XjWz061nyBPbdxkfdhfy5uMgGn6+oLFCfn44ZGbdDqCzVmlOWA==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.2.4.tgz", + "integrity": "sha512-ysFSFEDVduQpyhzAob/kkuJjf5zWkZD8/A9ywSp1byueyuCfHamrCBa14/Oc2iiB0e51B+NpxSl5gmzn+Ms/mg==", "license": "(MPL-2.0 OR Apache-2.0)", "optionalDependencies": { "@types/trusted-types": "^2.0.7" @@ -2030,16 +2055,16 @@ } }, "node_modules/engine.io": { - "version": "6.6.3", - "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.3.tgz", - "integrity": "sha512-2hkLItQMBkoYSagneiisupWGvsQlWXqzhSMvsjaM8GYbnfUsX7tzYQq9QARnate5LRedVTX+MbkSZAANAr3NtQ==", + "version": "6.6.4", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.4.tgz", + "integrity": "sha512-ZCkIjSYNDyGn0R6ewHDtXgns/Zre/NT6Agvq1/WobF7JXgFff4SeDroKiCO3fNJreU9YG429Sc81o4w5ok/W5g==", "license": "MIT", "dependencies": { "@types/cors": "^2.8.12", "@types/node": ">=10.0.0", "accepts": "~1.3.4", "base64id": "2.0.0", - "cookie": "~1.0.2", + "cookie": "~0.7.2", "cors": "~2.8.5", "debug": "~4.3.1", "engine.io-parser": "~5.2.1", @@ -2058,15 +2083,6 @@ "node": ">=10.0.0" } }, - "node_modules/engine.io/node_modules/cookie": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.0.2.tgz", - "integrity": "sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==", - "license": "MIT", - "engines": { - "node": ">=18" - } - }, "node_modules/engine.io/node_modules/debug": { "version": "4.3.7", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", @@ -2316,9 +2332,9 @@ "license": "MIT" }, "node_modules/fastq": { - "version": "1.18.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.18.0.tgz", - "integrity": "sha512-QKHXPW0hD8g4UET03SdOdunzSouc9N4AuHdsX8XNcTsuz+yYFILVNIX4l9yHABMhiEI9Db0JTTIpu0wB+Y1QQw==", + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.19.0.tgz", + "integrity": "sha512-7SFSRCNjBQIZH/xZR3iy5iQYR8aGBE0h3VG6/cwlbrpdciNYBMotQav8c1XI3HjHH+NikUpP53nPdlZSdWmFzA==", "license": "ISC", "dependencies": { "reusify": "^1.0.4" @@ -3470,16 +3486,6 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "license": "MIT" }, - "node_modules/n8ao": { - "version": "1.9.4", - "resolved": "https://registry.npmjs.org/n8ao/-/n8ao-1.9.4.tgz", - "integrity": "sha512-gbpAorQecZn2oGK/rheHxPTNwOxVsEC6216+Jr9tXHUk9L5VCE2q/uxsSrQpfNkZDoCmQHf7oSg3SYFWCAt0wg==", - "license": "ISC", - "peerDependencies": { - "postprocessing": ">=6.30.0", - "three": ">=0.137" - } - }, "node_modules/nanoid": { "version": "3.3.8", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz", @@ -3846,15 +3852,6 @@ "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.", "license": "MIT" }, - "node_modules/postprocessing": { - "version": "6.36.6", - "resolved": "https://registry.npmjs.org/postprocessing/-/postprocessing-6.36.6.tgz", - "integrity": "sha512-mjJjoXbC97XMV6iQVhOZYNjD5X93o3+/zpYm9oRmsyjP3LjfwedT8PgusECTk+s5DZeZoJ8vA9htdWuH8JH+mQ==", - "license": "Zlib", - "peerDependencies": { - "three": ">= 0.157.0 < 0.173.0" - } - }, "node_modules/potpack": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/potpack/-/potpack-1.0.2.tgz", @@ -4082,6 +4079,21 @@ "react": "^18.0.0" } }, + "node_modules/react-use-measure": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/react-use-measure/-/react-use-measure-2.1.7.tgz", + "integrity": "sha512-KrvcAo13I/60HpwGO5jpW7E9DfusKyLPLvuHlUyP5zqnmAPhNc6qTRjUQrdTADl0lpPpDVU2/Gg51UlOGHXbdg==", + "license": "MIT", + "peerDependencies": { + "react": ">=16.13", + "react-dom": ">=16.13" + }, + "peerDependenciesMeta": { + "react-dom": { + "optional": true + } + } + }, "node_modules/readdirp": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.1.tgz", @@ -4347,9 +4359,9 @@ } }, "node_modules/semver": { - "version": "7.6.3", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", - "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.0.tgz", + "integrity": "sha512-DrfFnPzblFmNrIZzg5RzHegbiRWg7KMR7btwi2yjHwx06zsUbO5g613sVwEV7FTwmzJu+Io0lJe2GJ3LxqpvBQ==", "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -4974,9 +4986,9 @@ } }, "node_modules/swagger-ui-dist": { - "version": "5.18.2", - "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.18.2.tgz", - "integrity": "sha512-J+y4mCw/zXh1FOj5wGJvnAajq6XgHOyywsa9yITmwxIlJbMqITq3gYRZHaeqLVH/eV/HOPphE6NjF+nbSNC5Zw==", + "version": "5.18.3", + "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.18.3.tgz", + "integrity": "sha512-G33HFW0iFNStfY2x6QXO2JYVMrFruc8AZRX0U/L71aA7WeWfX2E5Nm8E/tsipSZJeIZZbSjUDeynLK/wcuNWIw==", "license": "Apache-2.0", "dependencies": { "@scarf/scarf": "=1.4.0" @@ -4998,15 +5010,15 @@ } }, "node_modules/three": { - "version": "0.172.0", - "resolved": "https://registry.npmjs.org/three/-/three-0.172.0.tgz", - "integrity": "sha512-6HMgMlzU97MsV7D/tY8Va38b83kz8YJX+BefKjspMNAv0Vx6dxMogHOrnRl/sbMIs3BPUKijPqDqJ/+UwJbIow==", + "version": "0.173.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.173.0.tgz", + "integrity": "sha512-AUwVmViIEUgBwxJJ7stnF0NkPpZxx1aZ6WiAbQ/Qq61h6I9UR4grXtZDmO8mnlaNORhHnIBlXJ1uBxILEKuVyw==", "license": "MIT" }, "node_modules/three-custom-shader-material": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/three-custom-shader-material/-/three-custom-shader-material-6.2.1.tgz", - "integrity": "sha512-lzWeJklQ8C1qt51VlVC4QRuw0OZ+QSkqfVrdhT14jpvSGVAl3IWQ0H203YdZsFRFhAf/L/QWuO7GYT41drzrAA==", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/three-custom-shader-material/-/three-custom-shader-material-6.3.0.tgz", + "integrity": "sha512-5hd5IpAxybyJmrUBZ7tiVW67ESGzMcYv4im6Hs9m9Zgmwj3gHkbPhniqg2Mu69WrtaMialV9gxxFnGP91Yl1vA==", "license": "MIT", "peerDependencies": { "@react-three/fiber": ">=8.0", @@ -5032,9 +5044,9 @@ } }, "node_modules/three-stdlib": { - "version": "2.35.12", - "resolved": "https://registry.npmjs.org/three-stdlib/-/three-stdlib-2.35.12.tgz", - "integrity": "sha512-3Mb3U7gtf1orCb6j2BBcc8BJsBVoCYUjFtwaq9KM8I7ippz4o9G+aDQdT5AF8Sg5FXXZfnPPccP6ufsP8bgG3g==", + "version": "2.35.13", + "resolved": "https://registry.npmjs.org/three-stdlib/-/three-stdlib-2.35.13.tgz", + "integrity": "sha512-AbXVObkM0OFCKX0r4VmHguGTdebiUQA+Yl+4VNta1wC158gwY86tCkjp2LFfmABtjYJhdK6aP13wlLtxZyLMAA==", "license": "MIT", "dependencies": { "@types/draco3d": "^1.4.0", diff --git a/package.json b/package.json index 734a2204..603dd283 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "express-session": "^1.18.1", "fast-glob": "^3.3.3", "fast-json-patch": "^3.1.1", - "fs-extra": "^11.2.0", + "fs-extra": "^11.3.0", "glob": "^11.0.1", "gltf-bounding-box": "^0.4.1", "gltf-pipeline": "^4.1.0", @@ -94,8 +94,8 @@ "ws": "^8.18.0", "swagger-jsdoc": "^6.2.8", "swagger-ui-express": "^5.0.1", - "three": "0.172.0", - "three-custom-shader-material": "6.2.1", + "three": "0.173.0", + "three-custom-shader-material": "6.3.0", "three-mesh-bvh": "0.9.0", "webdav-server": "^2.6.2", "zlibjs": "^0.3.1" diff --git a/public/dist/ATON.min.js b/public/dist/ATON.min.js index d32ad5b1..af5ce522 100644 --- a/public/dist/ATON.min.js +++ b/public/dist/ATON.min.js @@ -1,2 +1,2 @@ /*! For license information please see ATON.min.js.LICENSE.txt */ -(()=>{"use strict";class e extends THREE.Group{constructor(e,t){super(),this.type=t||ATON.NTYPES.SCENE,this.enablePicking(),this.type===ATON.NTYPES.SCENE&&(this._rootG=ATON._rootVisible,this._nodes=ATON.snodes),this.type===ATON.NTYPES.SEM&&(this._rootG=ATON._rootSem,this._nodes=ATON.semnodes),this.type===ATON.NTYPES.UI&&(this._rootG=ATON._rootUI,this._nodes=ATON.uinodes),this.as(e),this.kwords=void 0,this._bCloneOnLoadHit=!0,this._tlist=void 0,this._aniMixers=void 0,this.castShadow=!1,this.receiveShadow=!1,this._bs=new THREE.Sphere,this.autocenter=!1,this.onHover=void 0,this.onLeave=void 0,this.onSelect=void 0}as(e){if(void 0!==e&&e!==ATON.ROOT_NID)return this._nodes[e]=this,this.nid=e,this.name=e,this}setAsRoot(){return this._nodes[ATON.ROOT_NID]=this,this.nid=ATON.ROOT_NID,this}setCloneOnLoadHit(e){return this._bCloneOnLoadHit=e,this}addKeywords(e){let t=e.split(",");void 0===this.kwords&&(this.kwords={});for(let e in t){let o=t[e].trim();o.length>0&&(this.kwords[o]=!0)}for(let t in this.children){let o=this.children[t];void 0!==o.type&&o.addKeywords(e)}return this}hasKeyword(e){if(void 0!==this.kwords)return void 0!==this.kwords[e]}setDescription(e){return this.userData.description=e,this}getDescription(){return this.userData.description}setAudio(e){return this.userData.audio=e,this}getAudio(){return this.userData.audio}hide(){let e=this.visible;return this.visible=!1,ATON.Utils.setPicking(this,this.type,!1),ATON._renderer.shadowMap.enabled&&(ATON._dMainL.shadow.needsUpdate=!0),e&&ATON.updateLightProbes(),this}show(){let e=this.visible;return this.visible=!0,ATON.Utils.setPicking(this,this.type,this.bPickable),ATON._renderer.shadowMap.enabled&&void 0!==ATON._dMainL&&void 0!==ATON._dMainL.shadow&&(ATON._dMainL.shadow.needsUpdate=!0),e||ATON.updateLightProbes(),this}toggle(e){return void 0===e?this.visible?this.hide():this.show():e?this.show():this.hide()}disablePicking(){return this.bPickable=!1,ATON.Utils.setPicking(this,this.type,this.bPickable),this}enablePicking(){return this.bPickable=!0,ATON.Utils.setPicking(this,this.type,this.bPickable),this}setPickable(e){return e?this.enablePicking():this.disablePicking(),this}setMaterial(e){this.userData.cMat=e,this.traverse((t=>{t.isMesh&&(t.material=e),t.type&&(this.userData.cMat=e)}));for(let t in this.children){let o=this.children[t];o.setMaterial&&o.setMaterial(e)}return this}getMaterial(){return this.userData.cMat}setDefaultAndHighlightMaterials(e,t){return this.userData.matSTD=e,this.userData.matHL=t,this}highlight(){return this.userData.matHL&&this.setMaterial(this.userData.matHL),this}restoreDefaultMaterial(){return this.userData.matSTD&&this.setMaterial(this.userData.matSTD),this}setOpacity(e){return this.traverse((t=>{t.isMesh&&(t.material.opacity=e)})),this}setShadowCast(e){return this.castShadow=e,this.traverse((t=>{t.isMesh&&(t.castShadow=e)})),this}setShadowReceive(e){return this.receiveShadow=e,this.traverse((t=>{t.isMesh&&(t.receiveShadow=e)})),this}setEnvMap(e){return this.traverse((t=>{t.isMesh&&(t.material.envMap=e)})),this}assignLightProbe(e){return this.traverse((t=>{t.isMesh&&t.geometry&&ATON.Utils.assignLightProbeToMesh(e,t)})),this}assignLightProbesByProximity(){return 0===ATON._lps.length||this.traverse((e=>{if(e.isMesh&&e.geometry){let t,o,i=new THREE.Vector3;(new THREE.Box3).setFromObject(e).getCenter(i);for(let e in ATON._lps){let r=ATON._lps[e],a=i.distanceToSquared(r.pos);(void 0===t||a{e.isMesh&&e.geometry&&(ATON.Utils.clearLightProbeFromMesh(e),e.material&&(e.material.envMap.dispose(),e.material.needsUpdate=!0))})),this}updateLightProbes=()=>(this.traverse((e=>{if(e.isMesh&&e.geometry){let t=e.userData.LP;void 0!==t&&(t.update(),e.material.envMap=t.getEnvTex(),e.material.needsUpdate=!0)}})),this);duplicate(){let e=this.clone();return e.traverse((e=>{e.isMesh&&(e.material=e.material.clone())})),e}delete(){let e=this.parent;void 0!==e&&void 0!==e.nid&&e.removeChild(this)}removeChild(e){if(void 0!==e)return e.nid,void 0!==e.nid&&(this._nodes[e.nid]=void 0),e.parent=void 0,e.traverse((e=>{e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})),this.remove(e),this}removeChildren(){for(let e=this.children.length-1;e>=0;e--)this.removeChild(this.children[e]);return this}attachTo(e){let t="string"==typeof e?this._nodes[e]:e;return t&&(t.add(this),void 0!==t.userData.cMat&&(this.userData.cMat=t.userData.cMat),void 0!==t.bPickable&&(this.bPickable=t.bPickable)),t}attachToRoot(){return this._rootG.add(this),void 0!==this._rootG.userData.cMat&&(this.userData.cMat=this._rootG.userData.cMat),void 0!==this._rootG.bPickable&&(this.bPickable=this._rootG.bPickable),this._rootG}getBound(){return this.dirtyBound(),this._bs}dirtyBound(){return(new THREE.Box3).setFromObject(this).getBoundingSphere(this._bs),this}autoFit(e,t){if(this.dirtyBound(),e&&(this.position.copy(this._bs.center),this.position.multiplyScalar(-1)),t&&t>0&&this._bs.radius>0){let e=t/this._bs.radius;this.scale.set(e,e,e)}}setPosition(e,t,o){return e instanceof THREE.Vector3?this.position.copy(e):this.position.set(e,t,o),this}setScale(e,t,o){return e instanceof THREE.Vector3?this.scale.copy(e):(void 0===t&&(t=e,o=e),this.scale.set(e,t,o)),this}setRotation(e,t,o){return e instanceof THREE.Vector3?this.rotation.copy(e):this.rotation.set(e,t,o),this}orientToCamera(){return this.quaternion.copy(ATON.Nav._qOri),this}orientToLocation(e,t,o){return e instanceof THREE.Vector3?this.lookAt(e):this.lookAt(e,t,o),this}orientToNode(e){return e?(this.orientToLocation(e.position),this):this}setYup(){return this.rotation.set(-1.57079632679,0,0),this}addTransform(e){let t;return"string"==typeof e&&(t=ATON.Utils.parseTransformString(e)),void 0===t||(void 0===this._tlist&&(this._tlist=[]),this._tlist.push(t)),this}load(e,t){if(void 0===e)return this;let o=this;if(e=ATON.Utils.resolveCollectionURL(e),ATON.Utils.tryLoadFromService(e,o))return t&&t(),o;if("json"===ATON.Utils.getFileExtension(e))return ATON.MRes.loadTileSetFromURL(e,o),t&&t(),o;if(ATON._resHandler)for(let t in ATON._resHandler)if(ATON._resHandler[t](e,o))return o;if(o._bCloneOnLoadHit&&void 0!==ATON._assetsManager[e])return ATON._assetsManager[e].then((e=>{let i=e.clone();if(ATON.Utils.modelVisitor(o,i),void 0!==o._tlist)for(let e in o._tlist)o._tlist[e].add(i.clone()),o.add(o._tlist[e]);else o.add(i);t&&t()})),o;ATON._assetReqNew(e);let i=new Promise(((i,r)=>{ATON._aLoader.load(e,(r=>{let a=r.scene||r.scene[0];if(ATON.Utils.modelVisitor(o,a),void 0!==o._tlist)for(let e in o._tlist)o._tlist[e].add(a.clone()),o.add(o._tlist[e]);else o.add(a);ATON.Utils.registerAniMixers(o,r),ATON.CC.extract(r),i(a),console.log("%cModel loaded","color:green"),ATON._assetReqComplete(e),o.type===ATON.NTYPES.SCENE&&(ATON._bqScene=!0),o.type===ATON.NTYPES.SEM&&(ATON._bqSem=!0),o.bPickable&&o.enablePicking(),o.dirtyBound(),t&&t()}),void 0,(o=>{console.log("%cError loading model "+e,"color:red"),ATON._assetReqComplete(e),t&&t()}))}));return o._bCloneOnLoadHit&&(ATON._assetsManager[e]=i),this}exportAs(e){return ATON.Utils.exportNode(this,e),this}setOnHover(e){return this.onHover=e,this}setOnLeave(e){return this.onLeave=e,this}setOnSelect(e){return this.onSelect=e,this}loadCesiumIONAsset(e){return ATON.MRes.loadCesiumIONAsset(e,this),this}loadSketchfabAsset(e){let t=ATON.getAPIToken("sketchfab"),o=this;return null==t&&(console.log("A valid Sketchfab token is required"),t=prompt("Please enter a valid Sketchfab token:"),null==t||""==t)||fetch("https://api.sketchfab.com/v3/models/"+e+"/download",{method:"GET",headers:{Authorization:"Token "+t},mode:"cors"}).then((function(e){return e.json()})).then((function(e){if(ATON.setAPIToken("sketchfab",t),e.glb){let t=e.glb.url;return o.load(t),o}})),this}}const t=e;let o={init:()=>{o.evLocal={},o.evNetwork={},ATON.on=o.on,ATON.fire=o.fire,ATON.fireEvent=o.fire,ATON.clearEventHandlers=o.clearEventHandlers},clearEventHandlers:e=>{o.evLocal[e]=[],o.evNetwork[e]=[]},executeHandlers:(e,t)=>{if(e)for(let o=0;o{if(void 0!==t){const i=o.evLocal;void 0===i[e]&&(i[e]=[]),i[e].push(t)}void 0!==i&&ATON.Photon.on(e,i)},fire:(e,t,i)=>{const r=o.evLocal[e];o.executeHandlers(r,t),i&&ATON.Photon.fire(e,t)}};const i=o;let r={init:()=>{r.materials={},r.colors={},r._loader=new THREE.MaterialLoader,r._uSem={time:{type:"float",value:0},tint:{type:"vec4",value:new THREE.Vector4(.2,.2,1,.2)},sel:{type:"vec4",value:new THREE.Vector4(0,0,0,.1)}},r.addDefaults()},getDefVertexShader:()=>"\n varying vec3 vPositionW;\n varying vec3 vNormalW;\n varying vec3 vNormalV;\n varying vec2 vUv;\n\n void main(){\n vUv = uv;\n\n vPositionW = ( modelMatrix * vec4( position, 1.0 )).xyz;\n vNormalV = normalize( vec3( normalMatrix * normal ));\n vNormalW = ( modelMatrix * vec4(normal, 0.0 )).xyz;\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }\n ",addDefaults:()=>{r.colors.white=new THREE.Color(1,1,1),r.colors.black=new THREE.Color(0,0,0),r.colors.green=new THREE.Color(0,1,0),r.colors.yellow=new THREE.Color(1,1,0),r.colors.red=new THREE.Color(1,0,0),r.colors.blue=new THREE.Color(0,0,1),r.colors.orange=new THREE.Color(1,.5,0),r.colors.defUI=new THREE.Color(.85,1,.95),r.colors.sem=new THREE.Color(0,1,.5),r.colors.darksem=new THREE.Color(0,0,.1),r.materials.fullyTransparent=new THREE.MeshBasicMaterial({transparent:!0,depthWrite:!1,opacity:0}),r.materials.defUI=new THREE.ShaderMaterial({uniforms:{tint:{type:"vec3",value:r.colors.defUI},opacity:{type:"float",value:0}},vertexShader:r.getDefVertexShader(),fragmentShader:"\n varying vec3 vPositionW;\n\t\t varying vec3 vNormalW;\n varying vec3 vNormalV;\n uniform vec3 tint;\n //uniform vec3 base;\n uniform float opacity;\n\n\t\t void main(){\n\t\t //vec3 viewDirectionW = normalize(cameraPosition - vPositionW);\n\n float f;\n\t\t //f = dot(vNormalV, viewDirectionW);\n f = dot(vNormalV, vec3(0,0,1));\n\t\t f = clamp(1.0-f, 0.0, 1.0);\n f *= f;\n\n f = mix(opacity, 1.0 + opacity, f);\n f = clamp(f, 0.0,1.0);\n\n //vec3 col = mix(base,tint, f);\n\t\t //gl_FragColor = vec4(col, f * opacity);\n\n gl_FragColor = vec4(tint, f);\n\t\t }\n ",transparent:!0,depthWrite:!1}),r.materials.selector=r.materials.defUI.clone(),r.materials.outline=new THREE.MeshBasicMaterial({color:r.colors.black,side:THREE.BackSide,transparent:!0,depthWrite:!1,opacity:.2}),r.materials.controllerRay=r.materials.defUI.clone(),r.materials.controllerRay.uniforms.tint.value=r.colors.white,r.materials.xray=r.materials.defUI.clone(),r.materials.xray.uniforms.tint.value=r.colors.white,r.materials.xray.uniforms.opacity.value=.5,r.materials.teleportLoc=new THREE.MeshBasicMaterial({transparent:!0,opacity:1,depthWrite:!1,side:THREE.DoubleSide}),ATON.Utils.textureLoader.load(ATON.PATH_RES+"grad.png",(e=>{r.materials.teleportLoc.map=e})),r.materials.measurement=new THREE.MeshBasicMaterial({color:r.colors.white,transparent:!0,depthWrite:!1,opacity:.5,depthTest:!1}),r.materials.semanticShape=new THREE.ShaderMaterial({uniforms:r._uSem,vertexShader:r.getDefVertexShader(),fragmentShader:"\n varying vec3 vPositionW;\n\t\t varying vec3 vNormalW;\n varying vec3 vNormalV;\n\n uniform float time;\n uniform vec4 tint;\n\n\t\t void main(){\n\t\t //vec3 viewDirectionW = normalize(cameraPosition - vPositionW);\n\n //float ff = dot(vNormalV, vec3(0,0,1));\n\t\t //ff = clamp(1.0-ff, 0.0, 1.0);\n\n float f = (1.0 * cos(time*2.0)); // - 0.5;\n //f = cos(time + (vPositionW.y*10.0));\n f = clamp(f, 0.0,1.0);\n\n\t\t gl_FragColor = vec4(tint.rgb, tint.a * f);\n //gl_FragColor = vec4(tint.rgb, ff);\n\t\t }\n ",transparent:!0,depthWrite:!1}),r.materials.semanticShapeHL=new THREE.MeshBasicMaterial({color:r.colors.sem,transparent:!0,depthWrite:!1,opacity:.2}),r.materials.semanticShapeEdit=new THREE.MeshBasicMaterial({color:r.colors.orange,transparent:!0,depthWrite:!1,opacity:.5}),r.materials.transWhite=new THREE.MeshBasicMaterial({color:r.colors.white,transparent:!0,depthWrite:!1,side:THREE.DoubleSide,opacity:.2}),r.materials.transBlack=new THREE.MeshBasicMaterial({color:r.colors.black,transparent:!0,depthWrite:!1,side:THREE.DoubleSide,opacity:.2}),r.materials.wireframe=new THREE.MeshBasicMaterial({color:r.colors.black,transparent:!0,depthWrite:!1,opacity:.1,wireframe:!0}),r.materials.normSlope=new THREE.ShaderMaterial({vertexShader:r.getDefVertexShader(),fragmentShader:"\n varying vec3 vPositionW;\n\t\t varying vec3 vNormalW;\n\n\t\t void main(){\n vec4 A = vec4(0,1,0, 1.0);\n vec4 B = vec4(1,0,0, 1.0);\n\n float f;\n f = dot(vNormalW, vec3(0,1,0));\n\n\t\t gl_FragColor = mix(B,A, f);\n\t\t }\n "}),r.materials.gradient=new THREE.ShaderMaterial({uniforms:{range:{type:"vec2",value:new THREE.Vector2(-4,5)}},vertexShader:r.getDefVertexShader(),fragmentShader:"\n varying vec3 vPositionW;\n\n uniform vec2 range;\n\n\t\t void main(){\n vec4 A = vec4(0,0,0, 1.0);\n vec4 B = vec4(0,0.5,1, 1.0);\n\n float t = (vPositionW.y - range.x)/(range.y - range.x);\n t = clamp(t, 0.0,1.0);\n\n\t\t gl_FragColor = mix(A,B, t);\n\t\t }\n "}),r.materials.lp=new THREE.ShaderMaterial({vertexShader:r.getDefVertexShader(),fragmentShader:"\n varying vec3 vPositionW;\n\t\t varying vec3 vNormalW;\n varying vec3 vNormalV;\n\n\t\t void main(){\n\t\t vec3 viewDirectionW = normalize(cameraPosition - vPositionW);\n\n float f;\n\t\t //f = dot(viewDirectionW, vNormalW);\n f = dot(vNormalV, vec3(0,0,1));\n\t\t f = clamp(1.0 - f, 0.0, 1.0);\n\n\t\t gl_FragColor = vec4(1.0,1.0,1.0, f);\n\t\t }\n ",transparent:!0,depthWrite:!1});let e=(new THREE.TextureLoader).load(ATON.PATH_RES+"point-mask.png");e.generateMipmaps=!1,r.materials.point=new THREE.PointsMaterial({vertexColors:!0,alphaMap:e,alphaTest:.5,depthTest:!0,transparent:!1,size:4,sizeAttenuation:!1}),r.materials.chromakey=new THREE.ShaderMaterial({uniforms:{tBase:{type:"t"},keycolor:{type:"vec4",value:new THREE.Vector4(0,1,0,0)},similarity:{type:"float",value:.4},smoothness:{type:"float",value:.08},spill:{type:"float",value:.1}},vertexShader:r.getDefVertexShader(),fragmentShader:"\n uniform sampler2D tBase;\n uniform vec4 keycolor;\n\n uniform float similarity;\n uniform float smoothness;\n uniform float spill;\n\n varying vec2 vUv;\n\n // From https://github.com/libretro/glsl-shaders/blob/master/nnedi3/shaders/rgb-to-yuv.glsl\n vec2 RGBtoUV(vec3 rgb){\n return vec2(\n rgb.r * -0.169 + rgb.g * -0.331 + rgb.b * 0.5 + 0.5,\n rgb.r * 0.5 + rgb.g * -0.419 + rgb.b * -0.081 + 0.5\n );\n }\n\n // From https://godotshaders.com/shader/green-screen-chromakey/\n\t\t void main(){\n\t\t vec4 frag = texture2D(tBase, vUv);\n vec4 orig = frag;\n\n float chromaDist = distance(RGBtoUV(frag.rgb), RGBtoUV(keycolor.rgb));\n\n float baseMask = chromaDist - similarity;\n float fullMask = pow(clamp(baseMask / smoothness, 0.0,1.0), 1.5);\n frag.a = fullMask;\n \n float spillVal = pow(clamp(baseMask / spill, 0.0,1.0), 1.5);\n float desat = clamp(frag.r * 0.2126 + frag.g * 0.7152 + frag.b * 0.0722, 0.0,1.0);\n frag.rgb = mix(vec3(desat, desat, desat), frag.rgb, spillVal);\n\n frag = mix(orig,frag, keycolor.w);\n\n\t\t gl_FragColor = frag;\n\t\t }\n ",transparent:!0,side:THREE.DoubleSide})},addMaterial:(e,t)=>{r.materials[e]?console.log("MatHub: material "+e+" already registered"):r.materials[e]=t},loadMaterial:(e,t)=>{r._loader.load(t,(t=>{r.addMaterial(e,t)}),void 0,(e=>{console.log(e)}))},getMaterial:e=>r.materials[e],update:()=>{r._uSem.time.value+=ATON._dt,r._uSem.sel.value.x=ATON.SUI.mainSelector.position.x,r._uSem.sel.value.y=ATON.SUI.mainSelector.position.y,r._uSem.sel.value.z=ATON.SUI.mainSelector.position.z,r._uSem.sel.value.w=ATON.SUI._selectorRad}};const a=r;let n={TSTRING_SEPARATOR:" ",VOID_CAST:(e,t)=>{},init:()=>{ATON.device={},n.geomUnitSphere=new THREE.SphereGeometry(1,32,32),n.geomUnitCube=new THREE.BoxGeometry,n.exporterGLTF=void 0,n.exporterOBJ=void 0,n.exporterUSDZ=void 0,n._dlink=document.createElement("a"),n._dlink.style.display="none",document.body.appendChild(n._dlink),n.textureLoader=new THREE.TextureLoader,n._bvhBounds=0,n.stats={},n.stats.numVertices=0,n.stats.numTris=0},generateID:e=>(void 0===e&&(e="id"),e+"-"+Math.random().toString(36).substr(2,9)),goToURL:e=>{window.location.href=e},goToScene:(e,t)=>{if(void 0===e)return;if(e.length<2)return;let o=ATON.PATH_FE+e;void 0!==t&&(o+="&vrc="+t),window.location.href=o},isConnectionSecure:()=>window.isSecureContext,isLocalhost:()=>!!window.location.origin.includes("localhost")||!!window.location.origin.includes("127.0.0.1"),showBVHbounds:e=>{e>0&&(n._bvhBounds=e)},_addBVHbounds:(e,t)=>{if(void 0===e)return;let o=new ThreeMeshBVH.MeshBVHHelper(e,t);o.displayParents=!0,o.update(),e.parent.add(o)},profileDevice:()=>{ATON.device.isMobile=!1,ATON.device.isMobile=!(!/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)&&!/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4))),ATON.device.xrSupported={},ATON.device.xrSupported["immersive-vr"]=!1,ATON.device.xrSupported["immersive-ar"]=!1,"xr"in navigator&&(navigator.xr.isSessionSupported("immersive-vr").then((e=>{ATON.device.xrSupported["immersive-vr"]=!!e,console.log("WebXR VR session support: "+ATON.device.xrSupported["immersive-vr"]),ATON.fire("XR_support",{type:"immersive-vr",v:ATON.device.xrSupported["immersive-vr"]})})),navigator.xr.isSessionSupported("immersive-ar").then((e=>{ATON.device.xrSupported["immersive-ar"]=!!e,console.log("WebXR AR session support: "+ATON.device.xrSupported["immersive-ar"]),ATON.fire("XR_support",{type:"immersive-ar",v:ATON.device.xrSupported["immersive-ar"]})})))},profileRenderingCapabilities:()=>{if(void 0===ATON._renderer)return;let e=ATON._renderer.capabilities;void 0!==e&&(ATON.device.lowGPU=!1,e.isWebGL2||(ATON.device.lowGPU=!0),e.maxTextureSize<8192&&(ATON.device.lowGPU=!0),e.maxCubemapSize<4096&&(ATON.device.lowGPU=!0),console.log(e))},isMobile:()=>ATON.device.isMobile,isVRsupported:()=>ATON.device.xrSupported["immersive-vr"],isARsupported:()=>ATON.device.xrSupported["immersive-ar"],getFileExtension:e=>e.substr(e.lastIndexOf(".")+1).toLowerCase(),removeFileExtension:e=>e.replace(/\.[^/.]+$/,""),isVideo:e=>{let t=n.getFileExtension(e);return"mp4"===t||"webm"===t||"m3u8"===t},isImage:e=>{let t=n.getFileExtension(e);return"jpg"===t||"png"===t||"ktx"===t||"ktx2"===t},getBaseFolder:e=>{var t=e.lastIndexOf("/");return-1!==t?e.substring(0,t+1):""},getFilename:e=>e.split(/(\\|\/)/g).pop(),isResourceURL:e=>!!e.startsWith("http://")||!!e.startsWith("https://"),URLify:e=>{if("string"!=typeof e)return e;const t=e.match(/(((ftp|https?):\/\/)[\-\w@:%_\+.~#?,&\/\/=]+)/g);return t&&t.forEach((function(t){e=e.replace(t,"")})),e},resolveCollectionURL:e=>e?(ATON._collMod&&(e=ATON._collMod(e)),e.startsWith("http")?e:ATON.PATH_COLLECTION+e):"",tryLoadFromService:(e,t)=>{if(!t)return!1;if(e.startsWith("https://cesium.com/ion/assets/")||e.startsWith("https://ion.cesium.com/assets/")){let o=e.split("/"),i=o[o.length-1];return t.loadCesiumIONAsset(i),!0}if(e.startsWith("https://assets.cesium.com/")){let o=e.split("/"),i=o[o.length-2];return t.loadCesiumIONAsset(i),!0}if(e.startsWith("https://sketchfab.com/3d-models/")){let o=e.split("-"),i=o[o.length-1];return t.loadSketchfabAsset(i),!0}for(let o in ATON._resMappers){let i=ATON._resMappers[o](e);if(void 0!==i)return t.load(i),!0}return!1},postJSON:(e,t,o,i)=>{$.ajax({url:e,type:"POST",xhrFields:{withCredentials:!0},data:JSON.stringify(t),contentType:"application/json; charset=utf-8",dataType:"json",success:e=>{o&&o(e)}}).fail((e=>{console.log(e),i&&i()}))},getJSON:(e,t)=>{fetch(e,{method:"GET",headers:{Accept:"application/json"}}).then((e=>e.json())).then((e=>{console.log(e),t&&t(e)}))},runAsync:e=>{const t=new Worker(URL.createObjectURL(new Blob([`postMessage((${e})());`]),{type:"application/javascript; charset=utf-8"}));return new Promise(((e,o)=>{t.onmessage=({data:o})=>{e(o),t.terminate()},t.onerror=e=>{o(e),t.terminate()}}))},mergeObject:e=>{e.updateMatrixWorld(!0);const t=[];e.traverse((e=>{if(e.isMesh){const o=e.geometry;o.applyMatrix4(e.matrixWorld),t.push(o.toNonIndexed())}}));const o=THREE.BufferGeometryUtils.mergeGeometries(t,!1),i=THREE.BufferGeometryUtils.mergeVertices(o).center(),r=new THREE.Group,a=new THREE.Mesh(i);return r.add(a),r},setPicking:(e,t,o)=>{void 0===o&&(o=!0),e.traverse((e=>{o?e.layers.enable(t):e.layers.disable(t)}))},graphPostVisitor:e=>{e.visible?console.log(e):n.setPicking(e,e.type,!1)},rotationBetweenDirections:(e,t)=>{const o=new THREE.Quaternion,i=(new THREE.Vector3).crossVectors(e,t);return o.x=i.x,o.y=i.y,o.z=i.z,o.w=1+e.clone().dot(t),o.normalize(),o},clampValue:(e,t,o)=>Math.min(Math.max(e,t),o),loadTexture:(e,t)=>{e.endsWith(".ktx2")?ATON._ktx2Loader.load(e,t):n.textureLoader.load(e,t)},modelVisitor:(e,t)=>{if(void 0===t)return;if(void 0===e)return;let o=e.type;t.traverse((t=>{t.isMesh&&(o===ATON.NTYPES.SCENE&&(t.castShadow=!0,t.receiveShadow=!0,t.geometry&&(t.geometry.computeBoundsTree(),console.log("Computed visible BVH"),n._bvhBounds>0&&n._addBVHbounds(t,n._bvhBounds)),n.processMaterial(t.material)),o===ATON.NTYPES.SEM&&(t.material=ATON.MatHub.materials.semanticShape,t.geometry&&(t.geometry.computeBoundsTree(),console.log("Computed semantic BVH"))),e.userData.cMat&&(t.material=e.userData.cMat))}))},processMaterial:e=>{void 0!==e&&null!==e.map&&void 0!==e.map&&(e.map.generateMipmaps=!0,e.map.anisotropy=ATON.device.isMobile?0:ATON._maxAnisotropy,e.map.minFilter=THREE.LinearMipmapLinearFilter,e.map.magFilter=THREE.LinearFilter,e.map.colorSpace=ATON._stdEncoding)},_visitorCP:e=>{ATON._renderer.localClippingEnabled&&(e||(e=ATON._rootVisible),e.traverse((e=>{e.material&&(e.material.clippingPlanes=ATON._clipPlanes,e.material.clipIntersection=!1,e.material.clipShadows=!0)})))},cleanupVisitor:e=>{e.traverse((e=>{if(e.material)if(e.material.length)for(let t=0;t{let o=t.scene||t.scene[0],i=!1;if(void 0===t.animations)return;let r=new THREE.AnimationMixer(o);t.animations.forEach((e=>{r.clipAction(e).play(),i=!0})),i&&(ATON._aniMixers.push(r),void 0===e._aniMixers&&(e._aniMixers=[]),e._aniMixers.push(r))},parseTransformString:e=>{let t=new THREE.Group,o=e.split(n.TSTRING_SEPARATOR),i=o.length;return i<3||(t.position.set(parseFloat(o[0]),parseFloat(o[1]),parseFloat(o[2])),i<6||(t.rotation.set(parseFloat(o[3]),parseFloat(o[4]),parseFloat(o[5])),i<9||t.scale.set(parseFloat(o[6]),parseFloat(o[7]),parseFloat(o[8])))),t},setVectorPrecision:(e,t)=>(e.x=parseFloat(e.x.toPrecision(t)),e.y=parseFloat(e.y.toPrecision(t)),e.z=parseFloat(e.z.toPrecision(t)),e),parseMD:e=>(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/^\s*\n\*/gm,"
    \n*")).replace(/^(\*.+)\s*\n([^\*])/gm,"$1\n
\n\n$2")).replace(/^\*(.+)/gm,"
  • $1
  • ")).replace(/^\s*\n\d\./gm,"
      \n1.")).replace(/^(\d\..+)\s*\n([^\d\.])/gm,"$1\n
    \n\n$2")).replace(/^\d\.(.+)/gm,"
  • $1
  • ")).replace(/^\>(.+)/gm,"
    $1
    ")).replace(/[\#]{6}(.+)/g,"
    $1
    ")).replace(/[\#]{5}(.+)/g,"
    $1
    ")).replace(/[\#]{4}(.+)/g,"

    $1

    ")).replace(/[\#]{3}(.+)/g,"

    $1

    ")).replace(/[\#]{2}(.+)/g,"

    $1

    ")).replace(/[\#]{1}(.+)/g,"

    $1

    ")).replace(/^(.+)\n\=+/gm,"

    $1

    ")).replace(/^(.+)\n\-+/gm,"

    $1

    ")).replace(/\!\[([^\]]+)\]\(([^\)]+)\)/g,'$1')).replace(/[\[]{1}([^\]]+)[\]]{1}[\(]{1}([^\)\"]+)(\"(.+)\")?[\)]{1}/g,'$1')).replace(/[\*\_]{2}([^\*\_]+)[\*\_]{2}/g,"$1")).replace(/[\*\_]{1}([^\*\_]+)[\*\_]{1}/g,"$1")).replace(/[\~]{2}([^\~]+)[\~]{2}/g,"$1")).replace(/^\s*\n\`\`\`(([^\s]+))?/gm,'
    ')).replace(/^\`\`\`\s*\n/gm,"
    \n\n")).replace(/[\`]{1}([^\`]+)[\`]{1}/g,"$1")).replace(/^\s*(\n)?(.+)/gm,(function(e){return/\<(\/)?(h\d|ul|ol|li|blockquote|pre|img)/.test(e)?e:"

    "+e+"

    "}))).replace(/(\)\s*\n\(.+)\<\/p\>/gm,"$1$2"),checkAuth:e=>{$.ajax({type:"GET",url:ATON.PATH_RESTAPI+"user",xhrFields:{withCredentials:!0},dataType:"json",success:t=>{e(t)}})},getHumanReadableDistance:e=>{let t=" m";return e<.01?(t=" mm",t=(e*=1e3).toPrecision(3)+t,t):e<1?(t=" cm",t=(e*=100).toPrecision(3)+t,t):e>1e3?(t=" km",t=e.toPrecision(3)+t,t):(t=e.toPrecision(3)+t,t)},stripHTMLtagsFromString:e=>e.replace(/(<([^>]+)>)/gi,""),requestFullscreen:()=>{let e=document.documentElement;return e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen(),!0},downloadBlob:(e,t)=>{void 0!==t&&(n._dlink.href=URL.createObjectURL(e),n._dlink.download=t,n._dlink.click())},downloadText:(e,t)=>{n.downloadBlob(new Blob([e],{type:"text/plain"}),t)},downloadJSONobj:(e,t)=>{n.downloadText(JSON.stringify(e),t)},downloadArrayBuffer:(e,t)=>{n.downloadBlob(new Blob([e],{type:"application/octet-stream"}),t)},downloadImageFromCanvas:(e,t)=>{if(!e)return;let o=e.toDataURL();ATON.Utils._dlink.href=o,ATON.Utils._dlink.download=t,ATON.Utils._dlink.click()},exportNode:(e,t)=>{let o=n.getFileExtension(t);if(!(o.length<1)){if("glb"===o||"gltf"===o){let i={binary:"glb"===o};void 0===n.exporterGLTF&&(n.exporterGLTF=new THREE.GLTFExporter),n.exporterGLTF.parse(e,(e=>{e instanceof ArrayBuffer?n.downloadArrayBuffer(e,t):(console.log(e),n.downloadJSONobj(e,t))}),i)}if("obj"===o){void 0===n.exporterOBJ&&(n.exporterOBJ=new THREE.OBJExporter);let o=n.exporterOBJ.parse(e);n.downloadText(o,t)}"usdz"===o&&(void 0===n.exporterUSDZ&&(n.exporterUSDZ=new THREE.USDZExporter),$("#idLoader").show(),n.exporterUSDZ.parse(e).then((e=>{n.downloadArrayBuffer(e,t),$("#idLoader").hide()})))}},takeScreenshot:(e,t)=>{let o=new Image;console.log("Screenshot with size:"+e),ATON.Nav._camera.aspect=1,ATON.Nav._camera.updateProjectionMatrix(),ATON._renderer.setSize(e,e),ATON._renderer.render(ATON._mainRoot,ATON.Nav._camera);let i=ATON._renderer.domElement;if(ATON.FX.composer){if(ATON.FX.composer.setSize(e,e),ATON.FX.passes[ATON.FX.PASS_AA]){let t=ATON.FX.passes[ATON.FX.PASS_AA].material.uniforms;t&&t.resolution.value.set(1/e,1/e)}ATON.FX.composer.render(),i=ATON.FX.composer.renderer.domElement}let r=ATON._renderer.domElement.toDataURL();return o.src=r,t&&(n._dlink.href=r.replace("image/png","image/octet-stream"),n._dlink.download=t,n._dlink.click()),ATON._onResize(),o},assignLightProbeToMesh:(e,t)=>{void 0!==e&&void 0!==t&&(t.noLP||(t.userData.LP=e))},clearLightProbeFromMesh:e=>{void 0!==e&&(e.noLP||(e.userData.LP=null))},vibrate:e=>{void 0===e&&(e=100),window.navigator.vibrate(e)},createATONCube:e=>{let t=new THREE.BoxGeometry(1,1,1),o=new THREE.MeshStandardMaterial;n.textureLoader.load(ATON.PATH_RES+"models/aton-cube.jpg",(e=>{e.colorSpace=ATON._stdEncoding,o.map=e}));let i=ATON.createSceneNode(e);return i.add(new THREE.Mesh(t)),i.setMaterial(o),i.enablePicking(),i},createATONCubePBR:e=>{let t=new THREE.BoxGeometry(1,1,1),o=new THREE.MeshStandardMaterial;o.metalness=1,n.textureLoader.load(ATON.PATH_RES+"models/aton-cube.jpg",(e=>{e.colorSpace=ATON._stdEncoding,o.map=e})),n.textureLoader.load(ATON.PATH_RES+"models/aton-cube-pbr.jpg",(e=>{e.colorSpace=ATON._stdEncoding,o.metalnessMap=e,o.roughnessMap=e})),n.textureLoader.load(ATON.PATH_RES+"models/aton-cube-nrm.png",(e=>{e.colorSpace=ATON._stdEncoding,o.normalMap=e}));let i=ATON.createSceneNode(e);return i.add(new THREE.Mesh(t)),i.setMaterial(o),i.enablePicking(),i},createGround:(e,t,o)=>{void 0===t&&(t=1),void 0===o&&(o=1);let i=new THREE.PlaneGeometry(t,o),r=new THREE.MeshStandardMaterial;void 0!==e&&n.textureLoader.load(e,(e=>{e.colorSpace=ATON._stdEncoding,r.map=e}));let a=ATON.createSceneNode().rotateX(.5*-Math.PI);return a.add(new THREE.Mesh(i,r)),a.enablePicking(),a},convertByteArrayToHexString:e=>e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),""),convertHexStringToByteArray:e=>Uint8Array.from(e.match(/.{1,2}/g).map((e=>parseInt(e,16))))};const s=n;let l={MODE_ADD:0,MODE_DEL:1,FLOAT_PREC:5,init:()=>{l.currID=void 0,l.currData=void 0,l._bEdit=!1,l._bLoading=!1,l._title=void 0,l._descr=void 0,l.initBaseParsers()},setEditMode:e=>{l._bEdit=e,console.log("Edit mode:"+e)},load:(e,t,o)=>(l._bLoading=!0,console.log("Loading Scene: "+t),$.getJSON(e,(e=>{l.currData=e,l.currID=t,l._bLoading=!1,l.parseScene(e),o&&o(),ATON.fire("SceneJSONLoaded",t)}))),clearScene:()=>{if(!(ATON._rootVisible.children.length<=0)){ATON._rootVisible.removeChildren();for(let e in ATON.snodes)e!==ATON.ROOT_NID&&delete ATON.snodes[e];ATON.MRes.clear(),ATON.XPFNetwork.clear()}},clearSemantics:()=>{if(!(ATON._rootSem.children.length<=0)){ATON._rootSem.removeChildren();for(let e in ATON.semnodes)e!==ATON.ROOT_NID&&delete ATON.semnodes[e];ATON.SUI.gSemIcons&&ATON.SUI.gSemIcons.removeChildren(),ATON.SemFactory.stopCurrentConvex(),ATON.SemFactory.init()}},clear:()=>{l.clearScene(),l.clearSemantics(),ATON.Nav.clear()},parseScene:e=>{if(void 0!==(e=void 0===e?l.currData:e))for(let t in e)l._jsonParsers[t]&&l._jsonParsers[t](e[t])},getJSONchildren:(e,t)=>{let o;void 0===t&&(t=ATON.NTYPES.SCENE);let i=[];if(t===ATON.NTYPES.SEM&&(o=ATON.getSemanticNode(e)),t===ATON.NTYPES.SCENE&&(o=ATON.getSceneNode(e)),void 0!==o){for(let e in o.children){let t=o.children[e];void 0!==t.nid&&i.push(t.nid)}return i}},getJSONgraphEdges:e=>{void 0===e&&(e=ATON.NTYPES.SCENE);let t=ATON.snodes;e===ATON.NTYPES.SEM&&(t=ATON.semnodes),e===ATON.NTYPES.UI&&(t=ATON.uinodes);let o={};for(let e in t){let i=t[e];i&&i.parent&&i.parent.nid&&(void 0===o[i.parent.nid]&&(o[i.parent.nid]=[]),o[i.parent.nid].push(i.nid))}return o},getJSONsemanticSpheresList:e=>{let t=ATON.getSemanticNode(e);if(void 0===t)return;let o=[];for(let e in t.children){let i=t.children[e];i.type&&o.push([parseFloat(i.position.x.toPrecision(l.FLOAT_PREC)),parseFloat(i.position.y.toPrecision(l.FLOAT_PREC)),parseFloat(i.position.z.toPrecision(l.FLOAT_PREC)),parseFloat(i.scale.x.toPrecision(l.FLOAT_PREC))])}return o},getJSONsemanticConvexShapes:e=>{let t=ATON.getSemanticNode(e);if(void 0===t)return;let o=[];for(let e in t.children){let i=t.children[e];i.userData._convexPoints&&o.push(i.userData._convexPoints)}return o},_applyJSONTransformToNode:(e,t)=>{if(void 0!==e&&void 0!==t){if(e.bUseGeoCoords)return t.bUseGeoCoords=!0,void(e.scale&&t.setScale(e.scale[0],e.scale[1],e.scale[2]));e.autocenter?t.autocenter=!0:e.position&&t.setPosition(e.position[0],e.position[1],e.position[2]),e.rotation&&t.setRotation(e.rotation[0],e.rotation[1],e.rotation[2]),e.scale&&t.setScale(e.scale[0],e.scale[1],e.scale[2]),e.list&&Array.isArray(e.list)}},initBaseParsers:()=>{l._jsonParsers={},l._jsonParsers.title=e=>{void 0!==e&&l.setTitle(e)},l._jsonParsers.description=e=>{void 0!==e&&l.setDescription(e)},l._jsonParsers.fx=e=>{e.ao&&(ATON.FX.togglePass(ATON.FX.PASS_AO,!0),e.ao.i&&ATON.FX.setAOintensity(parseFloat(e.ao.i))),e.bloom&&(ATON.FX.togglePass(ATON.FX.PASS_BLOOM,!0),e.bloom.i&&ATON.FX.setBloomStrength(parseFloat(e.bloom.i)),e.bloom.t&&ATON.FX.setBloomThreshold(parseFloat(e.bloom.t))),e.dof&&(ATON.FX.togglePass(ATON.FX.PASS_DOF,!0),e.dof.f&&ATON.FX.setDOFfocus(parseFloat(e.dof.f)))},l._jsonParsers.environment=e=>{let t=e.mainpano;if(e.mainpano&&(t.url&&ATON.setMainPanorama(t.url),t.rotation&&ATON.setMainPanoramaRotation(t.rotation)),e.bgcolor){let t=new THREE.Color(e.bgcolor[0],e.bgcolor[1],e.bgcolor[2]);ATON.setBackgroundColor(t)}let o=e.mainlight;o?(o.direction&&ATON.setMainLightDirection(new THREE.Vector3(o.direction[0],o.direction[1],o.direction[2])),ATON._dMainL?(o.color&&(ATON._dMainL.color=new THREE.Color(o.color[0],o.color[1],o.color[2])),o.intensity&&(ATON._dMainL.intensity=o.intensity),void 0!==o.shadows?ATON.toggleShadows(o.shadows):ATON.toggleShadows(!1)):ATON.toggleMainLight(!1)):ATON.toggleMainLight(!1);let i=e.lightprobes;if(i&&(void 0!==i.auto&&ATON.setAutoLP(i.auto),i.list))for(let e in i.list){let t=i.list[e],o=new ATON.LightProbe(t.res);t.pos&&o.setPosition(parseFloat(t.pos[0]),parseFloat(t.pos[1]),parseFloat(t.pos[2])),t.near&&o.setNear(parseFloat(t.near)),t.far&&o.setFar(parseFloat(t.far)),ATON.addLightProbe(o),console.log(o)}e.exposure&&ATON.setExposure(e.exposure)},l._jsonParsers.soundscape=e=>{void 0!==e&&e.global&&ATON.setGlobalAudio(e.global.url,e.global.loop)},l._jsonParsers.navmode=e=>{void 0!==e&&ATON.Nav.setNavMode(e)},l._jsonParsers.locomotionGraph=e=>{if(void 0!==e){for(let t in e){let o=e[t];o.pos&&ATON.Nav.addLocomotionNode(parseFloat(o.pos[0]),parseFloat(o.pos[1]),parseFloat(o.pos[2]),!0)}ATON.Nav.setFirstPersonControl(),ATON.Nav.toggleLocomotionValidator(!1)}},l._jsonParsers.measurements=e=>{if(void 0!==e)for(let t in e){let o=e[t];if(o.points&&6===o.points.length){let e=new THREE.Vector3(parseFloat(o.points[0]),parseFloat(o.points[1]),parseFloat(o.points[2])),t=new THREE.Vector3(parseFloat(o.points[3]),parseFloat(o.points[4]),parseFloat(o.points[5]));ATON.SUI.addMeasurementPoint(e),ATON.SUI.addMeasurementPoint(t)}}},l._jsonParsers.viewpoints=e=>{if(void 0!==e)for(let t in e){let o=e[t];"home"===t?ATON.Nav.setHomePOV((new ATON.POV).setPosition(o.position[0],o.position[1],o.position[2]).setTarget(o.target[0],o.target[1],o.target[2]).setFOV(o.fov)):new ATON.POV(t).setPosition(o.position[0],o.position[1],o.position[2]).setTarget(o.target[0],o.target[1],o.target[2]).setFOV(o.fov)}},l._jsonParsers.scenegraph=e=>{if(void 0===e)return;let t=e.nodes,o=e.edges;for(let e in t){let o=t[e],i=ATON.getOrCreateSceneNode(e).removeChildren();l._applyJSONTransformToNode(o.transform,i);let r=o.urls;if(r&&(Array.isArray(r)?r.forEach((e=>{i.load(e)})):i.load(r)),o["cesium.ion"]){let e=o["cesium.ion"];ATON.MRes.loadCesiumIONAsset(e,i)}if(o.stream){let t,r=o.stream;if(r.src.startsWith("#")){let e=parseInt(r.src.substring(1));t=ATON.MediaFlow.getOrCreateVideoStream(e,void 0,!0)}else{let o=ATON.Utils.resolveCollectionURL(r.src);t=ATON.MediaFlow.getOrCreateVideoStream(e,o)}if(r.chromakey){let e=r.chromakey.color;e&&t.matStream.uniforms.keycolor.value.set(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])),r.chromakey.smoothness&&(t.matStream.uniforms.smoothness.value=parseFloat(r.chromakey.smoothness)),r.chromakey.spill&&(t.matStream.uniforms.spill.value=parseFloat(r.chromakey.spill)),r.chromakey.similarity&&(t.matStream.uniforms.similarity.value=parseFloat(r.chromakey.similarity))}if(!o.urls){let e=new THREE.PlaneGeometry(1,1),o=new THREE.Mesh(e);o.scale.x=1,o.scale.y=-1,t.el.addEventListener("loadedmetadata",(e=>{let i=t.el.videoWidth/t.el.videoHeight;o.scale.x=i,o.scale.y=-1})),ATON.Utils.modelVisitor(i,o),i.add(o),ATON._bqScene=!0,i.setPickable(!0),i.dirtyBound()}i.setMaterial(t.matStream)}o.shadowcast&&i.setShadowCast(o.shadowcast),o.shadowreceive&&i.setShadowCast(o.shadowreceive),o.toYup&&i.setYup(),o.keywords&&(i.kwords=o.keywords)}for(let e in o){let t=o[e],i=ATON.getSceneNode(e);if(void 0!==i)for(let e in t){let o=t[e],r=ATON.getSceneNode(o);void 0!==r&&r.attachTo(i)}}for(let e in t){let o=t[e],i=ATON.getSceneNode(e);if(void 0!==i&&(void 0!==o.show&&(o.show?(i.show(),console.log("show "+e)):(i.hide(),console.log("hide "+e))),o.material)){let e;"string"==typeof o.material?e=ATON.MatHub.materials[o.material]:o.material.fragmentShader||o.material.vertexShader?(o.material.vertexShader||(o.material.vertexShader=ATON.MatHub.getDefVertexShader()),e=new THREE.ShaderMaterial(o.material)):e=new THREE.MeshStandardMaterial(o.material),e&&i.setMaterial(e)}}},l._jsonParsers.semanticgraph=e=>{if(void 0===e)return;let t=e.nodes,o=e.edges;for(let e in t){let o=t[e],i=ATON.getOrCreateSemanticNode(e).removeChildren(),r=o.urls;r&&(Array.isArray(r)?r.forEach((e=>{i.load(e)})):i.load(r)),o.toYup&&i.setYup(),o.description&&i.setDescription(o.description),o.audio&&i.setAudio(o.audio),o.keywords&&(i.kwords=o.keywords);let a=o.spheres;if(Array.isArray(a))for(let t in a){let o=a[t],i=new THREE.Vector3(parseFloat(o[0]),parseFloat(o[1]),parseFloat(o[2]));ATON.SemFactory.createSphere(e,i,parseFloat(o[3]))}let n=o.convexshapes;if(Array.isArray(n))for(let t in n){let o=n[t],i=[];for(let e=0;e{if(ATON.Nav.setFirstPersonControl(),e.list){let t=e.list,o=t.length;for(let e=0;e{ATON.XPFNetwork.setHomeXPF(0),ATON.XPFNetwork.requestTransitionByIndex(0,0)}))}},addSceneParser:(e,t)=>{l._jsonParsers[e]=t},patch:(e,t,o)=>{if(l._bLoading||!l._bEdit)return;if(void 0===e)return;void 0===t&&(t=l.MODE_ADD);let i=l.currID,r={};r.data=e,r.mode=t===l.MODE_DEL?"DEL":"ADD";let a=JSON.stringify(r);e=null,r=null,$.ajax({url:ATON.PATH_RESTAPI2+"scenes/"+i,type:"PATCH",data:a,contentType:"application/json; charset=utf-8",dataType:"json",success:e=>{e&&(l.currData=e),o&&o()}})}};l.sendEdit=l.patch,l.setVisibility=(e,t)=>{l.currData.visibility=e,l.sendEdit({visibility:e},ATON.SceneHub.MODE_ADD,t)},l.currSceneHasHomeConfig=()=>void 0!==l.currData&&void 0!==l.currData.viewpoints&&void 0!==l.currData.viewpoints.home,l.setTitle=e=>{l._title=e},l.getTitle=()=>l._title,l.setDescription=e=>{l._descr=e},l.getDescription=()=>l._descr;const d=l;let c={init:()=>{c._listener=new THREE.AudioListener,c._loader=new THREE.AudioLoader,c._bGenAuPlaying=!1},playOnceGlobally:(e,t)=>{if(t&&c._bGenAuPlaying)return;e=ATON.Utils.resolveCollectionURL(e);let o=new THREE.Audio(ATON.AudioHub._listener);return c._loader.load(e,(e=>{o.setBuffer(e),o.play(),t&&(c._bGenAuPlaying=!0)})),t&&(o.onEnded=()=>{c._bGenAuPlaying=!1}),o}};const u=c;class p extends THREE.EventDispatcher{constructor(e){super(),!1===window.isSecureContext&&console.error("DeviceOrientationEvent is only available in secure contexts (https)"),this._zee=new THREE.Vector3(0,0,1),this._euler=new THREE.Euler,this._q0=new THREE.Quaternion,this._q1=new THREE.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._changeEvent={type:"change"};const t=this,o=new THREE.Quaternion;this.object=e,this.object.rotation.reorder("YXZ"),this.enabled=!0,this.deviceOrientation={},this.screenOrientation=0,this.alphaOffset=0;const i=function(e){t.deviceOrientation=e},r=function(){t.screenOrientation=window.orientation||0};this.connect=function(){r(),void 0!==window.DeviceOrientationEvent&&"function"==typeof window.DeviceOrientationEvent.requestPermission?window.DeviceOrientationEvent.requestPermission().then((function(e){"granted"==e&&(window.addEventListener("orientationchange",r),window.addEventListener("deviceorientation",i))})).catch((function(e){console.error("Unable to use DeviceOrientation API:",e)})):(window.addEventListener("orientationchange",r),window.addEventListener("deviceorientation",i)),t.enabled=!0},this.disconnect=function(){window.removeEventListener("orientationchange",r),window.removeEventListener("deviceorientation",i),t.enabled=!1},this.update=function(){if(!1===t.enabled)return;const e=t.deviceOrientation;if(e){const i=e.alpha?THREE.MathUtils.degToRad(e.alpha)+t.alphaOffset:0,r=e.beta?THREE.MathUtils.degToRad(e.beta):0,a=e.gamma?THREE.MathUtils.degToRad(e.gamma):0,n=t.screenOrientation?THREE.MathUtils.degToRad(t.screenOrientation):0;!function(e,o,i,r,a){t._euler.set(i,o,-r,"YXZ"),e.setFromEuler(t._euler),e.multiply(t._q1),e.multiply(t._q0.setFromAxisAngle(t._zee,-a))}(t.object.quaternion,i,r,a,n),8*(1-o.dot(t.object.quaternion))>1e-6&&(o.copy(t.object.quaternion),t.dispatchEvent(t._changeEvent))}},this.dispose=function(){t.disconnect()},this.connect()}}const _=p;let m={STD_FOV:50,STD_NEAR:.01,STD_FAR:800,FP_EPS:.01,STD_POV_TRANS_DURATION:2,STD_LOCNODE_SIZE:.5,MIN_LOC_VALID_DIST:1.5,MODE_ORBIT:0,MODE_FP:1,MODE_DEVORI:2,LocomotionNode:class{constructor(e){this.pos=new THREE.Vector3(0,0,0),this.id=e,this._iXPF=void 0,this._sui=void 0}setLocation(e,t,o){return e instanceof THREE.Vector3?this.pos.copy(e):this.pos.set(e,t,o),this._sui&&this._sui.position.copy(this.pos),this}getLocation(){return this.pos}realizeSUI(e){return void 0===ATON.SUI.gLocNodes||(this._sui=new THREE.Sprite(ATON.SUI.getOrCreateSpriteWalk()),this._sui.position.copy(this.pos),this._sui.scale.set(ATON.Nav.STD_LOCNODE_SIZE,ATON.Nav.STD_LOCNODE_SIZE,ATON.Nav.STD_LOCNODE_SIZE),ATON.SUI.gLocNodes.add(this._sui)),this}toggleSUI(e){return void 0===this._sui||(this._sui.visible=e),this}},init:()=>{m._mode=void 0,m.POVtransitionDuration=m.STD_POV_TRANS_DURATION,m._rotSpeedOrbit=.4,m._rotSpeedFP=-.2,m._inertia=.08,m._bControl=!0,m._bLocValidator=!0,m._bInteracting=!1,m._prevMode=void 0,m.setOrbitControl(),m._currPOV=(new ATON.POV).setPosition(0,0,0).setTarget(1,0,0).setFOV(ATON.Nav.STD_FOV),m._fromPOV=new ATON.POV,m._reqPOV=new ATON.POV,m.homePOV=void 0,m._tPOVcall=-1,m._tPOVprogress=0,m.povlist={},m._vDir=new THREE.Vector3(1,0,0),m._qOri=new THREE.Quaternion,m._lastPos=new THREE.Vector3(0,0,0),m._lastOri=new THREE.Quaternion,m._dOri=0,m._dPos=0,m._motionAmt=0,m._motionDir=new THREE.Vector3(0,1,0),m._bValidLocomotion=!1,m._locNodes=[],m._prevLN=void 0},getCurrentEyeLocation:()=>m._currPOV.pos,getCurrentDirection:()=>m._vDir,copyCurrentPOV:()=>{let e=new ATON.POV;return e.pos.copy(m._currPOV.pos),e.target.copy(m._currPOV.target),e.fov=m._currPOV.fov,e},addPOV:(e,t)=>{if(void 0!==e)return e.as(t),e},clearPOVs:()=>{for(let e in ATON.Nav.povlist)delete m.povlist[e]},isTransitioning:()=>m._tPOVcall>=0,currentQueryValidForLocomotion:()=>m._bValidLocomotion,locomotionValidator:()=>{if(void 0===ATON._queryDataScene)return void(m._bValidLocomotion=!1);let e=ATON._queryDataScene,t=(e.p,e.n);e.d<=m.MIN_LOC_VALID_DIST?m._bValidLocomotion=!1:t?t.y<=.7?m._bValidLocomotion=!1:m._bValidLocomotion=!0:m._bValidLocomotion=!1},toggleLocomotionValidator:e=>{e?m._bLocValidator=!0:(m._bLocValidator=!1,m._bValidLocomotion=!1)},addLocomotionNode:(e,t,o,i)=>{let r=(new m.LocomotionNode).setLocation(e,t,o);return i&&r.realizeSUI(),m._locNodes.push(r),ATON.fire("LocomotionNodeAdded",r),r},getLocomotionNodeByIndex:e=>m._locNodes[e],clearLocomotionNodes:()=>{m._locNodes=[],m._prevLN=void 0,ATON.SUI.gLocNodes&&ATON.SUI.gLocNodes.removeChildren()},getLocomotionNodeInSight:()=>{let e=m._locNodes.length;if(e<=0)return;if(m.isTransitioning())return;let t,o,i=m._currPOV.pos,r=m._vDir;void 0===m._dirLNode&&(m._dirLNode=new THREE.Vector3);for(let a=0;a.8){let e=i.distanceToSquared(m._posLNode);e>.3&&(void 0===o||e{if(void 0===e)return;if(m._mode===m.MODE_ORBIT)return;let o=ATON.Nav._vDir,i=(new ATON.POV).setPosition(e.pos).setTarget(e.pos.x+o.x,e.pos.y+o.y,e.pos.z+o.z).setFOV(m._currPOV.fov);e.toggleSUI(!1),void 0!==m._prevLN&&m._prevLN.toggleSUI(!0),m.requestPOV(i,t),m._prevLN=e,ATON.fire("LocomotionNodeRequested",e)},requestTransitionToLocomotionNodeInSightIfAny:e=>{let t=ATON.XPFNetwork.getNextXPFindex();if(void 0!==t)return m.requestTransitionToLocomotionNode(ATON.XPFNetwork._list[t]._lnode,e),!0;let o=ATON.Nav.getLocomotionNodeInSight();if(void 0===o)return!1;let i=m._locNodes[o];return m.requestTransitionToLocomotionNode(i,e),!0},requestDeltaRotation:(e,t,o)=>{if(ATON.XR._bPresenting)return;let i=new THREE.Vector3,r=new THREE.Vector3;i.crossVectors(m._vDir,THREE.Object3D.DEFAULT_UP),r.x=m._currPOV.target.x+i.x*e,r.y=m._currPOV.target.y+t,r.z=m._currPOV.target.z+i.z*e;let a=new ATON.POV;a.setTarget(r),a.setPosition(ATON.Nav._currPOV.pos),ATON.Nav.requestPOV(a,o)},setUserControl:e=>{void 0!==e&&e!==m._bControl&&(m._bControl=e,void 0!==m._controls&&(m._controls.enabled=e),m._cOrbit&&(m._cOrbit.enabled=e),m._cFirstPerson&&(m._cFirstPerson.enabled=e),console.log("Nav controls: "+m._bControl))},toggleUserControl:()=>{m.setUserControl(!m._bControl)},isUserControlEnabled:()=>m._bControl,isOrbit:()=>!ATON.XR._bPresenting&&m._mode===m.MODE_ORBIT,isFirstPerson:()=>!ATON.XR._bPresenting&&m._mode===m.MODE_FP,isDevOri:()=>!ATON.XR._bPresenting&&m._mode===m.MODE_DEVORI,setNavMode:e=>{void 0!==e&&(e===m.MODE_ORBIT&&m.setOrbitControl(),e===m.MODE_FP&&m.setFirstPersonControl(),e===m.MODE_DEVORI&&m.setDeviceOrientationControl())},restorePreviousNavMode:()=>{void 0===m._prevMode&&m.setOrbitControl(),m.setNavMode(m._prevMode)},_updCamera:e=>{if(void 0===e&&(e=m._camera),ATON.FX.composer){let t=ATON.FX.composer.passes;if(t)for(let o=0;o{if(!ATON.XR.isPresenting()){if(m._prevMode=m._mode,m._mode=m.MODE_ORBIT,m._bInteracting=!1,ATON.fire("NavInteraction",!1),void 0===m._cOrbit){m._camOrbit=new THREE.PerspectiveCamera(m.STD_FOV,window.innerWidth/window.innerHeight,m.STD_NEAR,m.STD_FAR),m._camOrbit.layers.enableAll(),m._cOrbit=new THREE.OrbitControls(m._camOrbit,ATON._renderer.domElement);let e=m._cOrbit;e.rotateSpeed=m._rotSpeedOrbit,e.enablePan=!0,m._inertia>0&&(e.enableDamping=!0,e.dampingFactor=m._inertia),e.screenSpacePanning=!0,e.enableZoom=!0,e.minDistance=.03,e.maxDistance=300,m._bControl||(e.enabled=!1),e.addEventListener("start",(()=>{m._bInteracting=!0,ATON.fire("NavInteraction",!0)})),e.addEventListener("end",(()=>{m._bInteracting=!1,ATON.fire("NavInteraction",!1)}))}m._controls=m._cOrbit,m._camera=m._camOrbit,ATON.AudioHub._listener&&m._camera.children.length<1&&m._camera.add(ATON.AudioHub._listener),m._updCamera(),m._controls.update(),m._currPOV&&m.syncCurrCamera(),ATON._onResize(),ATON.toggleCenteredQuery(!1),ATON.fire("NavMode",m._mode)}},setFirstPersonControl:()=>{if(!ATON.XR.isPresenting()){if(m._prevMode=m._mode,ATON.SUI.getSelectorRadius()>.1&&ATON.SUI.setSelectorRadius(.1),m._mode=m.MODE_FP,m._bInteracting=!1,ATON.fire("NavInteraction",!1),void 0===m._cFirstPerson){m._camFP=new THREE.PerspectiveCamera(m.STD_FOV,window.innerWidth/window.innerHeight,m.STD_NEAR,m.STD_FAR),m._camFP.layers.enableAll(),m._cFirstPerson=new THREE.OrbitControls(m._camFP,ATON._renderer.domElement);let e=m._cFirstPerson;e.enableZoom=!1,e.enablePan=!1,e.rotateSpeed=m._rotSpeedFP,m._inertia>0&&(e.enableDamping=!0,e.dampingFactor=m._inertia),e.target.copy(m._camera.position),e.minDistance=.01,e.maxDistance=.01,m._bControl||(e.enabled=!1)}m._controls=m._cFirstPerson,m._camera=m._camFP,ATON.AudioHub._listener&&m._camera.children.length<1&&m._camera.add(ATON.AudioHub._listener),m._updCamera(),m._controls.update(),m._currPOV&&m.syncCurrCamera(),ATON._onResize(),ATON.toggleCenteredQuery(!1),ATON.fire("NavMode",m._mode)}},setDeviceOrientationControl:()=>{ATON.Utils.isMobile()&&(m._prevMode=m._mode,m._mode=m.MODE_DEVORI,m._bInteracting=!1,ATON.fire("NavInteraction",!1),ATON._screenPointerCoords.set(0,0),void 0===m._cDevOri&&(m._camDevOri=new THREE.PerspectiveCamera(m.STD_FOV,window.innerWidth/window.innerHeight,m.STD_NEAR,m.STD_FAR),m._camDevOri.layers.enableAll(),m._cDevOri=new _(m._camDevOri,ATON._renderer.domElement),m._cDevOri.alphaOffset=0),m._controls=m._cDevOri,m._camera=m._camDevOri,ATON.AudioHub._listener&&m._camera.children.length<1&&m._camera.add(ATON.AudioHub._listener),m._updCamera(),m._controls.update(),m._currPOV&&m.syncCurrCamera(),ATON._onResize(),ATON.toggleCenteredQuery(!0),ATON.fire("NavMode",m._mode))},useAbsoluteOrientation:e=>{m._cDevOri},setMotionAmount:e=>{m._motionAmt=e},setMotionDirection:e=>{m._motionDir.copy(e)},stop:()=>{m._motionAmt=0},setFOV:e=>{if(ATON.XR.isPresenting())return;m._currPOV.fov=e;let t=m._camera;t.fov=e,t.updateProjectionMatrix()},getFOV:()=>m._currPOV.fov,_deltaMotions:()=>{m._dOri=m._lastOri.angleTo(ATON.Nav._qOri),m._dPos=m._lastPos.distanceToSquared(m._currPOV.pos),m._lastPos.copy(m._currPOV.pos),m._lastOri.copy(ATON.Nav._qOri)},syncCurrPOV:()=>{if(ATON.XR.isPresenting()){const e=ATON._renderer.xr.getCamera().cameras[0];return m._currPOV.pos.copy(e.position),m._qOri.copy(e.quaternion),e.getWorldDirection(m._vDir),m._currPOV.pos.x+=ATON.XR.rig.position.x,m._currPOV.pos.y+=ATON.XR.rig.position.y,m._currPOV.pos.z+=ATON.XR.rig.position.z,void m._deltaMotions()}const e=m._controls,t=m._camera;if(t.getWorldDirection(m._vDir),t.getWorldQuaternion(m._qOri),m._deltaMotions(),m._mode!==m.MODE_DEVORI){if(m._mode===m.MODE_FP)return m._currPOV.pos.copy(e.target),m._currPOV.target.x=m._currPOV.pos.x+m._vDir.x,m._currPOV.target.y=m._currPOV.pos.y+m._vDir.y,void(m._currPOV.target.z=m._currPOV.pos.z+m._vDir.z);m._currPOV.pos.copy(t.position),m._currPOV.target.copy(e.target)}else m._currPOV.pos.copy(t.position)},applyPOVconstraints:e=>{},handlePOV:()=>{ATON.XR.isPresenting()?m.handleXRtransition():m.handlePOVtransition(),m.handleMotion(),m.applyPOVconstraints(m._currPOV)},handleMotion:()=>{if(m.isTransitioning())return;if(0==m._motionAmt)return;ATON.XR.controller0&&ATON.XR.controller0.visible?(ATON.XR.controller0.getWorldDirection(m._motionDir),m._motionDir.negate()):m._motionDir.copy(m._vDir);let e=m._motionAmt*ATON._dt,t=m._motionDir.x*e,o=m._motionDir.y*e,i=m._motionDir.z*e;m._currPOV.pos.x+=t,m._currPOV.pos.y+=o,m._currPOV.pos.z+=i,m._currPOV.target.x+=t,m._currPOV.target.y+=o,m._currPOV.target.z+=i},handlePOVtransition:()=>{if(!(m._tPOVcall<0)){if(m.POVtransitionDuration<=0?m._tPOVprogress=1:m._tPOVprogress=(ATON._clock.elapsedTime-m._tPOVcall)/m.POVtransitionDuration,m._tPOVprogress>=1)return m._tPOVcall=-1,m._currPOV.pos.copy(m._reqPOV.pos),m._currPOV.target.copy(m._reqPOV.target),m._currPOV.fov=m._reqPOV.fov,void ATON.fire("POVTransitionCompleted",m._reqPOV.id);var e;m._tPOVprogress=(e=m._tPOVprogress,(1-Math.cos(e*Math.PI))/2),m._currPOV.pos.lerpVectors(m._fromPOV.pos,m._reqPOV.pos,m._tPOVprogress),m._currPOV.target.lerpVectors(m._fromPOV.target,m._reqPOV.target,m._tPOVprogress),m._fromPOV.fov&&m._reqPOV.fov&&(m._currPOV.fov=THREE.MathUtils.lerp(m._fromPOV.fov,m._reqPOV.fov,m._tPOVprogress),m._camera.fov=m._currPOV.fov,m._camera.updateProjectionMatrix())}},handleXRtransition:()=>{if(!(m._tPOVcall<0)){if(m.POVtransitionDuration<=0?m._tPOVprogress=1:m._tPOVprogress=(ATON._clock.elapsedTime-m._tPOVcall)/m.POVtransitionDuration,m._tPOVprogress>=1)return m._tPOVcall=-1,ATON.XR._currPos.copy(ATON.XR._reqPos),void ATON.fire("POVTransitionCompleted",m._reqPOV.id);ATON.XR._currPos.lerpVectors(ATON.XR._fromPos,ATON.XR._reqPos,m._tPOVprogress)}},syncCurrCamera:()=>{if(ATON.XR.isPresenting())return;let e=m._controls,t=m._camera,o=m._currPOV.pos,i=m._currPOV.target;m._mode!==m.MODE_DEVORI?(m._vDir.subVectors(i,o),m._vDir.normalize(),m._mode===m.MODE_FP?(e.target.copy(o),t.position.x=e.target.x-m._vDir.x*m.FP_EPS,t.position.y=e.target.y-m._vDir.y*m.FP_EPS,t.position.z=e.target.z-m._vDir.z*m.FP_EPS):(t.position.copy(o),e.target.copy(i))):t.position.copy(o)},update:()=>{m.syncCurrPOV(),m.handlePOV(),m.syncCurrCamera()},requestPOV:(e,t,o)=>{ATON._tPOVcall>=0||void 0!==e&&(ATON.XR._bPresenting&&"immersive-ar"===ATON.XR._sessionType||(m.POVtransitionDuration=void 0!==t?t:m.STD_POV_TRANS_DURATION,ATON.XR.isPresenting()?(m._reqPOV.pos.copy(e.pos?e.pos:m._currPOV.pos),m._fromPOV.pos.copy(m._currPOV.pos),ATON.XR._reqPos.copy(e.pos?e.pos:m._currPOV.pos),ATON.XR._fromPos.copy(ATON.XR._currPos)):(m._reqPOV.pos.copy(e.pos?e.pos:m._currPOV.pos),m._reqPOV.target.copy(e.target?e.target:m._currPOV.target),m._reqPOV.fov=e.fov?e.fov:m._currPOV.fov,m._fromPOV.pos.copy(m._currPOV.pos),m._fromPOV.target.copy(m._currPOV.target),m._fromPOV.fov=m._currPOV.fov),o&&(e.pos&&(m._reqPOV.pos.x*=ATON._worldScale,m._reqPOV.pos.y*=ATON._worldScale,m._reqPOV.pos.z*=ATON._worldScale,ATON.XR.isPresenting()&&(ATON.XR._reqPos.x*=ATON._worldScale,ATON.XR._reqPos.y*=ATON._worldScale,ATON.XR._reqPos.z*=ATON._worldScale)),e.target&&(m._reqPOV.target.x*=ATON._worldScale,m._reqPOV.target.y*=ATON._worldScale,m._reqPOV.target.z*=ATON._worldScale)),m._tPOVcall=ATON._clock.elapsedTime,ATON.fire("POVTransitionRequested",e.id)))},requestPOVbyBound:(e,t)=>{if(void 0===e)return;let o=new THREE.Vector3,i=3*e.radius;o.x=e.center.x-i*m._vDir.x,o.y=e.center.y-i*m._vDir.y,o.z=e.center.z-i*m._vDir.z;let r=(new ATON.POV).setPosition(o).setTarget(e.center);m.requestPOV(r,t)},requestPOVbyNode:(e,t)=>{if(void 0===e)return;let o=e.getBound();m.requestPOVbyBound(o,t)},requestPOVbyID:(e,t)=>{if(void 0===e)return;let o=m.povlist[e];void 0!==o&&m.requestPOV(o,t)},requestRetarget:(e,t,o)=>{let i=new THREE.Vector3;if(void 0===t)i.lerpVectors(e,m._currPOV.pos,.8);else{let o=e.distanceTo(m._currPOV.pos);o*=.5,i.x=e.x+t.x*o,i.y=e.y+t.y*o,i.z=e.z+t.z*o}let r=e.distanceTo(i);ATON.FX.setDOFfocus(r);let a=(new ATON.POV).setPosition(i).setTarget(e).setFOV(m._currPOV.fov);m.requestPOV(a,o),console.log(a)},computeDefaultHome:(e,t)=>{void 0===e&&(e=new THREE.Vector3(1,.7,1)),void 0===t&&(t=ATON.getRootScene().getBound());let o=new THREE.Vector3(t.center.x+t.radius*e.x*1.5,t.center.y+t.radius*e.y*1.5,t.center.z+t.radius*e.z*1.5);m.homePOV=(new ATON.POV).setPosition(o).setTarget(t.center)},setHomePOV:e=>{m.homePOV=e},computeAndRequestDefaultHome:(e,t,o)=>{m.computeDefaultHome(t,o),m.requestPOV(m.homePOV,e)},requestHomePOV:e=>{m.requestPOV(m.homePOV,e)}};m.requestHome=m.requestHomePOV,m.setAndRequestHomePOV=(e,t)=>{m.setHomePOV(e),m.requestPOV(e,t)},m.clear=()=>{m.clearPOVs(),m.clearLocomotionNodes()},m.DeviceOrientationControls=function(e){let t=this;this.object=e,this.object.rotation.reorder("YXZ"),this.enabled=!0,this.deviceOrientation={},this.screenOrientation=0,this.alphaOffset=0,this.absolute=!1,this.alphaOffsetDevice=void 0,this.alphaOffsetScreen=void 0;let o=function(e){t.absolute||(t.deviceOrientation=e)},i=function(e){t.deviceOrientation=e,t.absolute=!0},r=function(){t.screenOrientation=window.orientation||0},a=function(){let e=new THREE.Vector3(0,0,1),t=new THREE.Euler,o=new THREE.Quaternion,i=new THREE.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5));return function(r,a,n,s,l){t.set(n,a,-s,"YXZ"),r.setFromEuler(t),r.multiply(i),r.multiply(o.setFromAxisAngle(e,-l))}}();this.connect=function(){r(),window.addEventListener("orientationchange",r,!1),window.addEventListener("deviceorientation",o,!1),window.addEventListener("deviceorientationabsolute",i,!1),t.enabled=!0},this.disconnect=function(){window.removeEventListener("orientationchange",r,!1),window.removeEventListener("deviceorientation",o,!1),window.removeEventListener("deviceorientationabsolute",i,!1),t.enabled=!1},this.update=function(){if(!1===t.enabled)return;let e;if(e=t.deviceOrientation,e){let o=this.getDirection()?THREE.Math.degToRad(this.getDirection())+t.alphaOffset:0,i=e.beta?THREE.Math.degToRad(e.beta):0,r=e.gamma?THREE.Math.degToRad(e.gamma):0,n=t.screenOrientation?THREE.Math.degToRad(t.screenOrientation):0;a(t.object.quaternion,o,i,r,n)}},this.dispose=()=>{t.disconnect()},this.iOSOrientationPermission=()=>{"function"==typeof DeviceOrientationEvent.requestPermission&&DeviceOrientationEvent.requestPermission().then((e=>{console.log(e)})).catch(console.error)},this.getDirection=()=>void 0!==t.deviceOrientation.webkitCompassHeading?t.deviceOrientation.webkitCompassHeading:t.deviceOrientation.alpha,this.getDirectionMap=()=>void 0!==t.deviceOrientation.webkitCompassHeading?360-t.deviceOrientation.webkitCompassHeading:t.deviceOrientation.alpha,this.connect()};const h=m;let T={STD_TELEP_DURATION:.03,HAND_R:0,HAND_L:1,MOBILE_DENSITY_F:.5,MAX_QUERY_DISTANCE:40,init:()=>{ATON._renderer.xr.enabled=!0,ATON._renderer.xr.setReferenceSpaceType("local"),ATON.device.isMobile?ATON._renderer.xr.setFramebufferScaleFactor(ATON._stdpxd*T.MOBILE_DENSITY_F):ATON._renderer.xr.setFramebufferScaleFactor(ATON._stdpxd),T._bPresenting=!1,T.currSession=null,T._sessionType="immersive-vr",T._bReqPresenting=!1,T.rig=new THREE.Group,T.rig.add(ATON.Nav._camera),ATON._rootUI.add(T.rig),T._cam=void 0,T._currPos=T.rig.position,T._fromPos=new THREE.Vector3,T._reqPos=new THREE.Vector3,T.gControllers=void 0,T.controller0=void 0,T.controller1=void 0,T.controller0pos=new THREE.Vector3,T.controller1pos=new THREE.Vector3,T.controller0dir=new THREE.Vector3,T.controller1dir=new THREE.Vector3,T._lastPosR=void 0,T._lastPosL=void 0,T._pointerLineGeom=void 0,T._pointerLineMesh=void 0,T.gpad0=void 0,T.gpad1=void 0,T._urlHand=ATON.PATH_RES+"models/hand/hand.glb",ATON.on("XRselectStart",(e=>{e===T.HAND_R&&ATON._stdActivation()})),ATON.on("XRselectEnd",(e=>{})),ATON.on("XRsqueezeStart",(e=>{e===T.HAND_R&&ATON.Photon.setFocusStreaming(!0)})),ATON.on("XRsqueezeEnd",(e=>{e===T.HAND_R&&ATON.Photon.setFocusStreaming(!1)})),ATON.on("VRC_IDassigned",(e=>{let t=ATON.getUINode("Rhand"),o=ATON.getUINode("Lhand"),i=ATON.MatHub.materials.avatars,r=i[e%i.length];o&&o.setMaterial(r),t&&t.setMaterial(r)}))},setSessionType:e=>{void 0!==e&&("immersive-vr"!==e&&"immersive-ar"!==e||(T._sessionType=e,console.log("Session type: "+e)))},isPresenting:()=>T._bPresenting,teleportOnQueriedPoint:()=>{if(!ATON.Nav.currentQueryValidForLocomotion())return!1;const e=ATON._queryDataScene.p;return ATON.Nav.requestPOV((new ATON.POV).setPosition(e.x,e.y+ATON.userHeight,e.z),T.STD_TELEP_DURATION),!0},setupQueryRay:e=>{void 0!==e&&(T.controller0?e.set(T.controller0pos,T.controller0dir):e.set(ATON.Nav.getCurrentEyeLocation(),ATON.Nav.getCurrentDirection()))},setRefSpaceLocation:e=>{T.rig.position.copy(e)},_setupControllerR:(e,t)=>{T.controller0||(T.controller0=e,console.log("R controller"),e.addEventListener("selectstart",(()=>{ATON.fire("XRselectStart",T.HAND_R)})),e.addEventListener("selectend",(()=>{ATON.fire("XRselectEnd",T.HAND_R)})),e.addEventListener("squeezestart",(()=>{ATON.fire("XRsqueezeStart",T.HAND_R)})),e.addEventListener("squeezeend",(()=>{ATON.fire("XRsqueezeEnd",T.HAND_R)})),T.setupControllerUI(T.HAND_R,t),ATON.fire("XRcontrollerConnected",T.HAND_R))},_setupControllerL:(e,t)=>{T.controller1||(T.controller1=e,console.log("L controller"),e.addEventListener("selectstart",(()=>{ATON.fire("XRselectStart",T.HAND_L)})),e.addEventListener("selectend",(()=>{ATON.fire("XRselectEnd",T.HAND_L)})),e.addEventListener("squeezestart",(()=>{ATON.fire("XRsqueezeStart",T.HAND_L)})),e.addEventListener("squeezeend",(()=>{ATON.fire("XRsqueezeEnd",T.HAND_L)})),T.setupControllerUI(T.HAND_L,t),ATON.fire("XRcontrollerConnected",T.HAND_L))},setupSceneForAR:()=>{if("immersive-ar"!==T._sessionType)return;ATON.recomputeSceneBounds();let e=ATON.bounds.center;ATON._rootVisible.position.x=-e.x,ATON._rootVisible.position.y=-e.y,ATON._rootVisible.position.z=-e.z,ATON._rootSem.position.x=-e.x,ATON._rootSem.position.y=-e.y,ATON._rootSem.position.z=-e.z,ATON.recomputeSceneBounds()},resetSceneOffsets:()=>{ATON._rootVisible.position.set(0,0,0),ATON._rootSem.position.set(0,0,0),ATON.recomputeSceneBounds()},onSessionStarted:e=>{T.currSession||(T._bReqPresenting=!1,e.addEventListener("end",T.onSessionEnded),e.isImmersive=!0,console.log(T._sessionType+" session started."),ATON.MediaFlow.stopAllStreams(),"immersive-ar"===T._sessionType&&ATON._renderer.xr.setReferenceSpaceType("local"),ATON._renderer.xr.setSession(e).then((()=>{if(T.currSession=e,console.log(T.currSession),"immersive-ar"===T._sessionType)ATON._mainRoot.background=null,ATON._mMainPano&&(ATON._mMainPano.visible=!1),ATON._renderer.xr.getController(0)&&ATON.device.isMobile&&(T.controller0=ATON._renderer.xr.getController(0),T.controller0.addEventListener("selectstart",(()=>{ATON.fire("XRselectStart",T.HAND_R),console.log("Head-aligned select")})),T.controller0.addEventListener("selectend",(()=>{ATON.fire("XRselectEnd",T.HAND_R)})),T.gControllers.add(T.controller0));else{for(let e=0;e<2;e++){const t=ATON._renderer.xr.getController(e);void 0===t||t.userData.bXRconfig||(t.visible=!1,t.userData.bXRconfig=!0,t.addEventListener("connected",(e=>{let o=e.data.handedness;t.gm=e.data.gamepad,console.log("Hand "+o),console.log("GamePad "+t.gm),"left"===o?T._setupControllerL(t,!0):"right"===o?T._setupControllerR(t,!0):(t.addEventListener("selectstart",(()=>{ATON.fire("XRselectStart",T.HAND_R),console.log("Head-aligned select")})),t.addEventListener("selectend",(()=>{ATON.fire("XRselectEnd",T.HAND_R)})),ATON.fire("XRcontrollerConnected",T.HAND_R))})))}T.rig.add(ATON.Nav._camera),T.setRefSpaceLocation(ATON.Nav._currPOV.pos)}let t=ATON._renderer.xr.getCamera(ATON.Nav._camera);ATON.Nav._updCamera(t),T._bPresenting=!0,ATON.Nav._bInteracting=!1,console.log("XR now presenting"),ATON.fire("XRmode",!0),ATON.rewindAllPlayingMedia(),ATON.toggleShadows(!1),ATON.SUI.getSelectorRadius()>ATON.FE.STD_SEL_RAD&&ATON.SUI.setSelectorRadius(ATON.FE.STD_SEL_RAD),ATON._qSyncInt=2,ATON.XPFNetwork.getNumXPFs()>0?ATON.setQueryRange(0,100):ATON.setQueryRange(0,T.MAX_QUERY_DISTANCE),ATON.MRes.estimateTSErrorTarget(),setTimeout((()=>{ATON.SUI.getSelectorRadius()>ATON.FE.STD_SEL_RAD&&ATON.SUI.setSelectorRadius(ATON.FE.STD_SEL_RAD)}),2e3)})))},onSessionEnded:()=>{T.currSession.removeEventListener("end",T.onSessionEnded),T.currSession=null,T._bReqPresenting=!1,T._bPresenting=!1,ATON.Nav._bInteracting=!1,"immersive-ar"===T._sessionType&&ATON._mMainPano&&(ATON._mMainPano.visible=!0),T.setRefSpaceLocation(new THREE.Vector3(0,0,0)),ATON.fire("XRmode",!1),ATON._qSyncInt=1,ATON.MediaFlow.stopAllStreams(),ATON.Nav.requestHome(),ATON.Nav._updCamera(),ATON.setQueryRange(0,1/0),ATON.MRes.estimateTSErrorTarget(),console.log("Quit XR")},toggle:e=>{if(T.setSessionType(e),ATON.device.xrSupported[T._sessionType])if(null===T.currSession){let e={optionalFeatures:["high-refresh-rate"]};"immersive-ar"===T._sessionType&&(void 0===e.optionalFeatures&&(e.optionalFeatures=[]),e.optionalFeatures.push("light-estimation")),T._bReqPresenting=!0,navigator.xr.requestSession(T._sessionType,e).then(T.onSessionStarted)}else T.currSession.end()},setupControllerUI:(e,t)=>{let o,i;if(void 0===T.gControllers&&(T.gControllers=ATON.createUINode(),T.gControllers.disablePicking(),T.rig.add(T.gControllers)),e===T.HAND_L?(T.gControllers.add(T.controller1),t&&(i=ATON.createUINode("Lhand").load(T._urlHand).setMaterial(ATON.MatHub.materials.controllerRay).setScale(-1,1,1),T.controller1.add(i))):(T.gControllers.add(T.controller0),t&&(T._pointerLineGeom=new THREE.CylinderGeometry(.003,.003,1,4),T._pointerLineGeom.rotateX(-Math.PI/2),T._pointerLineGeom.translate(0,0,-.5),T._pointerLineMesh=new THREE.Mesh(T._pointerLineGeom,ATON.MatHub.materials.controllerRay),T.controller0.add(T._pointerLineMesh),T._pointerLineMesh.visible=!1,o=ATON.createUINode("Rhand").load(T._urlHand).setMaterial(ATON.MatHub.materials.controllerRay),T.controller0.add(o))),void 0!==ATON.Photon.uid&&t){let t=ATON.MatHub.materials.avatars,r=t[ATON.Photon.uid%t.length];e===T.HAND_L?i.setMaterial(r):o.setMaterial(r)}},switchHands:()=>{let e=T.controller1;T.controller1=T.controller0,T.controller0=e;for(let e in T.controller0.children)T.controller0.remove(T.controller0.children[e]);for(let e in T.controller1.children)T.controller1.remove(T.controller1.children[e]);T.gControllers.removeChildren(),T.setupControllerUI(T.HAND_L),T.setupControllerUI(T.HAND_R),console.log("VR controllers switched")},getControllerSpace:e=>{1===e?T.getControllerGrip(1):T.getControllerGrip(0)},getControllerWorldLocation:e=>1===e?T.controller1pos:T.controller0pos,getControllerWorldDirection:e=>1===e?T.controller1dir:T.controller0dir,getControllerWorldOrientation:e=>{let t=new THREE.Quaternion;return 1===e?T.controller1.getWorldQuaternion(t):T.controller0.getWorldQuaternion(t),t},_deltaMotionController:e=>{if(e===T.HAND_L&&void 0===T._lastPosL)return;if(e===T.HAND_R&&void 0===T._lastPosR)return;let t=e===T.HAND_L?T.controller1pos:T.controller0pos,o=e===T.HAND_L?T._lastPosL:T._lastPosR;THREE.Vector3(t.x-o.x,t.y-o.y,t.z-o.z).lengthSq(),e===T.HAND_L?T._lastPosL=t:T._lastPosR=t},update:()=>{T.controller0&&T.controller0.visible&&(T.controller0.getWorldPosition(T.controller0pos),T.controller0.getWorldDirection(T.controller0dir),T.controller0dir.negate()),T.controller1&&T.controller1.visible&&(T.controller1.getWorldPosition(T.controller1pos),T.controller1.getWorldDirection(T.controller1dir),T.controller1dir.negate())},getAxisValue:e=>{let t=new THREE.Vector2(0,0),o=e===T.HAND_L?T.controller1:T.controller0;if(void 0===o)return t;if(void 0===o.gm||void 0===o.gm.axes)return t;let i=o.gm.axes[0],r=o.gm.axes[2],a=o.gm.axes[1],n=o.gm.axes[3];return t.x=i>0?-i:r,t.y=a>0?a:-n,t}};const v=T,g=class extends t{constructor(e,t,o){super(e,ATON.NTYPES.UI),this.baseColor=ATON.MatHub.colors.black,this.baseOpacity=.5,this.container=new ThreeMeshUI.Block({width:t||.2,height:o||.05,padding:.001,borderRadius:.01,backgroundColor:this.baseColor,backgroundOpacity:this.baseOpacity,fontFamily:ATON.SUI.PATH_FONT_JSON,fontTexture:ATON.SUI.PATH_FONT_TEX,justifyContent:"center",textAlign:"center"}),this.container.position.z=.03,this.add(this.container),this.uiText=new ThreeMeshUI.Text({content:"Label",fontSize:.03,fontColor:ATON.MatHub.colors.white}),this.container.add(this.uiText),ThreeMeshUI.update()}setBaseColor(e){return this.baseColor=e,this.container.set({backgroundColor:this.baseColor}),ThreeMeshUI.update(),this}setTextColor(e){return this.uiText.set({fontColor:e}),ThreeMeshUI.update(),this}setBackgroundOpacity(e){return this.container.set({backgroundOpacity:e}),this.baseOpacity=e,ThreeMeshUI.update(),this}setText(e){return this.uiText.set({content:e}),ThreeMeshUI.update(),this}};let S={STD_BTN_SIZE:.1,STD_SELECTOR_TICKNESS:1.05};S.Button=class extends t{constructor(e,t=1,o=1){super(e,ATON.NTYPES.UI),this.baseColor=ATON.MatHub.colors.black,this.switchColor=ATON.MatHub.colors.green,this.baseOpacity=.5,this.hoverOpacity=.8,this._bSwitched=!1,this.container=new ThreeMeshUI.Block({width:.1*t,height:.1,padding:.01,borderRadius:.02,backgroundColor:this.baseColor,backgroundOpacity:this.baseOpacity,fontFamily:ATON.SUI.PATH_FONT_JSON,fontTexture:ATON.SUI.PATH_FONT_TEX,justifyContent:"center",textAlign:"center"}),this.add(this.container),this.uiText=new ThreeMeshUI.Text({content:"",fontSize:.02*o,fontColor:ATON.MatHub.colors.white}),this.container.add(this.uiText);let i=.9*ATON.SUI.STD_BTN_SIZE*t,r=.9*ATON.SUI.STD_BTN_SIZE;this._trigger=new THREE.Mesh(new THREE.PlaneGeometry(i,r,2),ATON.MatHub.materials.fullyTransparent),this._trigger.position.set(0,0,.002),this.add(this._trigger),this.onHover=()=>{this.container.set({backgroundOpacity:this.hoverOpacity})},this.onLeave=()=>{this.container.set({backgroundOpacity:this.baseOpacity})},this.enablePicking(),this.traverse((e=>{e.material&&(e.material.depthWrite=!1)})),ThreeMeshUI.update()}setBaseColor(e){return this.baseColor=e,this._bSwitched||this.container.set({backgroundColor:this.baseColor}),ThreeMeshUI.update(),this}setSwitchColor(e){return this.switchColor=e,this._bSwitched&&this.container.set({backgroundColor:this.switchColor}),ThreeMeshUI.update(),this}setBackgroundOpacity(e){return this.container.set({backgroundOpacity:e}),this.baseOpacity=e,ThreeMeshUI.update(),this}setText(e){return this.uiText.set({content:e}),ThreeMeshUI.update(),this}switch(e){return this._bSwitched=e,e?this.container.set({backgroundColor:this.switchColor}):this.container.set({backgroundColor:this.baseColor}),ThreeMeshUI.update(),this}setIcon(e,t){return ATON.Utils.textureLoader.load(e,(e=>{this._trigger.material=new THREE.MeshStandardMaterial({map:e,transparent:!0,depthWrite:!1}),t&&(this.setBackgroundOpacity(0),this.hoverOpacity=0),this.uiText.position.set(0,-.035,0)})),ThreeMeshUI.update(),this}},S.Label=g,S.MediaPanel=class extends t{constructor(e){super(e,ATON.NTYPES.UI),this._resurl=void 0,this._mediamesh=void 0,this._vs=void 0,this._yratio=1,this._titleYoffs=.6,this._color=ATON.MatHub.colors.black;let t=this;this.onSelect=()=>{t._vs&&t._vs.el}}load(e,t){this._yratio=1,this._mediamesh||(this._mediamesh=new THREE.Mesh(new THREE.PlaneGeometry(1,1)),this.add(this._mediamesh)),e=ATON.Utils.resolveCollectionURL(e);let o=this;return ATON.Utils.isVideo(e)?(this._vs=ATON.MediaFlow.getOrCreateVideoStream(this.nid,e,!1),this._mediamesh.material=this._vs.matStream,this._vs.el.addEventListener("loadedmetadata",(i=>{o._yratio=o._vs.el.videoHeight/o._vs.el.videoWidth,o._mediamesh.scale.y=-o._yratio,o._resurl=e,o._onContentLoad(),t&&t()}))):ATON.Utils.loadTexture(e,(i=>{i.image&&(this._yratio=i.image.height/i.image.width),o._mediamesh.scale.y=o._yratio,o._mediamesh.material=ATON.MatHub.materials.chromakey.clone(),o._mediamesh.material.uniforms.tBase.value=i,o._mediamesh.material.needsUpdate=!0,o._resurl=e,o._onContentLoad(),t&&t()})),this.setPickable(!0),this}setColor(e){return this._color=e,this._labelTitle&&this._labelTitle.setBaseColor(e),this._bd&&(this._bd.material.color=e),this}getMaterial(){return this._mediamesh.material}_onContentLoad(){this._labelTitle&&(this._labelTitle.position.y=this._yratio*this._titleYoffs),this._bd&&(this._bd.scale.y=1.05*this._yratio)}setTitle(e){return this._labelTitle||(this._labelTitle=new g(void 0,.5,.07),this._labelTitle.position.z=-.01,this._labelTitle.attachTo(this)),this._labelTitle.setText(e),this._labelTitle.setBaseColor(this._color),this}toggleTitle(e){return this._labelTitle?(this._labelTitle.toggle(e),this):this}setBackdrop(e){return this._bd=new THREE.Mesh(new THREE.PlaneGeometry(1,1)),this._bd.material=new THREE.MeshStandardMaterial({transparent:!0,side:THREE.DoubleSide,color:this._color,opacity:e||.5}),this._bd.scale.x=1.05,this._bd.scale.y=1.05*this._yratio,this._bd.position.z=-.005,this.add(this._bd),this}},S.init=()=>{S.initSelector(),S.fpTeleport=ATON.createUINode();let e=new THREE.CylinderGeometry(.4,.4,.9,32,1,!0),t=new THREE.Mesh(e,ATON.MatHub.getMaterial("teleportLoc"));t.renderOrder=100,S.fpTeleport.add(t),S.fpTeleport.disablePicking(),S.fpTeleport.visible=!1,ATON._rootUI.add(S.fpTeleport),S.PATH_FONT_JSON||(S.PATH_FONT_JSON=ATON.PATH_RES+"fonts/custom-msdf.json"),S.PATH_FONT_TEX||(S.PATH_FONT_TEX=ATON.PATH_RES+"fonts/custom.png"),S.gMeasures=ATON.createUINode(),S._prevMPoint=void 0,S._measLabels=[],ATON._rootUI.add(S.gMeasures);let o=(new THREE.BufferGeometry).setFromPoints([new THREE.Vector3,new THREE.Vector3]);S._measLine=new THREE.Line(o,ATON.MatHub.getMaterial("measurement")),S._measLine.visible=!1,ATON._rootUI.add(S._measLine),S.gPoints=ATON.createUINode(),ATON._rootUI.add(S.gPoints),S.gLocNodes=ATON.createUINode(),ATON._rootUI.add(S.gLocNodes),S.buildInfoNode(),S.bShowInfo=!0,S._labelScale=ATON.Utils.isMobile()?80:90,S._labelScaleVR=2,S.sprites={},S._sync=0},S.getOrCreateSpritePointEdit=()=>(S.sprites.pointEdit||(S.sprites.pointEdit=new THREE.SpriteMaterial({map:(new THREE.TextureLoader).load(ATON.PATH_RES+"sui-point.png"),color:ATON.MatHub.colors.orange,transparent:!0,opacity:1,depthTest:!1})),S.sprites.pointEdit),S.getOrCreateSpriteSemIcon=()=>(S.sprites.semIcon||(S.sprites.semIcon=new THREE.SpriteMaterial({map:(new THREE.TextureLoader).load(ATON.PATH_RES+"sui-sem.png"),transparent:!0,opacity:1,depthWrite:!1,depthTest:!1})),S.sprites.semIcon),S.getOrCreateSpriteLP=()=>(S.sprites.lp||(S.sprites.lp=new THREE.SpriteMaterial({map:(new THREE.TextureLoader).load(ATON.PATH_RES+"sui-lp.png"),transparent:!0,opacity:1,depthWrite:!1}),S.sprites.lp.sizeAttenuation=!1),S.sprites.lp),S.getOrCreateSpriteWalk=()=>(S.sprites.walk||(S.sprites.walk=new THREE.SpriteMaterial({map:(new THREE.TextureLoader).load(ATON.PATH_RES+"sui-walk.png"),transparent:!0,opacity:1,depthWrite:!1})),S.sprites.walk),S.initSelector=()=>{S.mainSelector=ATON.createUINode(),S._mSelectorSphere=new THREE.Mesh(ATON.Utils.geomUnitSphere,ATON.MatHub.getMaterial("selector")),S._mSelectorSphere.renderOrder=100,S.mainSelector.add(S._mSelectorSphere),S.mainSelector.disablePicking(),S.setSelectorRadius(.05),S.mainSelector.visible=!1,ATON._rootUI.add(S.mainSelector),S._selOffset=new THREE.Vector3,S._bShowSelector=!0},S.enableLPIcons=()=>{S.gLPIcons=ATON.createUINode(),S.gLPIcons.disablePicking(),ATON._rootUI.add(S.gLPIcons)},S.enableSemIcons=()=>{S.gSemIcons=ATON.createUINode(),S.gSemIcons.disablePicking(),ATON._rootUI.add(S.gSemIcons)},S.showSelector=e=>{S._bShowSelector=e},S.setSelectorRadius=e=>{S._selectorRad=e,S.mainSelector.scale.set(e,e,e)},S.setSelectorOffset=(e,t,o)=>{void 0!==e&&(S._selOffset.x=e),void 0!==t&&(S._selOffset.y=t),void 0!==o&&(S._selOffset.z=o);let i=ATON.getSceneQueriedPoint();void 0!==i&&(S.mainSelector.position.x=i.x+S._selOffset.x,S.mainSelector.position.y=i.y+S._selOffset.y,S.mainSelector.position.z=i.z+S._selOffset.z)},S.getSelectorRadius=()=>S._selectorRad,S.getSelectorLocation=()=>S.mainSelector.position,S.setSelectorModel=(e,t)=>{void 0!==e&&(S.mainSelector.removeChildren(),S.mainSelector.load(e).disablePicking(),t&&S.mainSelector.setMaterial(ATON.MatHub.getMaterial("selector")))},S.setSelectorColor=(e,t)=>{let o=ATON.MatHub.materials.selector;o.uniforms.tint.value=e,void 0!==t&&(o.uniforms.opacity.value=t)},S.addSemIcon=(e,t)=>{if(void 0===S.gSemIcons)return;let o=(new THREE.Box3).setFromObject(t),i=new THREE.Sphere;o.getBoundingSphere(i);let r=new THREE.Sprite(S.getOrCreateSpriteSemIcon());r.position.copy(i.center),r.scale.set(.8,.8,1),r.name=e,S.gSemIcons.add(r)},S.addLPIcon=e=>{if(void 0===S.gLPIcons)return;let t=e._near,o=new THREE.Sprite(S.getOrCreateSpriteLP());o.position.copy(e.pos),o.scale.set(.1,.1,.1);let i=new THREE.Mesh(ATON.Utils.geomUnitSphere,ATON.MatHub.materials.lp);i.scale.set(t,t,t),i.position.copy(e.pos),S.gLPIcons.add(o),S.gLPIcons.add(i)},S.setSemIconsOpacity=e=>{ATON.MatHub.spriteSemIcon.opacity=void 0===e?1:e},S.buildInfoNode=()=>{S.infoNode=ATON.createUINode(),S.infoNode.attachToRoot(),S.infoContainer=new ThreeMeshUI.Block({width:.2,height:.05,padding:.01,borderRadius:.02,backgroundColor:ATON.MatHub.colors.black,backgroundOpacity:.4,fontFamily:S.PATH_FONT_JSON,fontTexture:S.PATH_FONT_TEX,justifyContent:"center",textAlign:"center"}),S.infoContainer.position.y=.03,S.infoNode.add(S.infoContainer),S.infoNodeText=new ThreeMeshUI.Text({content:"Info",fontSize:.02,fontColor:ATON.MatHub.colors.white}),S.infoContainer.add(S.infoNodeText),ThreeMeshUI.update()},S.getInfoNode=()=>S.infoNode,S.setInfoNodeText=e=>{S.bShowInfo&&(S.infoNodeText.set({content:e}),ThreeMeshUI.update())},S.createToolbar=(e,t,o)=>{let i=ATON.createUINode(),r=e.length,a=.3*S.STD_BTN_SIZE,n=new ThreeMeshUI.Block({width:S.STD_BTN_SIZE*r*1.1+a,height:S.STD_BTN_SIZE+a,padding:.01,borderRadius:.02,backgroundColor:t||ATON.MatHub.colors.black,backgroundOpacity:void 0!==o?o:.3,fontFamily:S.PATH_FONT_JSON,fontTexture:S.PATH_FONT_TEX,justifyContent:"center",textAlign:"center"}),s=.5*r*S.STD_BTN_SIZE*1.1;s-=.5*S.STD_BTN_SIZE;for(let t=0;t{void 0===o&&(o=1),void 0===i&&(i=1);let r=ATON.createUINode(e),a=new THREE.Mesh(new THREE.PlaneGeometry(o,i,2),ATON.MatHub.materials.fullyTransparent);return r.add(a),void 0!==t&&ATON.Utils.textureLoader.load(t,(e=>{a.material=new THREE.MeshStandardMaterial({map:e,transparent:!0,depthWrite:!1,side:THREE.DoubleSide})})),r},S.createLayout=(e,t)=>{let o=e.children.length;for(let i=0;i{if(void 0===e)return;let t=.01,o=.001;if(void 0===S._prevMPoint){S._prevMPoint=e;let t=S._measLine.geometry.attributes.position.array;return t[0]=e.x,t[1]=e.y,void(t[2]=e.z)}S._measLine.visible=!1;let i=S._prevMPoint.distanceTo(e);t*=i,o*=i;let r=new THREE.Mesh(ATON.Utils.geomUnitCube,ATON.MatHub.getMaterial("measurement"));r.position.copy(S._prevMPoint),r.scale.set(t,t,t),S.gMeasures.add(r);let a=new THREE.Mesh(ATON.Utils.geomUnitCube,ATON.MatHub.getMaterial("measurement"));a.position.copy(e),a.scale.set(t,t,t),S.gMeasures.add(a);let n=2*i,s=(new THREE.BufferGeometry).setFromPoints([S._prevMPoint,e]);S.gMeasures.add(new THREE.Line(s,ATON.MatHub.getMaterial("measurement")));let l=new S.Label;l.setBaseColor(ATON.MatHub.colors.white).setTextColor(ATON.MatHub.colors.black),l.userData.vStart=new THREE.Vector3,l.userData.vEnd=new THREE.Vector3,l.userData.vStart.copy(S._prevMPoint),l.userData.vEnd.copy(e),l.userData.vSEdir=new THREE.Vector3,l.userData.vSEdir.x=l.userData.vStart.x-l.userData.vEnd.x,l.userData.vSEdir.y=l.userData.vStart.y-l.userData.vEnd.y,l.userData.vSEdir.z=l.userData.vStart.z-l.userData.vEnd.z,l.userData.vSEdir.normalize(),l.setPosition(.5*(S._prevMPoint.x+e.x),.5*(S._prevMPoint.y+e.y),.5*(S._prevMPoint.z+e.z)),l.setScale(n).setText(ATON.Utils.getHumanReadableDistance(i)),S.gMeasures.add(l),S._measLabels.push(l);let d={};return d.A=l.userData.vStart,d.B=l.userData.vEnd,S._prevMPoint=void 0,d},S.clearMeasurements=()=>{S.gMeasures.removeChildren(),S._measLabels=[]},S._updateMeasurements=()=>{if(!(S._measLabels.length<=0))for(let e in S._measLabels)S._measLabels[e].orientToCamera()},S.update=()=>{if(ATON.Nav.isTransitioning()||ATON._bPauseQuery)S.infoNode.visible=!1;else{if(S._prevMPoint){if(ATON._queryDataScene){let e=S._measLine.geometry.attributes.position.array;e[3]=ATON._queryDataScene.p.x,e[4]=ATON._queryDataScene.p.y,e[5]=ATON._queryDataScene.p.z,S._measLine.geometry.attributes.position.needsUpdate=!0}S._measLine.visible=!0}else S._measLine.visible=!1;if(ATON._queryDataScene&&!ATON.Nav._bInteracting?(S._bShowSelector&&(S.mainSelector.visible=!0),S.mainSelector.position.x=ATON._queryDataScene.p.x+S._selOffset.x,S.mainSelector.position.y=ATON._queryDataScene.p.y+S._selOffset.y,S.mainSelector.position.z=ATON._queryDataScene.p.z+S._selOffset.z):S.mainSelector.visible=!1,S.gSemIcons&&(ATON.Nav._bInteracting?S.gSemIcons.hide():void 0===ATON._hoveredSemNode&&S.gSemIcons.show()),ATON.Nav.isOrbit()&&!ATON.XR._bPresenting||!ATON.Nav.currentQueryValidForLocomotion()?S.fpTeleport.visible=!1:(S.fpTeleport.visible=!0,S.fpTeleport.position.copy(ATON._queryDataScene.p)),ATON.XR._pointerLineMesh){let e=0;ATON._queryDataScene&&(e=ATON._queryDataScene.d),ATON._queryDataUI&&(e<=0||ATON._queryDataUI.d0?(ATON.XR._pointerLineMesh.visible=!0,ATON.XR._pointerLineMesh.scale.set(1,1,e)):ATON.XR._pointerLineMesh.visible=!1}if(S._updateMeasurements(),ATON._queryDataSem)ATON.XR._bPresenting&&(S.bShowInfo&&(S.infoNode.visible=!0),ATON.XR.controller0?(S.infoNode.position.copy(ATON.XR.controller0pos),S.infoNode.position.x-=.1*ATON.XR.controller0dir.x,S.infoNode.position.y-=.1*ATON.XR.controller0dir.y,S.infoNode.position.z-=.1*ATON.XR.controller0dir.z,S.infoNode.setScale(1)):(S.infoNode.position.lerpVectors(ATON._queryDataSem.p,ATON.Nav._currPOV.pos,.1),S.infoNode.setScale(ATON._queryDataSem.d*S._labelScaleVR)),S.infoNode.orientToCamera()),ATON.Photon._bStreamFocus||(S.mainSelector.visible=!1);else if(ATON.XR._bPresenting&&S.bShowInfo&&ATON._queryDataScene&&void 0!==ATON.XPFNetwork._semCurr){S.infoNode.position.lerpVectors(ATON._queryDataScene.p,ATON.Nav._currPOV.pos,.5);const e=ATON._queryDataScene.d*(ATON.Nav._currPOV.fov/S._labelScale);S.infoNode.setScale(e),S.infoNode.orientToCamera(),S.infoNode.visible=!0}else S.infoNode.visible=!1;if(S.mainSelector.visible&&ATON.Photon._bStreamFocus){let e=S._selectorRad*(1+.2*Math.cos(10*ATON._clock.elapsedTime));S.mainSelector.scale.set(e,e,e);let t=ATON.getSceneFocalPoint();void 0!==t&&void 0!==ATON.plight&&(ATON.enablePointLight(),ATON.plight.position.copy(t),ATON.plight.distance=2*S._selectorRad)}}};const N=S;let O={SCENES_SORTER:(e,t)=>{let o=e.creationDate,i=t.creationDate;return o&&i?o>i?-1:i>o?1:0:0},init:()=>{window.bootstrap&&window.bootstrap.Offcanvas&&(O._parser=new DOMParser,O.PATH_RES_ICONS=ATON.PATH_RES+"icons/",O._bModal=!1,O._bSidePanel=!1,O._bSemL=!1,O._setupBase())},setTheme:e=>{document.body.setAttribute("data-bs-theme",e)},createElementFromHTMLString:e=>O._parser.parseFromString(e,"text/html").body.firstElementChild,onContextMenu:()=>!1,_setupBase:()=>{document.body.oncontextmenu=O.onContextMenu,O.setTheme("dark"),O.elCenteredOverlay=O.createElementFromHTMLString('\n
    \n
    Loading...
    \n
    \n\t'),document.body.append(O.elCenteredOverlay),O.hideCenteredOverlay(),O.elLabelCon=document.createElement("div"),O.elLabelCon.classList.add("aton-floating-label-container"),O.elLabel=document.createElement("div"),O.elLabel.classList.add("aton-floating-label"),O.elLabelCon.append(O.elLabel),document.body.prepend(O.elLabelCon),O.hideSemLabel(),O.elModal=O.createElementFromHTMLString('\n \n\t'),O.modal=new bootstrap.Modal(O.elModal),document.body.append(O.elModal),O.elModalContent=document.getElementById("uiModalContent"),O.elSidePanel=O.createElementFromHTMLString('\n
    \n\t'),O.sidepanel=new bootstrap.Offcanvas(O.elSidePanel),document.body.append(O.elSidePanel)},showCenteredOverlay:e=>{O.elCenteredOverlay.classList.add("d-flex"),O.elCenteredOverlay.classList.remove("d-none")},hideCenteredOverlay:()=>{O.elCenteredOverlay.classList.remove("d-flex"),O.elCenteredOverlay.classList.add("d-none")},showModal:e=>{if(e){if(O.elModalContent.innerHTML="",e.header){let t=document.createElement("div");t.classList.add("modal-header"),t.innerHTML="",O.elModalContent.append(t)}if(e.body){let t=document.createElement("div");t.classList.add("modal-body"),t.append(e.body),O.elModalContent.append(t)}if(e.footer){let t=document.createElement("div");t.classList.add("modal-footer"),t.append(e.footer),O.elModalContent.append(t)}O.modal.show(),O._bModal=!0}},hideModal:()=>{O.modal.hide(),O._bModal=!1},showSidePanel:e=>{if(e){if(O.elSidePanel.innerHTML="",e.header){let t=document.createElement("div");t.classList.add("offcanvas-header"),t.innerHTML="

    "+e.header+"

    ",O.elSidePanel.append(t)}if(e.body){let t=document.createElement("div");t.classList.add("offcanvas-body"),t.append(e.body),O.elSidePanel.append(t)}O.sidepanel.show(),O._bSidePanel=!0}},hideSidePanel:()=>{O.sidepanel.hide(),O._bSidePanel=!1},addBasicEvents:()=>{let e=document.querySelector("canvas");ATON.on("NodeRequestFired",(()=>{O.showCenteredOverlay()})),ATON.on("AllNodeRequestsCompleted",(()=>{O.hideCenteredOverlay()})),ATON.on("SemanticNodeHover",(t=>{let o=ATON.getSemanticNode(t);void 0!==o&&(O.showSemLabel(t),o.highlight(),e.style.cursor="pointer",ATON.SUI.gSemIcons&&ATON.SUI.gSemIcons.hide())})),ATON.on("SemanticNodeLeave",(t=>{let o=ATON.getSemanticNode(t);void 0!==o&&(O.hideSemLabel(),o.restoreDefaultMaterial(),e.style.cursor="grab",ATON.SUI.gSemIcons&&ATON.SUI.gSemIcons.show())})),ATON.on("SemanticMaskHover",(t=>{O.showSemLabel(t),e.style.cursor="pointer"})),ATON.on("SemanticMaskLeave",(t=>{O.hideSemLabel(),e.style.cursor="grab"})),ATON.addUpdateRoutine(O.update)},update:()=>{if(O._bSemL&&!ATON.XR._bPresenting){let e=.5*ATON._screenPointerCoords.x*window.innerWidth,t=.5*(1-ATON._screenPointerCoords.y)*window.innerHeight;t-=35,O.elLabel.style.transform="translate("+e+"px, "+t+"px)"}},showSemLabel:e=>{O.elLabel.innerHTML=e,O.elLabel.style.display="inline-block",O._bSemL=!0},hideSemLabel:()=>{O.elLabel.style.display="none",O._bSemL=!1},loadPartial:(e,t,o,i)=>{fetch(e).then((e=>e.text())).then((e=>{let i=O._parser.parseFromString(e,"text/html").body.childNodes;t?o?document.querySelector(`#${t}`).prepend(...i):document.querySelector(`#${t}`).append(...i):o?document.body.prepend(...i):document.body.append(...i)})).catch((e=>`Error fetching partial: ${e}`)),i&&i()},resolveIconURL:e=>e.includes("/")?e:O.PATH_RES_ICONS+e+".png",prependIcon:(e,t)=>{t.startsWith("bi-")?e.prepend(O.createElementFromHTMLString("")):e.prepend(O.createElementFromHTMLString(""))},createButton:e=>{let t=document.createElement("button");return t.classList.add("btn","aton-btn"),t.setAttribute("type","button"),e.variant&&t.classList.add("btn-"+e.variant),e.text&&(t.innerText=e.text),e.icon&&O.prependIcon(t,e.icon),e.badge&&t.append(O.createElementFromHTMLString(""+e.badge+"")),e.onpress&&(t.onclick=e.onpress),t},createDropdown:e=>{let t=document.createElement("div");t.classList.add("btn-group");let o=O.createElementFromHTMLString(`\n \n `);if(e.icon&&O.prependIcon(o,e.icon),t.append(o),e.items){let o=document.createElement("ul");o.classList.add("dropdown-menu","aton-dropdown-menu"),e.align&&o.classList.add(e.align);for(let t=0;t${r.title}\n `);let a=document.createElement("li");a.append(i),o.append(a),r.icon&&O.prependIcon(i,r.icon)}t.append(o)}return t},createTabsGroup:e=>{let t=ATON.Utils.generateID("tabgroup"),o=document.createElement("div"),i=document.createElement("ul");i.classList.add("nav","nav-justified","nav-tabs"),i.setAttribute("role","tablist");let r=document.createElement("div");r.classList.add("tab-content"),o.append(i),o.append(r);for(let o=0;o");let c=t+"-"+n;c=c.replaceAll(" ","");let u,p=document.createElement("li");p.classList.add("nav-item"),p.setAttribute("role","presentation"),p.innerHTML=0===o?"":"",i.append(p),u=0===o?O.createElementFromHTMLString("
    "):O.createElementFromHTMLString("
    "),u.style.padding="10px 0px 10px 0px",s&&u.append(s),r.append(u)}return o},createTreeGroup:e=>{let t=ATON.Utils.generateID("tree"),o=document.createElement("div");o.classList.add("aton-tree-container");for(let i=0;i"+a+"")),n){let e=document.createElement("div");e.classList.add("aton-tree-item-content"),e.append(r.content),s.append(e)}o.append(s)}return o},createVectorControl:e=>{let t,o=ATON.Utils.generateID("vec3");e.vector&&(t=e.vector);let i=.01;e.step&&(i=e.step);let r=t?t.x:0,a=t?t.y:0,n=t?t.z:0,s=O.createElementFromHTMLString(`\n
    \n \n \n \n
    \n `);s.id=o;let l=s.children[0],d=s.children[1],c=s.children[2];return l.oninput=()=>{let o=l.value;t&&(t.x=o),e.onupdate&&e.onupdate()},d.oninput=()=>{let o=d.value;t&&(t.y=o),e.onupdate&&e.onupdate()},c.oninput=()=>{let o=c.value;t&&(t.z=o),e.onupdate&&e.onupdate()},s},createQuaternionControl:e=>{let t,o=ATON.Utils.generateID("vec3");e.quat&&(t=e.quat);let i=.01;e.step&&(i=e.step);let r=t?t.x:0,a=t?t.y:0,n=t?t.z:0,s=t?t.w:0,l=O.createElementFromHTMLString(`\n
    \n \n \n \n \n
    \n `);l.id=o;let d=l.children[0],c=l.children[1],u=l.children[2],p=l.children[3];return d.oninput=()=>{let o=d.value;t&&(t.x=o),e.onupdate&&e.onupdate()},c.oninput=()=>{let o=c.value;t&&(t.y=o),e.onupdate&&e.onupdate()},u.oninput=()=>{let o=u.value;t&&(t.z=o),e.onupdate&&e.onupdate()},u.oninput=()=>{let o=p.value;t&&(t.w=o),e.onupdate&&e.onupdate()},l},createNodeTrasformControl:e=>{let t,o=ATON.Utils.generateID("ftrans"),i=document.createElement("div");if(i.id=o,e.node&&(t=ATON.getSceneNode(e.node)),e.position){let o=O.createVectorControl({vector:t.position,step:e.position.step});i.append(O.createElementFromHTMLString("")),i.append(o)}if(e.scale){let o=O.createVectorControl({vector:t.scale,step:e.scale.step});i.append(O.createElementFromHTMLString("")),i.append(o)}if(e.rotation){let o=O.createVectorControl({vector:t.rotation,step:e.rotation.step});i.append(O.createElementFromHTMLString("")),i.append(o)}return i},createSceneCard:e=>{let t,o,i,r=document.createElement("div");if(r.classList.add("card","aton-scene-card"),"small"===e.size&&r.classList.add("aton-scene-card-small"),"large"===e.size&&r.classList.add("aton-scene-card-large"),!e.sid)return r;let a="";if(e.keywords){for(let t in e.keywords)a+=t+" ";a=a.trim().toLowerCase(),r.setAttribute("data-search-term",a)}i=ATON.PATH_RESTAPI2+"scenes/"+e.sid+"/cover";let n=e.sid.split("/");if(t=n[0],o=n[1],r.setAttribute("data-search-user",t),e.useblurtint){let e=document.createElement("div");e.classList.add("aton-scene-card-bg"),e.style.backgroundImage="url('"+i+"')",r.append(e)}r.innerHTML+="";let s=document.createElement("div");s.classList.add("card-body","aton-scene-card-body"),r.append(s);let l=document.createElement("div");return l.classList.add("card-title","aton-scene-card-title"),l.innerHTML="Title",s.append(l),e.title?(l.innerHTML=e.title,a+=e.title.trim().toLowerCase(),r.setAttribute("data-search-term",a)):ATON.REQ.get("scenes/"+e.sid,(e=>{e.title&&(l.innerHTML=e.title)})),s.innerHTML+="
    "+t+"
    ",r},createLiveFilter:e=>{let t=ATON.Utils.generateID("filter"),o=t+"-input",i=document.createElement("form");i.id=t,i.classList.add("d-flex"),i.setAttribute("role","search");let r="Search";e.placeholder&&(r=e.placeholder);let a=O.createElementFromHTMLString(``);const n=document.createElement("div");return n.classList.add("input-group"),n.append(O.createElementFromHTMLString("")),n.append(a),a.oninput=()=>{if(!e.filterclass)return;let t=a.value.trim().toLowerCase(),o=document.querySelectorAll(`.${e.filterclass}`);if(t.length<3)for(let e of o)e.classList.remove("d-none");else for(let e of o)e.getAttribute("data-search-term").includes(t)||t.length<1?e.classList.remove("d-none"):e.classList.add("d-none")},e.onfocus&&(a.onfocus=e.onfocus),e.onblur&&(a.onblur=e.onblur),i.append(n),i},createPublicScenesGallery:e=>{if(!e.containerid)return;let t=document.getElementById(e.containerid);if(!t)return;const o=o=>{o.sort(O.SCENES_SORTER),console.log(o);for(let i of o){let o=i.sid.startsWith("samples/");if(!o||o&&e.samples){let o=ATON.UI.createSceneCard({title:i.title?i.title:i.sid,sid:i.sid,keywords:i.kwords,useblurtint:!0,size:e.size});t.append(o)}}};return e.entries?o(e.entries):ATON.REQ.get("scenes/",(e=>o(e))),t},createLoginForm:e=>{let t=document.createElement("form");t.classList.add("container-sm","text-center");let o=O.createElementFromHTMLString('
    Username
    '),i=O.createElementFromHTMLString('
    Password
    '),r=O.createElementFromHTMLString(''),a=O.createElementFromHTMLString('');o.append(r),i.append(a);let n=ATON.UI.createButton({text:"Login",icon:"bi-person",variant:"primary",onpress:()=>{let t=r.value.trim(),o=a.value.trim();ATON.REQ.login(t,o,e.onSuccess,e.onFail)}});return e.header?t.append(e.header):t.append(O.createElementFromHTMLString('')),t.append(o),t.append(i),t.append(n),t}};const A=O;let b={USER_STATE_FREQ:.25,REPLICATED_EVT:"EREP",THRES_STATE_POS:.01,THRES_STATE_ORI:.08};b.Avatar=class extends t{constructor(e){super(void 0,ATON.NTYPES.UI),this.userid=e,this.username=void 0,this.message="...",this.color=ATON.Photon.ucolors[this.userid%ATON.Photon.ucolors.length],this._auTalk=[],this._auTalk.push(new THREE.PositionalAudio(ATON.AudioHub._listener)),this._auTalk.push(new THREE.PositionalAudio(ATON.AudioHub._listener));for(let e=0;e<2;e++)this._auTalk[e].setRefDistance(30),this._auTalk[e].setLoop(!1),this.add(this._auTalk[e]);this._auTalki=0,this.bMuted=!1,this._bPlayingAudio=!1,this._blob=void 0,this._b64=void 0,this._tStateCall=-1,this._tProgress=0,this._tFocCall=-1,this._currFocusPos=new THREE.Vector3,this._tgtFocusPos=new THREE.Vector3,this._currState={position:new THREE.Vector3,quaternion:new THREE.Quaternion,scale:1},this._tgtState={position:new THREE.Vector3,quaternion:new THREE.Quaternion,scale:1},this.userlabelnode=void 0,this.mStream=void 0,this._elVStream=void 0,this.realize()}getColor(){return this.color}setTalkDistance(e){e>0&&this._auTalk.setRefDistance(e)}setMuted(e){this.bMuted=e}getAvatarMaterialByUID(e){let t=ATON.MatHub.materials.avatars;return t[e%t.length]}_buildLabel(){this.userlabelnode=ATON.createUINode(),this.labelcontainer=new ThreeMeshUI.Block({width:.5,height:.2,padding:.03,borderRadius:.05,backgroundColor:ATON.MatHub.colors.white,fontFamily:ATON.SUI.PATH_FONT_JSON,fontTexture:ATON.SUI.PATH_FONT_TEX,justifyContent:"center",textAlign:"center"}),this.userlabelnode.position.y=.4,this.userlabelnode.add(this.labelcontainer),this.usernametext=new ThreeMeshUI.Text({content:"User #"+this.userid,fontSize:.07,fontColor:this.color}),this.usernametext.position.y=.01,this.labelcontainer.add(this.usernametext),this.add(this.userlabelnode),ThreeMeshUI.update()}realizeStreamPanel(){let e=ATON.MediaFlow.getOrCreateVideoStream(this.userid,void 0,!0);this._elVStream=e.el;let t=new THREE.PlaneGeometry(1,1);this.mStream=new THREE.Mesh(t,e.matStream),this.mStream.position.y=1;let o=.5625;this.mStream.scale.y=-o,this.mStream.position.y=.8*o,this._elVStream.addEventListener("loadedmetadata",(e=>{o=this._elVStream.videoHeight/this._elVStream.videoWidth,this.mStream.scale.y=-o,this.mStream.position.y=.8*o}))}getStreamPanel(){return this.mStream}toggleStreamPanel(e){void 0!==this.mStream&&(this.mStream.visible=e)}realize(){let e=new THREE.SphereGeometry(.2,16,16);ATON.Photon.customAvatarMaterial?this.usermaterial=ATON.Photon.customAvatarMaterial():this.usermaterial=this.getAvatarMaterialByUID(this.userid);let t=new THREE.Mesh(e,this.usermaterial);this.usermeshnode=ATON.createUINode(),this.usermeshnode.add(t),this.usermeshnode.setMaterial(this.usermaterial),this.usermeshnode.setCloneOnLoadHit(!1),this.add(this.usermeshnode),this.userauinode=new THREE.Sprite(ATON.Photon.uspritemats[this.userid%ATON.Photon.uspritemats.length]),this.userauinode.position.set(0,0,0),this.userauinode.visible=!1,this.add(this.userauinode),this.userfpnode=new THREE.Sprite(ATON.Photon.ufocmats[this.userid%ATON.Photon.ufocmats.length]),this.userfpnode.position.set(0,0,0),this.userfpnode.visible=!1,void 0===ATON.Photon._focNodes[this.userid]&&(ATON.Photon._focNodes[this.userid]=this.userfpnode,ATON.Photon.focGroup.add(this.userfpnode)),this._buildLabel()}loadRepresentation(e){let t=this;return void 0!==t.usermeshnode.children[0]&&t.usermeshnode.remove(t.usermeshnode.children[0]),t.usermeshnode.load(e),this}setUsername(e){return void 0===this.userlabelnode||(this.username=e,this.usernametext.set({content:e}),ThreeMeshUI.update()),this}getUsername(){if(void 0!==this.userid)return void 0===this.username?"User #"+this.userid:this.username}setMessage(e){if(void 0===this.userlabelnode)return this;this.message=e}setTalkVolume(e){if(void 0!==e)if(e>0){this.userauinode.visible=!0;let t=.1+.03*e;this.userauinode.scale.set(t,t,t)}else this.userauinode.visible=!1;else this.userauinode.visible=!1}hideFocalPoint(){this.userfpnode.visible=!1}requestFocus(e){if(void 0===e)return;if(this._tFocCall>=0)return;this._tFocCall=ATON._clock.elapsedTime,this._currFocusPos.copy(this.userfpnode.position);let t=this.scale.x*ATON._worldScale,o=parseFloat(e[0])*t,i=parseFloat(e[1])*t,r=parseFloat(e[2])*t,a=parseFloat(e[3])*t;this._tgtFocusPos.set(o,i,r),this._tgtFocusRad=2*a,this.userfpnode.scale.set(this._tgtFocusRad,this._tgtFocusRad,this._tgtFocusRad),this.userfpnode.visible=!0,ATON.enablePointLight(),ATON.plight.color=this.color,ATON.plight.position.copy(this._tgtFocusPos),ATON.plight.distance=this._tgtFocusRad}handleFocusTransition(){if(this._tFocCall<0)return;let e=ATON.Photon.USER_STATE_FREQ,t=(ATON._clock.elapsedTime-this._tFocCall)/e;if(t>=1)return this._tFocCall=-1,this.userfpnode.position.copy(this._tgtFocusPos),this.userfpnode.scale.set(this._tgtFocusRad,this._tgtFocusRad,this._tgtFocusRad),void(this.userfpnode.visible=!0);this.userfpnode.position.lerpVectors(this._currFocusPos,this._tgtFocusPos,t),ATON.plight.position.copy(this.userfpnode.position),this.userfpnode.visible=!0}requestStateTransition(e){this._tStateCall>=0||void 0!==e&&(this._tStateCall=ATON._clock.elapsedTime,this._currState.position.copy(this.position),this._currState.quaternion.copy(this.quaternion),this._currState.scale=this.scale,this._tgtState.position.copy(e.position),this._tgtState.quaternion.copy(e.quaternion),this._tgtState.scale=1/e.scale)}handleStateTransition(){if(this._tStateCall<0)return;let e=ATON.Photon.USER_STATE_FREQ;this._tProgress=e<=0?1:(ATON._clock.elapsedTime-this._tStateCall)/e;let t=this._currState,o=this._tgtState;if(this._tProgress>=1)return this._tStateCall=-1,this.position.copy(o.position),void this.usermeshnode.quaternion.copy(o.quaternion);this.position.lerpVectors(t.position,o.position,this._tProgress),this.usermeshnode.quaternion.slerp(o.quaternion,this._tProgress)}update(){if(this.handleStateTransition(),this.userfpnode&&this.userfpnode.visible){this.handleFocusTransition();let e=this.userfpnode.scale.x;e>.001?(this.userfpnode.scale.set(.99*e,.99*e,.99*e),ATON.plight.intensity*=.99):(this.userfpnode.visible=!1,ATON.disablePointLight())}let e=ATON.Nav._camera,t=ATON.Nav._currPOV.pos;if(void 0===e||void 0===t)return;this.userlabelnode&&this.userlabelnode.orientToCamera();let o=this.userauinode.scale.x;o*=.99,o>.01?this.userauinode.scale.set(o,o,o):this.userauinode.visible=!1}_handleTalk(){if(this._auTalk.isPlaying)return;if(this._auChunks.length<2)return;let e=this._auChunks[this._iAU];this._auTalk.setBuffer(e),this._auTalk.play(),this.setTalkVolume(5)}_handleTalkOLD(){if(this._bPlayingAudio)return;if(this._auChunks.length<1)return;let e=this._auChunks.shift();this._auTalk.setBuffer(e),this._auTalk.play(),this._bPlayingAudio=!0,this._auTalk.onended=()=>{this._bPlayingAudio=!1,e=null},this.setTalkVolume(5)}},b.CSTATE={DISCONNECTED:0,CONNECTING:1,CONNECTED:2},b.init=()=>{b.address=window.location.origin,b.initMaterials(),b.socket=void 0,b._cstate=b.CSTATE.DISCONNECTED,b._reqSSID=void 0,b._username=void 0,b.uid=void 0,b.color=ATON.MatHub.colors.white,b._bStreamFocus=!1,b._numUsers=1,b.avatarList=[],b.avaGroup=ATON.createUINode("avatars"),b.avaGroup.attachToRoot(),b.focGroup=ATON.createUINode("focus"),b.focGroup.attachTo(b.avaGroup),b._focNodes=[],b.bSendState=!0,window.setInterval(b.sendState,1e3*b.USER_STATE_FREQ),b._lastStateSent=void 0,b._bShowAvaG=!0,b._bSpatial=!0,b._decS={quaternion:new THREE.Quaternion,position:new THREE.Vector3},b.customAvatarMaterial=void 0,console.log("Photon initialized"),b.enableChatLog(),b._elVStream=void 0,window.addEventListener("beforeunload",(e=>{b.disconnect()}))},b.setCustomAvatarMaterialRoutine=e=>{b.customAvatarMaterial=e},b.enableChatLog=()=>{b._elChat=$("
    ").text("")},b.getNumUsers=()=>b._numUsers,b.initMaterials=()=>{b.ucolorhex=[],b.ucolorhex.push("#D88"),b.ucolorhex.push("#DD8"),b.ucolorhex.push("#8D8"),b.ucolorhex.push("#8DD"),b.ucolorhex.push("#88D"),b.ucolorhex.push("#D8D"),b.ucolorhex_light=[],b.ucolorhex_light.push("#FAA"),b.ucolorhex_light.push("#FFA"),b.ucolorhex_light.push("#AFA"),b.ucolorhex_light.push("#AFF"),b.ucolorhex_light.push("#AAF"),b.ucolorhex_light.push("#FAF"),b.ucolors=[],b.ucolors.push(new THREE.Color(b.ucolorhex[0])),b.ucolors.push(new THREE.Color(b.ucolorhex[1])),b.ucolors.push(new THREE.Color(b.ucolorhex[2])),b.ucolors.push(new THREE.Color(b.ucolorhex[3])),b.ucolors.push(new THREE.Color(b.ucolorhex[4])),b.ucolors.push(new THREE.Color(b.ucolorhex[5])),b.ucolorsdark=[],b.ucolorsdark.push(new THREE.Color(.2,0,0)),b.ucolorsdark.push(new THREE.Color(.2,.2,0)),b.ucolorsdark.push(new THREE.Color(0,.2,0)),b.ucolorsdark.push(new THREE.Color(0,.2,.2)),b.ucolorsdark.push(new THREE.Color(0,0,.2)),b.ucolorsdark.push(new THREE.Color(.2,0,.2));let e=ATON.MatHub.materials;e&&(e.avatars=[]);for(let t=0;t{if(!b.isConnected())return;let o=b.socket;o&&o.emit(b.REPLICATED_EVT,{e,d:t})},b.fireEvent=b.fire,b.on=(e,t)=>{if(void 0===t)return;let o=ATON.EventHub.evNetwork;void 0===o[e]&&(o[e]=[]),o[e].push(t)},b.isConnected=()=>b._cstate===b.CSTATE.CONNECTED,b.hasID=()=>void 0!==b.uid,b.log=e=>{if(!b.isConnected())return;let t=b.socket;t&&t.emit("UMSG",e)},b.joinSession=e=>{b.socket&&(void 0===e&&(e=ATON.SceneHub.currID),void 0!==e?(console.log("Joining Photon session '"+e+"'..."),b.socket.emit("SENTER",e)):console.log("Photon ERROR: current session ID is undefined"))},b.requestSceneState=()=>{b.socket&&b.socket.emit("SSTATE")},b.setAvatarsVisibility=e=>{b._bShowAvaG=e,e?b.avaGroup.show():b.avaGroup.hide()},b.disableSpatiality=()=>{b._bSpatial=!1},b.enableSpatiality=()=>{b._bSpatial=!0},b.setAddress=e=>{e&&(b.address=e)},b.connect=e=>{if(b._cstate===b.CSTATE.CONNECTED)return;if(b._cstate===b.CSTATE.CONNECTING)return;b._reqSSID=e;let t={};ATON.Utils.isConnectionSecure()?(t.path="/svrc/socket.io",t.secure=!0,t.rejectUnauthorized=!1):t.path="/vrc/socket.io",b._cstate=b.CSTATE.CONNECTING,b.socket=io.connect(b.address,t),void 0!==b.socket?b._registerSocketHandlers():b._cstate=b.CSTATE.DISCONNECTED},b.disconnect=()=>{void 0!==b.socket&&(b._numUsers=1,b.socket.disconnect(),b.color=ATON.MatHub.colors.white,ATON.plight.color=ATON.MatHub.colors.white,b._cstate=b.CSTATE.DISCONNECTED)},b._onConnected=()=>{},b.setUsername=e=>{(e=e.trim()).length<1||(b._username=e,void 0!==b.socket&&void 0!==b.uid&&(b.appendToChatBox("Your username is now: "+e+""),b.socket.emit("UNAME",e)))},b.setMessage=e=>{(e=e.trim()).length<1||e.length>3e3||(b._msg=e,void 0!==b.socket&&void 0!==b.uid&&(b.socket.emit("UMSG",e),b._elChat&&(e=b.chatMessageProcessor(b.uid,e),b.appendToChatBox("
    YOU
    : "+e+""))))},b.appendToChatBox=e=>{b._elChat&&(b._elChat.append("
    "+e+"
    "),b._elChat.scrollTop(b._elChat[0].scrollHeight))},b._registerSocketHandlers=()=>{b.socket.on("connect",(()=>{b._cstate=b.CSTATE.CONNECTED,void 0!==b._reqSSID?b.joinSession(b._reqSSID):b.joinSession(ATON.SceneHub.currID),console.log("Connected to Photon service!"),ATON.fire("VRC_Connected"),b._onConnected()})),b.socket.on("disconnect",(()=>{b._cstate=b.CSTATE.DISCONNECTED,b.uid=void 0,b.avaGroup.hide(),b.appendToChatBox("YOU disconnected from the Photon session"),console.log("Disconnected from Photon service!"),ATON.fire("VRC_Disconnected")})),b.socket.on(b.REPLICATED_EVT,(e=>{let t=e.e,o=e.d,i=ATON.EventHub.evNetwork[t];ATON.EventHub.executeHandlers(i,o)})),b.socket.on("ID",(e=>{console.log("Your ID is "+e),b.uid=e,b.color=b.ucolors[b.uid%b.ucolors.length],b._bShowAvaG&&b.avaGroup.show(),b.appendToChatBox("Your ID is #"+e+""),b.requestSceneState(),ATON.fire("VRC_IDassigned",e)})),b.socket.on("SSTATE",(e=>{b._numUsers=e.numUsers,console.log("Num. users: "+b._numUsers),ATON.fire("VRC_SceneState",e)})),b.socket.on("UENTER",(e=>{let t=e;console.log("User #"+t+" entered the session"),b.appendToChatBox("User #"+t+" entered the session"),b.requestSceneState(),ATON.fire("VRC_UserEnter",t)})),b.socket.on("ULEAVE",(e=>{let t=e;if(void 0===t)return;let o=b.avatarList[t];o&&(o.toggleStreamPanel(!1),o.hide()),console.log("User #"+t+" left the session"),b.appendToChatBox("User #"+t+" left the session"),b.requestSceneState(),ATON.fire("VRC_UserLeave",t)})),b.socket.on("USTATE",(e=>{if(!b._bShowAvaG)return;if(!b._bSpatial)return;let t=b.decodeState(e),o=t.userid,i=b.touchAvatar(o);i.requestStateTransition(t);let r=1/t.scale;i.scale.set(r,r,r)})),b.socket.on("UFOCUS",(e=>{if(!b._bSpatial)return;let t=e.uid,o=e.fp;b.touchAvatar(t).requestFocus(o)})),b.socket.on("UNAME",(e=>{let t=e.uid,o=e.name;void 0!==t&&(b.touchAvatar(t).setUsername(o),console.log("User #"+t+" changed username to: "+o),b.appendToChatBox("User #"+t+" changed username to: "+o+""),ATON.fire("VRC_UName",e))})),b.socket.on("UMSG",(e=>{let t=e.uid,o=e.msg;if(void 0===t)return;let i=b.touchAvatar(t);o.length<100&&i.setMessage(o),console.log("User #"+t+": "+o);let r=i.getUsername();o=b.chatMessageProcessor(t,o),b.ucolorhex[t%6];let a=b.ucolorhex_light[t%6];b.appendToChatBox("
    "+r+"
    : "+o+""),ATON.fire("VRC_UMessage",e)})),b.socket.on("UTALK",(e=>{let t=e.uid;if(void 0===t)return;let o=e.audio;if(o){if(b._bSpatial){let e=b.touchAvatar(t);if(e.bMuted)return;ATON.AudioHub._loader.load(o,(t=>{let o=e._auTalk[e._auTalki],i=(e._auTalki+1)%2;o.setBuffer(t),o.isPlaying||o.play(),e.setTalkVolume(5),e._auTalki=i}))}ATON.fire("VRC_UTalk",e),o=null}})),b.socket.on("UTALKSTOP",(e=>{void 0!==e.uid&&ATON.fire("VRC_UTalkStop",e)})),b.socket.on("UVIDEO",(e=>{void 0!==e.uid&&ATON.fire("VRC_UVideo",e)})),b.socket.on("UVIDEOSTOP",(e=>{let t=e.uid;if(void 0===t)return;let o=b.avatarList[t];o&&o.toggleStreamPanel(!1),ATON.fire("VRC_UVideoStop",e)}))},b.chatMessageProcessor=(e,t)=>{const o=(t=String(t)).match(/(((ftp|https?):\/\/)[\-\w@:%_\+.~#?,&\/\/=]+)/g);return o&&o.forEach((e=>{t=t.replace(e,""+e+"")})),t},b.encodeState=e=>{if(!e)return;let t=new Float32Array(5);t[0]=e.position.x,t[1]=e.position.y,t[2]=e.position.z;var o=new Int8Array(t.buffer);return o[12]=128*e.quaternion.x,o[13]=128*e.quaternion.y,o[14]=128*e.quaternion.z,o[15]=128*e.quaternion.w,o[16]=e.userid,o[17]=ATON._ws,o},b.decodeState=e=>{let t=new Int8Array(e);b._decS.userid=t[16];let o=ATON._unpackScale(t[17]);return b._decS.scale=o,b._decS.quaternion.set(parseFloat(t[12])/128,parseFloat(t[13])/128,parseFloat(t[14])/128,parseFloat(t[15])/128),t=new Float32Array(e),b._decS.position.set(parseFloat(t[0])/o,parseFloat(t[1])/o,parseFloat(t[2])/o),b._decS},b.update=()=>{if(b.isConnected())for(let e=0;e{if(void 0!==e){if(e)return b._bStreamFocus||(ATON.fire("VRC_FocusStreamingStarted"),ATON.enablePointLight(),ATON.plight.color=ATON.Photon.color),void(b._bStreamFocus=!0);{b._bStreamFocus&&(ATON.fire("VRC_FocusStreamingStopped"),ATON.disablePointLight());let e=ATON.SUI._selectorRad;ATON.SUI.mainSelector.scale.set(e,e,e),b._bStreamFocus=!1}}},b.sendState=()=>{if(!b.bSendState||!b._bSpatial)return;if(void 0===b.uid)return;if(!b.socket||!b.isConnected())return;let e=ATON.Nav._currPOV;if(!e)return;let t=ATON.getSceneFocalPoint();if(b._bStreamFocus&&void 0!==t){let e=t.x.toFixed(3),o=t.y.toFixed(3),i=t.z.toFixed(3),r=ATON.SUI.getSelectorRadius().toFixed(3);b.socket.emit("UFOCUS",[e,o,i,r])}if(!e.pos)return;if(!ATON.Nav._qOri)return;if(void 0!==b._lastStateSent){let t=b._lastStateSent.position,o=b._lastStateSent.quaternion,i=t.distanceToSquared(e.pos),r=o.angleTo(ATON.Nav._qOri);if(ib.avatarList[e],b.touchAvatar=e=>{if(void 0===b.avatarList[e]){let t=new b.Avatar(e);t.attachTo(b.avaGroup),t.loadRepresentation(ATON.PATH_RES+"models/vrc/head.glb"),b.avatarList[e]=t}let t=b.avatarList[e];return t.visible||ATON.fire("VRC_UserEnter",e),b._bShowAvaG&&t.show(),t},b.destroyAvatar=e=>{let t=b.avatarList[e];void 0!==t&&t.destroy()},b.clearAllAvatars=()=>{for(let e in b.avatarList)b.avatarList[e].hide()};const P=b;let f={FLOAT_PREC:5,init:()=>{f.bConvexBuilding=!1,f.convexPoints=[],f.convexNode=void 0,f.currConvexMesh=void 0,f.currSemNode=ATON.createSemanticNode(),f.currSemNode.disablePicking(),f.currSemNode.attachToRoot(),f.resetMaterial(),f._numShapes=0},resetMaterial:()=>{f.currMaterial=ATON.MatHub.getMaterial("semanticShapeHL")},setMaterial:e=>{void 0!==e&&(f.currMaterial=e)},addConvexPoint:e=>{if(void 0===e)return!1;if(f.convexPoints.length>0){let t=f.convexPoints[f.convexPoints.length-1];if(e.equals(t))return!1}f.convexPoints.push(e);let t=f.convexPoints.length,o=new THREE.Sprite(ATON.SUI.getOrCreateSpritePointEdit()),i=.02*ATON.getSceneQueriedDistance();if(void 0===i&&(i=.02),o.position.copy(e),o.scale.set(i,i,i),ATON.SUI.gPoints.add(o),t<4)return!1;let r=new THREE.ConvexGeometry(f.convexPoints),a=new THREE.Mesh(r,ATON.MatHub.getMaterial("semanticShapeEdit"));if(f.bConvexBuilding){let t=f.currConvexMesh;t.geometry.dispose(),t.geometry=r,ATON.Utils.setVectorPrecision(e,4),t.userData._convexPoints.push(e.x),t.userData._convexPoints.push(e.y),t.userData._convexPoints.push(e.z)}else{f.currSemNode.add(a),a.userData._convexPoints=[];for(let e=0;e{if(0!==f.convexPoints.length&&(f.convexPoints.pop(),f.currConvexMesh)){let e=f.currConvexMesh.userData;e._convexPoints&&e._convexPoints.pop()}},stopCurrentConvex:()=>{f.bConvexBuilding&&(f.convexPoints=[],f.bConvexBuilding=!1,f.currSemNode.removeChildren(),ATON.SUI.gPoints.removeChildren())},getCurrentConvexShape:()=>f.currSemNode,isBuildingShape:()=>f.convexPoints.length>0,completeConvexShape:e=>{if(f.convexPoints=[],f.bConvexBuilding=!1,void 0===f.currSemNode)return;void 0===e&&(e="sem"+f._numShapes);let t=ATON.getSemanticNode(e)||ATON.createSemanticNode(e),o=f.currSemNode.children[0];return ATON.SUI.addSemIcon(e,o),t.add(o),t.setMaterial(ATON.MatHub.materials.semanticShape),t.setDefaultAndHighlightMaterials(ATON.MatHub.materials.semanticShape,f.currMaterial),t.enablePicking(),f.currSemNode.removeChildren(),f._numShapes++,ATON.SUI.gPoints.removeChildren(),ATON._bqSem=!0,t},createConvexShape:(e,t)=>{let o=new THREE.ConvexGeometry(t),i=new THREE.Mesh(o,ATON.MatHub.materials.semanticShape);i.userData._convexPoints=[];for(let e=0;e{if(void 0===ATON._queryDataScene)return!1;void 0===e&&(e=.02);let t=ATON._queryDataScene.p,o=ATON.Nav.getCurrentEyeLocation();return t.lerpVectors(t,o,e),f.addConvexPoint(t),t},createSphere:(e,t,o)=>{if(void 0===t)return;if(void 0===o)return;void 0===e&&(e="sem"+f._numShapes);let i=ATON.getOrCreateSemanticNode(e),r=new THREE.Mesh(ATON.Utils.geomUnitSphere,ATON.MatHub.materials.semanticShape),a=new THREE.Object3D;return a.position.copy(t),a.scale.set(o,o,o),a.add(r),ATON.SUI.addSemIcon(e,a),i.add(a),i.enablePicking(),i.setDefaultAndHighlightMaterials(ATON.MatHub.materials.semanticShape,f.currMaterial),f._numShapes++,ATON._bqSem=!0,i},createSurfaceSphere:e=>{if(!ATON._queryDataScene)return;let t=ATON._queryDataScene.p,o=ATON.SUI.getSelectorRadius();return f.createSphere(e,t,o)},deleteSemanticNode:e=>{let t=ATON.getSemanticNode(e);if(void 0===t)return!1;if(t.removeChildren(),void 0===ATON.SUI.gSemIcons)return!0;for(let t in ATON.SUI.gSemIcons.children){let o=ATON.SUI.gSemIcons.children[t];o&&o.name===e&&ATON.SUI.gSemIcons.removeChild(o)}return!0}};const E=f;let R={SEMSHAPE_SPHERE:0,SEMSHAPE_CONVEX:1,POPUP_DT:500,STD_SEL_RAD:.05,_bRealized:!1,realize:()=>{if(R._bRealized)return;R.PATH_RES_ICONS=ATON.PATH_RES+"icons/",R._bPopup=!1,R._tPopup=void 0,R.popupBlurBG=0,R._userAuth={},R._bControlLight=!1,R._bControlSelScale=!1,R._cLightDir=new THREE.Vector3,R._auSemNode=void 0,R._auSemNodePlaying=!1,R._bReqHome=!1,R._bVRCsetup=!1,R.urlParams=new URLSearchParams(window.location.search),R._uiSetupBase(),R._uiProfiles={},R._uiCurrProfile=void 0,R._selRanges=[.01,50],R._selRefRadius=.5,ATON.realize(),ATON.on("Fullscreen",(e=>{R.uiSwitchButton("fullscreen",e)}));let e=ATON.FE.urlParams.get("d");e&&e>0&&(ATON.setDefaultPixelDensity(e),ATON.toggleAdaptiveDensity(!1));let t=ATON.FE.urlParams.get("dd");t&&t>0&&ATON.toggleAdaptiveDensity(!0),R._canvas=ATON._renderer.domElement,R._bSem=!1,R._bShowSemLabel=!0,R._bRealized=!0,R.loadSceneID=ATON.App.loadScene},_handleHomeReq:()=>{R._bReqHome||ATON.getRootScene().getBound().radius<=0||(R._bReqHome=!0,void 0!==ATON.Nav.homePOV?ATON.Nav.requestHome(1):ATON.Nav.computeAndRequestDefaultHome(.5))},addBasicLoaderEvents:()=>{ATON.on("NodeRequestFired",(()=>{$("#idLoader").show()})),ATON.on("SceneJSONLoaded",(()=>{ATON.SceneHub.getDescription()&&$("#btn-info").show(),void 0!==ATON.Nav.homePOV&&ATON.Nav.requestHome(1),ATON.XPFNetwork._list.length>0&&void 0===ATON.Nav.homePOV&&(ATON.XPFNetwork.setHomeXPF(0),ATON.XPFNetwork.requestTransitionByIndex(0))})),ATON.on("AllNodeRequestsCompleted",(()=>{$("#idLoader").hide(),ATON.CC.anyCopyrightFound()&&$("#btn-cc").show(),R.computeSelectorRanges(),ATON.SUI.setSelectorRadius(Math.min(R.STD_SEL_RAD,R._selRefRadius)),R._handleHomeReq()})),ATON.on("XR_support",(e=>{"immersive-vr"===e.type&&(e.v?$("#btn-vr").show():$("#btn-vr").hide())})),ATON.on("SemanticNodeHover",(e=>{let t=ATON.getSemanticNode(e);void 0!==t&&(R.showSemLabel(e),R._bSem=!0,t.highlight(),$("canvas").css({cursor:"crosshair"}),ATON.SUI.gSemIcons&&ATON.SUI.gSemIcons.hide())})),ATON.on("SemanticNodeLeave",(e=>{let t=ATON.getSemanticNode(e);void 0!==t&&(R.hideSemLabel(),R._bSem=!1,t.restoreDefaultMaterial(),$("canvas").css({cursor:"grab"}),ATON.SUI.gSemIcons&&ATON.SUI.gSemIcons.show())})),ATON.on("SemanticMaskHover",(e=>{R.showSemLabel(e),R._bSem=!0,$("canvas").css({cursor:"crosshair"})})),ATON.on("SemanticMaskLeave",(e=>{R.hideSemLabel(),R._bSem=!1,$("canvas").css({cursor:"grab"})})),ATON.addUpdateRoutine(R._update)},showSemLabel:e=>{R._bShowSemLabel&&($("#idPopupLabel").html(e),$("#idPopupLabel").show(),ATON.SUI.setInfoNodeText(e))},hideSemLabel:()=>{$("#idPopupLabel").hide(),$("#idPopupLabel").html("")},controlLight:e=>{R._bControlLight=e,ATON.Nav.setUserControl(!e)},controlSelectorScale:e=>{R._bControlSelScale=e,ATON._bPauseQuery=e,ATON.Nav.setUserControl(!e)},attachGizmoToNode:e=>{if(void 0===ATON._gizmo)return;let t=ATON.getSceneNode(e);void 0!==t&&ATON._gizmo.attach(t)},useMouseWheelToScaleSelector:e=>{void 0===e&&(e=.9),ATON.on("MouseWheel",(t=>{if(ATON._kModCtrl){let e=ATON.Nav.getFOV();return t>0?e+=1:e-=1,void ATON.Nav.setFOV(e)}if(ATON._kModShift){let o=ATON.SUI.mainSelector.scale.x;return t>0?o*=e:o/=e,oR._selRanges[1]&&(o=R._selRanges[1]),void ATON.SUI.setSelectorRadius(o)}}))},_update:()=>{if(R._bControlLight){const e=ATON._screenPointerCoords.x,t=ATON._screenPointerCoords.y;R._cLightDir.x=-Math.cos(e*Math.PI),R._cLightDir.y=4*-t,R._cLightDir.z=-Math.sin(e*Math.PI),R._cLightDir.normalize(),ATON.setMainLightDirection(R._cLightDir)}if(ATON.XR._bPresenting){let e=ATON.XR.getAxisValue(ATON.XR.HAND_R);if(!ATON.Photon._bStreamFocus){let t=ATON.SUI._selectorRad;t+=.01*e.y,t>.001&&ATON.SUI.setSelectorRadius(t)}}else{if(ATON.Nav.isTransitioning()||ATON.Nav._bInteracting||ATON._bPauseQuery)return void $("#idPopupLabel").hide();if(R._bSem&&R._bShowSemLabel){$("#idPopupLabel").show();let e=.5*ATON._screenPointerCoords.x*window.innerWidth,t=.5*(1-ATON._screenPointerCoords.y)*window.innerHeight;t-=55,$("#idPopupLabel").css("transform","translate("+e+"px, "+t+"px)")}else $("#idPopupLabel").hide()}},uiBasicSetup:()=>{R.uiAddButton("idTopToolbar","fullscreen",ATON.toggleFullScreen),ATON.Utils.isConnectionSecure()&&R.uiAddButton("idTopToolbar","vr",ATON.XR.toggle),R.uiAddButton("idBottomToolbar","home",(()=>{ATON.Nav.requestHome(.1)}))},_uiSetupBase:()=>{$("#idPopup").click(R.popupClose),$("#idLoader").html(""),$("body").prepend("
    "),R.hideSemLabel()},uiAddButton:(e,t,o,i)=>{let r,a;t.endsWith(".png")?(r=t,a=t.slice(0,-4)):(r=R.PATH_RES_ICONS+t+".png",a=t);let n=$("
    ");$("#"+e).append(n),o&&n.click(o),i&&n.attr("title",i)},uiSwitchButton:(e,t)=>{t?$("#btn-"+e).addClass("switchedON"):$("#btn-"+e).removeClass("switchedON")},uiSetButtonHandler:(e,t)=>{$("#"+e).click(t)},uiAddButtonHome:e=>{R.uiAddButton(e,"home",(()=>{ATON.Nav.requestHome(.3)}),"Home viewpoint")},uiAddButtonBack:(e,t)=>{R.uiAddButton(e,"back",(()=>{t&&t.length>1&&t.startsWith("http:")?ATON.Utils.goToURL(t):history.back()}),"Go Back")},uiAddButtonFirstPerson:e=>{R.uiAddButton(e,"fp",(()=>{ATON.Nav.isFirstPerson()?(ATON.Nav.setOrbitControl(),R.uiSwitchButton("fp",!1)):(ATON.Nav.setFirstPersonControl(),R.uiSwitchButton("fp",!0))}),"First-person navigation mode"),ATON.Nav.isFirstPerson()?R.uiSwitchButton("fp",!0):R.uiSwitchButton("fp",!1)},uiAddButtonVR:e=>{ATON.Utils.isConnectionSecure()&&(R.uiAddButton(e,"vr",(()=>{ATON.XR.toggle("immersive-vr")}),"Immersive VR mode"),ATON.Utils.isVRsupported()||$("#btn-vr").hide())},uiAddButtonAR:e=>{ATON.Utils.isConnectionSecure()&&R.uiAddButton(e,"ar",(()=>{ATON.Utils.isARsupported()&&ATON.XR.toggle("immersive-ar")}),"Immersive AR mode")},uiAddButtonDeviceOrientation:e=>{ATON.Utils.isConnectionSecure()&&ATON.Utils.isMobile()&&(R.uiAddButton(e,"devori",(()=>{ATON.Nav.isDevOri()?(ATON.Nav.restorePreviousNavMode(),R.uiSwitchButton("devori",!1)):(ATON.Nav.setDeviceOrientationControl(),R.uiSwitchButton("devori",!0))}),"Device-orientation mode"),ATON.Nav.isDevOri()?R.uiSwitchButton("devori",!0):R.uiSwitchButton("devori",!1))},uiAddButtonNav:e=>{R.uiAddButton(e,"nav",(()=>{R.popupNav()}),"Navigation")},uiAddButtonTalk:e=>{ATON.Utils.isConnectionSecure()&&(R.uiAddButton(e,"talk",(()=>{ATON.MediaFlow.isAudioRecording()?(ATON.MediaFlow.stopAudioStreaming(),$("#btn-talk").removeClass("atonBTN-rec")):(ATON.MediaFlow.startAudioStreaming(),$("#btn-talk").addClass("atonBTN-rec"))}),"Talk ON/OFF"),ATON.MediaFlow.isAudioRecording()?$("#btn-talk").addClass("atonBTN-rec"):$("#btn-talk").removeClass("atonBTN-rec"))},uiAddButtonStreamFocus:e=>{R.uiAddButton(e,"focus",(()=>{ATON.Photon._bStreamFocus?(ATON.Photon.setFocusStreaming(!1),$("#btn-focus").removeClass("atonBTN-rec")):(ATON.Photon.setFocusStreaming(!0),$("#btn-focus").addClass("atonBTN-rec"))}),"Focus streaming ON/OFF"),ATON.Photon._bStreamFocus?$("#btn-focus").addClass("atonBTN-rec"):$("#btn-focus").removeClass("atonBTN-rec")},uiAddButtonMainVideoPanoPlayPause:e=>{R.uiAddButton(e,"playpause",(()=>{ATON._vpanoPlaying?ATON._elPanoVideo&&ATON._elPanoVideo.pause():ATON._elPanoVideo&&ATON._elPanoVideo.play()}),"360 Video play/pause"),ATON._elPanoVideo?$("#btn-playpause").show():$("#btn-playpause").hide()},uiAddButtonQR:e=>{ATON.Utils.isLocalhost()||R.uiAddButton(e,"qr",R.popupQR,"QR-code")},uiAddButtonScreenshot:e=>{R.uiAddButton(e,"sshot",R.popupScreenShot,"Screenshot")},uiAddButtonInfo:e=>{R.uiAddButton(e,"info",ATON.FE.popupSceneInfo,"Scene information"),$("#btn-info").hide()},uiAddButtonFullScreen:e=>{R.uiAddButton(e,"fullscreen",(()=>{ATON.toggleFullScreen()}),"Fullscreen"),R.uiSwitchButton("fullscreen",ATON.isFullscreen())},uiAddKeywordsArea:(e,t,o,i)=>{let r="";r+="Add keyword:

    ",r+="
    ",$("#"+e).html(r),R.uiAttachInputFilterID("idKWordInput"),$.getJSON(ATON.PATH_RESTAPI+"keywords/",(t=>{let o="";for(let e in t)o+="";o+="",$("#"+e).append(o)}));let a={},n=e=>{a[e]||(e=e.toLowerCase().trim(),$("#idKWordInput").val(""),a[e]=1,console.log("Added keyword "+e),o&&o(e),$("#idKWords").append("
    "+e+"
    "),$("#idkw-"+e).click((()=>{$("#idkw-"+e).remove(),a[e]=void 0,console.log("Removed keyword "+e),i&&i(e)})))};if(t)for(let e in t)n(t[e]);$("#idKWordInput").keypress((function(e){if("13"!=(e.keyCode?e.keyCode:e.which))return;let t=$("#idKWordInput").val().toLowerCase().trim();!t||t.length<3||n(t)})),$("#idKWadd").click((()=>{let e=$("#idKWordInput").val().toLowerCase().trim();!e||e.length<3||n(e)}))},uiAttachCollectionItemsToInput:(e,t)=>{let o="";$("#"+e).attr("list",e+"-list"),$("#"+e).attr("name",e+"-list"),$.getJSON(ATON.PATH_RESTAPI+"c/"+t+"/",(t=>{o+="";for(let e in t){let i=t[e];o+=""}o+="",$("#"+e).html(o)}))},getVRCclassFromID:e=>"atonVRCu"+e%6,_setupVRCevents:()=>{R._bVRCsetup||(ATON.on("VRC_IDassigned",(e=>{$("#btn-vrc").addClass(R.getVRCclassFromID(e)),ATON.SUI.setSelectorColor(ATON.Photon.color),ATON.plight.color=ATON.Photon.color,R.checkAuth((e=>{void 0!==e.username&&ATON.Photon.setUsername(e.username)}))})),ATON.on("VRC_SceneState",(e=>{let t=ATON.Photon.getNumUsers();t>1?$("#idVRCnumusers").html(t):$("#idVRCnumusers").html(""),console.log("Users: "+t)})),ATON.on("VRC_Disconnected",(()=>{$("#btn-vrc").attr("class","atonBTN"),ATON.SUI.setSelectorColor(ATON.MatHub.colors.defUI),ATON.MediaFlow.stopAllStreams(),$("#idVRCnumusers").html("")})),R._bVRCsetup=!0)},uiAddButtonPhoton:e=>{R.uiAddButton(e,"vrc",(()=>{ATON.Photon.isConnected()?R.popupVRC():ATON.Photon.connect()}),"Photon (collaborative session)"),$("#btn-vrc").append(""),R._setupVRCevents(),void 0!==ATON.Photon.uid?$("#btn-vrc").addClass(R.getVRCclassFromID(ATON.Photon.uid)):$("#btn-vrc").attr("class","atonBTN")}};R.uiAddButtonVRC=R.uiAddButtonPhoton,R.uiAddButtonUser=e=>{R.uiAddButton(e,"user",(()=>{R.popupUser()}),"User"),R.checkAuth((e=>{void 0!==e.username?$("#btn-user").addClass("switchedON"):$("#btn-user").removeClass("switchedON")}))},R.uiSetEditMode=(e,t)=>{ATON.SceneHub._bEdit=e,R.uiSwitchButton("edit",e),ATON._renderer.domElement,e?$("#"+t).addClass("atonToolbar-bg-edit"):$("#"+t).removeClass("atonToolbar-bg-edit")},R.uiAddButtonEditMode=e=>{R.uiAddButton(e,"edit",(()=>{R.checkAuth((t=>{void 0!==t.username?(ATON.SceneHub._bEdit?R.uiSetEditMode(!1,e):R.uiSetEditMode(!0,e),console.log("Persistent Edit Mode: "+ATON.SceneHub._bEdit)):R.popupUser()}))}),"Persistent Edit Mode"),ATON.SceneHub._bEdit?R.uiSwitchButton("edit",!0):R.uiSwitchButton("edit",!1)},R.uiAddProfile=(e,t)=>{"function"==typeof t&&(R._uiProfiles[e]=t)},R.uiLoadProfile=e=>{let t=R._uiProfiles[e];void 0!==t&&(t(),R._uiCurrProfile=e,console.log("Loaded UI Profile: "+R._uiCurrProfile))},R.getCurrentUIP=()=>R._uiCurrProfile,R.attachHandlerToButton=(e,t)=>{void 0!==t&&$("#"+e).click((()=>{t()}))},R.uiAttachInputFilterID=e=>{$("#"+e).on("keyup change input",(()=>{let t=$("#"+e).val(),o=new RegExp("[^A-Za-z0-9-_]","ig");$("#"+e).val(t.replace(o,""))}))},R.switchNode=(e,t,o)=>{let i;i=o===ATON.NTYPES.SEM?ATON.getSemanticNode(e):ATON.getSceneNode(e),void 0!==i&&(i.toggle(t),ATON.fire("FE_NodeSwitch",{nid:e,t:o,v:t}))},R.uiCreateGraph=e=>{let t=ATON.snodes;e===ATON.NTYPES.SEM&&(t=ATON.semnodes);let o="";for(let i in t){let r=t[i].visible?"checked":"";"."!==i&&(o+="'+i,o+="
    ")}return o},R.setupBasicUISounds=()=>{R.auLib={},R.auLib.switch=new Audio(ATON.PATH_RES+"audio/switch.wav"),R.auLib.switch.loop=!1},R.playAudioFromSemanticNode=e=>{if(void 0===e)return;let t=ATON.getSemanticNode(e);if(void 0===t)return;let o=t.getAudio();void 0!==o&&("string"!=typeof o||o.startsWith("data:audio")||(o=ATON.Utils.resolveCollectionURL(o)),void 0===R._auSemNode||null===R._auSemNode?R._auSemNode=new THREE.Audio(ATON.AudioHub._listener):R._auSemNode.stop(),ATON.AudioHub._loader.load(o,(e=>{R._auSemNode.setBuffer(e),R._auSemNode.setLoop(!1),R._auSemNode.play()})))},R.popupShow=(e,t)=>{if(R._bPopup)return!1;R._tPopup=Date.now();let o="atonPopup ";t&&(o+=t);let i="
    ";return i+=e+"
    ",R._bPopup=!0,ATON._bListenKeyboardEvents=!1,$("#idPopup").html(i),$("#idPopupContent").click((e=>{e.stopPropagation()})),$("#idPopup").show(),R.popupBlurBG>0&&(ATON._renderer.domElement.style.filter="blur("+R.popupBlurBG+"px)"),ATON._bPauseQuery=!0,$("#idTopToolbar").hide(),$("#idBottomToolbar").hide(),$("#idBottomRToolbar").hide(),$("#idPoweredBy").hide(),!0},R.popupClose=e=>{Date.now()-R._tPopup0&&(ATON._renderer.domElement.style.filter="none"),$("#idPopup").hide(),ATON._bPauseQuery=!1,$("#idTopToolbar").show(),$("#idBottomToolbar").show(),$("#idBottomRToolbar").show(),$("#idPoweredBy").show(),ATON.focusOn3DView())},R.subPopup=e=>{ATON.FE.popupClose(),e()},R.popupQR=()=>{let e="
    Share
    ";if(e+="


    ",!ATON.FE.popupShow("
    Share


    "))return;let t=window.location.href;new QRCode(document.getElementById("idQRcode"),t)},R.popupScreenShot=()=>{let e=ATON.Utils.takeScreenshot(256);R.checkAuth((t=>{let o="
    Capture
    ";o+="This is a preview of what your screenshot will look like:

    ",o+="
    ",o+="Resolution: px
    ",o+="
    Screenshot
    ",o+="
    Record video
    ",void 0!==t.username&&(o+="
    Set as Cover
    "),ATON.FE.popupShow(o)&&(ATON.MediaFlow._bScreenRec?$("#btnScreenRec").addClass("atonBTN-rec"):$("#btnScreenRec").removeClass("atonBTN-rec"),$("#btnScreenShot").click((()=>{let e=parseInt($("#isShotSize").val());e<100||(ATON.FE.popupClose(),ATON.Utils.takeScreenshot(e,"shot.png"))})),$("#btnScreenRec").click((()=>{ATON.MediaFlow._bScreenRec||ATON.MediaFlow.startScreenRecording(),ATON.FE.popupClose()})),$("#btnSetCover").click((()=>{ATON.FE.popupClose(),ATON.Utils.postJSON(ATON.PATH_RESTAPI+"cover/scene/",{sid:ATON.SceneHub.currID,img:e.src},(e=>{console.log(e)}))})))}))},R.popupVRC=()=>{let e="",t=ATON.Photon.getNumUsers();e+=t>1?"
    Collaborative Session ("+t+" users)
    ":"
    Collaborative Session
    ",e+="
    ",e+="",e+="",e+="
    LEAVE
    ",e+="
    ",e+="",ATON.FE.popupShow(e,"atonPopupLarge")&&(ATON.checkAuth((e=>{console.log(e),ATON.MediaFlow._bCamStream||ATON.FE.uiAddButton("idCollabTools","screenshare",(()=>{ATON.MediaFlow._bScreenStream?$("#btn-screenshare").addClass("atonBTN-rec"):$("#btn-screenshare").removeClass("atonBTN-rec"),ATON.MediaFlow.startOrStopScreenStreaming(),ATON.FE.popupClose()}),"Share your screen with other participants"),!ATON.MediaFlow._bScreenStream&&ATON.MediaFlow.hasVideoInput()&&ATON.FE.uiAddButton("idCollabTools","camera",(()=>{ATON.MediaFlow._bCamStream?$("#btn-camera").addClass("atonBTN-rec"):$("#btn-camera").removeClass("atonBTN-rec"),ATON.MediaFlow.startOrStopCameraStreaming(),ATON.FE.popupClose()}),"Share your camera with other participants"),ATON.MediaFlow._bScreenStream?$("#btn-screenshare").addClass("atonBTN-rec"):$("#btn-screenshare").removeClass("atonBTN-rec"),ATON.MediaFlow._bCamStream?$("#btn-camera").addClass("atonBTN-rec"):$("#btn-camera").removeClass("atonBTN-rec")})),void 0===ATON.Photon._username?($("#idVRCusername").show(),$("#idVRCusernameBTN").hide()):($("#idVRCusername").val(ATON.Photon._username),$("#idVRCusername").hide(),$("#idVRCusernameBTN").show()),void 0!==ATON.Photon.uid&&$("#idVRCusernameBTN").addClass("atonVRCu"+ATON.Photon.uid%6),$("#idChatBoxPopup").append(ATON.Photon._elChat),$("#idVRCmsg").keypress((e=>{if("13"==(e.keyCode?e.keyCode:e.which)){let e=$("#idVRCmsg").val();ATON.Photon.setMessage(e),$("#idVRCmsg").val("")}})),$("#idVRCusername").keypress((e=>{if("13"==(e.keyCode?e.keyCode:e.which)){let e=$("#idVRCusername").val();ATON.Photon.setUsername(e),$("#idVRCusername").hide(),$("#idVRCusernameBTN").html(ATON.Photon._username),$("#idVRCusernameBTN").show()}})),$("#idVRCusernameBTN").click((()=>{$("#idVRCusername").show(),$("#idVRCusernameBTN").hide()})),$("#idVRCdisconnect").click((()=>{ATON.Photon.disconnect(),ATON.FE.popupClose()})))},R.checkAuth=e=>{ATON.Utils.checkAuth((t=>{R._userAuth=t,void 0!==t.username?($("#btn-user").addClass("switchedON"),void 0===ATON.Photon._username&&ATON.Photon.setUsername(t.username)):$("#btn-user").removeClass("switchedON"),e&&e(t)}))},R.popupUser=()=>{R.checkAuth((e=>{if(void 0!==e.username){let t="
    ";if(t+="'"+e.username+"'

    ",Object.keys(R._uiProfiles).length>0){t+="UI Profile:


    "}if(t+="
    LOGOUT
    ",!ATON.FE.popupShow(t))return;R._uiCurrProfile&&(console.log(R._uiCurrProfile),$("#idUIProfiles").val(R._uiCurrProfile)),$("#idLogoutBTN").click((()=>{$.get(ATON.PATH_RESTAPI+"logout",(e=>{console.log(e),ATON.SceneHub.setEditMode(!1),R.uiSwitchButton("edit",!1),ATON.fire("Logout"),$("#btn-user").removeClass("switchedON")})),ATON.FE.popupClose()})),$("#idSHUscenes").click((()=>{ATON.Utils.goToURL("/shu/scenes/")})),$("#idSHUuser").click((()=>{ATON.Utils.goToURL("/shu/auth/")})),$("#idUIProfiles").on("change",(()=>{let e=$("#idUIProfiles").val();R.uiLoadProfile(e),ATON.FE.popupClose()}))}else{let e="
    ";if(e+="username:
    ",e+="password:
    ",e+="
    LOGIN
    ",!ATON.FE.popupShow(e))return;$("#idLoginBTN").click((()=>{let e=JSON.stringify({username:$("#idUsername").val(),password:$("#idPassword").val()});$.ajax({url:ATON.PATH_RESTAPI+"login",type:"POST",data:e,contentType:"application/json; charset=utf-8",dataType:"json",success:e=>{console.log(e),e&&(ATON.fire("Login",e),$("#btn-user").addClass("switchedON"),ATON.FE.popupClose())}}).fail((e=>{$("#idLoginBTN").html("LOGIN FAILED"),$("#idLoginBTN").attr("class","atonBTN atonBTN-red")}))}))}}))},R.popupSceneInfo=()=>{let e=ATON.SceneHub.getTitle();void 0===e&&(e=ATON.SceneHub.currID);let t=ATON.SceneHub.getDescription(),o="
    "+e+"
    ";t&&(o+="
    "+JSON.parse(t)+"
    "),o+="
    OK
    ",ATON.FE.popupShow(o)&&$("#btnOK").click((()=>{ATON._onUserInteraction(),ATON.FE.popupClose()}))},R.computeSelectorRanges=()=>{let e=ATON.bounds.radius;e<=0||(R._selRanges[0]=.001*e,R._selRefRadius=.01*e,R._selRanges[1]=.5*e)},R.popupSelector=()=>{let e="
    3D Selector
    ",t=ATON.SUI.getSelectorRadius(),o=ATON.Utils.getHumanReadableDistance(t);R.computeSelectorRanges(),e+="Radius ("+o+"):
    ",e+="",ATON.FE.popupShow(e,"atonPopupLarge")&&($("#idSelRad").val(t),$("#idSelRad").on("input change",(()=>{let e=parseFloat($("#idSelRad").val());ATON.SUI.setSelectorRadius(e),$("#idSelRadTxt").html(ATON.Utils.getHumanReadableDistance(e))})))},R.popupNav=()=>{let e="
    Navigation
    ";e+="
    ",e+="
    ",e+="
    Switch between first-person and orbit navigation mode
    ",e+="
    ",ATON.Utils.isConnectionSecure()&&(e+="
    ",e+="
    ",e+="
    Immersive VR mode
    ",e+="
    ",ATON.Utils.isMobile()&&(e+="
    ",e+="
    ",e+="
    Enable or disable device-orientation mode
    ",e+="
    ")),R.popupShow(e)&&(R.uiAddButtonFirstPerson("idNMfp"),R.uiAddButtonDeviceOrientation("idNMdevori"),R.uiAddButtonVR("idNMvr"))},R.popupModalToken=(e,t)=>{if(void 0===t)return;ATON.FE.popupClose();let o="
    Token Required
    ";e&&(o+=e),o+="

    ",o+="
    OK
    ",R.popupShow(o)&&$("#btnTokenOK").click((()=>{let e=$("#idTokStr").val();void 0===e||e.length<2||(ATON.FE.popupClose(),t(e))}))},R.popupNewNode=e=>{void 0===e&&(e=ATON.NTYPES.SCENE);let t="";e===ATON.NTYPES.SCENE&&(t="
    New Scene Node
    "),e===ATON.NTYPES.SEM&&(t="
    New Semantic Node
    "),t+="ID:
    ",t+="
    Add

    ",R.popupShow(t)&&$("#btnNewNID").click((()=>{let t=$("#idNID").val().trim();void 0===t||t.length<3||new ATON.Node(t,e).attachToRoot()}))};const y=R;let w={auType:"audio/wav",auStreamSegmentInterval:200,auStreamNumSegments:2,vidStreamSegmentInterval:300,vidStreamNumSegments:1,auMinVol:1,init:()=>{w._bAudioRecording=!1,w._bAudioStreaming=!1,w._bScreenRec=!1,w._blobOptAudio={type:"audio/wav"},w._blobOptVideo={type:"video/mp4"},w._cAuStream={audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}},w._cAuRec={audio:{channelCount:1}},w._cScreenRec={video:{width:1280,height:720,framerate:30}},w._cScreenStream={video:{cursor:"always",width:{max:640},height:{max:360},framerate:15}},w._cCamStream={video:{width:{max:512},height:{max:512}}},w._oStream={audioBitsPerSecond:9e3,videoBitsPerSecond:5e5},w._aurec=void 0,w._sblob=void 0,w._schunks=[],w._bVideoStream=!1,w._vrec=void 0,w._scblob=void 0,w._scchunks=[],w._bCamStream=!1,w._bScreenStream=!1,w._setupFR(),w.detectDevices(),navigator.mediaDevices&&navigator.mediaDevices.addEventListener("devicechange",(e=>{w.detectDevices()})),w._vStreams={}},_setupFR:()=>{w._frAR=new window.FileReader,w._frAR.onloadend=()=>{let e=w._frAR.result;ATON.fire("AudioRecordCompleted",e),w._bAudioRecording=!1},w._frAS=new window.FileReader,w._frAS.onloadend=()=>{if(!w._bAudioStreaming)return;let e=w._frAS.result;ATON.Photon.socket.emit("UTALK",{audio:e,uid:ATON.Photon.uid}),e=null},w._frVS=new window.FileReader,w._frVS.onloadend=()=>{if(!w._bVideoStream)return;let e=w._frVS.result;ATON.Photon.socket.emit("UVIDEO",{video:e,uid:ATON.Photon.uid}),e=null}},detectDevices:()=>{w.audioInputDevices=[],w.videoInputDevices=[],navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices().then((e=>{for(let t in e){let o=e[t];"audioinput"===o.kind&&w.audioInputDevices.push(o),"videoinput"===o.kind&&w.videoInputDevices.push(o)}}))},hasAudioInput:()=>w.audioInputDevices.length>0,hasVideoInput:()=>w.videoInputDevices.length>0,isAudioRecording:()=>w._bAudioRecording,startRecording:()=>{w._bAudioRecording?console.log("Already recording."):navigator.mediaDevices.getUserMedia(w._cAuRec).then((e=>{w._aurec=new MediaRecorder(e),w._aurec.onstart=function(e){console.log("Start recording..."),w._bAudioRecording=!0,w._schunks=[]},w._aurec.ondataavailable=function(e){w._schunks.push(e.data)},w._aurec.onstop=function(e){console.log("Stop recording..."),w._sblob=new Blob(w._schunks,w._blobOptAudio),w._frAR.readAsDataURL(w._sblob)},w._aurec.start()})).catch((e=>{console.log(e)}))},stopRecording:()=>{w._aurec&&w._bAudioRecording&&w._aurec.stop()},startOrStopRecording:()=>{w._bAudioRecording?w.stopRecording():w.startRecording()},startAudioStreaming:()=>{navigator.mediaDevices.getUserMedia(w._cAuStream).then((e=>{w._aurec=new MediaRecorder(e,w._oStream),w._aurec.start(w.auStreamSegmentInterval),console.log("Start audio streaming"),w._aurec.onstart=e=>{w._bAudioStreaming=!0,w._bAudioRecording=!0,w._schunks=[]},w._aurec.ondataavailable=e=>{e.data.size<=0||(w._schunks.push(e.data),w._schunks.length{w._sblob=new Blob(w._schunks,w._blobOptAudio),w._frAS.readAsDataURL(w._sblob),w._bAudioStreaming&&w._aurec.start(w.auStreamSegmentInterval)}})).catch((e=>{console.log(e)}))},stopAudioStreaming:()=>{w._aurec&&w._bAudioStreaming&&("inactive"!==w._aurec.state&&w._aurec.stop(),console.log("Stop audio streaming"),w._bAudioStreaming=!1,w._bAudioRecording=!1,ATON.Photon.socket.emit("UAUDIOSTOP",{uid:ATON.Photon.uid}))},startOrStopAudioStreaming:()=>{w._bAudioRecording?w.stopAudioStreaming():w.startAudioStreaming()},startScreenRecording:()=>{w._bScreenRec||w._bScreenStream||navigator.mediaDevices.getDisplayMedia(w._cScreenRec).then((e=>{w._vrec=new MediaRecorder(e),w._scchunks=[],w._vrec.ondataavailable=e=>{e.data.size>0&&w._scchunks.push(e.data)},w._vrec.onstop=()=>{w._scblob=new Blob(w._scchunks,w._blobOptVideo),console.log(w._scblob.size),ATON.Utils.downloadBlob(w._scblob,"capture.mp4"),w._scchunks=[],w._bScreenRec=!1},w._vrec.start(200),w._bScreenRec=!0})).catch((e=>{console.log(e)}))},stopScreenRecording:()=>{w._bScreenRec&&(w._vrec.stop(),w._bVideoStream=!1,w._bScreenStream=!1,console.log("Stop screen recording"))},startScreenStreaming:()=>{navigator.mediaDevices.getDisplayMedia(w._cScreenStream).then((e=>{w.realizeOrUpdateVStream(e,w.stopScreenStreaming),w._vrec=new MediaRecorder(e,w._oStream),w._vrec.start(w.vidStreamSegmentInterval),console.log("Start screen streaming"),w._vrec.onstart=e=>{w._bVideoStream=!0,w._bScreenStream=!0,w._scchunks=[]},w._vrec.ondataavailable=e=>{e.data.size<1||(w._scchunks.push(e.data),w._scchunks.length{w._scblob=new Blob(w._scchunks,w._blobOptVideo),w._frVS.readAsDataURL(w._scblob),w._bVideoStream&&w._vrec.start(w.vidStreamSegmentInterval)}})).catch((e=>{console.log(e)}))},stopScreenStreaming:()=>{if(w._vrec&&w._bVideoStream&&(w._vrec.stop(),w._bVideoStream=!1,w._bScreenStream=!1,console.log("Stop screen streaming"),void 0!==ATON.Photon.uid)){let e=w.getVideoStream(ATON.Photon.uid);e.el.style.display="none",e.el.pause(),ATON.Photon.socket.emit("UVIDEOSTOP",{uid:ATON.Photon.uid})}},startOrStopScreenStreaming:()=>{w._bVideoStream?w.stopScreenStreaming():w.startScreenStreaming()},startCameraStreaming:()=>{w._bVideoStream||navigator.mediaDevices.getUserMedia(w._cCamStream).then((e=>{w.realizeOrUpdateVStream(e,w.stopCameraStreaming),w._vrec=new MediaRecorder(e,w._oStream),w._vrec.start(w.vidStreamSegmentInterval),console.log("Start camera streaming"),w._vrec.onstart=e=>{w._bVideoStream=!0,w._bCamStream=!0,w._scchunks=[]},w._vrec.ondataavailable=e=>{e.data.size<1||(w._scchunks.push(e.data),w._scchunks.length{w._scblob=new Blob(w._scchunks,w._blobOptVideo),w._frVS.readAsDataURL(w._scblob),w._bVideoStream&&w._vrec.start(w.vidStreamSegmentInterval)}})).catch((e=>{console.log(e)}))},stopCameraStreaming:()=>{if(w._vrec&&w._bVideoStream&&(w._vrec.stop(),w._bVideoStream=!1,w._bCamStream=!1,console.log("Stop camera streaming"),void 0!==ATON.Photon.uid)){let e=w.getVideoStream(ATON.Photon.uid);e.el.style.display="none",e.el.pause(),ATON.Photon.socket.emit("UVIDEOSTOP",{uid:ATON.Photon.uid})}},startOrStopCameraStreaming:()=>{w._bVideoStream?w.stopCameraStreaming():w.startCameraStreaming()},realizeOrUpdateVStream:(e,t)=>{let o=ATON.Photon.uid;if(void 0===o)return;let i=w.getOrCreateVideoStream(o,void 0,!0);i.el.playsinline=!0,i.el.style.display="inline-block",i.el.classList.add("atonVRCvidStream"),i.el.classList.add("atonVRCu"+o%6),t&&(i.el.onclick=t),i.el.srcObject=e},stopAllStreams:()=>{w.stopAudioStreaming(),w.stopCameraStreaming(),w.stopScreenStreaming()},getOrCreateVideoStream:(e,t,o)=>{if(w._vStreams[e])t&&(w._vStreams[e].el.src=t);else{w._vStreams[e]={};let i="vStream-"+e;if(o&&(i="uStream"+e,w._vStreams[e].uid=e),$("").appendTo("body"),w._vStreams[e].el=document.getElementById(i),t)if(t.endsWith("m3u8"))if(Hls.isSupported()){let o=new Hls;o.loadSource(t),o.attachMedia(w._vStreams[e].el)}else w._vStreams[e].el.src=t;else w._vStreams[e].el.src=t;o||(w._vStreams[e].el.loop=!0),w._vStreams[e].texStream=new THREE.VideoTexture(w._vStreams[e].el),w._vStreams[e].texStream.colorSpace=ATON._stdEncoding,w._vStreams[e].texStream.flipY=!1,w._vStreams[e].matStream=ATON.MatHub.materials.chromakey.clone(),w._vStreams[e].matStream.uniforms.tBase.value=w._vStreams[e].texStream}return w._vStreams[e]},getVideoStream:e=>w._vStreams[e],downloadVideoSnapshot:(e,t,o)=>{o||(o=1);let i=e.videoWidth*o,r=e.videoHeight*o,a=document.createElement("canvas");a.width=i,a.height=r,a.getContext("2d").drawImage(e,0,0,i,r),ATON.Utils.downloadImageFromCanvas(a,t)}};const M=w;let L={EARTH_R_KM:6371};L.EARTH_D_KM=2*L.EARTH_R_KM,L.init=()=>{L._bActive=!1,L._wpid=void 0,L._currGeoPos=new THREE.Vector2,L._GeoPOIs=[],L._currGeoPOI=void 0,L._closestGeoPOI=void 0,L._maxGeoError=40},L.enableGeoTracking=()=>{L._bActive||ATON.Utils.isConnectionSecure()&&navigator.geolocation&&(L._wpid=navigator.geolocation.watchPosition(L._onGeoPosition,L._onGeoError,{enableHighAccuracy:!0}),L._bActive=!0)},L.disableGeoTracking=()=>{L._bActive&&(navigator.geolocation.clearWatch(L._wpid),L._bActive=!1)},L.setMaxGeoError=e=>{e>0&&(L._maxGeoError=e)},L._onGeoError=()=>{console.log("Geolocation error")},L._onGeoPosition=e=>{if(!L._bActive)return;if(!e.coords)return;let t=e.coords.accuracy;t&&t>L._maxGeoError||(L._currGeoPos.x=e.coords.latitude,L._currGeoPos.y=e.coords.longitude,ATON.fire("GeoLocation",e),L._handleGeoPOIs())},L._handleGeoPOIs=()=>{let e=L._GeoPOIs.length;if(!(e<=0)){L._closestGeoPOIdist=void 0,L._closestGeoPOI=void 0;for(let t=0;t{if(L._bActive)return L._currGeoPos},L.geolocationFromLatLon=(e,t)=>new THREE.Vector2(e,t),L.geodistance_orig=(e,t)=>{let o=ATON.DEG2RAD*(t.x-e.x),i=ATON.DEG2RAD*(t.y-e.y),r=Math.sin(o/2)*Math.sin(o/2)+Math.cos(ATON.DEG2RAD*e.x)*Math.cos(ATON.DEG2RAD*t.x)*Math.sin(i/2)*Math.sin(i/2),a=2*Math.atan2(Math.sqrt(r),Math.sqrt(1-r));return L.EARTH_R_KM*a*1e3},L.geodistance=(e,t)=>{let o=.5-Math.cos((t.x-e.x)*ATON.DEG2RAD)/2+Math.cos(e.x*ATON.DEG2RAD)*Math.cos(t.x*ATON.DEG2RAD)*(1-Math.cos((t.y-e.y)*ATON.DEG2RAD))/2;return L.EARTH_D_KM*Math.asin(Math.sqrt(o))*1e3},L.addGeoPOI=(e,t)=>{let o={};return o.pos=new THREE.Vector2(e.x,e.y),o.radius=t,L._GeoPOIs.push(o),L._bActive||L.enableTracking(),L._handleGeoPOIs(),L._GeoPOIs.length-1},L.getGeoPOIbyIndex=e=>L._GeoPOIs[e],L.getClosestGeoPOI=()=>L._closestGeoPOI,L.getClosestGeoPOIdistance=()=>L._closestGeoPOIdist;const C=L;let H={};H._id=$("meta[name='aton\\:appid']").attr("content"),H._data={},H.setup=void 0,H.update=void 0,H._bRunning=!1,H._pDeps=[],H._fLoading=0,H._sendDataPatch=(e,t,o)=>new Promise(((i,r)=>{if(void 0===e)return void r("No storage ID specified");if(e.length<3)return void r("Storage ID too short");if(void 0===t)return void r("No storage patch");if(void 0===H._id)return void r("No app-ID");void 0===o&&(o=ATON.PATCH_ADD);let a={};a.wappid=H._id,a.fid=e,a.data=t,a.mode=o===ATON.PATCH_DEL?"DEL":"ADD";let n=JSON.stringify(a);$.ajax({url:ATON.PATH_RESTAPI+"patch/wapp",type:"POST",data:n,contentType:"application/json; charset=utf-8",dataType:"json",success:t=>{void 0!==t?(H._data[e]=t,i(t)):r("Error writing on server")}})})),H.getAppID=()=>H._id,H.addToStorage=(e,t)=>H._sendDataPatch(e,t,ATON.PATCH_ADD),H.deleteFromStorage=(e,t)=>H._sendDataPatch(e,t,ATON.PATCH_DEL),H.getStorage=e=>new Promise(((t,o)=>{void 0!==H._id?void 0!==e?$.getJSON(ATON.PATH_WAPPS+H._id+"/data/"+e+".json",(o=>{console.log(o),H._data[e]=o,t(o)})):o("No storage ID specified"):o()})),H.loadJSONConfig=(e,t)=>(ATON.Utils.getJSON(e,t),H),H.registerServiceWorker=e=>{if(e)return H.basePath&&(e=H.basePath+e),"serviceWorker"in navigator&&window.addEventListener("load",(()=>{navigator.serviceWorker.register(e).then((e=>console.log("PWA service worker registered"))).catch((e=>console.log("PWA service worker not registered",e)))})),H},H.requireFlares=e=>{if(e)return ATON._fReqList=e,console.log("Required Flares: "+ATON._fReqList),H},H.loadScene=(e,t)=>{void 0!==e&&ATON.SceneHub.load(ATON.PATH_RESTAPI2+"scenes/"+e,e,t)},H.realize=(e,t,o)=>{H.setup=e,H.update=t,H.params=new URLSearchParams(window.location.search),H.basePath=ATON.Utils.getBaseFolder(window.location.href.split("?")[0]),H.registerServiceWorker(o);let i=H.params.get("ff");if(i){let e=String(i).split(",");H.requireFlares(e)}return H},H.realizeAndRun=(e,t,o)=>{H.realize(e,t,o).run()},H.run=()=>!H._bRunning&&(H._bRunning=!0,H.setup?H.setup():(ATON.FE.realize(),console.log("App [Warn]: your App should define a setup() routine")),H.update&&(ATON.addUpdateRoutine(H.update),console.log("App: update routine registered")),ATON._fRequired<=0&&ATON.fire("AllFlaresReady"),!0);const D=H;let x={PASS_BASE:"p_base",PASS_AA:"p_aa",PASS_AO:"p_ao",PASS_SSR:"p_ssr",PASS_BLOOM:"p_bloom",PASS_DOF:"p_dof",PASS_GAMMA:"p_gamma",PASS_SOBEL:"p_sobel",init:()=>{if(void 0===ATON._renderer)return;let e=ATON._renderer.getPixelRatio(),t=ATON._renderer.getSize(new THREE.Vector2);const o=new THREE.WebGLRenderTarget(t.width*e,t.height*e,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat,colorSpace:ATON._stdEncoding});o.texture.name="EffectComposer.rt1",x.composer=new THREE.EffectComposer(ATON._renderer,o),x.passes={},ATON._renderer.autoClear=!1;let i=window.innerWidth*ATON._stdpxd,r=window.innerHeight*ATON._stdpxd;x.passes[x.PASS_BASE]=new THREE.RenderPass(ATON._mainRoot,ATON.Nav._camera),x.composer.addPass(x.passes[x.PASS_BASE]),x.passes[x.PASS_AO]=new THREE.SAOPass(ATON._mainRoot,ATON.Nav._camera,i,r),x.passes[x.PASS_AO].params.saoBias=1,x.passes[x.PASS_AO].params.saoScale=100,x.passes[x.PASS_AO].params.saoIntensity=.2,x.passes[x.PASS_BLOOM]=new THREE.UnrealBloomPass(new THREE.Vector2(i,r),1.5,.4,.85),x.passes[x.PASS_BLOOM].threshold=.9,x.passes[x.PASS_BLOOM].strength=1,x.passes[x.PASS_BLOOM].radius=1.2,x.passes[x.PASS_DOF]=new THREE.BokehPass(ATON._mainRoot,ATON.Nav._camera,{focus:5,aperture:.001,maxblur:.01,width:i,height:r}),x.composer.addPass(x.passes[x.PASS_AO]),x.composer.addPass(x.passes[x.PASS_DOF]),x.composer.addPass(x.passes[x.PASS_BLOOM]),x.togglePass(x.PASS_AO,!1),x.togglePass(x.PASS_BLOOM,!1),x.togglePass(x.PASS_DOF,!1)},togglePass:(e,t)=>{void 0!==x.composer&&(ATON.device.lowGPU||void 0!==x.passes[e]&&(x.passes[e].enabled=void 0===t?!x.passes[e].enabled:t))},isPassEnabled:e=>void 0!==x.composer&&(void 0!==x.passes[e]&&x.passes[e].enabled),setAOintensity:e=>{void 0!==x.composer&&void 0!==x.passes[x.PASS_AO]&&(x.passes[x.PASS_AO].params.saoIntensity=e)},getAOintensity:()=>void 0===x.composer||void 0===x.passes[x.PASS_AO]?0:x.passes[x.PASS_AO].params.saoIntensity,setBloomStrength:e=>{void 0!==x.composer&&void 0!==x.passes[x.PASS_BLOOM]&&(x.passes[x.PASS_BLOOM].strength=e)},getBloomStrength:()=>void 0===x.composer||void 0===x.passes[x.PASS_BLOOM]?0:x.passes[x.PASS_BLOOM].strength,setBloomThreshold:e=>{void 0!==x.composer&&void 0!==x.passes[x.PASS_BLOOM]&&(x.passes[x.PASS_BLOOM].threshold=e)},getBloomThreshold:()=>void 0===x.composer||void 0===x.passes[x.PASS_BLOOM]?0:x.passes[x.PASS_BLOOM].threshold,setDOFfocus:e=>{if(void 0===x.composer)return;if(void 0===x.passes[x.PASS_DOF])return;let t=x.passes[x.PASS_DOF].uniforms;void 0!==t&&(t.focus.value=e)},getDOFfocus:()=>{if(void 0===x.composer)return 0;if(void 0===x.passes[x.PASS_DOF])return 0;let e=x.passes[x.PASS_DOF].uniforms;return void 0===e?0:e.focus.value},setDOFaperture:e=>{if(void 0===x.composer)return;if(void 0===x.passes[x.PASS_DOF])return;let t=x.passes[x.PASS_DOF].uniforms;void 0!==t&&(t.aperture.value=e)}};const F=x;let V={STD_XPF_TRANSITION_DURATION:1,SEM_PREFIX:"XPF",SEMGROUP_PREFIX:"GXPF",init:()=>{V._list=[],V._iCurr=void 0,V._iNext=void 0,V._geom=void 0,V._mesh=void 0,V._mat=void 0,V._size=50,V._gSem=[],V._semIMGMasks={},V._semCanvas=void 0,V._semCTX=void 0,V._semCurr=void 0,V._shColor=new THREE.Color(0,0,1),V._shOpacity=.2,V._txCache={},V._pathMod=void 0,V._realizeBaseMat(),V._elVid=void 0,V._vidPlaying=!1},_realizeBaseMat:()=>{V._uniforms={tBase:{type:"t"},tSem:{type:"t"},tSemHint:{type:"t"},semHL:{type:"vec4",value:new THREE.Vector4(0,1,0,.15)},opacity:{type:"float",value:1},shColor:{type:"vec4",value:new THREE.Vector4(0,0,1,.2)},time:{type:"float",value:0}},V._mat=new THREE.ShaderMaterial({uniforms:V._uniforms,vertexShader:"\n varying vec3 vPositionW;\n varying vec3 vNormalW;\n varying vec3 vNormalV;\n varying vec2 vUv;\n\n void main(){\n vUv = uv;\n\n vPositionW = vec3( vec4( position, 1.0 ) * modelMatrix);\n vNormalW = normalize( vec3( vec4( normal, 0.0 ) * modelMatrix ) );\n vNormalV = normalize( vec3( normalMatrix * normal ));\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }\n ",fragmentShader:"\n varying vec3 vPositionW;\n\t\t varying vec3 vNormalW;\n varying vec3 vNormalV;\n varying vec2 vUv;\n\n uniform float time;\n uniform sampler2D tBase;\n uniform sampler2D tSem;\n uniform sampler2D tSemHint;\n //uniform sampler2D tDepth;\n\n uniform vec4 semHL, shColor;\n uniform float opacity;\n\n\t\t void main(){\n vec4 frag = texture2D(tBase, vUv);\n vec4 sem = texture2D(tSem, vUv);\n vec4 semH = texture2D(tSemHint, vUv);\n float shv = max( max(semH.r,semH.g), semH.b);\n\n float t = (1.0 * cos(time*2.0));\n t = clamp(t, 0.0,1.0);\n\n frag = mix(frag, semHL, (sem.r * semHL.a));\n\n frag = mix(frag, shColor, (t * shv * shColor.a));\n\n frag.a = opacity;\n\n gl_FragColor = frag;\n\t\t }\n ",depthTest:!1,depthWrite:!1}),V.setSemanticHintMapOpacity(.2)},setPathModifier:e=>{if(void 0!==e){V._pathMod=e;for(let t in V.list)V.list[t].setPathModifier(e)}},update:()=>{if(ATON.Nav.isTransitioning())return;if(V._list.length<1)return;let e,t,o,i,r=V._list.length,a=ATON.Nav._currPOV.pos,n=ATON.Nav._vDir;V._uniforms.time.value+=ATON._dt,void 0===V._dirLNode&&(V._dirLNode=new THREE.Vector3);for(let s=0;s.8&&(void 0===o||l{void 0===V._geom&&(V._group=new THREE.Group,ATON._rootVisibleGlobal.add(V._group),V._geom=new THREE.SphereGeometry(1,40,40),V._geom.scale(-V._size,V._size,V._size),V._geom.castShadow=!1,V._geom.receiveShadow=!1,V._mesh=new THREE.Mesh(V._geom,V._mat),V._mesh.frustumCulled=!1,V._mesh.renderOrder=-100,V._mesh.layers.enable(ATON.NTYPES.SCENE),V._group.add(V._mesh),V._mesh.visible=!1)},setBaseGeometry:e=>{},add:e=>{if(void 0===e)return;V.realizeBaseGeometry();let t=V._list.length;V._list.push(e);let o=e.getMesh();o&&V._group.add(o);let i=ATON.getOrCreateSemanticNode(V.SEMGROUP_PREFIX+t);V._gSem.push(i),i.attachToRoot(),t>0||(ATON.Nav.toggleLocomotionValidator(!1),ATON._bqScene=!0)},clear:()=>{V._iCurr=void 0,V._iNext=void 0,V._semCurr=void 0;for(let e=0;eV._list.length,getMainGroup:()=>V._group,getSemanticGroup:e=>V._gSem[e],getCurrentSemanticGroup:()=>{if(void 0!==V._iCurr)return V._gSem[V._iCurr]},_preloadBaseLayer:(e,t)=>{if(void 0!==V._txCache[e])return V._txCache[e];let o=V._list[e]._pathbaselayer;V._pathMod&&(o=V._pathMod(o)),ATON.Utils.textureLoader.load(o,(o=>{o.colorSpace=ATON._stdEncoding,o.generateMipmaps=!0,V._txCache[e]=o,t&&t(o)}))},_clearTexCache:()=>{if(void 0!==V._iCurr)for(let e in V._txCache)V._txCache[e]&&e!==V._iCurr&&(V._txCache[e].dispose(),V._txCache[e]=void 0)},_setBaseLayerTexture:(e,t)=>{V._mat.map=t,V._mat.needsUpdate=!0,V._mesh.position.copy(e.getLocation()),V._mesh.rotation.set(e.getRotation().x,e.getRotation().y,e.getRotation().z)},updateCurrentXPFbaseLayer:e=>{if(void 0===V._iCurr)return;let t=V._list[V._iCurr];if(void 0===t)return;let o=t._pathbaselayer;if(V._pathMod&&(o=V._pathMod(o)),ATON.Utils.isVideo(o)){if(void 0===V._elVid){let e="",$(e).appendTo("body"),V._elVid=document.getElementById("idXPFVideo"),V._elVid.onplaying=()=>{console.log("XPF VideoPano playing"),V._vidPlaying=!0},V._elVid.onpause=()=>{console.log("XPF VideoPano paused"),V._vidPlaying=!1},V._elVid.addEventListener("touchstart",(function(){V._elVid.play()})),enableInlineVideo(V._elVid)}let i=new THREE.VideoTexture(V._elVid);return i.colorSpace=ATON._stdEncoding,V._mat.map=i,V._mat.needsUpdate=!0,V._uniforms.tBase.value=i,V._mesh.position.copy(t.getLocation()),V._mesh.rotation.set(t.getRotation().x,t.getRotation().y,t.getRotation().z),void(e&&e(i))}ATON.Utils.textureLoader.load(o,(o=>{o.colorSpace=ATON._stdEncoding,o.generateMipmaps=!0,V._mat.map=o,V._mat.needsUpdate=!0,V._uniforms.tBase.value=o,V._mesh.position.copy(t.getLocation()),V._mesh.rotation.set(t.getRotation().x,t.getRotation().y,t.getRotation().z),e&&e(o)}))},playOrPauseXPFVideoStream:()=>{void 0!==V._elVid&&(V._vidPlaying?V._elVid.pause():V._elVid.play())},updateCurrentXPFsemLayer:e=>{let t=V._list.indexOf(e);t<0||t===V._iCurr&&V.loadSemanticMasksIfAny(V._iCurr)},setCurrentXPF:(e,t)=>{V.toggleSUI(e,!1),V._iCurr=e,V._iNext=void 0,V._mesh.visible=!0,V._gSem[e].show(),V.updateCurrentXPFbaseLayer(t),ATON.fire("CurrentXPF",e),ATON.fire("NextXPF",void 0),V.loadSemanticMasksIfAny(e)},toggleSUI:(e,t)=>{if(void 0===e)return;let o=V._list[e];void 0!==o&&o._lnode.toggleSUI(t)},loadSemanticMasksIfAny:e=>{let t=V._list[e];if(void 0!==t){V._semIMGMasks={},V._uniforms.tSemHint.value=0,void 0!==t._semHintURL&&(V._uniforms.tSemHint.value=ATON.Utils.textureLoader.load(t._semHintURL));for(let e in t._semMasksURLs){void 0===V._semCanvas&&(V._semCanvas=document.createElement("canvas"),V._semCanvas.width=2048,V._semCanvas.height=2048,V._semCTX=V._semCanvas.getContext("2d",{willReadFrequently:!0}));let o=t._semMasksURLs[e],i=new Image;i.src=o,V._semIMGMasks[e]=i}}},getXPFbyIndex:e=>V._list[e],getCurrentXPFindex:()=>V._iCurr,getCurrentXPF:()=>{if(void 0!==V._iCurr)return V._list[V._iCurr]},getNextXPFindex:()=>V._iNext,getNextXPF:()=>{if(void 0!==V._iNext)return V._list[V._iNext]},getDistanceToXPFindex:e=>{if(void 0===e)return;let t=V._list[e];return void 0!==t?ATON.Nav._currPOV.pos.distanceTo(t.getLocation()):void 0},showSUIonlyForXPF:e=>{let t=V._list.length;if(!(t<1))for(let o=0;o{let o=V._list[e];void 0!==o&&(void 0===t&&(t=V.STD_XPF_TRANSITION_DURATION),ATON.XR._bPresenting&&(t=0),V.setCurrentXPF(e),ATON.Nav.requestTransitionToLocomotionNode(o.getLocomotionNode(),t))},requestTransitionToTarget:(e,t,o)=>{if(void 0===e)return;let i=new ATON.POV;i.setTarget(e),i.setPosition(ATON.Nav._currPOV.pos),t&&i.setFOV(t),ATON.Nav.requestPOV(i,o)},requestTransitionToDirection:(e,t,o)=>{if(void 0===e)return;let i=new THREE.Vector3;i.x=e.x+ATON.Nav._currPOV.pos.x,i.y=e.y+ATON.Nav._currPOV.pos.y,i.z=e.z+ATON.Nav._currPOV.pos.z,V.requestTransitionToTarget(i,t,o)},setHomeXPF:e=>{let t=V._list[e];if(void 0===t)return;let o=t.getLocomotionNode(),i=(new ATON.POV).setPosition(o.pos).setTarget(o.pos.x,o.pos.y,o.pos.z+1);ATON.Nav.setHomePOV(i)},getSemanticMaskURLfromXPFindex:(e,t)=>{let o=V._list[e];if(void 0!==o)return o.getSemanticMaskURL(t)},getSemanticMaskURLfromCurrentXPF:e=>{if(void 0!==V._iCurr)return V.getSemanticMaskURLfromXPFindex(V._iCurr,e)},setSemanticColor:(e,t)=>{void 0===t&&(t=.15),V._uniforms.semHL.value=new THREE.Vector4(e.r,e.g,e.b,t)},setSemanticOpacity:e=>{void 0===e&&(e=.15),V._uniforms.semHL.value.w=e},setSemanticHintMapOpacity:e=>{void 0===e&&(e=.2),V._shOpacity=e,V._uniforms.shColor.value.w=e},setSemanticHintMapColor:(e,t)=>{void 0!==e&&(V._shColor=e,V._uniforms.shColor.value.x=e.r,V._uniforms.shColor.value.y=e.g,V._uniforms.shColor.value.z=e.b,void 0!==t&&V.setSemanticHintMapOpacity(t))},querySemanticMasks:()=>{if(void 0===V._semCTX)return;if(void 0===ATON._queryDataScene)return;if(void 0===ATON._queryDataScene.uv)return;let e,t=V._semCTX,o=ATON._queryDataScene.uv;for(let i in V._semIMGMasks){let r=V._semIMGMasks[i],a=parseInt(r.width*o.x),n=parseInt(r.height*(1-o.y));if(t.drawImage(r,0,0),t.getImageData(a,n,1,1).data[0]>127){e=i;break}}if(void 0===e)return void 0!==V._semCurr&&ATON.fire("SemanticMaskLeave",V._semCurr),V._semCurr=void 0,V._uniforms.tSem.value=0,V._uniforms.shColor.value.w=V._shOpacity,void(V._mat.needsUpdate=!0);V.highlightSemanticMaskInCurrentXPF(e),V._semCurr=e},highlightSemanticMaskInCurrentXPF:e=>{if(void 0===e)return void 0!==V._semCurr&&ATON.fire("SemanticMaskLeave",V._semCurr),V._semCurr=void 0,V._uniforms.tSem.value=0,V._uniforms.shColor.value.w=V._shOpacity,void(V._mat.needsUpdate=!0);if(V._semCurr===e)return;let t=V.getSemanticMaskURLfromCurrentXPF(e);V._uniforms.tSem.value=ATON.Utils.textureLoader.load(t),V._mat.needsUpdate=!0,ATON.fire("SemanticMaskHover",e),V._uniforms.shColor.value.w=0,void 0!==V._semCurr&&ATON.fire("SemanticMaskLeave",V._semCurr)},loadFromPhotoscanFile:(e,t)=>{if(void 0===e)return;e=ATON.Utils.resolveCollectionURL(e);let o=ATON.Utils.getBaseFolder(e),i=0;$.ajax({url:e,dataType:"text",success:function(e){e=e.split(/\r\n|\n/);for(let t in e){let r=e[t];if(!r.startsWith("#")){let e=r.split(/\s{2,}|\t/);if(e.length>10){let t=new ATON.XPF,r=o+e[0],a=parseFloat(e[1]),n=parseFloat(e[2]),s=parseFloat(e[3]),l=ATON.DEG2RAD*parseFloat(e[4]);ATON.DEG2RAD,parseFloat(e[5]),ATON.DEG2RAD,parseFloat(e[6]),t.setLocation(a,s,-n),t.setBaseLayer(r),t.setRotation(0,-l,0),V.add(t),i++}}}console.log("Num panoramas parsed: "+i),t&&t()}})}};const I=V;let U={init:()=>{U.list=[]},anyCopyrightFound:()=>U.list.length>0,extract:e=>{if(void 0===e)return;if(void 0===e.asset)return;let t={};if(e.asset.copyright&&(t.copyright=e.asset.copyright),e.asset.extras)for(let o in e.asset.extras)"string"==typeof e.asset.extras[o]&&(t[o]=e.asset.extras[o]);if(U.extractXMP3DC(e,t),0!==Object.keys(t).length){e.asset.generator&&(t.generator=e.asset.generator);for(let e in U.list){let o=U.list[e];if(U.compare(t,o))return}U.list.push(t),console.log(t)}},compare:(e,t)=>{if(void 0===e||void 0===t)return!1;const o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return!1;for(let i of o)if(e[i]!==t[i])return!1;return!0},extractXMP3DC:(e,t)=>{if(void 0===e||void 0===t)return;if(!e.userData)return;let o=e.userData.gltfExtensions;if(!o)return;if(!o.KHR_xmp)return;let i=o.KHR_xmp.packets;if(!i)return;let r=i[0],a="en-us";r["model3d:spdxLicense"]&&(t.license=r["model3d:spdxLicense"]),r["dc:date"]&&(t.date=r["dc:date"]),r["dc:title"]&&(t.title=r["dc:title"][a]),r["dc:description"]&&(t.description=r["dc:description"][a]),r["dc:rights"]&&(t.rights=r["dc:rights"][a]),r["dc:source"]&&(t.source=r["dc:source"]),r["dc:subject"]&&(t.subject=r["dc:subject"]),r["dc:type"]&&(t.type=r["dc:type"]),r["xmpRights:Owner"]&&(t.owner=r["xmpRights:Owner"]),r["xmp:CreatorTool"]&&(t.creatorTool=r["xmp:CreatorTool"])}};const k=U;let B={REST_API_CESIUMION_DEF_TOKEN:"https://api.cesium.com/v2/tokens/default",THRES_ORI:.01,THRES_POS:1e-6,init:()=>{B._tsets=[],B._tsET=20,B._tsB=!1,B._bTileBVH=!0,B._tsTasks=[],B.tsSchedCB=e=>{B._tsTasks.push(e)},B._tseBase=8,B.estimateTSErrorTarget(),B._tsuSync=0,B._bPCs=!1,B._pqLRU=void 0,B._pqDownload=void 0,B._pqParse=void 0,B._numTilesLoaded=0,B._numTSLoaded=0},clear:()=>{for(let e in B._tsets)B._tsets[e]=null;B._tsets=[],B._bPCs=!1},getTSetsErrorTarget:()=>B._tsET,setTSetsErrorTarget:e=>{B._tsET=e;const t=B._tsets.length;if(!(t<=0))for(let o=0;o{B._tsB=e;const t=B._tsets.length;if(!(t<=0))for(let o=0;o{void 0===e&&(e=ATON.Nav._camera);const t=B._tsets.length;if(!(t<=0))for(let o=0;o{B._tseBase=e,console.log(B._tseBase),B.estimateTSErrorTarget()},estimateTSErrorTarget:()=>{let e=B._tseBase;(ATON.device.lowGPU||ATON.device.isMobile)&&(e+=4),ATON.XR._bPresenting&&(e+=3),e<1&&(e=1),e>25&&(e=25),console.log("Estimated TSet error target: "+e),B.setTSetsErrorTarget(e)},loadTileSetFromURL:(e,t,o)=>{if(void 0===t)return;let i=new TILES.TilesRenderer(e);if(!i)return;ATON._assetReqNew(e),i.displayBoxBounds=B._tsB,i.fetchOptions.mode="cors",i.registerPlugin(new TILES.ImplicitTilingPlugin),o&&(i.fetchOptions.headers={},i.fetchOptions.headers.Authorization=`Bearer ${o.accessToken}`,i.preprocessURL=e=>(e=new URL(e),/^http/.test(e.protocol)&&e.searchParams.append("v",o.v),e.toString())),i.errorTarget=B._tsET,i.optimizeRaycast=!1,void 0===B._pqLRU?(i.downloadQueue.schedulingCallback=B.tsSchedCB,i.parseQueue.schedulingCallback=B.tsSchedCB,i.downloadQueue.maxJobs=6,i.parseQueue.maxJobs=1,B._pqLRU=i.lruCache,B._pqDownload=i.downloadQueue,B._pqParse=i.parseQueue):(i.lruCache=B._pqLRU,i.downloadQueue=B._pqDownload,i.parseQueue=B._pqParse),i.setCamera(ATON.Nav._camera),i.setResolutionFromRenderer(ATON.Nav._camera,ATON._renderer),i.manager.addHandler(/\.gltf$/,ATON._aLoader),i.manager.addHandler(/\.ktx2$/,ATON._ktx2Loader),i.manager.addHandler(/\.drc$/,ATON._dracoLoader),t.add(i.group),$.getJSON(e,(e=>{ATON.CC.extract(e)}));let r=new THREE.Box3,a=new THREE.Sphere;new THREE.Matrix4,new THREE.Vector3;let n=!1;i.addEventListener("load-tile-set",(()=>{if(console.log("TileSet loaded"),ATON._assetReqComplete(e),B._numTSLoaded++,o||t.bUseGeoCoords){console.log("TileSet using GeoCoords"),i.getBoundingSphere(a);const e=a.center.clone(),t=e.length(),o=e.normalize(),r=new THREE.Vector3(0,1,0),n=ATON.Utils.rotationBetweenDirections(o,r);i.group.quaternion.x=n.x,i.group.quaternion.y=n.y,i.group.quaternion.z=n.z,i.group.quaternion.w=n.w,i.group.position.y=-t}else i.getBoundingBox(r)?(r.getBoundingSphere(a),t.autocenter?(r.getCenter(i.group.position),i.group.position.multiplyScalar(-1)):void 0===ATON.Nav.homePOV&&ATON.Nav.computeAndRequestDefaultHome(.5,void 0,a)):i.getBoundingSphere(a)&&(t.autocenter?(i.group.position.copy(a.center),i.group.position.multiplyScalar(-1)):void 0===ATON.Nav.homePOV&&ATON.Nav.computeAndRequestDefaultHome(.5,void 0,a));ATON.Utils._visitorCP(i.group)})),i.addEventListener("load-model",(e=>{let o=e.scene;B._numTilesLoaded++,o.traverse((e=>{if(e.layers.enable(t.type),e.isMesh?(e.castShadow=!0,e.receiveShadow=!0,B._bTileBVH&&e.geometry&&(e.geometry.computeVertexNormals(),e.geometry.computeBoundsTree({}),ATON.Utils._bvhBounds>0&&ATON.Utils._addBVHbounds(e,ATON.Utils._bvhBounds)),ATON._bqScene=!0):(n=!0,B._bPCs=!0,e.layers.disable(t.type),e.raycast=ATON.Utils.VOID_CAST,e.material=ATON.MatHub.materials.point),t.userData.cMat&&(e.material=t.userData.cMat),e.material){let t=e.material.map;t&&(t.minFilter=THREE.LinearMipmapLinearFilter,t.magFilter=THREE.LinearFilter,t.colorSpace=ATON._stdEncoding)}})),ATON.fire("TileLoaded",o),ATON.Utils._visitorCP(o)})),i.addEventListener("dispose-model",((e,t)=>{ATON.Utils.cleanupVisitor(e.scene),e=null})),n||ATON.Utils.setPicking(t,t.type,!0),B._tsets.push(i)},loadCesiumIONAsset:(e,t)=>{let o=ATON.getAPIToken("cesium.ion");if(null==o&&(console.log("A valid Cesium ION token is required"),o=prompt("Please enter a valid Cesium ION token:"),null==o||""==o))return;let i=new URL(`https://api.cesium.com/v1/assets/${e}/endpoint`);i.searchParams.append("access_token",o),fetch(i,{mode:"cors"}).then((e=>e.ok?e.json():Promise.reject(`${e.status} : ${e.statusText}`))).then((e=>{i=new URL(e.url);const r=i.searchParams.get("v");B.loadTileSetFromURL(i.toString(),t,{accessToken:e.accessToken,v:r}),ATON.setAPIToken("cesium.ion",o)}))},update:()=>{const e=B._tsets.length;if(e<1)return;for(let t=0;t!!ATON.Nav._bControl&&(ATON.Nav._dOri>B.THRES_ORI||ATON.Nav._dPos>B.THRES_POS)};const q=B;let z={DELIM_CSV:",",DELIM_TSV:"\t",init:()=>{},loadTextFromURL:(e,t)=>($.get(e,(e=>{t&&t(e)})),z),loadValuesFromFile:(e,t,o,i)=>{let r={};void 0===o&&(o=-1),$.get(e,(e=>{let a=e.split("\n"),n=a.length,s=[],l=!1;for(let e=0;e0)if(l){let a=i.split(t),n=o>=0?a[o]:e;r[n]={};for(let e=0;e{z.loadValuesFromFile(e,z.DELIM_CSV,t,o)},loadTSV:(e,t,o)=>{z.loadValuesFromFile(e,z.DELIM_TSV,t,o)}};const X=z;let G={init:()=>{G._base=ATON.PATH_RESTAPI2},setBaseDomain:e=>e.startsWith("http")?(G._base=e,G):G,get:(e,t,o)=>(e.startsWith("http")||(e=G._base+e),fetch(e,{credentials:"include"}).then((e=>{e.ok?e.json().then(t).catch((e=>{console.log("ERROR: "+e),o&&o(e)})):o&&o()})),G),post:(e,t,o,i)=>(e.startsWith("http")||(e=G._base+e),fetch(e,{method:"POST",body:JSON.stringify(t),credentials:"include",headers:{"Content-type":"application/json; charset=UTF-8"}}).then((e=>{e.ok?e.json().then(o).catch((e=>{console.log("ERROR: "+e),i&&i(e)})):i&&i()})),G),put:(e,t,o,i)=>(e.startsWith("http")||(e=G._base+e),fetch(e,{method:"PUT",body:JSON.stringify(t),credentials:"include",headers:{"Content-type":"application/json; charset=UTF-8"}}).then((e=>{e.ok?e.json().then(o).catch((e=>{console.log("ERROR: "+e),i&&i(e)})):i&&i()})),G),patch:(e,t,o,i)=>(e.startsWith("http")||(e=G._base+e),fetch(e,{method:"PATCH",body:JSON.stringify(t),credentials:"include",headers:{"Content-type":"application/json; charset=UTF-8"}}).then((e=>{e.ok?e.json().then(o).catch((e=>{console.log("ERROR: "+e),i&&i(e)})):i&&i()})),G),delete:(e,t,o)=>(e.startsWith("http")||(e=G._base+e),fetch(e,{method:"DELETE",credentials:"include"}).then((e=>{e.ok?e.json().then(t).catch((e=>{console.log("ERROR: "+e),o&&o(e)})):o&&o()})),G),login:(e,t,o,i)=>G.post("login",{username:e,password:t},(e=>{e&&o?o(e):i&&i()}),(e=>{i&&i()})),logout:(e,t)=>G.get("logout",e,t)};const W=G;let j={};window.ATON=j,j.Node=t,j.POV=class{constructor(e){this.pos=new THREE.Vector3(1,0,0),this.target=new THREE.Vector3(0,0,0),this.up=ATON.STD_UPVECTOR,this.fov=void 0,this.nextPOV=void 0,this.prevPOV=void 0,this.as(e)}as(e){if(void 0!==e)return ATON.Nav.povlist[e]=this,this.id=e,this}setPosition(e,t,o){return e instanceof THREE.Vector3?this.pos.copy(e):this.pos.set(e,t,o),this}setTarget(e,t,o){return e instanceof THREE.Vector3?this.target.copy(e):this.target.set(e,t,o),this}setFOV(e){return this.fov=e,this}addKeywords(e){let t=e.split(",");void 0===this.kwords&&(this.kwords={});for(let e in t){let o=t[e].trim();o.length>0&&(this.kwords[o]=!0)}return this}hasKeyword(e){if(void 0!==this.kwords)return void 0!==this.kwords[e]}setNextPOV(e){if(e)return this.nextPOV=e,this}setPrevPOV(e){if(e)return this.prevPOV=e,this}},j.LightProbe=class{constructor(e,t,o){this.pos=new THREE.Vector3(0,0,0),this._res=void 0!==e?e:128,this._near=void 0!==t?t:1,this._far=void 0!==o?o:ATON.Nav.STD_FAR,this._envtex=void 0,this._CC=void 0,void 0===ATON._pmremGenerator&&(ATON._pmremGenerator=new THREE.PMREMGenerator(ATON._renderer),ATON._pmremGenerator.compileCubemapShader())}setPosition(e,t,o){return e instanceof THREE.Vector3?this.pos.copy(e):this.pos.set(e,t,o),this}setNear(e){return this._near=e,this}setFar(e){return this._far=e,this}_createCCtarget(){this._CCtarget||(this._CCtarget=new THREE.WebGLCubeRenderTarget(this._res,{format:THREE.RGBEFormat,generateMipmaps:!0,minFilter:THREE.LinearMipmapLinearFilter,colorSpace:ATON._stdEncoding}))}update(){return this._envtex&&this._envtex.dispose(),ATON._rootVisibleGlobal.position.set(-this.pos.x,-this.pos.y,-this.pos.z),ATON._render(),this._envtex=ATON._pmremGenerator.fromScene(ATON._mainRoot,0,this._near,this._far).texture,ATON._rootVisibleGlobal.position.set(0,0,0),ATON._renderer.shadowMap.enabled&&ATON._dMainL&&(ATON._dMainL.shadow.needsUpdate=!0),this}getEnvTex(){return this._envtex}assignToNode(e){}},j.XPF=class{constructor(e){this.id=e,this._geom=void 0,this._mesh=void 0,this._pathbaselayer=void 0,this._size=20,this._location=new THREE.Vector3(0,0,0),this._rotation=new THREE.Vector3(0,0,0),this._lnode=ATON.Nav.addLocomotionNode(this._location),this._pathMod=void 0,this._semMasksURLs={},this._semHintURL=void 0}setSize(e){this._size=e}realizeSUI(){return void 0===this._lnode||this._lnode.realizeSUI(),this}realizeGeometry(){return void 0!==this._geom||(this._geom=new THREE.SphereGeometry(1,60,60),this._geom.scale(-this._size,this._size,this._size),this._geom.castShadow=!1,this._geom.receiveShadow=!1,this._mat=new THREE.MeshBasicMaterial({depthTest:!1,depthWrite:!1}),this._mesh=new THREE.Mesh(this._geom,this._mat),this._mesh.frustumCulled=!1,this._mesh.renderOrder=-100),this}getMesh(){return this._mesh}getLocomotionNode(){return this._lnode}setRotation(e,t,o){return e instanceof THREE.Vector3?this._rotation.copy(e):this._rotation.set(e,t,o),void 0===this._mesh||this._mesh.rotation.copy(this._rotation),this}getRotation(){return this._rotation}setLocation(e,t,o){return e instanceof THREE.Vector3?this._location.copy(e):this._location.set(e,t,o),this._lnode&&this._lnode.setLocation(this._location),void 0===this._mesh||this._mesh.position.copy(this._location),this}getLocation(){return this._location}hasGeometry(){return void 0!==this._geom}setPathModifier=e=>(this._pathMod=e,this);updateBaseLayer(){}setBaseLayer(e){if(void 0===e)return this;this._pathbaselayer=ATON.Utils.resolveCollectionURL(e);let t=this;return this._pathMod&&(this._pathbaselayer=this._pathMod(this._pathbaselayer)),this.hasGeometry()?(ATON.Utils.isVideo(this._pathbaselayer)||ATON.Utils.textureLoader.load(t._pathbaselayer,(e=>{e.colorSpace=ATON._stdEncoding,e.generateMipmaps=!0,t._mat.map=e,t._mat.map.needsUpdate=!0,t._mat.needsUpdate=!0,console.log("XPF base layer "+t._pathbaselayer+" loaded")})),this):this}setSemanticMask(e,t){return void 0===e||(this._semMasksURLs[e]=ATON.Utils.resolveCollectionURL(t),ATON.XPFNetwork.updateCurrentXPFsemLayer(this)),this}removeSemanticMask(e){return void 0===e||(this._semMasksURLs[e]=void 0,ATON.XPFNetwork.updateCurrentXPFsemLayer(this)),this}removeAllSemanticMasks(){return this._semMasksURLs={},this}getSemanticMaskURL(e){return this._semMasksURLs[e]}setSemanticHintMap(e){return void 0===e||(this._semHintURL=ATON.Utils.resolveCollectionURL(e),ATON.XPFNetwork.updateCurrentXPFsemLayer(this)),this}removeSemanticHintMap(){return this._semHintURL=void 0,ATON.XPFNetwork.updateCurrentXPFsemLayer(this),this}},j.Flare=class{constructor(e){this._id=void 0,this._bDeployed=!1,e&&this.register(e)}register(e){return e&&(this._id=e),ATON.addFlare(this),this}getID(){return this._id}log(e){return this._id?console.log("[Flare "+this._id+"] "+e):console.log("[Flare]"+e),this}setSetup(e){return this.setup=e,this}setUpdate(e){return this.update=e,this}},j.EventHub=i,j.Utils=s,j.CC=k,j.SceneHub=d,j.MatHub=a,j.Nav=h,j.AudioHub=u,j.XR=v,j.SUI=N,j.UI=A,j.Photon=P,j.SemFactory=E,j.FE=y,j.MediaFlow=M,j.Phygital=C,j.App=D,j.FX=F,j.XPFNetwork=I,j.MRes=q,j.ASCII=X,j.REQ=W,j.STD_UPVECTOR=new THREE.Vector3(0,1,0),j.ROOT_NID=".",j.RAD2DEG=180/Math.PI,j.DEG2RAD=Math.PI/180,j.PATCH_ADD=0,j.PATCH_DEL=1,j.NTYPES={},j.NTYPES.SCENE=3,j.NTYPES.SEM=4,j.NTYPES.UI=5,j.SHADOWS_NEAR=.1,j.SHADOWS_FAR=100,j.SHADOWS_SIZE=50,j.SHADOWS_RES=1024,j.AMB_L=.2,j.SCALE_DEFAULT=0,j.SCALE_BIG=5,j.SCALE_VERYBIG=10,j.SCALE_SMALL=-5,j.SCALE_VERYSMALL=-10,j.Flares={},j._fReqList=[],j._bInitialized=!1,j._b2D=!1,j._resMappers=[],j._clipPlanes=[],j.setBaseURL=e=>{j.BASE_URL=e,j.PATH_RESTAPI=`${j.BASE_URL}/api/`,j.PATH_RESTAPI_SCENE=`${j.PATH_RESTAPI}scene/`,j.PATH_RESTAPI2=`${j.BASE_URL}/api/v2/`,j.PATH_WAPPS=`${j.BASE_URL}/a/`,j.PATH_FLARES=`${j.BASE_URL}/flares/`,j.PATH_DRACO_LIB=`${j.BASE_URL}/dist/draco/`,j.PATH_BASIS_LIB=`${j.BASE_URL}/dist/basis/`,j.PATH_COLLECTION=`${j.BASE_URL}/collections/`,j.PATH_SCENES=`${j.BASE_URL}/scenes/`,j.PATH_RES=`${j.BASE_URL}/res/`,j.PATH_FE=`${j.BASE_URL}/s/`},j.setBaseURL(window.location.origin),j.setPathCollection=e=>{j.PATH_COLLECTION=e},j.setPathScenes=e=>{j.PATH_SCENES=e},j.setAsStandalone=e=>{e||(e="../"),j.PATH_DRACO_LIB=e+"dist/draco/",j.PATH_BASIS_LIB=e+"dist/basis/",j.PATH_RES=e+"res/"},j.addResourceMapper=e=>{j._resMappers.push(e)},j._onUserInteraction=()=>{j._elPanoVideo&&!j._vpanoPlaying&&j._elPanoVideo.play(),j.XPFNetwork._elVid&&!j.XPFNetwork._vidPlaying&&j.XPFNetwork._elVid.play(),j.AudioHub._listener&&j.AudioHub._listener.context&&"suspended"===j.AudioHub._listener.context.state&&j.AudioHub._listener.context.resume();for(let e in j.MediaFlow._vStreams){let t=j.MediaFlow._vStreams[e].el;t.playing||t.uid||t.play()}},j.rewindAllPlayingMedia=()=>{j._elPanoVideo&&(j._elPanoVideo.currentTime=0),j.XPFNetwork._elVid&&(j.XPFNetwork.currentTime=0),j._auMain&&(j._auMain.stop(),j._auMain.play());for(let e in j.MediaFlow._vStreams){let t=j.MediaFlow._vStreams[e].el;t.playing&&!t.uid&&(t.stop(),t.play())}},j.checkAuth=(e,t)=>{j.REQ.get("user",(o=>{o&&e?e(o):t&&t()}),(e=>{t&&t()}))},j._setupBaseListeners=()=>{let e,t,o=j._renderer.domElement;window.addEventListener("resize",j._onResize,!1),window.onorientationchange=j._readDeviceOrientationMode,document.addEventListener("fullscreenchange",(e=>{j._bFS=!!document.fullscreenElement,j.fire("Fullscreen",j._bFS),j._bFS?console.log("Now fullscreen"):console.log("Exit fullscreen")})),void 0!==document.hidden?(e="hidden",t="visibilitychange"):void 0!==document.mozHidden?(e="mozHidden",t="mozvisibilitychange"):void 0!==document.msHidden?(e="msHidden",t="msvisibilitychange"):void 0!==document.webkitHidden&&(e="webkitHidden",t="webkitvisibilitychange"),void 0!==e&&document.addEventListener(t,(()=>{if(document[e]){if(j.XR._bPresenting)return;console.log("Suspend"),j.renderPause()}else{if(j.XR._bPresenting)return;console.log("Resume"),j.renderResume()}}),!1),o.addEventListener("mousemove",j._updateScreenMove,!1),o.addEventListener("mousedown",(e=>{1===e.button&&j.fire("MouseMidButton"),2===e.button&&j.fire("MouseRightButton")})),o.addEventListener("wheel",j._onMouseWheel,!1),j._bPointerDown=!1,Hammer(o).on("doubletap",(e=>{j._bPointerDown=!1,j._onUserInteraction(),j.fire("DoubleTap",e.srcEvent)})),Hammer(o).on("tap",(e=>{if(j._bPointerDown=!1,j._onUserInteraction(),j._updateScreenMove(e.srcEvent),j._handleQueries(),j.fire("Tap",e.srcEvent),void 0===j._hoveredUI)return;let t=j.getUINode(j._hoveredUI);t&&t.onSelect&&t.onSelect()})),j.on("DoubleTap",(e=>{j.defaultDoubleTapFromScreenCoords(e)})),j._kModShift=!1,j._kModCtrl=!1,j._bListenKeyboardEvents=!0,window.addEventListener("keydown",(e=>{j._onUserInteraction(),"Shift"===e.key&&(j._kModShift=!0),"Control"===e.key&&(j._kModCtrl=!0),j._bListenKeyboardEvents&&j.fire("KeyPress",e.key)}),!1),window.addEventListener("keyup",(e=>{"Shift"===e.key&&(j._kModShift=!1),"Control"===e.key&&(j._kModCtrl=!1),j._bListenKeyboardEvents&&j.fire("KeyUp",e.key)}),!1),j.on("KeyPress",(e=>{if("+"===e){let e=j.Nav.getFOV()+1;j.Nav.setFOV(e)}if("-"===e){let e=j.Nav.getFOV()-1;j.Nav.setFOV(e)}}))},j._onResize=()=>{if(j.Nav._camera.aspect=window.innerWidth/window.innerHeight,j.Nav._camera.updateProjectionMatrix(),j._renderer.setSize(window.innerWidth,window.innerHeight),j.FX.composer&&(j.FX.composer.setSize(window.innerWidth,window.innerHeight),j.FX.passes[j.FX.PASS_AA])){let e=j.FX.passes[j.FX.PASS_AA].material.uniforms;e&&e.resolution.value.set(1/window.innerWidth,1/window.innerHeight)}console.log("onResize")},j._onMouseWheel=e=>{e.preventDefault(),j.fire("MouseWheel",e.deltaY)},j.focusOn3DView=()=>{j._renderer.domElement.focus()},j._SUIactivation=()=>{const e=j.getUINode(j._hoveredUI);return void 0!==e&&void 0!==e.onSelect&&(e.onSelect(),!0)},j._stdActivation=()=>{if(j._SUIactivation())return;if(!j.Nav._bControl)return;if(void 0!==j.XPFNetwork._semCurr&&j.fire("SemanticMaskSelect",j.XPFNetwork._semCurr),j.XR._bPresenting){if(h.requestTransitionToLocomotionNodeInSightIfAny(j.XR.STD_TELEP_DURATION))return;return"immersive-vr"===j.XR._sessionType&&j.XR.teleportOnQueriedPoint(),void j.FE.playAudioFromSemanticNode(j._hoveredSemNode)}if(j.Nav.isFirstPerson()||j.Nav.isDevOri()){if(h.requestTransitionToLocomotionNodeInSightIfAny(.5))return;if(j.Nav.currentQueryValidForLocomotion()){let e=j._queryDataScene.p,t=j.Nav._vDir,o=new THREE.Vector3(e.x,e.y+j.userHeight,e.z),i=new THREE.Vector3(o.x+t.x,o.y+t.y,o.z+t.z),r=(new j.POV).setPosition(o).setTarget(i).setFOV(j.Nav._currPOV.fov);j.Nav.requestPOV(r,.5)}return}let e=j.getSemanticNode(j._hoveredSemNode);j._queryDataSem&&e?j.Nav.requestPOVbyNode(e,.5):j._queryDataScene&&j.Nav.requestRetarget(j._queryDataScene.p,void 0,.5)},j.defaultDoubleTapFromScreenCoords=e=>{j._updateScreenMove(e),j._handleQueryScene(),j._stdActivation()},j.isFullscreen=()=>j._bFS,j.toggleFullScreen=()=>{document.fullscreenElement?document.exitFullscreen&&document.exitFullscreen():document.documentElement.requestFullscreen()},j.realize=e=>{console.log("Initialize ATON..."),j.Utils.init(),j.Utils.profileDevice(),j._clock=new THREE.Clock(!0),j.bounds=new THREE.Sphere,j._worldScale=1,j._ws=0,j._bFS=!1,j._renderer=new THREE.WebGLRenderer({antialias:!0,alpha:!0}),j._renderer.setSize(window.innerWidth,window.innerHeight),j.Utils.profileRenderingCapabilities(),j._stdpxd=1,j._fps=60,j._dt=.01,j._dtAccum=0,j._dtCount=0,j._avgFPSaccum=0,j._avgFPS=60,j._dRenderBudgetMinFPS=20,j._dRenderBudgetMaxFPS=55,j._bAdaptiveDensity=!0,j._adMin=.4,j._adMax=1.5,j.device.lowGPU&&(j._adMax=1),j._aniMixers=[],j._stdEncoding=THREE.LinearSRGBColorSpace,j._renderer.outputColorSpace=j._stdEncoding,j._renderer.toneMapping=THREE.LinearToneMapping,j._renderer.toneMappingExposure=1,e||j._renderer.setAnimationLoop(j._onFrame),j._maxAnisotropy=j._renderer.capabilities.getMaxAnisotropy(),j.userHeight=1.7,e||document.body.appendChild(j._renderer.domElement);let t=j._renderer.domElement;t.id="idView3D",t.style.outline="none",t.style.border="none",j.UI.init(),j.REQ.init(),j._vpanoPlaying=!1,j._bUserInts=0,j.EventHub.init(),j.MatHub.init(),j.ASCII.init(),j._assetsManager={},j._aLoader=new THREE.GLTFLoader,j._numReqLoad=0,j._collMod=void 0,j._ktx2Loader=new THREE.KTX2Loader,j._ktx2Loader.setTranscoderPath(j.PATH_BASIS_LIB),j._ktx2Loader.detectSupport(j._renderer),j._dracoLoader=new THREE.DRACOLoader,j._dracoLoader.setDecoderPath(j.PATH_DRACO_LIB),j._dracoLoader.setWorkerLimit(2),j._dracoLoader.preload(),j._aLoader.setDRACOLoader(j._dracoLoader),j._aLoader.setKTX2Loader(j._ktx2Loader),THREE.DefaultLoadingManager.addHandler(/\.ktx2$/,j._ktx2Loader),j._updRoutines=[],j._pmremGenerator=void 0,j._lps=[],j._bAutoLP=!1,j._envMapInt=1,j._numLPbounces=2,j._lpbCount=0,j._bShadowsFixedBound=!1,j._shadowsFixedBoundCenter=void 0,j._shadowsNear=j.SHADOWS_NEAR,j._shadowsFar=j.SHADOWS_FAR,j._shadowsSize=j.SHADOWS_SIZE,j._shadowsRes=j.SHADOWS_RES,j.initGraphs(),j.SceneHub.init(),j.MRes.init(),j.CC.init(),j.AudioHub.init(),j.Nav.init(),j.XR.init(),j.SUI.init(),j.Photon.init(),j.VRoadcast=j.Photon,j.MediaFlow.init(),j.SemFactory.init(),j.Phygital.init(),j.XPFNetwork.init(),j.device.lowGPU||j.device.isMobile||j.FX.init(),j.FX.composer||(j._render=()=>{j._renderer.render(j._mainRoot,j.Nav._camera)}),j.setDefaultPixelDensity(1),j._queryDataScene=void 0,j._queryDataSem=void 0,j._queryDataUI=void 0,j._hoveredSemNode=void 0,j._hoveredUI=void 0,j._bq=!0,j._bQuerySemOcclusion=!0,j._bQueryNormals=!0,j._bPauseQuery=!1,j._bCenteredQuery=!1,j._bqScene=!1,j._bqSem=!1,j._qSync=0,j._qSyncInt=1,j._tgiDur=void 0,j._tgiPer=void 0,j._tHover=void 0,j._bMainPanoInfinite=!0,j._matMainPano=void 0,j._mMainPano=void 0,j._screenPointerCoords=new THREE.Vector2(0,0),j._rcScene=new THREE.Raycaster,j._rcScene.layers.set(j.NTYPES.SCENE),j._rcScene.firstHitOnly=!0,j._rcSemantics=new THREE.Raycaster,j._rcSemantics.layers.set(j.NTYPES.SEM),j._rcSemantics.firstHitOnly=!0,j._rcUI=new THREE.Raycaster,j._rcUI.layers.set(j.NTYPES.UI),j._rcUI.firstHitOnly=!0,j._setupBaseListeners(),j.device.isMobile&&j._readDeviceOrientationMode(),j._fLoading=0,j._fRequired=j._fReqList.length,j._loadFlares(),j._gizmo=void 0,j._bGizmo=!1,j.focusOn3DView(),j._bInitialized=!0},j.realize2D=()=>{j._b2D=!0,j.UI.init(),j.REQ.init(),document.body.classList.add("aton-body2D"),document.body.oncontextmenu=null,j.EventHub.init(),j._bInitialized=!0},j.addFlare=e=>{if(void 0===e)return;let t=Object.keys(j.Flares).length,o=e.getID();o?j.Flares[o]=e:j.Flares["F"+t]=e},j.registerFlare=j.addFlare,j.getFlare=e=>j.Flares[e],j.loadScript=(e,t,o)=>{let i=document.createElement("script");i.src=e,i.async=!1,document.head.appendChild(i),t&&(i.onload=t),o&&(i.onerror=o)},j._loadFlare=e=>{j._fLoading++,$.get(j.PATH_RESTAPI2+"flares/"+e,(t=>{let o=t.files;if(o){let t=o.length;for(let i in o)j.loadScript(j.PATH_FLARES+e+"/"+o[i],(()=>{t--,t<=0&&j._onFlareLoaded(e)}),(()=>{console.log("Missing flare '"+e+"' dependency: "+o[i]),t--,t<=0&&j._onFlareLoaded(e)}))}})).fail((()=>{console.log("Flare "+e+" not found."),j._onFlareError(e)}))},j._loadFlares=()=>{if(j._fRequired<=0)j.fire("AllFlaresReady");else for(let e in j._fReqList)j._loadFlare(j._fReqList[e])},j._onFlareLoaded=e=>{console.log("All deps loaded for flare '"+e+"'"),j._deployNewFlares(),j._fLoading--,j._fLoading<=0&&j._onAllFlaresLoaded()},j._onFlareError=e=>{j._fLoading--,j._fLoading<=0&&j._onAllFlaresLoaded()},j._onAllFlaresLoaded=()=>{console.log("All Flares ready!"),j.fire("AllFlaresReady")},j._deployFlare=e=>{e._bDeployed||(void 0!==e.setup&&e.setup(),void 0!==e.update&&j.addUpdateRoutine(e.update),e._bDeployed=!0)},j._deployNewFlares=()=>{for(let e in j.Flares)j._deployFlare(j.Flares[e])},j.setCollectionPathModifier=e=>{j._collMod=e},j.setTimedGazeDuration=e=>{j._tgiDur=e},j.getTimedGazeProgress=()=>{if(void 0!==j._tgiDur)return j._tgiPer},j.getElapsedTime=()=>j._clock.elapsedTime,j.renderPause=()=>{j._renderer.setAnimationLoop(void 0)},j.renderResume=()=>{j._renderer.setAnimationLoop(j._onFrame)},j._setupLoadManager=()=>{j._loadManager=new THREE.LoadingManager,j._loadManager.onStart=(e,t,o)=>{console.log("Started loading file: "+e+".\nLoaded "+t+" of "+o+" files."),j.fire("NodeRequestFired",e)},j._loadManager.onLoad=()=>{console.log("Loading complete!"),j.fire("AllNodeRequestsCompleted")},j._loadManager.onProgress=(e,t,o)=>{},j._loadManager.onError=e=>{console.log("There was an error loading "+e)}},j.setDefaultPixelDensity=e=>{j._stdpxd=e,j._renderer.setPixelRatio(e),j.FX.composer&&j.FX.composer.setPixelRatio(e),void 0!==j._renderer.xr&&(j.device.isMobile?j._renderer.xr.setFramebufferScaleFactor(j._stdpxd*j.XR.MOBILE_DENSITY_F):j._renderer.xr.setFramebufferScaleFactor(j._stdpxd))},j.resetPixelDensity=()=>{j._renderer.setPixelRatio(j._stdpxd)},j._readDeviceOrientationMode=()=>{90===Math.abs(window.orientation)?(console.log("Landscape Mode"),j.fire("MobileLandscapeMode")):(console.log("Portrait Mode"),j.fire("MobilePortraitMode")),setTimeout(j._onResize,500)},j.snodes={},j.semnodes={},j.uinodes={},j.createSceneNode=e=>new j.Node(e,j.NTYPES.SCENE),j.getSceneNode=e=>{if(void 0!==e)return j.snodes[e]},j.getOrCreateSceneNode=e=>{let t=j.getSceneNode(e);return void 0!==t?t:j.createSceneNode(e)},j.getRootScene=()=>j._rootVisible,j.createSemanticNode=e=>new j.Node(e,j.NTYPES.SEM),j.getSemanticNode=e=>{if(void 0!==e)return j.semnodes[e]},j.getOrCreateSemanticNode=e=>{let t=j.getSemanticNode(e);return void 0!==t?t:j.createSemanticNode(e)},j.getRootSemantics=()=>j._rootSem,j.createUINode=e=>new j.Node(e,j.NTYPES.UI),j.getUINode=e=>{if(void 0!==e)return j.uinodes[e]},j.getRootUI=()=>j._rootUI,j._unpackScale=e=>0==e?1:e>=0?1.1*e:1/(-1.1*e),j.setUserScaleLevel=e=>{j.setWorldScaleLevel(-e)},j.getUserScale=()=>1/j._worldScale,j.setWorldScaleLevel=e=>{void 0===e&&(e=0),e<-127&&(e=127),e>127&&(e=127),j._ws=e;let t=j._unpackScale(e);j._rootVisible.scale.set(t,t,t),j._rootSem.scale.set(t,t,t),N.gLocNodes.scale.set(t,t,t),N.gMeasures.scale.set(t,t,t),j.Photon.avaGroup&&j.Photon.avaGroup.scale.set(t,t,t),j.recomputeSceneBounds();let o=t/j._worldScale;j.Nav._currPOV.pos.x*=o,j.Nav._currPOV.pos.y*=o,j.Nav._currPOV.pos.z*=o,j.Nav._currPOV.target.x*=o,j.Nav._currPOV.target.y*=o,j.Nav._currPOV.target.z*=o,j.Nav.syncCurrCamera(),j.XR._bPresenting&&j.XR.setRefSpaceLocation(j.Nav._currPOV.pos),j._worldScale=t,console.log("World scale: "+t)},j.getWorldScaleLevel=()=>j._ws,j.getWorldScale=()=>j._worldScale,j._assetReqNew=e=>{j._numReqLoad++,j.fire("NodeRequestFired",e)},j._assetReqComplete=e=>{j.fire("NodeRequestCompleted",e),j._numReqLoad--,j._numReqLoad<=0&&j._onAllReqsCompleted()},j._onAllReqsCompleted=()=>{j.recomputeSceneBounds(),j.getRootScene().assignLightProbesByProximity(),j.fire("AllNodeRequestsCompleted"),j._postAllReqsCompleted(),setTimeout((()=>{j.updateLightProbes(),j._renderer.shadowMap.enabled&&j._bShadowsFixedBound&&0===j._aniMixers.length&&(j._dMainL.shadow.autoUpdate=!1,console.log("Lazy shadows"))}),1e3)},j._postAllReqsCompleted=e=>{void 0===e&&(e=j._rootVisible);for(let t in e.children){let o=e.children[t];o&&o.toggle&&(j._postAllReqsCompleted(o),o.toggle(o.visible))}ThreeMeshUI.update()},j.recomputeSceneBounds=e=>{e?j.bounds.union(e):(j.bounds.center.copy(j._rootVisible.getBound().center),j.bounds.radius=j._rootVisible.getBound().radius),j.bounds.radius<=0||(j._renderer.shadowMap.enabled&&(j._rootVisible.traverse((e=>{e.isMesh&&(e.castShadow=!0,e.receiveShadow=!0)})),j.adjustShadowsParamsFromSceneBounds(),j._bShadowsFixedBound&&j.updateDirShadows()),j._bAutoLP&&(void 0===j._lps[0]?j.addLightProbe((new j.LightProbe).setPosition(j.bounds.center).setNear(j.bounds.radius)):j._lps[0].setPosition(j.bounds.center).setNear(j.bounds.radius),console.log("Auto LP")),j.FX.composer&&j.FX.setDOFaperture(1/(30*j.bounds.radius)),j._mMainPano&&j._mMainPano.position.copy(j.bounds.center))},j.registerNodeResourceHandler=(e,t)=>{j._resHandler||(j._resHandler={}),j._resHandler[e]=t,console.log("Registered resource handler '"+e+"'")},j.removeNodeResourceHanlder=e=>{j._resHandler&&j._resHandler[e]&&(j._resHandler[e]=void 0)},j.initGraphs=()=>{j._mainRoot=new THREE.Scene,j._mainRoot.background=new THREE.Color(.7,.7,.7),j._rootVisibleGlobal=new THREE.Scene,j._mainRoot.add(j._rootVisibleGlobal),j._rootVisible=j.createSceneNode().setAsRoot(),j._rootVisibleGlobal.add(j._rootVisible),j._rootSem=j.createSemanticNode().setAsRoot(),j._mainRoot.add(j._rootSem),j._rootUI=j.createUINode().setAsRoot(),j._mainRoot.add(j._rootUI),j.ambLight=new THREE.AmbientLight(new THREE.Color(1,1,1)),j.ambLight.intensity=3,j._rootVisibleGlobal.add(j.ambLight),j.plight=new THREE.PointLight,j.plight.intensity=0,j.plight.decay=.2,j._rootVisibleGlobal.add(j.plight)},j.enablePointLight=()=>{j.plight.intensity=3},j.disablePointLight=()=>{j.plight.intensity=0},j.setBackgroundColor=e=>{j._mainRoot.background=e},j.setFog=(e,t)=>{void 0!==e&&(void 0===t&&(t=200),j._rootVisibleGlobal.fog=new THREE.Fog(e,1,t),j.setBackgroundColor(e))},j.disableFog=()=>{j._rootVisibleGlobal.fog=null},j.setAutoLP=e=>{j._bAutoLP=e},j.setNeutralAmbientLight=e=>{j.ambLight.color=new THREE.Color(e,e,e)},j.addLightProbe=e=>{void 0!==e&&(j._lps.push(e),j.setNeutralAmbientLight(0),void 0!==j.SUI.gLPIcons&&N.addLPIcon(e))},j.getNumLightProbes=()=>j._lps.length,j._updLP=()=>{for(let e in j._lps)j._lps[e].update();j._rootVisible.traverse((e=>{let t=e.userData.LP;void 0!==t&&t instanceof j.LightProbe&&(e.material.envMap=t.getEnvTex(),e.material.envMapIntensity=j._envMapInt,e.material.needsUpdate=!0)}))},j.setLightProbesNumBounces=e=>{e<1||(j._numLPbounces=e)},j.dirtyLightProbes=e=>{void 0===e&&(e=j._numLPbounces),j._lpbCount=e},j.updateLightProbes=()=>{if(!j.XR._bPresenting&&0!==j._lps.length){for(let e=0;e{let t;if(e=j.Utils.resolveCollectionURL(e),void 0===j._mMainPano&&(j._gMainPano=new THREE.SphereGeometry(1,60,60),j._gMainPano.castShadow=!1,j._gMainPano.receiveShadow=!1,j._mMainPano=new THREE.Mesh(j._gMainPano,j._matMainPano),j._mMainPano.frustumCulled=!1,j._mMainPano.renderOrder=-100,j._mMainPano.layers.disable(j.NTYPES.SCENE),j._mMainPano.layers.disable(j.NTYPES.SEM),j._mMainPano.layers.disable(j.NTYPES.UI),j._mMainPano.raycast=j.Utils.VOID_CAST,j.setMainPanoramaRadius(.8*j.Nav.STD_FAR)),j.Utils.isVideo(e)){if(void 0===j._elPanoVideo){let t="",$(t).appendTo("body"),j._elPanoVideo=document.getElementById("idPanoVideo"),j._elPanoVideo.onplaying=()=>{console.log("VideoPano playing"),j._vpanoPlaying=!0},j._elPanoVideo.onpause=()=>{console.log("VideoPano paused"),j._vpanoPlaying=!1},j._elPanoVideo.addEventListener("touchstart",(function(){j._elPanoVideo.play()})),enableInlineVideo(j._elPanoVideo)}t=new THREE.VideoTexture(j._elPanoVideo),t.colorSpace=j._stdEncoding,j._realizeOrUpdateMainPano(t),j.fire("MainPanoVideo")}else{if(e.endsWith(".hdr"))return void(new THREE.RGBELoader).load(e,(e=>{e.minFilter=THREE.LinearMipmapLinearFilter,e.magFilter=THREE.LinearFilter,e.colorSpace=j._stdEncoding,j._realizeOrUpdateMainPano(e),j.fire("MainPanoHDR")}));if(e.endsWith(".exr"))return void(new THREE.EXRLoader).load(e,(e=>{e.minFilter=THREE.LinearMipmapLinearFilter,e.magFilter=THREE.LinearFilter,e.colorSpace=j._stdEncoding,j._realizeOrUpdateMainPano(e),j.fire("MainPanoHDR")}));j.Utils.textureLoader.load(e,(e=>{e.colorSpace=j._stdEncoding,e.generateMipmaps=!0,j._realizeOrUpdateMainPano(e),j.fire("MainPano")}))}},j.playMainPanorama=()=>{j._elPanoVideo&&(j._vpanoPlaying||j._elPanoVideo.play())},j.pauseMainPanorama=()=>{j._elPanoVideo&&j._vpanoPlaying&&j._elPanoVideo.pause()},j.playOrPauseMainPanorama=()=>{j._elPanoVideo&&(j._vpanoPlaying?j._elPanoVideo.pause():j._elPanoVideo.play())},j.stopAndRemoveMainPanorama=()=>{j._elPanoVideo&&(j._vpanoPlaying&&j._elPanoVideo.pause(),j._elPanoVideo.remove(),j._elPanoVideo=void 0,j._vpanoPlaying=!1)},j._realizeOrUpdateMainPano=e=>{if(void 0!==j._matMainPano)return j._matMainPano.map=e,void j.updateLightProbes();j._matMainPano=new THREE.MeshBasicMaterial({map:e,depthTest:!1,depthWrite:!1}),j._mMainPano.material=j._matMainPano,j._bMainPanoInfinite&&(j._mMainPano.onAfterRender=()=>{"immersive-ar"!==j.XR._sessionType&&j.Nav._currPOV&&j._mMainPano.position.copy(j.Nav._currPOV.pos)}),j._rootVisibleGlobal.add(j._mMainPano),j.updateLightProbes()},j.setMainPanoramaRadius=e=>{void 0!==j._gMainPano&&j._gMainPano.scale(-e,e,e)},j.setMainPanoramaRotation=e=>{void 0!==j._mMainPano&&j._mMainPano.rotation.set(0,e,0)},j.setMainPanoramaInfinite=e=>{j._bMainPanoInfinite=e,void 0!==j._mMainPano&&(j._mMainPano.onAfterRender=e?()=>{j.Nav._currPOV&&j._mMainPano.position.copy(j.Nav._currPOV.pos)}:void 0)},j.setMainPanoramaLocation=e=>{j._bMainPanoInfinite||void 0!==j._mMainPano&&j._mMainPano.position.copy(e)},j.setMainLightDirection=e=>{let t=e.clone();t.normalize(),t.x*=.5*j.SHADOWS_FAR,t.y*=.5*j.SHADOWS_FAR,t.z*=.5*j.SHADOWS_FAR,void 0===j._dMainL&&(j._dMainL=new THREE.DirectionalLight(new THREE.Color(1,1,1),1),j._dMainL.castShadow=!1,j._dMainL.intensity=2,j._dMainLtgt=new THREE.Object3D,j._rootVisibleGlobal.add(j._dMainLtgt),j._dMainL.target=j._dMainLtgt,j._rootVisibleGlobal.add(j._dMainL),j._dMainLpos=new THREE.Vector3),j._dMainLdir=t,j._dMainL.position.set(-t.x,-t.y,-t.z),j._renderer.shadowMap.enabled&&(j._dMainL.shadow.needsUpdate=!0),j.toggleMainLight(!0)},j.getMainLightDirection=()=>{if(void 0===j._dMainLdir)return;let e=j._dMainLdir.clone();return e.normalize(),e},j.toggleMainLight=e=>{if(void 0===j._dMainL)return;j._dMainL.visible=e;let t=j._lps.length;e?(t>0?j.setNeutralAmbientLight(0):j.setNeutralAmbientLight(j.AMB_L),j.updateDirShadows()):t>0?j.setNeutralAmbientLight(0):j.setNeutralAmbientLight(j.AMB_L)},j.isMainLightEnabled=()=>void 0!==j._dMainL&&!!j._dMainL.visible,j.setExposure=e=>{j._renderer.toneMappingExposure=e},j.getExposure=()=>j._renderer.toneMappingExposure,j.adjustShadowsParamsFromSceneBounds=()=>{if(void 0===j._dMainL)return;let e=j._rootVisible.getBound().radius,t=j._rootVisible.getBound().center;e<=0||e>=j.SHADOWS_SIZE?(j._bShadowsFixedBound=!1,j._shadowsSize=j.SHADOWS_SIZE):(j._bShadowsFixedBound=!0,j._shadowsFixedBoundCenter=t,j._shadowsSize=1.5*e),j._dMainL.shadow.map&&(j._dMainL.shadow.map.dispose(),j._dMainL.shadow.map=null),j._dMainL.shadow.camera.left=-j._shadowsSize,j._dMainL.shadow.camera.right=j._shadowsSize,j._dMainL.shadow.camera.bottom=-j._shadowsSize,j._dMainL.shadow.camera.top=j._shadowsSize,j._dMainL.shadow.mapSize.width=j._shadowsRes,j._dMainL.shadow.mapSize.height=j._shadowsRes,j._dMainL.shadow.camera.near=j._shadowsNear,j._dMainL.shadow.camera.far=j._shadowsFar;let o=-2e-4*e;o<-.001&&(o=-.001),j._dMainL.shadow.bias=o},j.toggleShadows=e=>{if(void 0!==j._dMainL)if(e){if(j.XR.isPresenting())return;if(j.device.lowGPU)return;j._dMainL.castShadow=!0,j._renderer.shadowMap.enabled=!0,j.device.isMobile?j._renderer.shadowMap.type=THREE.PCFShadowMap:j._renderer.shadowMap.type=THREE.PCFSoftShadowMap,j._rootVisible.traverse((e=>{e.isMesh&&(e.castShadow=!0,e.receiveShadow=!0)})),j.adjustShadowsParamsFromSceneBounds(),j.updateDirShadows(),j._dMainL.shadow.needsUpdate=!0,console.log("Shadows ON")}else j._dMainL.castShadow=!1,j._renderer.shadowMap.enabled=!1,console.log("Shadows OFF")},j.updateDirShadows=()=>{if(void 0===j._dMainLdir)return;if(void 0===j._dMainLpos)return;let e=j._shadowsFixedBoundCenter;void 0===e?(e=j.Nav.getCurrentEyeLocation(),j._dMainLpos.x=e.x+j.Nav._vDir.x*j._shadowsSize,j._dMainLpos.y=e.y+j.Nav._vDir.y*j._shadowsSize,j._dMainLpos.z=e.z+j.Nav._vDir.z*j._shadowsSize):(j._dMainLpos.x=e.x,j._dMainLpos.y=e.y,j._dMainLpos.z=e.z),j._dMainL.position.set(j._dMainLpos.x-j._dMainLdir.x,j._dMainLpos.y-j._dMainLdir.y,j._dMainLpos.z-j._dMainLdir.z),j._dMainLtgt.position.copy(j._dMainLpos)},j._updateEnvironment=()=>{j._renderer.shadowMap.enabled&&(j._bShadowsFixedBound||j.updateDirShadows())},j.setGlobalAudio=(e,t)=>{void 0!==e&&(void 0===t&&(t=!0),e=j.Utils.resolveCollectionURL(e),void 0===j._auMain||null===j._auMain?j._auMain=new THREE.Audio(j.AudioHub._listener):j._auMain.isPlaying&&j._auMain.stop(),j.AudioHub._loader.load(e,(e=>{j._auMain.setBuffer(e),j._auMain.setLoop(t),j._auMain.play()})))},j._markFPS=()=>{j._numReqLoad>0||j._dt<0||(j._dtCount+=1,j._dtAccum+=j._dt,j._dtAccum<1||(j._fps=1/(j._dtAccum/j._dtCount),j._dtCount=0,j._dtAccum=0,j._handleDynamicRenderProfiles()))},j.toggleAdaptiveDensity=e=>{j._bAdaptiveDensity=e},j.setAdaptiveDensityRange=(e,t)=>{e>=t||(j._adMin=e,j._adMax=t)},j.setDynamicRenderingFPS=(e,t)=>{e>=t||(e&&(j._dRenderBudgetMinFPS=e),t&&(j._dRenderBudgetMaxFPS=t))},j._handleDynamicRenderProfiles=()=>{let e=j._renderer.getPixelRatio();j._fps=j._adMin&&(j._renderer.setPixelRatio(e),j.FX.composer&&j.FX.composer.setPixelRatio(e),console.log("Density: "+e.toPrecision(2)))),j.fire("RequestLowerRender")),j._fps>j._dRenderBudgetMaxFPS&&(j._bAdaptiveDensity&&!j.XR._bPresenting&&(e+=.1,e<=j._adMax&&(j._renderer.setPixelRatio(e),j.FX.composer&&j.FX.composer.setPixelRatio(e),console.log("Density: "+e.toPrecision(2)))),j.fire("RequestHigherRender"))},j._onFrame=()=>{j._dt=j._clock.getDelta(),j._markFPS(),j.XR._bPresenting?j.XR.update():j.Nav._controls.update(j._dt),j._handleQueries(),j.Nav.update(),j.Photon.update(),j.SUI.update(),j.MatHub.update(),j._updateEnvironment(),j._updateAniMixers(),j._updateRoutines(),j.MRes.update(),j.XPFNetwork.update(),j._render()},j._render=()=>{!j.FX.composer||j.XR._bPresenting?j._renderer.render(j._mainRoot,j.Nav._camera):j.FX.composer.render()},j.addUpdateRoutine=e=>{void 0!==e&&j._updRoutines.push(e)},j.deleteAllUpdateRoutines=()=>{j._updRoutines=[]},j._updateRoutines=()=>{let e=j._updRoutines.length;if(!(e<=0))for(let t=0;t{let e=j._aniMixers.length;if(!(e<1))for(let t=0;t{e.preventDefault&&e.preventDefault(),j._bCenteredQuery||(j._screenPointerCoords.x=e.clientX/window.innerWidth*2-1,j._screenPointerCoords.y=-e.clientY/window.innerHeight*2+1)},j.toggleCenteredQuery=e=>{j._bCenteredQuery=e,e&&(j._screenPointerCoords.x=0,j._screenPointerCoords.y=0)},j.toggleQueries=e=>{j._bq=e},j._registerRCS=()=>{j._rcRR=0,j._rcHandlers=[],j._rcHandlers.push(j._handleQueryScene),j._rcHandlers.push(j._handleQuerySemantics),j._rcHandlers.push(j._handleQueryUI)},j._handleQueries=()=>{if(!j._bq)return;if(j._bPauseQuery)return;if(j.Nav._bInteracting)return;if(j._numReqLoad>0)return;if(j.Nav.isTransitioning())return;if(j._handleQueryUI(),j._bqScene&&j._handleQueryScene(),j._bqSem&&j._handleQuerySemantics(),j.Nav._bLocValidator&&j.Nav.locomotionValidator(),void 0===j._tgiDur)return;if(void 0===j._tHover)return;const e=j._clock.elapsedTime-j._tHover;e>=j._tgiDur?(j._stdActivation(),j._tHover=void 0,j._tgiPer=void 0):j._tgiPer=e/j._tgiDur},j._handleQueryScene=()=>{if(j.XR.isPresenting()?j.XR.setupQueryRay(j._rcScene):j._rcScene.setFromCamera(j._screenPointerCoords,j.Nav._camera),j._hitsScene=[],j._rcScene.intersectObjects(j._mainRoot.children,!0,j._hitsScene),j._hitsScene.length<=0)return void(j._queryDataScene=void 0);const e=j._hitsScene[0];j._queryDataScene={},j._queryDataScene.p=e.point,j._queryDataScene.d=e.distance,j._queryDataScene.o=e.object,j._queryDataScene.uv=e.uv,j._bQueryNormals&&e.face&&e.face.normal&&(j._queryDataScene.matrixWorld=(new THREE.Matrix3).getNormalMatrix(e.object.matrixWorld),j._queryDataScene.n=e.face.normal.clone().applyMatrix3(j._queryDataScene.matrixWorld).normalize())},j.getSceneFocalPoint=()=>{if(void 0===j._queryDataScene)return;let e=j._queryDataScene.p,t=new THREE.Vector3;return t.lerpVectors(e,j.Nav._currPOV.pos,.02),t},j.getSceneQueriedPoint=()=>{if(void 0!==j._queryDataScene)return j._queryDataScene.p},j.getSceneQueriedDistance=()=>{if(void 0!==j._queryDataScene)return j._queryDataScene.d},j.getSceneQueriedNormal=()=>{if(void 0!==j._queryDataScene)return j._queryDataScene.n},j.getSceneQueriedObjectName=()=>{if(void 0!==j._queryDataScene&&void 0!==j._queryDataScene.o)return j._queryDataScene.o.name},j.getSceneQueriedUV=()=>{if(void 0!==j._queryDataScene)return j._queryDataScene.uv},j.setQueryRange=(e,t,o)=>{void 0!==o&&o!==j.NTYPES.SCENE||(j._rcScene.near=e,j._rcScene.far=t),void 0!==o&&o!==j.NTYPES.SEM||(j._rcSemantics.near=e,j._rcSemantics.far=t)},j._handleQuerySemantics=()=>{if(j.XR.isPresenting()?j.XR.setupQueryRay(j._rcSemantics):j._rcSemantics.setFromCamera(j._screenPointerCoords,j.Nav._camera),j._hitsSem=[],j._rcSemantics.intersectObjects(j._mainRoot.children,!0,j._hitsSem),j._hitsSem.length<=0){if(j._queryDataSem=void 0,j._hoveredSemNode){j.fire("SemanticNodeLeave",j._hoveredSemNode);let e=j.getSemanticNode(j._hoveredSemNode);e&&e.onLeave&&e.onLeave()}return j._hoveredSemNode=void 0,void(j._tHover=void 0)}const e=j._hitsSem[0];if(j._bQuerySemOcclusion&&j._queryDataScene&&j._queryDataScene.d{if(j.XR.isPresenting()?j.XR.setupQueryRay(j._rcUI):j._rcUI.setFromCamera(j._screenPointerCoords,j.Nav._camera),j._hitsUI=[],j._rcUI.intersectObjects(j._mainRoot.children,!0,j._hitsUI),j._hitsUI.length<=0){if(j._queryDataUI=void 0,j._hoveredUI){j.fire("UINodeLeave",j._hoveredUI);const e=j.getUINode(j._hoveredUI);e&&e.onLeave&&e.onLeave()}return j._hoveredUI=void 0,void(j._tHover=void 0)}const e=j._hitsUI[0];if(j._queryDataScene&&j._queryDataScene.d{if(void 0!==j._hoveredSemNode)return j.getSemanticNode(j._hoveredSemNode)},j.setAPIToken=(e,t)=>{window.sessionStorage.setItem("ATON.tokens."+e,t)},j.getAPIToken=e=>window.sessionStorage.getItem("ATON.tokens."+e),j.clearToken=e=>{window.sessionStorage.removeItem("ATON.tokens."+e)},j.enableClipPlanes=()=>{j._renderer&&(j._renderer.localClippingEnabled=!0)},j.disableClipPlanes=()=>{j._renderer&&(j._renderer.localClippingEnabled=!1,j._clipPlanes=[])},j.addClipPlane=(e,t)=>{j.enableClipPlanes();let o=new THREE.Plane;return o.setFromNormalAndCoplanarPoint(e,t),j._clipPlanes.push(o),j.Utils._visitorCP(),o},j.useGizmo=e=>{j._bGizmo=e,j._setupGizmo()},j._setupGizmo=()=>{}})(); \ No newline at end of file +(()=>{"use strict";class e extends THREE.Group{constructor(e,t){super(),this.type=t||ATON.NTYPES.SCENE,this.enablePicking(),this.type===ATON.NTYPES.SCENE&&(this._rootG=ATON._rootVisible,this._nodes=ATON.snodes),this.type===ATON.NTYPES.SEM&&(this._rootG=ATON._rootSem,this._nodes=ATON.semnodes),this.type===ATON.NTYPES.UI&&(this._rootG=ATON._rootUI,this._nodes=ATON.uinodes),this.as(e),this.kwords=void 0,this._bCloneOnLoadHit=!0,this._tlist=void 0,this._aniMixers=void 0,this.castShadow=!1,this.receiveShadow=!1,this._bs=new THREE.Sphere,this.autocenter=!1,this.onHover=void 0,this.onLeave=void 0,this.onSelect=void 0}as(e){if(void 0!==e&&e!==ATON.ROOT_NID)return this._nodes[e]=this,this.nid=e,this.name=e,this}setAsRoot(){return this._nodes[ATON.ROOT_NID]=this,this.nid=ATON.ROOT_NID,this}setCloneOnLoadHit(e){return this._bCloneOnLoadHit=e,this}addKeywords(e){let t=e.split(",");void 0===this.kwords&&(this.kwords={});for(let e in t){let o=t[e].trim();o.length>0&&(this.kwords[o]=!0)}for(let t in this.children){let o=this.children[t];void 0!==o.type&&o.addKeywords(e)}return this}hasKeyword(e){if(void 0!==this.kwords)return void 0!==this.kwords[e]}setDescription(e){return this.userData.description=e,this}getDescription(){return this.userData.description}setAudio(e){return this.userData.audio=e,this}getAudio(){return this.userData.audio}hide(){let e=this.visible;return this.visible=!1,ATON.Utils.setPicking(this,this.type,!1),ATON._renderer.shadowMap.enabled&&(ATON._dMainL.shadow.needsUpdate=!0),e&&ATON.updateLightProbes(),this}show(){let e=this.visible;return this.visible=!0,ATON.Utils.setPicking(this,this.type,this.bPickable),ATON._renderer.shadowMap.enabled&&void 0!==ATON._dMainL&&void 0!==ATON._dMainL.shadow&&(ATON._dMainL.shadow.needsUpdate=!0),e||ATON.updateLightProbes(),this}toggle(e){return void 0===e?this.visible?this.hide():this.show():e?this.show():this.hide()}disablePicking(){return this.bPickable=!1,ATON.Utils.setPicking(this,this.type,this.bPickable),this}enablePicking(){return this.bPickable=!0,ATON.Utils.setPicking(this,this.type,this.bPickable),this}setPickable(e){return e?this.enablePicking():this.disablePicking(),this}setMaterial(e){this.userData.cMat=e,this.traverse((t=>{t.isMesh&&(t.material=e),t.type&&(this.userData.cMat=e)}));for(let t in this.children){let o=this.children[t];o.setMaterial&&o.setMaterial(e)}return this}getMaterial(){return this.userData.cMat}setDefaultAndHighlightMaterials(e,t){return this.userData.matSTD=e,this.userData.matHL=t,this}highlight(){return this.userData.matHL&&this.setMaterial(this.userData.matHL),this}restoreDefaultMaterial(){return this.userData.matSTD&&this.setMaterial(this.userData.matSTD),this}setOpacity(e){return this.traverse((t=>{t.isMesh&&(t.material.opacity=e)})),this}setShadowCast(e){return this.castShadow=e,this.traverse((t=>{t.isMesh&&(t.castShadow=e)})),this}setShadowReceive(e){return this.receiveShadow=e,this.traverse((t=>{t.isMesh&&(t.receiveShadow=e)})),this}setEnvMap(e){return this.traverse((t=>{t.isMesh&&(t.material.envMap=e)})),this}assignLightProbe(e){return this.traverse((t=>{t.isMesh&&t.geometry&&ATON.Utils.assignLightProbeToMesh(e,t)})),this}assignLightProbesByProximity(){return 0===ATON._lps.length||this.traverse((e=>{if(e.isMesh&&e.geometry){let t,o,i=new THREE.Vector3;(new THREE.Box3).setFromObject(e).getCenter(i);for(let e in ATON._lps){let r=ATON._lps[e],a=i.distanceToSquared(r.pos);(void 0===t||a{e.isMesh&&e.geometry&&(ATON.Utils.clearLightProbeFromMesh(e),e.material&&(e.material.envMap.dispose(),e.material.needsUpdate=!0))})),this}updateLightProbes=()=>(this.traverse((e=>{if(e.isMesh&&e.geometry){let t=e.userData.LP;void 0!==t&&(t.update(),e.material.envMap=t.getEnvTex(),e.material.needsUpdate=!0)}})),this);duplicate(){let e=this.clone();return e.traverse((e=>{e.isMesh&&(e.material=e.material.clone())})),e}delete(){let e=this.parent;void 0!==e&&void 0!==e.nid&&e.removeChild(this)}removeChild(e){if(void 0!==e)return e.nid,void 0!==e.nid&&(this._nodes[e.nid]=void 0),e.parent=void 0,e.traverse((e=>{e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})),this.remove(e),this}removeChildren(){for(let e=this.children.length-1;e>=0;e--)this.removeChild(this.children[e]);return this}attachTo(e){let t="string"==typeof e?this._nodes[e]:e;return t&&(t.add(this),void 0!==t.userData.cMat&&(this.userData.cMat=t.userData.cMat),void 0!==t.bPickable&&(this.bPickable=t.bPickable)),t}attachToRoot(){return this._rootG.add(this),void 0!==this._rootG.userData.cMat&&(this.userData.cMat=this._rootG.userData.cMat),void 0!==this._rootG.bPickable&&(this.bPickable=this._rootG.bPickable),this._rootG}getBound(){return this.dirtyBound(),this._bs}dirtyBound(){return(new THREE.Box3).setFromObject(this).getBoundingSphere(this._bs),this}autoFit(e,t){if(this.dirtyBound(),e&&(this.position.copy(this._bs.center),this.position.multiplyScalar(-1)),t&&t>0&&this._bs.radius>0){let e=t/this._bs.radius;this.scale.set(e,e,e)}}setPosition(e,t,o){return e instanceof THREE.Vector3?this.position.copy(e):this.position.set(e,t,o),this}setScale(e,t,o){return e instanceof THREE.Vector3?this.scale.copy(e):(void 0===t&&(t=e,o=e),this.scale.set(e,t,o)),this}setRotation(e,t,o){return e instanceof THREE.Vector3?this.rotation.copy(e):this.rotation.set(e,t,o),this}orientToCamera(){return this.quaternion.copy(ATON.Nav._qOri),this}orientToLocation(e,t,o){return e instanceof THREE.Vector3?this.lookAt(e):this.lookAt(e,t,o),this}orientToNode(e){return e?(this.orientToLocation(e.position),this):this}setYup(){return this.rotation.set(-1.57079632679,0,0),this}addTransform(e){let t;return"string"==typeof e&&(t=ATON.Utils.parseTransformString(e)),void 0===t||(void 0===this._tlist&&(this._tlist=[]),this._tlist.push(t)),this}load(e,t){if(void 0===e)return this;let o=this;if(e=ATON.Utils.resolveCollectionURL(e),ATON.Utils.tryLoadFromService(e,o))return t&&t(),o;if("json"===ATON.Utils.getFileExtension(e))return ATON.MRes.loadTileSetFromURL(e,o),t&&t(),o;if(ATON._resHandler)for(let t in ATON._resHandler)if(ATON._resHandler[t](e,o))return o;if(o._bCloneOnLoadHit&&void 0!==ATON._assetsManager[e])return ATON._assetsManager[e].then((e=>{let i=e.clone();if(ATON.Utils.modelVisitor(o,i),void 0!==o._tlist)for(let e in o._tlist)o._tlist[e].add(i.clone()),o.add(o._tlist[e]);else o.add(i);t&&t()})),o;ATON._assetReqNew(e);let i=new Promise(((i,r)=>{ATON._aLoader.load(e,(r=>{let a=r.scene||r.scene[0];if(ATON.Utils.modelVisitor(o,a),void 0!==o._tlist)for(let e in o._tlist)o._tlist[e].add(a.clone()),o.add(o._tlist[e]);else o.add(a);ATON.Utils.registerAniMixers(o,r),ATON.CC.extract(r),i(a),console.log("%cModel loaded","color:green"),ATON._assetReqComplete(e),o.type===ATON.NTYPES.SCENE&&(ATON._bqScene=!0),o.type===ATON.NTYPES.SEM&&(ATON._bqSem=!0),o.bPickable&&o.enablePicking(),o.dirtyBound(),t&&t()}),void 0,(o=>{console.log("%cError loading model "+e,"color:red"),ATON._assetReqComplete(e),t&&t()}))}));return o._bCloneOnLoadHit&&(ATON._assetsManager[e]=i),this}exportAs(e){return ATON.Utils.exportNode(this,e),this}setOnHover(e){return this.onHover=e,this}setOnLeave(e){return this.onLeave=e,this}setOnSelect(e){return this.onSelect=e,this}loadCesiumIONAsset(e){return ATON.MRes.loadCesiumIONAsset(e,this),this}loadSketchfabAsset(e){let t=ATON.getAPIToken("sketchfab"),o=this;return null==t&&(console.log("A valid Sketchfab token is required"),t=prompt("Please enter a valid Sketchfab token:"),null==t||""==t)||fetch("https://api.sketchfab.com/v3/models/"+e+"/download",{method:"GET",headers:{Authorization:"Token "+t},mode:"cors"}).then((function(e){return e.json()})).then((function(e){if(ATON.setAPIToken("sketchfab",t),e.glb){let t=e.glb.url;return o.load(t),o}})),this}}const t=e;let o={init:()=>{o.evLocal={},o.evNetwork={},ATON.on=o.on,ATON.fire=o.fire,ATON.fireEvent=o.fire,ATON.clearEventHandlers=o.clearEventHandlers},clearEventHandlers:e=>{o.evLocal[e]=[],o.evNetwork[e]=[]},executeHandlers:(e,t)=>{if(e)for(let o=0;o{if(void 0!==t){const i=o.evLocal;void 0===i[e]&&(i[e]=[]),i[e].push(t)}void 0!==i&&ATON.Photon.on(e,i)},fire:(e,t,i)=>{const r=o.evLocal[e];o.executeHandlers(r,t),i&&ATON.Photon.fire(e,t)}};const i=o;let r={init:()=>{r.materials={},r.colors={},r._loader=new THREE.MaterialLoader,r._uSem={time:{type:"float",value:0},tint:{type:"vec4",value:new THREE.Vector4(.2,.2,1,.2)},sel:{type:"vec4",value:new THREE.Vector4(0,0,0,.1)}},r.addDefaults()},getDefVertexShader:()=>"\n varying vec3 vPositionW;\n varying vec3 vNormalW;\n varying vec3 vNormalV;\n varying vec2 vUv;\n\n void main(){\n vUv = uv;\n\n vPositionW = ( modelMatrix * vec4( position, 1.0 )).xyz;\n vNormalV = normalize( vec3( normalMatrix * normal ));\n vNormalW = ( modelMatrix * vec4(normal, 0.0 )).xyz;\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }\n ",addDefaults:()=>{r.colors.white=new THREE.Color(1,1,1),r.colors.black=new THREE.Color(0,0,0),r.colors.green=new THREE.Color(0,1,0),r.colors.yellow=new THREE.Color(1,1,0),r.colors.red=new THREE.Color(1,0,0),r.colors.blue=new THREE.Color(0,0,1),r.colors.orange=new THREE.Color(1,.5,0),r.colors.defUI=new THREE.Color(.85,1,.95),r.colors.sem=new THREE.Color(0,1,.5),r.colors.darksem=new THREE.Color(0,0,.1),r.materials.fullyTransparent=new THREE.MeshBasicMaterial({transparent:!0,depthWrite:!1,opacity:0}),r.materials.defUI=new THREE.ShaderMaterial({uniforms:{tint:{type:"vec3",value:r.colors.defUI},opacity:{type:"float",value:0}},vertexShader:r.getDefVertexShader(),fragmentShader:"\n varying vec3 vPositionW;\n\t\t varying vec3 vNormalW;\n varying vec3 vNormalV;\n uniform vec3 tint;\n //uniform vec3 base;\n uniform float opacity;\n\n\t\t void main(){\n\t\t //vec3 viewDirectionW = normalize(cameraPosition - vPositionW);\n\n float f;\n\t\t //f = dot(vNormalV, viewDirectionW);\n f = dot(vNormalV, vec3(0,0,1));\n\t\t f = clamp(1.0-f, 0.0, 1.0);\n f *= f;\n\n f = mix(opacity, 1.0 + opacity, f);\n f = clamp(f, 0.0,1.0);\n\n //vec3 col = mix(base,tint, f);\n\t\t //gl_FragColor = vec4(col, f * opacity);\n\n gl_FragColor = vec4(tint, f);\n\t\t }\n ",transparent:!0,depthWrite:!1}),r.materials.selector=r.materials.defUI.clone(),r.materials.outline=new THREE.MeshBasicMaterial({color:r.colors.black,side:THREE.BackSide,transparent:!0,depthWrite:!1,opacity:.2}),r.materials.controllerRay=r.materials.defUI.clone(),r.materials.controllerRay.uniforms.tint.value=r.colors.white,r.materials.xray=r.materials.defUI.clone(),r.materials.xray.uniforms.tint.value=r.colors.white,r.materials.xray.uniforms.opacity.value=.5,r.materials.teleportLoc=new THREE.MeshBasicMaterial({transparent:!0,opacity:1,depthWrite:!1,side:THREE.DoubleSide}),ATON.Utils.textureLoader.load(ATON.PATH_RES+"grad.png",(e=>{r.materials.teleportLoc.map=e})),r.materials.measurement=new THREE.MeshBasicMaterial({color:r.colors.white,transparent:!0,depthWrite:!1,opacity:.5,depthTest:!1}),r.materials.semanticShape=new THREE.ShaderMaterial({uniforms:r._uSem,vertexShader:r.getDefVertexShader(),fragmentShader:"\n varying vec3 vPositionW;\n\t\t varying vec3 vNormalW;\n varying vec3 vNormalV;\n\n uniform float time;\n uniform vec4 tint;\n\n\t\t void main(){\n\t\t //vec3 viewDirectionW = normalize(cameraPosition - vPositionW);\n\n //float ff = dot(vNormalV, vec3(0,0,1));\n\t\t //ff = clamp(1.0-ff, 0.0, 1.0);\n\n float f = (1.0 * cos(time*2.0)); // - 0.5;\n //f = cos(time + (vPositionW.y*10.0));\n f = clamp(f, 0.0,1.0);\n\n\t\t gl_FragColor = vec4(tint.rgb, tint.a * f);\n //gl_FragColor = vec4(tint.rgb, ff);\n\t\t }\n ",transparent:!0,depthWrite:!1}),r.materials.semanticShapeHL=new THREE.MeshBasicMaterial({color:r.colors.sem,transparent:!0,depthWrite:!1,opacity:.2}),r.materials.semanticShapeEdit=new THREE.MeshBasicMaterial({color:r.colors.orange,transparent:!0,depthWrite:!1,opacity:.5}),r.materials.transWhite=new THREE.MeshBasicMaterial({color:r.colors.white,transparent:!0,depthWrite:!1,side:THREE.DoubleSide,opacity:.2}),r.materials.transBlack=new THREE.MeshBasicMaterial({color:r.colors.black,transparent:!0,depthWrite:!1,side:THREE.DoubleSide,opacity:.2}),r.materials.wireframe=new THREE.MeshBasicMaterial({color:r.colors.black,transparent:!0,depthWrite:!1,opacity:.1,wireframe:!0}),r.materials.normSlope=new THREE.ShaderMaterial({vertexShader:r.getDefVertexShader(),fragmentShader:"\n varying vec3 vPositionW;\n\t\t varying vec3 vNormalW;\n\n\t\t void main(){\n vec4 A = vec4(0,1,0, 1.0);\n vec4 B = vec4(1,0,0, 1.0);\n\n float f;\n f = dot(vNormalW, vec3(0,1,0));\n\n\t\t gl_FragColor = mix(B,A, f);\n\t\t }\n "}),r.materials.gradient=new THREE.ShaderMaterial({uniforms:{range:{type:"vec2",value:new THREE.Vector2(-4,5)}},vertexShader:r.getDefVertexShader(),fragmentShader:"\n varying vec3 vPositionW;\n\n uniform vec2 range;\n\n\t\t void main(){\n vec4 A = vec4(0,0,0, 1.0);\n vec4 B = vec4(0,0.5,1, 1.0);\n\n float t = (vPositionW.y - range.x)/(range.y - range.x);\n t = clamp(t, 0.0,1.0);\n\n\t\t gl_FragColor = mix(A,B, t);\n\t\t }\n "}),r.materials.lp=new THREE.ShaderMaterial({vertexShader:r.getDefVertexShader(),fragmentShader:"\n varying vec3 vPositionW;\n\t\t varying vec3 vNormalW;\n varying vec3 vNormalV;\n\n\t\t void main(){\n\t\t vec3 viewDirectionW = normalize(cameraPosition - vPositionW);\n\n float f;\n\t\t //f = dot(viewDirectionW, vNormalW);\n f = dot(vNormalV, vec3(0,0,1));\n\t\t f = clamp(1.0 - f, 0.0, 1.0);\n\n\t\t gl_FragColor = vec4(1.0,1.0,1.0, f);\n\t\t }\n ",transparent:!0,depthWrite:!1});let e=(new THREE.TextureLoader).load(ATON.PATH_RES+"point-mask.png");e.generateMipmaps=!1,r.materials.point=new THREE.PointsMaterial({vertexColors:!0,alphaMap:e,alphaTest:.5,depthTest:!0,transparent:!1,size:4,sizeAttenuation:!1}),r.materials.chromakey=new THREE.ShaderMaterial({uniforms:{tBase:{type:"t"},keycolor:{type:"vec4",value:new THREE.Vector4(0,1,0,0)},similarity:{type:"float",value:.4},smoothness:{type:"float",value:.08},spill:{type:"float",value:.1}},vertexShader:r.getDefVertexShader(),fragmentShader:"\n uniform sampler2D tBase;\n uniform vec4 keycolor;\n\n uniform float similarity;\n uniform float smoothness;\n uniform float spill;\n\n varying vec2 vUv;\n\n // From https://github.com/libretro/glsl-shaders/blob/master/nnedi3/shaders/rgb-to-yuv.glsl\n vec2 RGBtoUV(vec3 rgb){\n return vec2(\n rgb.r * -0.169 + rgb.g * -0.331 + rgb.b * 0.5 + 0.5,\n rgb.r * 0.5 + rgb.g * -0.419 + rgb.b * -0.081 + 0.5\n );\n }\n\n // From https://godotshaders.com/shader/green-screen-chromakey/\n\t\t void main(){\n\t\t vec4 frag = texture2D(tBase, vUv);\n vec4 orig = frag;\n\n float chromaDist = distance(RGBtoUV(frag.rgb), RGBtoUV(keycolor.rgb));\n\n float baseMask = chromaDist - similarity;\n float fullMask = pow(clamp(baseMask / smoothness, 0.0,1.0), 1.5);\n frag.a = fullMask;\n \n float spillVal = pow(clamp(baseMask / spill, 0.0,1.0), 1.5);\n float desat = clamp(frag.r * 0.2126 + frag.g * 0.7152 + frag.b * 0.0722, 0.0,1.0);\n frag.rgb = mix(vec3(desat, desat, desat), frag.rgb, spillVal);\n\n frag = mix(orig,frag, keycolor.w);\n\n\t\t gl_FragColor = frag;\n\t\t }\n ",transparent:!0,side:THREE.DoubleSide})},addMaterial:(e,t)=>{r.materials[e]?console.log("MatHub: material "+e+" already registered"):r.materials[e]=t},loadMaterial:(e,t)=>{r._loader.load(t,(t=>{r.addMaterial(e,t)}),void 0,(e=>{console.log(e)}))},getMaterial:e=>r.materials[e],update:()=>{r._uSem.time.value+=ATON._dt,r._uSem.sel.value.x=ATON.SUI.mainSelector.position.x,r._uSem.sel.value.y=ATON.SUI.mainSelector.position.y,r._uSem.sel.value.z=ATON.SUI.mainSelector.position.z,r._uSem.sel.value.w=ATON.SUI._selectorRad}};const a=r;let n={TSTRING_SEPARATOR:" ",VOID_CAST:(e,t)=>{},init:()=>{ATON.device={},n.geomUnitSphere=new THREE.SphereGeometry(1,32,32),n.geomUnitCube=new THREE.BoxGeometry,n.exporterGLTF=void 0,n.exporterOBJ=void 0,n.exporterUSDZ=void 0,n._dlink=document.createElement("a"),n._dlink.style.display="none",document.body.appendChild(n._dlink),n.textureLoader=new THREE.TextureLoader,n._bvhBounds=0,n.stats={},n.stats.numVertices=0,n.stats.numTris=0},generateID:e=>(void 0===e&&(e="id"),e+"-"+Math.random().toString(36).substr(2,9)),goToURL:e=>{window.location.href=e},goToScene:(e,t)=>{if(void 0===e)return;if(e.length<2)return;let o=ATON.PATH_FE+e;void 0!==t&&(o+="&vrc="+t),window.location.href=o},isConnectionSecure:()=>window.isSecureContext,isLocalhost:()=>!!window.location.origin.includes("localhost")||!!window.location.origin.includes("127.0.0.1"),showBVHbounds:e=>{e>0&&(n._bvhBounds=e)},_addBVHbounds:(e,t)=>{if(void 0===e)return;let o=new ThreeMeshBVH.MeshBVHHelper(e,t);o.displayParents=!0,o.update(),e.parent.add(o)},profileDevice:()=>{ATON.device.isMobile=!1,ATON.device.isMobile=!(!/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)&&!/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4))),ATON.device.xrSupported={},ATON.device.xrSupported["immersive-vr"]=!1,ATON.device.xrSupported["immersive-ar"]=!1,"xr"in navigator&&(navigator.xr.isSessionSupported("immersive-vr").then((e=>{ATON.device.xrSupported["immersive-vr"]=!!e,console.log("WebXR VR session support: "+ATON.device.xrSupported["immersive-vr"]),ATON.fire("XR_support",{type:"immersive-vr",v:ATON.device.xrSupported["immersive-vr"]})})),navigator.xr.isSessionSupported("immersive-ar").then((e=>{ATON.device.xrSupported["immersive-ar"]=!!e,console.log("WebXR AR session support: "+ATON.device.xrSupported["immersive-ar"]),ATON.fire("XR_support",{type:"immersive-ar",v:ATON.device.xrSupported["immersive-ar"]})})))},profileRenderingCapabilities:()=>{if(void 0===ATON._renderer)return;let e=ATON._renderer.capabilities;void 0!==e&&(ATON.device.lowGPU=!1,e.isWebGL2||(ATON.device.lowGPU=!0),e.maxTextureSize<8192&&(ATON.device.lowGPU=!0),e.maxCubemapSize<4096&&(ATON.device.lowGPU=!0),console.log(e))},isMobile:()=>ATON.device.isMobile,isVRsupported:()=>ATON.device.xrSupported["immersive-vr"],isARsupported:()=>ATON.device.xrSupported["immersive-ar"],getFileExtension:e=>e.substr(e.lastIndexOf(".")+1).toLowerCase(),removeFileExtension:e=>e.replace(/\.[^/.]+$/,""),isVideo:e=>{let t=n.getFileExtension(e);return"mp4"===t||"webm"===t||"m3u8"===t},isImage:e=>{let t=n.getFileExtension(e);return"jpg"===t||"png"===t||"ktx"===t||"ktx2"===t},getBaseFolder:e=>{var t=e.lastIndexOf("/");return-1!==t?e.substring(0,t+1):""},getFilename:e=>e.split(/(\\|\/)/g).pop(),isResourceURL:e=>!!e.startsWith("http://")||!!e.startsWith("https://"),URLify:e=>{if("string"!=typeof e)return e;const t=e.match(/(((ftp|https?):\/\/)[\-\w@:%_\+.~#?,&\/\/=]+)/g);return t&&t.forEach((function(t){e=e.replace(t,"")})),e},resolveCollectionURL:e=>e?(ATON._collMod&&(e=ATON._collMod(e)),e.startsWith("http")?e:ATON.PATH_COLLECTION+e):"",tryLoadFromService:(e,t)=>{if(!t)return!1;if(e.startsWith("https://cesium.com/ion/assets/")||e.startsWith("https://ion.cesium.com/assets/")){let o=e.split("/"),i=o[o.length-1];return t.loadCesiumIONAsset(i),!0}if(e.startsWith("https://assets.cesium.com/")){let o=e.split("/"),i=o[o.length-2];return t.loadCesiumIONAsset(i),!0}if(e.startsWith("https://sketchfab.com/3d-models/")){let o=e.split("-"),i=o[o.length-1];return t.loadSketchfabAsset(i),!0}for(let o in ATON._resMappers){let i=ATON._resMappers[o](e);if(void 0!==i)return t.load(i),!0}return!1},postJSON:(e,t,o,i)=>{$.ajax({url:e,type:"POST",xhrFields:{withCredentials:!0},data:JSON.stringify(t),contentType:"application/json; charset=utf-8",dataType:"json",success:e=>{o&&o(e)}}).fail((e=>{console.log(e),i&&i()}))},getJSON:(e,t)=>{fetch(e,{method:"GET",headers:{Accept:"application/json"}}).then((e=>e.json())).then((e=>{console.log(e),t&&t(e)}))},runAsync:e=>{const t=new Worker(URL.createObjectURL(new Blob([`postMessage((${e})());`]),{type:"application/javascript; charset=utf-8"}));return new Promise(((e,o)=>{t.onmessage=({data:o})=>{e(o),t.terminate()},t.onerror=e=>{o(e),t.terminate()}}))},mergeObject:e=>{e.updateMatrixWorld(!0);const t=[];e.traverse((e=>{if(e.isMesh){const o=e.geometry;o.applyMatrix4(e.matrixWorld),t.push(o.toNonIndexed())}}));const o=THREE.BufferGeometryUtils.mergeGeometries(t,!1),i=THREE.BufferGeometryUtils.mergeVertices(o).center(),r=new THREE.Group,a=new THREE.Mesh(i);return r.add(a),r},setPicking:(e,t,o)=>{void 0===o&&(o=!0),e.traverse((e=>{o?e.layers.enable(t):e.layers.disable(t)}))},graphPostVisitor:e=>{e.visible?console.log(e):n.setPicking(e,e.type,!1)},rotationBetweenDirections:(e,t)=>{const o=new THREE.Quaternion,i=(new THREE.Vector3).crossVectors(e,t);return o.x=i.x,o.y=i.y,o.z=i.z,o.w=1+e.clone().dot(t),o.normalize(),o},clampValue:(e,t,o)=>Math.min(Math.max(e,t),o),loadTexture:(e,t)=>{e.endsWith(".ktx2")?ATON._ktx2Loader.load(e,t):n.textureLoader.load(e,t)},modelVisitor:(e,t)=>{if(void 0===t)return;if(void 0===e)return;let o=e.type;t.traverse((t=>{t.isMesh&&(o===ATON.NTYPES.SCENE&&(t.castShadow=!0,t.receiveShadow=!0,t.geometry&&(t.geometry.computeBoundsTree(),console.log("Computed visible BVH"),n._bvhBounds>0&&n._addBVHbounds(t,n._bvhBounds)),n.processMaterial(t.material)),o===ATON.NTYPES.SEM&&(t.material=ATON.MatHub.materials.semanticShape,t.geometry&&(t.geometry.computeBoundsTree(),console.log("Computed semantic BVH"))),e.userData.cMat&&(t.material=e.userData.cMat))}))},processMaterial:e=>{void 0!==e&&null!==e.map&&void 0!==e.map&&(e.map.generateMipmaps=!0,e.map.anisotropy=ATON.device.isMobile?0:ATON._maxAnisotropy,e.map.minFilter=THREE.LinearMipmapLinearFilter,e.map.magFilter=THREE.LinearFilter,e.map.colorSpace=ATON._stdEncoding)},_visitorCP:e=>{ATON._renderer.localClippingEnabled&&(e||(e=ATON._rootVisible),e.traverse((e=>{e.material&&(e.material.clippingPlanes=ATON._clipPlanes,e.material.clipIntersection=!1,e.material.clipShadows=!0)})))},cleanupVisitor:e=>{e.traverse((e=>{if(e.material)if(e.material.length)for(let t=0;t{let o=t.scene||t.scene[0],i=!1;if(void 0===t.animations)return;let r=new THREE.AnimationMixer(o);t.animations.forEach((e=>{r.clipAction(e).play(),i=!0})),i&&(ATON._aniMixers.push(r),void 0===e._aniMixers&&(e._aniMixers=[]),e._aniMixers.push(r))},parseTransformString:e=>{let t=new THREE.Group,o=e.split(n.TSTRING_SEPARATOR),i=o.length;return i<3||(t.position.set(parseFloat(o[0]),parseFloat(o[1]),parseFloat(o[2])),i<6||(t.rotation.set(parseFloat(o[3]),parseFloat(o[4]),parseFloat(o[5])),i<9||t.scale.set(parseFloat(o[6]),parseFloat(o[7]),parseFloat(o[8])))),t},setVectorPrecision:(e,t)=>(e.x=parseFloat(e.x.toPrecision(t)),e.y=parseFloat(e.y.toPrecision(t)),e.z=parseFloat(e.z.toPrecision(t)),e),parseMD:e=>(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/^\s*\n\*/gm,"
      \n*")).replace(/^(\*.+)\s*\n([^\*])/gm,"$1\n
    \n\n$2")).replace(/^\*(.+)/gm,"
  • $1
  • ")).replace(/^\s*\n\d\./gm,"
      \n1.")).replace(/^(\d\..+)\s*\n([^\d\.])/gm,"$1\n
    \n\n$2")).replace(/^\d\.(.+)/gm,"
  • $1
  • ")).replace(/^\>(.+)/gm,"
    $1
    ")).replace(/[\#]{6}(.+)/g,"
    $1
    ")).replace(/[\#]{5}(.+)/g,"
    $1
    ")).replace(/[\#]{4}(.+)/g,"

    $1

    ")).replace(/[\#]{3}(.+)/g,"

    $1

    ")).replace(/[\#]{2}(.+)/g,"

    $1

    ")).replace(/[\#]{1}(.+)/g,"

    $1

    ")).replace(/^(.+)\n\=+/gm,"

    $1

    ")).replace(/^(.+)\n\-+/gm,"

    $1

    ")).replace(/\!\[([^\]]+)\]\(([^\)]+)\)/g,'$1')).replace(/[\[]{1}([^\]]+)[\]]{1}[\(]{1}([^\)\"]+)(\"(.+)\")?[\)]{1}/g,'$1')).replace(/[\*\_]{2}([^\*\_]+)[\*\_]{2}/g,"$1")).replace(/[\*\_]{1}([^\*\_]+)[\*\_]{1}/g,"$1")).replace(/[\~]{2}([^\~]+)[\~]{2}/g,"$1")).replace(/^\s*\n\`\`\`(([^\s]+))?/gm,'
    ')).replace(/^\`\`\`\s*\n/gm,"
    \n\n")).replace(/[\`]{1}([^\`]+)[\`]{1}/g,"$1")).replace(/^\s*(\n)?(.+)/gm,(function(e){return/\<(\/)?(h\d|ul|ol|li|blockquote|pre|img)/.test(e)?e:"

    "+e+"

    "}))).replace(/(\)\s*\n\(.+)\<\/p\>/gm,"$1$2"),checkAuth:e=>{$.ajax({type:"GET",url:ATON.PATH_RESTAPI+"user",xhrFields:{withCredentials:!0},dataType:"json",success:t=>{e(t)}})},getHumanReadableDistance:e=>{let t=" m";return e<.01?(t=" mm",t=(e*=1e3).toPrecision(3)+t,t):e<1?(t=" cm",t=(e*=100).toPrecision(3)+t,t):e>1e3?(t=" km",t=e.toPrecision(3)+t,t):(t=e.toPrecision(3)+t,t)},stripHTMLtagsFromString:e=>e.replace(/(<([^>]+)>)/gi,""),requestFullscreen:()=>{let e=document.documentElement;return e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen(),!0},downloadBlob:(e,t)=>{void 0!==t&&(n._dlink.href=URL.createObjectURL(e),n._dlink.download=t,n._dlink.click())},downloadText:(e,t)=>{n.downloadBlob(new Blob([e],{type:"text/plain"}),t)},downloadJSONobj:(e,t)=>{n.downloadText(JSON.stringify(e),t)},downloadArrayBuffer:(e,t)=>{n.downloadBlob(new Blob([e],{type:"application/octet-stream"}),t)},downloadImageFromCanvas:(e,t)=>{if(!e)return;let o=e.toDataURL();ATON.Utils._dlink.href=o,ATON.Utils._dlink.download=t,ATON.Utils._dlink.click()},exportNode:(e,t)=>{let o=n.getFileExtension(t);if(!(o.length<1)){if("glb"===o||"gltf"===o){let i={binary:"glb"===o};void 0===n.exporterGLTF&&(n.exporterGLTF=new THREE.GLTFExporter),n.exporterGLTF.parse(e,(e=>{e instanceof ArrayBuffer?n.downloadArrayBuffer(e,t):(console.log(e),n.downloadJSONobj(e,t))}),i)}if("obj"===o){void 0===n.exporterOBJ&&(n.exporterOBJ=new THREE.OBJExporter);let o=n.exporterOBJ.parse(e);n.downloadText(o,t)}"usdz"===o&&(void 0===n.exporterUSDZ&&(n.exporterUSDZ=new THREE.USDZExporter),$("#idLoader").show(),n.exporterUSDZ.parse(e).then((e=>{n.downloadArrayBuffer(e,t),$("#idLoader").hide()})))}},takeScreenshot:(e,t)=>{let o=new Image;console.log("Screenshot with size:"+e),ATON.Nav._camera.aspect=1,ATON.Nav._camera.updateProjectionMatrix(),ATON._renderer.setSize(e,e),ATON._renderer.render(ATON._mainRoot,ATON.Nav._camera);let i=ATON._renderer.domElement;if(ATON.FX.composer){if(ATON.FX.composer.setSize(e,e),ATON.FX.passes[ATON.FX.PASS_AA]){let t=ATON.FX.passes[ATON.FX.PASS_AA].material.uniforms;t&&t.resolution.value.set(1/e,1/e)}ATON.FX.composer.render(),i=ATON.FX.composer.renderer.domElement}let r=ATON._renderer.domElement.toDataURL();return o.src=r,t&&(n._dlink.href=r.replace("image/png","image/octet-stream"),n._dlink.download=t,n._dlink.click()),ATON._onResize(),o},assignLightProbeToMesh:(e,t)=>{void 0!==e&&void 0!==t&&(t.noLP||(t.userData.LP=e))},clearLightProbeFromMesh:e=>{void 0!==e&&(e.noLP||(e.userData.LP=null))},vibrate:e=>{void 0===e&&(e=100),window.navigator.vibrate(e)},createATONCube:e=>{let t=new THREE.BoxGeometry(1,1,1),o=new THREE.MeshStandardMaterial;n.textureLoader.load(ATON.PATH_RES+"models/aton-cube.jpg",(e=>{e.colorSpace=ATON._stdEncoding,o.map=e}));let i=ATON.createSceneNode(e);return i.add(new THREE.Mesh(t)),i.setMaterial(o),i.enablePicking(),i},createATONCubePBR:e=>{let t=new THREE.BoxGeometry(1,1,1),o=new THREE.MeshStandardMaterial;o.metalness=1,n.textureLoader.load(ATON.PATH_RES+"models/aton-cube.jpg",(e=>{e.colorSpace=ATON._stdEncoding,o.map=e})),n.textureLoader.load(ATON.PATH_RES+"models/aton-cube-pbr.jpg",(e=>{e.colorSpace=ATON._stdEncoding,o.metalnessMap=e,o.roughnessMap=e})),n.textureLoader.load(ATON.PATH_RES+"models/aton-cube-nrm.png",(e=>{e.colorSpace=ATON._stdEncoding,o.normalMap=e}));let i=ATON.createSceneNode(e);return i.add(new THREE.Mesh(t)),i.setMaterial(o),i.enablePicking(),i},createGround:(e,t,o)=>{void 0===t&&(t=1),void 0===o&&(o=1);let i=new THREE.PlaneGeometry(t,o),r=new THREE.MeshStandardMaterial;void 0!==e&&n.textureLoader.load(e,(e=>{e.colorSpace=ATON._stdEncoding,r.map=e}));let a=ATON.createSceneNode().rotateX(.5*-Math.PI);return a.add(new THREE.Mesh(i,r)),a.enablePicking(),a},convertByteArrayToHexString:e=>e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),""),convertHexStringToByteArray:e=>Uint8Array.from(e.match(/.{1,2}/g).map((e=>parseInt(e,16))))};const s=n;let l={MODE_ADD:0,MODE_DEL:1,FLOAT_PREC:5,init:()=>{l.currID=void 0,l.currData=void 0,l._bEdit=!1,l._bLoading=!1,l._title=void 0,l._descr=void 0,l.initBaseParsers()},setEditMode:e=>{l._bEdit=e,console.log("Edit mode:"+e)},load:(e,t,o)=>(l._bLoading=!0,console.log("Loading Scene: "+t),$.getJSON(e,(e=>{l.currData=e,l.currID=t,l._bLoading=!1,l.parseScene(e),o&&o(),ATON.fire("SceneJSONLoaded",t)}))),clearScene:()=>{if(!(ATON._rootVisible.children.length<=0)){ATON._rootVisible.removeChildren();for(let e in ATON.snodes)e!==ATON.ROOT_NID&&delete ATON.snodes[e];ATON.MRes.clear(),ATON.XPFNetwork.clear()}},clearSemantics:()=>{if(!(ATON._rootSem.children.length<=0)){ATON._rootSem.removeChildren();for(let e in ATON.semnodes)e!==ATON.ROOT_NID&&delete ATON.semnodes[e];ATON.SUI.gSemIcons&&ATON.SUI.gSemIcons.removeChildren(),ATON.SemFactory.stopCurrentConvex(),ATON.SemFactory.init()}},clear:()=>{l.clearScene(),l.clearSemantics(),ATON.Nav.clear()},parseScene:e=>{if(void 0!==(e=void 0===e?l.currData:e))for(let t in e)l._jsonParsers[t]&&l._jsonParsers[t](e[t])},getJSONchildren:(e,t)=>{let o;void 0===t&&(t=ATON.NTYPES.SCENE);let i=[];if(t===ATON.NTYPES.SEM&&(o=ATON.getSemanticNode(e)),t===ATON.NTYPES.SCENE&&(o=ATON.getSceneNode(e)),void 0!==o){for(let e in o.children){let t=o.children[e];void 0!==t.nid&&i.push(t.nid)}return i}},getJSONgraphEdges:e=>{void 0===e&&(e=ATON.NTYPES.SCENE);let t=ATON.snodes;e===ATON.NTYPES.SEM&&(t=ATON.semnodes),e===ATON.NTYPES.UI&&(t=ATON.uinodes);let o={};for(let e in t){let i=t[e];i&&i.parent&&i.parent.nid&&(void 0===o[i.parent.nid]&&(o[i.parent.nid]=[]),o[i.parent.nid].push(i.nid))}return o},getJSONsemanticSpheresList:e=>{let t=ATON.getSemanticNode(e);if(void 0===t)return;let o=[];for(let e in t.children){let i=t.children[e];i.type&&o.push([parseFloat(i.position.x.toPrecision(l.FLOAT_PREC)),parseFloat(i.position.y.toPrecision(l.FLOAT_PREC)),parseFloat(i.position.z.toPrecision(l.FLOAT_PREC)),parseFloat(i.scale.x.toPrecision(l.FLOAT_PREC))])}return o},getJSONsemanticConvexShapes:e=>{let t=ATON.getSemanticNode(e);if(void 0===t)return;let o=[];for(let e in t.children){let i=t.children[e];i.userData._convexPoints&&o.push(i.userData._convexPoints)}return o},_applyJSONTransformToNode:(e,t)=>{if(void 0!==e&&void 0!==t){if(e.bUseGeoCoords)return t.bUseGeoCoords=!0,void(e.scale&&t.setScale(e.scale[0],e.scale[1],e.scale[2]));e.autocenter?t.autocenter=!0:e.position&&t.setPosition(e.position[0],e.position[1],e.position[2]),e.rotation&&t.setRotation(e.rotation[0],e.rotation[1],e.rotation[2]),e.scale&&t.setScale(e.scale[0],e.scale[1],e.scale[2]),e.list&&Array.isArray(e.list)}},initBaseParsers:()=>{l._jsonParsers={},l._jsonParsers.title=e=>{void 0!==e&&l.setTitle(e)},l._jsonParsers.description=e=>{void 0!==e&&l.setDescription(e)},l._jsonParsers.fx=e=>{e.ao&&(ATON.FX.togglePass(ATON.FX.PASS_AO,!0),e.ao.i&&ATON.FX.setAOintensity(parseFloat(e.ao.i))),e.bloom&&(ATON.FX.togglePass(ATON.FX.PASS_BLOOM,!0),e.bloom.i&&ATON.FX.setBloomStrength(parseFloat(e.bloom.i)),e.bloom.t&&ATON.FX.setBloomThreshold(parseFloat(e.bloom.t))),e.dof&&(ATON.FX.togglePass(ATON.FX.PASS_DOF,!0),e.dof.f&&ATON.FX.setDOFfocus(parseFloat(e.dof.f)))},l._jsonParsers.environment=e=>{let t=e.mainpano;if(e.mainpano&&(t.url&&ATON.setMainPanorama(t.url),t.rotation&&ATON.setMainPanoramaRotation(t.rotation)),e.bgcolor){let t=new THREE.Color(e.bgcolor[0],e.bgcolor[1],e.bgcolor[2]);ATON.setBackgroundColor(t)}let o=e.mainlight;o?(o.direction&&ATON.setMainLightDirection(new THREE.Vector3(o.direction[0],o.direction[1],o.direction[2])),ATON._dMainL?(o.color&&(ATON._dMainL.color=new THREE.Color(o.color[0],o.color[1],o.color[2])),o.intensity&&(ATON._dMainL.intensity=o.intensity),void 0!==o.shadows?ATON.toggleShadows(o.shadows):ATON.toggleShadows(!1)):ATON.toggleMainLight(!1)):ATON.toggleMainLight(!1);let i=e.lightprobes;if(i&&(void 0!==i.auto&&ATON.setAutoLP(i.auto),i.list))for(let e in i.list){let t=i.list[e],o=new ATON.LightProbe(t.res);t.pos&&o.setPosition(parseFloat(t.pos[0]),parseFloat(t.pos[1]),parseFloat(t.pos[2])),t.near&&o.setNear(parseFloat(t.near)),t.far&&o.setFar(parseFloat(t.far)),ATON.addLightProbe(o),console.log(o)}e.exposure&&ATON.setExposure(e.exposure)},l._jsonParsers.soundscape=e=>{void 0!==e&&e.global&&ATON.setGlobalAudio(e.global.url,e.global.loop)},l._jsonParsers.navmode=e=>{void 0!==e&&ATON.Nav.setNavMode(e)},l._jsonParsers.locomotionGraph=e=>{if(void 0!==e){for(let t in e){let o=e[t];o.pos&&ATON.Nav.addLocomotionNode(parseFloat(o.pos[0]),parseFloat(o.pos[1]),parseFloat(o.pos[2]),!0)}ATON.Nav.setFirstPersonControl(),ATON.Nav.toggleLocomotionValidator(!1)}},l._jsonParsers.measurements=e=>{if(void 0!==e)for(let t in e){let o=e[t];if(o.points&&6===o.points.length){let e=new THREE.Vector3(parseFloat(o.points[0]),parseFloat(o.points[1]),parseFloat(o.points[2])),t=new THREE.Vector3(parseFloat(o.points[3]),parseFloat(o.points[4]),parseFloat(o.points[5]));ATON.SUI.addMeasurementPoint(e),ATON.SUI.addMeasurementPoint(t)}}},l._jsonParsers.viewpoints=e=>{if(void 0!==e)for(let t in e){let o=e[t];"home"===t?ATON.Nav.setHomePOV((new ATON.POV).setPosition(o.position[0],o.position[1],o.position[2]).setTarget(o.target[0],o.target[1],o.target[2]).setFOV(o.fov)):new ATON.POV(t).setPosition(o.position[0],o.position[1],o.position[2]).setTarget(o.target[0],o.target[1],o.target[2]).setFOV(o.fov)}},l._jsonParsers.scenegraph=e=>{if(void 0===e)return;let t=e.nodes,o=e.edges;for(let e in t){let o=t[e],i=ATON.getOrCreateSceneNode(e).removeChildren();l._applyJSONTransformToNode(o.transform,i);let r=o.urls;if(r&&(Array.isArray(r)?r.forEach((e=>{i.load(e)})):i.load(r)),o["cesium.ion"]){let e=o["cesium.ion"];ATON.MRes.loadCesiumIONAsset(e,i)}if(o.stream){let t,r=o.stream;if(r.src.startsWith("#")){let e=parseInt(r.src.substring(1));t=ATON.MediaFlow.getOrCreateVideoStream(e,void 0,!0)}else{let o=ATON.Utils.resolveCollectionURL(r.src);t=ATON.MediaFlow.getOrCreateVideoStream(e,o)}if(r.chromakey){let e=r.chromakey.color;e&&t.matStream.uniforms.keycolor.value.set(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])),r.chromakey.smoothness&&(t.matStream.uniforms.smoothness.value=parseFloat(r.chromakey.smoothness)),r.chromakey.spill&&(t.matStream.uniforms.spill.value=parseFloat(r.chromakey.spill)),r.chromakey.similarity&&(t.matStream.uniforms.similarity.value=parseFloat(r.chromakey.similarity))}if(!o.urls){let e=new THREE.PlaneGeometry(1,1),o=new THREE.Mesh(e);o.scale.x=1,o.scale.y=-1,t.el.addEventListener("loadedmetadata",(e=>{let i=t.el.videoWidth/t.el.videoHeight;o.scale.x=i,o.scale.y=-1})),ATON.Utils.modelVisitor(i,o),i.add(o),ATON._bqScene=!0,i.setPickable(!0),i.dirtyBound()}i.setMaterial(t.matStream)}o.shadowcast&&i.setShadowCast(o.shadowcast),o.shadowreceive&&i.setShadowCast(o.shadowreceive),o.toYup&&i.setYup(),o.keywords&&(i.kwords=o.keywords)}for(let e in o){let t=o[e],i=ATON.getSceneNode(e);if(void 0!==i)for(let e in t){let o=t[e],r=ATON.getSceneNode(o);void 0!==r&&r.attachTo(i)}}for(let e in t){let o=t[e],i=ATON.getSceneNode(e);if(void 0!==i&&(void 0!==o.show&&(o.show?(i.show(),console.log("show "+e)):(i.hide(),console.log("hide "+e))),o.material)){let e;"string"==typeof o.material?e=ATON.MatHub.materials[o.material]:o.material.fragmentShader||o.material.vertexShader?(o.material.vertexShader||(o.material.vertexShader=ATON.MatHub.getDefVertexShader()),e=new THREE.ShaderMaterial(o.material)):e=new THREE.MeshStandardMaterial(o.material),e&&i.setMaterial(e)}}},l._jsonParsers.semanticgraph=e=>{if(void 0===e)return;let t=e.nodes,o=e.edges;for(let e in t){let o=t[e],i=ATON.getOrCreateSemanticNode(e).removeChildren(),r=o.urls;r&&(Array.isArray(r)?r.forEach((e=>{i.load(e)})):i.load(r)),o.toYup&&i.setYup(),o.description&&i.setDescription(o.description),o.audio&&i.setAudio(o.audio),o.keywords&&(i.kwords=o.keywords);let a=o.spheres;if(Array.isArray(a))for(let t in a){let o=a[t],i=new THREE.Vector3(parseFloat(o[0]),parseFloat(o[1]),parseFloat(o[2]));ATON.SemFactory.createSphere(e,i,parseFloat(o[3]))}let n=o.convexshapes;if(Array.isArray(n))for(let t in n){let o=n[t],i=[];for(let e=0;e{if(ATON.Nav.setFirstPersonControl(),e.list){let t=e.list,o=t.length;for(let e=0;e{ATON.XPFNetwork.setHomeXPF(0),ATON.XPFNetwork.requestTransitionByIndex(0,0)}))}},addSceneParser:(e,t)=>{l._jsonParsers[e]=t},patch:(e,t,o)=>{if(l._bLoading||!l._bEdit)return;if(void 0===e)return;void 0===t&&(t=l.MODE_ADD);let i=l.currID,r={};r.data=e,r.mode=t===l.MODE_DEL?"DEL":"ADD";let a=JSON.stringify(r);e=null,r=null,$.ajax({url:ATON.PATH_RESTAPI2+"scenes/"+i,type:"PATCH",data:a,contentType:"application/json; charset=utf-8",dataType:"json",success:e=>{e&&(l.currData=e),o&&o()}})}};l.sendEdit=l.patch,l.setVisibility=(e,t)=>{l.currData.visibility=e,l.sendEdit({visibility:e},ATON.SceneHub.MODE_ADD,t)},l.currSceneHasHomeConfig=()=>void 0!==l.currData&&void 0!==l.currData.viewpoints&&void 0!==l.currData.viewpoints.home,l.setTitle=e=>{l._title=e},l.getTitle=()=>l._title,l.setDescription=e=>{l._descr=e},l.getDescription=()=>l._descr;const d=l;let c={init:()=>{c._listener=new THREE.AudioListener,c._loader=new THREE.AudioLoader,c._bGenAuPlaying=!1},playOnceGlobally:(e,t)=>{if(t&&c._bGenAuPlaying)return;e=ATON.Utils.resolveCollectionURL(e);let o=new THREE.Audio(ATON.AudioHub._listener);return c._loader.load(e,(e=>{o.setBuffer(e),o.play(),t&&(c._bGenAuPlaying=!0)})),t&&(o.onEnded=()=>{c._bGenAuPlaying=!1}),o}};const u=c;class p extends THREE.EventDispatcher{constructor(e){super(),!1===window.isSecureContext&&console.error("DeviceOrientationEvent is only available in secure contexts (https)"),this._zee=new THREE.Vector3(0,0,1),this._euler=new THREE.Euler,this._q0=new THREE.Quaternion,this._q1=new THREE.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._changeEvent={type:"change"};const t=this,o=new THREE.Quaternion;this.object=e,this.object.rotation.reorder("YXZ"),this.enabled=!0,this.deviceOrientation={},this.screenOrientation=0,this.alphaOffset=0;const i=function(e){t.deviceOrientation=e},r=function(){t.screenOrientation=window.orientation||0};this.connect=function(){r(),void 0!==window.DeviceOrientationEvent&&"function"==typeof window.DeviceOrientationEvent.requestPermission?window.DeviceOrientationEvent.requestPermission().then((function(e){"granted"==e&&(window.addEventListener("orientationchange",r),window.addEventListener("deviceorientation",i))})).catch((function(e){console.error("Unable to use DeviceOrientation API:",e)})):(window.addEventListener("orientationchange",r),window.addEventListener("deviceorientation",i)),t.enabled=!0},this.disconnect=function(){window.removeEventListener("orientationchange",r),window.removeEventListener("deviceorientation",i),t.enabled=!1},this.update=function(){if(!1===t.enabled)return;const e=t.deviceOrientation;if(e){const i=e.alpha?THREE.MathUtils.degToRad(e.alpha)+t.alphaOffset:0,r=e.beta?THREE.MathUtils.degToRad(e.beta):0,a=e.gamma?THREE.MathUtils.degToRad(e.gamma):0,n=t.screenOrientation?THREE.MathUtils.degToRad(t.screenOrientation):0;!function(e,o,i,r,a){t._euler.set(i,o,-r,"YXZ"),e.setFromEuler(t._euler),e.multiply(t._q1),e.multiply(t._q0.setFromAxisAngle(t._zee,-a))}(t.object.quaternion,i,r,a,n),8*(1-o.dot(t.object.quaternion))>1e-6&&(o.copy(t.object.quaternion),t.dispatchEvent(t._changeEvent))}},this.dispose=function(){t.disconnect()},this.connect()}}const _=p;let m={STD_FOV:50,STD_NEAR:.01,STD_FAR:800,FP_EPS:.01,STD_POV_TRANS_DURATION:2,STD_LOCNODE_SIZE:.5,MIN_LOC_VALID_DIST:1.5,MODE_ORBIT:0,MODE_FP:1,MODE_DEVORI:2,LocomotionNode:class{constructor(e){this.pos=new THREE.Vector3(0,0,0),this.id=e,this._iXPF=void 0,this._sui=void 0}setLocation(e,t,o){return e instanceof THREE.Vector3?this.pos.copy(e):this.pos.set(e,t,o),this._sui&&this._sui.position.copy(this.pos),this}getLocation(){return this.pos}realizeSUI(e){return void 0===ATON.SUI.gLocNodes||(this._sui=new THREE.Sprite(ATON.SUI.getOrCreateSpriteWalk()),this._sui.position.copy(this.pos),this._sui.scale.set(ATON.Nav.STD_LOCNODE_SIZE,ATON.Nav.STD_LOCNODE_SIZE,ATON.Nav.STD_LOCNODE_SIZE),ATON.SUI.gLocNodes.add(this._sui)),this}toggleSUI(e){return void 0===this._sui||(this._sui.visible=e),this}},init:()=>{m._mode=void 0,m.POVtransitionDuration=m.STD_POV_TRANS_DURATION,m._rotSpeedOrbit=.4,m._rotSpeedFP=-.2,m._inertia=.08,m._bControl=!0,m._bLocValidator=!0,m._bInteracting=!1,m._prevMode=void 0,m.setOrbitControl(),m._currPOV=(new ATON.POV).setPosition(0,0,0).setTarget(1,0,0).setFOV(ATON.Nav.STD_FOV),m._fromPOV=new ATON.POV,m._reqPOV=new ATON.POV,m.homePOV=void 0,m._tPOVcall=-1,m._tPOVprogress=0,m.povlist={},m._vDir=new THREE.Vector3(1,0,0),m._qOri=new THREE.Quaternion,m._lastPos=new THREE.Vector3(0,0,0),m._lastOri=new THREE.Quaternion,m._dOri=0,m._dPos=0,m._motionAmt=0,m._motionDir=new THREE.Vector3(0,1,0),m._bValidLocomotion=!1,m._locNodes=[],m._prevLN=void 0},getCurrentEyeLocation:()=>m._currPOV.pos,getCurrentDirection:()=>m._vDir,copyCurrentPOV:()=>{let e=new ATON.POV;return e.pos.copy(m._currPOV.pos),e.target.copy(m._currPOV.target),e.fov=m._currPOV.fov,e},addPOV:(e,t)=>{if(void 0!==e)return e.as(t),e},clearPOVs:()=>{for(let e in ATON.Nav.povlist)delete m.povlist[e]},isTransitioning:()=>m._tPOVcall>=0,currentQueryValidForLocomotion:()=>m._bValidLocomotion,locomotionValidator:()=>{if(void 0===ATON._queryDataScene)return void(m._bValidLocomotion=!1);let e=ATON._queryDataScene,t=(e.p,e.n);e.d<=m.MIN_LOC_VALID_DIST?m._bValidLocomotion=!1:t?t.y<=.7?m._bValidLocomotion=!1:m._bValidLocomotion=!0:m._bValidLocomotion=!1},toggleLocomotionValidator:e=>{e?m._bLocValidator=!0:(m._bLocValidator=!1,m._bValidLocomotion=!1)},addLocomotionNode:(e,t,o,i)=>{let r=(new m.LocomotionNode).setLocation(e,t,o);return i&&r.realizeSUI(),m._locNodes.push(r),ATON.fire("LocomotionNodeAdded",r),r},getLocomotionNodeByIndex:e=>m._locNodes[e],clearLocomotionNodes:()=>{m._locNodes=[],m._prevLN=void 0,ATON.SUI.gLocNodes&&ATON.SUI.gLocNodes.removeChildren()},getLocomotionNodeInSight:()=>{let e=m._locNodes.length;if(e<=0)return;if(m.isTransitioning())return;let t,o,i=m._currPOV.pos,r=m._vDir;void 0===m._dirLNode&&(m._dirLNode=new THREE.Vector3);for(let a=0;a.8){let e=i.distanceToSquared(m._posLNode);e>.3&&(void 0===o||e{if(void 0===e)return;if(m._mode===m.MODE_ORBIT)return;let o=ATON.Nav._vDir,i=(new ATON.POV).setPosition(e.pos).setTarget(e.pos.x+o.x,e.pos.y+o.y,e.pos.z+o.z).setFOV(m._currPOV.fov);e.toggleSUI(!1),void 0!==m._prevLN&&m._prevLN.toggleSUI(!0),m.requestPOV(i,t),m._prevLN=e,ATON.fire("LocomotionNodeRequested",e)},requestTransitionToLocomotionNodeInSightIfAny:e=>{let t=ATON.XPFNetwork.getNextXPFindex();if(void 0!==t)return m.requestTransitionToLocomotionNode(ATON.XPFNetwork._list[t]._lnode,e),!0;let o=ATON.Nav.getLocomotionNodeInSight();if(void 0===o)return!1;let i=m._locNodes[o];return m.requestTransitionToLocomotionNode(i,e),!0},requestDeltaRotation:(e,t,o)=>{if(ATON.XR._bPresenting)return;let i=new THREE.Vector3,r=new THREE.Vector3;i.crossVectors(m._vDir,THREE.Object3D.DEFAULT_UP),r.x=m._currPOV.target.x+i.x*e,r.y=m._currPOV.target.y+t,r.z=m._currPOV.target.z+i.z*e;let a=new ATON.POV;a.setTarget(r),a.setPosition(ATON.Nav._currPOV.pos),ATON.Nav.requestPOV(a,o)},setUserControl:e=>{void 0!==e&&e!==m._bControl&&(m._bControl=e,void 0!==m._controls&&(m._controls.enabled=e),m._cOrbit&&(m._cOrbit.enabled=e),m._cFirstPerson&&(m._cFirstPerson.enabled=e),console.log("Nav controls: "+m._bControl))},toggleUserControl:()=>{m.setUserControl(!m._bControl)},isUserControlEnabled:()=>m._bControl,isOrbit:()=>!ATON.XR._bPresenting&&m._mode===m.MODE_ORBIT,isFirstPerson:()=>!ATON.XR._bPresenting&&m._mode===m.MODE_FP,isDevOri:()=>!ATON.XR._bPresenting&&m._mode===m.MODE_DEVORI,setNavMode:e=>{void 0!==e&&(e===m.MODE_ORBIT&&m.setOrbitControl(),e===m.MODE_FP&&m.setFirstPersonControl(),e===m.MODE_DEVORI&&m.setDeviceOrientationControl())},restorePreviousNavMode:()=>{void 0===m._prevMode&&m.setOrbitControl(),m.setNavMode(m._prevMode)},_updCamera:e=>{if(void 0===e&&(e=m._camera),ATON.FX.composer){let t=ATON.FX.composer.passes;if(t)for(let o=0;o{if(!ATON.XR.isPresenting()){if(m._prevMode=m._mode,m._mode=m.MODE_ORBIT,m._bInteracting=!1,ATON.fire("NavInteraction",!1),void 0===m._cOrbit){m._camOrbit=new THREE.PerspectiveCamera(m.STD_FOV,window.innerWidth/window.innerHeight,m.STD_NEAR,m.STD_FAR),m._camOrbit.layers.enableAll(),m._cOrbit=new THREE.OrbitControls(m._camOrbit,ATON._renderer.domElement);let e=m._cOrbit;e.rotateSpeed=m._rotSpeedOrbit,e.enablePan=!0,m._inertia>0&&(e.enableDamping=!0,e.dampingFactor=m._inertia),e.screenSpacePanning=!0,e.enableZoom=!0,e.minDistance=.03,e.maxDistance=300,m._bControl||(e.enabled=!1),e.addEventListener("start",(()=>{m._bInteracting=!0,ATON.fire("NavInteraction",!0)})),e.addEventListener("end",(()=>{m._bInteracting=!1,ATON.fire("NavInteraction",!1)}))}m._controls=m._cOrbit,m._camera=m._camOrbit,ATON.AudioHub._listener&&m._camera.children.length<1&&m._camera.add(ATON.AudioHub._listener),m._updCamera(),m._controls.update(),m._currPOV&&m.syncCurrCamera(),ATON._onResize(),ATON.toggleCenteredQuery(!1),ATON.fire("NavMode",m._mode)}},setFirstPersonControl:()=>{if(!ATON.XR.isPresenting()){if(m._prevMode=m._mode,ATON.SUI.getSelectorRadius()>.1&&ATON.SUI.setSelectorRadius(.1),m._mode=m.MODE_FP,m._bInteracting=!1,ATON.fire("NavInteraction",!1),void 0===m._cFirstPerson){m._camFP=new THREE.PerspectiveCamera(m.STD_FOV,window.innerWidth/window.innerHeight,m.STD_NEAR,m.STD_FAR),m._camFP.layers.enableAll(),m._cFirstPerson=new THREE.OrbitControls(m._camFP,ATON._renderer.domElement);let e=m._cFirstPerson;e.enableZoom=!1,e.enablePan=!1,e.rotateSpeed=m._rotSpeedFP,m._inertia>0&&(e.enableDamping=!0,e.dampingFactor=m._inertia),e.target.copy(m._camera.position),e.minDistance=.01,e.maxDistance=.01,m._bControl||(e.enabled=!1)}m._controls=m._cFirstPerson,m._camera=m._camFP,ATON.AudioHub._listener&&m._camera.children.length<1&&m._camera.add(ATON.AudioHub._listener),m._updCamera(),m._controls.update(),m._currPOV&&m.syncCurrCamera(),ATON._onResize(),ATON.toggleCenteredQuery(!1),ATON.fire("NavMode",m._mode)}},setDeviceOrientationControl:()=>{ATON.Utils.isMobile()&&(m._prevMode=m._mode,m._mode=m.MODE_DEVORI,m._bInteracting=!1,ATON.fire("NavInteraction",!1),ATON._screenPointerCoords.set(0,0),void 0===m._cDevOri&&(m._camDevOri=new THREE.PerspectiveCamera(m.STD_FOV,window.innerWidth/window.innerHeight,m.STD_NEAR,m.STD_FAR),m._camDevOri.layers.enableAll(),m._cDevOri=new _(m._camDevOri,ATON._renderer.domElement),m._cDevOri.alphaOffset=0),m._controls=m._cDevOri,m._camera=m._camDevOri,ATON.AudioHub._listener&&m._camera.children.length<1&&m._camera.add(ATON.AudioHub._listener),m._updCamera(),m._controls.update(),m._currPOV&&m.syncCurrCamera(),ATON._onResize(),ATON.toggleCenteredQuery(!0),ATON.fire("NavMode",m._mode))},useAbsoluteOrientation:e=>{m._cDevOri},setMotionAmount:e=>{m._motionAmt=e},setMotionDirection:e=>{m._motionDir.copy(e)},stop:()=>{m._motionAmt=0},setFOV:e=>{if(ATON.XR.isPresenting())return;m._currPOV.fov=e;let t=m._camera;t.fov=e,t.updateProjectionMatrix()},getFOV:()=>m._currPOV.fov,_deltaMotions:()=>{m._dOri=m._lastOri.angleTo(ATON.Nav._qOri),m._dPos=m._lastPos.distanceToSquared(m._currPOV.pos),m._lastPos.copy(m._currPOV.pos),m._lastOri.copy(ATON.Nav._qOri)},syncCurrPOV:()=>{if(ATON.XR.isPresenting()){const e=ATON._renderer.xr.getCamera().cameras[0];return m._currPOV.pos.copy(e.position),m._qOri.copy(e.quaternion),e.getWorldDirection(m._vDir),m._currPOV.pos.x+=ATON.XR.rig.position.x,m._currPOV.pos.y+=ATON.XR.rig.position.y,m._currPOV.pos.z+=ATON.XR.rig.position.z,void m._deltaMotions()}const e=m._controls,t=m._camera;if(t.getWorldDirection(m._vDir),t.getWorldQuaternion(m._qOri),m._deltaMotions(),m._mode!==m.MODE_DEVORI){if(m._mode===m.MODE_FP)return m._currPOV.pos.copy(e.target),m._currPOV.target.x=m._currPOV.pos.x+m._vDir.x,m._currPOV.target.y=m._currPOV.pos.y+m._vDir.y,void(m._currPOV.target.z=m._currPOV.pos.z+m._vDir.z);m._currPOV.pos.copy(t.position),m._currPOV.target.copy(e.target)}else m._currPOV.pos.copy(t.position)},applyPOVconstraints:e=>{},handlePOV:()=>{ATON.XR.isPresenting()?m.handleXRtransition():m.handlePOVtransition(),m.handleMotion(),m.applyPOVconstraints(m._currPOV)},handleMotion:()=>{if(m.isTransitioning())return;if(0==m._motionAmt)return;ATON.XR.controller0&&ATON.XR.controller0.visible?(ATON.XR.controller0.getWorldDirection(m._motionDir),m._motionDir.negate()):m._motionDir.copy(m._vDir);let e=m._motionAmt*ATON._dt,t=m._motionDir.x*e,o=m._motionDir.y*e,i=m._motionDir.z*e;m._currPOV.pos.x+=t,m._currPOV.pos.y+=o,m._currPOV.pos.z+=i,m._currPOV.target.x+=t,m._currPOV.target.y+=o,m._currPOV.target.z+=i},handlePOVtransition:()=>{if(!(m._tPOVcall<0)){if(m.POVtransitionDuration<=0?m._tPOVprogress=1:m._tPOVprogress=(ATON._clock.elapsedTime-m._tPOVcall)/m.POVtransitionDuration,m._tPOVprogress>=1)return m._tPOVcall=-1,m._currPOV.pos.copy(m._reqPOV.pos),m._currPOV.target.copy(m._reqPOV.target),m._currPOV.fov=m._reqPOV.fov,void ATON.fire("POVTransitionCompleted",m._reqPOV.id);var e;m._tPOVprogress=(e=m._tPOVprogress,(1-Math.cos(e*Math.PI))/2),m._currPOV.pos.lerpVectors(m._fromPOV.pos,m._reqPOV.pos,m._tPOVprogress),m._currPOV.target.lerpVectors(m._fromPOV.target,m._reqPOV.target,m._tPOVprogress),m._fromPOV.fov&&m._reqPOV.fov&&(m._currPOV.fov=THREE.MathUtils.lerp(m._fromPOV.fov,m._reqPOV.fov,m._tPOVprogress),m._camera.fov=m._currPOV.fov,m._camera.updateProjectionMatrix())}},handleXRtransition:()=>{if(!(m._tPOVcall<0)){if(m.POVtransitionDuration<=0?m._tPOVprogress=1:m._tPOVprogress=(ATON._clock.elapsedTime-m._tPOVcall)/m.POVtransitionDuration,m._tPOVprogress>=1)return m._tPOVcall=-1,ATON.XR._currPos.copy(ATON.XR._reqPos),void ATON.fire("POVTransitionCompleted",m._reqPOV.id);ATON.XR._currPos.lerpVectors(ATON.XR._fromPos,ATON.XR._reqPos,m._tPOVprogress)}},syncCurrCamera:()=>{if(ATON.XR.isPresenting())return;let e=m._controls,t=m._camera,o=m._currPOV.pos,i=m._currPOV.target;m._mode!==m.MODE_DEVORI?(m._vDir.subVectors(i,o),m._vDir.normalize(),m._mode===m.MODE_FP?(e.target.copy(o),t.position.x=e.target.x-m._vDir.x*m.FP_EPS,t.position.y=e.target.y-m._vDir.y*m.FP_EPS,t.position.z=e.target.z-m._vDir.z*m.FP_EPS):(t.position.copy(o),e.target.copy(i))):t.position.copy(o)},update:()=>{m.syncCurrPOV(),m.handlePOV(),m.syncCurrCamera()},requestPOV:(e,t,o)=>{ATON._tPOVcall>=0||void 0!==e&&(ATON.XR._bPresenting&&"immersive-ar"===ATON.XR._sessionType||(m.POVtransitionDuration=void 0!==t?t:m.STD_POV_TRANS_DURATION,ATON.XR.isPresenting()?(m._reqPOV.pos.copy(e.pos?e.pos:m._currPOV.pos),m._fromPOV.pos.copy(m._currPOV.pos),ATON.XR._reqPos.copy(e.pos?e.pos:m._currPOV.pos),ATON.XR._fromPos.copy(ATON.XR._currPos)):(m._reqPOV.pos.copy(e.pos?e.pos:m._currPOV.pos),m._reqPOV.target.copy(e.target?e.target:m._currPOV.target),m._reqPOV.fov=e.fov?e.fov:m._currPOV.fov,m._fromPOV.pos.copy(m._currPOV.pos),m._fromPOV.target.copy(m._currPOV.target),m._fromPOV.fov=m._currPOV.fov),o&&(e.pos&&(m._reqPOV.pos.x*=ATON._worldScale,m._reqPOV.pos.y*=ATON._worldScale,m._reqPOV.pos.z*=ATON._worldScale,ATON.XR.isPresenting()&&(ATON.XR._reqPos.x*=ATON._worldScale,ATON.XR._reqPos.y*=ATON._worldScale,ATON.XR._reqPos.z*=ATON._worldScale)),e.target&&(m._reqPOV.target.x*=ATON._worldScale,m._reqPOV.target.y*=ATON._worldScale,m._reqPOV.target.z*=ATON._worldScale)),m._tPOVcall=ATON._clock.elapsedTime,ATON.fire("POVTransitionRequested",e.id)))},requestPOVbyBound:(e,t)=>{if(void 0===e)return;let o=new THREE.Vector3,i=3*e.radius;o.x=e.center.x-i*m._vDir.x,o.y=e.center.y-i*m._vDir.y,o.z=e.center.z-i*m._vDir.z;let r=(new ATON.POV).setPosition(o).setTarget(e.center);m.requestPOV(r,t)},requestPOVbyNode:(e,t)=>{if(void 0===e)return;let o=e.getBound();m.requestPOVbyBound(o,t)},requestPOVbyID:(e,t)=>{if(void 0===e)return;let o=m.povlist[e];void 0!==o&&m.requestPOV(o,t)},requestRetarget:(e,t,o)=>{let i=new THREE.Vector3;if(void 0===t)i.lerpVectors(e,m._currPOV.pos,.8);else{let o=e.distanceTo(m._currPOV.pos);o*=.5,i.x=e.x+t.x*o,i.y=e.y+t.y*o,i.z=e.z+t.z*o}let r=e.distanceTo(i);ATON.FX.setDOFfocus(r);let a=(new ATON.POV).setPosition(i).setTarget(e).setFOV(m._currPOV.fov);m.requestPOV(a,o),console.log(a)},computeDefaultHome:(e,t)=>{void 0===e&&(e=new THREE.Vector3(1,.7,1)),void 0===t&&(t=ATON.getRootScene().getBound());let o=new THREE.Vector3(t.center.x+t.radius*e.x*1.5,t.center.y+t.radius*e.y*1.5,t.center.z+t.radius*e.z*1.5);m.homePOV=(new ATON.POV).setPosition(o).setTarget(t.center)},setHomePOV:e=>{m.homePOV=e},computeAndRequestDefaultHome:(e,t,o)=>{m.computeDefaultHome(t,o),m.requestPOV(m.homePOV,e)},requestHomePOV:e=>{m.requestPOV(m.homePOV,e)}};m.requestHome=m.requestHomePOV,m.setAndRequestHomePOV=(e,t)=>{m.setHomePOV(e),m.requestPOV(e,t)},m.clear=()=>{m.clearPOVs(),m.clearLocomotionNodes()},m.DeviceOrientationControls=function(e){let t=this;this.object=e,this.object.rotation.reorder("YXZ"),this.enabled=!0,this.deviceOrientation={},this.screenOrientation=0,this.alphaOffset=0,this.absolute=!1,this.alphaOffsetDevice=void 0,this.alphaOffsetScreen=void 0;let o=function(e){t.absolute||(t.deviceOrientation=e)},i=function(e){t.deviceOrientation=e,t.absolute=!0},r=function(){t.screenOrientation=window.orientation||0},a=function(){let e=new THREE.Vector3(0,0,1),t=new THREE.Euler,o=new THREE.Quaternion,i=new THREE.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5));return function(r,a,n,s,l){t.set(n,a,-s,"YXZ"),r.setFromEuler(t),r.multiply(i),r.multiply(o.setFromAxisAngle(e,-l))}}();this.connect=function(){r(),window.addEventListener("orientationchange",r,!1),window.addEventListener("deviceorientation",o,!1),window.addEventListener("deviceorientationabsolute",i,!1),t.enabled=!0},this.disconnect=function(){window.removeEventListener("orientationchange",r,!1),window.removeEventListener("deviceorientation",o,!1),window.removeEventListener("deviceorientationabsolute",i,!1),t.enabled=!1},this.update=function(){if(!1===t.enabled)return;let e;if(e=t.deviceOrientation,e){let o=this.getDirection()?THREE.Math.degToRad(this.getDirection())+t.alphaOffset:0,i=e.beta?THREE.Math.degToRad(e.beta):0,r=e.gamma?THREE.Math.degToRad(e.gamma):0,n=t.screenOrientation?THREE.Math.degToRad(t.screenOrientation):0;a(t.object.quaternion,o,i,r,n)}},this.dispose=()=>{t.disconnect()},this.iOSOrientationPermission=()=>{"function"==typeof DeviceOrientationEvent.requestPermission&&DeviceOrientationEvent.requestPermission().then((e=>{console.log(e)})).catch(console.error)},this.getDirection=()=>void 0!==t.deviceOrientation.webkitCompassHeading?t.deviceOrientation.webkitCompassHeading:t.deviceOrientation.alpha,this.getDirectionMap=()=>void 0!==t.deviceOrientation.webkitCompassHeading?360-t.deviceOrientation.webkitCompassHeading:t.deviceOrientation.alpha,this.connect()};const h=m;let T={STD_TELEP_DURATION:.03,HAND_R:0,HAND_L:1,MOBILE_DENSITY_F:.5,MAX_QUERY_DISTANCE:40,init:()=>{ATON._renderer.xr.enabled=!0,ATON._renderer.xr.setReferenceSpaceType("local"),ATON.device.isMobile?ATON._renderer.xr.setFramebufferScaleFactor(ATON._stdpxd*T.MOBILE_DENSITY_F):ATON._renderer.xr.setFramebufferScaleFactor(ATON._stdpxd),T._bPresenting=!1,T.currSession=null,T._sessionType="immersive-vr",T._bReqPresenting=!1,T.rig=new THREE.Group,T.rig.add(ATON.Nav._camera),ATON._rootUI.add(T.rig),T._cam=void 0,T._currPos=T.rig.position,T._fromPos=new THREE.Vector3,T._reqPos=new THREE.Vector3,T.gControllers=void 0,T.controller0=void 0,T.controller1=void 0,T.controller0pos=new THREE.Vector3,T.controller1pos=new THREE.Vector3,T.controller0dir=new THREE.Vector3,T.controller1dir=new THREE.Vector3,T._lastPosR=void 0,T._lastPosL=void 0,T._pointerLineGeom=void 0,T._pointerLineMesh=void 0,T.gpad0=void 0,T.gpad1=void 0,T._urlHand=ATON.PATH_RES+"models/hand/hand.glb",ATON.on("XRselectStart",(e=>{e===T.HAND_R&&ATON._stdActivation()})),ATON.on("XRselectEnd",(e=>{})),ATON.on("XRsqueezeStart",(e=>{e===T.HAND_R&&ATON.Photon.setFocusStreaming(!0)})),ATON.on("XRsqueezeEnd",(e=>{e===T.HAND_R&&ATON.Photon.setFocusStreaming(!1)})),ATON.on("VRC_IDassigned",(e=>{let t=ATON.getUINode("Rhand"),o=ATON.getUINode("Lhand"),i=ATON.MatHub.materials.avatars,r=i[e%i.length];o&&o.setMaterial(r),t&&t.setMaterial(r)}))},setSessionType:e=>{void 0!==e&&("immersive-vr"!==e&&"immersive-ar"!==e||(T._sessionType=e,console.log("Session type: "+e)))},isPresenting:()=>T._bPresenting,teleportOnQueriedPoint:()=>{if(!ATON.Nav.currentQueryValidForLocomotion())return!1;const e=ATON._queryDataScene.p;return ATON.Nav.requestPOV((new ATON.POV).setPosition(e.x,e.y+ATON.userHeight,e.z),T.STD_TELEP_DURATION),!0},setupQueryRay:e=>{void 0!==e&&(T.controller0?e.set(T.controller0pos,T.controller0dir):e.set(ATON.Nav.getCurrentEyeLocation(),ATON.Nav.getCurrentDirection()))},setRefSpaceLocation:e=>{T.rig.position.copy(e)},_setupControllerR:(e,t)=>{T.controller0||(T.controller0=e,console.log("R controller"),e.addEventListener("selectstart",(()=>{ATON.fire("XRselectStart",T.HAND_R)})),e.addEventListener("selectend",(()=>{ATON.fire("XRselectEnd",T.HAND_R)})),e.addEventListener("squeezestart",(()=>{ATON.fire("XRsqueezeStart",T.HAND_R)})),e.addEventListener("squeezeend",(()=>{ATON.fire("XRsqueezeEnd",T.HAND_R)})),T.setupControllerUI(T.HAND_R,t),ATON.fire("XRcontrollerConnected",T.HAND_R))},_setupControllerL:(e,t)=>{T.controller1||(T.controller1=e,console.log("L controller"),e.addEventListener("selectstart",(()=>{ATON.fire("XRselectStart",T.HAND_L)})),e.addEventListener("selectend",(()=>{ATON.fire("XRselectEnd",T.HAND_L)})),e.addEventListener("squeezestart",(()=>{ATON.fire("XRsqueezeStart",T.HAND_L)})),e.addEventListener("squeezeend",(()=>{ATON.fire("XRsqueezeEnd",T.HAND_L)})),T.setupControllerUI(T.HAND_L,t),ATON.fire("XRcontrollerConnected",T.HAND_L))},setupSceneForAR:()=>{if("immersive-ar"!==T._sessionType)return;ATON.recomputeSceneBounds();let e=ATON.bounds.center;ATON._rootVisible.position.x=-e.x,ATON._rootVisible.position.y=-e.y,ATON._rootVisible.position.z=-e.z,ATON._rootSem.position.x=-e.x,ATON._rootSem.position.y=-e.y,ATON._rootSem.position.z=-e.z,ATON.recomputeSceneBounds()},resetSceneOffsets:()=>{ATON._rootVisible.position.set(0,0,0),ATON._rootSem.position.set(0,0,0),ATON.recomputeSceneBounds()},onSessionStarted:e=>{T.currSession||(T._bReqPresenting=!1,e.addEventListener("end",T.onSessionEnded),e.isImmersive=!0,console.log(T._sessionType+" session started."),ATON.MediaFlow.stopAllStreams(),"immersive-ar"===T._sessionType&&ATON._renderer.xr.setReferenceSpaceType("local"),ATON._renderer.xr.setSession(e).then((()=>{if(T.currSession=e,console.log(T.currSession),"immersive-ar"===T._sessionType)ATON._mainRoot.background=null,ATON._mMainPano&&(ATON._mMainPano.visible=!1),ATON._renderer.xr.getController(0)&&ATON.device.isMobile&&(T.controller0=ATON._renderer.xr.getController(0),T.controller0.addEventListener("selectstart",(()=>{ATON.fire("XRselectStart",T.HAND_R),console.log("Head-aligned select")})),T.controller0.addEventListener("selectend",(()=>{ATON.fire("XRselectEnd",T.HAND_R)})),T.gControllers.add(T.controller0));else{for(let e=0;e<2;e++){const t=ATON._renderer.xr.getController(e);void 0===t||t.userData.bXRconfig||(t.visible=!1,t.userData.bXRconfig=!0,t.addEventListener("connected",(e=>{let o=e.data.handedness;t.gm=e.data.gamepad,console.log("Hand "+o),console.log("GamePad "+t.gm),"left"===o?T._setupControllerL(t,!0):"right"===o?T._setupControllerR(t,!0):(t.addEventListener("selectstart",(()=>{ATON.fire("XRselectStart",T.HAND_R),console.log("Head-aligned select")})),t.addEventListener("selectend",(()=>{ATON.fire("XRselectEnd",T.HAND_R)})),ATON.fire("XRcontrollerConnected",T.HAND_R))})))}T.rig.add(ATON.Nav._camera),T.setRefSpaceLocation(ATON.Nav._currPOV.pos)}let t=ATON._renderer.xr.getCamera(ATON.Nav._camera);ATON.Nav._updCamera(t),T._bPresenting=!0,ATON.Nav._bInteracting=!1,console.log("XR now presenting"),ATON.fire("XRmode",!0),ATON.rewindAllPlayingMedia(),ATON.toggleShadows(!1),ATON.SUI.getSelectorRadius()>ATON.FE.STD_SEL_RAD&&ATON.SUI.setSelectorRadius(ATON.FE.STD_SEL_RAD),ATON._qSyncInt=2,ATON.XPFNetwork.getNumXPFs()>0?ATON.setQueryRange(0,100):ATON.setQueryRange(0,T.MAX_QUERY_DISTANCE),ATON.MRes.estimateTSErrorTarget(),setTimeout((()=>{ATON.SUI.getSelectorRadius()>ATON.FE.STD_SEL_RAD&&ATON.SUI.setSelectorRadius(ATON.FE.STD_SEL_RAD)}),2e3)})))},onSessionEnded:()=>{T.currSession.removeEventListener("end",T.onSessionEnded),T.currSession=null,T._bReqPresenting=!1,T._bPresenting=!1,ATON.Nav._bInteracting=!1,"immersive-ar"===T._sessionType&&ATON._mMainPano&&(ATON._mMainPano.visible=!0),T.setRefSpaceLocation(new THREE.Vector3(0,0,0)),ATON.fire("XRmode",!1),ATON._qSyncInt=1,ATON.MediaFlow.stopAllStreams(),ATON.Nav.requestHome(),ATON.Nav._updCamera(),ATON.setQueryRange(0,1/0),ATON.MRes.estimateTSErrorTarget(),console.log("Quit XR")},toggle:e=>{if(T.setSessionType(e),ATON.device.xrSupported[T._sessionType])if(null===T.currSession){let e={optionalFeatures:["high-refresh-rate"]};"immersive-ar"===T._sessionType&&(void 0===e.optionalFeatures&&(e.optionalFeatures=[]),e.optionalFeatures.push("light-estimation")),T._bReqPresenting=!0,navigator.xr.requestSession(T._sessionType,e).then(T.onSessionStarted)}else T.currSession.end()},setupControllerUI:(e,t)=>{let o,i;if(void 0===T.gControllers&&(T.gControllers=ATON.createUINode(),T.gControllers.disablePicking(),T.rig.add(T.gControllers)),e===T.HAND_L?(T.gControllers.add(T.controller1),t&&(i=ATON.createUINode("Lhand").load(T._urlHand).setMaterial(ATON.MatHub.materials.controllerRay).setScale(-1,1,1),T.controller1.add(i))):(T.gControllers.add(T.controller0),t&&(T._pointerLineGeom=new THREE.CylinderGeometry(.003,.003,1,4),T._pointerLineGeom.rotateX(-Math.PI/2),T._pointerLineGeom.translate(0,0,-.5),T._pointerLineMesh=new THREE.Mesh(T._pointerLineGeom,ATON.MatHub.materials.controllerRay),T.controller0.add(T._pointerLineMesh),T._pointerLineMesh.visible=!1,o=ATON.createUINode("Rhand").load(T._urlHand).setMaterial(ATON.MatHub.materials.controllerRay),T.controller0.add(o))),void 0!==ATON.Photon.uid&&t){let t=ATON.MatHub.materials.avatars,r=t[ATON.Photon.uid%t.length];e===T.HAND_L?i.setMaterial(r):o.setMaterial(r)}},switchHands:()=>{let e=T.controller1;T.controller1=T.controller0,T.controller0=e;for(let e in T.controller0.children)T.controller0.remove(T.controller0.children[e]);for(let e in T.controller1.children)T.controller1.remove(T.controller1.children[e]);T.gControllers.removeChildren(),T.setupControllerUI(T.HAND_L),T.setupControllerUI(T.HAND_R),console.log("VR controllers switched")},getControllerSpace:e=>{1===e?T.getControllerGrip(1):T.getControllerGrip(0)},getControllerWorldLocation:e=>1===e?T.controller1pos:T.controller0pos,getControllerWorldDirection:e=>1===e?T.controller1dir:T.controller0dir,getControllerWorldOrientation:e=>{let t=new THREE.Quaternion;return 1===e?T.controller1.getWorldQuaternion(t):T.controller0.getWorldQuaternion(t),t},_deltaMotionController:e=>{if(e===T.HAND_L&&void 0===T._lastPosL)return;if(e===T.HAND_R&&void 0===T._lastPosR)return;let t=e===T.HAND_L?T.controller1pos:T.controller0pos,o=e===T.HAND_L?T._lastPosL:T._lastPosR;THREE.Vector3(t.x-o.x,t.y-o.y,t.z-o.z).lengthSq(),e===T.HAND_L?T._lastPosL=t:T._lastPosR=t},update:()=>{T.controller0&&T.controller0.visible&&(T.controller0.getWorldPosition(T.controller0pos),T.controller0.getWorldDirection(T.controller0dir),T.controller0dir.negate()),T.controller1&&T.controller1.visible&&(T.controller1.getWorldPosition(T.controller1pos),T.controller1.getWorldDirection(T.controller1dir),T.controller1dir.negate())},getAxisValue:e=>{let t=new THREE.Vector2(0,0),o=e===T.HAND_L?T.controller1:T.controller0;if(void 0===o)return t;if(void 0===o.gm||void 0===o.gm.axes)return t;let i=o.gm.axes[0],r=o.gm.axes[2],a=o.gm.axes[1],n=o.gm.axes[3];return t.x=i>0?-i:r,t.y=a>0?a:-n,t}};const v=T,g=class extends t{constructor(e,t,o){super(e,ATON.NTYPES.UI),this.baseColor=ATON.MatHub.colors.black,this.baseOpacity=.5,this.container=new ThreeMeshUI.Block({width:t||.2,height:o||.05,padding:.001,borderRadius:.01,backgroundColor:this.baseColor,backgroundOpacity:this.baseOpacity,fontFamily:ATON.SUI.PATH_FONT_JSON,fontTexture:ATON.SUI.PATH_FONT_TEX,justifyContent:"center",textAlign:"center"}),this.container.position.z=.03,this.add(this.container),this.uiText=new ThreeMeshUI.Text({content:"Label",fontSize:.03,fontColor:ATON.MatHub.colors.white}),this.container.add(this.uiText),ThreeMeshUI.update()}setBaseColor(e){return this.baseColor=e,this.container.set({backgroundColor:this.baseColor}),ThreeMeshUI.update(),this}setTextColor(e){return this.uiText.set({fontColor:e}),ThreeMeshUI.update(),this}setBackgroundOpacity(e){return this.container.set({backgroundOpacity:e}),this.baseOpacity=e,ThreeMeshUI.update(),this}setText(e){return this.uiText.set({content:e}),ThreeMeshUI.update(),this}};let S={STD_BTN_SIZE:.1,STD_SELECTOR_TICKNESS:1.05};S.Button=class extends t{constructor(e,t=1,o=1){super(e,ATON.NTYPES.UI),this.baseColor=ATON.MatHub.colors.black,this.switchColor=ATON.MatHub.colors.green,this.baseOpacity=.5,this.hoverOpacity=.8,this._bSwitched=!1,this.container=new ThreeMeshUI.Block({width:.1*t,height:.1,padding:.01,borderRadius:.02,backgroundColor:this.baseColor,backgroundOpacity:this.baseOpacity,fontFamily:ATON.SUI.PATH_FONT_JSON,fontTexture:ATON.SUI.PATH_FONT_TEX,justifyContent:"center",textAlign:"center"}),this.add(this.container),this.uiText=new ThreeMeshUI.Text({content:"",fontSize:.02*o,fontColor:ATON.MatHub.colors.white}),this.container.add(this.uiText);let i=.9*ATON.SUI.STD_BTN_SIZE*t,r=.9*ATON.SUI.STD_BTN_SIZE;this._trigger=new THREE.Mesh(new THREE.PlaneGeometry(i,r,2),ATON.MatHub.materials.fullyTransparent),this._trigger.position.set(0,0,.002),this.add(this._trigger),this.onHover=()=>{this.container.set({backgroundOpacity:this.hoverOpacity})},this.onLeave=()=>{this.container.set({backgroundOpacity:this.baseOpacity})},this.enablePicking(),this.traverse((e=>{e.material&&(e.material.depthWrite=!1)})),ThreeMeshUI.update()}setBaseColor(e){return this.baseColor=e,this._bSwitched||this.container.set({backgroundColor:this.baseColor}),ThreeMeshUI.update(),this}setSwitchColor(e){return this.switchColor=e,this._bSwitched&&this.container.set({backgroundColor:this.switchColor}),ThreeMeshUI.update(),this}setBackgroundOpacity(e){return this.container.set({backgroundOpacity:e}),this.baseOpacity=e,ThreeMeshUI.update(),this}setText(e){return this.uiText.set({content:e}),ThreeMeshUI.update(),this}switch(e){return this._bSwitched=e,e?this.container.set({backgroundColor:this.switchColor}):this.container.set({backgroundColor:this.baseColor}),ThreeMeshUI.update(),this}setIcon(e,t){return ATON.Utils.textureLoader.load(e,(e=>{this._trigger.material=new THREE.MeshStandardMaterial({map:e,transparent:!0,depthWrite:!1}),t&&(this.setBackgroundOpacity(0),this.hoverOpacity=0),this.uiText.position.set(0,-.035,0)})),ThreeMeshUI.update(),this}},S.Label=g,S.MediaPanel=class extends t{constructor(e){super(e,ATON.NTYPES.UI),this._resurl=void 0,this._mediamesh=void 0,this._vs=void 0,this._yratio=1,this._titleYoffs=.6,this._color=ATON.MatHub.colors.black;let t=this;this.onSelect=()=>{t._vs&&t._vs.el}}load(e,t){this._yratio=1,this._mediamesh||(this._mediamesh=new THREE.Mesh(new THREE.PlaneGeometry(1,1)),this.add(this._mediamesh)),e=ATON.Utils.resolveCollectionURL(e);let o=this;return ATON.Utils.isVideo(e)?(this._vs=ATON.MediaFlow.getOrCreateVideoStream(this.nid,e,!1),this._mediamesh.material=this._vs.matStream,this._vs.el.addEventListener("loadedmetadata",(i=>{o._yratio=o._vs.el.videoHeight/o._vs.el.videoWidth,o._mediamesh.scale.y=-o._yratio,o._resurl=e,o._onContentLoad(),t&&t()}))):ATON.Utils.loadTexture(e,(i=>{i.image&&(this._yratio=i.image.height/i.image.width),o._mediamesh.scale.y=o._yratio,o._mediamesh.material=ATON.MatHub.materials.chromakey.clone(),o._mediamesh.material.uniforms.tBase.value=i,o._mediamesh.material.needsUpdate=!0,o._resurl=e,o._onContentLoad(),t&&t()})),this.setPickable(!0),this}setColor(e){return this._color=e,this._labelTitle&&this._labelTitle.setBaseColor(e),this._bd&&(this._bd.material.color=e),this}getMaterial(){return this._mediamesh.material}_onContentLoad(){this._labelTitle&&(this._labelTitle.position.y=this._yratio*this._titleYoffs),this._bd&&(this._bd.scale.y=1.05*this._yratio)}setTitle(e){return this._labelTitle||(this._labelTitle=new g(void 0,.5,.07),this._labelTitle.position.z=-.01,this._labelTitle.attachTo(this)),this._labelTitle.setText(e),this._labelTitle.setBaseColor(this._color),this}toggleTitle(e){return this._labelTitle?(this._labelTitle.toggle(e),this):this}setBackdrop(e){return this._bd=new THREE.Mesh(new THREE.PlaneGeometry(1,1)),this._bd.material=new THREE.MeshStandardMaterial({transparent:!0,side:THREE.DoubleSide,color:this._color,opacity:e||.5}),this._bd.scale.x=1.05,this._bd.scale.y=1.05*this._yratio,this._bd.position.z=-.005,this.add(this._bd),this}},S.init=()=>{S.initSelector(),S.fpTeleport=ATON.createUINode();let e=new THREE.CylinderGeometry(.4,.4,.9,32,1,!0),t=new THREE.Mesh(e,ATON.MatHub.getMaterial("teleportLoc"));t.renderOrder=100,S.fpTeleport.add(t),S.fpTeleport.disablePicking(),S.fpTeleport.visible=!1,ATON._rootUI.add(S.fpTeleport),S.PATH_FONT_JSON||(S.PATH_FONT_JSON=ATON.PATH_RES+"fonts/custom-msdf.json"),S.PATH_FONT_TEX||(S.PATH_FONT_TEX=ATON.PATH_RES+"fonts/custom.png"),S.gMeasures=ATON.createUINode(),S._prevMPoint=void 0,S._measLabels=[],ATON._rootUI.add(S.gMeasures);let o=(new THREE.BufferGeometry).setFromPoints([new THREE.Vector3,new THREE.Vector3]);S._measLine=new THREE.Line(o,ATON.MatHub.getMaterial("measurement")),S._measLine.visible=!1,ATON._rootUI.add(S._measLine),S.gPoints=ATON.createUINode(),ATON._rootUI.add(S.gPoints),S.gLocNodes=ATON.createUINode(),ATON._rootUI.add(S.gLocNodes),S.buildInfoNode(),S.bShowInfo=!0,S._labelScale=ATON.Utils.isMobile()?80:90,S._labelScaleVR=2,S.sprites={},S._sync=0},S.getOrCreateSpritePointEdit=()=>(S.sprites.pointEdit||(S.sprites.pointEdit=new THREE.SpriteMaterial({map:(new THREE.TextureLoader).load(ATON.PATH_RES+"sui-point.png"),color:ATON.MatHub.colors.orange,transparent:!0,opacity:1,depthTest:!1})),S.sprites.pointEdit),S.getOrCreateSpriteSemIcon=()=>(S.sprites.semIcon||(S.sprites.semIcon=new THREE.SpriteMaterial({map:(new THREE.TextureLoader).load(ATON.PATH_RES+"sui-sem.png"),transparent:!0,opacity:1,depthWrite:!1,depthTest:!1})),S.sprites.semIcon),S.getOrCreateSpriteLP=()=>(S.sprites.lp||(S.sprites.lp=new THREE.SpriteMaterial({map:(new THREE.TextureLoader).load(ATON.PATH_RES+"sui-lp.png"),transparent:!0,opacity:1,depthWrite:!1}),S.sprites.lp.sizeAttenuation=!1),S.sprites.lp),S.getOrCreateSpriteWalk=()=>(S.sprites.walk||(S.sprites.walk=new THREE.SpriteMaterial({map:(new THREE.TextureLoader).load(ATON.PATH_RES+"sui-walk.png"),transparent:!0,opacity:1,depthWrite:!1})),S.sprites.walk),S.initSelector=()=>{S.mainSelector=ATON.createUINode(),S._mSelectorSphere=new THREE.Mesh(ATON.Utils.geomUnitSphere,ATON.MatHub.getMaterial("selector")),S._mSelectorSphere.renderOrder=100,S.mainSelector.add(S._mSelectorSphere),S.mainSelector.disablePicking(),S.setSelectorRadius(.05),S.mainSelector.visible=!1,ATON._rootUI.add(S.mainSelector),S._selOffset=new THREE.Vector3,S._bShowSelector=!0},S.enableLPIcons=()=>{S.gLPIcons=ATON.createUINode(),S.gLPIcons.disablePicking(),ATON._rootUI.add(S.gLPIcons)},S.enableSemIcons=()=>{S.gSemIcons=ATON.createUINode(),S.gSemIcons.disablePicking(),ATON._rootUI.add(S.gSemIcons)},S.showSelector=e=>{S._bShowSelector=e},S.setSelectorRadius=e=>{S._selectorRad=e,S.mainSelector.scale.set(e,e,e)},S.setSelectorOffset=(e,t,o)=>{void 0!==e&&(S._selOffset.x=e),void 0!==t&&(S._selOffset.y=t),void 0!==o&&(S._selOffset.z=o);let i=ATON.getSceneQueriedPoint();void 0!==i&&(S.mainSelector.position.x=i.x+S._selOffset.x,S.mainSelector.position.y=i.y+S._selOffset.y,S.mainSelector.position.z=i.z+S._selOffset.z)},S.getSelectorRadius=()=>S._selectorRad,S.getSelectorLocation=()=>S.mainSelector.position,S.setSelectorModel=(e,t)=>{void 0!==e&&(S.mainSelector.removeChildren(),S.mainSelector.load(e).disablePicking(),t&&S.mainSelector.setMaterial(ATON.MatHub.getMaterial("selector")))},S.setSelectorColor=(e,t)=>{let o=ATON.MatHub.materials.selector;o.uniforms.tint.value=e,void 0!==t&&(o.uniforms.opacity.value=t)},S.addSemIcon=(e,t)=>{if(void 0===S.gSemIcons)return;let o=(new THREE.Box3).setFromObject(t),i=new THREE.Sphere;o.getBoundingSphere(i);let r=new THREE.Sprite(S.getOrCreateSpriteSemIcon());r.position.copy(i.center),r.scale.set(.8,.8,1),r.name=e,S.gSemIcons.add(r)},S.addLPIcon=e=>{if(void 0===S.gLPIcons)return;let t=e._near,o=new THREE.Sprite(S.getOrCreateSpriteLP());o.position.copy(e.pos),o.scale.set(.1,.1,.1);let i=new THREE.Mesh(ATON.Utils.geomUnitSphere,ATON.MatHub.materials.lp);i.scale.set(t,t,t),i.position.copy(e.pos),S.gLPIcons.add(o),S.gLPIcons.add(i)},S.setSemIconsOpacity=e=>{ATON.MatHub.spriteSemIcon.opacity=void 0===e?1:e},S.buildInfoNode=()=>{S.infoNode=ATON.createUINode(),S.infoNode.attachToRoot(),S.infoContainer=new ThreeMeshUI.Block({width:.2,height:.05,padding:.01,borderRadius:.02,backgroundColor:ATON.MatHub.colors.black,backgroundOpacity:.4,fontFamily:S.PATH_FONT_JSON,fontTexture:S.PATH_FONT_TEX,justifyContent:"center",textAlign:"center"}),S.infoContainer.position.y=.03,S.infoNode.add(S.infoContainer),S.infoNodeText=new ThreeMeshUI.Text({content:"Info",fontSize:.02,fontColor:ATON.MatHub.colors.white}),S.infoContainer.add(S.infoNodeText),ThreeMeshUI.update()},S.getInfoNode=()=>S.infoNode,S.setInfoNodeText=e=>{S.bShowInfo&&(S.infoNodeText.set({content:e}),ThreeMeshUI.update())},S.createToolbar=(e,t,o)=>{let i=ATON.createUINode(),r=e.length,a=.3*S.STD_BTN_SIZE,n=new ThreeMeshUI.Block({width:S.STD_BTN_SIZE*r*1.1+a,height:S.STD_BTN_SIZE+a,padding:.01,borderRadius:.02,backgroundColor:t||ATON.MatHub.colors.black,backgroundOpacity:void 0!==o?o:.3,fontFamily:S.PATH_FONT_JSON,fontTexture:S.PATH_FONT_TEX,justifyContent:"center",textAlign:"center"}),s=.5*r*S.STD_BTN_SIZE*1.1;s-=.5*S.STD_BTN_SIZE;for(let t=0;t{void 0===o&&(o=1),void 0===i&&(i=1);let r=ATON.createUINode(e),a=new THREE.Mesh(new THREE.PlaneGeometry(o,i,2),ATON.MatHub.materials.fullyTransparent);return r.add(a),void 0!==t&&ATON.Utils.textureLoader.load(t,(e=>{a.material=new THREE.MeshStandardMaterial({map:e,transparent:!0,depthWrite:!1,side:THREE.DoubleSide})})),r},S.createLayout=(e,t)=>{let o=e.children.length;for(let i=0;i{if(void 0===e)return;let t=.01,o=.001;if(void 0===S._prevMPoint){S._prevMPoint=e;let t=S._measLine.geometry.attributes.position.array;return t[0]=e.x,t[1]=e.y,void(t[2]=e.z)}S._measLine.visible=!1;let i=S._prevMPoint.distanceTo(e);t*=i,o*=i;let r=new THREE.Mesh(ATON.Utils.geomUnitCube,ATON.MatHub.getMaterial("measurement"));r.position.copy(S._prevMPoint),r.scale.set(t,t,t),S.gMeasures.add(r);let a=new THREE.Mesh(ATON.Utils.geomUnitCube,ATON.MatHub.getMaterial("measurement"));a.position.copy(e),a.scale.set(t,t,t),S.gMeasures.add(a);let n=2*i,s=(new THREE.BufferGeometry).setFromPoints([S._prevMPoint,e]);S.gMeasures.add(new THREE.Line(s,ATON.MatHub.getMaterial("measurement")));let l=new S.Label;l.setBaseColor(ATON.MatHub.colors.white).setTextColor(ATON.MatHub.colors.black),l.userData.vStart=new THREE.Vector3,l.userData.vEnd=new THREE.Vector3,l.userData.vStart.copy(S._prevMPoint),l.userData.vEnd.copy(e),l.userData.vSEdir=new THREE.Vector3,l.userData.vSEdir.x=l.userData.vStart.x-l.userData.vEnd.x,l.userData.vSEdir.y=l.userData.vStart.y-l.userData.vEnd.y,l.userData.vSEdir.z=l.userData.vStart.z-l.userData.vEnd.z,l.userData.vSEdir.normalize(),l.setPosition(.5*(S._prevMPoint.x+e.x),.5*(S._prevMPoint.y+e.y),.5*(S._prevMPoint.z+e.z)),l.setScale(n).setText(ATON.Utils.getHumanReadableDistance(i)),S.gMeasures.add(l),S._measLabels.push(l);let d={};return d.A=l.userData.vStart,d.B=l.userData.vEnd,S._prevMPoint=void 0,d},S.clearMeasurements=()=>{S.gMeasures.removeChildren(),S._measLabels=[]},S._updateMeasurements=()=>{if(!(S._measLabels.length<=0))for(let e in S._measLabels)S._measLabels[e].orientToCamera()},S.update=()=>{if(ATON.Nav.isTransitioning()||ATON._bPauseQuery)S.infoNode.visible=!1;else{if(S._prevMPoint){if(ATON._queryDataScene){let e=S._measLine.geometry.attributes.position.array;e[3]=ATON._queryDataScene.p.x,e[4]=ATON._queryDataScene.p.y,e[5]=ATON._queryDataScene.p.z,S._measLine.geometry.attributes.position.needsUpdate=!0}S._measLine.visible=!0}else S._measLine.visible=!1;if(ATON._queryDataScene&&!ATON.Nav._bInteracting?(S._bShowSelector&&(S.mainSelector.visible=!0),S.mainSelector.position.x=ATON._queryDataScene.p.x+S._selOffset.x,S.mainSelector.position.y=ATON._queryDataScene.p.y+S._selOffset.y,S.mainSelector.position.z=ATON._queryDataScene.p.z+S._selOffset.z):S.mainSelector.visible=!1,S.gSemIcons&&(ATON.Nav._bInteracting?S.gSemIcons.hide():void 0===ATON._hoveredSemNode&&S.gSemIcons.show()),ATON.Nav.isOrbit()&&!ATON.XR._bPresenting||!ATON.Nav.currentQueryValidForLocomotion()?S.fpTeleport.visible=!1:(S.fpTeleport.visible=!0,S.fpTeleport.position.copy(ATON._queryDataScene.p)),ATON.XR._pointerLineMesh){let e=0;ATON._queryDataScene&&(e=ATON._queryDataScene.d),ATON._queryDataUI&&(e<=0||ATON._queryDataUI.d0?(ATON.XR._pointerLineMesh.visible=!0,ATON.XR._pointerLineMesh.scale.set(1,1,e)):ATON.XR._pointerLineMesh.visible=!1}if(S._updateMeasurements(),ATON._queryDataSem)ATON.XR._bPresenting&&(S.bShowInfo&&(S.infoNode.visible=!0),ATON.XR.controller0?(S.infoNode.position.copy(ATON.XR.controller0pos),S.infoNode.position.x-=.1*ATON.XR.controller0dir.x,S.infoNode.position.y-=.1*ATON.XR.controller0dir.y,S.infoNode.position.z-=.1*ATON.XR.controller0dir.z,S.infoNode.setScale(1)):(S.infoNode.position.lerpVectors(ATON._queryDataSem.p,ATON.Nav._currPOV.pos,.1),S.infoNode.setScale(ATON._queryDataSem.d*S._labelScaleVR)),S.infoNode.orientToCamera()),ATON.Photon._bStreamFocus||(S.mainSelector.visible=!1);else if(ATON.XR._bPresenting&&S.bShowInfo&&ATON._queryDataScene&&void 0!==ATON.XPFNetwork._semCurr){S.infoNode.position.lerpVectors(ATON._queryDataScene.p,ATON.Nav._currPOV.pos,.5);const e=ATON._queryDataScene.d*(ATON.Nav._currPOV.fov/S._labelScale);S.infoNode.setScale(e),S.infoNode.orientToCamera(),S.infoNode.visible=!0}else S.infoNode.visible=!1;if(S.mainSelector.visible&&ATON.Photon._bStreamFocus){let e=S._selectorRad*(1+.2*Math.cos(10*ATON._clock.elapsedTime));S.mainSelector.scale.set(e,e,e);let t=ATON.getSceneFocalPoint();void 0!==t&&void 0!==ATON.plight&&(ATON.enablePointLight(),ATON.plight.position.copy(t),ATON.plight.distance=2*S._selectorRad)}}};const N=S;let O={SCENES_SORTER:(e,t)=>{let o=e.creationDate,i=t.creationDate;return o&&i?o>i?-1:i>o?1:0:0},init:()=>{window.bootstrap&&window.bootstrap.Offcanvas&&(O._parser=new DOMParser,O.PATH_RES_ICONS=ATON.PATH_RES+"icons/",O._bModal=!1,O._bSidePanel=!1,O._bSemL=!1,O._setupBase())},setTheme:e=>{document.body.setAttribute("data-bs-theme",e)},createElementFromHTMLString:e=>O._parser.parseFromString(e,"text/html").body.firstElementChild,onContextMenu:()=>!1,_setupBase:()=>{document.body.oncontextmenu=O.onContextMenu,O.setTheme("dark"),O.elCenteredOverlay=O.createElementFromHTMLString('\n
    \n
    Loading...
    \n
    \n\t'),document.body.append(O.elCenteredOverlay),O.hideCenteredOverlay(),O.elLabelCon=document.createElement("div"),O.elLabelCon.classList.add("aton-floating-label-container"),O.elLabel=document.createElement("div"),O.elLabel.classList.add("aton-floating-label"),O.elLabelCon.append(O.elLabel),document.body.prepend(O.elLabelCon),O.hideSemLabel(),O.elModal=O.createElementFromHTMLString('\n \n\t'),O.modal=new bootstrap.Modal(O.elModal),document.body.append(O.elModal),O.elModalContent=document.getElementById("uiModalContent"),O.elSidePanel=O.createElementFromHTMLString('\n
    \n\t'),O.sidepanel=new bootstrap.Offcanvas(O.elSidePanel),document.body.append(O.elSidePanel)},showCenteredOverlay:e=>{O.elCenteredOverlay.classList.add("d-flex"),O.elCenteredOverlay.classList.remove("d-none")},hideCenteredOverlay:()=>{O.elCenteredOverlay.classList.remove("d-flex"),O.elCenteredOverlay.classList.add("d-none")},showModal:e=>{if(e){if(O.elModalContent.innerHTML="",e.header){let t=document.createElement("div");t.classList.add("modal-header"),t.innerHTML="",O.elModalContent.append(t)}if(e.body){let t=document.createElement("div");t.classList.add("modal-body"),t.append(e.body),O.elModalContent.append(t)}if(e.footer){let t=document.createElement("div");t.classList.add("modal-footer"),t.append(e.footer),O.elModalContent.append(t)}O.modal.show(),O._bModal=!0}},hideModal:()=>{O.modal.hide(),O._bModal=!1},showSidePanel:e=>{if(e){if(O.elSidePanel.innerHTML="",e.header){let t=document.createElement("div");t.classList.add("offcanvas-header"),t.innerHTML="

    "+e.header+"

    ",O.elSidePanel.append(t)}if(e.body){let t=document.createElement("div");t.classList.add("offcanvas-body"),t.append(e.body),O.elSidePanel.append(t)}O.sidepanel.show(),O._bSidePanel=!0}},hideSidePanel:()=>{O.sidepanel.hide(),O._bSidePanel=!1},addBasicEvents:()=>{let e=document.querySelector("canvas");ATON.on("NodeRequestFired",(()=>{O.showCenteredOverlay()})),ATON.on("AllNodeRequestsCompleted",(()=>{O.hideCenteredOverlay()})),ATON.on("SemanticNodeHover",(t=>{let o=ATON.getSemanticNode(t);void 0!==o&&(O.showSemLabel(t),o.highlight(),e.style.cursor="pointer",ATON.SUI.gSemIcons&&ATON.SUI.gSemIcons.hide())})),ATON.on("SemanticNodeLeave",(t=>{let o=ATON.getSemanticNode(t);void 0!==o&&(O.hideSemLabel(),o.restoreDefaultMaterial(),e.style.cursor="grab",ATON.SUI.gSemIcons&&ATON.SUI.gSemIcons.show())})),ATON.on("SemanticMaskHover",(t=>{O.showSemLabel(t),e.style.cursor="pointer"})),ATON.on("SemanticMaskLeave",(t=>{O.hideSemLabel(),e.style.cursor="grab"})),ATON.addUpdateRoutine(O.update)},update:()=>{if(O._bSemL&&!ATON.XR._bPresenting){let e=.5*ATON._screenPointerCoords.x*window.innerWidth,t=.5*(1-ATON._screenPointerCoords.y)*window.innerHeight;t-=35,O.elLabel.style.transform="translate("+e+"px, "+t+"px)"}},showSemLabel:e=>{O.elLabel.innerHTML=e,O.elLabel.style.display="inline-block",O._bSemL=!0},hideSemLabel:()=>{O.elLabel.style.display="none",O._bSemL=!1},loadPartial:(e,t,o,i)=>{fetch(e).then((e=>e.text())).then((e=>{let i=O._parser.parseFromString(e,"text/html").body.childNodes;t?o?document.querySelector(`#${t}`).prepend(...i):document.querySelector(`#${t}`).append(...i):o?document.body.prepend(...i):document.body.append(...i)})).catch((e=>`Error fetching partial: ${e}`)),i&&i()},resolveIconURL:e=>e.includes("/")?e:O.PATH_RES_ICONS+e+".png",prependIcon:(e,t)=>{t.startsWith("bi-")?e.prepend(O.createElementFromHTMLString("")):e.prepend(O.createElementFromHTMLString(""))},createButton:e=>{let t=document.createElement("button");return t.classList.add("btn","aton-btn"),t.setAttribute("type","button"),e.variant&&t.classList.add("btn-"+e.variant),e.text&&(t.innerText=e.text),e.icon&&O.prependIcon(t,e.icon),e.badge&&t.append(O.createElementFromHTMLString(""+e.badge+"")),e.onpress&&(t.onclick=e.onpress),t},createDropdown:e=>{let t=document.createElement("div");t.classList.add("btn-group");let o=O.createElementFromHTMLString(`\n \n `);if(e.icon&&O.prependIcon(o,e.icon),t.append(o),e.items){let o=document.createElement("ul");o.classList.add("dropdown-menu","dropdown-menu-sm-end","aton-dropdown-menu");for(let t=0;t${r.title}\n `);let a=document.createElement("li");a.append(i),o.append(a),r.icon&&O.prependIcon(i,r.icon)}t.append(o)}return t},createTabsGroup:e=>{let t=ATON.Utils.generateID("tabgroup"),o=document.createElement("div"),i=document.createElement("ul");i.classList.add("nav","nav-justified","nav-tabs"),i.setAttribute("role","tablist");let r=document.createElement("div");r.classList.add("tab-content"),o.append(i),o.append(r);for(let o=0;o");let c=t+"-"+n;c=c.replaceAll(" ","");let u,p=document.createElement("li");p.classList.add("nav-item"),p.setAttribute("role","presentation"),p.innerHTML=0===o?"":"",i.append(p),u=0===o?O.createElementFromHTMLString("
    "):O.createElementFromHTMLString("
    "),u.style.padding="10px 0px 10px 0px",s&&u.append(s),r.append(u)}return o},createTreeGroup:e=>{let t=ATON.Utils.generateID("tree"),o=document.createElement("div");o.classList.add("aton-tree-container");for(let i=0;i"+a+"")),n){let e=document.createElement("div");e.classList.add("aton-tree-item-content"),e.append(r.content),s.append(e)}o.append(s)}return o},createVectorControl:e=>{let t,o=ATON.Utils.generateID("vec3");e.vector&&(t=e.vector);let i=.01;e.step&&(i=e.step);let r=t?t.x:0,a=t?t.y:0,n=t?t.z:0,s=O.createElementFromHTMLString(`\n
    \n \n \n \n
    \n `);s.id=o;let l=s.children[0],d=s.children[1],c=s.children[2];return l.oninput=()=>{let o=l.value;t&&(t.x=o),e.onupdate&&e.onupdate()},d.oninput=()=>{let o=d.value;t&&(t.y=o),e.onupdate&&e.onupdate()},c.oninput=()=>{let o=c.value;t&&(t.z=o),e.onupdate&&e.onupdate()},s},createQuaternionControl:e=>{let t,o=ATON.Utils.generateID("vec3");e.quat&&(t=e.quat);let i=.01;e.step&&(i=e.step);let r=t?t.x:0,a=t?t.y:0,n=t?t.z:0,s=t?t.w:0,l=O.createElementFromHTMLString(`\n
    \n \n \n \n \n
    \n `);l.id=o;let d=l.children[0],c=l.children[1],u=l.children[2],p=l.children[3];return d.oninput=()=>{let o=d.value;t&&(t.x=o),e.onupdate&&e.onupdate()},c.oninput=()=>{let o=c.value;t&&(t.y=o),e.onupdate&&e.onupdate()},u.oninput=()=>{let o=u.value;t&&(t.z=o),e.onupdate&&e.onupdate()},u.oninput=()=>{let o=p.value;t&&(t.w=o),e.onupdate&&e.onupdate()},l},createNodeTrasformControl:e=>{let t,o=ATON.Utils.generateID("ftrans"),i=document.createElement("div");if(i.id=o,e.node&&(t=ATON.getSceneNode(e.node)),e.position){let o=O.createVectorControl({vector:t.position,step:e.position.step});i.append(O.createElementFromHTMLString("")),i.append(o)}if(e.scale){let o=O.createVectorControl({vector:t.scale,step:e.scale.step});i.append(O.createElementFromHTMLString("")),i.append(o)}if(e.rotation){let o=O.createVectorControl({vector:t.rotation,step:e.rotation.step});i.append(O.createElementFromHTMLString("")),i.append(o)}return i},createSceneCard:e=>{let t,o,i,r=document.createElement("div");if(r.classList.add("card","aton-scene-card"),"small"===e.size&&r.classList.add("aton-scene-card-small"),"large"===e.size&&r.classList.add("aton-scene-card-large"),!e.sid)return r;let a="";if(e.keywords){for(let t in e.keywords)a+=t+" ";a=a.trim().toLowerCase(),r.setAttribute("data-search-term",a)}i=ATON.PATH_RESTAPI2+"scenes/"+e.sid+"/cover";let n=e.sid.split("/");if(t=n[0],o=n[1],r.setAttribute("data-search-user",t),e.useblurtint){let e=document.createElement("div");e.classList.add("aton-scene-card-bg"),e.style.backgroundImage="url('"+i+"')",r.append(e)}r.innerHTML+="";let s=document.createElement("div");s.classList.add("card-body","aton-scene-card-body"),r.append(s);let l=document.createElement("div");return l.classList.add("card-title","aton-scene-card-title"),l.innerHTML="Title",s.append(l),e.title?(l.innerHTML=e.title,a+=e.title.trim().toLowerCase(),r.setAttribute("data-search-term",a)):ATON.REQ.get("scenes/"+e.sid,(e=>{e.title&&(l.innerHTML=e.title)})),s.innerHTML+="
    "+t+"
    ",r},createLiveFilter:e=>{let t=ATON.Utils.generateID("filter"),o=t+"-input",i=document.createElement("form");i.id=t,i.classList.add("d-flex"),i.setAttribute("role","search");let r="Search";e.placeholder&&(r=e.placeholder);let a=O.createElementFromHTMLString(``);const n=document.createElement("div");return n.classList.add("input-group"),n.append(O.createElementFromHTMLString("")),n.append(a),e.oninput?a.oninput=e.oninput:a.oninput=()=>{if(!e.filterclass)return;let t=a.value.trim().toLowerCase(),o=document.querySelectorAll(`.${e.filterclass}`);if(t.length<3)for(let e of o)e.classList.remove("d-none");else for(let e of o){let o=e.getAttribute("data-search-term");o&&(o.includes(t)||t.length<1)?e.classList.remove("d-none"):e.classList.add("d-none")}},e.onfocus&&(a.onfocus=e.onfocus),e.onblur&&(a.onblur=e.onblur),i.append(n),i},createPublicScenesGallery:e=>{if(!e.containerid)return;let t=document.getElementById(e.containerid);if(!t)return;const o=o=>{o.sort(O.SCENES_SORTER),console.log(o);for(let i of o){let o=i.sid.startsWith("samples/");if(!o||o&&e.samples){let o=ATON.UI.createSceneCard({title:i.title?i.title:i.sid,sid:i.sid,keywords:i.kwords,useblurtint:!0,size:e.size});t.append(o)}}};return e.entries?o(e.entries):ATON.REQ.get("scenes/",(e=>o(e))),t},createLoginForm:e=>{let t=document.createElement("form");t.classList.add("container-sm","text-center");let o=O.createElementFromHTMLString('
    Username
    '),i=O.createElementFromHTMLString('
    Password
    '),r=O.createElementFromHTMLString(''),a=O.createElementFromHTMLString('');o.append(r),i.append(a);let n=ATON.UI.createButton({text:"Login",icon:"bi-person",variant:"primary",onpress:()=>{let t=r.value.trim(),o=a.value.trim();ATON.REQ.login(t,o,e.onSuccess,e.onFail)}});return e.header?t.append(e.header):t.append(O.createElementFromHTMLString('')),t.append(o),t.append(i),t.append(n),t}};const A=O;let b={USER_STATE_FREQ:.25,REPLICATED_EVT:"EREP",THRES_STATE_POS:.01,THRES_STATE_ORI:.08};b.Avatar=class extends t{constructor(e){super(void 0,ATON.NTYPES.UI),this.userid=e,this.username=void 0,this.message="...",this.color=ATON.Photon.ucolors[this.userid%ATON.Photon.ucolors.length],this._auTalk=[],this._auTalk.push(new THREE.PositionalAudio(ATON.AudioHub._listener)),this._auTalk.push(new THREE.PositionalAudio(ATON.AudioHub._listener));for(let e=0;e<2;e++)this._auTalk[e].setRefDistance(30),this._auTalk[e].setLoop(!1),this.add(this._auTalk[e]);this._auTalki=0,this.bMuted=!1,this._bPlayingAudio=!1,this._blob=void 0,this._b64=void 0,this._tStateCall=-1,this._tProgress=0,this._tFocCall=-1,this._currFocusPos=new THREE.Vector3,this._tgtFocusPos=new THREE.Vector3,this._currState={position:new THREE.Vector3,quaternion:new THREE.Quaternion,scale:1},this._tgtState={position:new THREE.Vector3,quaternion:new THREE.Quaternion,scale:1},this.userlabelnode=void 0,this.mStream=void 0,this._elVStream=void 0,this.realize()}getColor(){return this.color}setTalkDistance(e){e>0&&this._auTalk.setRefDistance(e)}setMuted(e){this.bMuted=e}getAvatarMaterialByUID(e){let t=ATON.MatHub.materials.avatars;return t[e%t.length]}_buildLabel(){this.userlabelnode=ATON.createUINode(),this.labelcontainer=new ThreeMeshUI.Block({width:.5,height:.2,padding:.03,borderRadius:.05,backgroundColor:ATON.MatHub.colors.white,fontFamily:ATON.SUI.PATH_FONT_JSON,fontTexture:ATON.SUI.PATH_FONT_TEX,justifyContent:"center",textAlign:"center"}),this.userlabelnode.position.y=.4,this.userlabelnode.add(this.labelcontainer),this.usernametext=new ThreeMeshUI.Text({content:"User #"+this.userid,fontSize:.07,fontColor:this.color}),this.usernametext.position.y=.01,this.labelcontainer.add(this.usernametext),this.add(this.userlabelnode),ThreeMeshUI.update()}realizeStreamPanel(){let e=ATON.MediaFlow.getOrCreateVideoStream(this.userid,void 0,!0);this._elVStream=e.el;let t=new THREE.PlaneGeometry(1,1);this.mStream=new THREE.Mesh(t,e.matStream),this.mStream.position.y=1;let o=.5625;this.mStream.scale.y=-o,this.mStream.position.y=.8*o,this._elVStream.addEventListener("loadedmetadata",(e=>{o=this._elVStream.videoHeight/this._elVStream.videoWidth,this.mStream.scale.y=-o,this.mStream.position.y=.8*o}))}getStreamPanel(){return this.mStream}toggleStreamPanel(e){void 0!==this.mStream&&(this.mStream.visible=e)}realize(){let e=new THREE.SphereGeometry(.2,16,16);ATON.Photon.customAvatarMaterial?this.usermaterial=ATON.Photon.customAvatarMaterial():this.usermaterial=this.getAvatarMaterialByUID(this.userid);let t=new THREE.Mesh(e,this.usermaterial);this.usermeshnode=ATON.createUINode(),this.usermeshnode.add(t),this.usermeshnode.setMaterial(this.usermaterial),this.usermeshnode.setCloneOnLoadHit(!1),this.add(this.usermeshnode),this.userauinode=new THREE.Sprite(ATON.Photon.uspritemats[this.userid%ATON.Photon.uspritemats.length]),this.userauinode.position.set(0,0,0),this.userauinode.visible=!1,this.add(this.userauinode),this.userfpnode=new THREE.Sprite(ATON.Photon.ufocmats[this.userid%ATON.Photon.ufocmats.length]),this.userfpnode.position.set(0,0,0),this.userfpnode.visible=!1,void 0===ATON.Photon._focNodes[this.userid]&&(ATON.Photon._focNodes[this.userid]=this.userfpnode,ATON.Photon.focGroup.add(this.userfpnode)),this._buildLabel()}loadRepresentation(e){let t=this;return void 0!==t.usermeshnode.children[0]&&t.usermeshnode.remove(t.usermeshnode.children[0]),t.usermeshnode.load(e),this}setUsername(e){return void 0===this.userlabelnode||(this.username=e,this.usernametext.set({content:e}),ThreeMeshUI.update()),this}getUsername(){if(void 0!==this.userid)return void 0===this.username?"User #"+this.userid:this.username}setMessage(e){if(void 0===this.userlabelnode)return this;this.message=e}setTalkVolume(e){if(void 0!==e)if(e>0){this.userauinode.visible=!0;let t=.1+.03*e;this.userauinode.scale.set(t,t,t)}else this.userauinode.visible=!1;else this.userauinode.visible=!1}hideFocalPoint(){this.userfpnode.visible=!1}requestFocus(e){if(void 0===e)return;if(this._tFocCall>=0)return;this._tFocCall=ATON._clock.elapsedTime,this._currFocusPos.copy(this.userfpnode.position);let t=this.scale.x*ATON._worldScale,o=parseFloat(e[0])*t,i=parseFloat(e[1])*t,r=parseFloat(e[2])*t,a=parseFloat(e[3])*t;this._tgtFocusPos.set(o,i,r),this._tgtFocusRad=2*a,this.userfpnode.scale.set(this._tgtFocusRad,this._tgtFocusRad,this._tgtFocusRad),this.userfpnode.visible=!0,ATON.enablePointLight(),ATON.plight.color=this.color,ATON.plight.position.copy(this._tgtFocusPos),ATON.plight.distance=this._tgtFocusRad}handleFocusTransition(){if(this._tFocCall<0)return;let e=ATON.Photon.USER_STATE_FREQ,t=(ATON._clock.elapsedTime-this._tFocCall)/e;if(t>=1)return this._tFocCall=-1,this.userfpnode.position.copy(this._tgtFocusPos),this.userfpnode.scale.set(this._tgtFocusRad,this._tgtFocusRad,this._tgtFocusRad),void(this.userfpnode.visible=!0);this.userfpnode.position.lerpVectors(this._currFocusPos,this._tgtFocusPos,t),ATON.plight.position.copy(this.userfpnode.position),this.userfpnode.visible=!0}requestStateTransition(e){this._tStateCall>=0||void 0!==e&&(this._tStateCall=ATON._clock.elapsedTime,this._currState.position.copy(this.position),this._currState.quaternion.copy(this.quaternion),this._currState.scale=this.scale,this._tgtState.position.copy(e.position),this._tgtState.quaternion.copy(e.quaternion),this._tgtState.scale=1/e.scale)}handleStateTransition(){if(this._tStateCall<0)return;let e=ATON.Photon.USER_STATE_FREQ;this._tProgress=e<=0?1:(ATON._clock.elapsedTime-this._tStateCall)/e;let t=this._currState,o=this._tgtState;if(this._tProgress>=1)return this._tStateCall=-1,this.position.copy(o.position),void this.usermeshnode.quaternion.copy(o.quaternion);this.position.lerpVectors(t.position,o.position,this._tProgress),this.usermeshnode.quaternion.slerp(o.quaternion,this._tProgress)}update(){if(this.handleStateTransition(),this.userfpnode&&this.userfpnode.visible){this.handleFocusTransition();let e=this.userfpnode.scale.x;e>.001?(this.userfpnode.scale.set(.99*e,.99*e,.99*e),ATON.plight.intensity*=.99):(this.userfpnode.visible=!1,ATON.disablePointLight())}let e=ATON.Nav._camera,t=ATON.Nav._currPOV.pos;if(void 0===e||void 0===t)return;this.userlabelnode&&this.userlabelnode.orientToCamera();let o=this.userauinode.scale.x;o*=.99,o>.01?this.userauinode.scale.set(o,o,o):this.userauinode.visible=!1}_handleTalk(){if(this._auTalk.isPlaying)return;if(this._auChunks.length<2)return;let e=this._auChunks[this._iAU];this._auTalk.setBuffer(e),this._auTalk.play(),this.setTalkVolume(5)}_handleTalkOLD(){if(this._bPlayingAudio)return;if(this._auChunks.length<1)return;let e=this._auChunks.shift();this._auTalk.setBuffer(e),this._auTalk.play(),this._bPlayingAudio=!0,this._auTalk.onended=()=>{this._bPlayingAudio=!1,e=null},this.setTalkVolume(5)}},b.CSTATE={DISCONNECTED:0,CONNECTING:1,CONNECTED:2},b.init=()=>{b.address=window.location.origin,b.initMaterials(),b.socket=void 0,b._cstate=b.CSTATE.DISCONNECTED,b._reqSSID=void 0,b._username=void 0,b.uid=void 0,b.color=ATON.MatHub.colors.white,b._bStreamFocus=!1,b._numUsers=1,b.avatarList=[],b.avaGroup=ATON.createUINode("avatars"),b.avaGroup.attachToRoot(),b.focGroup=ATON.createUINode("focus"),b.focGroup.attachTo(b.avaGroup),b._focNodes=[],b.bSendState=!0,window.setInterval(b.sendState,1e3*b.USER_STATE_FREQ),b._lastStateSent=void 0,b._bShowAvaG=!0,b._bSpatial=!0,b._decS={quaternion:new THREE.Quaternion,position:new THREE.Vector3},b.customAvatarMaterial=void 0,console.log("Photon initialized"),b.enableChatLog(),b._elVStream=void 0,window.addEventListener("beforeunload",(e=>{b.disconnect()}))},b.setCustomAvatarMaterialRoutine=e=>{b.customAvatarMaterial=e},b.enableChatLog=()=>{b._elChat=$("
    ").text("")},b.getNumUsers=()=>b._numUsers,b.initMaterials=()=>{b.ucolorhex=[],b.ucolorhex.push("#D88"),b.ucolorhex.push("#DD8"),b.ucolorhex.push("#8D8"),b.ucolorhex.push("#8DD"),b.ucolorhex.push("#88D"),b.ucolorhex.push("#D8D"),b.ucolorhex_light=[],b.ucolorhex_light.push("#FAA"),b.ucolorhex_light.push("#FFA"),b.ucolorhex_light.push("#AFA"),b.ucolorhex_light.push("#AFF"),b.ucolorhex_light.push("#AAF"),b.ucolorhex_light.push("#FAF"),b.ucolors=[],b.ucolors.push(new THREE.Color(b.ucolorhex[0])),b.ucolors.push(new THREE.Color(b.ucolorhex[1])),b.ucolors.push(new THREE.Color(b.ucolorhex[2])),b.ucolors.push(new THREE.Color(b.ucolorhex[3])),b.ucolors.push(new THREE.Color(b.ucolorhex[4])),b.ucolors.push(new THREE.Color(b.ucolorhex[5])),b.ucolorsdark=[],b.ucolorsdark.push(new THREE.Color(.2,0,0)),b.ucolorsdark.push(new THREE.Color(.2,.2,0)),b.ucolorsdark.push(new THREE.Color(0,.2,0)),b.ucolorsdark.push(new THREE.Color(0,.2,.2)),b.ucolorsdark.push(new THREE.Color(0,0,.2)),b.ucolorsdark.push(new THREE.Color(.2,0,.2));let e=ATON.MatHub.materials;e&&(e.avatars=[]);for(let t=0;t{if(!b.isConnected())return;let o=b.socket;o&&o.emit(b.REPLICATED_EVT,{e,d:t})},b.fireEvent=b.fire,b.on=(e,t)=>{if(void 0===t)return;let o=ATON.EventHub.evNetwork;void 0===o[e]&&(o[e]=[]),o[e].push(t)},b.isConnected=()=>b._cstate===b.CSTATE.CONNECTED,b.hasID=()=>void 0!==b.uid,b.log=e=>{if(!b.isConnected())return;let t=b.socket;t&&t.emit("UMSG",e)},b.joinSession=e=>{b.socket&&(void 0===e&&(e=ATON.SceneHub.currID),void 0!==e?(console.log("Joining Photon session '"+e+"'..."),b.socket.emit("SENTER",e)):console.log("Photon ERROR: current session ID is undefined"))},b.requestSceneState=()=>{b.socket&&b.socket.emit("SSTATE")},b.setAvatarsVisibility=e=>{b._bShowAvaG=e,e?b.avaGroup.show():b.avaGroup.hide()},b.disableSpatiality=()=>{b._bSpatial=!1},b.enableSpatiality=()=>{b._bSpatial=!0},b.setAddress=e=>{e&&(b.address=e)},b.connect=e=>{if(b._cstate===b.CSTATE.CONNECTED)return;if(b._cstate===b.CSTATE.CONNECTING)return;b._reqSSID=e;let t={};ATON.Utils.isConnectionSecure()?(t.path="/svrc/socket.io",t.secure=!0,t.rejectUnauthorized=!1):t.path="/vrc/socket.io",b._cstate=b.CSTATE.CONNECTING,b.socket=io.connect(b.address,t),void 0!==b.socket?b._registerSocketHandlers():b._cstate=b.CSTATE.DISCONNECTED},b.disconnect=()=>{void 0!==b.socket&&(b._numUsers=1,b.socket.disconnect(),b.color=ATON.MatHub.colors.white,ATON.plight.color=ATON.MatHub.colors.white,b._cstate=b.CSTATE.DISCONNECTED)},b._onConnected=()=>{},b.setUsername=e=>{(e=e.trim()).length<1||(b._username=e,void 0!==b.socket&&void 0!==b.uid&&(b.appendToChatBox("Your username is now: "+e+""),b.socket.emit("UNAME",e)))},b.setMessage=e=>{(e=e.trim()).length<1||e.length>3e3||(b._msg=e,void 0!==b.socket&&void 0!==b.uid&&(b.socket.emit("UMSG",e),b._elChat&&(e=b.chatMessageProcessor(b.uid,e),b.appendToChatBox("
    YOU
    : "+e+""))))},b.appendToChatBox=e=>{b._elChat&&(b._elChat.append("
    "+e+"
    "),b._elChat.scrollTop(b._elChat[0].scrollHeight))},b._registerSocketHandlers=()=>{b.socket.on("connect",(()=>{b._cstate=b.CSTATE.CONNECTED,void 0!==b._reqSSID?b.joinSession(b._reqSSID):b.joinSession(ATON.SceneHub.currID),console.log("Connected to Photon service!"),ATON.fire("VRC_Connected"),b._onConnected()})),b.socket.on("disconnect",(()=>{b._cstate=b.CSTATE.DISCONNECTED,b.uid=void 0,b.avaGroup.hide(),b.appendToChatBox("YOU disconnected from the Photon session"),console.log("Disconnected from Photon service!"),ATON.fire("VRC_Disconnected")})),b.socket.on(b.REPLICATED_EVT,(e=>{let t=e.e,o=e.d,i=ATON.EventHub.evNetwork[t];ATON.EventHub.executeHandlers(i,o)})),b.socket.on("ID",(e=>{console.log("Your ID is "+e),b.uid=e,b.color=b.ucolors[b.uid%b.ucolors.length],b._bShowAvaG&&b.avaGroup.show(),b.appendToChatBox("Your ID is #"+e+""),b.requestSceneState(),ATON.fire("VRC_IDassigned",e)})),b.socket.on("SSTATE",(e=>{b._numUsers=e.numUsers,console.log("Num. users: "+b._numUsers),ATON.fire("VRC_SceneState",e)})),b.socket.on("UENTER",(e=>{let t=e;console.log("User #"+t+" entered the session"),b.appendToChatBox("User #"+t+" entered the session"),b.requestSceneState(),ATON.fire("VRC_UserEnter",t)})),b.socket.on("ULEAVE",(e=>{let t=e;if(void 0===t)return;let o=b.avatarList[t];o&&(o.toggleStreamPanel(!1),o.hide()),console.log("User #"+t+" left the session"),b.appendToChatBox("User #"+t+" left the session"),b.requestSceneState(),ATON.fire("VRC_UserLeave",t)})),b.socket.on("USTATE",(e=>{if(!b._bShowAvaG)return;if(!b._bSpatial)return;let t=b.decodeState(e),o=t.userid,i=b.touchAvatar(o);i.requestStateTransition(t);let r=1/t.scale;i.scale.set(r,r,r)})),b.socket.on("UFOCUS",(e=>{if(!b._bSpatial)return;let t=e.uid,o=e.fp;b.touchAvatar(t).requestFocus(o)})),b.socket.on("UNAME",(e=>{let t=e.uid,o=e.name;void 0!==t&&(b.touchAvatar(t).setUsername(o),console.log("User #"+t+" changed username to: "+o),b.appendToChatBox("User #"+t+" changed username to: "+o+""),ATON.fire("VRC_UName",e))})),b.socket.on("UMSG",(e=>{let t=e.uid,o=e.msg;if(void 0===t)return;let i=b.touchAvatar(t);o.length<100&&i.setMessage(o),console.log("User #"+t+": "+o);let r=i.getUsername();o=b.chatMessageProcessor(t,o),b.ucolorhex[t%6];let a=b.ucolorhex_light[t%6];b.appendToChatBox("
    "+r+"
    : "+o+""),ATON.fire("VRC_UMessage",e)})),b.socket.on("UTALK",(e=>{let t=e.uid;if(void 0===t)return;let o=e.audio;if(o){if(b._bSpatial){let e=b.touchAvatar(t);if(e.bMuted)return;ATON.AudioHub._loader.load(o,(t=>{let o=e._auTalk[e._auTalki],i=(e._auTalki+1)%2;o.setBuffer(t),o.isPlaying||o.play(),e.setTalkVolume(5),e._auTalki=i}))}ATON.fire("VRC_UTalk",e),o=null}})),b.socket.on("UTALKSTOP",(e=>{void 0!==e.uid&&ATON.fire("VRC_UTalkStop",e)})),b.socket.on("UVIDEO",(e=>{void 0!==e.uid&&ATON.fire("VRC_UVideo",e)})),b.socket.on("UVIDEOSTOP",(e=>{let t=e.uid;if(void 0===t)return;let o=b.avatarList[t];o&&o.toggleStreamPanel(!1),ATON.fire("VRC_UVideoStop",e)}))},b.chatMessageProcessor=(e,t)=>{const o=(t=String(t)).match(/(((ftp|https?):\/\/)[\-\w@:%_\+.~#?,&\/\/=]+)/g);return o&&o.forEach((e=>{t=t.replace(e,""+e+"")})),t},b.encodeState=e=>{if(!e)return;let t=new Float32Array(5);t[0]=e.position.x,t[1]=e.position.y,t[2]=e.position.z;var o=new Int8Array(t.buffer);return o[12]=128*e.quaternion.x,o[13]=128*e.quaternion.y,o[14]=128*e.quaternion.z,o[15]=128*e.quaternion.w,o[16]=e.userid,o[17]=ATON._ws,o},b.decodeState=e=>{let t=new Int8Array(e);b._decS.userid=t[16];let o=ATON._unpackScale(t[17]);return b._decS.scale=o,b._decS.quaternion.set(parseFloat(t[12])/128,parseFloat(t[13])/128,parseFloat(t[14])/128,parseFloat(t[15])/128),t=new Float32Array(e),b._decS.position.set(parseFloat(t[0])/o,parseFloat(t[1])/o,parseFloat(t[2])/o),b._decS},b.update=()=>{if(b.isConnected())for(let e=0;e{if(void 0!==e){if(e)return b._bStreamFocus||(ATON.fire("VRC_FocusStreamingStarted"),ATON.enablePointLight(),ATON.plight.color=ATON.Photon.color),void(b._bStreamFocus=!0);{b._bStreamFocus&&(ATON.fire("VRC_FocusStreamingStopped"),ATON.disablePointLight());let e=ATON.SUI._selectorRad;ATON.SUI.mainSelector.scale.set(e,e,e),b._bStreamFocus=!1}}},b.sendState=()=>{if(!b.bSendState||!b._bSpatial)return;if(void 0===b.uid)return;if(!b.socket||!b.isConnected())return;let e=ATON.Nav._currPOV;if(!e)return;let t=ATON.getSceneFocalPoint();if(b._bStreamFocus&&void 0!==t){let e=t.x.toFixed(3),o=t.y.toFixed(3),i=t.z.toFixed(3),r=ATON.SUI.getSelectorRadius().toFixed(3);b.socket.emit("UFOCUS",[e,o,i,r])}if(!e.pos)return;if(!ATON.Nav._qOri)return;if(void 0!==b._lastStateSent){let t=b._lastStateSent.position,o=b._lastStateSent.quaternion,i=t.distanceToSquared(e.pos),r=o.angleTo(ATON.Nav._qOri);if(ib.avatarList[e],b.touchAvatar=e=>{if(void 0===b.avatarList[e]){let t=new b.Avatar(e);t.attachTo(b.avaGroup),t.loadRepresentation(ATON.PATH_RES+"models/vrc/head.glb"),b.avatarList[e]=t}let t=b.avatarList[e];return t.visible||ATON.fire("VRC_UserEnter",e),b._bShowAvaG&&t.show(),t},b.destroyAvatar=e=>{let t=b.avatarList[e];void 0!==t&&t.destroy()},b.clearAllAvatars=()=>{for(let e in b.avatarList)b.avatarList[e].hide()};const P=b;let f={FLOAT_PREC:5,init:()=>{f.bConvexBuilding=!1,f.convexPoints=[],f.convexNode=void 0,f.currConvexMesh=void 0,f.currSemNode=ATON.createSemanticNode(),f.currSemNode.disablePicking(),f.currSemNode.attachToRoot(),f.resetMaterial(),f._numShapes=0},resetMaterial:()=>{f.currMaterial=ATON.MatHub.getMaterial("semanticShapeHL")},setMaterial:e=>{void 0!==e&&(f.currMaterial=e)},addConvexPoint:e=>{if(void 0===e)return!1;if(f.convexPoints.length>0){let t=f.convexPoints[f.convexPoints.length-1];if(e.equals(t))return!1}f.convexPoints.push(e);let t=f.convexPoints.length,o=new THREE.Sprite(ATON.SUI.getOrCreateSpritePointEdit()),i=.02*ATON.getSceneQueriedDistance();if(void 0===i&&(i=.02),o.position.copy(e),o.scale.set(i,i,i),ATON.SUI.gPoints.add(o),t<4)return!1;let r=new THREE.ConvexGeometry(f.convexPoints),a=new THREE.Mesh(r,ATON.MatHub.getMaterial("semanticShapeEdit"));if(f.bConvexBuilding){let t=f.currConvexMesh;t.geometry.dispose(),t.geometry=r,ATON.Utils.setVectorPrecision(e,4),t.userData._convexPoints.push(e.x),t.userData._convexPoints.push(e.y),t.userData._convexPoints.push(e.z)}else{f.currSemNode.add(a),a.userData._convexPoints=[];for(let e=0;e{if(0!==f.convexPoints.length&&(f.convexPoints.pop(),f.currConvexMesh)){let e=f.currConvexMesh.userData;e._convexPoints&&e._convexPoints.pop()}},stopCurrentConvex:()=>{f.bConvexBuilding&&(f.convexPoints=[],f.bConvexBuilding=!1,f.currSemNode.removeChildren(),ATON.SUI.gPoints.removeChildren())},getCurrentConvexShape:()=>f.currSemNode,isBuildingShape:()=>f.convexPoints.length>0,completeConvexShape:e=>{if(f.convexPoints=[],f.bConvexBuilding=!1,void 0===f.currSemNode)return;void 0===e&&(e="sem"+f._numShapes);let t=ATON.getSemanticNode(e)||ATON.createSemanticNode(e),o=f.currSemNode.children[0];return ATON.SUI.addSemIcon(e,o),t.add(o),t.setMaterial(ATON.MatHub.materials.semanticShape),t.setDefaultAndHighlightMaterials(ATON.MatHub.materials.semanticShape,f.currMaterial),t.enablePicking(),f.currSemNode.removeChildren(),f._numShapes++,ATON.SUI.gPoints.removeChildren(),ATON._bqSem=!0,t},createConvexShape:(e,t)=>{let o=new THREE.ConvexGeometry(t),i=new THREE.Mesh(o,ATON.MatHub.materials.semanticShape);i.userData._convexPoints=[];for(let e=0;e{if(void 0===ATON._queryDataScene)return!1;void 0===e&&(e=.02);let t=ATON._queryDataScene.p,o=ATON.Nav.getCurrentEyeLocation();return t.lerpVectors(t,o,e),f.addConvexPoint(t),t},createSphere:(e,t,o)=>{if(void 0===t)return;if(void 0===o)return;void 0===e&&(e="sem"+f._numShapes);let i=ATON.getOrCreateSemanticNode(e),r=new THREE.Mesh(ATON.Utils.geomUnitSphere,ATON.MatHub.materials.semanticShape),a=new THREE.Object3D;return a.position.copy(t),a.scale.set(o,o,o),a.add(r),ATON.SUI.addSemIcon(e,a),i.add(a),i.enablePicking(),i.setDefaultAndHighlightMaterials(ATON.MatHub.materials.semanticShape,f.currMaterial),f._numShapes++,ATON._bqSem=!0,i},createSurfaceSphere:e=>{if(!ATON._queryDataScene)return;let t=ATON._queryDataScene.p,o=ATON.SUI.getSelectorRadius();return f.createSphere(e,t,o)},deleteSemanticNode:e=>{let t=ATON.getSemanticNode(e);if(void 0===t)return!1;if(t.removeChildren(),void 0===ATON.SUI.gSemIcons)return!0;for(let t in ATON.SUI.gSemIcons.children){let o=ATON.SUI.gSemIcons.children[t];o&&o.name===e&&ATON.SUI.gSemIcons.removeChild(o)}return!0}};const E=f;let R={SEMSHAPE_SPHERE:0,SEMSHAPE_CONVEX:1,POPUP_DT:500,STD_SEL_RAD:.05,_bRealized:!1,realize:()=>{if(R._bRealized)return;R.PATH_RES_ICONS=ATON.PATH_RES+"icons/",R._bPopup=!1,R._tPopup=void 0,R.popupBlurBG=0,R._userAuth={},R._bControlLight=!1,R._bControlSelScale=!1,R._cLightDir=new THREE.Vector3,R._auSemNode=void 0,R._auSemNodePlaying=!1,R._bReqHome=!1,R._bVRCsetup=!1,R.urlParams=new URLSearchParams(window.location.search),R._uiSetupBase(),R._uiProfiles={},R._uiCurrProfile=void 0,R._selRanges=[.01,50],R._selRefRadius=.5,ATON.realize(),ATON.on("Fullscreen",(e=>{R.uiSwitchButton("fullscreen",e)}));let e=ATON.FE.urlParams.get("d");e&&e>0&&(ATON.setDefaultPixelDensity(e),ATON.toggleAdaptiveDensity(!1));let t=ATON.FE.urlParams.get("dd");t&&t>0&&ATON.toggleAdaptiveDensity(!0),R._canvas=ATON._renderer.domElement,R._bSem=!1,R._bShowSemLabel=!0,R._bRealized=!0,R.loadSceneID=ATON.App.loadScene},_handleHomeReq:()=>{R._bReqHome||ATON.getRootScene().getBound().radius<=0||(R._bReqHome=!0,void 0!==ATON.Nav.homePOV?ATON.Nav.requestHome(1):ATON.Nav.computeAndRequestDefaultHome(.5))},addBasicLoaderEvents:()=>{ATON.on("NodeRequestFired",(()=>{$("#idLoader").show()})),ATON.on("SceneJSONLoaded",(()=>{ATON.SceneHub.getDescription()&&$("#btn-info").show(),void 0!==ATON.Nav.homePOV&&ATON.Nav.requestHome(1),ATON.XPFNetwork._list.length>0&&void 0===ATON.Nav.homePOV&&(ATON.XPFNetwork.setHomeXPF(0),ATON.XPFNetwork.requestTransitionByIndex(0))})),ATON.on("AllNodeRequestsCompleted",(()=>{$("#idLoader").hide(),ATON.CC.anyCopyrightFound()&&$("#btn-cc").show(),R.computeSelectorRanges(),ATON.SUI.setSelectorRadius(Math.min(R.STD_SEL_RAD,R._selRefRadius)),R._handleHomeReq()})),ATON.on("XR_support",(e=>{"immersive-vr"===e.type&&(e.v?$("#btn-vr").show():$("#btn-vr").hide())})),ATON.on("SemanticNodeHover",(e=>{let t=ATON.getSemanticNode(e);void 0!==t&&(R.showSemLabel(e),R._bSem=!0,t.highlight(),$("canvas").css({cursor:"crosshair"}),ATON.SUI.gSemIcons&&ATON.SUI.gSemIcons.hide())})),ATON.on("SemanticNodeLeave",(e=>{let t=ATON.getSemanticNode(e);void 0!==t&&(R.hideSemLabel(),R._bSem=!1,t.restoreDefaultMaterial(),$("canvas").css({cursor:"grab"}),ATON.SUI.gSemIcons&&ATON.SUI.gSemIcons.show())})),ATON.on("SemanticMaskHover",(e=>{R.showSemLabel(e),R._bSem=!0,$("canvas").css({cursor:"crosshair"})})),ATON.on("SemanticMaskLeave",(e=>{R.hideSemLabel(),R._bSem=!1,$("canvas").css({cursor:"grab"})})),ATON.addUpdateRoutine(R._update)},showSemLabel:e=>{R._bShowSemLabel&&($("#idPopupLabel").html(e),$("#idPopupLabel").show(),ATON.SUI.setInfoNodeText(e))},hideSemLabel:()=>{$("#idPopupLabel").hide(),$("#idPopupLabel").html("")},controlLight:e=>{R._bControlLight=e,ATON.Nav.setUserControl(!e)},controlSelectorScale:e=>{R._bControlSelScale=e,ATON._bPauseQuery=e,ATON.Nav.setUserControl(!e)},attachGizmoToNode:e=>{if(void 0===ATON._gizmo)return;let t=ATON.getSceneNode(e);void 0!==t&&ATON._gizmo.attach(t)},useMouseWheelToScaleSelector:e=>{void 0===e&&(e=.9),ATON.on("MouseWheel",(t=>{if(ATON._kModCtrl){let e=ATON.Nav.getFOV();return t>0?e+=1:e-=1,void ATON.Nav.setFOV(e)}if(ATON._kModShift){let o=ATON.SUI.mainSelector.scale.x;return t>0?o*=e:o/=e,oR._selRanges[1]&&(o=R._selRanges[1]),void ATON.SUI.setSelectorRadius(o)}}))},_update:()=>{if(R._bControlLight){const e=ATON._screenPointerCoords.x,t=ATON._screenPointerCoords.y;R._cLightDir.x=-Math.cos(e*Math.PI),R._cLightDir.y=4*-t,R._cLightDir.z=-Math.sin(e*Math.PI),R._cLightDir.normalize(),ATON.setMainLightDirection(R._cLightDir)}if(ATON.XR._bPresenting){let e=ATON.XR.getAxisValue(ATON.XR.HAND_R);if(!ATON.Photon._bStreamFocus){let t=ATON.SUI._selectorRad;t+=.01*e.y,t>.001&&ATON.SUI.setSelectorRadius(t)}}else{if(ATON.Nav.isTransitioning()||ATON.Nav._bInteracting||ATON._bPauseQuery)return void $("#idPopupLabel").hide();if(R._bSem&&R._bShowSemLabel){$("#idPopupLabel").show();let e=.5*ATON._screenPointerCoords.x*window.innerWidth,t=.5*(1-ATON._screenPointerCoords.y)*window.innerHeight;t-=55,$("#idPopupLabel").css("transform","translate("+e+"px, "+t+"px)")}else $("#idPopupLabel").hide()}},uiBasicSetup:()=>{R.uiAddButton("idTopToolbar","fullscreen",ATON.toggleFullScreen),ATON.Utils.isConnectionSecure()&&R.uiAddButton("idTopToolbar","vr",ATON.XR.toggle),R.uiAddButton("idBottomToolbar","home",(()=>{ATON.Nav.requestHome(.1)}))},_uiSetupBase:()=>{$("#idPopup").click(R.popupClose),$("#idLoader").html(""),$("body").prepend("
    "),R.hideSemLabel()},uiAddButton:(e,t,o,i)=>{let r,a;t.endsWith(".png")?(r=t,a=t.slice(0,-4)):(r=R.PATH_RES_ICONS+t+".png",a=t);let n=$("
    ");$("#"+e).append(n),o&&n.click(o),i&&n.attr("title",i)},uiSwitchButton:(e,t)=>{t?$("#btn-"+e).addClass("switchedON"):$("#btn-"+e).removeClass("switchedON")},uiSetButtonHandler:(e,t)=>{$("#"+e).click(t)},uiAddButtonHome:e=>{R.uiAddButton(e,"home",(()=>{ATON.Nav.requestHome(.3)}),"Home viewpoint")},uiAddButtonBack:(e,t)=>{R.uiAddButton(e,"back",(()=>{t&&t.length>1&&t.startsWith("http:")?ATON.Utils.goToURL(t):history.back()}),"Go Back")},uiAddButtonFirstPerson:e=>{R.uiAddButton(e,"fp",(()=>{ATON.Nav.isFirstPerson()?(ATON.Nav.setOrbitControl(),R.uiSwitchButton("fp",!1)):(ATON.Nav.setFirstPersonControl(),R.uiSwitchButton("fp",!0))}),"First-person navigation mode"),ATON.Nav.isFirstPerson()?R.uiSwitchButton("fp",!0):R.uiSwitchButton("fp",!1)},uiAddButtonVR:e=>{ATON.Utils.isConnectionSecure()&&(R.uiAddButton(e,"vr",(()=>{ATON.XR.toggle("immersive-vr")}),"Immersive VR mode"),ATON.Utils.isVRsupported()||$("#btn-vr").hide())},uiAddButtonAR:e=>{ATON.Utils.isConnectionSecure()&&R.uiAddButton(e,"ar",(()=>{ATON.Utils.isARsupported()&&ATON.XR.toggle("immersive-ar")}),"Immersive AR mode")},uiAddButtonDeviceOrientation:e=>{ATON.Utils.isConnectionSecure()&&ATON.Utils.isMobile()&&(R.uiAddButton(e,"devori",(()=>{ATON.Nav.isDevOri()?(ATON.Nav.restorePreviousNavMode(),R.uiSwitchButton("devori",!1)):(ATON.Nav.setDeviceOrientationControl(),R.uiSwitchButton("devori",!0))}),"Device-orientation mode"),ATON.Nav.isDevOri()?R.uiSwitchButton("devori",!0):R.uiSwitchButton("devori",!1))},uiAddButtonNav:e=>{R.uiAddButton(e,"nav",(()=>{R.popupNav()}),"Navigation")},uiAddButtonTalk:e=>{ATON.Utils.isConnectionSecure()&&(R.uiAddButton(e,"talk",(()=>{ATON.MediaFlow.isAudioRecording()?(ATON.MediaFlow.stopAudioStreaming(),$("#btn-talk").removeClass("atonBTN-rec")):(ATON.MediaFlow.startAudioStreaming(),$("#btn-talk").addClass("atonBTN-rec"))}),"Talk ON/OFF"),ATON.MediaFlow.isAudioRecording()?$("#btn-talk").addClass("atonBTN-rec"):$("#btn-talk").removeClass("atonBTN-rec"))},uiAddButtonStreamFocus:e=>{R.uiAddButton(e,"focus",(()=>{ATON.Photon._bStreamFocus?(ATON.Photon.setFocusStreaming(!1),$("#btn-focus").removeClass("atonBTN-rec")):(ATON.Photon.setFocusStreaming(!0),$("#btn-focus").addClass("atonBTN-rec"))}),"Focus streaming ON/OFF"),ATON.Photon._bStreamFocus?$("#btn-focus").addClass("atonBTN-rec"):$("#btn-focus").removeClass("atonBTN-rec")},uiAddButtonMainVideoPanoPlayPause:e=>{R.uiAddButton(e,"playpause",(()=>{ATON._vpanoPlaying?ATON._elPanoVideo&&ATON._elPanoVideo.pause():ATON._elPanoVideo&&ATON._elPanoVideo.play()}),"360 Video play/pause"),ATON._elPanoVideo?$("#btn-playpause").show():$("#btn-playpause").hide()},uiAddButtonQR:e=>{ATON.Utils.isLocalhost()||R.uiAddButton(e,"qr",R.popupQR,"QR-code")},uiAddButtonScreenshot:e=>{R.uiAddButton(e,"sshot",R.popupScreenShot,"Screenshot")},uiAddButtonInfo:e=>{R.uiAddButton(e,"info",ATON.FE.popupSceneInfo,"Scene information"),$("#btn-info").hide()},uiAddButtonFullScreen:e=>{R.uiAddButton(e,"fullscreen",(()=>{ATON.toggleFullScreen()}),"Fullscreen"),R.uiSwitchButton("fullscreen",ATON.isFullscreen())},uiAddKeywordsArea:(e,t,o,i)=>{let r="";r+="Add keyword:

    ",r+="
    ",$("#"+e).html(r),R.uiAttachInputFilterID("idKWordInput"),$.getJSON(ATON.PATH_RESTAPI+"keywords/",(t=>{let o="";for(let e in t)o+="";o+="",$("#"+e).append(o)}));let a={},n=e=>{a[e]||(e=e.toLowerCase().trim(),$("#idKWordInput").val(""),a[e]=1,console.log("Added keyword "+e),o&&o(e),$("#idKWords").append("
    "+e+"
    "),$("#idkw-"+e).click((()=>{$("#idkw-"+e).remove(),a[e]=void 0,console.log("Removed keyword "+e),i&&i(e)})))};if(t)for(let e in t)n(t[e]);$("#idKWordInput").keypress((function(e){if("13"!=(e.keyCode?e.keyCode:e.which))return;let t=$("#idKWordInput").val().toLowerCase().trim();!t||t.length<3||n(t)})),$("#idKWadd").click((()=>{let e=$("#idKWordInput").val().toLowerCase().trim();!e||e.length<3||n(e)}))},uiAttachCollectionItemsToInput:(e,t)=>{let o="";$("#"+e).attr("list",e+"-list"),$("#"+e).attr("name",e+"-list"),$.getJSON(ATON.PATH_RESTAPI+"c/"+t+"/",(t=>{o+="";for(let e in t){let i=t[e];o+=""}o+="",$("#"+e).html(o)}))},getVRCclassFromID:e=>"atonVRCu"+e%6,_setupVRCevents:()=>{R._bVRCsetup||(ATON.on("VRC_IDassigned",(e=>{$("#btn-vrc").addClass(R.getVRCclassFromID(e)),ATON.SUI.setSelectorColor(ATON.Photon.color),ATON.plight.color=ATON.Photon.color,R.checkAuth((e=>{void 0!==e.username&&ATON.Photon.setUsername(e.username)}))})),ATON.on("VRC_SceneState",(e=>{let t=ATON.Photon.getNumUsers();t>1?$("#idVRCnumusers").html(t):$("#idVRCnumusers").html(""),console.log("Users: "+t)})),ATON.on("VRC_Disconnected",(()=>{$("#btn-vrc").attr("class","atonBTN"),ATON.SUI.setSelectorColor(ATON.MatHub.colors.defUI),ATON.MediaFlow.stopAllStreams(),$("#idVRCnumusers").html("")})),R._bVRCsetup=!0)},uiAddButtonPhoton:e=>{R.uiAddButton(e,"vrc",(()=>{ATON.Photon.isConnected()?R.popupVRC():ATON.Photon.connect()}),"Photon (collaborative session)"),$("#btn-vrc").append(""),R._setupVRCevents(),void 0!==ATON.Photon.uid?$("#btn-vrc").addClass(R.getVRCclassFromID(ATON.Photon.uid)):$("#btn-vrc").attr("class","atonBTN")}};R.uiAddButtonVRC=R.uiAddButtonPhoton,R.uiAddButtonUser=e=>{R.uiAddButton(e,"user",(()=>{R.popupUser()}),"User"),R.checkAuth((e=>{void 0!==e.username?$("#btn-user").addClass("switchedON"):$("#btn-user").removeClass("switchedON")}))},R.uiSetEditMode=(e,t)=>{ATON.SceneHub._bEdit=e,R.uiSwitchButton("edit",e),ATON._renderer.domElement,e?$("#"+t).addClass("atonToolbar-bg-edit"):$("#"+t).removeClass("atonToolbar-bg-edit")},R.uiAddButtonEditMode=e=>{R.uiAddButton(e,"edit",(()=>{R.checkAuth((t=>{void 0!==t.username?(ATON.SceneHub._bEdit?R.uiSetEditMode(!1,e):R.uiSetEditMode(!0,e),console.log("Persistent Edit Mode: "+ATON.SceneHub._bEdit)):R.popupUser()}))}),"Persistent Edit Mode"),ATON.SceneHub._bEdit?R.uiSwitchButton("edit",!0):R.uiSwitchButton("edit",!1)},R.uiAddProfile=(e,t)=>{"function"==typeof t&&(R._uiProfiles[e]=t)},R.uiLoadProfile=e=>{let t=R._uiProfiles[e];void 0!==t&&(t(),R._uiCurrProfile=e,console.log("Loaded UI Profile: "+R._uiCurrProfile))},R.getCurrentUIP=()=>R._uiCurrProfile,R.attachHandlerToButton=(e,t)=>{void 0!==t&&$("#"+e).click((()=>{t()}))},R.uiAttachInputFilterID=e=>{$("#"+e).on("keyup change input",(()=>{let t=$("#"+e).val(),o=new RegExp("[^A-Za-z0-9-_]","ig");$("#"+e).val(t.replace(o,""))}))},R.switchNode=(e,t,o)=>{let i;i=o===ATON.NTYPES.SEM?ATON.getSemanticNode(e):ATON.getSceneNode(e),void 0!==i&&(i.toggle(t),ATON.fire("FE_NodeSwitch",{nid:e,t:o,v:t}))},R.uiCreateGraph=e=>{let t=ATON.snodes;e===ATON.NTYPES.SEM&&(t=ATON.semnodes);let o="";for(let i in t){let r=t[i].visible?"checked":"";"."!==i&&(o+="'+i,o+="
    ")}return o},R.setupBasicUISounds=()=>{R.auLib={},R.auLib.switch=new Audio(ATON.PATH_RES+"audio/switch.wav"),R.auLib.switch.loop=!1},R.playAudioFromSemanticNode=e=>{if(void 0===e)return;let t=ATON.getSemanticNode(e);if(void 0===t)return;let o=t.getAudio();void 0!==o&&("string"!=typeof o||o.startsWith("data:audio")||(o=ATON.Utils.resolveCollectionURL(o)),void 0===R._auSemNode||null===R._auSemNode?R._auSemNode=new THREE.Audio(ATON.AudioHub._listener):R._auSemNode.stop(),ATON.AudioHub._loader.load(o,(e=>{R._auSemNode.setBuffer(e),R._auSemNode.setLoop(!1),R._auSemNode.play()})))},R.popupShow=(e,t)=>{if(R._bPopup)return!1;R._tPopup=Date.now();let o="atonPopup ";t&&(o+=t);let i="
    ";return i+=e+"
    ",R._bPopup=!0,ATON._bListenKeyboardEvents=!1,$("#idPopup").html(i),$("#idPopupContent").click((e=>{e.stopPropagation()})),$("#idPopup").show(),R.popupBlurBG>0&&(ATON._renderer.domElement.style.filter="blur("+R.popupBlurBG+"px)"),ATON._bPauseQuery=!0,$("#idTopToolbar").hide(),$("#idBottomToolbar").hide(),$("#idBottomRToolbar").hide(),$("#idPoweredBy").hide(),!0},R.popupClose=e=>{Date.now()-R._tPopup0&&(ATON._renderer.domElement.style.filter="none"),$("#idPopup").hide(),ATON._bPauseQuery=!1,$("#idTopToolbar").show(),$("#idBottomToolbar").show(),$("#idBottomRToolbar").show(),$("#idPoweredBy").show(),ATON.focusOn3DView())},R.subPopup=e=>{ATON.FE.popupClose(),e()},R.popupQR=()=>{let e="
    Share
    ";if(e+="


    ",!ATON.FE.popupShow("
    Share


    "))return;let t=window.location.href;new QRCode(document.getElementById("idQRcode"),t)},R.popupScreenShot=()=>{let e=ATON.Utils.takeScreenshot(256);R.checkAuth((t=>{let o="
    Capture
    ";o+="This is a preview of what your screenshot will look like:

    ",o+="
    ",o+="Resolution: px
    ",o+="
    Screenshot
    ",o+="
    Record video
    ",void 0!==t.username&&(o+="
    Set as Cover
    "),ATON.FE.popupShow(o)&&(ATON.MediaFlow._bScreenRec?$("#btnScreenRec").addClass("atonBTN-rec"):$("#btnScreenRec").removeClass("atonBTN-rec"),$("#btnScreenShot").click((()=>{let e=parseInt($("#isShotSize").val());e<100||(ATON.FE.popupClose(),ATON.Utils.takeScreenshot(e,"shot.png"))})),$("#btnScreenRec").click((()=>{ATON.MediaFlow._bScreenRec||ATON.MediaFlow.startScreenRecording(),ATON.FE.popupClose()})),$("#btnSetCover").click((()=>{ATON.FE.popupClose(),ATON.Utils.postJSON(ATON.PATH_RESTAPI+"cover/scene/",{sid:ATON.SceneHub.currID,img:e.src},(e=>{console.log(e)}))})))}))},R.popupVRC=()=>{let e="",t=ATON.Photon.getNumUsers();e+=t>1?"
    Collaborative Session ("+t+" users)
    ":"
    Collaborative Session
    ",e+="
    ",e+="",e+="",e+="
    LEAVE
    ",e+="
    ",e+="",ATON.FE.popupShow(e,"atonPopupLarge")&&(ATON.checkAuth((e=>{console.log(e),ATON.MediaFlow._bCamStream||ATON.FE.uiAddButton("idCollabTools","screenshare",(()=>{ATON.MediaFlow._bScreenStream?$("#btn-screenshare").addClass("atonBTN-rec"):$("#btn-screenshare").removeClass("atonBTN-rec"),ATON.MediaFlow.startOrStopScreenStreaming(),ATON.FE.popupClose()}),"Share your screen with other participants"),!ATON.MediaFlow._bScreenStream&&ATON.MediaFlow.hasVideoInput()&&ATON.FE.uiAddButton("idCollabTools","camera",(()=>{ATON.MediaFlow._bCamStream?$("#btn-camera").addClass("atonBTN-rec"):$("#btn-camera").removeClass("atonBTN-rec"),ATON.MediaFlow.startOrStopCameraStreaming(),ATON.FE.popupClose()}),"Share your camera with other participants"),ATON.MediaFlow._bScreenStream?$("#btn-screenshare").addClass("atonBTN-rec"):$("#btn-screenshare").removeClass("atonBTN-rec"),ATON.MediaFlow._bCamStream?$("#btn-camera").addClass("atonBTN-rec"):$("#btn-camera").removeClass("atonBTN-rec")})),void 0===ATON.Photon._username?($("#idVRCusername").show(),$("#idVRCusernameBTN").hide()):($("#idVRCusername").val(ATON.Photon._username),$("#idVRCusername").hide(),$("#idVRCusernameBTN").show()),void 0!==ATON.Photon.uid&&$("#idVRCusernameBTN").addClass("atonVRCu"+ATON.Photon.uid%6),$("#idChatBoxPopup").append(ATON.Photon._elChat),$("#idVRCmsg").keypress((e=>{if("13"==(e.keyCode?e.keyCode:e.which)){let e=$("#idVRCmsg").val();ATON.Photon.setMessage(e),$("#idVRCmsg").val("")}})),$("#idVRCusername").keypress((e=>{if("13"==(e.keyCode?e.keyCode:e.which)){let e=$("#idVRCusername").val();ATON.Photon.setUsername(e),$("#idVRCusername").hide(),$("#idVRCusernameBTN").html(ATON.Photon._username),$("#idVRCusernameBTN").show()}})),$("#idVRCusernameBTN").click((()=>{$("#idVRCusername").show(),$("#idVRCusernameBTN").hide()})),$("#idVRCdisconnect").click((()=>{ATON.Photon.disconnect(),ATON.FE.popupClose()})))},R.checkAuth=e=>{ATON.Utils.checkAuth((t=>{R._userAuth=t,void 0!==t.username?($("#btn-user").addClass("switchedON"),void 0===ATON.Photon._username&&ATON.Photon.setUsername(t.username)):$("#btn-user").removeClass("switchedON"),e&&e(t)}))},R.popupUser=()=>{R.checkAuth((e=>{if(void 0!==e.username){let t="
    ";if(t+="'"+e.username+"'

    ",Object.keys(R._uiProfiles).length>0){t+="UI Profile:


    "}if(t+="
    LOGOUT
    ",!ATON.FE.popupShow(t))return;R._uiCurrProfile&&(console.log(R._uiCurrProfile),$("#idUIProfiles").val(R._uiCurrProfile)),$("#idLogoutBTN").click((()=>{$.get(ATON.PATH_RESTAPI+"logout",(e=>{console.log(e),ATON.SceneHub.setEditMode(!1),R.uiSwitchButton("edit",!1),ATON.fire("Logout"),$("#btn-user").removeClass("switchedON")})),ATON.FE.popupClose()})),$("#idSHUscenes").click((()=>{ATON.Utils.goToURL("/shu/scenes/")})),$("#idSHUuser").click((()=>{ATON.Utils.goToURL("/shu/auth/")})),$("#idUIProfiles").on("change",(()=>{let e=$("#idUIProfiles").val();R.uiLoadProfile(e),ATON.FE.popupClose()}))}else{let e="
    ";if(e+="username:
    ",e+="password:
    ",e+="
    LOGIN
    ",!ATON.FE.popupShow(e))return;$("#idLoginBTN").click((()=>{let e=JSON.stringify({username:$("#idUsername").val(),password:$("#idPassword").val()});$.ajax({url:ATON.PATH_RESTAPI+"login",type:"POST",data:e,contentType:"application/json; charset=utf-8",dataType:"json",success:e=>{console.log(e),e&&(ATON.fire("Login",e),$("#btn-user").addClass("switchedON"),ATON.FE.popupClose())}}).fail((e=>{$("#idLoginBTN").html("LOGIN FAILED"),$("#idLoginBTN").attr("class","atonBTN atonBTN-red")}))}))}}))},R.popupSceneInfo=()=>{let e=ATON.SceneHub.getTitle();void 0===e&&(e=ATON.SceneHub.currID);let t=ATON.SceneHub.getDescription(),o="
    "+e+"
    ";t&&(o+="
    "+JSON.parse(t)+"
    "),o+="
    OK
    ",ATON.FE.popupShow(o)&&$("#btnOK").click((()=>{ATON._onUserInteraction(),ATON.FE.popupClose()}))},R.computeSelectorRanges=()=>{let e=ATON.bounds.radius;e<=0||(R._selRanges[0]=.001*e,R._selRefRadius=.01*e,R._selRanges[1]=.5*e)},R.popupSelector=()=>{let e="
    3D Selector
    ",t=ATON.SUI.getSelectorRadius(),o=ATON.Utils.getHumanReadableDistance(t);R.computeSelectorRanges(),e+="Radius ("+o+"):
    ",e+="",ATON.FE.popupShow(e,"atonPopupLarge")&&($("#idSelRad").val(t),$("#idSelRad").on("input change",(()=>{let e=parseFloat($("#idSelRad").val());ATON.SUI.setSelectorRadius(e),$("#idSelRadTxt").html(ATON.Utils.getHumanReadableDistance(e))})))},R.popupNav=()=>{let e="
    Navigation
    ";e+="
    ",e+="
    ",e+="
    Switch between first-person and orbit navigation mode
    ",e+="
    ",ATON.Utils.isConnectionSecure()&&(e+="
    ",e+="
    ",e+="
    Immersive VR mode
    ",e+="
    ",ATON.Utils.isMobile()&&(e+="
    ",e+="
    ",e+="
    Enable or disable device-orientation mode
    ",e+="
    ")),R.popupShow(e)&&(R.uiAddButtonFirstPerson("idNMfp"),R.uiAddButtonDeviceOrientation("idNMdevori"),R.uiAddButtonVR("idNMvr"))},R.popupModalToken=(e,t)=>{if(void 0===t)return;ATON.FE.popupClose();let o="
    Token Required
    ";e&&(o+=e),o+="

    ",o+="
    OK
    ",R.popupShow(o)&&$("#btnTokenOK").click((()=>{let e=$("#idTokStr").val();void 0===e||e.length<2||(ATON.FE.popupClose(),t(e))}))},R.popupNewNode=e=>{void 0===e&&(e=ATON.NTYPES.SCENE);let t="";e===ATON.NTYPES.SCENE&&(t="
    New Scene Node
    "),e===ATON.NTYPES.SEM&&(t="
    New Semantic Node
    "),t+="ID:
    ",t+="
    Add

    ",R.popupShow(t)&&$("#btnNewNID").click((()=>{let t=$("#idNID").val().trim();void 0===t||t.length<3||new ATON.Node(t,e).attachToRoot()}))};const y=R;let w={auType:"audio/wav",auStreamSegmentInterval:200,auStreamNumSegments:2,vidStreamSegmentInterval:300,vidStreamNumSegments:1,auMinVol:1,init:()=>{w._bAudioRecording=!1,w._bAudioStreaming=!1,w._bScreenRec=!1,w._blobOptAudio={type:"audio/wav"},w._blobOptVideo={type:"video/mp4"},w._cAuStream={audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}},w._cAuRec={audio:{channelCount:1}},w._cScreenRec={video:{width:1280,height:720,framerate:30}},w._cScreenStream={video:{cursor:"always",width:{max:640},height:{max:360},framerate:15}},w._cCamStream={video:{width:{max:512},height:{max:512}}},w._oStream={audioBitsPerSecond:9e3,videoBitsPerSecond:5e5},w._aurec=void 0,w._sblob=void 0,w._schunks=[],w._bVideoStream=!1,w._vrec=void 0,w._scblob=void 0,w._scchunks=[],w._bCamStream=!1,w._bScreenStream=!1,w._setupFR(),w.detectDevices(),navigator.mediaDevices&&navigator.mediaDevices.addEventListener("devicechange",(e=>{w.detectDevices()})),w._vStreams={}},_setupFR:()=>{w._frAR=new window.FileReader,w._frAR.onloadend=()=>{let e=w._frAR.result;ATON.fire("AudioRecordCompleted",e),w._bAudioRecording=!1},w._frAS=new window.FileReader,w._frAS.onloadend=()=>{if(!w._bAudioStreaming)return;let e=w._frAS.result;ATON.Photon.socket.emit("UTALK",{audio:e,uid:ATON.Photon.uid}),e=null},w._frVS=new window.FileReader,w._frVS.onloadend=()=>{if(!w._bVideoStream)return;let e=w._frVS.result;ATON.Photon.socket.emit("UVIDEO",{video:e,uid:ATON.Photon.uid}),e=null}},detectDevices:()=>{w.audioInputDevices=[],w.videoInputDevices=[],navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices().then((e=>{for(let t in e){let o=e[t];"audioinput"===o.kind&&w.audioInputDevices.push(o),"videoinput"===o.kind&&w.videoInputDevices.push(o)}}))},hasAudioInput:()=>w.audioInputDevices.length>0,hasVideoInput:()=>w.videoInputDevices.length>0,isAudioRecording:()=>w._bAudioRecording,startRecording:()=>{w._bAudioRecording?console.log("Already recording."):navigator.mediaDevices.getUserMedia(w._cAuRec).then((e=>{w._aurec=new MediaRecorder(e),w._aurec.onstart=function(e){console.log("Start recording..."),w._bAudioRecording=!0,w._schunks=[]},w._aurec.ondataavailable=function(e){w._schunks.push(e.data)},w._aurec.onstop=function(e){console.log("Stop recording..."),w._sblob=new Blob(w._schunks,w._blobOptAudio),w._frAR.readAsDataURL(w._sblob)},w._aurec.start()})).catch((e=>{console.log(e)}))},stopRecording:()=>{w._aurec&&w._bAudioRecording&&w._aurec.stop()},startOrStopRecording:()=>{w._bAudioRecording?w.stopRecording():w.startRecording()},startAudioStreaming:()=>{navigator.mediaDevices.getUserMedia(w._cAuStream).then((e=>{w._aurec=new MediaRecorder(e,w._oStream),w._aurec.start(w.auStreamSegmentInterval),console.log("Start audio streaming"),w._aurec.onstart=e=>{w._bAudioStreaming=!0,w._bAudioRecording=!0,w._schunks=[]},w._aurec.ondataavailable=e=>{e.data.size<=0||(w._schunks.push(e.data),w._schunks.length{w._sblob=new Blob(w._schunks,w._blobOptAudio),w._frAS.readAsDataURL(w._sblob),w._bAudioStreaming&&w._aurec.start(w.auStreamSegmentInterval)}})).catch((e=>{console.log(e)}))},stopAudioStreaming:()=>{w._aurec&&w._bAudioStreaming&&("inactive"!==w._aurec.state&&w._aurec.stop(),console.log("Stop audio streaming"),w._bAudioStreaming=!1,w._bAudioRecording=!1,ATON.Photon.socket.emit("UAUDIOSTOP",{uid:ATON.Photon.uid}))},startOrStopAudioStreaming:()=>{w._bAudioRecording?w.stopAudioStreaming():w.startAudioStreaming()},startScreenRecording:()=>{w._bScreenRec||w._bScreenStream||navigator.mediaDevices.getDisplayMedia(w._cScreenRec).then((e=>{w._vrec=new MediaRecorder(e),w._scchunks=[],w._vrec.ondataavailable=e=>{e.data.size>0&&w._scchunks.push(e.data)},w._vrec.onstop=()=>{w._scblob=new Blob(w._scchunks,w._blobOptVideo),console.log(w._scblob.size),ATON.Utils.downloadBlob(w._scblob,"capture.mp4"),w._scchunks=[],w._bScreenRec=!1},w._vrec.start(200),w._bScreenRec=!0})).catch((e=>{console.log(e)}))},stopScreenRecording:()=>{w._bScreenRec&&(w._vrec.stop(),w._bVideoStream=!1,w._bScreenStream=!1,console.log("Stop screen recording"))},startScreenStreaming:()=>{navigator.mediaDevices.getDisplayMedia(w._cScreenStream).then((e=>{w.realizeOrUpdateVStream(e,w.stopScreenStreaming),w._vrec=new MediaRecorder(e,w._oStream),w._vrec.start(w.vidStreamSegmentInterval),console.log("Start screen streaming"),w._vrec.onstart=e=>{w._bVideoStream=!0,w._bScreenStream=!0,w._scchunks=[]},w._vrec.ondataavailable=e=>{e.data.size<1||(w._scchunks.push(e.data),w._scchunks.length{w._scblob=new Blob(w._scchunks,w._blobOptVideo),w._frVS.readAsDataURL(w._scblob),w._bVideoStream&&w._vrec.start(w.vidStreamSegmentInterval)}})).catch((e=>{console.log(e)}))},stopScreenStreaming:()=>{if(w._vrec&&w._bVideoStream&&(w._vrec.stop(),w._bVideoStream=!1,w._bScreenStream=!1,console.log("Stop screen streaming"),void 0!==ATON.Photon.uid)){let e=w.getVideoStream(ATON.Photon.uid);e.el.style.display="none",e.el.pause(),ATON.Photon.socket.emit("UVIDEOSTOP",{uid:ATON.Photon.uid})}},startOrStopScreenStreaming:()=>{w._bVideoStream?w.stopScreenStreaming():w.startScreenStreaming()},startCameraStreaming:()=>{w._bVideoStream||navigator.mediaDevices.getUserMedia(w._cCamStream).then((e=>{w.realizeOrUpdateVStream(e,w.stopCameraStreaming),w._vrec=new MediaRecorder(e,w._oStream),w._vrec.start(w.vidStreamSegmentInterval),console.log("Start camera streaming"),w._vrec.onstart=e=>{w._bVideoStream=!0,w._bCamStream=!0,w._scchunks=[]},w._vrec.ondataavailable=e=>{e.data.size<1||(w._scchunks.push(e.data),w._scchunks.length{w._scblob=new Blob(w._scchunks,w._blobOptVideo),w._frVS.readAsDataURL(w._scblob),w._bVideoStream&&w._vrec.start(w.vidStreamSegmentInterval)}})).catch((e=>{console.log(e)}))},stopCameraStreaming:()=>{if(w._vrec&&w._bVideoStream&&(w._vrec.stop(),w._bVideoStream=!1,w._bCamStream=!1,console.log("Stop camera streaming"),void 0!==ATON.Photon.uid)){let e=w.getVideoStream(ATON.Photon.uid);e.el.style.display="none",e.el.pause(),ATON.Photon.socket.emit("UVIDEOSTOP",{uid:ATON.Photon.uid})}},startOrStopCameraStreaming:()=>{w._bVideoStream?w.stopCameraStreaming():w.startCameraStreaming()},realizeOrUpdateVStream:(e,t)=>{let o=ATON.Photon.uid;if(void 0===o)return;let i=w.getOrCreateVideoStream(o,void 0,!0);i.el.playsinline=!0,i.el.style.display="inline-block",i.el.classList.add("atonVRCvidStream"),i.el.classList.add("atonVRCu"+o%6),t&&(i.el.onclick=t),i.el.srcObject=e},stopAllStreams:()=>{w.stopAudioStreaming(),w.stopCameraStreaming(),w.stopScreenStreaming()},getOrCreateVideoStream:(e,t,o)=>{if(w._vStreams[e])t&&(w._vStreams[e].el.src=t);else{w._vStreams[e]={};let i="vStream-"+e;if(o&&(i="uStream"+e,w._vStreams[e].uid=e),$("").appendTo("body"),w._vStreams[e].el=document.getElementById(i),t)if(t.endsWith("m3u8"))if(Hls.isSupported()){let o=new Hls;o.loadSource(t),o.attachMedia(w._vStreams[e].el)}else w._vStreams[e].el.src=t;else w._vStreams[e].el.src=t;o||(w._vStreams[e].el.loop=!0),w._vStreams[e].texStream=new THREE.VideoTexture(w._vStreams[e].el),w._vStreams[e].texStream.colorSpace=ATON._stdEncoding,w._vStreams[e].texStream.flipY=!1,w._vStreams[e].matStream=ATON.MatHub.materials.chromakey.clone(),w._vStreams[e].matStream.uniforms.tBase.value=w._vStreams[e].texStream}return w._vStreams[e]},getVideoStream:e=>w._vStreams[e],downloadVideoSnapshot:(e,t,o)=>{o||(o=1);let i=e.videoWidth*o,r=e.videoHeight*o,a=document.createElement("canvas");a.width=i,a.height=r,a.getContext("2d").drawImage(e,0,0,i,r),ATON.Utils.downloadImageFromCanvas(a,t)}};const M=w;let L={EARTH_R_KM:6371};L.EARTH_D_KM=2*L.EARTH_R_KM,L.init=()=>{L._bActive=!1,L._wpid=void 0,L._currGeoPos=new THREE.Vector2,L._GeoPOIs=[],L._currGeoPOI=void 0,L._closestGeoPOI=void 0,L._maxGeoError=40},L.enableGeoTracking=()=>{L._bActive||ATON.Utils.isConnectionSecure()&&navigator.geolocation&&(L._wpid=navigator.geolocation.watchPosition(L._onGeoPosition,L._onGeoError,{enableHighAccuracy:!0}),L._bActive=!0)},L.disableGeoTracking=()=>{L._bActive&&(navigator.geolocation.clearWatch(L._wpid),L._bActive=!1)},L.setMaxGeoError=e=>{e>0&&(L._maxGeoError=e)},L._onGeoError=()=>{console.log("Geolocation error")},L._onGeoPosition=e=>{if(!L._bActive)return;if(!e.coords)return;let t=e.coords.accuracy;t&&t>L._maxGeoError||(L._currGeoPos.x=e.coords.latitude,L._currGeoPos.y=e.coords.longitude,ATON.fire("GeoLocation",e),L._handleGeoPOIs())},L._handleGeoPOIs=()=>{let e=L._GeoPOIs.length;if(!(e<=0)){L._closestGeoPOIdist=void 0,L._closestGeoPOI=void 0;for(let t=0;t{if(L._bActive)return L._currGeoPos},L.geolocationFromLatLon=(e,t)=>new THREE.Vector2(e,t),L.geodistance_orig=(e,t)=>{let o=ATON.DEG2RAD*(t.x-e.x),i=ATON.DEG2RAD*(t.y-e.y),r=Math.sin(o/2)*Math.sin(o/2)+Math.cos(ATON.DEG2RAD*e.x)*Math.cos(ATON.DEG2RAD*t.x)*Math.sin(i/2)*Math.sin(i/2),a=2*Math.atan2(Math.sqrt(r),Math.sqrt(1-r));return L.EARTH_R_KM*a*1e3},L.geodistance=(e,t)=>{let o=.5-Math.cos((t.x-e.x)*ATON.DEG2RAD)/2+Math.cos(e.x*ATON.DEG2RAD)*Math.cos(t.x*ATON.DEG2RAD)*(1-Math.cos((t.y-e.y)*ATON.DEG2RAD))/2;return L.EARTH_D_KM*Math.asin(Math.sqrt(o))*1e3},L.addGeoPOI=(e,t)=>{let o={};return o.pos=new THREE.Vector2(e.x,e.y),o.radius=t,L._GeoPOIs.push(o),L._bActive||L.enableTracking(),L._handleGeoPOIs(),L._GeoPOIs.length-1},L.getGeoPOIbyIndex=e=>L._GeoPOIs[e],L.getClosestGeoPOI=()=>L._closestGeoPOI,L.getClosestGeoPOIdistance=()=>L._closestGeoPOIdist;const C=L;let H={};H._id=$("meta[name='aton\\:appid']").attr("content"),H._data={},H.setup=void 0,H.update=void 0,H._bRunning=!1,H._pDeps=[],H._fLoading=0,H._sendDataPatch=(e,t,o)=>new Promise(((i,r)=>{if(void 0===e)return void r("No storage ID specified");if(e.length<3)return void r("Storage ID too short");if(void 0===t)return void r("No storage patch");if(void 0===H._id)return void r("No app-ID");void 0===o&&(o=ATON.PATCH_ADD);let a={};a.wappid=H._id,a.fid=e,a.data=t,a.mode=o===ATON.PATCH_DEL?"DEL":"ADD";let n=JSON.stringify(a);$.ajax({url:ATON.PATH_RESTAPI+"patch/wapp",type:"POST",data:n,contentType:"application/json; charset=utf-8",dataType:"json",success:t=>{void 0!==t?(H._data[e]=t,i(t)):r("Error writing on server")}})})),H.getAppID=()=>H._id,H.addToStorage=(e,t)=>H._sendDataPatch(e,t,ATON.PATCH_ADD),H.deleteFromStorage=(e,t)=>H._sendDataPatch(e,t,ATON.PATCH_DEL),H.getStorage=e=>new Promise(((t,o)=>{void 0!==H._id?void 0!==e?$.getJSON(ATON.PATH_WAPPS+H._id+"/data/"+e+".json",(o=>{console.log(o),H._data[e]=o,t(o)})):o("No storage ID specified"):o()})),H.loadJSONConfig=(e,t)=>(ATON.Utils.getJSON(e,t),H),H.registerServiceWorker=e=>{if(e)return H.basePath&&(e=H.basePath+e),"serviceWorker"in navigator&&window.addEventListener("load",(()=>{navigator.serviceWorker.register(e).then((e=>console.log("PWA service worker registered"))).catch((e=>console.log("PWA service worker not registered",e)))})),H},H.requireFlares=e=>{if(e)return ATON._fReqList=e,console.log("Required Flares: "+ATON._fReqList),H},H.loadScene=(e,t)=>{void 0!==e&&ATON.SceneHub.load(ATON.PATH_RESTAPI2+"scenes/"+e,e,t)},H.realize=(e,t,o)=>{H.setup=e,H.update=t,H.params=new URLSearchParams(window.location.search),H.basePath=ATON.Utils.getBaseFolder(window.location.href.split("?")[0]),H.registerServiceWorker(o);let i=H.params.get("ff");if(i){let e=String(i).split(",");H.requireFlares(e)}return H},H.realizeAndRun=(e,t,o)=>{H.realize(e,t,o).run()},H.run=()=>!H._bRunning&&(H._bRunning=!0,H.setup?H.setup():(ATON.FE.realize(),console.log("App [Warn]: your App should define a setup() routine")),H.update&&(ATON.addUpdateRoutine(H.update),console.log("App: update routine registered")),ATON._fRequired<=0&&ATON.fire("AllFlaresReady"),!0);const D=H;let x={PASS_BASE:"p_base",PASS_AA:"p_aa",PASS_AO:"p_ao",PASS_SSR:"p_ssr",PASS_BLOOM:"p_bloom",PASS_DOF:"p_dof",PASS_GAMMA:"p_gamma",PASS_SOBEL:"p_sobel",init:()=>{if(void 0===ATON._renderer)return;let e=ATON._renderer.getPixelRatio(),t=ATON._renderer.getSize(new THREE.Vector2);const o=new THREE.WebGLRenderTarget(t.width*e,t.height*e,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat,colorSpace:ATON._stdEncoding});o.texture.name="EffectComposer.rt1",x.composer=new THREE.EffectComposer(ATON._renderer,o),x.passes={},ATON._renderer.autoClear=!1;let i=window.innerWidth*ATON._stdpxd,r=window.innerHeight*ATON._stdpxd;x.passes[x.PASS_BASE]=new THREE.RenderPass(ATON._mainRoot,ATON.Nav._camera),x.composer.addPass(x.passes[x.PASS_BASE]),x.passes[x.PASS_AO]=new THREE.SAOPass(ATON._mainRoot,ATON.Nav._camera,i,r),x.passes[x.PASS_AO].params.saoBias=1,x.passes[x.PASS_AO].params.saoScale=100,x.passes[x.PASS_AO].params.saoIntensity=.2,x.passes[x.PASS_BLOOM]=new THREE.UnrealBloomPass(new THREE.Vector2(i,r),1.5,.4,.85),x.passes[x.PASS_BLOOM].threshold=.9,x.passes[x.PASS_BLOOM].strength=1,x.passes[x.PASS_BLOOM].radius=1.2,x.passes[x.PASS_DOF]=new THREE.BokehPass(ATON._mainRoot,ATON.Nav._camera,{focus:5,aperture:.001,maxblur:.01,width:i,height:r}),x.composer.addPass(x.passes[x.PASS_AO]),x.composer.addPass(x.passes[x.PASS_DOF]),x.composer.addPass(x.passes[x.PASS_BLOOM]),x.togglePass(x.PASS_AO,!1),x.togglePass(x.PASS_BLOOM,!1),x.togglePass(x.PASS_DOF,!1)},togglePass:(e,t)=>{void 0!==x.composer&&(ATON.device.lowGPU||void 0!==x.passes[e]&&(x.passes[e].enabled=void 0===t?!x.passes[e].enabled:t))},isPassEnabled:e=>void 0!==x.composer&&(void 0!==x.passes[e]&&x.passes[e].enabled),setAOintensity:e=>{void 0!==x.composer&&void 0!==x.passes[x.PASS_AO]&&(x.passes[x.PASS_AO].params.saoIntensity=e)},getAOintensity:()=>void 0===x.composer||void 0===x.passes[x.PASS_AO]?0:x.passes[x.PASS_AO].params.saoIntensity,setBloomStrength:e=>{void 0!==x.composer&&void 0!==x.passes[x.PASS_BLOOM]&&(x.passes[x.PASS_BLOOM].strength=e)},getBloomStrength:()=>void 0===x.composer||void 0===x.passes[x.PASS_BLOOM]?0:x.passes[x.PASS_BLOOM].strength,setBloomThreshold:e=>{void 0!==x.composer&&void 0!==x.passes[x.PASS_BLOOM]&&(x.passes[x.PASS_BLOOM].threshold=e)},getBloomThreshold:()=>void 0===x.composer||void 0===x.passes[x.PASS_BLOOM]?0:x.passes[x.PASS_BLOOM].threshold,setDOFfocus:e=>{if(void 0===x.composer)return;if(void 0===x.passes[x.PASS_DOF])return;let t=x.passes[x.PASS_DOF].uniforms;void 0!==t&&(t.focus.value=e)},getDOFfocus:()=>{if(void 0===x.composer)return 0;if(void 0===x.passes[x.PASS_DOF])return 0;let e=x.passes[x.PASS_DOF].uniforms;return void 0===e?0:e.focus.value},setDOFaperture:e=>{if(void 0===x.composer)return;if(void 0===x.passes[x.PASS_DOF])return;let t=x.passes[x.PASS_DOF].uniforms;void 0!==t&&(t.aperture.value=e)}};const F=x;let V={STD_XPF_TRANSITION_DURATION:1,SEM_PREFIX:"XPF",SEMGROUP_PREFIX:"GXPF",init:()=>{V._list=[],V._iCurr=void 0,V._iNext=void 0,V._geom=void 0,V._mesh=void 0,V._mat=void 0,V._size=50,V._gSem=[],V._semIMGMasks={},V._semCanvas=void 0,V._semCTX=void 0,V._semCurr=void 0,V._shColor=new THREE.Color(0,0,1),V._shOpacity=.2,V._txCache={},V._pathMod=void 0,V._realizeBaseMat(),V._elVid=void 0,V._vidPlaying=!1},_realizeBaseMat:()=>{V._uniforms={tBase:{type:"t"},tSem:{type:"t"},tSemHint:{type:"t"},semHL:{type:"vec4",value:new THREE.Vector4(0,1,0,.15)},opacity:{type:"float",value:1},shColor:{type:"vec4",value:new THREE.Vector4(0,0,1,.2)},time:{type:"float",value:0}},V._mat=new THREE.ShaderMaterial({uniforms:V._uniforms,vertexShader:"\n varying vec3 vPositionW;\n varying vec3 vNormalW;\n varying vec3 vNormalV;\n varying vec2 vUv;\n\n void main(){\n vUv = uv;\n\n vPositionW = vec3( vec4( position, 1.0 ) * modelMatrix);\n vNormalW = normalize( vec3( vec4( normal, 0.0 ) * modelMatrix ) );\n vNormalV = normalize( vec3( normalMatrix * normal ));\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }\n ",fragmentShader:"\n varying vec3 vPositionW;\n\t\t varying vec3 vNormalW;\n varying vec3 vNormalV;\n varying vec2 vUv;\n\n uniform float time;\n uniform sampler2D tBase;\n uniform sampler2D tSem;\n uniform sampler2D tSemHint;\n //uniform sampler2D tDepth;\n\n uniform vec4 semHL, shColor;\n uniform float opacity;\n\n\t\t void main(){\n vec4 frag = texture2D(tBase, vUv);\n vec4 sem = texture2D(tSem, vUv);\n vec4 semH = texture2D(tSemHint, vUv);\n float shv = max( max(semH.r,semH.g), semH.b);\n\n float t = (1.0 * cos(time*2.0));\n t = clamp(t, 0.0,1.0);\n\n frag = mix(frag, semHL, (sem.r * semHL.a));\n\n frag = mix(frag, shColor, (t * shv * shColor.a));\n\n frag.a = opacity;\n\n gl_FragColor = frag;\n\t\t }\n ",depthTest:!1,depthWrite:!1}),V.setSemanticHintMapOpacity(.2)},setPathModifier:e=>{if(void 0!==e){V._pathMod=e;for(let t in V.list)V.list[t].setPathModifier(e)}},update:()=>{if(ATON.Nav.isTransitioning())return;if(V._list.length<1)return;let e,t,o,i,r=V._list.length,a=ATON.Nav._currPOV.pos,n=ATON.Nav._vDir;V._uniforms.time.value+=ATON._dt,void 0===V._dirLNode&&(V._dirLNode=new THREE.Vector3);for(let s=0;s.8&&(void 0===o||l{void 0===V._geom&&(V._group=new THREE.Group,ATON._rootVisibleGlobal.add(V._group),V._geom=new THREE.SphereGeometry(1,40,40),V._geom.scale(-V._size,V._size,V._size),V._geom.castShadow=!1,V._geom.receiveShadow=!1,V._mesh=new THREE.Mesh(V._geom,V._mat),V._mesh.frustumCulled=!1,V._mesh.renderOrder=-100,V._mesh.layers.enable(ATON.NTYPES.SCENE),V._group.add(V._mesh),V._mesh.visible=!1)},setBaseGeometry:e=>{},add:e=>{if(void 0===e)return;V.realizeBaseGeometry();let t=V._list.length;V._list.push(e);let o=e.getMesh();o&&V._group.add(o);let i=ATON.getOrCreateSemanticNode(V.SEMGROUP_PREFIX+t);V._gSem.push(i),i.attachToRoot(),t>0||(ATON.Nav.toggleLocomotionValidator(!1),ATON._bqScene=!0)},clear:()=>{V._iCurr=void 0,V._iNext=void 0,V._semCurr=void 0;for(let e=0;eV._list.length,getMainGroup:()=>V._group,getSemanticGroup:e=>V._gSem[e],getCurrentSemanticGroup:()=>{if(void 0!==V._iCurr)return V._gSem[V._iCurr]},_preloadBaseLayer:(e,t)=>{if(void 0!==V._txCache[e])return V._txCache[e];let o=V._list[e]._pathbaselayer;V._pathMod&&(o=V._pathMod(o)),ATON.Utils.textureLoader.load(o,(o=>{o.colorSpace=ATON._stdEncoding,o.generateMipmaps=!0,V._txCache[e]=o,t&&t(o)}))},_clearTexCache:()=>{if(void 0!==V._iCurr)for(let e in V._txCache)V._txCache[e]&&e!==V._iCurr&&(V._txCache[e].dispose(),V._txCache[e]=void 0)},_setBaseLayerTexture:(e,t)=>{V._mat.map=t,V._mat.needsUpdate=!0,V._mesh.position.copy(e.getLocation()),V._mesh.rotation.set(e.getRotation().x,e.getRotation().y,e.getRotation().z)},updateCurrentXPFbaseLayer:e=>{if(void 0===V._iCurr)return;let t=V._list[V._iCurr];if(void 0===t)return;let o=t._pathbaselayer;if(V._pathMod&&(o=V._pathMod(o)),ATON.Utils.isVideo(o)){if(void 0===V._elVid){let e="",$(e).appendTo("body"),V._elVid=document.getElementById("idXPFVideo"),V._elVid.onplaying=()=>{console.log("XPF VideoPano playing"),V._vidPlaying=!0},V._elVid.onpause=()=>{console.log("XPF VideoPano paused"),V._vidPlaying=!1},V._elVid.addEventListener("touchstart",(function(){V._elVid.play()})),enableInlineVideo(V._elVid)}let i=new THREE.VideoTexture(V._elVid);return i.colorSpace=ATON._stdEncoding,V._mat.map=i,V._mat.needsUpdate=!0,V._uniforms.tBase.value=i,V._mesh.position.copy(t.getLocation()),V._mesh.rotation.set(t.getRotation().x,t.getRotation().y,t.getRotation().z),void(e&&e(i))}ATON.Utils.textureLoader.load(o,(o=>{o.colorSpace=ATON._stdEncoding,o.generateMipmaps=!0,V._mat.map=o,V._mat.needsUpdate=!0,V._uniforms.tBase.value=o,V._mesh.position.copy(t.getLocation()),V._mesh.rotation.set(t.getRotation().x,t.getRotation().y,t.getRotation().z),e&&e(o)}))},playOrPauseXPFVideoStream:()=>{void 0!==V._elVid&&(V._vidPlaying?V._elVid.pause():V._elVid.play())},updateCurrentXPFsemLayer:e=>{let t=V._list.indexOf(e);t<0||t===V._iCurr&&V.loadSemanticMasksIfAny(V._iCurr)},setCurrentXPF:(e,t)=>{V.toggleSUI(e,!1),V._iCurr=e,V._iNext=void 0,V._mesh.visible=!0,V._gSem[e].show(),V.updateCurrentXPFbaseLayer(t),ATON.fire("CurrentXPF",e),ATON.fire("NextXPF",void 0),V.loadSemanticMasksIfAny(e)},toggleSUI:(e,t)=>{if(void 0===e)return;let o=V._list[e];void 0!==o&&o._lnode.toggleSUI(t)},loadSemanticMasksIfAny:e=>{let t=V._list[e];if(void 0!==t){V._semIMGMasks={},V._uniforms.tSemHint.value=0,void 0!==t._semHintURL&&(V._uniforms.tSemHint.value=ATON.Utils.textureLoader.load(t._semHintURL));for(let e in t._semMasksURLs){void 0===V._semCanvas&&(V._semCanvas=document.createElement("canvas"),V._semCanvas.width=2048,V._semCanvas.height=2048,V._semCTX=V._semCanvas.getContext("2d",{willReadFrequently:!0}));let o=t._semMasksURLs[e],i=new Image;i.src=o,V._semIMGMasks[e]=i}}},getXPFbyIndex:e=>V._list[e],getCurrentXPFindex:()=>V._iCurr,getCurrentXPF:()=>{if(void 0!==V._iCurr)return V._list[V._iCurr]},getNextXPFindex:()=>V._iNext,getNextXPF:()=>{if(void 0!==V._iNext)return V._list[V._iNext]},getDistanceToXPFindex:e=>{if(void 0===e)return;let t=V._list[e];return void 0!==t?ATON.Nav._currPOV.pos.distanceTo(t.getLocation()):void 0},showSUIonlyForXPF:e=>{let t=V._list.length;if(!(t<1))for(let o=0;o{let o=V._list[e];void 0!==o&&(void 0===t&&(t=V.STD_XPF_TRANSITION_DURATION),ATON.XR._bPresenting&&(t=0),V.setCurrentXPF(e),ATON.Nav.requestTransitionToLocomotionNode(o.getLocomotionNode(),t))},requestTransitionToTarget:(e,t,o)=>{if(void 0===e)return;let i=new ATON.POV;i.setTarget(e),i.setPosition(ATON.Nav._currPOV.pos),t&&i.setFOV(t),ATON.Nav.requestPOV(i,o)},requestTransitionToDirection:(e,t,o)=>{if(void 0===e)return;let i=new THREE.Vector3;i.x=e.x+ATON.Nav._currPOV.pos.x,i.y=e.y+ATON.Nav._currPOV.pos.y,i.z=e.z+ATON.Nav._currPOV.pos.z,V.requestTransitionToTarget(i,t,o)},setHomeXPF:e=>{let t=V._list[e];if(void 0===t)return;let o=t.getLocomotionNode(),i=(new ATON.POV).setPosition(o.pos).setTarget(o.pos.x,o.pos.y,o.pos.z+1);ATON.Nav.setHomePOV(i)},getSemanticMaskURLfromXPFindex:(e,t)=>{let o=V._list[e];if(void 0!==o)return o.getSemanticMaskURL(t)},getSemanticMaskURLfromCurrentXPF:e=>{if(void 0!==V._iCurr)return V.getSemanticMaskURLfromXPFindex(V._iCurr,e)},setSemanticColor:(e,t)=>{void 0===t&&(t=.15),V._uniforms.semHL.value=new THREE.Vector4(e.r,e.g,e.b,t)},setSemanticOpacity:e=>{void 0===e&&(e=.15),V._uniforms.semHL.value.w=e},setSemanticHintMapOpacity:e=>{void 0===e&&(e=.2),V._shOpacity=e,V._uniforms.shColor.value.w=e},setSemanticHintMapColor:(e,t)=>{void 0!==e&&(V._shColor=e,V._uniforms.shColor.value.x=e.r,V._uniforms.shColor.value.y=e.g,V._uniforms.shColor.value.z=e.b,void 0!==t&&V.setSemanticHintMapOpacity(t))},querySemanticMasks:()=>{if(void 0===V._semCTX)return;if(void 0===ATON._queryDataScene)return;if(void 0===ATON._queryDataScene.uv)return;let e,t=V._semCTX,o=ATON._queryDataScene.uv;for(let i in V._semIMGMasks){let r=V._semIMGMasks[i],a=parseInt(r.width*o.x),n=parseInt(r.height*(1-o.y));if(t.drawImage(r,0,0),t.getImageData(a,n,1,1).data[0]>127){e=i;break}}if(void 0===e)return void 0!==V._semCurr&&ATON.fire("SemanticMaskLeave",V._semCurr),V._semCurr=void 0,V._uniforms.tSem.value=0,V._uniforms.shColor.value.w=V._shOpacity,void(V._mat.needsUpdate=!0);V.highlightSemanticMaskInCurrentXPF(e),V._semCurr=e},highlightSemanticMaskInCurrentXPF:e=>{if(void 0===e)return void 0!==V._semCurr&&ATON.fire("SemanticMaskLeave",V._semCurr),V._semCurr=void 0,V._uniforms.tSem.value=0,V._uniforms.shColor.value.w=V._shOpacity,void(V._mat.needsUpdate=!0);if(V._semCurr===e)return;let t=V.getSemanticMaskURLfromCurrentXPF(e);V._uniforms.tSem.value=ATON.Utils.textureLoader.load(t),V._mat.needsUpdate=!0,ATON.fire("SemanticMaskHover",e),V._uniforms.shColor.value.w=0,void 0!==V._semCurr&&ATON.fire("SemanticMaskLeave",V._semCurr)},loadFromPhotoscanFile:(e,t)=>{if(void 0===e)return;e=ATON.Utils.resolveCollectionURL(e);let o=ATON.Utils.getBaseFolder(e),i=0;$.ajax({url:e,dataType:"text",success:function(e){e=e.split(/\r\n|\n/);for(let t in e){let r=e[t];if(!r.startsWith("#")){let e=r.split(/\s{2,}|\t/);if(e.length>10){let t=new ATON.XPF,r=o+e[0],a=parseFloat(e[1]),n=parseFloat(e[2]),s=parseFloat(e[3]),l=ATON.DEG2RAD*parseFloat(e[4]);ATON.DEG2RAD,parseFloat(e[5]),ATON.DEG2RAD,parseFloat(e[6]),t.setLocation(a,s,-n),t.setBaseLayer(r),t.setRotation(0,-l,0),V.add(t),i++}}}console.log("Num panoramas parsed: "+i),t&&t()}})}};const I=V;let U={init:()=>{U.list=[]},anyCopyrightFound:()=>U.list.length>0,extract:e=>{if(void 0===e)return;if(void 0===e.asset)return;let t={};if(e.asset.copyright&&(t.copyright=e.asset.copyright),e.asset.extras)for(let o in e.asset.extras)"string"==typeof e.asset.extras[o]&&(t[o]=e.asset.extras[o]);if(U.extractXMP3DC(e,t),0!==Object.keys(t).length){e.asset.generator&&(t.generator=e.asset.generator);for(let e in U.list){let o=U.list[e];if(U.compare(t,o))return}U.list.push(t),console.log(t)}},compare:(e,t)=>{if(void 0===e||void 0===t)return!1;const o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return!1;for(let i of o)if(e[i]!==t[i])return!1;return!0},extractXMP3DC:(e,t)=>{if(void 0===e||void 0===t)return;if(!e.userData)return;let o=e.userData.gltfExtensions;if(!o)return;if(!o.KHR_xmp)return;let i=o.KHR_xmp.packets;if(!i)return;let r=i[0],a="en-us";r["model3d:spdxLicense"]&&(t.license=r["model3d:spdxLicense"]),r["dc:date"]&&(t.date=r["dc:date"]),r["dc:title"]&&(t.title=r["dc:title"][a]),r["dc:description"]&&(t.description=r["dc:description"][a]),r["dc:rights"]&&(t.rights=r["dc:rights"][a]),r["dc:source"]&&(t.source=r["dc:source"]),r["dc:subject"]&&(t.subject=r["dc:subject"]),r["dc:type"]&&(t.type=r["dc:type"]),r["xmpRights:Owner"]&&(t.owner=r["xmpRights:Owner"]),r["xmp:CreatorTool"]&&(t.creatorTool=r["xmp:CreatorTool"])}};const k=U;let B={REST_API_CESIUMION_DEF_TOKEN:"https://api.cesium.com/v2/tokens/default",THRES_ORI:.01,THRES_POS:1e-6,init:()=>{B._tsets=[],B._tsET=20,B._tsB=!1,B._bTileBVH=!0,B._tsTasks=[],B.tsSchedCB=e=>{B._tsTasks.push(e)},B._tseBase=8,B.estimateTSErrorTarget(),B._tsuSync=0,B._bPCs=!1,B._pqLRU=void 0,B._pqDownload=void 0,B._pqParse=void 0,B._numTilesLoaded=0,B._numTSLoaded=0},clear:()=>{for(let e in B._tsets)B._tsets[e]=null;B._tsets=[],B._bPCs=!1},getTSetsErrorTarget:()=>B._tsET,setTSetsErrorTarget:e=>{B._tsET=e;const t=B._tsets.length;if(!(t<=0))for(let o=0;o{B._tsB=e;const t=B._tsets.length;if(!(t<=0))for(let o=0;o{void 0===e&&(e=ATON.Nav._camera);const t=B._tsets.length;if(!(t<=0))for(let o=0;o{B._tseBase=e,console.log(B._tseBase),B.estimateTSErrorTarget()},estimateTSErrorTarget:()=>{let e=B._tseBase;(ATON.device.lowGPU||ATON.device.isMobile)&&(e+=4),ATON.XR._bPresenting&&(e+=3),e<1&&(e=1),e>25&&(e=25),console.log("Estimated TSet error target: "+e),B.setTSetsErrorTarget(e)},loadTileSetFromURL:(e,t,o)=>{if(void 0===t)return;let i=new TILES.TilesRenderer(e);if(!i)return;ATON._assetReqNew(e),i.displayBoxBounds=B._tsB,i.fetchOptions.mode="cors",i.registerPlugin(new TILES.ImplicitTilingPlugin),o&&(i.fetchOptions.headers={},i.fetchOptions.headers.Authorization=`Bearer ${o.accessToken}`,i.preprocessURL=e=>(e=new URL(e),/^http/.test(e.protocol)&&e.searchParams.append("v",o.v),e.toString())),i.errorTarget=B._tsET,i.optimizeRaycast=!1,void 0===B._pqLRU?(i.downloadQueue.schedulingCallback=B.tsSchedCB,i.parseQueue.schedulingCallback=B.tsSchedCB,i.downloadQueue.maxJobs=6,i.parseQueue.maxJobs=1,B._pqLRU=i.lruCache,B._pqDownload=i.downloadQueue,B._pqParse=i.parseQueue):(i.lruCache=B._pqLRU,i.downloadQueue=B._pqDownload,i.parseQueue=B._pqParse),i.setCamera(ATON.Nav._camera),i.setResolutionFromRenderer(ATON.Nav._camera,ATON._renderer),i.manager.addHandler(/\.gltf$/,ATON._aLoader),i.manager.addHandler(/\.ktx2$/,ATON._ktx2Loader),i.manager.addHandler(/\.drc$/,ATON._dracoLoader),t.add(i.group),$.getJSON(e,(e=>{ATON.CC.extract(e)}));let r=new THREE.Box3,a=new THREE.Sphere;new THREE.Matrix4,new THREE.Vector3;let n=!1;i.addEventListener("load-tile-set",(()=>{if(console.log("TileSet loaded"),ATON._assetReqComplete(e),B._numTSLoaded++,o||t.bUseGeoCoords){console.log("TileSet using GeoCoords"),i.getBoundingSphere(a);const e=a.center.clone(),t=e.length(),o=e.normalize(),r=new THREE.Vector3(0,1,0),n=ATON.Utils.rotationBetweenDirections(o,r);i.group.quaternion.x=n.x,i.group.quaternion.y=n.y,i.group.quaternion.z=n.z,i.group.quaternion.w=n.w,i.group.position.y=-t}else i.getBoundingBox(r)?(r.getBoundingSphere(a),t.autocenter?(r.getCenter(i.group.position),i.group.position.multiplyScalar(-1)):void 0===ATON.Nav.homePOV&&ATON.Nav.computeAndRequestDefaultHome(.5,void 0,a)):i.getBoundingSphere(a)&&(t.autocenter?(i.group.position.copy(a.center),i.group.position.multiplyScalar(-1)):void 0===ATON.Nav.homePOV&&ATON.Nav.computeAndRequestDefaultHome(.5,void 0,a));ATON.Utils._visitorCP(i.group)})),i.addEventListener("load-model",(e=>{let o=e.scene;B._numTilesLoaded++,o.traverse((e=>{if(e.layers.enable(t.type),e.isMesh?(e.castShadow=!0,e.receiveShadow=!0,B._bTileBVH&&e.geometry&&(e.geometry.computeVertexNormals(),e.geometry.computeBoundsTree({}),ATON.Utils._bvhBounds>0&&ATON.Utils._addBVHbounds(e,ATON.Utils._bvhBounds)),ATON._bqScene=!0):(n=!0,B._bPCs=!0,e.layers.disable(t.type),e.raycast=ATON.Utils.VOID_CAST,e.material=ATON.MatHub.materials.point),t.userData.cMat&&(e.material=t.userData.cMat),e.material){let t=e.material.map;t&&(t.minFilter=THREE.LinearMipmapLinearFilter,t.magFilter=THREE.LinearFilter,t.colorSpace=ATON._stdEncoding)}})),ATON.fire("TileLoaded",o),ATON.Utils._visitorCP(o)})),i.addEventListener("dispose-model",((e,t)=>{ATON.Utils.cleanupVisitor(e.scene),e=null})),n||ATON.Utils.setPicking(t,t.type,!0),B._tsets.push(i)},loadCesiumIONAsset:(e,t)=>{let o=ATON.getAPIToken("cesium.ion");if(null==o&&(console.log("A valid Cesium ION token is required"),o=prompt("Please enter a valid Cesium ION token:"),null==o||""==o))return;let i=new URL(`https://api.cesium.com/v1/assets/${e}/endpoint`);i.searchParams.append("access_token",o),fetch(i,{mode:"cors"}).then((e=>e.ok?e.json():Promise.reject(`${e.status} : ${e.statusText}`))).then((e=>{i=new URL(e.url);const r=i.searchParams.get("v");B.loadTileSetFromURL(i.toString(),t,{accessToken:e.accessToken,v:r}),ATON.setAPIToken("cesium.ion",o)}))},update:()=>{const e=B._tsets.length;if(e<1)return;for(let t=0;t!!ATON.Nav._bControl&&(ATON.Nav._dOri>B.THRES_ORI||ATON.Nav._dPos>B.THRES_POS)};const q=B;let z={DELIM_CSV:",",DELIM_TSV:"\t",init:()=>{},loadTextFromURL:(e,t)=>($.get(e,(e=>{t&&t(e)})),z),loadValuesFromFile:(e,t,o,i)=>{let r={};void 0===o&&(o=-1),$.get(e,(e=>{let a=e.split("\n"),n=a.length,s=[],l=!1;for(let e=0;e0)if(l){let a=i.split(t),n=o>=0?a[o]:e;r[n]={};for(let e=0;e{z.loadValuesFromFile(e,z.DELIM_CSV,t,o)},loadTSV:(e,t,o)=>{z.loadValuesFromFile(e,z.DELIM_TSV,t,o)}};const X=z;let G={init:()=>{G._base=ATON.PATH_RESTAPI2},setBaseDomain:e=>e.startsWith("http")?(G._base=e,G):G,get:(e,t,o)=>(e.startsWith("http")||(e=G._base+e),fetch(e,{credentials:"include"}).then((e=>{e.ok?e.json().then(t).catch((e=>{console.log("ERROR: "+e),o&&o(e)})):o&&o()})),G),post:(e,t,o,i)=>(e.startsWith("http")||(e=G._base+e),fetch(e,{method:"POST",body:JSON.stringify(t),credentials:"include",headers:{"Content-type":"application/json; charset=UTF-8"}}).then((e=>{e.ok?e.json().then(o).catch((e=>{console.log("ERROR: "+e),i&&i(e)})):i&&i()})),G),put:(e,t,o,i)=>(e.startsWith("http")||(e=G._base+e),fetch(e,{method:"PUT",body:JSON.stringify(t),credentials:"include",headers:{"Content-type":"application/json; charset=UTF-8"}}).then((e=>{e.ok?e.json().then(o).catch((e=>{console.log("ERROR: "+e),i&&i(e)})):i&&i()})),G),patch:(e,t,o,i)=>(e.startsWith("http")||(e=G._base+e),fetch(e,{method:"PATCH",body:JSON.stringify(t),credentials:"include",headers:{"Content-type":"application/json; charset=UTF-8"}}).then((e=>{e.ok?e.json().then(o).catch((e=>{console.log("ERROR: "+e),i&&i(e)})):i&&i()})),G),delete:(e,t,o)=>(e.startsWith("http")||(e=G._base+e),fetch(e,{method:"DELETE",credentials:"include"}).then((e=>{e.ok?e.json().then(t).catch((e=>{console.log("ERROR: "+e),o&&o(e)})):o&&o()})),G),login:(e,t,o,i)=>G.post("login",{username:e,password:t},(e=>{e&&o?o(e):i&&i()}),(e=>{i&&i()})),logout:(e,t)=>G.get("logout",e,t)};const W=G;let j={};window.ATON=j,j.Node=t,j.POV=class{constructor(e){this.pos=new THREE.Vector3(1,0,0),this.target=new THREE.Vector3(0,0,0),this.up=ATON.STD_UPVECTOR,this.fov=void 0,this.nextPOV=void 0,this.prevPOV=void 0,this.as(e)}as(e){if(void 0!==e)return ATON.Nav.povlist[e]=this,this.id=e,this}setPosition(e,t,o){return e instanceof THREE.Vector3?this.pos.copy(e):this.pos.set(e,t,o),this}setTarget(e,t,o){return e instanceof THREE.Vector3?this.target.copy(e):this.target.set(e,t,o),this}setFOV(e){return this.fov=e,this}addKeywords(e){let t=e.split(",");void 0===this.kwords&&(this.kwords={});for(let e in t){let o=t[e].trim();o.length>0&&(this.kwords[o]=!0)}return this}hasKeyword(e){if(void 0!==this.kwords)return void 0!==this.kwords[e]}setNextPOV(e){if(e)return this.nextPOV=e,this}setPrevPOV(e){if(e)return this.prevPOV=e,this}},j.LightProbe=class{constructor(e,t,o){this.pos=new THREE.Vector3(0,0,0),this._res=void 0!==e?e:128,this._near=void 0!==t?t:1,this._far=void 0!==o?o:ATON.Nav.STD_FAR,this._envtex=void 0,this._CC=void 0,void 0===ATON._pmremGenerator&&(ATON._pmremGenerator=new THREE.PMREMGenerator(ATON._renderer),ATON._pmremGenerator.compileCubemapShader())}setPosition(e,t,o){return e instanceof THREE.Vector3?this.pos.copy(e):this.pos.set(e,t,o),this}setNear(e){return this._near=e,this}setFar(e){return this._far=e,this}_createCCtarget(){this._CCtarget||(this._CCtarget=new THREE.WebGLCubeRenderTarget(this._res,{format:THREE.RGBEFormat,generateMipmaps:!0,minFilter:THREE.LinearMipmapLinearFilter,colorSpace:ATON._stdEncoding}))}update(){return this._envtex&&this._envtex.dispose(),ATON._rootVisibleGlobal.position.set(-this.pos.x,-this.pos.y,-this.pos.z),ATON._render(),this._envtex=ATON._pmremGenerator.fromScene(ATON._mainRoot,0,this._near,this._far).texture,ATON._rootVisibleGlobal.position.set(0,0,0),ATON._renderer.shadowMap.enabled&&ATON._dMainL&&(ATON._dMainL.shadow.needsUpdate=!0),this}getEnvTex(){return this._envtex}assignToNode(e){}},j.XPF=class{constructor(e){this.id=e,this._geom=void 0,this._mesh=void 0,this._pathbaselayer=void 0,this._size=20,this._location=new THREE.Vector3(0,0,0),this._rotation=new THREE.Vector3(0,0,0),this._lnode=ATON.Nav.addLocomotionNode(this._location),this._pathMod=void 0,this._semMasksURLs={},this._semHintURL=void 0}setSize(e){this._size=e}realizeSUI(){return void 0===this._lnode||this._lnode.realizeSUI(),this}realizeGeometry(){return void 0!==this._geom||(this._geom=new THREE.SphereGeometry(1,60,60),this._geom.scale(-this._size,this._size,this._size),this._geom.castShadow=!1,this._geom.receiveShadow=!1,this._mat=new THREE.MeshBasicMaterial({depthTest:!1,depthWrite:!1}),this._mesh=new THREE.Mesh(this._geom,this._mat),this._mesh.frustumCulled=!1,this._mesh.renderOrder=-100),this}getMesh(){return this._mesh}getLocomotionNode(){return this._lnode}setRotation(e,t,o){return e instanceof THREE.Vector3?this._rotation.copy(e):this._rotation.set(e,t,o),void 0===this._mesh||this._mesh.rotation.copy(this._rotation),this}getRotation(){return this._rotation}setLocation(e,t,o){return e instanceof THREE.Vector3?this._location.copy(e):this._location.set(e,t,o),this._lnode&&this._lnode.setLocation(this._location),void 0===this._mesh||this._mesh.position.copy(this._location),this}getLocation(){return this._location}hasGeometry(){return void 0!==this._geom}setPathModifier=e=>(this._pathMod=e,this);updateBaseLayer(){}setBaseLayer(e){if(void 0===e)return this;this._pathbaselayer=ATON.Utils.resolveCollectionURL(e);let t=this;return this._pathMod&&(this._pathbaselayer=this._pathMod(this._pathbaselayer)),this.hasGeometry()?(ATON.Utils.isVideo(this._pathbaselayer)||ATON.Utils.textureLoader.load(t._pathbaselayer,(e=>{e.colorSpace=ATON._stdEncoding,e.generateMipmaps=!0,t._mat.map=e,t._mat.map.needsUpdate=!0,t._mat.needsUpdate=!0,console.log("XPF base layer "+t._pathbaselayer+" loaded")})),this):this}setSemanticMask(e,t){return void 0===e||(this._semMasksURLs[e]=ATON.Utils.resolveCollectionURL(t),ATON.XPFNetwork.updateCurrentXPFsemLayer(this)),this}removeSemanticMask(e){return void 0===e||(this._semMasksURLs[e]=void 0,ATON.XPFNetwork.updateCurrentXPFsemLayer(this)),this}removeAllSemanticMasks(){return this._semMasksURLs={},this}getSemanticMaskURL(e){return this._semMasksURLs[e]}setSemanticHintMap(e){return void 0===e||(this._semHintURL=ATON.Utils.resolveCollectionURL(e),ATON.XPFNetwork.updateCurrentXPFsemLayer(this)),this}removeSemanticHintMap(){return this._semHintURL=void 0,ATON.XPFNetwork.updateCurrentXPFsemLayer(this),this}},j.Flare=class{constructor(e){this._id=void 0,this._bDeployed=!1,e&&this.register(e)}register(e){return e&&(this._id=e),ATON.addFlare(this),this}getID(){return this._id}log(e){return this._id?console.log("[Flare "+this._id+"] "+e):console.log("[Flare]"+e),this}setSetup(e){return this.setup=e,this}setUpdate(e){return this.update=e,this}},j.EventHub=i,j.Utils=s,j.CC=k,j.SceneHub=d,j.MatHub=a,j.Nav=h,j.AudioHub=u,j.XR=v,j.SUI=N,j.UI=A,j.Photon=P,j.SemFactory=E,j.FE=y,j.MediaFlow=M,j.Phygital=C,j.App=D,j.FX=F,j.XPFNetwork=I,j.MRes=q,j.ASCII=X,j.REQ=W,j.STD_UPVECTOR=new THREE.Vector3(0,1,0),j.ROOT_NID=".",j.RAD2DEG=180/Math.PI,j.DEG2RAD=Math.PI/180,j.PATCH_ADD=0,j.PATCH_DEL=1,j.NTYPES={},j.NTYPES.SCENE=3,j.NTYPES.SEM=4,j.NTYPES.UI=5,j.SHADOWS_NEAR=.1,j.SHADOWS_FAR=100,j.SHADOWS_SIZE=50,j.SHADOWS_RES=1024,j.AMB_L=.2,j.SCALE_DEFAULT=0,j.SCALE_BIG=5,j.SCALE_VERYBIG=10,j.SCALE_SMALL=-5,j.SCALE_VERYSMALL=-10,j.Flares={},j._fReqList=[],j._bInitialized=!1,j._b2D=!1,j._resMappers=[],j._clipPlanes=[],j.setBaseURL=e=>{j.BASE_URL=e,j.PATH_RESTAPI=`${j.BASE_URL}/api/`,j.PATH_RESTAPI_SCENE=`${j.PATH_RESTAPI}scene/`,j.PATH_RESTAPI2=`${j.BASE_URL}/api/v2/`,j.PATH_WAPPS=`${j.BASE_URL}/a/`,j.PATH_FLARES=`${j.BASE_URL}/flares/`,j.PATH_DRACO_LIB=`${j.BASE_URL}/dist/draco/`,j.PATH_BASIS_LIB=`${j.BASE_URL}/dist/basis/`,j.PATH_COLLECTION=`${j.BASE_URL}/collections/`,j.PATH_SCENES=`${j.BASE_URL}/scenes/`,j.PATH_RES=`${j.BASE_URL}/res/`,j.PATH_FE=`${j.BASE_URL}/s/`},j.setBaseURL(window.location.origin),j.setPathCollection=e=>{j.PATH_COLLECTION=e},j.setPathScenes=e=>{j.PATH_SCENES=e},j.setAsStandalone=e=>{e||(e="../"),j.PATH_DRACO_LIB=e+"dist/draco/",j.PATH_BASIS_LIB=e+"dist/basis/",j.PATH_RES=e+"res/"},j.addResourceMapper=e=>{j._resMappers.push(e)},j._onUserInteraction=()=>{j._elPanoVideo&&!j._vpanoPlaying&&j._elPanoVideo.play(),j.XPFNetwork._elVid&&!j.XPFNetwork._vidPlaying&&j.XPFNetwork._elVid.play(),j.AudioHub._listener&&j.AudioHub._listener.context&&"suspended"===j.AudioHub._listener.context.state&&j.AudioHub._listener.context.resume();for(let e in j.MediaFlow._vStreams){let t=j.MediaFlow._vStreams[e].el;t.playing||t.uid||t.play()}},j.rewindAllPlayingMedia=()=>{j._elPanoVideo&&(j._elPanoVideo.currentTime=0),j.XPFNetwork._elVid&&(j.XPFNetwork.currentTime=0),j._auMain&&(j._auMain.stop(),j._auMain.play());for(let e in j.MediaFlow._vStreams){let t=j.MediaFlow._vStreams[e].el;t.playing&&!t.uid&&(t.stop(),t.play())}},j.checkAuth=(e,t)=>{j.REQ.get("user",(o=>{o&&e?e(o):t&&t()}),(e=>{t&&t()}))},j._setupBaseListeners=()=>{let e,t,o=j._renderer.domElement;window.addEventListener("resize",j._onResize,!1),window.onorientationchange=j._readDeviceOrientationMode,document.addEventListener("fullscreenchange",(e=>{j._bFS=!!document.fullscreenElement,j.fire("Fullscreen",j._bFS),j._bFS?console.log("Now fullscreen"):console.log("Exit fullscreen")})),void 0!==document.hidden?(e="hidden",t="visibilitychange"):void 0!==document.mozHidden?(e="mozHidden",t="mozvisibilitychange"):void 0!==document.msHidden?(e="msHidden",t="msvisibilitychange"):void 0!==document.webkitHidden&&(e="webkitHidden",t="webkitvisibilitychange"),void 0!==e&&document.addEventListener(t,(()=>{if(document[e]){if(j.XR._bPresenting)return;console.log("Suspend"),j.renderPause()}else{if(j.XR._bPresenting)return;console.log("Resume"),j.renderResume()}}),!1),o.addEventListener("mousemove",j._updateScreenMove,!1),o.addEventListener("mousedown",(e=>{1===e.button&&j.fire("MouseMidButton"),2===e.button&&j.fire("MouseRightButton")})),o.addEventListener("wheel",j._onMouseWheel,!1),j._bPointerDown=!1,Hammer(o).on("doubletap",(e=>{j._bPointerDown=!1,j._onUserInteraction(),j.fire("DoubleTap",e.srcEvent)})),Hammer(o).on("tap",(e=>{if(j._bPointerDown=!1,j._onUserInteraction(),j._updateScreenMove(e.srcEvent),j._handleQueries(),j.fire("Tap",e.srcEvent),void 0===j._hoveredUI)return;let t=j.getUINode(j._hoveredUI);t&&t.onSelect&&t.onSelect()})),j.on("DoubleTap",(e=>{j.defaultDoubleTapFromScreenCoords(e)})),j._kModShift=!1,j._kModCtrl=!1,j._bListenKeyboardEvents=!0,window.addEventListener("keydown",(e=>{j._onUserInteraction(),"Shift"===e.key&&(j._kModShift=!0),"Control"===e.key&&(j._kModCtrl=!0),j._bListenKeyboardEvents&&j.fire("KeyPress",e.key)}),!1),window.addEventListener("keyup",(e=>{"Shift"===e.key&&(j._kModShift=!1),"Control"===e.key&&(j._kModCtrl=!1),j._bListenKeyboardEvents&&j.fire("KeyUp",e.key)}),!1),j.on("KeyPress",(e=>{if("+"===e){let e=j.Nav.getFOV()+1;j.Nav.setFOV(e)}if("-"===e){let e=j.Nav.getFOV()-1;j.Nav.setFOV(e)}}))},j._onResize=()=>{if(j.Nav._camera.aspect=window.innerWidth/window.innerHeight,j.Nav._camera.updateProjectionMatrix(),j._renderer.setSize(window.innerWidth,window.innerHeight),j.FX.composer&&(j.FX.composer.setSize(window.innerWidth,window.innerHeight),j.FX.passes[j.FX.PASS_AA])){let e=j.FX.passes[j.FX.PASS_AA].material.uniforms;e&&e.resolution.value.set(1/window.innerWidth,1/window.innerHeight)}console.log("onResize")},j._onMouseWheel=e=>{e.preventDefault(),j.fire("MouseWheel",e.deltaY)},j.focusOn3DView=()=>{j._renderer.domElement.focus()},j._SUIactivation=()=>{const e=j.getUINode(j._hoveredUI);return void 0!==e&&void 0!==e.onSelect&&(e.onSelect(),!0)},j._stdActivation=()=>{if(j._SUIactivation())return;if(!j.Nav._bControl)return;if(void 0!==j.XPFNetwork._semCurr&&j.fire("SemanticMaskSelect",j.XPFNetwork._semCurr),j.XR._bPresenting){if(h.requestTransitionToLocomotionNodeInSightIfAny(j.XR.STD_TELEP_DURATION))return;return"immersive-vr"===j.XR._sessionType&&j.XR.teleportOnQueriedPoint(),void j.FE.playAudioFromSemanticNode(j._hoveredSemNode)}if(j.Nav.isFirstPerson()||j.Nav.isDevOri()){if(h.requestTransitionToLocomotionNodeInSightIfAny(.5))return;if(j.Nav.currentQueryValidForLocomotion()){let e=j._queryDataScene.p,t=j.Nav._vDir,o=new THREE.Vector3(e.x,e.y+j.userHeight,e.z),i=new THREE.Vector3(o.x+t.x,o.y+t.y,o.z+t.z),r=(new j.POV).setPosition(o).setTarget(i).setFOV(j.Nav._currPOV.fov);j.Nav.requestPOV(r,.5)}return}let e=j.getSemanticNode(j._hoveredSemNode);j._queryDataSem&&e?j.Nav.requestPOVbyNode(e,.5):j._queryDataScene&&j.Nav.requestRetarget(j._queryDataScene.p,void 0,.5)},j.defaultDoubleTapFromScreenCoords=e=>{j._updateScreenMove(e),j._handleQueryScene(),j._stdActivation()},j.isFullscreen=()=>j._bFS,j.toggleFullScreen=()=>{document.fullscreenElement?document.exitFullscreen&&document.exitFullscreen():document.documentElement.requestFullscreen()},j.realize=e=>{console.log("Initialize ATON..."),j.Utils.init(),j.Utils.profileDevice(),j._clock=new THREE.Clock(!0),j.bounds=new THREE.Sphere,j._worldScale=1,j._ws=0,j._bFS=!1,j._renderer=new THREE.WebGLRenderer({antialias:!0,alpha:!0}),j._renderer.setSize(window.innerWidth,window.innerHeight),j.Utils.profileRenderingCapabilities(),j._stdpxd=1,j._fps=60,j._dt=.01,j._dtAccum=0,j._dtCount=0,j._avgFPSaccum=0,j._avgFPS=60,j._dRenderBudgetMinFPS=20,j._dRenderBudgetMaxFPS=55,j._bAdaptiveDensity=!0,j._adMin=.4,j._adMax=1.5,j.device.lowGPU&&(j._adMax=1),j._aniMixers=[],j._stdEncoding=THREE.LinearSRGBColorSpace,j._renderer.outputColorSpace=j._stdEncoding,j._renderer.toneMapping=THREE.LinearToneMapping,j._renderer.toneMappingExposure=1,e||j._renderer.setAnimationLoop(j._onFrame),j._maxAnisotropy=j._renderer.capabilities.getMaxAnisotropy(),j.userHeight=1.7,e||document.body.appendChild(j._renderer.domElement);let t=j._renderer.domElement;t.id="idView3D",t.style.outline="none",t.style.border="none",j.UI.init(),j.REQ.init(),j._vpanoPlaying=!1,j._bUserInts=0,j.EventHub.init(),j.MatHub.init(),j.ASCII.init(),j._assetsManager={},j._aLoader=new THREE.GLTFLoader,j._numReqLoad=0,j._collMod=void 0,j._ktx2Loader=new THREE.KTX2Loader,j._ktx2Loader.setTranscoderPath(j.PATH_BASIS_LIB),j._ktx2Loader.detectSupport(j._renderer),j._dracoLoader=new THREE.DRACOLoader,j._dracoLoader.setDecoderPath(j.PATH_DRACO_LIB),j._dracoLoader.setWorkerLimit(2),j._dracoLoader.preload(),j._aLoader.setDRACOLoader(j._dracoLoader),j._aLoader.setKTX2Loader(j._ktx2Loader),THREE.DefaultLoadingManager.addHandler(/\.ktx2$/,j._ktx2Loader),j._updRoutines=[],j._pmremGenerator=void 0,j._lps=[],j._bAutoLP=!1,j._envMapInt=1,j._numLPbounces=2,j._lpbCount=0,j._bShadowsFixedBound=!1,j._shadowsFixedBoundCenter=void 0,j._shadowsNear=j.SHADOWS_NEAR,j._shadowsFar=j.SHADOWS_FAR,j._shadowsSize=j.SHADOWS_SIZE,j._shadowsRes=j.SHADOWS_RES,j.initGraphs(),j.SceneHub.init(),j.MRes.init(),j.CC.init(),j.AudioHub.init(),j.Nav.init(),j.XR.init(),j.SUI.init(),j.Photon.init(),j.VRoadcast=j.Photon,j.MediaFlow.init(),j.SemFactory.init(),j.Phygital.init(),j.XPFNetwork.init(),j.device.lowGPU||j.device.isMobile||j.FX.init(),j.FX.composer||(j._render=()=>{j._renderer.render(j._mainRoot,j.Nav._camera)}),j.setDefaultPixelDensity(1),j._queryDataScene=void 0,j._queryDataSem=void 0,j._queryDataUI=void 0,j._hoveredSemNode=void 0,j._hoveredUI=void 0,j._bq=!0,j._bQuerySemOcclusion=!0,j._bQueryNormals=!0,j._bPauseQuery=!1,j._bCenteredQuery=!1,j._bqScene=!1,j._bqSem=!1,j._qSync=0,j._qSyncInt=1,j._tgiDur=void 0,j._tgiPer=void 0,j._tHover=void 0,j._bMainPanoInfinite=!0,j._matMainPano=void 0,j._mMainPano=void 0,j._screenPointerCoords=new THREE.Vector2(0,0),j._rcScene=new THREE.Raycaster,j._rcScene.layers.set(j.NTYPES.SCENE),j._rcScene.firstHitOnly=!0,j._rcSemantics=new THREE.Raycaster,j._rcSemantics.layers.set(j.NTYPES.SEM),j._rcSemantics.firstHitOnly=!0,j._rcUI=new THREE.Raycaster,j._rcUI.layers.set(j.NTYPES.UI),j._rcUI.firstHitOnly=!0,j._setupBaseListeners(),j.device.isMobile&&j._readDeviceOrientationMode(),j._fLoading=0,j._fRequired=j._fReqList.length,j._loadFlares(),j._gizmo=void 0,j._bGizmo=!1,j.focusOn3DView(),j._bInitialized=!0},j.realize2D=()=>{j._b2D=!0,j.UI.init(),j.REQ.init(),document.body.classList.add("aton-body2D"),document.body.oncontextmenu=null,j.EventHub.init(),j._bInitialized=!0},j.addFlare=e=>{if(void 0===e)return;let t=Object.keys(j.Flares).length,o=e.getID();o?j.Flares[o]=e:j.Flares["F"+t]=e},j.registerFlare=j.addFlare,j.getFlare=e=>j.Flares[e],j.loadScript=(e,t,o)=>{let i=document.createElement("script");i.src=e,i.async=!1,document.head.appendChild(i),t&&(i.onload=t),o&&(i.onerror=o)},j._loadFlare=e=>{j._fLoading++,$.get(j.PATH_RESTAPI2+"flares/"+e,(t=>{let o=t.files;if(o){let t=o.length;for(let i in o)j.loadScript(j.PATH_FLARES+e+"/"+o[i],(()=>{t--,t<=0&&j._onFlareLoaded(e)}),(()=>{console.log("Missing flare '"+e+"' dependency: "+o[i]),t--,t<=0&&j._onFlareLoaded(e)}))}})).fail((()=>{console.log("Flare "+e+" not found."),j._onFlareError(e)}))},j._loadFlares=()=>{if(j._fRequired<=0)j.fire("AllFlaresReady");else for(let e in j._fReqList)j._loadFlare(j._fReqList[e])},j._onFlareLoaded=e=>{console.log("All deps loaded for flare '"+e+"'"),j._deployNewFlares(),j._fLoading--,j._fLoading<=0&&j._onAllFlaresLoaded()},j._onFlareError=e=>{j._fLoading--,j._fLoading<=0&&j._onAllFlaresLoaded()},j._onAllFlaresLoaded=()=>{console.log("All Flares ready!"),j.fire("AllFlaresReady")},j._deployFlare=e=>{e._bDeployed||(void 0!==e.setup&&e.setup(),void 0!==e.update&&j.addUpdateRoutine(e.update),e._bDeployed=!0)},j._deployNewFlares=()=>{for(let e in j.Flares)j._deployFlare(j.Flares[e])},j.setCollectionPathModifier=e=>{j._collMod=e},j.setTimedGazeDuration=e=>{j._tgiDur=e},j.getTimedGazeProgress=()=>{if(void 0!==j._tgiDur)return j._tgiPer},j.getElapsedTime=()=>j._clock.elapsedTime,j.renderPause=()=>{j._renderer.setAnimationLoop(void 0)},j.renderResume=()=>{j._renderer.setAnimationLoop(j._onFrame)},j._setupLoadManager=()=>{j._loadManager=new THREE.LoadingManager,j._loadManager.onStart=(e,t,o)=>{console.log("Started loading file: "+e+".\nLoaded "+t+" of "+o+" files."),j.fire("NodeRequestFired",e)},j._loadManager.onLoad=()=>{console.log("Loading complete!"),j.fire("AllNodeRequestsCompleted")},j._loadManager.onProgress=(e,t,o)=>{},j._loadManager.onError=e=>{console.log("There was an error loading "+e)}},j.setDefaultPixelDensity=e=>{j._stdpxd=e,j._renderer.setPixelRatio(e),j.FX.composer&&j.FX.composer.setPixelRatio(e),void 0!==j._renderer.xr&&(j.device.isMobile?j._renderer.xr.setFramebufferScaleFactor(j._stdpxd*j.XR.MOBILE_DENSITY_F):j._renderer.xr.setFramebufferScaleFactor(j._stdpxd))},j.resetPixelDensity=()=>{j._renderer.setPixelRatio(j._stdpxd)},j._readDeviceOrientationMode=()=>{90===Math.abs(window.orientation)?(console.log("Landscape Mode"),j.fire("MobileLandscapeMode")):(console.log("Portrait Mode"),j.fire("MobilePortraitMode")),setTimeout(j._onResize,500)},j.snodes={},j.semnodes={},j.uinodes={},j.createSceneNode=e=>new j.Node(e,j.NTYPES.SCENE),j.getSceneNode=e=>{if(void 0!==e)return j.snodes[e]},j.getOrCreateSceneNode=e=>{let t=j.getSceneNode(e);return void 0!==t?t:j.createSceneNode(e)},j.getRootScene=()=>j._rootVisible,j.createSemanticNode=e=>new j.Node(e,j.NTYPES.SEM),j.getSemanticNode=e=>{if(void 0!==e)return j.semnodes[e]},j.getOrCreateSemanticNode=e=>{let t=j.getSemanticNode(e);return void 0!==t?t:j.createSemanticNode(e)},j.getRootSemantics=()=>j._rootSem,j.createUINode=e=>new j.Node(e,j.NTYPES.UI),j.getUINode=e=>{if(void 0!==e)return j.uinodes[e]},j.getRootUI=()=>j._rootUI,j._unpackScale=e=>0==e?1:e>=0?1.1*e:1/(-1.1*e),j.setUserScaleLevel=e=>{j.setWorldScaleLevel(-e)},j.getUserScale=()=>1/j._worldScale,j.setWorldScaleLevel=e=>{void 0===e&&(e=0),e<-127&&(e=127),e>127&&(e=127),j._ws=e;let t=j._unpackScale(e);j._rootVisible.scale.set(t,t,t),j._rootSem.scale.set(t,t,t),N.gLocNodes.scale.set(t,t,t),N.gMeasures.scale.set(t,t,t),j.Photon.avaGroup&&j.Photon.avaGroup.scale.set(t,t,t),j.recomputeSceneBounds();let o=t/j._worldScale;j.Nav._currPOV.pos.x*=o,j.Nav._currPOV.pos.y*=o,j.Nav._currPOV.pos.z*=o,j.Nav._currPOV.target.x*=o,j.Nav._currPOV.target.y*=o,j.Nav._currPOV.target.z*=o,j.Nav.syncCurrCamera(),j.XR._bPresenting&&j.XR.setRefSpaceLocation(j.Nav._currPOV.pos),j._worldScale=t,console.log("World scale: "+t)},j.getWorldScaleLevel=()=>j._ws,j.getWorldScale=()=>j._worldScale,j._assetReqNew=e=>{j._numReqLoad++,j.fire("NodeRequestFired",e)},j._assetReqComplete=e=>{j.fire("NodeRequestCompleted",e),j._numReqLoad--,j._numReqLoad<=0&&j._onAllReqsCompleted()},j._onAllReqsCompleted=()=>{j.recomputeSceneBounds(),j.getRootScene().assignLightProbesByProximity(),j.fire("AllNodeRequestsCompleted"),j._postAllReqsCompleted(),setTimeout((()=>{j.updateLightProbes(),j._renderer.shadowMap.enabled&&j._bShadowsFixedBound&&0===j._aniMixers.length&&(j._dMainL.shadow.autoUpdate=!1,console.log("Lazy shadows"))}),1e3)},j._postAllReqsCompleted=e=>{void 0===e&&(e=j._rootVisible);for(let t in e.children){let o=e.children[t];o&&o.toggle&&(j._postAllReqsCompleted(o),o.toggle(o.visible))}ThreeMeshUI.update()},j.recomputeSceneBounds=e=>{e?j.bounds.union(e):(j.bounds.center.copy(j._rootVisible.getBound().center),j.bounds.radius=j._rootVisible.getBound().radius),j.bounds.radius<=0||(j._renderer.shadowMap.enabled&&(j._rootVisible.traverse((e=>{e.isMesh&&(e.castShadow=!0,e.receiveShadow=!0)})),j.adjustShadowsParamsFromSceneBounds(),j._bShadowsFixedBound&&j.updateDirShadows()),j._bAutoLP&&(void 0===j._lps[0]?j.addLightProbe((new j.LightProbe).setPosition(j.bounds.center).setNear(j.bounds.radius)):j._lps[0].setPosition(j.bounds.center).setNear(j.bounds.radius),console.log("Auto LP")),j.FX.composer&&j.FX.setDOFaperture(1/(30*j.bounds.radius)),j._mMainPano&&j._mMainPano.position.copy(j.bounds.center))},j.registerNodeResourceHandler=(e,t)=>{j._resHandler||(j._resHandler={}),j._resHandler[e]=t,console.log("Registered resource handler '"+e+"'")},j.removeNodeResourceHanlder=e=>{j._resHandler&&j._resHandler[e]&&(j._resHandler[e]=void 0)},j.initGraphs=()=>{j._mainRoot=new THREE.Scene,j._mainRoot.background=new THREE.Color(.7,.7,.7),j._rootVisibleGlobal=new THREE.Scene,j._mainRoot.add(j._rootVisibleGlobal),j._rootVisible=j.createSceneNode().setAsRoot(),j._rootVisibleGlobal.add(j._rootVisible),j._rootSem=j.createSemanticNode().setAsRoot(),j._mainRoot.add(j._rootSem),j._rootUI=j.createUINode().setAsRoot(),j._mainRoot.add(j._rootUI),j.ambLight=new THREE.AmbientLight(new THREE.Color(1,1,1)),j.ambLight.intensity=3,j._rootVisibleGlobal.add(j.ambLight),j.plight=new THREE.PointLight,j.plight.intensity=0,j.plight.decay=.2,j._rootVisibleGlobal.add(j.plight)},j.enablePointLight=()=>{j.plight.intensity=3},j.disablePointLight=()=>{j.plight.intensity=0},j.setBackgroundColor=e=>{j._mainRoot.background=e},j.setFog=(e,t)=>{void 0!==e&&(void 0===t&&(t=200),j._rootVisibleGlobal.fog=new THREE.Fog(e,1,t),j.setBackgroundColor(e))},j.disableFog=()=>{j._rootVisibleGlobal.fog=null},j.setAutoLP=e=>{j._bAutoLP=e},j.setNeutralAmbientLight=e=>{j.ambLight.color=new THREE.Color(e,e,e)},j.addLightProbe=e=>{void 0!==e&&(j._lps.push(e),j.setNeutralAmbientLight(0),void 0!==j.SUI.gLPIcons&&N.addLPIcon(e))},j.getNumLightProbes=()=>j._lps.length,j._updLP=()=>{for(let e in j._lps)j._lps[e].update();j._rootVisible.traverse((e=>{let t=e.userData.LP;void 0!==t&&t instanceof j.LightProbe&&(e.material.envMap=t.getEnvTex(),e.material.envMapIntensity=j._envMapInt,e.material.needsUpdate=!0)}))},j.setLightProbesNumBounces=e=>{e<1||(j._numLPbounces=e)},j.dirtyLightProbes=e=>{void 0===e&&(e=j._numLPbounces),j._lpbCount=e},j.updateLightProbes=()=>{if(!j.XR._bPresenting&&0!==j._lps.length){for(let e=0;e{let t;if(e=j.Utils.resolveCollectionURL(e),void 0===j._mMainPano&&(j._gMainPano=new THREE.SphereGeometry(1,60,60),j._gMainPano.castShadow=!1,j._gMainPano.receiveShadow=!1,j._mMainPano=new THREE.Mesh(j._gMainPano,j._matMainPano),j._mMainPano.frustumCulled=!1,j._mMainPano.renderOrder=-100,j._mMainPano.layers.disable(j.NTYPES.SCENE),j._mMainPano.layers.disable(j.NTYPES.SEM),j._mMainPano.layers.disable(j.NTYPES.UI),j._mMainPano.raycast=j.Utils.VOID_CAST,j.setMainPanoramaRadius(.8*j.Nav.STD_FAR)),j.Utils.isVideo(e)){if(void 0===j._elPanoVideo){let t="",$(t).appendTo("body"),j._elPanoVideo=document.getElementById("idPanoVideo"),j._elPanoVideo.onplaying=()=>{console.log("VideoPano playing"),j._vpanoPlaying=!0},j._elPanoVideo.onpause=()=>{console.log("VideoPano paused"),j._vpanoPlaying=!1},j._elPanoVideo.addEventListener("touchstart",(function(){j._elPanoVideo.play()})),enableInlineVideo(j._elPanoVideo)}t=new THREE.VideoTexture(j._elPanoVideo),t.colorSpace=j._stdEncoding,j._realizeOrUpdateMainPano(t),j.fire("MainPanoVideo")}else{if(e.endsWith(".hdr"))return void(new THREE.RGBELoader).load(e,(e=>{e.minFilter=THREE.LinearMipmapLinearFilter,e.magFilter=THREE.LinearFilter,e.colorSpace=j._stdEncoding,j._realizeOrUpdateMainPano(e),j.fire("MainPanoHDR")}));if(e.endsWith(".exr"))return void(new THREE.EXRLoader).load(e,(e=>{e.minFilter=THREE.LinearMipmapLinearFilter,e.magFilter=THREE.LinearFilter,e.colorSpace=j._stdEncoding,j._realizeOrUpdateMainPano(e),j.fire("MainPanoHDR")}));j.Utils.textureLoader.load(e,(e=>{e.colorSpace=j._stdEncoding,e.generateMipmaps=!0,j._realizeOrUpdateMainPano(e),j.fire("MainPano")}))}},j.playMainPanorama=()=>{j._elPanoVideo&&(j._vpanoPlaying||j._elPanoVideo.play())},j.pauseMainPanorama=()=>{j._elPanoVideo&&j._vpanoPlaying&&j._elPanoVideo.pause()},j.playOrPauseMainPanorama=()=>{j._elPanoVideo&&(j._vpanoPlaying?j._elPanoVideo.pause():j._elPanoVideo.play())},j.stopAndRemoveMainPanorama=()=>{j._elPanoVideo&&(j._vpanoPlaying&&j._elPanoVideo.pause(),j._elPanoVideo.remove(),j._elPanoVideo=void 0,j._vpanoPlaying=!1)},j._realizeOrUpdateMainPano=e=>{if(void 0!==j._matMainPano)return j._matMainPano.map=e,void j.updateLightProbes();j._matMainPano=new THREE.MeshBasicMaterial({map:e,depthTest:!1,depthWrite:!1}),j._mMainPano.material=j._matMainPano,j._bMainPanoInfinite&&(j._mMainPano.onAfterRender=()=>{"immersive-ar"!==j.XR._sessionType&&j.Nav._currPOV&&j._mMainPano.position.copy(j.Nav._currPOV.pos)}),j._rootVisibleGlobal.add(j._mMainPano),j.updateLightProbes()},j.setMainPanoramaRadius=e=>{void 0!==j._gMainPano&&j._gMainPano.scale(-e,e,e)},j.setMainPanoramaRotation=e=>{void 0!==j._mMainPano&&j._mMainPano.rotation.set(0,e,0)},j.setMainPanoramaInfinite=e=>{j._bMainPanoInfinite=e,void 0!==j._mMainPano&&(j._mMainPano.onAfterRender=e?()=>{j.Nav._currPOV&&j._mMainPano.position.copy(j.Nav._currPOV.pos)}:void 0)},j.setMainPanoramaLocation=e=>{j._bMainPanoInfinite||void 0!==j._mMainPano&&j._mMainPano.position.copy(e)},j.setMainLightDirection=e=>{let t=e.clone();t.normalize(),t.x*=.5*j.SHADOWS_FAR,t.y*=.5*j.SHADOWS_FAR,t.z*=.5*j.SHADOWS_FAR,void 0===j._dMainL&&(j._dMainL=new THREE.DirectionalLight(new THREE.Color(1,1,1),1),j._dMainL.castShadow=!1,j._dMainL.intensity=2,j._dMainLtgt=new THREE.Object3D,j._rootVisibleGlobal.add(j._dMainLtgt),j._dMainL.target=j._dMainLtgt,j._rootVisibleGlobal.add(j._dMainL),j._dMainLpos=new THREE.Vector3),j._dMainLdir=t,j._dMainL.position.set(-t.x,-t.y,-t.z),j._renderer.shadowMap.enabled&&(j._dMainL.shadow.needsUpdate=!0),j.toggleMainLight(!0)},j.getMainLightDirection=()=>{if(void 0===j._dMainLdir)return;let e=j._dMainLdir.clone();return e.normalize(),e},j.toggleMainLight=e=>{if(void 0===j._dMainL)return;j._dMainL.visible=e;let t=j._lps.length;e?(t>0?j.setNeutralAmbientLight(0):j.setNeutralAmbientLight(j.AMB_L),j.updateDirShadows()):t>0?j.setNeutralAmbientLight(0):j.setNeutralAmbientLight(j.AMB_L)},j.isMainLightEnabled=()=>void 0!==j._dMainL&&!!j._dMainL.visible,j.setExposure=e=>{j._renderer.toneMappingExposure=e},j.getExposure=()=>j._renderer.toneMappingExposure,j.adjustShadowsParamsFromSceneBounds=()=>{if(void 0===j._dMainL)return;let e=j._rootVisible.getBound().radius,t=j._rootVisible.getBound().center;e<=0||e>=j.SHADOWS_SIZE?(j._bShadowsFixedBound=!1,j._shadowsSize=j.SHADOWS_SIZE):(j._bShadowsFixedBound=!0,j._shadowsFixedBoundCenter=t,j._shadowsSize=1.5*e),j._dMainL.shadow.map&&(j._dMainL.shadow.map.dispose(),j._dMainL.shadow.map=null),j._dMainL.shadow.camera.left=-j._shadowsSize,j._dMainL.shadow.camera.right=j._shadowsSize,j._dMainL.shadow.camera.bottom=-j._shadowsSize,j._dMainL.shadow.camera.top=j._shadowsSize,j._dMainL.shadow.mapSize.width=j._shadowsRes,j._dMainL.shadow.mapSize.height=j._shadowsRes,j._dMainL.shadow.camera.near=j._shadowsNear,j._dMainL.shadow.camera.far=j._shadowsFar;let o=-2e-4*e;o<-.001&&(o=-.001),j._dMainL.shadow.bias=o},j.toggleShadows=e=>{if(void 0!==j._dMainL)if(e){if(j.XR.isPresenting())return;if(j.device.lowGPU)return;j._dMainL.castShadow=!0,j._renderer.shadowMap.enabled=!0,j.device.isMobile?j._renderer.shadowMap.type=THREE.PCFShadowMap:j._renderer.shadowMap.type=THREE.PCFSoftShadowMap,j._rootVisible.traverse((e=>{e.isMesh&&(e.castShadow=!0,e.receiveShadow=!0)})),j.adjustShadowsParamsFromSceneBounds(),j.updateDirShadows(),j._dMainL.shadow.needsUpdate=!0,console.log("Shadows ON")}else j._dMainL.castShadow=!1,j._renderer.shadowMap.enabled=!1,console.log("Shadows OFF")},j.updateDirShadows=()=>{if(void 0===j._dMainLdir)return;if(void 0===j._dMainLpos)return;let e=j._shadowsFixedBoundCenter;void 0===e?(e=j.Nav.getCurrentEyeLocation(),j._dMainLpos.x=e.x+j.Nav._vDir.x*j._shadowsSize,j._dMainLpos.y=e.y+j.Nav._vDir.y*j._shadowsSize,j._dMainLpos.z=e.z+j.Nav._vDir.z*j._shadowsSize):(j._dMainLpos.x=e.x,j._dMainLpos.y=e.y,j._dMainLpos.z=e.z),j._dMainL.position.set(j._dMainLpos.x-j._dMainLdir.x,j._dMainLpos.y-j._dMainLdir.y,j._dMainLpos.z-j._dMainLdir.z),j._dMainLtgt.position.copy(j._dMainLpos)},j._updateEnvironment=()=>{j._renderer.shadowMap.enabled&&(j._bShadowsFixedBound||j.updateDirShadows())},j.setGlobalAudio=(e,t)=>{void 0!==e&&(void 0===t&&(t=!0),e=j.Utils.resolveCollectionURL(e),void 0===j._auMain||null===j._auMain?j._auMain=new THREE.Audio(j.AudioHub._listener):j._auMain.isPlaying&&j._auMain.stop(),j.AudioHub._loader.load(e,(e=>{j._auMain.setBuffer(e),j._auMain.setLoop(t),j._auMain.play()})))},j._markFPS=()=>{j._numReqLoad>0||j._dt<0||(j._dtCount+=1,j._dtAccum+=j._dt,j._dtAccum<1||(j._fps=1/(j._dtAccum/j._dtCount),j._dtCount=0,j._dtAccum=0,j._handleDynamicRenderProfiles()))},j.toggleAdaptiveDensity=e=>{j._bAdaptiveDensity=e},j.setAdaptiveDensityRange=(e,t)=>{e>=t||(j._adMin=e,j._adMax=t)},j.setDynamicRenderingFPS=(e,t)=>{e>=t||(e&&(j._dRenderBudgetMinFPS=e),t&&(j._dRenderBudgetMaxFPS=t))},j._handleDynamicRenderProfiles=()=>{let e=j._renderer.getPixelRatio();j._fps=j._adMin&&(j._renderer.setPixelRatio(e),j.FX.composer&&j.FX.composer.setPixelRatio(e),console.log("Density: "+e.toPrecision(2)))),j.fire("RequestLowerRender")),j._fps>j._dRenderBudgetMaxFPS&&(j._bAdaptiveDensity&&!j.XR._bPresenting&&(e+=.1,e<=j._adMax&&(j._renderer.setPixelRatio(e),j.FX.composer&&j.FX.composer.setPixelRatio(e),console.log("Density: "+e.toPrecision(2)))),j.fire("RequestHigherRender"))},j._onFrame=()=>{j._dt=j._clock.getDelta(),j._markFPS(),j.XR._bPresenting?j.XR.update():j.Nav._controls.update(j._dt),j._handleQueries(),j.Nav.update(),j.Photon.update(),j.SUI.update(),j.MatHub.update(),j._updateEnvironment(),j._updateAniMixers(),j._updateRoutines(),j.MRes.update(),j.XPFNetwork.update(),j._render()},j._render=()=>{!j.FX.composer||j.XR._bPresenting?j._renderer.render(j._mainRoot,j.Nav._camera):j.FX.composer.render()},j.addUpdateRoutine=e=>{void 0!==e&&j._updRoutines.push(e)},j.deleteAllUpdateRoutines=()=>{j._updRoutines=[]},j._updateRoutines=()=>{let e=j._updRoutines.length;if(!(e<=0))for(let t=0;t{let e=j._aniMixers.length;if(!(e<1))for(let t=0;t{e.preventDefault&&e.preventDefault(),j._bCenteredQuery||(j._screenPointerCoords.x=e.clientX/window.innerWidth*2-1,j._screenPointerCoords.y=-e.clientY/window.innerHeight*2+1)},j.toggleCenteredQuery=e=>{j._bCenteredQuery=e,e&&(j._screenPointerCoords.x=0,j._screenPointerCoords.y=0)},j.toggleQueries=e=>{j._bq=e},j._registerRCS=()=>{j._rcRR=0,j._rcHandlers=[],j._rcHandlers.push(j._handleQueryScene),j._rcHandlers.push(j._handleQuerySemantics),j._rcHandlers.push(j._handleQueryUI)},j._handleQueries=()=>{if(!j._bq)return;if(j._bPauseQuery)return;if(j.Nav._bInteracting)return;if(j._numReqLoad>0)return;if(j.Nav.isTransitioning())return;if(j._handleQueryUI(),j._bqScene&&j._handleQueryScene(),j._bqSem&&j._handleQuerySemantics(),j.Nav._bLocValidator&&j.Nav.locomotionValidator(),void 0===j._tgiDur)return;if(void 0===j._tHover)return;const e=j._clock.elapsedTime-j._tHover;e>=j._tgiDur?(j._stdActivation(),j._tHover=void 0,j._tgiPer=void 0):j._tgiPer=e/j._tgiDur},j._handleQueryScene=()=>{if(j.XR.isPresenting()?j.XR.setupQueryRay(j._rcScene):j._rcScene.setFromCamera(j._screenPointerCoords,j.Nav._camera),j._hitsScene=[],j._rcScene.intersectObjects(j._mainRoot.children,!0,j._hitsScene),j._hitsScene.length<=0)return void(j._queryDataScene=void 0);const e=j._hitsScene[0];j._queryDataScene={},j._queryDataScene.p=e.point,j._queryDataScene.d=e.distance,j._queryDataScene.o=e.object,j._queryDataScene.uv=e.uv,j._bQueryNormals&&e.face&&e.face.normal&&(j._queryDataScene.matrixWorld=(new THREE.Matrix3).getNormalMatrix(e.object.matrixWorld),j._queryDataScene.n=e.face.normal.clone().applyMatrix3(j._queryDataScene.matrixWorld).normalize())},j.getSceneFocalPoint=()=>{if(void 0===j._queryDataScene)return;let e=j._queryDataScene.p,t=new THREE.Vector3;return t.lerpVectors(e,j.Nav._currPOV.pos,.02),t},j.getSceneQueriedPoint=()=>{if(void 0!==j._queryDataScene)return j._queryDataScene.p},j.getSceneQueriedDistance=()=>{if(void 0!==j._queryDataScene)return j._queryDataScene.d},j.getSceneQueriedNormal=()=>{if(void 0!==j._queryDataScene)return j._queryDataScene.n},j.getSceneQueriedObjectName=()=>{if(void 0!==j._queryDataScene&&void 0!==j._queryDataScene.o)return j._queryDataScene.o.name},j.getSceneQueriedUV=()=>{if(void 0!==j._queryDataScene)return j._queryDataScene.uv},j.setQueryRange=(e,t,o)=>{void 0!==o&&o!==j.NTYPES.SCENE||(j._rcScene.near=e,j._rcScene.far=t),void 0!==o&&o!==j.NTYPES.SEM||(j._rcSemantics.near=e,j._rcSemantics.far=t)},j._handleQuerySemantics=()=>{if(j.XR.isPresenting()?j.XR.setupQueryRay(j._rcSemantics):j._rcSemantics.setFromCamera(j._screenPointerCoords,j.Nav._camera),j._hitsSem=[],j._rcSemantics.intersectObjects(j._mainRoot.children,!0,j._hitsSem),j._hitsSem.length<=0){if(j._queryDataSem=void 0,j._hoveredSemNode){j.fire("SemanticNodeLeave",j._hoveredSemNode);let e=j.getSemanticNode(j._hoveredSemNode);e&&e.onLeave&&e.onLeave()}return j._hoveredSemNode=void 0,void(j._tHover=void 0)}const e=j._hitsSem[0];if(j._bQuerySemOcclusion&&j._queryDataScene&&j._queryDataScene.d{if(j.XR.isPresenting()?j.XR.setupQueryRay(j._rcUI):j._rcUI.setFromCamera(j._screenPointerCoords,j.Nav._camera),j._hitsUI=[],j._rcUI.intersectObjects(j._mainRoot.children,!0,j._hitsUI),j._hitsUI.length<=0){if(j._queryDataUI=void 0,j._hoveredUI){j.fire("UINodeLeave",j._hoveredUI);const e=j.getUINode(j._hoveredUI);e&&e.onLeave&&e.onLeave()}return j._hoveredUI=void 0,void(j._tHover=void 0)}const e=j._hitsUI[0];if(j._queryDataScene&&j._queryDataScene.d{if(void 0!==j._hoveredSemNode)return j.getSemanticNode(j._hoveredSemNode)},j.setAPIToken=(e,t)=>{window.sessionStorage.setItem("ATON.tokens."+e,t)},j.getAPIToken=e=>window.sessionStorage.getItem("ATON.tokens."+e),j.clearToken=e=>{window.sessionStorage.removeItem("ATON.tokens."+e)},j.enableClipPlanes=()=>{j._renderer&&(j._renderer.localClippingEnabled=!0)},j.disableClipPlanes=()=>{j._renderer&&(j._renderer.localClippingEnabled=!1,j._clipPlanes=[])},j.addClipPlane=(e,t)=>{j.enableClipPlanes();let o=new THREE.Plane;return o.setFromNormalAndCoplanarPoint(e,t),j._clipPlanes.push(o),j.Utils._visitorCP(),o},j.useGizmo=e=>{j._bGizmo=e,j._setupGizmo()},j._setupGizmo=()=>{}})(); \ No newline at end of file diff --git a/public/dist/THREE.bundle.js b/public/dist/THREE.bundle.js index 3cffe512..5e35c831 100644 --- a/public/dist/THREE.bundle.js +++ b/public/dist/THREE.bundle.js @@ -1,2 +1,2 @@ /*! For license information please see THREE.bundle.js.LICENSE.txt */ -(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})}};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var e={};t.r(e),t.d(e,{ACESFilmicToneMapping:()=>ft,AddEquation:()=>P,AddOperation:()=>ct,AdditiveAnimationBlendMode:()=>Ze,AdditiveBlending:()=>T,AgXToneMapping:()=>gt,AlphaFormat:()=>Kt,AlwaysCompare:()=>Fn,AlwaysDepth:()=>tt,AlwaysStencilFunc:()=>Tn,AmbientLight:()=>Oh,AnimationAction:()=>Iu,AnimationClip:()=>oh,AnimationLoader:()=>gh,AnimationMixer:()=>Bu,AnimationObjectGroup:()=>bu,AnimationUtils:()=>Xc,ArcCurve:()=>hl,ArrayCamera:()=>ru,ArrowHelper:()=>Md,AttachedBindMode:()=>vt,Audio:()=>du,AudioAnalyser:()=>vu,AudioContext:()=>Zh,AudioListener:()=>uu,AudioLoader:()=>$h,AxesHelper:()=>Sd,BackSide:()=>M,BasicDepthPacking:()=>nn,BasicShadowMap:()=>_,BatchedMesh:()=>Do,Bone:()=>qa,BooleanKeyframeTrack:()=>th,Box2:()=>ju,Box3:()=>Hi,Box3Helper:()=>_d,BoxGeometry:()=>Ks,BoxHelper:()=>yd,BufferAttribute:()=>_s,BufferGeometry:()=>Fs,BufferGeometryLoader:()=>Wh,ByteType:()=>Qt,Cache:()=>ch,Camera:()=>ia,CameraHelper:()=>gd,CanvasTexture:()=>al,CapsuleGeometry:()=>Rl,CatmullRomCurve3:()=>gl,CineonToneMapping:()=>pt,CircleGeometry:()=>Dl,ClampToEdgeWrapping:()=>bt,Clock:()=>su,Color:()=>ls,ColorKeyframeTrack:()=>eh,ColorManagement:()=>wi,CompressedArrayTexture:()=>rl,CompressedCubeTexture:()=>sl,CompressedTexture:()=>il,CompressedTextureLoader:()=>Ah,ConeGeometry:()=>Ll,ConstantAlphaFactor:()=>K,ConstantColorFactor:()=>Y,Controls:()=>Id,CubeCamera:()=>ca,CubeReflectionMapping:()=>xt,CubeRefractionMapping:()=>wt,CubeTexture:()=>ha,CubeTextureLoader:()=>yh,CubeUVReflectionMapping:()=>Mt,CubicBezierCurve:()=>_l,CubicBezierCurve3:()=>xl,CubicInterpolant:()=>Jc,CullFaceBack:()=>A,CullFaceFront:()=>v,CullFaceFrontBack:()=>y,CullFaceNone:()=>g,Curve:()=>ll,CurvePath:()=>Il,CustomBlending:()=>D,CustomToneMapping:()=>mt,CylinderGeometry:()=>Pl,Cylindrical:()=>Hu,Data3DTexture:()=>Fi,DataArrayTexture:()=>Ui,DataTexture:()=>Xa,DataTextureLoader:()=>_h,DataUtils:()=>As,DecrementStencilOp:()=>vn,DecrementWrapStencilOp:()=>_n,DefaultLoadingManager:()=>uh,DepthFormat:()=>ne,DepthStencilFormat:()=>ie,DepthTexture:()=>ol,DetachedBindMode:()=>yt,DirectionalLight:()=>Fh,DirectionalLightHelper:()=>pd,DiscreteInterpolant:()=>Zc,DodecahedronGeometry:()=>Nl,DoubleSide:()=>S,DstAlphaFactor:()=>V,DstColorFactor:()=>j,DynamicCopyUsage:()=>Wn,DynamicDrawUsage:()=>kn,DynamicReadUsage:()=>Gn,EdgesGeometry:()=>zl,EllipseCurve:()=>cl,EqualCompare:()=>Dn,EqualDepth:()=>it,EqualStencilFunc:()=>En,EquirectangularReflectionMapping:()=>Ct,EquirectangularRefractionMapping:()=>Et,Euler:()=>Sr,EventDispatcher:()=>Kn,ExtrudeGeometry:()=>gc,FileLoader:()=>mh,Float16BufferAttribute:()=>Is,Float32BufferAttribute:()=>Ts,FloatType:()=>Wt,Fog:()=>pa,FogExp2:()=>da,FramebufferTexture:()=>nl,FrontSide:()=>E,Frustum:()=>fo,GLBufferAttribute:()=>Fu,GLSL1:()=>qn,GLSL3:()=>Xn,GreaterCompare:()=>Ln,GreaterDepth:()=>st,GreaterEqualCompare:()=>Nn,GreaterEqualDepth:()=>rt,GreaterEqualStencilFunc:()=>In,GreaterStencilFunc:()=>Sn,GridHelper:()=>ld,Group:()=>tl,HalfFloatType:()=>jt,HemisphereLight:()=>Ch,HemisphereLightHelper:()=>od,IcosahedronGeometry:()=>vc,ImageBitmapLoader:()=>Jh,ImageLoader:()=>vh,ImageUtils:()=>Si,IncrementStencilOp:()=>An,IncrementWrapStencilOp:()=>yn,InstancedBufferAttribute:()=>Za,InstancedBufferGeometry:()=>Vh,InstancedInterleavedBuffer:()=>Nu,InstancedMesh:()=>ao,Int16BufferAttribute:()=>Es,Int32BufferAttribute:()=>Ss,Int8BufferAttribute:()=>xs,IntType:()=>Ht,InterleavedBuffer:()=>ma,InterleavedBufferAttribute:()=>Aa,Interpolant:()=>Yc,InterpolateDiscrete:()=>We,InterpolateLinear:()=>je,InterpolateSmooth:()=>qe,InvertStencilOp:()=>xn,KeepStencilOp:()=>mn,KeyframeTrack:()=>$c,LOD:()=>Na,LatheGeometry:()=>Bl,Layers:()=>br,LessCompare:()=>Rn,LessDepth:()=>et,LessEqualCompare:()=>Pn,LessEqualDepth:()=>nt,LessEqualStencilFunc:()=>Mn,LessStencilFunc:()=>Cn,Light:()=>wh,LightProbe:()=>zh,Line:()=>zo,Line3:()=>Yu,LineBasicMaterial:()=>Po,LineCurve:()=>wl,LineCurve3:()=>Cl,LineDashedMaterial:()=>Gc,LineLoop:()=>jo,LineSegments:()=>Wo,LinearFilter:()=>Lt,LinearInterpolant:()=>Kc,LinearMipMapLinearFilter:()=>Ot,LinearMipMapNearestFilter:()=>Nt,LinearMipmapLinearFilter:()=>Ft,LinearMipmapNearestFilter:()=>Ut,LinearSRGBColorSpace:()=>un,LinearToneMapping:()=>ut,LinearTransfer:()=>dn,Loader:()=>dh,LoaderUtils:()=>Hh,LoadingManager:()=>hh,LoopOnce:()=>Ge,LoopPingPong:()=>Ve,LoopRepeat:()=>He,LuminanceAlphaFormat:()=>ee,LuminanceFormat:()=>te,MOUSE:()=>f,Material:()=>us,MaterialLoader:()=>Gh,MathUtils:()=>li,Matrix2:()=>Vu,Matrix3:()=>hi,Matrix4:()=>gr,MaxEquation:()=>F,Mesh:()=>Ys,MeshBasicMaterial:()=>ds,MeshDepthMaterial:()=>kc,MeshDistanceMaterial:()=>Qc,MeshLambertMaterial:()=>Oc,MeshMatcapMaterial:()=>zc,MeshNormalMaterial:()=>Fc,MeshPhongMaterial:()=>Uc,MeshPhysicalMaterial:()=>Lc,MeshStandardMaterial:()=>Pc,MeshToonMaterial:()=>Nc,MinEquation:()=>N,MirroredRepeatWrapping:()=>It,MixOperation:()=>lt,MultiplyBlending:()=>R,MultiplyOperation:()=>ot,NearestFilter:()=>Tt,NearestMipMapLinearFilter:()=>Pt,NearestMipMapNearestFilter:()=>Rt,NearestMipmapLinearFilter:()=>Dt,NearestMipmapNearestFilter:()=>Bt,NeutralToneMapping:()=>At,NeverCompare:()=>Bn,NeverDepth:()=>$,NeverStencilFunc:()=>wn,NoBlending:()=>b,NoColorSpace:()=>cn,NoToneMapping:()=>ht,NormalAnimationBlendMode:()=>Ke,NormalBlending:()=>I,NotEqualCompare:()=>Un,NotEqualDepth:()=>at,NotEqualStencilFunc:()=>bn,NumberKeyframeTrack:()=>nh,Object3D:()=>Hr,ObjectLoader:()=>jh,ObjectSpaceNormalMap:()=>ln,OctahedronGeometry:()=>yc,OneFactor:()=>k,OneMinusConstantAlphaFactor:()=>Z,OneMinusConstantColorFactor:()=>J,OneMinusDstAlphaFactor:()=>W,OneMinusDstColorFactor:()=>q,OneMinusSrcAlphaFactor:()=>H,OneMinusSrcColorFactor:()=>z,OrthographicCamera:()=>Uh,PCFShadowMap:()=>x,PCFSoftShadowMap:()=>w,PMREMGenerator:()=>ep,Path:()=>Tl,PerspectiveCamera:()=>oa,Plane:()=>ho,PlaneGeometry:()=>_c,PlaneHelper:()=>xd,PointLight:()=>Lh,PointLightHelper:()=>id,Points:()=>Zo,PointsMaterial:()=>qo,PolarGridHelper:()=>cd,PolyhedronGeometry:()=>Ul,PositionalAudio:()=>Au,PropertyBinding:()=>Su,PropertyMixer:()=>yu,QuadraticBezierCurve:()=>El,QuadraticBezierCurve3:()=>Ml,Quaternion:()=>ki,QuaternionKeyframeTrack:()=>rh,QuaternionLinearInterpolant:()=>ih,RED_GREEN_RGTC2_Format:()=>Qe,RED_RGTC1_Format:()=>Oe,REVISION:()=>p,RGBADepthPacking:()=>rn,RGBAFormat:()=>$t,RGBAIntegerFormat:()=>ce,RGBA_ASTC_10x10_Format:()=>De,RGBA_ASTC_10x5_Format:()=>Te,RGBA_ASTC_10x6_Format:()=>Be,RGBA_ASTC_10x8_Format:()=>Re,RGBA_ASTC_12x10_Format:()=>Pe,RGBA_ASTC_12x12_Format:()=>Le,RGBA_ASTC_4x4_Format:()=>xe,RGBA_ASTC_5x4_Format:()=>we,RGBA_ASTC_5x5_Format:()=>Ce,RGBA_ASTC_6x5_Format:()=>Ee,RGBA_ASTC_6x6_Format:()=>Me,RGBA_ASTC_8x5_Format:()=>Se,RGBA_ASTC_8x6_Format:()=>be,RGBA_ASTC_8x8_Format:()=>Ie,RGBA_BPTC_Format:()=>Ue,RGBA_ETC2_EAC_Format:()=>_e,RGBA_PVRTC_2BPPV1_Format:()=>Ae,RGBA_PVRTC_4BPPV1_Format:()=>ge,RGBA_S3TC_DXT1_Format:()=>ue,RGBA_S3TC_DXT3_Format:()=>de,RGBA_S3TC_DXT5_Format:()=>pe,RGBDepthPacking:()=>sn,RGBFormat:()=>Zt,RGBIntegerFormat:()=>le,RGB_BPTC_SIGNED_Format:()=>Ne,RGB_BPTC_UNSIGNED_Format:()=>Fe,RGB_ETC1_Format:()=>ve,RGB_ETC2_Format:()=>ye,RGB_PVRTC_2BPPV1_Format:()=>me,RGB_PVRTC_4BPPV1_Format:()=>fe,RGB_S3TC_DXT1_Format:()=>he,RGDepthPacking:()=>an,RGFormat:()=>ae,RGIntegerFormat:()=>oe,RawShaderMaterial:()=>Dc,Ray:()=>mr,Raycaster:()=>ku,RectAreaLight:()=>kh,RedFormat:()=>re,RedIntegerFormat:()=>se,ReinhardToneMapping:()=>dt,RenderTarget:()=>Pi,RenderTarget3D:()=>Ru,RenderTargetArray:()=>Du,RepeatWrapping:()=>St,ReplaceStencilOp:()=>gn,ReverseSubtractEquation:()=>U,RingGeometry:()=>xc,SIGNED_RED_GREEN_RGTC2_Format:()=>ze,SIGNED_RED_RGTC1_Format:()=>ke,SRGBColorSpace:()=>hn,SRGBTransfer:()=>pn,Scene:()=>fa,ShaderChunk:()=>Pd,ShaderLib:()=>Ud,ShaderMaterial:()=>na,ShadowMaterial:()=>Rc,Shape:()=>Gl,ShapeGeometry:()=>wc,ShapePath:()=>bd,ShapeUtils:()=>pc,ShortType:()=>zt,Skeleton:()=>Ka,SkeletonHelper:()=>ed,SkinnedMesh:()=>ja,Source:()=>Ii,Sphere:()=>or,SphereGeometry:()=>Cc,Spherical:()=>Gu,SphericalHarmonics3:()=>Qh,SplineCurve:()=>Sl,SpotLight:()=>Th,SpotLightHelper:()=>Ku,Sprite:()=>Da,SpriteMaterial:()=>va,SrcAlphaFactor:()=>G,SrcAlphaSaturateFactor:()=>X,SrcColorFactor:()=>Q,StaticCopyUsage:()=>Vn,StaticDrawUsage:()=>On,StaticReadUsage:()=>zn,StereoCamera:()=>iu,StreamCopyUsage:()=>jn,StreamDrawUsage:()=>Qn,StreamReadUsage:()=>Hn,StringKeyframeTrack:()=>sh,SubtractEquation:()=>L,SubtractiveBlending:()=>B,TOUCH:()=>m,TangentSpaceNormalMap:()=>on,TetrahedronGeometry:()=>Ec,Texture:()=>Ri,TextureLoader:()=>xh,TextureUtils:()=>Bd,TorusGeometry:()=>Mc,TorusKnotGeometry:()=>Sc,Triangle:()=>is,TriangleFanDrawMode:()=>en,TriangleStripDrawMode:()=>tn,TrianglesDrawMode:()=>$e,TubeGeometry:()=>bc,UVMapping:()=>_t,Uint16BufferAttribute:()=>Ms,Uint32BufferAttribute:()=>bs,Uint8BufferAttribute:()=>ws,Uint8ClampedBufferAttribute:()=>Cs,Uniform:()=>Pu,UniformsGroup:()=>Uu,UniformsLib:()=>Ld,UniformsUtils:()=>ea,UnsignedByteType:()=>kt,UnsignedInt248Type:()=>Yt,UnsignedInt5999Type:()=>Jt,UnsignedIntType:()=>Vt,UnsignedShort4444Type:()=>qt,UnsignedShort5551Type:()=>Xt,UnsignedShortType:()=>Gt,VSMShadowMap:()=>C,Vector2:()=>ci,Vector3:()=>Qi,Vector4:()=>Di,VectorKeyframeTrack:()=>ah,VideoTexture:()=>el,WebGL3DRenderTarget:()=>Oi,WebGLArrayRenderTarget:()=>Ni,WebGLCoordinateSystem:()=>Yn,WebGLCubeRenderTarget:()=>ua,WebGLRenderTarget:()=>Li,WebGLRenderer:()=>dm,WebGLUtils:()=>im,WebGPUCoordinateSystem:()=>Jn,WireframeGeometry:()=>Ic,WrapAroundEnding:()=>Je,ZeroCurvatureEnding:()=>Xe,ZeroFactor:()=>O,ZeroSlopeEnding:()=>Ye,ZeroStencilOp:()=>fn,createCanvasElement:()=>gi});var n={};t.r(n),t.d(n,{ru:()=>Rg,pP:()=>Tg,_c:()=>Dg});var i={};t.r(i);var r={};t.r(r),t.d(r,{COLUMN:()=>dx,COLUMN_REVERSE:()=>px,ROW:()=>hx,ROW_REVERSE:()=>ux,contentDirection:()=>fx});var s={};t.r(s),t.d(s,{CENTER:()=>gx,END:()=>Ax,START:()=>mx,STRETCH:()=>vx,alignItems:()=>yx,warnAboutDeprecatedAlignItems:()=>_x});var a={};t.r(a),t.d(a,{CENTER:()=>Ex,END:()=>Mx,SPACE_AROUND:()=>Sx,SPACE_BETWEEN:()=>bx,SPACE_EVENLY:()=>Ix,START:()=>Cx,justifyContent:()=>Tx});var o={};t.r(o),t.d(o,{NORMAL:()=>Px,NOWRAP:()=>Lx,PRE:()=>Ux,PRE_LINE:()=>Nx,PRE_WRAP:()=>Fx,WHITE_CHARS:()=>Dx,collapseWhitespaceOnInlines:()=>zx,collapseWhitespaceOnString:()=>Ox,newlineBreakability:()=>kx,shouldBreak:()=>Qx});var l={};t.r(l),t.d(l,{CENTER:()=>qx,JUSTIFY:()=>Xx,JUSTIFY_CENTER:()=>Kx,JUSTIFY_LEFT:()=>Yx,JUSTIFY_RIGHT:()=>Jx,LEFT:()=>Wx,RIGHT:()=>jx,textAlign:()=>Zx});var c={};t.r(c),t.d(c,{bvh_distance_functions:()=>ES,bvh_ray_functions:()=>MS,bvh_struct_definitions:()=>SS,common_functions:()=>CS});var h={};t.r(h),t.d(h,{AVERAGE:()=>Hw,BVHShaderGLSL:()=>c,CENTER:()=>Gw,CONTAINED:()=>qw,ExtendedTriangle:()=>OC,FloatVertexAttributeTexture:()=>iS,INTERSECTED:()=>jw,IntVertexAttributeTexture:()=>nS,MeshBVH:()=>EM,MeshBVHHelper:()=>VM,MeshBVHUniformStruct:()=>rS,NOT_INTERSECTED:()=>Ww,OrientedBox:()=>kC,SAH:()=>Vw,StaticGeometryGenerator:()=>wS,UIntVertexAttributeTexture:()=>eS,VertexAttributeTexture:()=>tS,acceleratedRaycast:()=>LM,computeBatchedBoundsTree:()=>kM,computeBoundsTree:()=>FM,disposeBatchedBoundsTree:()=>QM,disposeBoundsTree:()=>OM,estimateMemoryInBytes:()=>JM,getBVHExtremes:()=>YM,getJSONStructure:()=>ZM,getTriangleHitPointInfo:()=>AE,shaderDistanceFunction:()=>IS,shaderIntersectFunction:()=>TS,shaderStructs:()=>bS,validateBounds:()=>KM});var u={};t.r(u),t.d(u,{latitudeToSphericalPhi:()=>Eb,sphericalPhiToLatitude:()=>Cb,swapToGeoFrame:()=>xb,swapToThreeFrame:()=>wb,toLatLonString:()=>Sb});var d={};t.r(d),t.d(d,{B3DMLoader:()=>hb,B3DMLoaderBase:()=>cb,CAMERA_FRAME:()=>zb,CMPTLoader:()=>sI,CMPTLoaderBase:()=>rI,CameraTransitionManager:()=>rB,ENU_FRAME:()=>Qb,Ellipsoid:()=>Hb,EllipsoidRegion:()=>RI,EnvironmentControls:()=>DT,FAILED:()=>PS,GeoUtils:()=>u,GlobeControls:()=>YT,I3DMLoader:()=>iI,I3DMLoaderBase:()=>Ab,LOADED:()=>FS,LOADING:()=>US,LRUCache:()=>RS,LoaderBase:()=>ob,OBJECT_FRAME:()=>Gb,PARSING:()=>NS,PNTSLoader:()=>gb,PNTSLoaderBase:()=>ub,PriorityQueue:()=>DS,TilesRenderer:()=>JI,TilesRendererBase:()=>tb,UNLOADED:()=>LS,WGS84_ELLIPSOID:()=>Vb,WGS84_FLATTENING:()=>kS,WGS84_HEIGHT:()=>QS,WGS84_RADIUS:()=>OS});const p="172",f={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},m={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},g=0,A=1,v=2,y=3,_=0,x=1,w=2,C=3,E=0,M=1,S=2,b=0,I=1,T=2,B=3,R=4,D=5,P=100,L=101,U=102,N=103,F=104,O=200,k=201,Q=202,z=203,G=204,H=205,V=206,W=207,j=208,q=209,X=210,Y=211,J=212,K=213,Z=214,$=0,tt=1,et=2,nt=3,it=4,rt=5,st=6,at=7,ot=0,lt=1,ct=2,ht=0,ut=1,dt=2,pt=3,ft=4,mt=5,gt=6,At=7,vt="attached",yt="detached",_t=300,xt=301,wt=302,Ct=303,Et=304,Mt=306,St=1e3,bt=1001,It=1002,Tt=1003,Bt=1004,Rt=1004,Dt=1005,Pt=1005,Lt=1006,Ut=1007,Nt=1007,Ft=1008,Ot=1008,kt=1009,Qt=1010,zt=1011,Gt=1012,Ht=1013,Vt=1014,Wt=1015,jt=1016,qt=1017,Xt=1018,Yt=1020,Jt=35902,Kt=1021,Zt=1022,$t=1023,te=1024,ee=1025,ne=1026,ie=1027,re=1028,se=1029,ae=1030,oe=1031,le=1032,ce=1033,he=33776,ue=33777,de=33778,pe=33779,fe=35840,me=35841,ge=35842,Ae=35843,ve=36196,ye=37492,_e=37496,xe=37808,we=37809,Ce=37810,Ee=37811,Me=37812,Se=37813,be=37814,Ie=37815,Te=37816,Be=37817,Re=37818,De=37819,Pe=37820,Le=37821,Ue=36492,Ne=36494,Fe=36495,Oe=36283,ke=36284,Qe=36285,ze=36286,Ge=2200,He=2201,Ve=2202,We=2300,je=2301,qe=2302,Xe=2400,Ye=2401,Je=2402,Ke=2500,Ze=2501,$e=0,tn=1,en=2,nn=3200,rn=3201,sn=3202,an=3203,on=0,ln=1,cn="",hn="srgb",un="srgb-linear",dn="linear",pn="srgb",fn=0,mn=7680,gn=7681,An=7682,vn=7683,yn=34055,_n=34056,xn=5386,wn=512,Cn=513,En=514,Mn=515,Sn=516,bn=517,In=518,Tn=519,Bn=512,Rn=513,Dn=514,Pn=515,Ln=516,Un=517,Nn=518,Fn=519,On=35044,kn=35048,Qn=35040,zn=35045,Gn=35049,Hn=35041,Vn=35046,Wn=35050,jn=35042,qn="100",Xn="300 es",Yn=2e3,Jn=2001;class Kn{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const n=this._listeners[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const n=e.slice(0);for(let e=0,i=n.length;e>8&255]+Zn[t>>16&255]+Zn[t>>24&255]+"-"+Zn[255&e]+Zn[e>>8&255]+"-"+Zn[e>>16&15|64]+Zn[e>>24&255]+"-"+Zn[63&n|128]+Zn[n>>8&255]+"-"+Zn[n>>16&255]+Zn[n>>24&255]+Zn[255&i]+Zn[i>>8&255]+Zn[i>>16&255]+Zn[i>>24&255]).toLowerCase()}function ii(t,e,n){return Math.max(e,Math.min(n,t))}function ri(t,e){return(t%e+e)%e}function si(t,e,n){return(1-n)*t+n*e}function ai(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function oi(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const li={DEG2RAD:ti,RAD2DEG:ei,generateUUID:ni,clamp:ii,euclideanModulo:ri,mapLinear:function(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)},inverseLerp:function(t,e,n){return t!==e?(n-t)/(e-t):0},lerp:si,damp:function(t,e,n,i){return si(t,e,1-Math.exp(-n*i))},pingpong:function(t,e=1){return e-Math.abs(ri(t,2*e)-e)},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-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())},seededRandom:function(t){void 0!==t&&($n=t);let e=$n+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(t){return t*ti},radToDeg:function(t){return t*ei},isPowerOfTwo:function(t){return!(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,n,i,r){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),c=s((e+i)/2),h=a((e+i)/2),u=s((e-i)/2),d=a((e-i)/2),p=s((i-e)/2),f=a((i-e)/2);switch(r){case"XYX":t.set(o*h,l*u,l*d,o*c);break;case"YZY":t.set(l*d,o*h,l*u,o*c);break;case"ZXZ":t.set(l*u,l*d,o*h,o*c);break;case"XZX":t.set(o*h,l*f,l*p,o*c);break;case"YXY":t.set(l*p,o*h,l*f,o*c);break;case"ZYZ":t.set(l*f,l*p,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:oi,denormalize:ai};class ci{constructor(t=0,e=0){ci.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(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(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=ii(this.x,t.x,e.x),this.y=ii(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=ii(this.x,t,e),this.y=ii(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ii(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(ii(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*n-s*i+t.x,this.y=r*i+s*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class hi{constructor(t,e,n,i,r,s,a,o,l){hi.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,s,a,o,l)}set(t,e,n,i,r,s,a,o,l){const c=this.elements;return c[0]=t,c[1]=i,c[2]=a,c[3]=e,c[4]=r,c[5]=o,c[6]=n,c[7]=s,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const 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}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],a=n[3],o=n[6],l=n[1],c=n[4],h=n[7],u=n[2],d=n[5],p=n[8],f=i[0],m=i[3],g=i[6],A=i[1],v=i[4],y=i[7],_=i[2],x=i[5],w=i[8];return r[0]=s*f+a*A+o*_,r[3]=s*m+a*v+o*x,r[6]=s*g+a*y+o*w,r[1]=l*f+c*A+h*_,r[4]=l*m+c*v+h*x,r[7]=l*g+c*y+h*w,r[2]=u*f+d*A+p*_,r[5]=u*m+d*v+p*x,r[8]=u*g+d*y+p*w,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8];return e*s*c-e*a*l-n*r*c+n*a*o+i*r*l-i*s*o}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8],h=c*s-a*l,u=a*o-c*r,d=l*r-s*o,p=e*h+n*u+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return t[0]=h*f,t[1]=(i*l-c*n)*f,t[2]=(a*n-i*s)*f,t[3]=u*f,t[4]=(c*e-i*o)*f,t[5]=(i*r-a*e)*f,t[6]=d*f,t[7]=(n*o-l*e)*f,t[8]=(s*e-n*r)*f,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,s,a){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*s+l*a)+s+t,-i*l,i*o,-i*(-l*s+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(ui.makeScale(t,e)),this}rotate(t){return this.premultiply(ui.makeRotation(-t)),this}translate(t,e){return this.premultiply(ui.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const ui=new hi;function di(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}const pi={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function fi(t,e){return new pi[t](e)}function mi(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function gi(){const t=mi("canvas");return t.style.display="block",t}const Ai={};function vi(t){t in Ai||(Ai[t]=!0,console.warn(t))}const yi=(new hi).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),_i=(new hi).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function xi(){const t={enabled:!0,workingColorSpace:un,spaces:{},convert:function(t,e,n){return!1!==this.enabled&&e!==n&&e&&n?(this.spaces[e].transfer===pn&&(t.r=Ci(t.r),t.g=Ci(t.g),t.b=Ci(t.b)),this.spaces[e].primaries!==this.spaces[n].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===pn&&(t.r=Ei(t.r),t.g=Ei(t.g),t.b=Ei(t.b)),t):t},fromWorkingColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return t===cn?dn:this.spaces[t].transfer},getLuminanceCoefficients:function(t,e=this.workingColorSpace){return t.fromArray(this.spaces[e].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,e,n){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],i=[.3127,.329];return t.define({[un]:{primaries:e,whitePoint:i,transfer:dn,toXYZ:yi,fromXYZ:_i,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:hn},outputColorSpaceConfig:{drawingBufferColorSpace:hn}},[hn]:{primaries:e,whitePoint:i,transfer:pn,toXYZ:yi,fromXYZ:_i,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:hn}}}),t}const wi=xi();function Ci(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Ei(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let Mi;class Si{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===Mi&&(Mi=mi("canvas")),Mi.width=t.width,Mi.height=t.height;const n=Mi.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Mi}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=mi("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let t=0;t0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==_t)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case St:t.x=t.x-Math.floor(t.x);break;case bt:t.x=t.x<0?0:1;break;case It: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 St:t.y=t.y-Math.floor(t.y);break;case bt:t.y=t.y<0?0:1;break;case It:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}Ri.DEFAULT_IMAGE=null,Ri.DEFAULT_MAPPING=_t,Ri.DEFAULT_ANISOTROPY=1;class Di{constructor(t=0,e=0,n=0,i=1){Di.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(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(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(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(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(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(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(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(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(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}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*e+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*e+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*e+s[7]*n+s[11]*i+s[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const 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(t){let e,n,i,r;const s=.01,a=.1,o=t.elements,l=o[0],c=o[4],h=o[8],u=o[1],d=o[5],p=o[9],f=o[2],m=o[6],g=o[10];if(Math.abs(c-u)o&&t>A?tA?o=0?1:-1,i=1-e*e;if(i>Number.EPSILON){const r=Math.sqrt(i),s=Math.atan2(r,e*n);t=Math.sin(t*s)/r,a=Math.sin(a*s)/r}const r=a*n;if(o=o*t+u*r,l=l*t+d*r,c=c*t+p*r,h=h*t+f*r,t===1-a){const t=1/Math.sqrt(o*o+l*l+c*c+h*h);o*=t,l*=t,c*=t,h*=t}}t[e]=o,t[e+1]=l,t[e+2]=c,t[e+3]=h}static multiplyQuaternionsFlat(t,e,n,i,r,s){const a=n[i],o=n[i+1],l=n[i+2],c=n[i+3],h=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return t[e]=a*p+c*h+o*d-l*u,t[e+1]=o*p+c*u+l*h-a*d,t[e+2]=l*p+c*d+a*u-o*h,t[e+3]=c*p-a*h-o*u-l*d,t}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(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,r=t._z,s=t._order,a=Math.cos,o=Math.sin,l=a(n/2),c=a(i/2),h=a(r/2),u=o(n/2),d=o(i/2),p=o(r/2);switch(s){case"XYZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"YXZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"ZXY":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"ZYX":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"YZX":this._x=u*c*h+l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h-u*d*p;break;case"XZY":this._x=u*c*h-l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],r=e[8],s=e[1],a=e[5],o=e[9],l=e[2],c=e[6],h=e[10],u=n+a+h;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(c-o)*t,this._y=(r-l)*t,this._z=(s-i)*t}else if(n>a&&n>h){const t=2*Math.sqrt(1+n-a-h);this._w=(c-o)/t,this._x=.25*t,this._y=(i+s)/t,this._z=(r+l)/t}else if(a>h){const t=2*Math.sqrt(1+a-n-h);this._w=(r-l)/t,this._x=(i+s)/t,this._y=.25*t,this._z=(o+c)/t}else{const t=2*Math.sqrt(1+h-n-a);this._w=(s-i)/t,this._x=(r+l)/t,this._y=(o+c)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return nMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(ii(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let 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(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,r=t._z,s=t._w,a=e._x,o=e._y,l=e._z,c=e._w;return this._x=n*c+s*a+i*l-r*o,this._y=i*c+s*o+r*a-n*l,this._z=r*c+s*l+n*o-i*a,this._w=s*c-n*a-i*o-r*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const n=this._x,i=this._y,r=this._z,s=this._w;let a=s*t._w+n*t._x+i*t._y+r*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=s,this._x=n,this._y=i,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const t=1-e;return this._w=t*s+e*this._w,this._x=t*n+e*this._x,this._y=t*i+e*this._y,this._z=t*r+e*this._z,this.normalize(),this}const l=Math.sqrt(o),c=Math.atan2(l,a),h=Math.sin((1-e)*c)/l,u=Math.sin(e*c)/l;return this._w=s*h+this._w*u,this._x=n*h+this._x*u,this._y=i*h+this._y*u,this._z=r*h+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Qi{constructor(t=0,e=0,n=0){Qi.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(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(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(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Gi.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Gi.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=t.elements,s=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,r=t.x,s=t.y,a=t.z,o=t.w,l=2*(s*i-a*n),c=2*(a*e-r*i),h=2*(r*n-s*e);return this.x=e+o*l+s*h-a*c,this.y=n+o*c+a*l-r*h,this.z=i+o*h+r*c-s*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(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(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(t,e){return this.x=ii(this.x,t.x,e.x),this.y=ii(this.y,t.y,e.y),this.z=ii(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=ii(this.x,t,e),this.y=ii(this.y,t,e),this.z=ii(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ii(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(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(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,r=t.z,s=e.x,a=e.y,o=e.z;return this.x=i*o-r*a,this.y=r*s-n*o,this.z=n*a-i*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return zi.copy(this).projectOnVector(t),this.sub(zi)}reflect(t){return this.sub(zi.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(ii(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const zi=new Qi,Gi=new ki;class Hi{constructor(t=new Qi(1/0,1/0,1/0),e=new Qi(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(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(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Wi),Wi.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter($i),tr.subVectors(this.max,$i),qi.subVectors(t.a,$i),Xi.subVectors(t.b,$i),Yi.subVectors(t.c,$i),Ji.subVectors(Xi,qi),Ki.subVectors(Yi,Xi),Zi.subVectors(qi,Yi);let e=[0,-Ji.z,Ji.y,0,-Ki.z,Ki.y,0,-Zi.z,Zi.y,Ji.z,0,-Ji.x,Ki.z,0,-Ki.x,Zi.z,0,-Zi.x,-Ji.y,Ji.x,0,-Ki.y,Ki.x,0,-Zi.y,Zi.x,0];return!!ir(e,qi,Xi,Yi,tr)&&(e=[1,0,0,0,1,0,0,0,1],!!ir(e,qi,Xi,Yi,tr)&&(er.crossVectors(Ji,Ki),e=[er.x,er.y,er.z],ir(e,qi,Xi,Yi,tr)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Wi).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(Wi).length()),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(Vi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Vi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Vi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Vi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Vi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Vi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Vi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Vi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Vi)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Vi=[new Qi,new Qi,new Qi,new Qi,new Qi,new Qi,new Qi,new Qi],Wi=new Qi,ji=new Hi,qi=new Qi,Xi=new Qi,Yi=new Qi,Ji=new Qi,Ki=new Qi,Zi=new Qi,$i=new Qi,tr=new Qi,er=new Qi,nr=new Qi;function ir(t,e,n,i,r){for(let s=0,a=t.length-3;s<=a;s+=3){nr.fromArray(t,s);const a=r.x*Math.abs(nr.x)+r.y*Math.abs(nr.y)+r.z*Math.abs(nr.z),o=e.dot(nr),l=n.dot(nr),c=i.dot(nr);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>a)return!1}return!0}const rr=new Hi,sr=new Qi,ar=new Qi;class or{constructor(t=new Qi,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):rr.setFromPoints(t).getCenter(n);let i=0;for(let e=0,r=t.length;ethis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;sr.subVectors(t,this.center);const e=sr.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.addScaledVector(sr,n/t),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(ar.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(sr.copy(t.center).add(ar)),this.expandByPoint(sr.copy(t.center).sub(ar))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const lr=new Qi,cr=new Qi,hr=new Qi,ur=new Qi,dr=new Qi,pr=new Qi,fr=new Qi;class mr{constructor(t=new Qi,e=new Qi(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,lr)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=lr.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(lr.copy(this.origin).addScaledVector(this.direction,e),lr.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){cr.copy(t).add(e).multiplyScalar(.5),hr.copy(e).sub(t).normalize(),ur.copy(this.origin).sub(cr);const r=.5*t.distanceTo(e),s=-this.direction.dot(hr),a=ur.dot(this.direction),o=-ur.dot(hr),l=ur.lengthSq(),c=Math.abs(1-s*s);let h,u,d,p;if(c>0)if(h=s*o-a,u=s*a-o,p=r*c,h>=0)if(u>=-p)if(u<=p){const t=1/c;h*=t,u*=t,d=h*(h+s*u+2*a)+u*(s*h+u+2*o)+l}else u=r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u=-r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u<=-p?(h=Math.max(0,-(-s*r+a)),u=h>0?-r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l):u<=p?(h=0,u=Math.min(Math.max(-r,-o),r),d=u*(u+2*o)+l):(h=Math.max(0,-(s*r+a)),u=h>0?r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l);else u=s>0?-r:r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(cr).addScaledVector(hr,u),d}intersectSphere(t,e){lr.subVectors(t.center,this.origin);const n=lr.dot(this.direction),i=lr.dot(lr)-n*n,r=t.radius*t.radius;if(i>r)return null;const s=Math.sqrt(r-i),a=n-s,o=n+s;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,s,a,o;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,u=this.origin;return l>=0?(n=(t.min.x-u.x)*l,i=(t.max.x-u.x)*l):(n=(t.max.x-u.x)*l,i=(t.min.x-u.x)*l),c>=0?(r=(t.min.y-u.y)*c,s=(t.max.y-u.y)*c):(r=(t.max.y-u.y)*c,s=(t.min.y-u.y)*c),n>s||r>i?null:((r>n||isNaN(n))&&(n=r),(s=0?(a=(t.min.z-u.z)*h,o=(t.max.z-u.z)*h):(a=(t.max.z-u.z)*h,o=(t.min.z-u.z)*h),n>o||a>i?null:((a>n||n!=n)&&(n=a),(o=0?n:i,e)))}intersectsBox(t){return null!==this.intersectBox(t,lr)}intersectTriangle(t,e,n,i,r){dr.subVectors(e,t),pr.subVectors(n,t),fr.crossVectors(dr,pr);let s,a=this.direction.dot(fr);if(a>0){if(i)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}ur.subVectors(this.origin,t);const o=s*this.direction.dot(pr.crossVectors(ur,pr));if(o<0)return null;const l=s*this.direction.dot(dr.cross(ur));if(l<0)return null;if(o+l>a)return null;const c=-s*ur.dot(fr);return c<0?null:this.at(c/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class gr{constructor(t,e,n,i,r,s,a,o,l,c,h,u,d,p,f,m){gr.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,s,a,o,l,c,h,u,d,p,f,m)}set(t,e,n,i,r,s,a,o,l,c,h,u,d,p,f,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=i,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=c,g[10]=h,g[14]=u,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new gr).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,i=1/Ar.setFromMatrixColumn(t,0).length(),r=1/Ar.setFromMatrixColumn(t,1).length(),s=1/Ar.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*s,e[9]=n[9]*s,e[10]=n[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,r=t.z,s=Math.cos(n),a=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(r),h=Math.sin(r);if("XYZ"===t.order){const t=s*c,n=s*h,i=a*c,r=a*h;e[0]=o*c,e[4]=-o*h,e[8]=l,e[1]=n+i*l,e[5]=t-r*l,e[9]=-a*o,e[2]=r-t*l,e[6]=i+n*l,e[10]=s*o}else if("YXZ"===t.order){const t=o*c,n=o*h,i=l*c,r=l*h;e[0]=t+r*a,e[4]=i*a-n,e[8]=s*l,e[1]=s*h,e[5]=s*c,e[9]=-a,e[2]=n*a-i,e[6]=r+t*a,e[10]=s*o}else if("ZXY"===t.order){const t=o*c,n=o*h,i=l*c,r=l*h;e[0]=t-r*a,e[4]=-s*h,e[8]=i+n*a,e[1]=n+i*a,e[5]=s*c,e[9]=r-t*a,e[2]=-s*l,e[6]=a,e[10]=s*o}else if("ZYX"===t.order){const t=s*c,n=s*h,i=a*c,r=a*h;e[0]=o*c,e[4]=i*l-n,e[8]=t*l+r,e[1]=o*h,e[5]=r*l+t,e[9]=n*l-i,e[2]=-l,e[6]=a*o,e[10]=s*o}else if("YZX"===t.order){const t=s*o,n=s*l,i=a*o,r=a*l;e[0]=o*c,e[4]=r-t*h,e[8]=i*h+n,e[1]=h,e[5]=s*c,e[9]=-a*c,e[2]=-l*c,e[6]=n*h+i,e[10]=t-r*h}else if("XZY"===t.order){const t=s*o,n=s*l,i=a*o,r=a*l;e[0]=o*c,e[4]=-h,e[8]=l*c,e[1]=t*h+r,e[5]=s*c,e[9]=n*h-i,e[2]=i*h-n,e[6]=a*c,e[10]=r*h+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(yr,t,_r)}lookAt(t,e,n){const i=this.elements;return Cr.subVectors(t,e),0===Cr.lengthSq()&&(Cr.z=1),Cr.normalize(),xr.crossVectors(n,Cr),0===xr.lengthSq()&&(1===Math.abs(n.z)?Cr.x+=1e-4:Cr.z+=1e-4,Cr.normalize(),xr.crossVectors(n,Cr)),xr.normalize(),wr.crossVectors(Cr,xr),i[0]=xr.x,i[4]=wr.x,i[8]=Cr.x,i[1]=xr.y,i[5]=wr.y,i[9]=Cr.y,i[2]=xr.z,i[6]=wr.z,i[10]=Cr.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],a=n[4],o=n[8],l=n[12],c=n[1],h=n[5],u=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],A=n[3],v=n[7],y=n[11],_=n[15],x=i[0],w=i[4],C=i[8],E=i[12],M=i[1],S=i[5],b=i[9],I=i[13],T=i[2],B=i[6],R=i[10],D=i[14],P=i[3],L=i[7],U=i[11],N=i[15];return r[0]=s*x+a*M+o*T+l*P,r[4]=s*w+a*S+o*B+l*L,r[8]=s*C+a*b+o*R+l*U,r[12]=s*E+a*I+o*D+l*N,r[1]=c*x+h*M+u*T+d*P,r[5]=c*w+h*S+u*B+d*L,r[9]=c*C+h*b+u*R+d*U,r[13]=c*E+h*I+u*D+d*N,r[2]=p*x+f*M+m*T+g*P,r[6]=p*w+f*S+m*B+g*L,r[10]=p*C+f*b+m*R+g*U,r[14]=p*E+f*I+m*D+g*N,r[3]=A*x+v*M+y*T+_*P,r[7]=A*w+v*S+y*B+_*L,r[11]=A*C+v*b+y*R+_*U,r[15]=A*E+v*I+y*D+_*N,this}multiplyScalar(t){const 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}determinant(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],s=t[1],a=t[5],o=t[9],l=t[13],c=t[2],h=t[6],u=t[10],d=t[14];return t[3]*(+r*o*h-i*l*h-r*a*u+n*l*u+i*a*d-n*o*d)+t[7]*(+e*o*d-e*l*u+r*s*u-i*s*d+i*l*c-r*o*c)+t[11]*(+e*l*h-e*a*d-r*s*h+n*s*d+r*a*c-n*l*c)+t[15]*(-i*a*c-e*o*h+e*a*u+i*s*h-n*s*u+n*o*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8],h=t[9],u=t[10],d=t[11],p=t[12],f=t[13],m=t[14],g=t[15],A=h*m*l-f*u*l+f*o*d-a*m*d-h*o*g+a*u*g,v=p*u*l-c*m*l-p*o*d+s*m*d+c*o*g-s*u*g,y=c*f*l-p*h*l+p*a*d-s*f*d-c*a*g+s*h*g,_=p*h*o-c*f*o-p*a*u+s*f*u+c*a*m-s*h*m,x=e*A+n*v+i*y+r*_;if(0===x)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/x;return t[0]=A*w,t[1]=(f*u*r-h*m*r-f*i*d+n*m*d+h*i*g-n*u*g)*w,t[2]=(a*m*r-f*o*r+f*i*l-n*m*l-a*i*g+n*o*g)*w,t[3]=(h*o*r-a*u*r-h*i*l+n*u*l+a*i*d-n*o*d)*w,t[4]=v*w,t[5]=(c*m*r-p*u*r+p*i*d-e*m*d-c*i*g+e*u*g)*w,t[6]=(p*o*r-s*m*r-p*i*l+e*m*l+s*i*g-e*o*g)*w,t[7]=(s*u*r-c*o*r+c*i*l-e*u*l-s*i*d+e*o*d)*w,t[8]=y*w,t[9]=(p*h*r-c*f*r-p*n*d+e*f*d+c*n*g-e*h*g)*w,t[10]=(s*f*r-p*a*r+p*n*l-e*f*l-s*n*g+e*a*g)*w,t[11]=(c*a*r-s*h*r-c*n*l+e*h*l+s*n*d-e*a*d)*w,t[12]=_*w,t[13]=(c*f*i-p*h*i+p*n*u-e*f*u-c*n*m+e*h*m)*w,t[14]=(p*a*i-s*f*i-p*n*o+e*f*o+s*n*m-e*a*m)*w,t[15]=(s*h*i-c*a*i+c*n*o-e*h*o-s*n*u+e*a*u)*w,this}scale(t){const e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),r=1-n,s=t.x,a=t.y,o=t.z,l=r*s,c=r*a;return this.set(l*s+n,l*a-i*o,l*o+i*a,0,l*a+i*o,c*a+n,c*o-i*s,0,l*o-i*a,c*o+i*s,r*o*o+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,s){return this.set(1,n,r,0,t,1,s,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,r=e._x,s=e._y,a=e._z,o=e._w,l=r+r,c=s+s,h=a+a,u=r*l,d=r*c,p=r*h,f=s*c,m=s*h,g=a*h,A=o*l,v=o*c,y=o*h,_=n.x,x=n.y,w=n.z;return i[0]=(1-(f+g))*_,i[1]=(d+y)*_,i[2]=(p-v)*_,i[3]=0,i[4]=(d-y)*x,i[5]=(1-(u+g))*x,i[6]=(m+A)*x,i[7]=0,i[8]=(p+v)*w,i[9]=(m-A)*w,i[10]=(1-(u+f))*w,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;let r=Ar.set(i[0],i[1],i[2]).length();const s=Ar.set(i[4],i[5],i[6]).length(),a=Ar.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],vr.copy(this);const o=1/r,l=1/s,c=1/a;return vr.elements[0]*=o,vr.elements[1]*=o,vr.elements[2]*=o,vr.elements[4]*=l,vr.elements[5]*=l,vr.elements[6]*=l,vr.elements[8]*=c,vr.elements[9]*=c,vr.elements[10]*=c,e.setFromRotationMatrix(vr),n.x=r,n.y=s,n.z=a,this}makePerspective(t,e,n,i,r,s,a=Yn){const o=this.elements,l=2*r/(e-t),c=2*r/(n-i),h=(e+t)/(e-t),u=(n+i)/(n-i);let d,p;if(a===Yn)d=-(s+r)/(s-r),p=-2*s*r/(s-r);else{if(a!==Jn)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);d=-s/(s-r),p=-s*r/(s-r)}return o[0]=l,o[4]=0,o[8]=h,o[12]=0,o[1]=0,o[5]=c,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,n,i,r,s,a=Yn){const o=this.elements,l=1/(e-t),c=1/(n-i),h=1/(s-r),u=(e+t)*l,d=(n+i)*c;let p,f;if(a===Yn)p=(s+r)*h,f=-2*h;else{if(a!==Jn)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=r*h,f=-1*h}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=f,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const Ar=new Qi,vr=new gr,yr=new Qi(0,0,0),_r=new Qi(1,1,1),xr=new Qi,wr=new Qi,Cr=new Qi,Er=new gr,Mr=new ki;class Sr{constructor(t=0,e=0,n=0,i=Sr.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}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(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,r=i[0],s=i[4],a=i[8],o=i[1],l=i[5],c=i[9],h=i[2],u=i[6],d=i[10];switch(e){case"XYZ":this._y=Math.asin(ii(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-ii(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(ii(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-ii(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(ii(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-ii(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Er.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Er,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Mr.setFromEuler(this),this.setFromQuaternion(Mr,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(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(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Sr.DEFAULT_ORDER="XYZ";class br{constructor(){this.mask=1}set(t){this.mask=1<>>0}enable(t){this.mask|=1<1){for(let t=0;t1){for(let t=0;t0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map((t=>({boxInitialized:t.boxInitialized,boxMin:t.box.min.toArray(),boxMax:t.box.max.toArray(),sphereInitialized:t.sphereInitialized,sphereRadius:t.sphere.radius,sphereCenter:t.sphere.center.toArray()}))),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),null!==this.boundingBox&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const n=e.shapes;if(Array.isArray(n))for(let e=0,i=n.length;e0){i.children=[];for(let e=0;e0){i.animations=[];for(let e=0;e0&&(n.geometries=e),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),a.length>0&&(n.images=a),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),h.length>0&&(n.nodes=h)}return n.object=i,n;function s(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,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.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,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.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){Vr.subVectors(i,e),Wr.subVectors(n,e),jr.subVectors(t,e);const s=Vr.dot(Vr),a=Vr.dot(Wr),o=Vr.dot(jr),l=Wr.dot(Wr),c=Wr.dot(jr),h=s*l-a*a;if(0===h)return r.set(0,0,0),null;const u=1/h,d=(l*o-a*c)*u,p=(s*c-a*o)*u;return r.set(1-d-p,p,d)}static containsPoint(t,e,n,i){return null!==this.getBarycoord(t,e,n,i,qr)&&qr.x>=0&&qr.y>=0&&qr.x+qr.y<=1}static getInterpolation(t,e,n,i,r,s,a,o){return null===this.getBarycoord(t,e,n,i,qr)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,qr.x),o.addScaledVector(s,qr.y),o.addScaledVector(a,qr.z),o)}static getInterpolatedAttribute(t,e,n,i,r,s){return ts.setScalar(0),es.setScalar(0),ns.setScalar(0),ts.fromBufferAttribute(t,e),es.fromBufferAttribute(t,n),ns.fromBufferAttribute(t,i),s.setScalar(0),s.addScaledVector(ts,r.x),s.addScaledVector(es,r.y),s.addScaledVector(ns,r.z),s}static isFrontFacing(t,e,n,i){return Vr.subVectors(n,e),Wr.subVectors(t,e),Vr.cross(Wr).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Vr.subVectors(this.c,this.b),Wr.subVectors(this.a,this.b),.5*Vr.cross(Wr).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return is.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return is.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return is.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return is.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return is.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,r=this.c;let s,a;Xr.subVectors(i,n),Yr.subVectors(r,n),Kr.subVectors(t,n);const o=Xr.dot(Kr),l=Yr.dot(Kr);if(o<=0&&l<=0)return e.copy(n);Zr.subVectors(t,i);const c=Xr.dot(Zr),h=Yr.dot(Zr);if(c>=0&&h<=c)return e.copy(i);const u=o*h-c*l;if(u<=0&&o>=0&&c<=0)return s=o/(o-c),e.copy(n).addScaledVector(Xr,s);$r.subVectors(t,r);const d=Xr.dot($r),p=Yr.dot($r);if(p>=0&&d<=p)return e.copy(r);const f=d*l-o*p;if(f<=0&&l>=0&&p<=0)return a=l/(l-p),e.copy(n).addScaledVector(Yr,a);const m=c*p-d*h;if(m<=0&&h-c>=0&&d-p>=0)return Jr.subVectors(r,i),a=(h-c)/(h-c+(d-p)),e.copy(i).addScaledVector(Jr,a);const g=1/(m+f+u);return s=f*g,a=u*g,e.copy(n).addScaledVector(Xr,s).addScaledVector(Yr,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const rs={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ss={h:0,s:0,l:0},as={h:0,s:0,l:0};function os(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}class ls{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(void 0===e&&void 0===n){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=hn){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,wi.toWorkingColorSpace(this,e),this}setRGB(t,e,n,i=wi.workingColorSpace){return this.r=t,this.g=e,this.b=n,wi.toWorkingColorSpace(this,i),this}setHSL(t,e,n,i=wi.workingColorSpace){if(t=ri(t,1),e=ii(e,0,1),n=ii(n,0,1),0===e)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+e):n+e-n*e,r=2*n-i;this.r=os(r,i,t+1/3),this.g=os(r,i,t),this.b=os(r,i,t-1/3)}return wi.toWorkingColorSpace(this,i),this}setStyle(t,e=hn){function n(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(n,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=hn){const n=rs[t.toLowerCase()];return void 0!==n?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Ci(t.r),this.g=Ci(t.g),this.b=Ci(t.b),this}copyLinearToSRGB(t){return this.r=Ei(t.r),this.g=Ei(t.g),this.b=Ei(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=hn){return wi.fromWorkingColorSpace(cs.copy(this),t),65536*Math.round(ii(255*cs.r,0,255))+256*Math.round(ii(255*cs.g,0,255))+Math.round(ii(255*cs.b,0,255))}getHexString(t=hn){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=wi.workingColorSpace){wi.fromWorkingColorSpace(cs.copy(this),e);const n=cs.r,i=cs.g,r=cs.b,s=Math.max(n,i,r),a=Math.min(n,i,r);let o,l;const c=(a+s)/2;if(a===s)o=0,l=0;else{const t=s-a;switch(l=c<=.5?t/(s+a):t/(2-s-a),s){case n:o=(i-r)/t+(i0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n:console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}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),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.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.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.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,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),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.normalMapType=this.normalMapType,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.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==I&&(n.blending=this.blending),this.side!==E&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),this.blendSrc!==G&&(n.blendSrc=this.blendSrc),this.blendDst!==H&&(n.blendDst=this.blendDst),this.blendEquation!==P&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==nt&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Tn&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==mn&&(n.stencilFail=this.stencilFail),this.stencilZFail!==mn&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==mn&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),e){const e=i(t.textures),r=i(t.images);e.length>0&&(n.textures=e),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,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.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let i=0;i!==t;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class ds extends us{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ls(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Sr,this.combine=ot,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const ps=fs();function fs(){const t=new ArrayBuffer(4),e=new Float32Array(t),n=new Uint32Array(t),i=new Uint32Array(512),r=new Uint32Array(512);for(let t=0;t<256;++t){const e=t-127;e<-27?(i[t]=0,i[256|t]=32768,r[t]=24,r[256|t]=24):e<-14?(i[t]=1024>>-e-14,i[256|t]=1024>>-e-14|32768,r[t]=-e-1,r[256|t]=-e-1):e<=15?(i[t]=e+15<<10,i[256|t]=e+15<<10|32768,r[t]=13,r[256|t]=13):e<128?(i[t]=31744,i[256|t]=64512,r[t]=24,r[256|t]=24):(i[t]=31744,i[256|t]=64512,r[t]=13,r[256|t]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let t=1;t<1024;++t){let e=t<<13,n=0;for(;!(8388608&e);)e<<=1,n-=8388608;e&=-8388609,n+=947912704,s[t]=e|n}for(let t=1024;t<2048;++t)s[t]=939524096+(t-1024<<13);for(let t=1;t<31;++t)a[t]=t<<23;a[31]=1199570944,a[32]=2147483648;for(let t=33;t<63;++t)a[t]=2147483648+(t-32<<23);a[63]=3347054592;for(let t=1;t<64;++t)32!==t&&(o[t]=1024);return{floatView:e,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}function ms(t){Math.abs(t)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),t=ii(t,-65504,65504),ps.floatView[0]=t;const e=ps.uint32View[0],n=e>>23&511;return ps.baseTable[n]+((8388607&e)>>ps.shiftTable[n])}function gs(t){const e=t>>10;return ps.uint32View[0]=ps.mantissaTable[ps.offsetTable[e]+(1023&t)]+ps.exponentTable[e],ps.floatView[0]}const As={toHalfFloat:ms,fromHalfFloat:gs},vs=new Qi,ys=new ci;class _s{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=n,this.usage=On,this.updateRanges=[],this.gpuType=Wt,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;ie.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Hi);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new Qi(-1/0,-1/0,-1/0),new Qi(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const e in n){const i=n[e];t.data.attributes[e]=i.toJSON(t.data)}const i={};let r=!1;for(const e in this.morphAttributes){const n=this.morphAttributes[e],s=[];for(let e=0,i=n.length;e0&&(i[e]=s,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;null!==n&&this.setIndex(n.clone(e));const i=t.attributes;for(const t in i){const n=i[t];this.setAttribute(t,n.clone(e))}const r=t.morphAttributes;for(const t in r){const n=[],i=r[t];for(let t=0,r=i.length;t0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t(t.far-t.near)**2)return}Os.copy(r).invert(),ks.copy(t.ray).applyMatrix4(Os),null!==n.boundingBox&&!1===ks.intersectsBox(n.boundingBox)||this._computeIntersections(t,e,ks)}}_computeIntersections(t,e,n){let i;const r=this.geometry,s=this.material,a=r.index,o=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,h=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==a)if(Array.isArray(s))for(let r=0,o=u.length;rn.far?null:{distance:c,point:Xs.clone(),object:t}}(t,e,n,i,Gs,Hs,Vs,qs);if(h){const t=new Qi;is.getBarycoord(qs,Gs,Hs,Vs,t),r&&(h.uv=is.getInterpolatedAttribute(r,o,l,c,t,new ci)),s&&(h.uv1=is.getInterpolatedAttribute(s,o,l,c,t,new ci)),a&&(h.normal=is.getInterpolatedAttribute(a,o,l,c,t,new Qi),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const e={a:o,b:l,c,normal:new Qi,materialIndex:0};is.getNormal(Gs,Hs,Vs,e.normal),h.face=e,h.barycoord=t}return h}class Ks extends Fs{constructor(t=1,e=1,n=1,i=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};const a=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);const o=[],l=[],c=[],h=[];let u=0,d=0;function p(t,e,n,i,r,s,p,f,m,g,A){const v=s/m,y=p/g,_=s/2,x=p/2,w=f/2,C=m+1,E=g+1;let M=0,S=0;const b=new Qi;for(let s=0;s0?1:-1,c.push(b.x,b.y,b.z),h.push(o/m),h.push(1-s/g),M+=1}}for(let t=0;t0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const t in this.extensions)!0===this.extensions[t]&&(n[t]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class ia extends Hr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new gr,this.projectionMatrix=new gr,this.projectionMatrixInverse=new gr,this.coordinateSystem=Yn}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}const ra=new Qi,sa=new ci,aa=new ci;class oa extends ia{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*ei*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*ti*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*ei*Math.atan(Math.tan(.5*ti*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){ra.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(ra.x,ra.y).multiplyScalar(-t/ra.z),ra.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ra.x,ra.y).multiplyScalar(-t/ra.z)}getViewSize(t,e){return this.getViewBounds(t,sa,aa),e.subVectors(aa,sa)}setViewOffset(t,e,n,i,r,s){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*ti*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i;const s=this.view;if(null!==this.view&&this.view.enabled){const t=s.fullWidth,a=s.fullHeight;r+=s.offsetX*i/t,e-=s.offsetY*n/a,i*=s.width/t,n*=s.height/a}const a=this.filmOffset;0!==a&&(r+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const la=-90;class ca extends Hr{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new oa(la,1,t,e);i.layers=this.layers,this.add(i);const r=new oa(la,1,t,e);r.layers=this.layers,this.add(r);const s=new oa(la,1,t,e);s.layers=this.layers,this.add(s);const a=new oa(la,1,t,e);a.layers=this.layers,this.add(a);const o=new oa(la,1,t,e);o.layers=this.layers,this.add(o);const l=new oa(la,1,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,r,s,a,o]=e;for(const t of e)this.remove(t);if(t===Yn)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(t!==Jn)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const t of e)this.add(t),t.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,s,a,o,l,c]=this.children,h=t.getRenderTarget(),u=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,i),t.render(e,r),t.setRenderTarget(n,1,i),t.render(e,s),t.setRenderTarget(n,2,i),t.render(e,a),t.setRenderTarget(n,3,i),t.render(e,o),t.setRenderTarget(n,4,i),t.render(e,l),n.texture.generateMipmaps=f,t.setRenderTarget(n,5,i),t.render(e,c),t.setRenderTarget(h,u,d),t.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class ha extends Ri{constructor(t,e,n,i,r,s,a,o,l,c){super(t=void 0!==t?t:[],e=void 0!==e?e:xt,n,i,r,s,a,o,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class ua extends Li{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];this.texture=new ha(i,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:Lt}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={tEquirect:{value:null}},i="\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",r="\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",s=new Ks(5,5,5),a=new na({name:"CubemapFromEquirect",uniforms:Zs(n),vertexShader:i,fragmentShader:r,side:M,blending:b});a.uniforms.tEquirect.value=e;const o=new Ys(s,a),l=e.minFilter;return e.minFilter===Ft&&(e.minFilter=Lt),new ca(1,10,this).update(t,o),e.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(t,e,n,i){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,n,i);t.setRenderTarget(r)}}class da{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new ls(t),this.density=e}clone(){return new da(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class pa{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new ls(t),this.near=e,this.far=n}clone(){return new pa(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class fa extends Hr{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Sr,this.environmentIntensity=1,this.environmentRotation=new Sr,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class ma{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=On,this.updateRanges=[],this.version=0,this.uuid=ni()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;it.far||e.push({distance:o,point:_a.clone(),uv:is.getInterpolation(_a,Sa,ba,Ia,Ta,Ba,Ra,new ci),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function Pa(t,e,n,i,r,s){Ca.subVectors(t,n).addScalar(.5).multiply(i),void 0!==r?(Ea.x=s*Ca.x-r*Ca.y,Ea.y=r*Ca.x+s*Ca.y):Ea.copy(Ca),t.copy(e),t.x+=Ea.x,t.y+=Ea.y,t.applyMatrix4(Ma)}const La=new Qi,Ua=new Qi;class Na extends Hr{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let t=0,n=e.length;t0){let n,i;for(n=1,i=e.length;n0){La.setFromMatrixPosition(this.matrixWorld);const n=t.ray.origin.distanceTo(La);this.getObjectForDistance(n).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){La.setFromMatrixPosition(t.matrixWorld),Ua.setFromMatrixPosition(this.matrixWorld);const n=La.distanceTo(Ua)/t.zoom;let i,r;for(e[0].object.visible=!0,i=1,r=e.length;i=t))break;e[i-1].object.visible=!1,e[i].object.visible=!0}for(this._currentLevel=i-1;i1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||co.getNormalMatrix(t),i=this.coplanarPoint(oo).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const uo=new or,po=new Qi;class fo{constructor(t=new ho,e=new ho,n=new ho,i=new ho,r=new ho,s=new ho){this.planes=[t,e,n,i,r,s]}set(t,e,n,i,r,s){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(s),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=Yn){const n=this.planes,i=t.elements,r=i[0],s=i[1],a=i[2],o=i[3],l=i[4],c=i[5],h=i[6],u=i[7],d=i[8],p=i[9],f=i[10],m=i[11],g=i[12],A=i[13],v=i[14],y=i[15];if(n[0].setComponents(o-r,u-l,m-d,y-g).normalize(),n[1].setComponents(o+r,u+l,m+d,y+g).normalize(),n[2].setComponents(o+s,u+c,m+p,y+A).normalize(),n[3].setComponents(o-s,u-c,m-p,y-A).normalize(),n[4].setComponents(o-a,u-h,m-f,y-v).normalize(),e===Yn)n[5].setComponents(o+a,u+h,m+f,y+v).normalize();else{if(e!==Jn)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);n[5].setComponents(a,h,f,v).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),uo.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),uo.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(uo)}intersectsSprite(t){return uo.center.set(0,0,0),uo.radius=.7071067811865476,uo.applyMatrix4(t.matrixWorld),this.intersectsSphere(uo)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let t=0;t<6;t++)if(e[t].distanceToPoint(n)0?t.max.x:t.min.x,po.y=i.normal.y>0?t.max.y:t.min.y,po.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(po)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function mo(t,e){return t-e}function go(t,e){return t.z-e.z}function Ao(t,e){return e.z-t.z}class vo{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,e,n,i){const r=this.pool,s=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const a=r[this.index];s.push(a),this.index++,a.start=t,a.count=e,a.z=n,a.index=i}reset(){this.list.length=0,this.index=0}}const yo=new gr,_o=new ls(1,1,1),xo=new fo,wo=new Hi,Co=new or,Eo=new Qi,Mo=new Qi,So=new Qi,bo=new vo,Io=new Ys,To=[];function Bo(t,e,n=0){const i=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const r=t.count;for(let s=0;s65535?new Uint32Array(i):new Uint16Array(i);e.setIndex(new _s(t,1))}this._geometryInitialized=!0}}_validateGeometry(t){const e=this.geometry;if(Boolean(t.getIndex())!==Boolean(e.getIndex()))throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in e.attributes){if(!t.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=t.getAttribute(n),r=e.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(t){const e=this._instanceInfo;if(t<0||t>=e.length||!1===e[t].active)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${t}. Instance is either out of range or has been deleted.`)}validateGeometryId(t){const e=this._geometryInfo;if(t<0||t>=e.length||!1===e[t].active)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${t}. Geometry is either out of range or has been deleted.`)}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Hi);const t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const e={visible:!0,active:!0,geometryIndex:t};let n=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(mo),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=e):(n=this._instanceInfo.length,this._instanceInfo.push(e));const i=this._matricesTexture;yo.identity().toArray(i.image.data,16*n),i.needsUpdate=!0;const r=this._colorsTexture;return r&&(_o.toArray(r.image.data,4*n),r.needsUpdate=!0),this._visibilityChanged=!0,n}addGeometry(t,e=-1,n=-1){this._initializeGeometry(t),this._validateGeometry(t);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=-1===e?t.getAttribute("position").count:e;const s=t.getIndex();if(null!==s&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=-1===n?s.count:n),-1!==i.indexStart&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let a;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(mo),a=this._availableGeometryIds.shift(),r[a]=i):(a=this._geometryCount,this._geometryCount++,r.push(i)),this.setGeometryAt(a,t),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,a}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const n=this.geometry,i=null!==n.getIndex(),r=n.getIndex(),s=e.getIndex(),a=this._geometryInfo[t];if(i&&s.count>a.reservedIndexCount||e.attributes.position.count>a.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const o=a.vertexStart,l=a.reservedVertexCount;a.vertexCount=e.getAttribute("position").count;for(const t in n.attributes){const i=e.getAttribute(t),r=n.getAttribute(t);Bo(i,r,o);const s=i.itemSize;for(let t=i.count,e=l;t=e.length||!1===e[t].active)return this;const n=this._instanceInfo;for(let e=0,i=n.length;ee)).sort(((t,e)=>n[t].vertexStart-n[e].vertexStart)),r=this.geometry;for(let s=0,a=n.length;s=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(null===i.boundingBox){const t=new Hi,e=n.index,r=n.attributes.position;for(let n=i.start,s=i.start+i.count;n=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(null===i.boundingSphere){const e=new or;this.getBoundingBoxAt(t,wo),wo.getCenter(e.center);const r=n.index,s=n.attributes.position;let a=0;for(let t=i.start,n=i.start+i.count;tt.active));if(Math.max(...n.map((t=>t.vertexStart+t.reservedVertexCount)))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map((t=>t.indexStart+t.reservedIndexCount)))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`);const i=this.geometry;i.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Fs,this._initializeGeometry(i));const r=this.geometry;i.index&&Ro(i.index.array,r.index.array);for(const t in i.attributes)Ro(i.attributes[t].array,r.attributes[t].array)}raycast(t,e){const n=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,s=this.geometry;Io.material=this.material,Io.geometry.index=s.index,Io.geometry.attributes=s.attributes,null===Io.geometry.boundingBox&&(Io.geometry.boundingBox=new Hi),null===Io.geometry.boundingSphere&&(Io.geometry.boundingSphere=new or);for(let s=0,a=n.length;s({...t,boundingBox:null!==t.boundingBox?t.boundingBox.clone():null,boundingSphere:null!==t.boundingSphere?t.boundingSphere.clone():null}))),this._instanceInfo=t._instanceInfo.map((t=>({...t}))),this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(t,e,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=i.getIndex(),a=null===s?1:s.array.BYTES_PER_ELEMENT,o=this._instanceInfo,l=this._multiDrawStarts,c=this._multiDrawCounts,h=this._geometryInfo,u=this.perObjectFrustumCulled,d=this._indirectTexture,p=d.image.data;u&&(yo.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),xo.setFromProjectionMatrix(yo,t.coordinateSystem));let f=0;if(this.sortObjects){yo.copy(this.matrixWorld).invert(),Eo.setFromMatrixPosition(n.matrixWorld).applyMatrix4(yo),Mo.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(yo);for(let t=0,e=o.length;t0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;ti)return;ko.applyMatrix4(t.matrixWorld);const o=e.ray.origin.distanceTo(ko);return oe.far?void 0:{distance:o,point:Qo.clone().applyMatrix4(t.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:t}}const Ho=new Qi,Vo=new Qi;class Wo extends zo{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[];for(let t=0,i=e.count;t0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;tr.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class tl extends Hr{constructor(){super(),this.isGroup=!0,this.type="Group"}}class el extends Ri{constructor(t,e,n,i,r,s,a,o,l){super(t,e,n,i,r,s,a,o,l),this.isVideoTexture=!0,this.minFilter=void 0!==s?s:Lt,this.magFilter=void 0!==r?r:Lt,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback((function e(){c.needsUpdate=!0,t.requestVideoFrameCallback(e)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;!1=="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class nl extends Ri{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=Tt,this.minFilter=Tt,this.generateMipmaps=!1,this.needsUpdate=!0}}class il extends Ri{constructor(t,e,n,i,r,s,a,o,l,c,h,u){super(null,s,a,o,l,c,i,r,h,u),this.isCompressedTexture=!0,this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class rl extends il{constructor(t,e,n,i,r,s){super(t,e,n,r,s),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=bt,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class sl extends il{constructor(t,e,n){super(void 0,t[0].width,t[0].height,e,n,xt),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}}class al extends Ri{constructor(t,e,n,i,r,s,a,o,l){super(t,e,n,i,r,s,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class ol extends Ri{constructor(t,e,n,i,r,s,a,o,l,c=ne){if(c!==ne&&c!==ie)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===ne&&(n=Vt),void 0===n&&c===ie&&(n=Yt),super(null,i,r,s,a,o,c,n,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=void 0!==a?a:Tt,this.minFilter=void 0!==o?o:Tt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}class ll{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,i=this.getPoint(0),r=0;e.push(0);for(let s=1;s<=t;s++)n=this.getPoint(s/t),r+=n.distanceTo(i),e.push(r),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const n=this.getLengths();let i=0;const r=n.length;let s;s=e||t*n[r-1];let a,o=0,l=r-1;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),a=n[i]-s,a<0)o=i+1;else{if(!(a>0)){l=i;break}l=i-1}if(i=l,n[i]===s)return i/(r-1);const c=n[i];return(i+(s-c)/(n[i+1]-c))/(r-1)}getTangent(t,e){const n=1e-4;let i=t-n,r=t+n;i<0&&(i=0),r>1&&(r=1);const s=this.getPoint(i),a=this.getPoint(r),o=e||(s.isVector2?new ci:new Qi);return o.copy(a).sub(s).normalize(),o}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new Qi,i=[],r=[],s=[],a=new Qi,o=new gr;for(let e=0;e<=t;e++){const n=e/t;i[e]=this.getTangentAt(n,new Qi)}r[0]=new Qi,s[0]=new Qi;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),h=Math.abs(i[0].y),u=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),u<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),s[0].crossVectors(i[0],r[0]);for(let e=1;e<=t;e++){if(r[e]=r[e-1].clone(),s[e]=s[e-1].clone(),a.crossVectors(i[e-1],i[e]),a.length()>Number.EPSILON){a.normalize();const t=Math.acos(ii(i[e-1].dot(i[e]),-1,1));r[e].applyMatrix4(o.makeRotationAxis(a,t))}s[e].crossVectors(i[e],r[e])}if(!0===e){let e=Math.acos(ii(r[0].dot(r[t]),-1,1));e/=t,i[0].dot(a.crossVectors(r[0],r[t]))>0&&(e=-e);for(let n=1;n<=t;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],e*n)),s[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:s}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class cl extends ll{constructor(t=0,e=0,n=1,i=1,r=0,s=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=s,this.aClockwise=a,this.aRotation=o}getPoint(t,e=new ci){const n=e,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const s=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?a=i[(l-1)%r]:(dl.subVectors(i[0],i[1]).add(i[0]),a=dl);const h=i[l%r],u=i[(l+1)%r];if(this.closed||l+2i.length-2?i.length-1:s+1],h=i[s>i.length-3?i.length-1:s+2];return n.set(Al(a,o.x,l.x,c.x,h.x),Al(a,o.y,l.y,c.y,h.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e=n){const t=i[r]-n,s=this.curves[r],a=s.getLength(),o=0===a?0:1-t/a;return s.getPointAt(o,e)}r++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,i=this.curves.length;n1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e0){const t=l.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class Bl extends Fs{constructor(t=[new ci(0,-.5),new ci(.5,0),new ci(0,.5)],e=12,n=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=ii(i,0,2*Math.PI);const r=[],s=[],a=[],o=[],l=[],c=1/e,h=new Qi,u=new ci,d=new Qi,p=new Qi,f=new Qi;let m=0,g=0;for(let e=0;e<=t.length-1;e++)switch(e){case 0:m=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,d.x=1*g,d.y=-m,d.z=0*g,f.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case t.length-1:o.push(f.x,f.y,f.z);break;default:m=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,d.x=1*g,d.y=-m,d.z=0*g,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),o.push(d.x,d.y,d.z),f.copy(p)}for(let r=0;r<=e;r++){const d=n+r*c*i,p=Math.sin(d),f=Math.cos(d);for(let n=0;n<=t.length-1;n++){h.x=t[n].x*p,h.y=t[n].y,h.z=t[n].x*f,s.push(h.x,h.y,h.z),u.x=r/e,u.y=n/(t.length-1),a.push(u.x,u.y);const i=o[3*n+0]*p,c=o[3*n+1],d=o[3*n+0]*f;l.push(i,c,d)}}for(let n=0;n0||0!==i)&&(c.push(s,a,l),v+=3),(e>0||i!==r-1)&&(c.push(a,o,l),v+=3)}l.addGroup(g,v,0),g+=v}(),!1===s&&(t>0&&A(!0),e>0&&A(!1)),this.setIndex(c),this.setAttribute("position",new Ts(h,3)),this.setAttribute("normal",new Ts(u,3)),this.setAttribute("uv",new Ts(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Pl(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Ll extends Pl{constructor(t=1,e=1,n=32,i=1,r=!1,s=0,a=2*Math.PI){super(0,t,e,n,i,r,s,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:s,thetaLength:a}}static fromJSON(t){return new Ll(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Ul extends Fs{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};const r=[],s=[];function a(t,e,n,i){const r=i+1,s=[];for(let i=0;i<=r;i++){s[i]=[];const a=t.clone().lerp(n,i/r),o=e.clone().lerp(n,i/r),l=r-i;for(let t=0;t<=l;t++)s[i][t]=0===t&&i===r?a:a.clone().lerp(o,t/l)}for(let t=0;t.9&&a<.1&&(e<.2&&(s[t+0]+=1),n<.2&&(s[t+2]+=1),i<.2&&(s[t+4]+=1))}}()}(),this.setAttribute("position",new Ts(r,3)),this.setAttribute("normal",new Ts(r.slice(),3)),this.setAttribute("uv",new Ts(s,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ul(t.vertices,t.indices,t.radius,t.details)}}class Nl extends Ul{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,i=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Nl(t.radius,t.detail)}}const Fl=new Qi,Ol=new Qi,kl=new Qi,Ql=new is;class zl extends Fs{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},null!==t){const n=4,i=Math.pow(10,n),r=Math.cos(ti*e),s=t.getIndex(),a=t.getAttribute("position"),o=s?s.count:a.count,l=[0,0,0],c=["a","b","c"],h=new Array(3),u={},d=[];for(let t=0;t0)for(s=e;s=e;s-=i)a=hc(s,t[s],t[s+1],a);return a&&rc(a,a.next)&&(uc(a),a=a.next),a}function Vl(t,e){if(!t)return t;e||(e=t);let n,i=t;do{if(n=!1,i.steiner||!rc(i,i.next)&&0!==ic(i.prev,i,i.next))i=i.next;else{if(uc(i),i=e=i.prev,i===i.next)break;n=!0}}while(n||i!==e);return e}function Wl(t,e,n,i,r,s,a){if(!t)return;!a&&s&&function(t,e,n,i){let r=t;do{0===r.z&&(r.z=$l(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,n,i,r,s,a,o,l,c=1;do{for(n=t,t=null,s=null,a=0;n;){for(a++,i=n,o=0,e=0;e0||l>0&&i;)0!==o&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,o--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;n=i}s.nextZ=null,c*=2}while(a>1)}(r)}(t,i,r,s);let o,l,c=t;for(;t.prev!==t.next;)if(o=t.prev,l=t.next,s?ql(t,i,r,s):jl(t))e.push(o.i/n|0),e.push(t.i/n|0),e.push(l.i/n|0),uc(t),t=l.next,c=l.next;else if((t=l)===c){a?1===a?Wl(t=Xl(Vl(t),e,n),e,n,i,r,s,2):2===a&&Yl(t,e,n,i,r,s):Wl(Vl(t),e,n,i,r,s,1);break}}function jl(t){const e=t.prev,n=t,i=t.next;if(ic(e,n,i)>=0)return!1;const r=e.x,s=n.x,a=i.x,o=e.y,l=n.y,c=i.y,h=rs?r>a?r:a:s>a?s:a,p=o>l?o>c?o:c:l>c?l:c;let f=i.next;for(;f!==e;){if(f.x>=h&&f.x<=d&&f.y>=u&&f.y<=p&&ec(r,o,s,l,a,c,f.x,f.y)&&ic(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function ql(t,e,n,i){const r=t.prev,s=t,a=t.next;if(ic(r,s,a)>=0)return!1;const o=r.x,l=s.x,c=a.x,h=r.y,u=s.y,d=a.y,p=ol?o>c?o:c:l>c?l:c,g=h>u?h>d?h:d:u>d?u:d,A=$l(p,f,e,n,i),v=$l(m,g,e,n,i);let y=t.prevZ,_=t.nextZ;for(;y&&y.z>=A&&_&&_.z<=v;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==a&&ec(o,h,l,u,c,d,y.x,y.y)&&ic(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==r&&_!==a&&ec(o,h,l,u,c,d,_.x,_.y)&&ic(_.prev,_,_.next)>=0)return!1;_=_.nextZ}for(;y&&y.z>=A;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==a&&ec(o,h,l,u,c,d,y.x,y.y)&&ic(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;_&&_.z<=v;){if(_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==r&&_!==a&&ec(o,h,l,u,c,d,_.x,_.y)&&ic(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function Xl(t,e,n){let i=t;do{const r=i.prev,s=i.next.next;!rc(r,s)&&sc(r,i,i.next,s)&&lc(r,s)&&lc(s,r)&&(e.push(r.i/n|0),e.push(i.i/n|0),e.push(s.i/n|0),uc(i),uc(i.next),i=t=s),i=i.next}while(i!==t);return Vl(i)}function Yl(t,e,n,i,r,s){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&nc(a,t)){let o=cc(a,t);return a=Vl(a,a.next),o=Vl(o,o.next),Wl(a,e,n,i,r,s,0),void Wl(o,e,n,i,r,s,0)}t=t.next}a=a.next}while(a!==t)}function Jl(t,e){return t.x-e.x}function Kl(t,e){const n=function(t,e){let n,i=e,r=-1/0;const s=t.x,a=t.y;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){const t=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=s&&t>r&&(r=t,n=i.x=i.x&&i.x>=l&&s!==i.x&&ec(an.x||i.x===n.x&&Zl(n,i)))&&(n=i,u=h)),i=i.next}while(i!==o);return n}(t,e);if(!n)return e;const i=cc(n,t);return Vl(i,i.next),Vl(n,n.next)}function Zl(t,e){return ic(t.prev,t,e.prev)<0&&ic(e.next,t,t.next)<0}function $l(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function tc(t){let e=t,n=t;do{(e.x=(t-a)*(s-o)&&(t-a)*(i-o)>=(n-a)*(e-o)&&(n-a)*(s-o)>=(r-a)*(i-o)}function nc(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&sc(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(lc(t,e)&&lc(e,t)&&function(t,e){let n=t,i=!1;const r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&r<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(ic(t.prev,t,e.prev)||ic(t,e.prev,e))||rc(t,e)&&ic(t.prev,t,t.next)>0&&ic(e.prev,e,e.next)>0)}function ic(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function rc(t,e){return t.x===e.x&&t.y===e.y}function sc(t,e,n,i){const r=oc(ic(t,e,n)),s=oc(ic(t,e,i)),a=oc(ic(n,i,t)),o=oc(ic(n,i,e));return r!==s&&a!==o||!(0!==r||!ac(t,n,e))||!(0!==s||!ac(t,i,e))||!(0!==a||!ac(n,t,i))||!(0!==o||!ac(n,e,i))}function ac(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function oc(t){return t>0?1:t<0?-1:0}function lc(t,e){return ic(t.prev,t,t.next)<0?ic(t,e,t.next)>=0&&ic(t,t.prev,e)>=0:ic(t,e,t.prev)<0||ic(t,t.next,e)<0}function cc(t,e){const n=new dc(t.i,t.x,t.y),i=new dc(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function hc(t,e,n,i){const r=new dc(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function uc(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function dc(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class pc{static area(t){const e=t.length;let n=0;for(let i=e-1,r=0;r80*n){o=c=t[0],l=h=t[1];for(let e=n;ec&&(c=u),d>h&&(h=d);p=Math.max(c-o,h-l),p=0!==p?32767/p:0}return Wl(s,a,n,o,l,p,0),a}(n,i);for(let t=0;t2&&t[e-1].equals(t[0])&&t.pop()}function mc(t,e){for(let n=0;nNumber.EPSILON){const u=Math.sqrt(h),d=Math.sqrt(l*l+c*c),p=e.x-o/u,f=e.y+a/u,m=((n.x-c/d-p)*c-(n.y+l/d-f)*l)/(a*c-o*l);i=p+a*m-t.x,r=f+o*m-t.y;const g=i*i+r*r;if(g<=2)return new ci(i,r);s=Math.sqrt(g/2)}else{let t=!1;a>Number.EPSILON?l>Number.EPSILON&&(t=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(o)===Math.sign(c)&&(t=!0),t?(i=-o,r=a,s=Math.sqrt(h)):(i=a,r=o,s=Math.sqrt(h/2))}return new ci(i/s,r/s)}const R=[];for(let t=0,e=S.length,n=e-1,i=t+1;t=0;t--){const e=t/p,n=h*Math.cos(e*Math.PI/2),i=u*Math.sin(e*Math.PI/2)+d;for(let t=0,e=S.length;t=0;){const i=n;let r=n-1;r<0&&(r=t.length-1);for(let t=0,n=o+2*p;t0)&&d.push(e,r,l),(t!==n-1||o0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class Uc extends us{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ls(16777215),this.specular=new ls(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ls(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new ci(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Sr,this.combine=ot,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Nc extends us{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ls(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ls(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new ci(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class Fc extends us{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new ci(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class Oc extends us{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ls(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ls(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new ci(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Sr,this.combine=ot,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class kc extends us{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=nn,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,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}}class Qc extends us{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}class zc extends us{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ls(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new ci(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Gc extends Po{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function Hc(t,e,n){return!t||!n&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)}function Vc(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Wc(t){const e=t.length,n=new Array(e);for(let t=0;t!==e;++t)n[t]=t;return n.sort((function(e,n){return t[e]-t[n]})),n}function jc(t,e,n){const i=t.length,r=new t.constructor(i);for(let s=0,a=0;a!==i;++s){const i=n[s]*e;for(let n=0;n!==e;++n)r[a++]=t[i+n]}return r}function qc(t,e,n,i){let r=1,s=t[0];for(;void 0!==s&&void 0===s[i];)s=t[r++];if(void 0===s)return;let a=s[i];if(void 0!==a)if(Array.isArray(a))do{a=s[i],void 0!==a&&(e.push(s.time),n.push.apply(n,a)),s=t[r++]}while(void 0!==s);else if(void 0!==a.toArray)do{a=s[i],void 0!==a&&(e.push(s.time),a.toArray(n,n.length)),s=t[r++]}while(void 0!==s);else do{a=s[i],void 0!==a&&(e.push(s.time),n.push(a)),s=t[r++]}while(void 0!==s)}const Xc={convertArray:Hc,isTypedArray:Vc,getKeyframeOrder:Wc,sortedArray:jc,flattenJSON:qc,subclip:function(t,e,n,i,r=30){const s=t.clone();s.name=e;const a=[];for(let t=0;t=i)){l.push(e.times[t]);for(let n=0;ns.tracks[t].times[0]&&(o=s.tracks[t].times[0]);for(let t=0;t=i.times[u]){const t=u*l+o,e=t+l-o;d=i.values.slice(t,e)}else{const t=i.createInterpolant(),e=o,n=l-o;t.evaluate(s),d=t.resultBuffer.slice(e,n)}"quaternion"===r&&(new ki).fromArray(d).normalize().conjugate().toArray(d);const p=a.times.length;for(let t=0;t=r)break t;{const a=e[1];t=r)break e}s=n,n=0}}for(;n>>1;te;)--s;if(++s,0!==r||s!==i){r>=s&&(s=Math.max(s,1),r=s-1);const t=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*t,s*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let s=null;for(let e=0;e!==r;e++){const i=n[e];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,i),t=!1;break}if(null!==s&&s>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,i,s),t=!1;break}s=i}if(void 0!==i&&Vc(i))for(let e=0,n=i.length;e!==n;++e){const n=i[e];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,n),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===qe,r=t.length-1;let s=1;for(let a=1;a0){t[s]=t[r];for(let t=r*n,i=s*n,a=0;a!==n;++a)e[i+a]=e[t+a];++s}return s!==t.length?(this.times=t.slice(0,s),this.values=e.slice(0,s*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}$c.prototype.TimeBufferType=Float32Array,$c.prototype.ValueBufferType=Float32Array,$c.prototype.DefaultInterpolation=je;class th extends $c{constructor(t,e,n){super(t,e,n)}}th.prototype.ValueTypeName="bool",th.prototype.ValueBufferType=Array,th.prototype.DefaultInterpolation=We,th.prototype.InterpolantFactoryMethodLinear=void 0,th.prototype.InterpolantFactoryMethodSmooth=void 0;class eh extends $c{}eh.prototype.ValueTypeName="color";class nh extends $c{}nh.prototype.ValueTypeName="number";class ih extends Yc{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(n-e)/(i-e);let l=t*a;for(let t=l+a;l!==t;l+=4)ki.slerpFlat(r,0,s,l-a,s,l,o);return r}}class rh extends $c{InterpolantFactoryMethodLinear(t){return new ih(this.times,this.values,this.getValueSize(),t)}}rh.prototype.ValueTypeName="quaternion",rh.prototype.InterpolantFactoryMethodSmooth=void 0;class sh extends $c{constructor(t,e,n){super(t,e,n)}}sh.prototype.ValueTypeName="string",sh.prototype.ValueBufferType=Array,sh.prototype.DefaultInterpolation=We,sh.prototype.InterpolantFactoryMethodLinear=void 0,sh.prototype.InterpolantFactoryMethodSmooth=void 0;class ah extends $c{}ah.prototype.ValueTypeName="vector";class oh{constructor(t="",e=-1,n=[],i=Ke){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=ni(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let t=0,r=n.length;t!==r;++t)e.push(lh(n[t]).scale(i));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,i=n.length;t!==i;++t)e.push($c.toJSON(n[t]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const r=e.length,s=[];for(let t=0;t1){const t=s[1];let e=i[t];e||(i[t]=e=[]),e.push(n)}}const s=[];for(const t in i)s.push(this.CreateFromMorphTargetSequence(t,i[t],e,n));return s}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(t,e,n,i,r){if(0!==n.length){const s=[],a=[];qc(n,s,a,i),0!==s.length&&r.push(new t(e,s,a))}},i=[],r=t.name||"default",s=t.fps||30,a=t.blendMode;let o=t.length||-1;const l=t.hierarchy||[];for(let t=0;t{e&&e(r),this.manager.itemEnd(t)}),0),r;if(void 0!==ph[t])return void ph[t].push({onLoad:e,onProgress:n,onError:i});ph[t]=[],ph[t].push({onLoad:e,onProgress:n,onError:i});const s=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(s).then((e=>{if(200===e.status||0===e.status){if(0===e.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===e.body||void 0===e.body.getReader)return e;const n=ph[t],i=e.body.getReader(),r=e.headers.get("X-File-Size")||e.headers.get("Content-Length"),s=r?parseInt(r):0,a=0!==s;let o=0;const l=new ReadableStream({start(t){!function e(){i.read().then((({done:i,value:r})=>{if(i)t.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:s});for(let t=0,e=n.length;t{t.error(e)}))}()}});return new Response(l)}throw new fh(`fetch for "${e.url}" responded with ${e.status}: ${e.statusText}`,e)})).then((t=>{switch(o){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then((t=>(new DOMParser).parseFromString(t,a)));case"json":return t.json();default:if(void 0===a)return t.text();{const e=/charset="?([^;"\s]*)"?/i.exec(a),n=e&&e[1]?e[1].toLowerCase():void 0,i=new TextDecoder(n);return t.arrayBuffer().then((t=>i.decode(t)))}}})).then((e=>{ch.add(t,e);const n=ph[t];delete ph[t];for(let t=0,i=n.length;t{const n=ph[t];if(void 0===n)throw this.manager.itemError(t),e;delete ph[t];for(let t=0,i=n.length;t{this.manager.itemEnd(t)})),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class gh extends dh{constructor(t){super(t)}load(t,e,n,i){const r=this,s=new mh(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(n){try{e(r.parse(JSON.parse(n)))}catch(e){i?i(e):console.error(e),r.manager.itemError(t)}}),n,i)}parse(t){const e=[];for(let n=0;n0:i.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const r=t.uniforms[e];switch(i.uniforms[e]={},r.type){case"t":i.uniforms[e].value=n(r.value);break;case"c":i.uniforms[e].value=(new ls).setHex(r.value);break;case"v2":i.uniforms[e].value=(new ci).fromArray(r.value);break;case"v3":i.uniforms[e].value=(new Qi).fromArray(r.value);break;case"v4":i.uniforms[e].value=(new Di).fromArray(r.value);break;case"m3":i.uniforms[e].value=(new hi).fromArray(r.value);break;case"m4":i.uniforms[e].value=(new gr).fromArray(r.value);break;default:i.uniforms[e].value=r.value}}if(void 0!==t.defines&&(i.defines=t.defines),void 0!==t.vertexShader&&(i.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(i.fragmentShader=t.fragmentShader),void 0!==t.glslVersion&&(i.glslVersion=t.glslVersion),void 0!==t.extensions)for(const e in t.extensions)i.extensions[e]=t.extensions[e];if(void 0!==t.lights&&(i.lights=t.lights),void 0!==t.clipping&&(i.clipping=t.clipping),void 0!==t.size&&(i.size=t.size),void 0!==t.sizeAttenuation&&(i.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(i.map=n(t.map)),void 0!==t.matcap&&(i.matcap=n(t.matcap)),void 0!==t.alphaMap&&(i.alphaMap=n(t.alphaMap)),void 0!==t.bumpMap&&(i.bumpMap=n(t.bumpMap)),void 0!==t.bumpScale&&(i.bumpScale=t.bumpScale),void 0!==t.normalMap&&(i.normalMap=n(t.normalMap)),void 0!==t.normalMapType&&(i.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),i.normalScale=(new ci).fromArray(e)}return void 0!==t.displacementMap&&(i.displacementMap=n(t.displacementMap)),void 0!==t.displacementScale&&(i.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(i.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(i.roughnessMap=n(t.roughnessMap)),void 0!==t.metalnessMap&&(i.metalnessMap=n(t.metalnessMap)),void 0!==t.emissiveMap&&(i.emissiveMap=n(t.emissiveMap)),void 0!==t.emissiveIntensity&&(i.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(i.specularMap=n(t.specularMap)),void 0!==t.specularIntensityMap&&(i.specularIntensityMap=n(t.specularIntensityMap)),void 0!==t.specularColorMap&&(i.specularColorMap=n(t.specularColorMap)),void 0!==t.envMap&&(i.envMap=n(t.envMap)),void 0!==t.envMapRotation&&i.envMapRotation.fromArray(t.envMapRotation),void 0!==t.envMapIntensity&&(i.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(i.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(i.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(i.lightMap=n(t.lightMap)),void 0!==t.lightMapIntensity&&(i.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(i.aoMap=n(t.aoMap)),void 0!==t.aoMapIntensity&&(i.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(i.gradientMap=n(t.gradientMap)),void 0!==t.clearcoatMap&&(i.clearcoatMap=n(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(i.clearcoatNormalMap=n(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(i.clearcoatNormalScale=(new ci).fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(i.iridescenceMap=n(t.iridescenceMap)),void 0!==t.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(t.iridescenceThicknessMap)),void 0!==t.transmissionMap&&(i.transmissionMap=n(t.transmissionMap)),void 0!==t.thicknessMap&&(i.thicknessMap=n(t.thicknessMap)),void 0!==t.anisotropyMap&&(i.anisotropyMap=n(t.anisotropyMap)),void 0!==t.sheenColorMap&&(i.sheenColorMap=n(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(i.sheenRoughnessMap=n(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return Gh.createMaterialFromType(t)}static createMaterialFromType(t){return new{ShadowMaterial:Rc,SpriteMaterial:va,RawShaderMaterial:Dc,ShaderMaterial:na,PointsMaterial:qo,MeshPhysicalMaterial:Lc,MeshStandardMaterial:Pc,MeshPhongMaterial:Uc,MeshToonMaterial:Nc,MeshNormalMaterial:Fc,MeshLambertMaterial:Oc,MeshDepthMaterial:kc,MeshDistanceMaterial:Qc,MeshBasicMaterial:ds,MeshMatcapMaterial:zc,LineDashedMaterial:Gc,LineBasicMaterial:Po,Material:us}[t]}}class Hh{static decodeText(t){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let n=0,i=t.length;n0){const n=new hh(e);r=new vh(n),r.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e0){i=new vh(this.manager),i.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e{const e=new Hi;e.min.fromArray(t.boxMin),e.max.fromArray(t.boxMax);const n=new or;return n.radius=t.sphereRadius,n.center.fromArray(t.sphereCenter),{boxInitialized:t.boxInitialized,box:e,sphereInitialized:t.sphereInitialized,sphere:n}})),s._maxInstanceCount=t.maxInstanceCount,s._maxVertexCount=t.maxVertexCount,s._maxIndexCount=t.maxIndexCount,s._geometryInitialized=t.geometryInitialized,s._geometryCount=t.geometryCount,s._matricesTexture=h(t.matricesTexture.uuid),void 0!==t.colorsTexture&&(s._colorsTexture=h(t.colorsTexture.uuid));break;case"LOD":s=new Na;break;case"Line":s=new zo(l(t.geometry),c(t.material));break;case"LineLoop":s=new jo(l(t.geometry),c(t.material));break;case"LineSegments":s=new Wo(l(t.geometry),c(t.material));break;case"PointCloud":case"Points":s=new Zo(l(t.geometry),c(t.material));break;case"Sprite":s=new Da(c(t.material));break;case"Group":s=new tl;break;case"Bone":s=new qa;break;default:s=new Hr}if(s.uuid=t.uuid,void 0!==t.name&&(s.name=t.name),void 0!==t.matrix?(s.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(s.matrixAutoUpdate=t.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(void 0!==t.position&&s.position.fromArray(t.position),void 0!==t.rotation&&s.rotation.fromArray(t.rotation),void 0!==t.quaternion&&s.quaternion.fromArray(t.quaternion),void 0!==t.scale&&s.scale.fromArray(t.scale)),void 0!==t.up&&s.up.fromArray(t.up),void 0!==t.castShadow&&(s.castShadow=t.castShadow),void 0!==t.receiveShadow&&(s.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(s.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(s.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(s.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(s.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&s.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(s.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(s.visible=t.visible),void 0!==t.frustumCulled&&(s.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(s.renderOrder=t.renderOrder),void 0!==t.userData&&(s.userData=t.userData),void 0!==t.layers&&(s.layers.mask=t.layers),void 0!==t.children){const a=t.children;for(let t=0;t{e&&e(n),r.manager.itemEnd(t)})).catch((t=>{i&&i(t)})):(setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s);const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader;const o=fetch(t,a).then((function(t){return t.blob()})).then((function(t){return createImageBitmap(t,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(n){return ch.add(t,n),e&&e(n),r.manager.itemEnd(t),n})).catch((function(e){i&&i(e),ch.remove(t),r.manager.itemError(t),r.manager.itemEnd(t)}));ch.add(t,o),r.manager.itemStart(t)}}let Kh;class Zh{static getContext(){return void 0===Kh&&(Kh=new(window.AudioContext||window.webkitAudioContext)),Kh}static setContext(t){Kh=t}}class $h extends dh{constructor(t){super(t)}load(t,e,n,i){const r=this,s=new mh(this.manager);function a(e){i?i(e):console.error(e),r.manager.itemError(t)}s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(t){try{const n=t.slice(0);Zh.getContext().decodeAudioData(n,(function(t){e(t)})).catch(a)}catch(t){a(t)}}),n,i)}}const tu=new gr,eu=new gr,nu=new gr;class iu{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new oa,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new oa,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,nu.copy(t.projectionMatrix);const n=e.eyeSep/2,i=n*e.near/e.focus,r=e.near*Math.tan(ti*e.fov*.5)/e.zoom;let s,a;eu.elements[12]=-n,tu.elements[12]=n,s=-r*e.aspect+i,a=r*e.aspect+i,nu.elements[0]=2*e.near/(a-s),nu.elements[8]=(a+s)/(a-s),this.cameraL.projectionMatrix.copy(nu),s=-r*e.aspect-i,a=r*e.aspect-i,nu.elements[0]=2*e.near/(a-s),nu.elements[8]=(a+s)/(a-s),this.cameraR.projectionMatrix.copy(nu)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(eu),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(tu)}}class ru extends oa{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class su{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=au(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=au();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function au(){return performance.now()}const ou=new Qi,lu=new ki,cu=new Qi,hu=new Qi;class uu extends Hr{constructor(){super(),this.type="AudioListener",this.context=Zh.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new su}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(ou,lu,cu),hu.set(0,0,-1).applyQuaternion(lu),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(ou.x,t),e.positionY.linearRampToValueAtTime(ou.y,t),e.positionZ.linearRampToValueAtTime(ou.z,t),e.forwardX.linearRampToValueAtTime(hu.x,t),e.forwardY.linearRampToValueAtTime(hu.y,t),e.forwardZ.linearRampToValueAtTime(hu.z,t),e.upX.linearRampToValueAtTime(n.x,t),e.upY.linearRampToValueAtTime(n.y,t),e.upZ.linearRampToValueAtTime(n.z,t)}else e.setPosition(ou.x,ou.y,ou.z),e.setOrientation(hu.x,hu.y,hu.z,n.x,n.y,n.z)}}class du extends Hr{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(t=0){if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(this.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let t=e,r=e+e;t!==r;++t)if(n[t]!==n[t+e]){a.setValue(n,i);break}}saveOriginalState(){const t=this.binding,e=this.buffer,n=this.valueSize,i=n*this._origIndex;t.getValue(e,i);for(let t=n,r=i;t!==r;++t)e[t]=e[i+t%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n=.5)for(let i=0;i!==r;++i)t[e+i]=t[n+i]}_slerp(t,e,n,i){ki.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,r){const s=this._workIndex*r;ki.multiplyQuaternionsFlat(t,s,t,e,t,n),ki.slerpFlat(t,e,t,e,t,s,i)}_lerp(t,e,n,i,r){const s=1-i;for(let a=0;a!==r;++a){const r=e+a;t[r]=t[r]*s+t[n+a]*i}}_lerpAdditive(t,e,n,i,r){for(let s=0;s!==r;++s){const r=e+s;t[r]=t[r]+t[n+s]*i}}}const _u="\\[\\]\\.:\\/",xu=new RegExp("["+_u+"]","g"),wu="[^"+_u+"]",Cu="[^"+_u.replace("\\.","")+"]",Eu=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",wu)+/(WCOD+)?/.source.replace("WCOD",Cu)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",wu)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",wu)+"$"),Mu=["material","materials","bones","map"];class Su{constructor(t,e,n){this.path=e,this.parsedPath=n||Su.parseTrackName(e),this.node=Su.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new Su.Composite(t,e,n):new Su(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(xu,"")}static parseTrackName(t){const e=Eu.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const t=n.nodeName.substring(i+1);-1!==Mu.indexOf(t)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=t)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(void 0!==n)return n}if(t.children){const n=function(t){for(let i=0;i=r){const s=r++,c=t[s];e[c.uuid]=l,t[l]=c,e[o]=s,t[s]=a;for(let t=0,e=i;t!==e;++t){const e=n[t],i=e[s],r=e[l];e[l]=i,e[s]=r}}}this.nCachedObjects_=r}uncache(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,s=t.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,l=e[o];if(void 0!==l)if(delete e[o],l0&&(e[a.uuid]=l),t[l]=a,t.pop();for(let t=0,e=i;t!==e;++t){const e=n[t];e[l]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){const n=this._bindingsIndicesByPath;let i=n[t];const r=this._bindings;if(void 0!==i)return r[i];const s=this._paths,a=this._parsedPaths,o=this._objects,l=o.length,c=this.nCachedObjects_,h=new Array(l);i=r.length,n[t]=i,s.push(t),a.push(e),r.push(h);for(let n=c,i=o.length;n!==i;++n){const i=o[n];h[n]=new Su(i,t,e)}return h}unsubscribe_(t){const e=this._bindingsIndicesByPath,n=e[t];if(void 0!==n){const i=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length-1,o=s[a];e[t[a]]=n,s[n]=o,s.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}}class Iu{constructor(t,e,n=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=i;const r=e.tracks,s=r.length,a=new Array(s),o={endingStart:Xe,endingEnd:Xe};for(let t=0;t!==s;++t){const e=r[t].createInterpolant(null);a[t]=e,e.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=He,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}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){const n=this._clip.duration,i=t._clip.duration,r=i/n,s=n/i;t.warp(1,r,e),this.warp(s,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){const i=this._mixer,r=i.time,s=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=r,o[1]=r+n,l[0]=t/s,l[1]=e/s,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,i){if(!this.enabled)return void this._updateWeight(t);const r=this._startTime;if(null!==r){const i=(t-r)*n;i<0||0===n?e=0:(this._startTime=null,e=n*i)}e*=this._updateTimeScale(t);const s=this._updateTime(e),a=this._updateWeight(t);if(a>0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===Ze)for(let n=0,i=t.length;n!==i;++n)t[n].evaluate(s),e[n].accumulateAdditive(a);else for(let n=0,r=t.length;n!==r;++n)t[n].evaluate(s),e[n].accumulate(i,a)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const n=this._timeScaleInterpolant;null!==n&&(e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e))}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,n=this.loop;let i=this.time+t,r=this._loopCount;const s=n===Ve;if(0===t)return-1===r||!s||1&~r?i:e-i;if(n===Ge){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else{if(!(i<0)){this.time=i;break t}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),i>=e||i<0){const n=Math.floor(i/e);i-=e*n,r+=Math.abs(n);const a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===a){const e=t<0;this._setEndings(e,!e,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(s&&!(1&~r))return e-i}return i}_setEndings(t,e,n){const i=this._interpolantSettings;n?(i.endingStart=Ye,i.endingEnd=Ye):(i.endingStart=t?this.zeroSlopeAtStart?Ye:Xe:Je,i.endingEnd=e?this.zeroSlopeAtEnd?Ye:Xe:Je)}_scheduleFading(t,e,n){const i=this._mixer,r=i.time;let s=this._weightInterpolant;null===s&&(s=i._lendControlInterpolant(),this._weightInterpolant=s);const a=s.parameterPositions,o=s.sampleValues;return a[0]=r,o[0]=e,a[1]=r+t,o[1]=n,this}}const Tu=new Float32Array(1);class Bu extends Kn{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const n=t._localRoot||this._root,i=t._clip.tracks,r=i.length,s=t._propertyBindings,a=t._interpolants,o=n.uuid,l=this._bindingsByRootAndName;let c=l[o];void 0===c&&(c={},l[o]=c);for(let t=0;t!==r;++t){const r=i[t],l=r.name;let h=c[l];if(void 0!==h)++h.referenceCount,s[t]=h;else{if(h=s[t],void 0!==h){null===h._cacheIndex&&(++h.referenceCount,this._addInactiveBinding(h,o,l));continue}const i=e&&e._propertyBindings[t].binding.parsedPath;h=new yu(Su.create(n,l,i),r.ValueTypeName,r.getValueSize()),++h.referenceCount,this._addInactiveBinding(h,o,l),s[t]=h}a[t].resultBuffer=h.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,n=t._clip.uuid,i=this._actionsByClip[n];this._bindAction(t,i&&i.knownActions[0]),this._addInactiveAction(t,n,e)}const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const 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(t){const e=t._cacheIndex;return null!==e&&e=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,n=this._nActiveActions,i=this.time+=t,r=Math.sign(t),s=this._accuIndex^=1;for(let a=0;a!==n;++a)e[a]._update(i,t,r,s);const a=this._bindings,o=this._nActiveBindings;for(let t=0;t!==o;++t)a[t].apply(s);return this}setTime(t){this.time=0;for(let t=0;t=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}containsBox(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(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Wu).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const qu=new Qi,Xu=new Qi;class Yu{constructor(t=new Qi,e=new Qi){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){qu.subVectors(t,this.start),Xu.subVectors(this.end,this.start);const n=Xu.dot(Xu);let i=Xu.dot(qu)/n;return e&&(i=ii(i,0,1)),i}closestPointToPoint(t,e,n){const i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}const Ju=new Qi;class Ku extends Hr{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const n=new Fs,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let t=0,e=1,n=32;t1)for(let n=0;n.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{wd.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(wd,e)}}setLength(t,e=.2*t,n=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class Sd extends Wo{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=new Fs;n.setAttribute("position",new Ts(e,3)),n.setAttribute("color",new Ts([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(n,new Po({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,n){const i=new ls,r=this.geometry.attributes.color.array;return i.set(t),i.toArray(r,0),i.toArray(r,3),i.set(e),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class bd{constructor(){this.type="ShapePath",this.color=new ls,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Tl,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,n,i){return this.currentPath.quadraticCurveTo(t,e,n,i),this}bezierCurveTo(t,e,n,i,r,s){return this.currentPath.bezierCurveTo(t,e,n,i,r,s),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(t,e){const n=e.length;let i=!1;for(let r=n-1,s=0;sNumber.EPSILON){if(l<0&&(n=e[s],o=-o,a=e[r],l=-l),t.ya.y)continue;if(t.y===n.y){if(t.x===n.x)return!0}else{const e=l*(t.x-n.x)-o*(t.y-n.y);if(0===e)return!0;if(e<0)continue;i=!i}}else{if(t.y!==n.y)continue;if(a.x<=t.x&&t.x<=n.x||n.x<=t.x&&t.x<=a.x)return!0}}return i}const n=pc.isClockWise,i=this.subPaths;if(0===i.length)return[];let r,s,a;const o=[];if(1===i.length)return s=i[0],a=new Gl,a.curves=s.curves,o.push(a),o;let l=!n(i[0].getPoints());l=t?!l:l;const c=[],h=[];let u,d,p=[],f=0;h[f]=void 0,p[f]=[];for(let e=0,a=i.length;e1){let t=!1,n=0;for(let t=0,e=h.length;t0&&!1===t&&(p=c)}for(let t=0,e=h.length;te?(t.repeat.x=1,t.repeat.y=n/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2):(t.repeat.x=e/n,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0),t},cover:function(t,e){const n=t.image&&t.image.width?t.image.width/t.image.height:1;return n>e?(t.repeat.x=e/n,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0):(t.repeat.x=1,t.repeat.y=n/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2),t},fill:function(t){return t.repeat.x=1,t.repeat.y=1,t.offset.x=0,t.offset.y=0,t},getByteLength:Td};function Rd(){let t=null,e=!1,n=null,i=null;function r(e,s){n(e,s),i=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==n&&(i=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function Dd(t){const e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);const i=e.get(n);i&&(t.deleteBuffer(i.buffer),e.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){const t=e.get(n);return void((!t||t.versiont.start-e.start));let e=0;for(let t=1;t 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 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 max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\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}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\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};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\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}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( 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.a );\n}\nvec4 sRGBTransferOETF( 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.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, 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, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\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",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\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",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\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",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.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};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.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};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_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}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, 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 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\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\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}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\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 depth, const in float near, const in float far ) {\n\treturn depth * ( 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 depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\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\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), 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( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), 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 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\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 shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\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\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",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\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\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\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( 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}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\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 \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \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#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\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_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\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}",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 \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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 \n#include \n#include \n#include \nvoid main() {\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\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\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\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\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\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\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \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\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\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\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\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\tvec4 diffuseColor = vec4( diffuse, opacity );\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 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\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#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\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\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \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\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \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\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\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\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \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 + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \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\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_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\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\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\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},Ld={common:{diffuse:{value:new ls(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new hi},alphaMap:{value:null},alphaMapTransform:{value:new hi},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new hi}},envmap:{envMap:{value:null},envMapRotation:{value:new hi},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new hi}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new hi}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new hi},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new hi},normalScale:{value:new ci(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new hi},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new hi}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new hi}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new hi}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ls(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new ls(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new hi},alphaTest:{value:0},uvTransform:{value:new hi}},sprite:{diffuse:{value:new ls(16777215)},opacity:{value:1},center:{value:new ci(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new hi},alphaMap:{value:null},alphaMapTransform:{value:new hi},alphaTest:{value:0}}},Ud={basic:{uniforms:$s([Ld.common,Ld.specularmap,Ld.envmap,Ld.aomap,Ld.lightmap,Ld.fog]),vertexShader:Pd.meshbasic_vert,fragmentShader:Pd.meshbasic_frag},lambert:{uniforms:$s([Ld.common,Ld.specularmap,Ld.envmap,Ld.aomap,Ld.lightmap,Ld.emissivemap,Ld.bumpmap,Ld.normalmap,Ld.displacementmap,Ld.fog,Ld.lights,{emissive:{value:new ls(0)}}]),vertexShader:Pd.meshlambert_vert,fragmentShader:Pd.meshlambert_frag},phong:{uniforms:$s([Ld.common,Ld.specularmap,Ld.envmap,Ld.aomap,Ld.lightmap,Ld.emissivemap,Ld.bumpmap,Ld.normalmap,Ld.displacementmap,Ld.fog,Ld.lights,{emissive:{value:new ls(0)},specular:{value:new ls(1118481)},shininess:{value:30}}]),vertexShader:Pd.meshphong_vert,fragmentShader:Pd.meshphong_frag},standard:{uniforms:$s([Ld.common,Ld.envmap,Ld.aomap,Ld.lightmap,Ld.emissivemap,Ld.bumpmap,Ld.normalmap,Ld.displacementmap,Ld.roughnessmap,Ld.metalnessmap,Ld.fog,Ld.lights,{emissive:{value:new ls(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Pd.meshphysical_vert,fragmentShader:Pd.meshphysical_frag},toon:{uniforms:$s([Ld.common,Ld.aomap,Ld.lightmap,Ld.emissivemap,Ld.bumpmap,Ld.normalmap,Ld.displacementmap,Ld.gradientmap,Ld.fog,Ld.lights,{emissive:{value:new ls(0)}}]),vertexShader:Pd.meshtoon_vert,fragmentShader:Pd.meshtoon_frag},matcap:{uniforms:$s([Ld.common,Ld.bumpmap,Ld.normalmap,Ld.displacementmap,Ld.fog,{matcap:{value:null}}]),vertexShader:Pd.meshmatcap_vert,fragmentShader:Pd.meshmatcap_frag},points:{uniforms:$s([Ld.points,Ld.fog]),vertexShader:Pd.points_vert,fragmentShader:Pd.points_frag},dashed:{uniforms:$s([Ld.common,Ld.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Pd.linedashed_vert,fragmentShader:Pd.linedashed_frag},depth:{uniforms:$s([Ld.common,Ld.displacementmap]),vertexShader:Pd.depth_vert,fragmentShader:Pd.depth_frag},normal:{uniforms:$s([Ld.common,Ld.bumpmap,Ld.normalmap,Ld.displacementmap,{opacity:{value:1}}]),vertexShader:Pd.meshnormal_vert,fragmentShader:Pd.meshnormal_frag},sprite:{uniforms:$s([Ld.sprite,Ld.fog]),vertexShader:Pd.sprite_vert,fragmentShader:Pd.sprite_frag},background:{uniforms:{uvTransform:{value:new hi},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Pd.background_vert,fragmentShader:Pd.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new hi}},vertexShader:Pd.backgroundCube_vert,fragmentShader:Pd.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Pd.cube_vert,fragmentShader:Pd.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Pd.equirect_vert,fragmentShader:Pd.equirect_frag},distanceRGBA:{uniforms:$s([Ld.common,Ld.displacementmap,{referencePosition:{value:new Qi},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Pd.distanceRGBA_vert,fragmentShader:Pd.distanceRGBA_frag},shadow:{uniforms:$s([Ld.lights,Ld.fog,{color:{value:new ls(0)},opacity:{value:1}}]),vertexShader:Pd.shadow_vert,fragmentShader:Pd.shadow_frag}};Ud.physical={uniforms:$s([Ud.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new hi},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new hi},clearcoatNormalScale:{value:new ci(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new hi},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new hi},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new hi},sheen:{value:0},sheenColor:{value:new ls(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new hi},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new hi},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new hi},transmissionSamplerSize:{value:new ci},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new hi},attenuationDistance:{value:0},attenuationColor:{value:new ls(0)},specularColor:{value:new ls(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new hi},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new hi},anisotropyVector:{value:new ci},anisotropyMap:{value:null},anisotropyMapTransform:{value:new hi}}]),vertexShader:Pd.meshphysical_vert,fragmentShader:Pd.meshphysical_frag};const Nd={r:0,b:0,g:0},Fd=new Sr,Od=new gr;function kd(t,e,n,i,r,s,a){const o=new ls(0);let l,c,h=!0===s?0:1,u=null,d=0,p=null;function f(t){let i=!0===t.isScene?t.background:null;return i&&i.isTexture&&(i=(t.backgroundBlurriness>0?n:e).get(i)),i}function m(e,n){e.getRGB(Nd,ta(t)),i.buffers.color.setClear(Nd.r,Nd.g,Nd.b,n,a)}return{getClearColor:function(){return o},setClearColor:function(t,e=1){o.set(t),h=e,m(o,h)},getClearAlpha:function(){return h},setClearAlpha:function(t){h=t,m(o,h)},render:function(e){let n=!1;const r=f(e);null===r?m(o,h):r&&r.isColor&&(m(r,1),n=!0);const s=t.xr.getEnvironmentBlendMode();"additive"===s?i.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===s&&i.buffers.color.setClear(0,0,0,0,a),(t.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))},addToRenderList:function(e,n){const i=f(n);i&&(i.isCubeTexture||i.mapping===Mt)?(void 0===c&&(c=new Ys(new Ks(1,1,1),new na({name:"BackgroundCubeMaterial",uniforms:Zs(Ud.backgroundCube.uniforms),vertexShader:Ud.backgroundCube.vertexShader,fragmentShader:Ud.backgroundCube.fragmentShader,side:M,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(t,e,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),Fd.copy(n.backgroundRotation),Fd.x*=-1,Fd.y*=-1,Fd.z*=-1,i.isCubeTexture&&!1===i.isRenderTargetTexture&&(Fd.y*=-1,Fd.z*=-1),c.material.uniforms.envMap.value=i,c.material.uniforms.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Od.makeRotationFromEuler(Fd)),c.material.toneMapped=wi.getTransfer(i.colorSpace)!==pn,u===i&&d===i.version&&p===t.toneMapping||(c.material.needsUpdate=!0,u=i,d=i.version,p=t.toneMapping),c.layers.enableAll(),e.unshift(c,c.geometry,c.material,0,0,null)):i&&i.isTexture&&(void 0===l&&(l=new Ys(new _c(2,2),new na({name:"BackgroundMaterial",uniforms:Zs(Ud.background.uniforms),vertexShader:Ud.background.vertexShader,fragmentShader:Ud.background.fragmentShader,side:E,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=i,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.toneMapped=wi.getTransfer(i.colorSpace)!==pn,!0===i.matrixAutoUpdate&&i.updateMatrix(),l.material.uniforms.uvTransform.value.copy(i.matrix),u===i&&d===i.version&&p===t.toneMapping||(l.material.needsUpdate=!0,u=i,d=i.version,p=t.toneMapping),l.layers.enableAll(),e.unshift(l,l.geometry,l.material,0,0,null))},dispose:function(){void 0!==c&&(c.geometry.dispose(),c.material.dispose()),void 0!==l&&(l.geometry.dispose(),l.material.dispose())}}}function Qd(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),i={},r=c(null);let s=r,a=!1;function o(e){return t.bindVertexArray(e)}function l(e){return t.deleteVertexArray(e)}function c(t){const e=[],i=[],r=[];for(let t=0;t=0){const n=r[e];let i=a[e];if(void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;o++}return s.attributesNum!==o||s.index!==i}(n,m,l,g),A&&function(t,e,n,i){const r={},a=e.attributes;let o=0;const l=n.getAttributes();for(const e in l)if(l[e].location>=0){let n=a[e];void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[e]=i,o++}s.attributes=r,s.attributesNum=o,s.index=i}(n,m,l,g),null!==g&&e.update(g,t.ELEMENT_ARRAY_BUFFER),(A||a)&&(a=!1,function(n,i,r,s){h();const a=s.attributes,o=r.getAttributes(),l=i.defaultAttributeValues;for(const i in o){const r=o[i];if(r.location>=0){let o=a[i];if(void 0===o&&("instanceMatrix"===i&&n.instanceMatrix&&(o=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(o=n.instanceColor)),void 0!==o){const i=o.normalized,a=o.itemSize,l=e.get(o);if(void 0===l)continue;const c=l.buffer,h=l.type,p=l.bytesPerElement,m=h===t.INT||h===t.UNSIGNED_INT||o.gpuType===Ht;if(o.isInterleavedBufferAttribute){const e=o.data,l=e.stride,g=o.offset;if(e.isInstancedInterleavedBuffer){for(let t=0;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"}let a=void 0!==n.precision?n.precision:"highp";const o=s(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const l=!0===n.logarithmicDepthBuffer,c=!0===n.reverseDepthBuffer&&e.has("EXT_clip_control"),h=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),u=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===e.has("EXT_texture_filter_anisotropic")){const n=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:s,textureFormatReadable:function(e){return e===$t||i.convert(e)===t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const r=n===jt&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(n!==kt&&i.convert(n)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==Wt&&!r)},precision:a,logarithmicDepthBuffer:l,reverseDepthBuffer:c,maxTextures:h,maxVertexTextures:u,maxTextureSize:t.getParameter(t.MAX_TEXTURE_SIZE),maxCubemapSize:t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:t.getParameter(t.MAX_VERTEX_ATTRIBS),maxVertexUniforms:t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:t.getParameter(t.MAX_VARYING_VECTORS),maxFragmentUniforms:t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),vertexTextures:u>0,maxSamples:t.getParameter(t.MAX_SAMPLES)}}function Hd(t){const e=this;let n=null,i=0,r=!1,s=!1;const a=new ho,o=new hi,l={value:null,needsUpdate:!1};function c(t,n,i,r){const s=null!==t?t.length:0;let c=null;if(0!==s){if(c=l.value,!0!==r||null===c){const e=i+4*s,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length0),e.numPlanes=i,e.numIntersection=0);else{const t=s?0:i,e=4*t;let r=f.clippingState||null;l.value=r,r=c(u,o,e,h);for(let t=0;t!==e;++t)r[t]=n[t];f.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=t}}}function Vd(t){let e=new WeakMap;function n(t,e){return e===Ct?t.mapping=xt:e===Et&&(t.mapping=wt),t}function i(t){const n=t.target;n.removeEventListener("dispose",i);const r=e.get(n);void 0!==r&&(e.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping;if(s===Ct||s===Et){if(e.has(r))return n(e.get(r).texture,r.mapping);{const s=r.image;if(s&&s.height>0){const a=new ua(s.height);return a.fromEquirectangularTexture(t,r),e.set(r,a),r.addEventListener("dispose",i),n(a.texture,r.mapping)}return null}}}return r},dispose:function(){e=new WeakMap}}}const Wd=[.125,.215,.35,.446,.526,.582],jd=new Uh,qd=new ls;let Xd=null,Yd=0,Jd=0,Kd=!1;const Zd=(1+Math.sqrt(5))/2,$d=1/Zd,tp=[new Qi(-Zd,$d,0),new Qi(Zd,$d,0),new Qi(-$d,0,Zd),new Qi($d,0,Zd),new Qi(0,Zd,-$d),new Qi(0,Zd,$d),new Qi(-1,1,-1),new Qi(1,1,-1),new Qi(-1,1,1),new Qi(1,1,1)];class ep{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,i=100){Xd=this._renderer.getRenderTarget(),Yd=this._renderer.getActiveCubeFace(),Jd=this._renderer.getActiveMipmapLevel(),Kd=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,n,i,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=sp(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=rp(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;tt-4?o=Wd[a-t+4-1]:0===a&&(o=0),i.push(o);const l=1/(s-2),c=-l,h=1+l,u=[c,c,h,c,h,h,c,c,h,h,c,h],d=6,p=6,f=3,m=2,g=1,A=new Float32Array(f*p*d),v=new Float32Array(m*p*d),y=new Float32Array(g*p*d);for(let t=0;t2?0:-1,i=[e,n,0,e+2/3,n,0,e+2/3,n+1,0,e,n,0,e+2/3,n+1,0,e,n+1,0];A.set(i,f*p*t),v.set(u,m*p*t);const r=[t,t,t,t,t,t];y.set(r,g*p*t)}const _=new Fs;_.setAttribute("position",new _s(A,f)),_.setAttribute("uv",new _s(v,m)),_.setAttribute("faceIndex",new _s(y,g)),e.push(_),r>4&&r--}return{lodPlanes:e,sizeLods:n,sigmas:i}}(i)),this._blurMaterial=function(t,e,n){const i=new Float32Array(20),r=new Qi(0,1,0);return new na({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:b,depthTest:!1,depthWrite:!1})}(i,t,e)}return i}_compileMaterial(t){const e=new Ys(this._lodPlanes[0],t);this._renderer.compile(e,jd)}_sceneToCubeUV(t,e,n,i){const r=new oa(90,1,e,n),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,c=o.toneMapping;o.getClearColor(qd),o.toneMapping=ht,o.autoClear=!1;const h=new ds({name:"PMREM.Background",side:M,depthWrite:!1,depthTest:!1}),u=new Ys(new Ks,h);let d=!1;const p=t.background;p?p.isColor&&(h.color.copy(p),t.background=null,d=!0):(h.color.copy(qd),d=!0);for(let e=0;e<6;e++){const n=e%3;0===n?(r.up.set(0,s[e],0),r.lookAt(a[e],0,0)):1===n?(r.up.set(0,0,s[e]),r.lookAt(0,a[e],0)):(r.up.set(0,s[e],0),r.lookAt(0,0,a[e]));const l=this._cubeSize;ip(i,n*l,e>2?l:0,l,l),o.setRenderTarget(i),d&&o.render(u,r),o.render(t,r)}u.geometry.dispose(),u.material.dispose(),o.toneMapping=c,o.autoClear=l,t.background=p}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===xt||t.mapping===wt;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=sp()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=rp());const r=i?this._cubemapMaterial:this._equirectMaterial,s=new Ys(this._lodPlanes[0],r);r.uniforms.envMap.value=t;const a=this._cubeSize;ip(e,0,0,3*a,2*a),n.setRenderTarget(e),n.render(s,jd)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodPlanes.length;for(let e=1;e20&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let t=0;t<20;++t){const e=t/p,n=Math.exp(-e*e/2);m.push(n),0===t?g+=n:tA-4?i-A+4:0),4*(this._cubeSize-v),3*v,2*v),o.setRenderTarget(e),o.render(c,jd)}}function np(t,e,n){const i=new Li(t,e,n);return i.texture.mapping=Mt,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function ip(t,e,n,i,r){t.viewport.set(e,n,i,r),t.scissor.set(e,n,i,r)}function rp(){return new na({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:b,depthTest:!1,depthWrite:!1})}function sp(){return new na({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:b,depthTest:!1,depthWrite:!1})}function ap(t){let e=new WeakMap,n=null;function i(t){const n=t.target;n.removeEventListener("dispose",i);const r=e.get(n);void 0!==r&&(e.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping,a=s===Ct||s===Et,o=s===xt||s===wt;if(a||o){let s=e.get(r);const l=void 0!==s?s.texture.pmremVersion:0;if(r.isRenderTargetTexture&&r.pmremVersion!==l)return null===n&&(n=new ep(t)),s=a?n.fromEquirectangular(r,s):n.fromCubemap(r,s),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),s.texture;if(void 0!==s)return s.texture;{const l=r.image;return a&&l&&l.height>0||o&&l&&function(t){let e=0;for(let n=0;n<6;n++)void 0!==t[n]&&e++;return 6===e}(l)?(null===n&&(n=new ep(t)),s=a?n.fromEquirectangular(r):n.fromCubemap(r),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),r.addEventListener("dispose",i),s.texture):null}}}return r},dispose:function(){e=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function op(t){const e={};function n(n){if(void 0!==e[n])return e[n];let i;switch(n){case"WEBGL_depth_texture":i=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=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":i=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":i=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=t.getExtension(n)}return e[n]=i,i}return{has:function(t){return null!==n(t)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(t){const e=n(t);return null===e&&vi("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function lp(t,e,n,i){const r={},s=new WeakMap;function a(t){const o=t.target;null!==o.index&&e.remove(o.index);for(const t in o.attributes)e.remove(o.attributes[t]);o.removeEventListener("dispose",a),delete r[o.id];const l=s.get(o);l&&(e.remove(l),s.delete(o)),i.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,n.memory.geometries--}function o(t){const n=[],i=t.index,r=t.attributes.position;let a=0;if(null!==i){const t=i.array;a=i.version;for(let e=0,i=t.length;ee.maxTextureSize&&(_=Math.ceil(y/e.maxTextureSize),y=e.maxTextureSize);const x=new Float32Array(y*_*4*h),w=new Ui(x,y,_,h);w.type=Wt,w.needsUpdate=!0;const C=4*v;for(let M=0;M0)return t;const r=e*n;let s=vp[r];if(void 0===s&&(s=new Float32Array(r),vp[r]=s),0!==e){i.toArray(s,0);for(let i=1,r=0;i!==e;++i)r+=n,t[i].toArray(s,r)}return s}function Ep(t,e){if(t.length!==e.length)return!1;for(let n=0,i=t.length;n":" "} ${r}: ${n[t]}`)}return i.join("\n")}(t.getShaderSource(e),i)}return r}function Cf(t,e){const n=function(t){wi._getMatrix(xf,wi.workingColorSpace,t);const e=`mat3( ${xf.elements.map((t=>t.toFixed(4)))} )`;switch(wi.getTransfer(t)){case dn:return[e,"LinearTransferOETF"];case pn:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}(e);return[`vec4 ${t}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}function Ef(t,e){let n;switch(e){case ut:n="Linear";break;case dt:n="Reinhard";break;case pt:n="Cineon";break;case ft:n="ACESFilmic";break;case gt:n="AgX";break;case At:n="Neutral";break;case mt:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const Mf=new Qi;function Sf(t){return""!==t}function bf(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function If(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Tf=/^[ \t]*#include +<([\w\d./]+)>/gm;function Bf(t){return t.replace(Tf,Df)}const Rf=new Map;function Df(t,e){let n=Pd[e];if(void 0===n){const t=Rf.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");n=Pd[t],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,t)}return Bf(n)}const Pf=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Lf(t){return t.replace(Pf,Uf)}function Uf(t,e,n,i){let r="";for(let t=parseInt(e);t0&&(g+="\n"),A=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f].filter(Sf).join("\n"),A.length>0&&(A+="\n")):(g=[Nf(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#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.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Sf).join("\n"),A=[Nf(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+h:"",n.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==ht?"#define TONE_MAPPING":"",n.toneMapping!==ht?Pd.tonemapping_pars_fragment:"",n.toneMapping!==ht?Ef("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Pd.colorspace_pars_fragment,Cf("linearToOutputTexel",n.outputColorSpace),(wi.getLuminanceCoefficients(Mf),["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${Mf.x.toFixed(4)}, ${Mf.y.toFixed(4)}, ${Mf.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Sf).join("\n")),a=Bf(a),a=bf(a,n),a=If(a,n),o=Bf(o),o=bf(o,n),o=If(o,n),a=Lf(a),o=Lf(o),!0!==n.isRawShaderMaterial&&(v="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,A=["#define varying in",n.glslVersion===Xn?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Xn?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+A);const y=v+g+a,_=v+A+o,E=yf(r,r.VERTEX_SHADER,y),M=yf(r,r.FRAGMENT_SHADER,_);function S(e){if(t.debug.checkShaderErrors){const n=r.getProgramInfoLog(m).trim(),i=r.getShaderInfoLog(E).trim(),s=r.getShaderInfoLog(M).trim();let a=!0,o=!0;if(!1===r.getProgramParameter(m,r.LINK_STATUS))if(a=!1,"function"==typeof t.debug.onShaderError)t.debug.onShaderError(r,m,E,M);else{const t=wf(r,E,"vertex"),i=wf(r,M,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(m,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+e.name+"\nMaterial Type: "+e.type+"\n\nProgram Info Log: "+n+"\n"+t+"\n"+i)}else""!==n?console.warn("THREE.WebGLProgram: Program Info Log:",n):""!==i&&""!==s||(o=!1);o&&(e.diagnostics={runnable:a,programLog:n,vertexShader:{log:i,prefix:g},fragmentShader:{log:s,prefix:A}})}r.deleteShader(E),r.deleteShader(M),b=new vf(r,m),I=function(t,e){const n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r0,J=s.clearcoat>0,K=s.dispersion>0,Z=s.iridescence>0,$=s.sheen>0,tt=s.transmission>0,et=Y&&!!s.anisotropyMap,nt=J&&!!s.clearcoatMap,it=J&&!!s.clearcoatNormalMap,rt=J&&!!s.clearcoatRoughnessMap,st=Z&&!!s.iridescenceMap,at=Z&&!!s.iridescenceThicknessMap,ot=$&&!!s.sheenColorMap,lt=$&&!!s.sheenRoughnessMap,ct=!!s.specularMap,ut=!!s.specularColorMap,dt=!!s.specularIntensityMap,pt=tt&&!!s.transmissionMap,ft=tt&&!!s.thicknessMap,mt=!!s.gradientMap,gt=!!s.alphaMap,At=s.alphaTest>0,vt=!!s.alphaHash,yt=!!s.extensions;let _t=ht;s.toneMapped&&(null!==L&&!0!==L.isXRRenderTarget||(_t=t.toneMapping));const xt={shaderID:C,shaderType:s.type,shaderName:s.name,vertexShader:T,fragmentShader:B,defines:s.defines,customVertexShaderID:R,customFragmentShaderID:D,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:p,batching:F,batchingColor:F&&null!==A._colorsTexture,instancing:N,instancingColor:N&&null!==A.instanceColor,instancingMorph:N&&null!==A.morphTexture,supportsVertexTextures:d,outputColorSpace:null===L?t.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:un,alphaToCoverage:!!s.alphaToCoverage,map:O,matcap:k,envMap:Q,envMapMode:Q&&x.mapping,envMapCubeUVHeight:w,aoMap:z,lightMap:G,bumpMap:H,normalMap:V,displacementMap:d&&W,emissiveMap:j,normalMapObjectSpace:V&&s.normalMapType===ln,normalMapTangentSpace:V&&s.normalMapType===on,metalnessMap:q,roughnessMap:X,anisotropy:Y,anisotropyMap:et,clearcoat:J,clearcoatMap:nt,clearcoatNormalMap:it,clearcoatRoughnessMap:rt,dispersion:K,iridescence:Z,iridescenceMap:st,iridescenceThicknessMap:at,sheen:$,sheenColorMap:ot,sheenRoughnessMap:lt,specularMap:ct,specularColorMap:ut,specularIntensityMap:dt,transmission:tt,transmissionMap:pt,thicknessMap:ft,gradientMap:mt,opaque:!1===s.transparent&&s.blending===I&&!1===s.alphaToCoverage,alphaMap:gt,alphaTest:At,alphaHash:vt,combine:s.combine,mapUv:O&&m(s.map.channel),aoMapUv:z&&m(s.aoMap.channel),lightMapUv:G&&m(s.lightMap.channel),bumpMapUv:H&&m(s.bumpMap.channel),normalMapUv:V&&m(s.normalMap.channel),displacementMapUv:W&&m(s.displacementMap.channel),emissiveMapUv:j&&m(s.emissiveMap.channel),metalnessMapUv:q&&m(s.metalnessMap.channel),roughnessMapUv:X&&m(s.roughnessMap.channel),anisotropyMapUv:et&&m(s.anisotropyMap.channel),clearcoatMapUv:nt&&m(s.clearcoatMap.channel),clearcoatNormalMapUv:it&&m(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:rt&&m(s.clearcoatRoughnessMap.channel),iridescenceMapUv:st&&m(s.iridescenceMap.channel),iridescenceThicknessMapUv:at&&m(s.iridescenceThicknessMap.channel),sheenColorMapUv:ot&&m(s.sheenColorMap.channel),sheenRoughnessMapUv:lt&&m(s.sheenRoughnessMap.channel),specularMapUv:ct&&m(s.specularMap.channel),specularColorMapUv:ut&&m(s.specularColorMap.channel),specularIntensityMapUv:dt&&m(s.specularIntensityMap.channel),transmissionMapUv:pt&&m(s.transmissionMap.channel),thicknessMapUv:ft&&m(s.thicknessMap.channel),alphaMapUv:gt&&m(s.alphaMap.channel),vertexTangents:!!y.attributes.tangent&&(V||Y),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!y.attributes.color&&4===y.attributes.color.itemSize,pointsUvs:!0===A.isPoints&&!!y.attributes.uv&&(O||gt),fog:!!v,useFog:!0===s.fog,fogExp2:!!v&&v.isFogExp2,flatShading:!0===s.flatShading,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:u,reverseDepthBuffer:U,skinning:!0===A.isSkinnedMesh,morphTargets:void 0!==y.morphAttributes.position,morphNormals:void 0!==y.morphAttributes.normal,morphColors:void 0!==y.morphAttributes.color,morphTargetsCount:b,morphTextureStride:P,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:s.dithering,shadowMapEnabled:t.shadowMap.enabled&&h.length>0,shadowMapType:t.shadowMap.type,toneMapping:_t,decodeVideoTexture:O&&!0===s.map.isVideoTexture&&wi.getTransfer(s.map.colorSpace)===pn,decodeVideoTextureEmissive:j&&!0===s.emissiveMap.isVideoTexture&&wi.getTransfer(s.emissiveMap.colorSpace)===pn,premultipliedAlpha:s.premultipliedAlpha,doubleSided:s.side===S,flipSided:s.side===M,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionClipCullDistance:yt&&!0===s.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(yt&&!0===s.extensions.multiDraw||F)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:s.customProgramCacheKey()};return xt.vertexUv1s=c.has(1),xt.vertexUv2s=c.has(2),xt.vertexUv3s=c.has(3),c.clear(),xt},getProgramCacheKey:function(e){const n=[];if(e.shaderID?n.push(e.shaderID):(n.push(e.customVertexShaderID),n.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)n.push(t),n.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.numLightProbes),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(n,e),function(t,e){o.disableAll(),e.supportsVertexTextures&&o.enable(0),e.instancing&&o.enable(1),e.instancingColor&&o.enable(2),e.instancingMorph&&o.enable(3),e.matcap&&o.enable(4),e.envMap&&o.enable(5),e.normalMapObjectSpace&&o.enable(6),e.normalMapTangentSpace&&o.enable(7),e.clearcoat&&o.enable(8),e.iridescence&&o.enable(9),e.alphaTest&&o.enable(10),e.vertexColors&&o.enable(11),e.vertexAlphas&&o.enable(12),e.vertexUv1s&&o.enable(13),e.vertexUv2s&&o.enable(14),e.vertexUv3s&&o.enable(15),e.vertexTangents&&o.enable(16),e.anisotropy&&o.enable(17),e.alphaHash&&o.enable(18),e.batching&&o.enable(19),e.dispersion&&o.enable(20),e.batchingColor&&o.enable(21),t.push(o.mask),o.disableAll(),e.fog&&o.enable(0),e.useFog&&o.enable(1),e.flatShading&&o.enable(2),e.logarithmicDepthBuffer&&o.enable(3),e.reverseDepthBuffer&&o.enable(4),e.skinning&&o.enable(5),e.morphTargets&&o.enable(6),e.morphNormals&&o.enable(7),e.morphColors&&o.enable(8),e.premultipliedAlpha&&o.enable(9),e.shadowMapEnabled&&o.enable(10),e.doubleSided&&o.enable(11),e.flipSided&&o.enable(12),e.useDepthPacking&&o.enable(13),e.dithering&&o.enable(14),e.transmission&&o.enable(15),e.sheen&&o.enable(16),e.opaque&&o.enable(17),e.pointsUvs&&o.enable(18),e.decodeVideoTexture&&o.enable(19),e.decodeVideoTextureEmissive&&o.enable(20),e.alphaToCoverage&&o.enable(21),t.push(o.mask)}(n,e),n.push(t.outputColorSpace)),n.push(e.customProgramCacheKey),n.join()},getUniforms:function(t){const e=f[t.type];let n;if(e){const t=Ud[e];n=ea.clone(t.uniforms)}else n=t.uniforms;return n},acquireProgram:function(e,n){let i;for(let t=0,e=h.length;t0?i.push(h):!0===a.transparent?r.push(h):n.push(h)},unshift:function(t,e,a,o,l,c){const h=s(t,e,a,o,l,c);a.transmission>0?i.unshift(h):!0===a.transparent?r.unshift(h):n.unshift(h)},finish:function(){for(let n=e,i=t.length;n1&&n.sort(t||Hf),i.length>1&&i.sort(e||Vf),r.length>1&&r.sort(e||Vf)}}}function jf(){let t=new WeakMap;return{get:function(e,n){const i=t.get(e);let r;return void 0===i?(r=new Wf,t.set(e,[r])):n>=i.length?(r=new Wf,i.push(r)):r=i[n],r},dispose:function(){t=new WeakMap}}}function qf(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Qi,color:new ls};break;case"SpotLight":n={position:new Qi,direction:new Qi,color:new ls,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Qi,color:new ls,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Qi,skyColor:new ls,groundColor:new ls};break;case"RectAreaLight":n={color:new ls,position:new Qi,halfWidth:new Qi,halfHeight:new Qi}}return t[e.id]=n,n}}}let Xf=0;function Yf(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Jf(t){const e=new qf,n=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ci};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ci,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=n,n}}}(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let t=0;t<9;t++)i.probe.push(new Qi);const r=new Qi,s=new gr,a=new gr;return{setup:function(r){let s=0,a=0,o=0;for(let t=0;t<9;t++)i.probe[t].set(0,0,0);let l=0,c=0,h=0,u=0,d=0,p=0,f=0,m=0,g=0,A=0,v=0;r.sort(Yf);for(let t=0,y=r.length;t0&&(!0===t.has("OES_texture_float_linear")?(i.rectAreaLTC1=Ld.LTC_FLOAT_1,i.rectAreaLTC2=Ld.LTC_FLOAT_2):(i.rectAreaLTC1=Ld.LTC_HALF_1,i.rectAreaLTC2=Ld.LTC_HALF_2)),i.ambient[0]=s,i.ambient[1]=a,i.ambient[2]=o;const y=i.hash;y.directionalLength===l&&y.pointLength===c&&y.spotLength===h&&y.rectAreaLength===u&&y.hemiLength===d&&y.numDirectionalShadows===p&&y.numPointShadows===f&&y.numSpotShadows===m&&y.numSpotMaps===g&&y.numLightProbes===v||(i.directional.length=l,i.spot.length=h,i.rectArea.length=u,i.point.length=c,i.hemi.length=d,i.directionalShadow.length=p,i.directionalShadowMap.length=p,i.pointShadow.length=f,i.pointShadowMap.length=f,i.spotShadow.length=m,i.spotShadowMap.length=m,i.directionalShadowMatrix.length=p,i.pointShadowMatrix.length=f,i.spotLightMatrix.length=m+g-A,i.spotLightMap.length=g,i.numSpotLightShadowsWithMaps=A,i.numLightProbes=v,y.directionalLength=l,y.pointLength=c,y.spotLength=h,y.rectAreaLength=u,y.hemiLength=d,y.numDirectionalShadows=p,y.numPointShadows=f,y.numSpotShadows=m,y.numSpotMaps=g,y.numLightProbes=v,i.version=Xf++)},setupView:function(t,e){let n=0,o=0,l=0,c=0,h=0;const u=e.matrixWorldInverse;for(let e=0,d=t.length;e=r.length?(s=new Kf(t),r.push(s)):s=r[i],s},dispose:function(){e=new WeakMap}}}function $f(t,e,n){let i=new fo;const r=new ci,s=new ci,a=new Di,o=new kc({depthPacking:rn}),l=new Qc,c={},h=n.maxTextureSize,u={[E]:M,[M]:E,[S]:S},d=new na({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ci},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const f=new Fs;f.setAttribute("position",new _s(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new Ys(f,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=x;let A=this.type;function v(n,i){const s=e.update(m);d.defines.VSM_SAMPLES!==n.blurSamples&&(d.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Li(r.x,r.y)),d.uniforms.shadow_pass.value=n.map.texture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,t.setRenderTarget(n.mapPass),t.clear(),t.renderBufferDirect(i,null,s,d,m,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,t.setRenderTarget(n.map),t.clear(),t.renderBufferDirect(i,null,s,p,m,null)}function y(e,n,i,r){let s=null;const a=!0===i.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===i.isPointLight?l:o,t.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const t=s.uuid,e=n.uuid;let i=c[t];void 0===i&&(i={},c[t]=i);let r=i[e];void 0===r&&(r=s.clone(),i[e]=r,n.addEventListener("dispose",w)),s=r}return s.visible=n.visible,s.wireframe=n.wireframe,s.side=r===C?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],s.alphaMap=n.alphaMap,s.alphaTest=n.alphaTest,s.map=n.map,s.clipShadows=n.clipShadows,s.clippingPlanes=n.clippingPlanes,s.clipIntersection=n.clipIntersection,s.displacementMap=n.displacementMap,s.displacementScale=n.displacementScale,s.displacementBias=n.displacementBias,s.wireframeLinewidth=n.wireframeLinewidth,s.linewidth=n.linewidth,!0===i.isPointLight&&!0===s.isMeshDistanceMaterial&&(t.properties.get(s).light=i),s}function _(n,r,s,a,o){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&o===C)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);const i=e.update(n),l=n.material;if(Array.isArray(l)){const e=i.groups;for(let c=0,h=e.length;ch||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/m.x),r.x=s.x*m.x,u.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/m.y),r.y=s.y*m.y,u.mapSize.y=s.y)),null===u.map||!0===p||!0===f){const t=this.type!==C?{minFilter:Tt,magFilter:Tt}:{};null!==u.map&&u.map.dispose(),u.map=new Li(r.x,r.y,t),u.map.texture.name=c.name+".shadowMap",u.camera.updateProjectionMatrix()}t.setRenderTarget(u.map),t.clear();const g=u.getViewportCount();for(let t=0;t=1):-1!==gt.indexOf("OpenGL ES")&&(mt=parseFloat(/^OpenGL ES (\d)/.exec(gt)[1]),ft=mt>=2);let At=null,vt={};const yt=t.getParameter(t.SCISSOR_BOX),_t=t.getParameter(t.VIEWPORT),xt=(new Di).fromArray(yt),wt=(new Di).fromArray(_t);function Ct(e,n,i,r){const s=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let a=0;an||r.height>n)&&(i=n/Math.max(r.width,r.height)),i<1){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&t instanceof VideoFrame){const n=Math.floor(i*r.width),s=Math.floor(i*r.height);void 0===u&&(u=f(n,s));const a=e?f(n,s):u;return a.width=n,a.height=s,a.getContext("2d").drawImage(t,0,0,n,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+n+"x"+s+")."),a}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),t}return t}function g(t){return t.generateMipmaps}function A(e){t.generateMipmap(e)}function v(e){return e.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:e.isWebGL3DRenderTarget?t.TEXTURE_3D:e.isWebGLArrayRenderTarget||e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function y(n,i,r,s,a=!1){if(null!==n){if(void 0!==t[n])return t[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=i;if(i===t.RED&&(r===t.FLOAT&&(o=t.R32F),r===t.HALF_FLOAT&&(o=t.R16F),r===t.UNSIGNED_BYTE&&(o=t.R8)),i===t.RED_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.R8UI),r===t.UNSIGNED_SHORT&&(o=t.R16UI),r===t.UNSIGNED_INT&&(o=t.R32UI),r===t.BYTE&&(o=t.R8I),r===t.SHORT&&(o=t.R16I),r===t.INT&&(o=t.R32I)),i===t.RG&&(r===t.FLOAT&&(o=t.RG32F),r===t.HALF_FLOAT&&(o=t.RG16F),r===t.UNSIGNED_BYTE&&(o=t.RG8)),i===t.RG_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RG8UI),r===t.UNSIGNED_SHORT&&(o=t.RG16UI),r===t.UNSIGNED_INT&&(o=t.RG32UI),r===t.BYTE&&(o=t.RG8I),r===t.SHORT&&(o=t.RG16I),r===t.INT&&(o=t.RG32I)),i===t.RGB_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGB8UI),r===t.UNSIGNED_SHORT&&(o=t.RGB16UI),r===t.UNSIGNED_INT&&(o=t.RGB32UI),r===t.BYTE&&(o=t.RGB8I),r===t.SHORT&&(o=t.RGB16I),r===t.INT&&(o=t.RGB32I)),i===t.RGBA_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGBA8UI),r===t.UNSIGNED_SHORT&&(o=t.RGBA16UI),r===t.UNSIGNED_INT&&(o=t.RGBA32UI),r===t.BYTE&&(o=t.RGBA8I),r===t.SHORT&&(o=t.RGBA16I),r===t.INT&&(o=t.RGBA32I)),i===t.RGB&&r===t.UNSIGNED_INT_5_9_9_9_REV&&(o=t.RGB9_E5),i===t.RGBA){const e=a?dn:wi.getTransfer(s);r===t.FLOAT&&(o=t.RGBA32F),r===t.HALF_FLOAT&&(o=t.RGBA16F),r===t.UNSIGNED_BYTE&&(o=e===pn?t.SRGB8_ALPHA8:t.RGBA8),r===t.UNSIGNED_SHORT_4_4_4_4&&(o=t.RGBA4),r===t.UNSIGNED_SHORT_5_5_5_1&&(o=t.RGB5_A1)}return o!==t.R16F&&o!==t.R32F&&o!==t.RG16F&&o!==t.RG32F&&o!==t.RGBA16F&&o!==t.RGBA32F||e.get("EXT_color_buffer_float"),o}function _(e,n){let i;return e?null===n||n===Vt||n===Yt?i=t.DEPTH24_STENCIL8:n===Wt?i=t.DEPTH32F_STENCIL8:n===Gt&&(i=t.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===Vt||n===Yt?i=t.DEPTH_COMPONENT24:n===Wt?i=t.DEPTH_COMPONENT32F:n===Gt&&(i=t.DEPTH_COMPONENT16),i}function x(t,e){return!0===g(t)||t.isFramebufferTexture&&t.minFilter!==Tt&&t.minFilter!==Lt?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function w(t){const e=t.target;e.removeEventListener("dispose",w),function(t){const e=i.get(t);if(void 0===e.__webglInit)return;const n=t.source,r=d.get(n);if(r){const i=r[e.__cacheKey];i.usedTimes--,0===i.usedTimes&&E(t),0===Object.keys(r).length&&d.delete(n)}i.remove(t)}(e),e.isVideoTexture&&h.delete(e)}function C(e){const n=e.target;n.removeEventListener("dispose",C),function(e){const n=i.get(e);if(e.depthTexture&&(e.depthTexture.dispose(),i.remove(e.depthTexture)),e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++){if(Array.isArray(n.__webglFramebuffer[e]))for(let i=0;i0&&s.__version!==e.version){const t=e.image;if(null===t)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==t.complete)return void D(s,e,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(t.TEXTURE_2D,s.__webglTexture,t.TEXTURE0+r)}const b={[St]:t.REPEAT,[bt]:t.CLAMP_TO_EDGE,[It]:t.MIRRORED_REPEAT},I={[Tt]:t.NEAREST,[Bt]:t.NEAREST_MIPMAP_NEAREST,[Dt]:t.NEAREST_MIPMAP_LINEAR,[Lt]:t.LINEAR,[Ut]:t.LINEAR_MIPMAP_NEAREST,[Ft]:t.LINEAR_MIPMAP_LINEAR},T={[Bn]:t.NEVER,[Fn]:t.ALWAYS,[Rn]:t.LESS,[Pn]:t.LEQUAL,[Dn]:t.EQUAL,[Nn]:t.GEQUAL,[Ln]:t.GREATER,[Un]:t.NOTEQUAL};function B(n,s){if(s.type!==Wt||!1!==e.has("OES_texture_float_linear")||s.magFilter!==Lt&&s.magFilter!==Ut&&s.magFilter!==Dt&&s.magFilter!==Ft&&s.minFilter!==Lt&&s.minFilter!==Ut&&s.minFilter!==Dt&&s.minFilter!==Ft||console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(n,t.TEXTURE_WRAP_S,b[s.wrapS]),t.texParameteri(n,t.TEXTURE_WRAP_T,b[s.wrapT]),n!==t.TEXTURE_3D&&n!==t.TEXTURE_2D_ARRAY||t.texParameteri(n,t.TEXTURE_WRAP_R,b[s.wrapR]),t.texParameteri(n,t.TEXTURE_MAG_FILTER,I[s.magFilter]),t.texParameteri(n,t.TEXTURE_MIN_FILTER,I[s.minFilter]),s.compareFunction&&(t.texParameteri(n,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(n,t.TEXTURE_COMPARE_FUNC,T[s.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){if(s.magFilter===Tt)return;if(s.minFilter!==Dt&&s.minFilter!==Ft)return;if(s.type===Wt&&!1===e.has("OES_texture_float_linear"))return;if(s.anisotropy>1||i.get(s).__currentAnisotropy){const a=e.get("EXT_texture_filter_anisotropic");t.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),i.get(s).__currentAnisotropy=s.anisotropy}}}function R(e,n){let i=!1;void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",w));const r=n.source;let s=d.get(r);void 0===s&&(s={},d.set(r,s));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(n);if(o!==e.__cacheKey){void 0===s[o]&&(s[o]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,i=!0),s[o].usedTimes++;const r=s[e.__cacheKey];void 0!==r&&(s[e.__cacheKey].usedTimes--,0===r.usedTimes&&E(n)),e.__cacheKey=o,e.__webglTexture=s[o].texture}return i}function D(e,a,o){let l=t.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(l=t.TEXTURE_2D_ARRAY),a.isData3DTexture&&(l=t.TEXTURE_3D);const c=R(e,a),h=a.source;n.bindTexture(l,e.__webglTexture,t.TEXTURE0+o);const u=i.get(h);if(h.version!==u.__version||!0===c){n.activeTexture(t.TEXTURE0+o);const e=wi.getPrimaries(wi.workingColorSpace),i=a.colorSpace===cn?null:wi.getPrimaries(a.colorSpace),d=a.colorSpace===cn||e===i?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);let p=m(a.image,!1,r.maxTextureSize);p=Q(a,p);const f=s.convert(a.format,a.colorSpace),v=s.convert(a.type);let w,C=y(a.internalFormat,f,v,a.colorSpace,a.isVideoTexture);B(l,a);const E=a.mipmaps,M=!0!==a.isVideoTexture,S=void 0===u.__version||!0===c,b=h.dataReady,I=x(a,p);if(a.isDepthTexture)C=_(a.format===ie,a.type),S&&(M?n.texStorage2D(t.TEXTURE_2D,1,C,p.width,p.height):n.texImage2D(t.TEXTURE_2D,0,C,p.width,p.height,0,f,v,null));else if(a.isDataTexture)if(E.length>0){M&&S&&n.texStorage2D(t.TEXTURE_2D,I,C,E[0].width,E[0].height);for(let e=0,i=E.length;e0){const i=Td(w.width,w.height,a.format,a.type);for(const r of a.layerUpdates){const s=w.data.subarray(r*i/w.data.BYTES_PER_ELEMENT,(r+1)*i/w.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,r,w.width,w.height,1,f,s)}a.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,w.width,w.height,p.depth,f,w.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,e,C,w.width,w.height,p.depth,0,w.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else M?b&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,w.width,w.height,p.depth,f,v,w.data):n.texImage3D(t.TEXTURE_2D_ARRAY,e,C,w.width,w.height,p.depth,0,f,v,w.data)}else{M&&S&&n.texStorage2D(t.TEXTURE_2D,I,C,E[0].width,E[0].height);for(let e=0,i=E.length;e0){const e=Td(p.width,p.height,a.format,a.type);for(const i of a.layerUpdates){const r=p.data.subarray(i*e/p.data.BYTES_PER_ELEMENT,(i+1)*e/p.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,i,p.width,p.height,1,f,v,r)}a.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,f,v,p.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,C,p.width,p.height,p.depth,0,f,v,p.data);else if(a.isData3DTexture)M?(S&&n.texStorage3D(t.TEXTURE_3D,I,C,p.width,p.height,p.depth),b&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,f,v,p.data)):n.texImage3D(t.TEXTURE_3D,0,C,p.width,p.height,p.depth,0,f,v,p.data);else if(a.isFramebufferTexture){if(S)if(M)n.texStorage2D(t.TEXTURE_2D,I,C,p.width,p.height);else{let e=p.width,i=p.height;for(let r=0;r>=1,i>>=1}}else if(E.length>0){if(M&&S){const e=z(E[0]);n.texStorage2D(t.TEXTURE_2D,I,C,e.width,e.height)}for(let e=0,i=E.length;e>h),i=Math.max(1,r.height>>h);c===t.TEXTURE_3D||c===t.TEXTURE_2D_ARRAY?n.texImage3D(c,h,p,e,i,r.depth,0,u,d,null):n.texImage2D(c,h,p,e,i,0,u,d,null)}n.bindFramebuffer(t.FRAMEBUFFER,e),k(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,l,c,m.__webglTexture,0,O(r)):(c===t.TEXTURE_2D||c>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,l,c,m.__webglTexture,h),n.bindFramebuffer(t.FRAMEBUFFER,null)}function L(e,n,i){if(t.bindRenderbuffer(t.RENDERBUFFER,e),n.depthBuffer){const r=n.depthTexture,s=r&&r.isDepthTexture?r.type:null,a=_(n.stencilBuffer,s),l=n.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,c=O(n);k(n)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,c,a,n.width,n.height):i?t.renderbufferStorageMultisample(t.RENDERBUFFER,c,a,n.width,n.height):t.renderbufferStorage(t.RENDERBUFFER,a,n.width,n.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,l,t.RENDERBUFFER,e)}else{const e=n.textures;for(let r=0;r{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,t.removeEventListener("dispose",e)};t.addEventListener("dispose",e),r.__depthDisposeCallback=e}r.__boundDepthTexture=t}if(e.depthTexture&&!r.__autoAllocateDepthBuffer){if(s)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const s=i.get(r.depthTexture);s.__renderTarget=r,s.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),S(r.depthTexture,0);const a=s.__webglTexture,l=O(r);if(r.depthTexture.format===ne)k(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0,l):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0);else{if(r.depthTexture.format!==ie)throw new Error("Unknown depthTexture format");k(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0,l):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0)}}(r.__webglFramebuffer,e)}else if(s){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[i]),void 0===r.__webglDepthbuffer[i])r.__webglDepthbuffer[i]=t.createRenderbuffer(),L(r.__webglDepthbuffer[i],e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,s=r.__webglDepthbuffer[i];t.bindRenderbuffer(t.RENDERBUFFER,s),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,s)}}else if(n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=t.createRenderbuffer(),L(r.__webglDepthbuffer,e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,i=r.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,i),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,i)}n.bindFramebuffer(t.FRAMEBUFFER,null)}const N=[],F=[];function O(t){return Math.min(r.maxSamples,t.samples)}function k(t){const n=i.get(t);return t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function Q(t,e){const n=t.colorSpace,i=t.format,r=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||n!==un&&n!==cn&&(wi.getTransfer(n)===pn?i===$t&&r===kt||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",n)),e}function z(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement?(c.width=t.naturalWidth||t.width,c.height=t.naturalHeight||t.height):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?(c.width=t.displayWidth,c.height=t.displayHeight):(c.width=t.width,c.height=t.height),c}this.allocateTextureUnit=function(){const t=M;return t>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+r.maxTextures),M+=1,t},this.resetTextureUnits=function(){M=0},this.setTexture2D=S,this.setTexture2DArray=function(e,r){const s=i.get(e);e.version>0&&s.__version!==e.version?D(s,e,r):n.bindTexture(t.TEXTURE_2D_ARRAY,s.__webglTexture,t.TEXTURE0+r)},this.setTexture3D=function(e,r){const s=i.get(e);e.version>0&&s.__version!==e.version?D(s,e,r):n.bindTexture(t.TEXTURE_3D,s.__webglTexture,t.TEXTURE0+r)},this.setTextureCube=function(e,a){const o=i.get(e);e.version>0&&o.__version!==e.version?function(e,a,o){if(6!==a.image.length)return;const l=R(e,a),c=a.source;n.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+o);const h=i.get(c);if(c.version!==h.__version||!0===l){n.activeTexture(t.TEXTURE0+o);const e=wi.getPrimaries(wi.workingColorSpace),i=a.colorSpace===cn?null:wi.getPrimaries(a.colorSpace),u=a.colorSpace===cn||e===i?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,u);const d=a.isCompressedTexture||a.image[0].isCompressedTexture,p=a.image[0]&&a.image[0].isDataTexture,f=[];for(let t=0;t<6;t++)f[t]=d||p?p?a.image[t].image:a.image[t]:m(a.image[t],!0,r.maxCubemapSize),f[t]=Q(a,f[t]);const v=f[0],_=s.convert(a.format,a.colorSpace),w=s.convert(a.type),C=y(a.internalFormat,_,w,a.colorSpace),E=!0!==a.isVideoTexture,M=void 0===h.__version||!0===l,S=c.dataReady;let b,I=x(a,v);if(B(t.TEXTURE_CUBE_MAP,a),d){E&&M&&n.texStorage2D(t.TEXTURE_CUBE_MAP,I,C,v.width,v.height);for(let e=0;e<6;e++){b=f[e].mipmaps;for(let i=0;i0&&I++;const e=z(f[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,I,C,e.width,e.height)}for(let e=0;e<6;e++)if(p){E?S&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,f[e].width,f[e].height,_,w,f[e].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,C,f[e].width,f[e].height,0,_,w,f[e].data);for(let i=0;i1;if(u||(void 0===l.__webglTexture&&(l.__webglTexture=t.createTexture()),l.__version=r.version,a.memory.textures++),h){o.__webglFramebuffer=[];for(let e=0;e<6;e++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[e]=[];for(let n=0;n0){o.__webglFramebuffer=[];for(let e=0;e0&&!1===k(e)){o.__webglMultisampledFramebuffer=t.createFramebuffer(),o.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let n=0;n0)for(let i=0;i0)for(let n=0;n0)if(!1===k(e)){const r=e.textures,s=e.width,a=e.height;let o=t.COLOR_BUFFER_BIT;const c=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,h=i.get(e),u=r.length>1;if(u)for(let e=0;eo+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&a<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==a&&(i=e.getPose(t.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(rm)))}return null!==a&&(a.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==s),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const n=new tl;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}class am{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(null===this.texture){const i=new Ri;t.properties.get(i).__webglTexture=e.texture,e.depthNear===n.depthNear&&e.depthFar===n.depthFar||(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(t){if(null!==this.texture&&null===this.mesh){const e=t.cameras[0].viewport,n=new na({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Ys(new _c(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class om extends Kn{constructor(t,e){super();const n=this;let i=null,r=1,s=null,a="local-floor",o=1,l=null,c=null,h=null,u=null,d=null,p=null;const f=new am,m=e.getContextAttributes();let g=null,A=null;const v=[],y=[],_=new ci;let x=null;const w=new oa;w.viewport=new Di;const C=new oa;C.viewport=new Di;const E=[w,C],M=new ru;let S=null,b=null;function I(t){const e=y.indexOf(t.inputSource);if(-1===e)return;const n=v[e];void 0!==n&&(n.update(t.inputSource,t.frame,l||s),n.dispatchEvent({type:t.type,data:t.inputSource}))}function T(){i.removeEventListener("select",I),i.removeEventListener("selectstart",I),i.removeEventListener("selectend",I),i.removeEventListener("squeeze",I),i.removeEventListener("squeezestart",I),i.removeEventListener("squeezeend",I),i.removeEventListener("end",T),i.removeEventListener("inputsourceschange",B);for(let t=0;t=0&&(y[i]=null,v[i].disconnect(n))}for(let e=0;e=y.length){y.push(n),i=t;break}if(null===y[t]){y[t]=n,i=t;break}}if(-1===i)break}const r=v[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=v[t];return void 0===e&&(e=new sm,v[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=v[t];return void 0===e&&(e=new sm,v[t]=e),e.getGripSpace()},this.getHand=function(t){let e=v[t];return void 0===e&&(e=new sm,v[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){a=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(t){l=t},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(c){if(i=c,null!==i){if(g=t.getRenderTarget(),i.addEventListener("select",I),i.addEventListener("selectstart",I),i.addEventListener("selectend",I),i.addEventListener("squeeze",I),i.addEventListener("squeezestart",I),i.addEventListener("squeezeend",I),i.addEventListener("end",T),i.addEventListener("inputsourceschange",B),!0!==m.xrCompatible&&await e.makeXRCompatible(),x=t.getPixelRatio(),t.getSize(_),void 0!==i.enabledFeatures&&i.enabledFeatures.includes("layers")){let n=null,s=null,a=null;m.depth&&(a=m.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,n=m.stencil?ie:ne,s=m.stencil?Yt:Vt);const o={colorFormat:e.RGBA8,depthFormat:a,scaleFactor:r};h=new XRWebGLBinding(i,e),u=h.createProjectionLayer(o),i.updateRenderState({layers:[u]}),t.setPixelRatio(1),t.setSize(u.textureWidth,u.textureHeight,!1),A=new Li(u.textureWidth,u.textureHeight,{format:$t,type:kt,depthTexture:new ol(u.textureWidth,u.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:m.stencil,colorSpace:t.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:!1===u.ignoreDepthValues})}else{const n={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,e,n),i.updateRenderState({baseLayer:d}),t.setPixelRatio(1),t.setSize(d.framebufferWidth,d.framebufferHeight,!1),A=new Li(d.framebufferWidth,d.framebufferHeight,{format:$t,type:kt,colorSpace:t.outputColorSpace,stencilBuffer:m.stencil})}A.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await i.requestReferenceSpace(a),U.setContext(i),U.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode},this.getDepthTexture=function(){return f.getDepthTexture()};const R=new Qi,D=new Qi;function P(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===i)return;let e=t.near,n=t.far;null!==f.texture&&(f.depthNear>0&&(e=f.depthNear),f.depthFar>0&&(n=f.depthFar)),M.near=C.near=w.near=e,M.far=C.far=w.far=n,S===M.near&&b===M.far||(i.updateRenderState({depthNear:M.near,depthFar:M.far}),S=M.near,b=M.far),w.layers.mask=2|t.layers.mask,C.layers.mask=4|t.layers.mask,M.layers.mask=w.layers.mask|C.layers.mask;const r=t.parent,s=M.cameras;P(M,r);for(let t=0;t0&&(t.alphaTest.value=i.alphaTest);const r=e.get(i),s=r.envMap,a=r.envMapRotation;s&&(t.envMap.value=s,lm.copy(a),lm.x*=-1,lm.y*=-1,lm.z*=-1,s.isCubeTexture&&!1===s.isRenderTargetTexture&&(lm.y*=-1,lm.z*=-1),t.envMapRotation.value.setFromMatrix4(cm.makeRotationFromEuler(lm)),t.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,t.reflectivity.value=i.reflectivity,t.ior.value=i.ior,t.refractionRatio.value=i.refractionRatio),i.lightMap&&(t.lightMap.value=i.lightMap,t.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,t.lightMapTransform)),i.aoMap&&(t.aoMap.value=i.aoMap,t.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,t.aoMapTransform))}return{refreshFogUniforms:function(e,n){n.color.getRGB(e.fogColor.value,ta(t)),n.isFog?(e.fogNear.value=n.near,e.fogFar.value=n.far):n.isFogExp2&&(e.fogDensity.value=n.density)},refreshMaterialUniforms:function(t,r,s,a,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(t,r):r.isMeshToonMaterial?(i(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,r)):r.isMeshPhongMaterial?(i(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,r)):r.isMeshStandardMaterial?(i(t,r),function(t,e){t.metalness.value=e.metalness,e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap,n(e.metalnessMap,t.metalnessMapTransform)),t.roughness.value=e.roughness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap,n(e.roughnessMap,t.roughnessMapTransform)),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}(t,r),r.isMeshPhysicalMaterial&&function(t,e,i){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,n(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,n(e.sheenRoughnessMap,t.sheenRoughnessMapTransform))),e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,n(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,n(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,n(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),e.side===M&&t.clearcoatNormalScale.value.negate())),e.dispersion>0&&(t.dispersion.value=e.dispersion),e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,n(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,n(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform))),e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=i.texture,t.transmissionSamplerSize.value.set(i.width,i.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,n(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,n(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor)),e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,n(e.anisotropyMap,t.anisotropyMapTransform))),t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,n(e.specularColorMap,t.specularColorMapTransform)),e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,n(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,r,o)):r.isMeshMatcapMaterial?(i(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,r)):r.isMeshDepthMaterial?i(t,r):r.isMeshDistanceMaterial?(i(t,r),function(t,n){const i=e.get(n).light;t.referencePosition.value.setFromMatrixPosition(i.matrixWorld),t.nearDistance.value=i.shadow.camera.near,t.farDistance.value=i.shadow.camera.far}(t,r)):r.isMeshNormalMaterial?i(t,r):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform))}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,i,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*i,t.scale.value=.5*r,e.map&&(t.map.value=e.map,n(e.map,t.uvTransform)),e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform)),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r,s,a):r.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform)),e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform)),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function um(t,e,n,i){let r={},s={},a=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(t,e,n,i){const r=t.value,s=e+"_"+n;if(void 0===i[s])return i[s]="number"==typeof r||"boolean"==typeof r?r:r.clone(),!0;{const t=i[s];if("number"==typeof r||"boolean"==typeof r){if(t!==r)return i[s]=r,!0}else if(!1===t.equals(r))return t.copy(r),!0}return!1}function c(t){const e={boundary:0,storage:0};return"number"==typeof t||"boolean"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4?(e.boundary=64,e.storage=64):t.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",t),e}function h(e){const n=e.target;n.removeEventListener("dispose",h);const i=a.indexOf(n.__bindingPointIndex);a.splice(i,1),t.deleteBuffer(r[n.id]),delete r[n.id],delete s[n.id]}return{bind:function(t,e){const n=e.program;i.uniformBlockBinding(t,n)},update:function(n,u){let d=r[n.id];void 0===d&&(function(t){const e=t.uniforms;let n=0;for(let t=0,i=e.length;t0&&(n+=16-i),t.__size=n,t.__cache={}}(n),d=function(e){const n=function(){for(let t=0;t0),u=!!n.morphAttributes.position,d=!!n.morphAttributes.normal,p=!!n.morphAttributes.color;let f=ht;i.toneMapped&&(null!==b&&!0!==b.isXRRenderTarget||(f=_.toneMapping));const m=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,g=void 0!==m?m.length:0,v=it.get(i),y=A.state.lights;if(!0===V&&(!0===W||t!==T)){const e=t===T&&i.id===I;mt.setState(i,t,e)}let x=!1;i.version===v.__version?v.needsLights&&v.lightsStateVersion!==y.state.version||v.outputColorSpace!==o||r.isBatchedMesh&&!1===v.batching?x=!0:r.isBatchedMesh||!0!==v.batching?r.isBatchedMesh&&!0===v.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===v.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===v.instancing?x=!0:r.isInstancedMesh||!0!==v.instancing?r.isSkinnedMesh&&!1===v.skinning?x=!0:r.isSkinnedMesh||!0!==v.skinning?r.isInstancedMesh&&!0===v.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===v.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===v.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===v.instancingMorph&&null!==r.morphTexture||v.envMap!==l||!0===i.fog&&v.fog!==s?x=!0:void 0===v.numClippingPlanes||v.numClippingPlanes===mt.numPlanes&&v.numIntersection===mt.numIntersection?(v.vertexAlphas!==c||v.vertexTangents!==h||v.morphTargets!==u||v.morphNormals!==d||v.morphColors!==p||v.toneMapping!==f||v.morphTargetsCount!==g)&&(x=!0):x=!0:x=!0:x=!0:x=!0:(x=!0,v.__version=i.version);let w=v.currentProgram;!0===x&&(w=Jt(i,e,r));let C=!1,E=!1,M=!1;const S=w.getUniforms(),B=v.uniforms;if(et.useProgram(w.program)&&(C=!0,E=!0,M=!0),i.id!==I&&(I=i.id,E=!0),C||T!==t){et.buffers.depth.getReversed()?(j.copy(t.projectionMatrix),function(t){const e=t.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}(j),function(t){const e=t.elements;-1===e[11]?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=1-e[14])}(j),S.setValue(Et,"projectionMatrix",j)):S.setValue(Et,"projectionMatrix",t.projectionMatrix),S.setValue(Et,"viewMatrix",t.matrixWorldInverse);const e=S.map.cameraPosition;void 0!==e&&e.setValue(Et,X.setFromMatrixPosition(t.matrixWorld)),tt.logarithmicDepthBuffer&&S.setValue(Et,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&S.setValue(Et,"isOrthographic",!0===t.isOrthographicCamera),T!==t&&(T=t,E=!0,M=!0)}if(r.isSkinnedMesh){S.setOptional(Et,r,"bindMatrix"),S.setOptional(Et,r,"bindMatrixInverse");const t=r.skeleton;t&&(null===t.boneTexture&&t.computeBoneTexture(),S.setValue(Et,"boneTexture",t.boneTexture,rt))}r.isBatchedMesh&&(S.setOptional(Et,r,"batchingTexture"),S.setValue(Et,"batchingTexture",r._matricesTexture,rt),S.setOptional(Et,r,"batchingIdTexture"),S.setValue(Et,"batchingIdTexture",r._indirectTexture,rt),S.setOptional(Et,r,"batchingColorTexture"),null!==r._colorsTexture&&S.setValue(Et,"batchingColorTexture",r._colorsTexture,rt));const R=n.morphAttributes;var D,P;if(void 0===R.position&&void 0===R.normal&&void 0===R.color||vt.update(r,n,w),(E||v.receiveShadow!==r.receiveShadow)&&(v.receiveShadow=r.receiveShadow,S.setValue(Et,"receiveShadow",r.receiveShadow)),i.isMeshGouraudMaterial&&null!==i.envMap&&(B.envMap.value=l,B.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1),i.isMeshStandardMaterial&&null===i.envMap&&null!==e.environment&&(B.envMapIntensity.value=e.environmentIntensity),E&&(S.setValue(Et,"toneMappingExposure",_.toneMappingExposure),v.needsLights&&(P=M,(D=B).ambientLightColor.needsUpdate=P,D.lightProbe.needsUpdate=P,D.directionalLights.needsUpdate=P,D.directionalLightShadows.needsUpdate=P,D.pointLights.needsUpdate=P,D.pointLightShadows.needsUpdate=P,D.spotLights.needsUpdate=P,D.spotLightShadows.needsUpdate=P,D.rectAreaLights.needsUpdate=P,D.hemisphereLights.needsUpdate=P),s&&!0===i.fog&&dt.refreshFogUniforms(B,s),dt.refreshMaterialUniforms(B,i,F,N,A.state.transmissionRenderTarget[t.id]),vf.upload(Et,Kt(v),B,rt)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(vf.upload(Et,Kt(v),B,rt),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&S.setValue(Et,"center",r.center),S.setValue(Et,"modelViewMatrix",r.modelViewMatrix),S.setValue(Et,"normalMatrix",r.normalMatrix),S.setValue(Et,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const t=i.uniformsGroups;for(let e=0,n=t.length;e{function n(){i.forEach((function(t){it.get(t).currentProgram.isReady()&&i.delete(t)})),0!==i.size?setTimeout(n,10):e(t)}null!==$.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)}))};let Pt=null;function Lt(){Nt.stop()}function Ut(){Nt.start()}const Nt=new Rd;function Ot(t,e,n,i){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)n=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)A.pushLight(t),t.castShadow&&A.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||H.intersectsSprite(t)){i&&Y.setFromMatrixPosition(t.matrixWorld).applyMatrix4(q);const e=ct.update(t),r=t.material;r.visible&&g.push(t,e,r,n,Y.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||H.intersectsObject(t))){const e=ct.update(t),r=t.material;if(i&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),Y.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),Y.copy(e.boundingSphere.center)),Y.applyMatrix4(t.matrixWorld).applyMatrix4(q)),Array.isArray(r)){const i=e.groups;for(let s=0,a=i.length;s0&&Ht(r,e,n),s.length>0&&Ht(s,e,n),a.length>0&&Ht(a,e,n),et.buffers.depth.setTest(!0),et.buffers.depth.setMask(!0),et.buffers.color.setMask(!0),et.setPolygonOffset(!1)}function zt(t,e,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;void 0===A.state.transmissionRenderTarget[i.id]&&(A.state.transmissionRenderTarget[i.id]=new Li(1,1,{generateMipmaps:!0,type:$.has("EXT_color_buffer_half_float")||$.has("EXT_color_buffer_float")?jt:kt,minFilter:Ft,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:wi.workingColorSpace}));const s=A.state.transmissionRenderTarget[i.id],a=i.viewport||B;s.setSize(a.z*_.transmissionResolutionScale,a.w*_.transmissionResolutionScale);const o=_.getRenderTarget();_.setRenderTarget(s),_.getClearColor(P),L=_.getClearAlpha(),L<1&&_.setClearColor(16777215,.5),_.clear(),K&&At.render(n);const l=_.toneMapping;_.toneMapping=ht;const c=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),A.setupLightsView(i),!0===V&&mt.setGlobalState(_.clippingPlanes,i),Ht(t,n,i),rt.updateMultisampleRenderTarget(s),rt.updateRenderTargetMipmap(s),!1===$.has("WEBGL_multisampled_render_to_texture")){let t=!1;for(let r=0,s=e.length;r0)for(let e=0,s=n.length;e0&&zt(i,r,t,e),K&&At.render(t),Qt(g,t,e);null!==b&&0===C&&(rt.updateMultisampleRenderTarget(b),rt.updateRenderTargetMipmap(b)),!0===t.isScene&&t.onAfterRender(_,t,e),wt.resetDefaultState(),I=-1,T=null,y.pop(),y.length>0?(A=y[y.length-1],!0===V&&mt.setGlobalState(_.clippingPlanes,A.state.camera)):A=null,v.pop(),g=v.length>0?v[v.length-1]:null},this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return b},this.setRenderTargetTextures=function(t,e,n){it.get(t.texture).__webglTexture=e,it.get(t.depthTexture).__webglTexture=n;const i=it.get(t);i.__hasExternalTextures=!0,i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===$.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(t,e){const n=it.get(t);n.__webglFramebuffer=e,n.__useDefaultFramebuffer=void 0===e};const $t=Et.createFramebuffer();this.setRenderTarget=function(t,e=0,n=0){b=t,w=e,C=n;let i=!0,r=null,s=!1,a=!1;if(t){const o=it.get(t);if(void 0!==o.__useDefaultFramebuffer)et.bindFramebuffer(Et.FRAMEBUFFER,null),i=!1;else if(void 0===o.__webglFramebuffer)rt.setupRenderTarget(t);else if(o.__hasExternalTextures)rt.rebindTextures(t,it.get(t.texture).__webglTexture,it.get(t.depthTexture).__webglTexture);else if(t.depthBuffer){const e=t.depthTexture;if(o.__boundDepthTexture!==e){if(null!==e&&it.has(e)&&(t.width!==e.image.width||t.height!==e.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");rt.setupDepthRenderbuffer(t)}}const l=t.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(a=!0);const c=it.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(r=Array.isArray(c[e])?c[e][n]:c[e],s=!0):r=t.samples>0&&!1===rt.useMultisampledRTT(t)?it.get(t).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,B.copy(t.viewport),R.copy(t.scissor),D=t.scissorTest}else B.copy(Q).multiplyScalar(F).floor(),R.copy(z).multiplyScalar(F).floor(),D=G;if(0!==n&&(r=$t),et.bindFramebuffer(Et.FRAMEBUFFER,r)&&i&&et.drawBuffers(t,r),et.viewport(B),et.scissor(R),et.setScissorTest(D),s){const i=it.get(t.texture);Et.framebufferTexture2D(Et.FRAMEBUFFER,Et.COLOR_ATTACHMENT0,Et.TEXTURE_CUBE_MAP_POSITIVE_X+e,i.__webglTexture,n)}else if(a){const i=it.get(t.texture),r=e;Et.framebufferTextureLayer(Et.FRAMEBUFFER,Et.COLOR_ATTACHMENT0,i.__webglTexture,n,r)}else if(null!==t&&0!==n){const e=it.get(t.texture);Et.framebufferTexture2D(Et.FRAMEBUFFER,Et.COLOR_ATTACHMENT0,Et.TEXTURE_2D,e.__webglTexture,n)}I=-1},this.readRenderTargetPixels=function(t,e,n,i,r,s,a){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=it.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){et.bindFramebuffer(Et.FRAMEBUFFER,o);try{const a=t.texture,o=a.format,l=a.type;if(!tt.textureFormatReadable(o))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!tt.textureTypeReadable(l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r&&Et.readPixels(e,n,i,r,xt.convert(o),xt.convert(l),s)}finally{const t=null!==b?it.get(b).__webglFramebuffer:null;et.bindFramebuffer(Et.FRAMEBUFFER,t)}}},this.readRenderTargetPixelsAsync=async function(t,e,n,i,r,s,a){if(!t||!t.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=it.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){const a=t.texture,l=a.format,c=a.type;if(!tt.textureFormatReadable(l))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!tt.textureTypeReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r){et.bindFramebuffer(Et.FRAMEBUFFER,o);const t=Et.createBuffer();Et.bindBuffer(Et.PIXEL_PACK_BUFFER,t),Et.bufferData(Et.PIXEL_PACK_BUFFER,s.byteLength,Et.STREAM_READ),Et.readPixels(e,n,i,r,xt.convert(l),xt.convert(c),0);const a=null!==b?it.get(b).__webglFramebuffer:null;et.bindFramebuffer(Et.FRAMEBUFFER,a);const h=Et.fenceSync(Et.SYNC_GPU_COMMANDS_COMPLETE,0);return Et.flush(),await function(t,e){return new Promise((function(n,i){setTimeout((function r(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(r,4);break;default:n()}}),4)}))}(Et,h),Et.bindBuffer(Et.PIXEL_PACK_BUFFER,t),Et.getBufferSubData(Et.PIXEL_PACK_BUFFER,0,s),Et.deleteBuffer(t),Et.deleteSync(h),s}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(t,e=null,n=0){!0!==t.isTexture&&(vi("WebGLRenderer: copyFramebufferToTexture function signature has changed."),e=arguments[0]||null,t=arguments[1]);const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),s=Math.floor(t.image.height*i),a=null!==e?e.x:0,o=null!==e?e.y:0;rt.setTexture2D(t,0),Et.copyTexSubImage2D(Et.TEXTURE_2D,n,0,0,a,o,r,s),et.unbindTexture()};const te=Et.createFramebuffer(),ee=Et.createFramebuffer();this.copyTextureToTexture=function(t,e,n=null,i=null,r=0,s=null){let a,o,l,c,h,u,d,p,f;!0!==t.isTexture&&(vi("WebGLRenderer: copyTextureToTexture function signature has changed."),i=arguments[0]||null,t=arguments[1],e=arguments[2],s=arguments[3]||0,n=null),null===s&&(0!==r?(vi("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),s=r,r=0):s=0);const m=t.isCompressedTexture?t.mipmaps[s]:t.image;if(null!==n)a=n.max.x-n.min.x,o=n.max.y-n.min.y,l=n.isBox3?n.max.z-n.min.z:1,c=n.min.x,h=n.min.y,u=n.isBox3?n.min.z:0;else{const e=Math.pow(2,-r);a=Math.floor(m.width*e),o=Math.floor(m.height*e),l=t.isDataArrayTexture?m.depth:t.isData3DTexture?Math.floor(m.depth*e):1,c=0,h=0,u=0}null!==i?(d=i.x,p=i.y,f=i.z):(d=0,p=0,f=0);const g=xt.convert(e.format),A=xt.convert(e.type);let v;e.isData3DTexture?(rt.setTexture3D(e,0),v=Et.TEXTURE_3D):e.isDataArrayTexture||e.isCompressedArrayTexture?(rt.setTexture2DArray(e,0),v=Et.TEXTURE_2D_ARRAY):(rt.setTexture2D(e,0),v=Et.TEXTURE_2D),Et.pixelStorei(Et.UNPACK_FLIP_Y_WEBGL,e.flipY),Et.pixelStorei(Et.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),Et.pixelStorei(Et.UNPACK_ALIGNMENT,e.unpackAlignment);const y=Et.getParameter(Et.UNPACK_ROW_LENGTH),_=Et.getParameter(Et.UNPACK_IMAGE_HEIGHT),x=Et.getParameter(Et.UNPACK_SKIP_PIXELS),w=Et.getParameter(Et.UNPACK_SKIP_ROWS),C=Et.getParameter(Et.UNPACK_SKIP_IMAGES);Et.pixelStorei(Et.UNPACK_ROW_LENGTH,m.width),Et.pixelStorei(Et.UNPACK_IMAGE_HEIGHT,m.height),Et.pixelStorei(Et.UNPACK_SKIP_PIXELS,c),Et.pixelStorei(Et.UNPACK_SKIP_ROWS,h),Et.pixelStorei(Et.UNPACK_SKIP_IMAGES,u);const E=t.isDataArrayTexture||t.isData3DTexture,M=e.isDataArrayTexture||e.isData3DTexture;if(t.isDepthTexture){const n=it.get(t),i=it.get(e),m=it.get(n.__renderTarget),g=it.get(i.__renderTarget);et.bindFramebuffer(Et.READ_FRAMEBUFFER,m.__webglFramebuffer),et.bindFramebuffer(Et.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n\n\n\t\tvarying vec2 vUv;\n\n\t\t#if DIFFUSE_TEXTURE == 1\n\t\tuniform sampler2D tDiffuse;\n\t\t#endif\n\n\t\tuniform highp sampler2D tDepth;\n\t\tuniform highp sampler2D tNormal;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraInverseProjectionMatrix;\n\n\t\tuniform float scale;\n\t\tuniform float intensity;\n\t\tuniform float bias;\n\t\tuniform float kernelRadius;\n\t\tuniform float minResolution;\n\t\tuniform vec2 size;\n\t\tuniform float randomSeed;\n\n\t\t// RGBA depth\n\n\t\t#include \n\n\t\tvec4 getDefaultColor( const in vec2 screenPosition ) {\n\t\t\t#if DIFFUSE_TEXTURE == 1\n\t\t\treturn texture2D( tDiffuse, vUv );\n\t\t\t#else\n\t\t\treturn vec4( 1.0 );\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n\t\t\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n\t\t\tvec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );\n\t\t\tclipPosition *= clipW; // unprojection.\n\n\t\t\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;\n\t\t}\n\n\t\tvec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPosition ) {\n\t\t\treturn unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );\n\t\t}\n\n\t\tfloat scaleDividedByCameraFar;\n\t\tfloat minResolutionMultipliedByCameraFar;\n\n\t\tfloat getOcclusion( const in vec3 centerViewPosition, const in vec3 centerViewNormal, const in vec3 sampleViewPosition ) {\n\t\t\tvec3 viewDelta = sampleViewPosition - centerViewPosition;\n\t\t\tfloat viewDistance = length( viewDelta );\n\t\t\tfloat scaledScreenDistance = scaleDividedByCameraFar * viewDistance;\n\n\t\t\treturn max(0.0, (dot(centerViewNormal, viewDelta) - minResolutionMultipliedByCameraFar) / scaledScreenDistance - bias) / (1.0 + pow2( scaledScreenDistance ) );\n\t\t}\n\n\t\t// moving costly divides into consts\n\t\tconst float ANGLE_STEP = PI2 * float( NUM_RINGS ) / float( NUM_SAMPLES );\n\t\tconst float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );\n\n\t\tfloat getAmbientOcclusion( const in vec3 centerViewPosition ) {\n\t\t\t// precompute some variables require in getOcclusion.\n\t\t\tscaleDividedByCameraFar = scale / cameraFar;\n\t\t\tminResolutionMultipliedByCameraFar = minResolution * cameraFar;\n\t\t\tvec3 centerViewNormal = getViewNormal( centerViewPosition, vUv );\n\n\t\t\t// jsfiddle that shows sample pattern: https://jsfiddle.net/a16ff1p7/\n\t\t\tfloat angle = rand( vUv + randomSeed ) * PI2;\n\t\t\tvec2 radius = vec2( kernelRadius * INV_NUM_SAMPLES ) / size;\n\t\t\tvec2 radiusStep = radius;\n\n\t\t\tfloat occlusionSum = 0.0;\n\t\t\tfloat weightSum = 0.0;\n\n\t\t\tfor( int i = 0; i < NUM_SAMPLES; i ++ ) {\n\t\t\t\tvec2 sampleUv = vUv + vec2( cos( angle ), sin( angle ) ) * radius;\n\t\t\t\tradius += radiusStep;\n\t\t\t\tangle += ANGLE_STEP;\n\n\t\t\t\tfloat sampleDepth = getDepth( sampleUv );\n\t\t\t\tif( sampleDepth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tfloat sampleViewZ = getViewZ( sampleDepth );\n\t\t\t\tvec3 sampleViewPosition = getViewPosition( sampleUv, sampleDepth, sampleViewZ );\n\t\t\t\tocclusionSum += getOcclusion( centerViewPosition, centerViewNormal, sampleViewPosition );\n\t\t\t\tweightSum += 1.0;\n\t\t\t}\n\n\t\t\tif( weightSum == 0.0 ) discard;\n\n\t\t\treturn occlusionSum * ( intensity / weightSum );\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat centerDepth = getDepth( vUv );\n\t\t\tif( centerDepth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\tdiscard;\n\t\t\t}\n\n\t\t\tfloat centerViewZ = getViewZ( centerDepth );\n\t\t\tvec3 viewPosition = getViewPosition( vUv, centerDepth, centerViewZ );\n\n\t\t\tfloat ambientOcclusion = getAmbientOcclusion( viewPosition );\n\n\t\t\tgl_FragColor = getDefaultColor( vUv );\n\t\t\tgl_FragColor.xyz *= 1.0 - ambientOcclusion;\n\t\t}"},wm={name:"DepthLimitedBlurShader",defines:{KERNEL_RADIUS:4,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDiffuse:{value:null},size:{value:new ci(512,512)},sampleUvOffsets:{value:[new ci(0,0)]},sampleWeights:{value:[1]},tDepth:{value:null},cameraNear:{value:10},cameraFar:{value:1e3},depthCutoff:{value:10}},vertexShader:"\n\n\t\t#include \n\n\t\tuniform vec2 size;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec2 vInvSize;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tvInvSize = 1.0 / size;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\n\t\t#include \n\t\t#include \n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tDepth;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform float depthCutoff;\n\n\t\tuniform vec2 sampleUvOffsets[ KERNEL_RADIUS + 1 ];\n\t\tuniform float sampleWeights[ KERNEL_RADIUS + 1 ];\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec2 vInvSize;\n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\t#if DEPTH_PACKING == 1\n\t\t\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );\n\t\t\t#else\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth( vUv );\n\t\t\tif( depth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\tdiscard;\n\t\t\t}\n\n\t\t\tfloat centerViewZ = -getViewZ( depth );\n\t\t\tbool rBreak = false, lBreak = false;\n\n\t\t\tfloat weightSum = sampleWeights[0];\n\t\t\tvec4 diffuseSum = texture2D( tDiffuse, vUv ) * weightSum;\n\n\t\t\tfor( int i = 1; i <= KERNEL_RADIUS; i ++ ) {\n\n\t\t\t\tfloat sampleWeight = sampleWeights[i];\n\t\t\t\tvec2 sampleUvOffset = sampleUvOffsets[i] * vInvSize;\n\n\t\t\t\tvec2 sampleUv = vUv + sampleUvOffset;\n\t\t\t\tfloat viewZ = -getViewZ( getDepth( sampleUv ) );\n\n\t\t\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) rBreak = true;\n\n\t\t\t\tif( ! rBreak ) {\n\t\t\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;\n\t\t\t\t\tweightSum += sampleWeight;\n\t\t\t\t}\n\n\t\t\t\tsampleUv = vUv - sampleUvOffset;\n\t\t\t\tviewZ = -getViewZ( getDepth( sampleUv ) );\n\n\t\t\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) lBreak = true;\n\n\t\t\t\tif( ! lBreak ) {\n\t\t\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;\n\t\t\t\t\tweightSum += sampleWeight;\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tgl_FragColor = diffuseSum / weightSum;\n\t\t}"},Cm={createSampleWeights:function(t,e){const n=[];for(let i=0;i<=t;i++)n.push(Em(i,e));return n},createSampleOffsets:function(t,e){const n=[];for(let i=0;i<=t;i++)n.push(e.clone().multiplyScalar(i));return n},configure:function(t,e,n,i){t.defines.KERNEL_RADIUS=e,t.uniforms.sampleUvOffsets.value=Cm.createSampleOffsets(e,i),t.uniforms.sampleWeights.value=Cm.createSampleWeights(e,n),t.needsUpdate=!0}};function Em(t,e){return Math.exp(-t*t/(e*e*2))/(Math.sqrt(2*Math.PI)*e)}class Mm extends fm{constructor(t,e,n=new ci(256,256)){super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.originalClearColor=new ls,this._oldClearColor=new ls,this.oldClearAlpha=1,this.params={output:0,saoBias:.5,saoIntensity:.18,saoScale:1,saoKernelRadius:100,saoMinResolution:0,saoBlur:!0,saoBlurRadius:8,saoBlurStdDev:4,saoBlurDepthCutoff:.01},this.resolution=new ci(n.x,n.y),this.saoRenderTarget=new Li(this.resolution.x,this.resolution.y,{type:jt}),this.blurIntermediateRenderTarget=this.saoRenderTarget.clone();const i=new ol;i.format=ie,i.type=Yt,this.normalRenderTarget=new Li(this.resolution.x,this.resolution.y,{minFilter:Tt,magFilter:Tt,type:jt,depthTexture:i}),this.normalMaterial=new Fc,this.normalMaterial.blending=b,this.saoMaterial=new na({defines:Object.assign({},xm.defines),fragmentShader:xm.fragmentShader,vertexShader:xm.vertexShader,uniforms:ea.clone(xm.uniforms)}),this.saoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.saoMaterial.uniforms.tDepth.value=i,this.saoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.saoMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.blending=b,this.vBlurMaterial=new na({uniforms:ea.clone(wm.uniforms),defines:Object.assign({},wm.defines),vertexShader:wm.vertexShader,fragmentShader:wm.fragmentShader}),this.vBlurMaterial.defines.DEPTH_PACKING=0,this.vBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.vBlurMaterial.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.vBlurMaterial.uniforms.tDepth.value=i,this.vBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.vBlurMaterial.blending=b,this.hBlurMaterial=new na({uniforms:ea.clone(wm.uniforms),defines:Object.assign({},wm.defines),vertexShader:wm.vertexShader,fragmentShader:wm.fragmentShader}),this.hBlurMaterial.defines.DEPTH_PACKING=0,this.hBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.hBlurMaterial.uniforms.tDiffuse.value=this.blurIntermediateRenderTarget.texture,this.hBlurMaterial.uniforms.tDepth.value=i,this.hBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.hBlurMaterial.blending=b,this.materialCopy=new na({uniforms:ea.clone(pm.uniforms),vertexShader:pm.vertexShader,fragmentShader:pm.fragmentShader,blending:b}),this.materialCopy.transparent=!0,this.materialCopy.depthTest=!1,this.materialCopy.depthWrite=!1,this.materialCopy.blending=D,this.materialCopy.blendSrc=j,this.materialCopy.blendDst=O,this.materialCopy.blendEquation=P,this.materialCopy.blendSrcAlpha=V,this.materialCopy.blendDstAlpha=O,this.materialCopy.blendEquationAlpha=P,this.fsQuad=new Am(null)}render(t,e,n){this.renderToScreen&&(this.materialCopy.blending=b,this.materialCopy.uniforms.tDiffuse.value=n.texture,this.materialCopy.needsUpdate=!0,this.renderPass(t,this.materialCopy,null)),t.getClearColor(this._oldClearColor),this.oldClearAlpha=t.getClearAlpha();const i=t.autoClear;t.autoClear=!1,this.saoMaterial.uniforms.bias.value=this.params.saoBias,this.saoMaterial.uniforms.intensity.value=this.params.saoIntensity,this.saoMaterial.uniforms.scale.value=this.params.saoScale,this.saoMaterial.uniforms.kernelRadius.value=this.params.saoKernelRadius,this.saoMaterial.uniforms.minResolution.value=this.params.saoMinResolution,this.saoMaterial.uniforms.cameraNear.value=this.camera.near,this.saoMaterial.uniforms.cameraFar.value=this.camera.far;const r=this.params.saoBlurDepthCutoff*(this.camera.far-this.camera.near);this.vBlurMaterial.uniforms.depthCutoff.value=r,this.hBlurMaterial.uniforms.depthCutoff.value=r,this.vBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.vBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.hBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.hBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.params.saoBlurRadius=Math.floor(this.params.saoBlurRadius),this.prevStdDev===this.params.saoBlurStdDev&&this.prevNumSamples===this.params.saoBlurRadius||(Cm.configure(this.vBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new ci(0,1)),Cm.configure(this.hBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new ci(1,0)),this.prevStdDev=this.params.saoBlurStdDev,this.prevNumSamples=this.params.saoBlurRadius),this.renderOverride(t,this.normalMaterial,this.normalRenderTarget,7829503,1),this.renderPass(t,this.saoMaterial,this.saoRenderTarget,16777215,1),this.params.saoBlur&&(this.renderPass(t,this.vBlurMaterial,this.blurIntermediateRenderTarget,16777215,1),this.renderPass(t,this.hBlurMaterial,this.saoRenderTarget,16777215,1));const s=this.materialCopy;this.params.output===Mm.OUTPUT.Normal?(this.materialCopy.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.materialCopy.needsUpdate=!0):(this.materialCopy.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.materialCopy.needsUpdate=!0),this.params.output===Mm.OUTPUT.Default?s.blending=D:s.blending=b,this.renderPass(t,s,this.renderToScreen?null:n),t.setClearColor(this._oldClearColor,this.oldClearAlpha),t.autoClear=i}renderPass(t,e,n,i,r){t.getClearColor(this.originalClearColor);const s=t.getClearAlpha(),a=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.fsQuad.material=e,this.fsQuad.render(t),t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}renderOverride(t,e,n,i,r){t.getClearColor(this.originalClearColor);const s=t.getClearAlpha(),a=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,i=e.clearColor||i,r=e.clearAlpha||r,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.scene.overrideMaterial=e,t.render(this.scene,this.camera),this.scene.overrideMaterial=null,t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}setSize(t,e){this.saoRenderTarget.setSize(t,e),this.blurIntermediateRenderTarget.setSize(t,e),this.normalRenderTarget.setSize(t,e),this.saoMaterial.uniforms.size.value.set(t,e),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.needsUpdate=!0,this.vBlurMaterial.uniforms.size.value.set(t,e),this.vBlurMaterial.needsUpdate=!0,this.hBlurMaterial.uniforms.size.value.set(t,e),this.hBlurMaterial.needsUpdate=!0}dispose(){this.saoRenderTarget.dispose(),this.blurIntermediateRenderTarget.dispose(),this.normalRenderTarget.dispose(),this.normalMaterial.dispose(),this.saoMaterial.dispose(),this.vBlurMaterial.dispose(),this.hBlurMaterial.dispose(),this.materialCopy.dispose(),this.fsQuad.dispose()}}Mm.OUTPUT={Default:0,SAO:1,Normal:2};const Sm={name:"GTAOShader",defines:{PERSPECTIVE_CAMERA:1,SAMPLES:16,NORMAL_VECTOR_TYPE:1,DEPTH_SWIZZLING:"x",SCREEN_SPACE_RADIUS:0,SCREEN_SPACE_RADIUS_SCALE:100,SCENE_CLIP_BOX:0},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new ci},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new gr},cameraProjectionMatrixInverse:{value:new gr},cameraWorldMatrix:{value:new gr},radius:{value:.25},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},scale:{value:1},sceneBoxMin:{value:new Qi(-1,-1,-1)},sceneBoxMax:{value:new Qi(1,1,1)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\t\tvarying vec2 vUv;\n\t\tuniform highp sampler2D tNormal;\n\t\tuniform highp sampler2D tDepth;\n\t\tuniform sampler2D tNoise;\n\t\tuniform vec2 resolution;\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraProjectionMatrixInverse;\t\t\n\t\tuniform mat4 cameraWorldMatrix;\n\t\tuniform float radius;\n\t\tuniform float distanceExponent;\n\t\tuniform float thickness;\n\t\tuniform float distanceFallOff;\n\t\tuniform float scale;\n\t\t#if SCENE_CLIP_BOX == 1\n\t\t\tuniform vec3 sceneBoxMin;\n\t\t\tuniform vec3 sceneBoxMax;\n\t\t#endif\n\t\t\n\t\t#include \n\t\t#include \n\n\t\t#ifndef FRAGMENT_OUTPUT\n\t\t#define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)\n\t\t#endif\n\n\t\tvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n\t\t\tvec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n\t\t\tvec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n\t\t\treturn viewSpacePosition.xyz / viewSpacePosition.w;\n\t\t}\n\n\t\tfloat getDepth(const vec2 uv) { \n\t\t\treturn textureLod(tDepth, uv.xy, 0.0).DEPTH_SWIZZLING;\n\t\t}\n\n\t\tfloat fetchDepth(const ivec2 uv) { \n\t\t\treturn texelFetch(tDepth, uv.xy, 0).DEPTH_SWIZZLING;\n\t\t}\n\n\t\tfloat getViewZ(const in float depth) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\t\treturn perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#else\n\t\t\t\treturn orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 computeNormalFromDepth(const vec2 uv) {\n\t\t\tvec2 size = vec2(textureSize(tDepth, 0));\n\t\t\tivec2 p = ivec2(uv * size);\n\t\t\tfloat c0 = fetchDepth(p);\n\t\t\tfloat l2 = fetchDepth(p - ivec2(2, 0));\n\t\t\tfloat l1 = fetchDepth(p - ivec2(1, 0));\n\t\t\tfloat r1 = fetchDepth(p + ivec2(1, 0));\n\t\t\tfloat r2 = fetchDepth(p + ivec2(2, 0));\n\t\t\tfloat b2 = fetchDepth(p - ivec2(0, 2));\n\t\t\tfloat b1 = fetchDepth(p - ivec2(0, 1));\n\t\t\tfloat t1 = fetchDepth(p + ivec2(0, 1));\n\t\t\tfloat t2 = fetchDepth(p + ivec2(0, 2));\n\t\t\tfloat dl = abs((2.0 * l1 - l2) - c0);\n\t\t\tfloat dr = abs((2.0 * r1 - r2) - c0);\n\t\t\tfloat db = abs((2.0 * b1 - b2) - c0);\n\t\t\tfloat dt = abs((2.0 * t1 - t2) - c0);\n\t\t\tvec3 ce = getViewPosition(uv, c0).xyz;\n\t\t\tvec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n\t\t\tvec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n\t\t\treturn normalize(cross(dpdx, dpdy));\n\t\t}\n\n\t\tvec3 getViewNormal(const vec2 uv) {\n\t\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\t\treturn normalize(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\t\treturn unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#else\n\t\t\t\treturn computeNormalFromDepth(uv);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 getSceneUvAndDepth(vec3 sampleViewPos) {\n\t\t\tvec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);\n\t\t\tvec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;\n\t\t\tfloat sampleSceneDepth = getDepth(sampleUv);\n\t\t\treturn vec3(sampleUv, sampleSceneDepth);\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth(vUv.xy);\n\t\t\tif (depth >= 1.0) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvec3 viewPos = getViewPosition(vUv, depth);\n\t\t\tvec3 viewNormal = getViewNormal(vUv);\n\n\t\t\tfloat radiusToUse = radius;\n\t\t\tfloat distanceFalloffToUse = thickness;\n\t\t\t#if SCREEN_SPACE_RADIUS == 1\n\t\t\t\tfloat radiusScale = getViewPosition(vec2(0.5 + float(SCREEN_SPACE_RADIUS_SCALE) / resolution.x, 0.0), depth).x;\n\t\t\t\tradiusToUse *= radiusScale;\n\t\t\t\tdistanceFalloffToUse *= radiusScale;\n\t\t\t#endif\n\n\t\t\t#if SCENE_CLIP_BOX == 1\n\t\t\t\tvec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;\n\t\t\t\tfloat boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));\n\t\t\t\tif (boxDistance > radiusToUse) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t#endif\n\t\t\t\n\t\t\tvec2 noiseResolution = vec2(textureSize(tNoise, 0));\n\t\t\tvec2 noiseUv = vUv * resolution / noiseResolution;\n\t\t\tvec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n\t\t\tvec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;\n\t\t\tvec3 tangent = normalize(vec3(randomVec.xy, 0.));\n\t\t\tvec3 bitangent = vec3(-tangent.y, tangent.x, 0.);\n\t\t\tmat3 kernelMatrix = mat3(tangent, bitangent, vec3(0., 0., 1.));\n\n\t\t\tconst int DIRECTIONS = SAMPLES < 30 ? 3 : 5;\n\t\t\tconst int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n\t\t\tfloat ao = 0.0;\n\t\t\tfor (int i = 0; i < DIRECTIONS; ++i) {\n\t\t\t\t\n\t\t\t\tfloat angle = float(i) / float(DIRECTIONS) * PI;\n\t\t\t\tvec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w); \n\t\t\t\tsampleDir.xyz = normalize(kernelMatrix * sampleDir.xyz);\n\n\t\t\t\tvec3 viewDir = normalize(-viewPos.xyz);\n\t\t\t\tvec3 sliceBitangent = normalize(cross(sampleDir.xyz, viewDir));\n\t\t\t\tvec3 sliceTangent = cross(sliceBitangent, viewDir);\n\t\t\t\tvec3 normalInSlice = normalize(viewNormal - sliceBitangent * dot(viewNormal, sliceBitangent));\n\t\t\t\t\n\t\t\t\tvec3 tangentToNormalInSlice = cross(normalInSlice, sliceBitangent);\n\t\t\t\tvec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice), dot(viewDir, -tangentToNormalInSlice));\n\t\t\t\t\n\t\t\t\tfor (int j = 0; j < STEPS; ++j) {\n\t\t\t\t\tvec3 sampleViewOffset = sampleDir.xyz * radiusToUse * sampleDir.w * pow(float(j + 1) / float(STEPS), distanceExponent);\t\n\n\t\t\t\t\tvec3 sampleSceneUvDepth = getSceneUvAndDepth(viewPos + sampleViewOffset);\n\t\t\t\t\tvec3 sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\tvec3 viewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\tcosHorizons.x += max(0., (sampleCosHorizon - cosHorizons.x) * mix(1., 2. / float(j + 2), distanceFallOff));\n\t\t\t\t\t}\t\t\n\n\t\t\t\t\tsampleSceneUvDepth = getSceneUvAndDepth(viewPos - sampleViewOffset);\n\t\t\t\t\tsampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\tviewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\tcosHorizons.y += max(0., (sampleCosHorizon - cosHorizons.y) * mix(1., 2. / float(j + 2), distanceFallOff));\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tvec2 sinHorizons = sqrt(1. - cosHorizons * cosHorizons);\n\t\t\t\tfloat nx = dot(normalInSlice, sliceTangent);\n\t\t\t\tfloat ny = dot(normalInSlice, viewDir);\n\t\t\t\tfloat nxb = 1. / 2. * (acos(cosHorizons.y) - acos(cosHorizons.x) + sinHorizons.x * cosHorizons.x - sinHorizons.y * cosHorizons.y);\n\t\t\t\tfloat nyb = 1. / 2. * (2. - cosHorizons.x * cosHorizons.x - cosHorizons.y * cosHorizons.y);\n\t\t\t\tfloat occlusion = nx * nxb + ny * nyb;\n\t\t\t\tao += occlusion;\n\t\t\t}\n\n\t\t\tao = clamp(ao / float(DIRECTIONS), 0., 1.);\t\t\n\t\t#if SCENE_CLIP_BOX == 1\n\t\t\tao = mix(ao, 1., smoothstep(0., radiusToUse, boxDistance));\n\t\t#endif\n\t\t\tao = pow(ao, scale);\n\n\t\t\tgl_FragColor = FRAGMENT_OUTPUT;\n\t\t}"},bm={PERSPECTIVE_CAMERA:1},Im={tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},Tm="\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",Bm="\n\t\tuniform sampler2D tDepth;\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tvarying vec2 vUv;\n\n\t\t#include \n\n\t\tfloat getLinearDepth( const in vec2 screenPosition ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\t\tfloat fragCoordZ = texture2D( tDepth, screenPosition ).x;\n\t\t\t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n\t\t\t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat depth = getLinearDepth( vUv );\n\t\t\tgl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );\n\n\t\t}",Rm={tDiffuse:{value:null},intensity:{value:1}},Dm="\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",Pm="\n\t\tuniform float intensity;\n\t\tuniform sampler2D tDiffuse;\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = vec4(mix(vec3(1.), texel.rgb, intensity), texel.a);\n\t\t}";const Lm={name:"PoissonDenoiseShader",defines:{SAMPLES:16,SAMPLE_VECTORS:Um(16,2,1),NORMAL_VECTOR_TYPE:1,DEPTH_VALUE_SOURCE:0},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new ci},cameraProjectionMatrixInverse:{value:new gr},lumaPhi:{value:5},depthPhi:{value:5},normalPhi:{value:5},radius:{value:4},index:{value:0}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tNormal;\n\t\tuniform sampler2D tDepth;\n\t\tuniform sampler2D tNoise;\n\t\tuniform vec2 resolution;\n\t\tuniform mat4 cameraProjectionMatrixInverse;\n\t\tuniform float lumaPhi;\n\t\tuniform float depthPhi;\n\t\tuniform float normalPhi;\n\t\tuniform float radius;\n\t\tuniform int index;\n\t\t\n\t\t#include \n\t\t#include \n\n\t\t#ifndef SAMPLE_LUMINANCE\n\t\t#define SAMPLE_LUMINANCE dot(vec3(0.2125, 0.7154, 0.0721), a)\n\t\t#endif\n\n\t\t#ifndef FRAGMENT_OUTPUT\n\t\t#define FRAGMENT_OUTPUT vec4(denoised, 1.)\n\t\t#endif\n\n\t\tfloat getLuminance(const in vec3 a) {\n\t\t\treturn SAMPLE_LUMINANCE;\n\t\t}\n\n\t\tconst vec3 poissonDisk[SAMPLES] = SAMPLE_VECTORS;\n\n\t\tvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n\t\t\tvec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n\t\t\tvec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n\t\t\treturn viewSpacePosition.xyz / viewSpacePosition.w;\n\t\t}\n\t\t\n\t\tfloat getDepth(const vec2 uv) {\n\t\t#if DEPTH_VALUE_SOURCE == 1 \n\t\t\treturn textureLod(tDepth, uv.xy, 0.0).a;\n\t\t#else\n\t\t\treturn textureLod(tDepth, uv.xy, 0.0).r;\n\t\t#endif\n\t\t}\n\n\t\tfloat fetchDepth(const ivec2 uv) {\n\t\t\t#if DEPTH_VALUE_SOURCE == 1 \n\t\t\t\treturn texelFetch(tDepth, uv.xy, 0).a;\n\t\t\t#else\n\t\t\t\treturn texelFetch(tDepth, uv.xy, 0).r;\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 computeNormalFromDepth(const vec2 uv) {\n\t\t\tvec2 size = vec2(textureSize(tDepth, 0));\n\t\t\tivec2 p = ivec2(uv * size);\n\t\t\tfloat c0 = fetchDepth(p);\n\t\t\tfloat l2 = fetchDepth(p - ivec2(2, 0));\n\t\t\tfloat l1 = fetchDepth(p - ivec2(1, 0));\n\t\t\tfloat r1 = fetchDepth(p + ivec2(1, 0));\n\t\t\tfloat r2 = fetchDepth(p + ivec2(2, 0));\n\t\t\tfloat b2 = fetchDepth(p - ivec2(0, 2));\n\t\t\tfloat b1 = fetchDepth(p - ivec2(0, 1));\n\t\t\tfloat t1 = fetchDepth(p + ivec2(0, 1));\n\t\t\tfloat t2 = fetchDepth(p + ivec2(0, 2));\n\t\t\tfloat dl = abs((2.0 * l1 - l2) - c0);\n\t\t\tfloat dr = abs((2.0 * r1 - r2) - c0);\n\t\t\tfloat db = abs((2.0 * b1 - b2) - c0);\n\t\t\tfloat dt = abs((2.0 * t1 - t2) - c0);\n\t\t\tvec3 ce = getViewPosition(uv, c0).xyz;\n\t\t\tvec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n\t\t\t\t\t\t\t\t\t: -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n\t\t\tvec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n\t\t\t\t\t\t\t\t\t: -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n\t\t\treturn normalize(cross(dpdx, dpdy));\n\t\t}\n\n\t\tvec3 getViewNormal(const vec2 uv) {\n\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\treturn normalize(textureLod(tNormal, uv, 0.).rgb);\n\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\treturn unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n\t\t#else\n\t\t\treturn computeNormalFromDepth(uv);\n\t\t#endif\n\t\t}\n\n\t\tvoid denoiseSample(in vec3 center, in vec3 viewNormal, in vec3 viewPos, in vec2 sampleUv, inout vec3 denoised, inout float totalWeight) {\n\t\t\tvec4 sampleTexel = textureLod(tDiffuse, sampleUv, 0.0);\n\t\t\tfloat sampleDepth = getDepth(sampleUv);\n\t\t\tvec3 sampleNormal = getViewNormal(sampleUv);\n\t\t\tvec3 neighborColor = sampleTexel.rgb;\n\t\t\tvec3 viewPosSample = getViewPosition(sampleUv, sampleDepth);\n\t\t\t\n\t\t\tfloat normalDiff = dot(viewNormal, sampleNormal);\n\t\t\tfloat normalSimilarity = pow(max(normalDiff, 0.), normalPhi);\n\t\t\tfloat lumaDiff = abs(getLuminance(neighborColor) - getLuminance(center));\n\t\t\tfloat lumaSimilarity = max(1.0 - lumaDiff / lumaPhi, 0.0);\n\t\t\tfloat depthDiff = abs(dot(viewPos - viewPosSample, viewNormal));\n\t\t\tfloat depthSimilarity = max(1. - depthDiff / depthPhi, 0.);\n\t\t\tfloat w = lumaSimilarity * depthSimilarity * normalSimilarity;\n\t\t\n\t\t\tdenoised += w * neighborColor;\n\t\t\ttotalWeight += w;\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth(vUv.xy);\t\n\t\t\tvec3 viewNormal = getViewNormal(vUv);\t\n\t\t\tif (depth == 1. || dot(viewNormal, viewNormal) == 0.) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvec4 texel = textureLod(tDiffuse, vUv, 0.0);\n\t\t\tvec3 center = texel.rgb;\n\t\t\tvec3 viewPos = getViewPosition(vUv, depth);\n\n\t\t\tvec2 noiseResolution = vec2(textureSize(tNoise, 0));\n\t\t\tvec2 noiseUv = vUv * resolution / noiseResolution;\n\t\t\tvec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n \t\tvec2 noiseVec = vec2(sin(noiseTexel[index % 4] * 2. * PI), cos(noiseTexel[index % 4] * 2. * PI));\n \t\tmat2 rotationMatrix = mat2(noiseVec.x, -noiseVec.y, noiseVec.x, noiseVec.y);\n\t\t\n\t\t\tfloat totalWeight = 1.0;\n\t\t\tvec3 denoised = texel.rgb;\n\t\t\tfor (int i = 0; i < SAMPLES; i++) {\n\t\t\t\tvec3 sampleDir = poissonDisk[i];\n\t\t\t\tvec2 offset = rotationMatrix * (sampleDir.xy * (1. + sampleDir.z * (radius - 1.)) / resolution);\n\t\t\t\tvec2 sampleUv = vUv + offset;\n\t\t\t\tdenoiseSample(center, viewNormal, viewPos, sampleUv, denoised, totalWeight);\n\t\t\t}\n\t\t\n\t\t\tif (totalWeight > 0.) { \n\t\t\t\tdenoised /= totalWeight;\n\t\t\t}\n\t\t\tgl_FragColor = FRAGMENT_OUTPUT;\n\t\t}"};function Um(t,e,n){const i=function(t,e,n){const i=[];for(let r=0;ru?(d=1,p=0):(d=0,p=1);const f=h-d+l,m=u-p+l,g=h-1+2*l,A=u-1+2*l,v=255&a,y=255&o,_=this.perm[v+this.perm[y]]%12,x=this.perm[v+d+this.perm[y+p]]%12,w=this.perm[v+1+this.perm[y+1]]%12;let C=.5-h*h-u*u;C<0?n=0:(C*=C,n=C*C*this.dot(this.grad3[_],h,u));let E=.5-f*f-m*m;E<0?i=0:(E*=E,i=E*E*this.dot(this.grad3[x],f,m));let M=.5-g*g-A*A;return M<0?r=0:(M*=M,r=M*M*this.dot(this.grad3[w],g,A)),70*(n+i+r)}noise3d(t,e,n){let i,r,s,a;const o=(t+e+n)*(1/3),l=Math.floor(t+o),c=Math.floor(e+o),h=Math.floor(n+o),u=1/6,d=(l+c+h)*u,p=t-(l-d),f=e-(c-d),m=n-(h-d);let g,A,v,y,_,x;p>=f?f>=m?(g=1,A=0,v=0,y=1,_=1,x=0):p>=m?(g=1,A=0,v=0,y=1,_=0,x=1):(g=0,A=0,v=1,y=1,_=0,x=1):fx?32:0)+(_>w?16:0)+(x>w?8:0)+(_>C?4:0)+(x>C?2:0)+(w>C?1:0),M=s[E][0]>=3?1:0,S=s[E][1]>=3?1:0,b=s[E][2]>=3?1:0,I=s[E][3]>=3?1:0,T=s[E][0]>=2?1:0,B=s[E][1]>=2?1:0,R=s[E][2]>=2?1:0,D=s[E][3]>=2?1:0,P=s[E][0]>=1?1:0,L=s[E][1]>=1?1:0,U=s[E][2]>=1?1:0,N=s[E][3]>=1?1:0,F=_-M+l,O=x-S+l,k=w-b+l,Q=C-I+l,z=_-T+2*l,G=x-B+2*l,H=w-R+2*l,V=C-D+2*l,W=_-P+3*l,j=x-L+3*l,q=w-U+3*l,X=C-N+3*l,Y=_-1+4*l,J=x-1+4*l,K=w-1+4*l,Z=C-1+4*l,$=255&m,tt=255&g,et=255&A,nt=255&v,it=a[$+a[tt+a[et+a[nt]]]]%32,rt=a[$+M+a[tt+S+a[et+b+a[nt+I]]]]%32,st=a[$+T+a[tt+B+a[et+R+a[nt+D]]]]%32,at=a[$+P+a[tt+L+a[et+U+a[nt+N]]]]%32,ot=a[$+1+a[tt+1+a[et+1+a[nt+1]]]]%32;let lt=.6-_*_-x*x-w*w-C*C;lt<0?c=0:(lt*=lt,c=lt*lt*this.dot4(r[it],_,x,w,C));let ct=.6-F*F-O*O-k*k-Q*Q;ct<0?h=0:(ct*=ct,h=ct*ct*this.dot4(r[rt],F,O,k,Q));let ht=.6-z*z-G*G-H*H-V*V;ht<0?u=0:(ht*=ht,u=ht*ht*this.dot4(r[st],z,G,H,V));let ut=.6-W*W-j*j-q*q-X*X;ut<0?d=0:(ut*=ut,d=ut*ut*this.dot4(r[at],W,j,q,X));let dt=.6-Y*Y-J*J-K*K-Z*Z;return dt<0?p=0:(dt*=dt,p=dt*dt*this.dot4(r[ot],Y,J,K,Z)),27*(c+h+u+d+p)}}class Fm extends fm{constructor(t,e,n,i,r,s,a){super(),this.width=void 0!==n?n:512,this.height=void 0!==i?i:512,this.clear=!0,this.camera=e,this.scene=t,this.output=0,this._renderGBuffer=!0,this._visibilityCache=new Map,this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=function(t=5){const e=Math.floor(t)%2==0?Math.floor(t)+1:Math.floor(t),n=function(t){const e=Math.floor(t)%2==0?Math.floor(t)+1:Math.floor(t),n=e*e,i=Array(n).fill(0);let r=Math.floor(e/2),s=e-1;for(let t=1;t<=n;)-1===r&&s===e?(s=e-2,r=0):(s===e&&(s=0),r<0&&(r=e-1)),0===i[r*e+s]?(i[r*e+s]=t++,s++,r--):(s-=2,r++);return i}(e),i=n.length,r=new Uint8Array(4*i);for(let t=0;t\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 invSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float gaussianCoefficients[KERNEL_RADIUS];\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tfloat weightSum = gaussianCoefficients[0];\n\t\t\t\t\tvec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;\n\t\t\t\t\tfor( int i = 1; i < KERNEL_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = float(i);\n\t\t\t\t\t\tfloat w = gaussianCoefficients[i];\n\t\t\t\t\t\tvec2 uvOffset = direction * invSize * x;\n\t\t\t\t\t\tvec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;\n\t\t\t\t\t\tvec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;\n\t\t\t\t\t\tdiffuseSum += (sample1 + sample2) * w;\n\t\t\t\t\t\tweightSum += 2.0 * w;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n\t\t\t\t}"})}getCompositeMaterial(t){return new na({defines:{NUM_MIPS:t},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\t\t\t\tuniform sampler2D blurTexture1;\n\t\t\t\tuniform sampler2D blurTexture2;\n\t\t\t\tuniform sampler2D blurTexture3;\n\t\t\t\tuniform sampler2D blurTexture4;\n\t\t\t\tuniform sampler2D blurTexture5;\n\t\t\t\tuniform float bloomStrength;\n\t\t\t\tuniform float bloomRadius;\n\t\t\t\tuniform float bloomFactors[NUM_MIPS];\n\t\t\t\tuniform vec3 bloomTintColors[NUM_MIPS];\n\n\t\t\t\tfloat lerpBloomFactor(const in float factor) {\n\t\t\t\t\tfloat mirrorFactor = 1.2 - factor;\n\t\t\t\t\treturn mix(factor, mirrorFactor, bloomRadius);\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tgl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );\n\t\t\t\t}"})}}km.BlurDirectionX=new ci(1,0),km.BlurDirectionY=new ci(0,1);const Qm={name:"SobelOperatorShader",uniforms:{tDiffuse:{value:null},resolution:{value:new ci}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform vec2 resolution;\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec2 texel = vec2( 1.0 / resolution.x, 1.0 / resolution.y );\n\n\t\t// kernel definition (in glsl matrices are filled in column-major order)\n\n\t\t\tconst mat3 Gx = mat3( -1, -2, -1, 0, 0, 0, 1, 2, 1 ); // x direction kernel\n\t\t\tconst mat3 Gy = mat3( -1, 0, 1, -2, 0, 2, -1, 0, 1 ); // y direction kernel\n\n\t\t// fetch the 3x3 neighbourhood of a fragment\n\n\t\t// first column\n\n\t\t\tfloat tx0y0 = texture2D( tDiffuse, vUv + texel * vec2( -1, -1 ) ).r;\n\t\t\tfloat tx0y1 = texture2D( tDiffuse, vUv + texel * vec2( -1, 0 ) ).r;\n\t\t\tfloat tx0y2 = texture2D( tDiffuse, vUv + texel * vec2( -1, 1 ) ).r;\n\n\t\t// second column\n\n\t\t\tfloat tx1y0 = texture2D( tDiffuse, vUv + texel * vec2( 0, -1 ) ).r;\n\t\t\tfloat tx1y1 = texture2D( tDiffuse, vUv + texel * vec2( 0, 0 ) ).r;\n\t\t\tfloat tx1y2 = texture2D( tDiffuse, vUv + texel * vec2( 0, 1 ) ).r;\n\n\t\t// third column\n\n\t\t\tfloat tx2y0 = texture2D( tDiffuse, vUv + texel * vec2( 1, -1 ) ).r;\n\t\t\tfloat tx2y1 = texture2D( tDiffuse, vUv + texel * vec2( 1, 0 ) ).r;\n\t\t\tfloat tx2y2 = texture2D( tDiffuse, vUv + texel * vec2( 1, 1 ) ).r;\n\n\t\t// gradient value in x direction\n\n\t\t\tfloat valueGx = Gx[0][0] * tx0y0 + Gx[1][0] * tx1y0 + Gx[2][0] * tx2y0 +\n\t\t\t\tGx[0][1] * tx0y1 + Gx[1][1] * tx1y1 + Gx[2][1] * tx2y1 +\n\t\t\t\tGx[0][2] * tx0y2 + Gx[1][2] * tx1y2 + Gx[2][2] * tx2y2;\n\n\t\t// gradient value in y direction\n\n\t\t\tfloat valueGy = Gy[0][0] * tx0y0 + Gy[1][0] * tx1y0 + Gy[2][0] * tx2y0 +\n\t\t\t\tGy[0][1] * tx0y1 + Gy[1][1] * tx1y1 + Gy[2][1] * tx2y1 +\n\t\t\t\tGy[0][2] * tx0y2 + Gy[1][2] * tx1y2 + Gy[2][2] * tx2y2;\n\n\t\t// magnitude of the total gradient\n\n\t\t\tfloat G = sqrt( ( valueGx * valueGx ) + ( valueGy * valueGy ) );\n\n\t\t\tgl_FragColor = vec4( vec3( G ), 1 );\n\n\t\t}"},zm={name:"SSRShader",defines:{MAX_STEP:0,PERSPECTIVE_CAMERA:!0,DISTANCE_ATTENUATION:!0,FRESNEL:!0,INFINITE_THICK:!1,SELECTIVE:!1},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tMetalness:{value:null},tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null},resolution:{value:new ci},cameraProjectionMatrix:{value:new gr},cameraInverseProjectionMatrix:{value:new gr},opacity:{value:.5},maxDistance:{value:180},cameraRange:{value:0},thickness:{value:.018}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}\n\n\t",fragmentShader:'\n\t\t// precision highp float;\n\t\tprecision highp sampler2D;\n\t\tvarying vec2 vUv;\n\t\tuniform sampler2D tDepth;\n\t\tuniform sampler2D tNormal;\n\t\tuniform sampler2D tMetalness;\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform float cameraRange;\n\t\tuniform vec2 resolution;\n\t\tuniform float opacity;\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform float maxDistance;\n\t\tuniform float thickness;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraInverseProjectionMatrix;\n\t\t#include \n\t\tfloat pointToLineDistance(vec3 x0, vec3 x1, vec3 x2) {\n\t\t\t//x0: point, x1: linePointA, x2: linePointB\n\t\t\t//https://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html\n\t\t\treturn length(cross(x0-x1,x0-x2))/length(x2-x1);\n\t\t}\n\t\tfloat pointPlaneDistance(vec3 point,vec3 planePoint,vec3 planeNormal){\n\t\t\t// https://mathworld.wolfram.com/Point-PlaneDistance.html\n\t\t\t//// https://en.wikipedia.org/wiki/Plane_(geometry)\n\t\t\t//// http://paulbourke.net/geometry/pointlineplane/\n\t\t\tfloat a=planeNormal.x,b=planeNormal.y,c=planeNormal.z;\n\t\t\tfloat x0=point.x,y0=point.y,z0=point.z;\n\t\t\tfloat x=planePoint.x,y=planePoint.y,z=planePoint.z;\n\t\t\tfloat d=-(a*x+b*y+c*z);\n\t\t\tfloat distance=(a*x0+b*y0+c*z0+d)/sqrt(a*a+b*b+c*c);\n\t\t\treturn distance;\n\t\t}\n\t\tfloat getDepth( const in vec2 uv ) {\n\t\t\treturn texture2D( tDepth, uv ).x;\n\t\t}\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#ifdef PERSPECTIVE_CAMERA\n\t\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\t\tvec3 getViewPosition( const in vec2 uv, const in float depth/*clip space*/, const in float clipW ) {\n\t\t\tvec4 clipPosition = vec4( ( vec3( uv, depth ) - 0.5 ) * 2.0, 1.0 );//ndc\n\t\t\tclipPosition *= clipW; //clip\n\t\t\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;//view\n\t\t}\n\t\tvec3 getViewNormal( const in vec2 uv ) {\n\t\t\treturn unpackRGBToNormal( texture2D( tNormal, uv ).xyz );\n\t\t}\n\t\tvec2 viewPositionToXY(vec3 viewPosition){\n\t\t\tvec2 xy;\n\t\t\tvec4 clip=cameraProjectionMatrix*vec4(viewPosition,1);\n\t\t\txy=clip.xy;//clip\n\t\t\tfloat clipW=clip.w;\n\t\t\txy/=clipW;//NDC\n\t\t\txy=(xy+1.)/2.;//uv\n\t\t\txy*=resolution;//screen\n\t\t\treturn xy;\n\t\t}\n\t\tvoid main(){\n\t\t\t#ifdef SELECTIVE\n\t\t\t\tfloat metalness=texture2D(tMetalness,vUv).r;\n\t\t\t\tif(metalness==0.) return;\n\t\t\t#endif\n\n\t\t\tfloat depth = getDepth( vUv );\n\t\t\tfloat viewZ = getViewZ( depth );\n\t\t\tif(-viewZ>=cameraFar) return;\n\n\t\t\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ+cameraProjectionMatrix[3][3];\n\t\t\tvec3 viewPosition=getViewPosition( vUv, depth, clipW );\n\n\t\t\tvec2 d0=gl_FragCoord.xy;\n\t\t\tvec2 d1;\n\n\t\t\tvec3 viewNormal=getViewNormal( vUv );\n\n\t\t\t#ifdef PERSPECTIVE_CAMERA\n\t\t\t\tvec3 viewIncidentDir=normalize(viewPosition);\n\t\t\t\tvec3 viewReflectDir=reflect(viewIncidentDir,viewNormal);\n\t\t\t#else\n\t\t\t\tvec3 viewIncidentDir=vec3(0,0,-1);\n\t\t\t\tvec3 viewReflectDir=reflect(viewIncidentDir,viewNormal);\n\t\t\t#endif\n\n\t\t\tfloat maxReflectRayLen=maxDistance/dot(-viewIncidentDir,viewNormal);\n\t\t\t// dot(a,b)==length(a)*length(b)*cos(theta) // https://www.mathsisfun.com/algebra/vectors-dot-product.html\n\t\t\t// if(a.isNormalized&&b.isNormalized) dot(a,b)==cos(theta)\n\t\t\t// maxDistance/maxReflectRayLen=cos(theta)\n\t\t\t// maxDistance/maxReflectRayLen==dot(a,b)\n\t\t\t// maxReflectRayLen==maxDistance/dot(a,b)\n\n\t\t\tvec3 d1viewPosition=viewPosition+viewReflectDir*maxReflectRayLen;\n\t\t\t#ifdef PERSPECTIVE_CAMERA\n\t\t\t\tif(d1viewPosition.z>-cameraNear){\n\t\t\t\t\t//https://tutorial.math.lamar.edu/Classes/CalcIII/EqnsOfLines.aspx\n\t\t\t\t\tfloat t=(-cameraNear-viewPosition.z)/viewReflectDir.z;\n\t\t\t\t\td1viewPosition=viewPosition+viewReflectDir*t;\n\t\t\t\t}\n\t\t\t#endif\n\t\t\td1=viewPositionToXY(d1viewPosition);\n\n\t\t\tfloat totalLen=length(d1-d0);\n\t\t\tfloat xLen=d1.x-d0.x;\n\t\t\tfloat yLen=d1.y-d0.y;\n\t\t\tfloat totalStep=max(abs(xLen),abs(yLen));\n\t\t\tfloat xSpan=xLen/totalStep;\n\t\t\tfloat ySpan=yLen/totalStep;\n\t\t\tfor(float i=0.;i=totalStep) break;\n\t\t\t\tvec2 xy=vec2(d0.x+i*xSpan,d0.y+i*ySpan);\n\t\t\t\tif(xy.x<0.||xy.x>resolution.x||xy.y<0.||xy.y>resolution.y) break;\n\t\t\t\tfloat s=length(xy-d0)/totalLen;\n\t\t\t\tvec2 uv=xy/resolution;\n\n\t\t\t\tfloat d = getDepth(uv);\n\t\t\t\tfloat vZ = getViewZ( d );\n\t\t\t\tif(-vZ>=cameraFar) continue;\n\t\t\t\tfloat cW = cameraProjectionMatrix[2][3] * vZ+cameraProjectionMatrix[3][3];\n\t\t\t\tvec3 vP=getViewPosition( uv, d, cW );\n\n\t\t\t\t#ifdef PERSPECTIVE_CAMERA\n\t\t\t\t\t// https://comp.nus.edu.sg/~lowkl/publications/lowk_persp_interp_techrep.pdf\n\t\t\t\t\tfloat recipVPZ=1./viewPosition.z;\n\t\t\t\t\tfloat viewReflectRayZ=1./(recipVPZ+s*(1./d1viewPosition.z-recipVPZ));\n\t\t\t\t#else\n\t\t\t\t\tfloat viewReflectRayZ=viewPosition.z+s*(d1viewPosition.z-viewPosition.z);\n\t\t\t\t#endif\n\n\t\t\t\t// if(viewReflectRayZ>vZ) continue; // will cause "npm run make-screenshot webgl_postprocessing_ssr" high probability hang.\n\t\t\t\t// https://github.com/mrdoob/three.js/pull/21539#issuecomment-821061164\n\t\t\t\tif(viewReflectRayZ<=vZ){\n\n\t\t\t\t\tbool hit;\n\t\t\t\t\t#ifdef INFINITE_THICK\n\t\t\t\t\t\thit=true;\n\t\t\t\t\t#else\n\t\t\t\t\t\tfloat away=pointToLineDistance(vP,viewPosition,d1viewPosition);\n\n\t\t\t\t\t\tfloat minThickness;\n\t\t\t\t\t\tvec2 xyNeighbor=xy;\n\t\t\t\t\t\txyNeighbor.x+=1.;\n\t\t\t\t\t\tvec2 uvNeighbor=xyNeighbor/resolution;\n\t\t\t\t\t\tvec3 vPNeighbor=getViewPosition(uvNeighbor,d,cW);\n\t\t\t\t\t\tminThickness=vPNeighbor.x-vP.x;\n\t\t\t\t\t\tminThickness*=3.;\n\t\t\t\t\t\tfloat tk=max(minThickness,thickness);\n\n\t\t\t\t\t\thit=away<=tk;\n\t\t\t\t\t#endif\n\n\t\t\t\t\tif(hit){\n\t\t\t\t\t\tvec3 vN=getViewNormal( uv );\n\t\t\t\t\t\tif(dot(viewReflectDir,vN)>=0.) continue;\n\t\t\t\t\t\tfloat distance=pointPlaneDistance(vP,viewPosition,viewNormal);\n\t\t\t\t\t\tif(distance>maxDistance) break;\n\t\t\t\t\t\tfloat op=opacity;\n\t\t\t\t\t\t#ifdef DISTANCE_ATTENUATION\n\t\t\t\t\t\t\tfloat ratio=1.-(distance/maxDistance);\n\t\t\t\t\t\t\tfloat attenuation=ratio*ratio;\n\t\t\t\t\t\t\top=opacity*attenuation;\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#ifdef FRESNEL\n\t\t\t\t\t\t\tfloat fresnelCoe=(dot(viewIncidentDir,viewReflectDir)+1.)/2.;\n\t\t\t\t\t\t\top*=fresnelCoe;\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\tvec4 reflectColor=texture2D(tDiffuse,uv);\n\t\t\t\t\t\tgl_FragColor.xyz=reflectColor.xyz;\n\t\t\t\t\t\tgl_FragColor.a=op;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t'},Gm={PERSPECTIVE_CAMERA:1},Hm={tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},Vm="\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}\n\n\t",Wm="\n\n\t\tuniform sampler2D tDepth;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\n\t\tvarying vec2 vUv;\n\n\t\t#include \n\n\t\tfloat getLinearDepth( const in vec2 uv ) {\n\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\n\t\t\t\tfloat fragCoordZ = texture2D( tDepth, uv ).x;\n\t\t\t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n\t\t\t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n\n\t\t\t#else\n\n\t\t\t\treturn texture2D( tDepth, uv ).x;\n\n\t\t\t#endif\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tfloat depth = getLinearDepth( vUv );\n\t\t\tfloat d = 1.0 - depth;\n\t\t\t// d=(d-.999)*1000.;\n\t\t\tgl_FragColor = vec4( vec3( d ), 1.0 );\n\n\t\t}\n\n\t",jm={name:"SSRBlurShader",uniforms:{tDiffuse:{value:null},resolution:{value:new ci},opacity:{value:.5}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}\n\n\t",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform vec2 resolution;\n\t\tvarying vec2 vUv;\n\t\tvoid main() {\n\t\t\t//reverse engineering from PhotoShop blur filter, then change coefficient\n\n\t\t\tvec2 texelSize = ( 1.0 / resolution );\n\n\t\t\tvec4 c=texture2D(tDiffuse,vUv);\n\n\t\t\tvec2 offset;\n\n\t\t\toffset=(vec2(-1,0))*texelSize;\n\t\t\tvec4 cl=texture2D(tDiffuse,vUv+offset);\n\n\t\t\toffset=(vec2(1,0))*texelSize;\n\t\t\tvec4 cr=texture2D(tDiffuse,vUv+offset);\n\n\t\t\toffset=(vec2(0,-1))*texelSize;\n\t\t\tvec4 cb=texture2D(tDiffuse,vUv+offset);\n\n\t\t\toffset=(vec2(0,1))*texelSize;\n\t\t\tvec4 ct=texture2D(tDiffuse,vUv+offset);\n\n\t\t\t// float coeCenter=.5;\n\t\t\t// float coeSide=.125;\n\t\t\tfloat coeCenter=.2;\n\t\t\tfloat coeSide=.2;\n\t\t\tfloat a=c.a*coeCenter+cl.a*coeSide+cr.a*coeSide+cb.a*coeSide+ct.a*coeSide;\n\t\t\tvec3 rgb=(c.rgb*c.a*coeCenter+cl.rgb*cl.a*coeSide+cr.rgb*cr.a*coeSide+cb.rgb*cb.a*coeSide+ct.rgb*ct.a*coeSide)/a;\n\t\t\tgl_FragColor=vec4(rgb,a);\n\n\t\t}\n\t"};class qm extends fm{constructor({renderer:t,scene:e,camera:n,width:i,height:r,selects:s,bouncing:a=!1,groundReflector:o}){super(),this.width=void 0!==i?i:512,this.height=void 0!==r?r:512,this.clear=!0,this.renderer=t,this.scene=e,this.camera=n,this.groundReflector=o,this.opacity=zm.uniforms.opacity.value,this.output=0,this.maxDistance=zm.uniforms.maxDistance.value,this.thickness=zm.uniforms.thickness.value,this.tempColor=new ls,this._selects=s,this.selective=Array.isArray(this._selects),Object.defineProperty(this,"selects",{get(){return this._selects},set(t){this._selects!==t&&(this._selects=t,Array.isArray(t)?(this.selective=!0,this.ssrMaterial.defines.SELECTIVE=!0,this.ssrMaterial.needsUpdate=!0):(this.selective=!1,this.ssrMaterial.defines.SELECTIVE=!1,this.ssrMaterial.needsUpdate=!0))}}),this._bouncing=a,Object.defineProperty(this,"bouncing",{get(){return this._bouncing},set(t){this._bouncing!==t&&(this._bouncing=t,this.ssrMaterial.uniforms.tDiffuse.value=t?this.prevRenderTarget.texture:this.beautyRenderTarget.texture)}}),this.blur=!0,this._distanceAttenuation=zm.defines.DISTANCE_ATTENUATION,Object.defineProperty(this,"distanceAttenuation",{get(){return this._distanceAttenuation},set(t){this._distanceAttenuation!==t&&(this._distanceAttenuation=t,this.ssrMaterial.defines.DISTANCE_ATTENUATION=t,this.ssrMaterial.needsUpdate=!0)}}),this._fresnel=zm.defines.FRESNEL,Object.defineProperty(this,"fresnel",{get(){return this._fresnel},set(t){this._fresnel!==t&&(this._fresnel=t,this.ssrMaterial.defines.FRESNEL=t,this.ssrMaterial.needsUpdate=!0)}}),this._infiniteThick=zm.defines.INFINITE_THICK,Object.defineProperty(this,"infiniteThick",{get(){return this._infiniteThick},set(t){this._infiniteThick!==t&&(this._infiniteThick=t,this.ssrMaterial.defines.INFINITE_THICK=t,this.ssrMaterial.needsUpdate=!0)}});const l=new ol;l.type=Gt,l.minFilter=Tt,l.magFilter=Tt,this.beautyRenderTarget=new Li(this.width,this.height,{minFilter:Tt,magFilter:Tt,type:jt,depthTexture:l,depthBuffer:!0}),this.prevRenderTarget=new Li(this.width,this.height,{minFilter:Tt,magFilter:Tt}),this.normalRenderTarget=new Li(this.width,this.height,{minFilter:Tt,magFilter:Tt,type:jt}),this.metalnessRenderTarget=new Li(this.width,this.height,{minFilter:Tt,magFilter:Tt,type:jt}),this.ssrRenderTarget=new Li(this.width,this.height,{minFilter:Tt,magFilter:Tt}),this.blurRenderTarget=this.ssrRenderTarget.clone(),this.blurRenderTarget2=this.ssrRenderTarget.clone(),this.ssrMaterial=new na({defines:Object.assign({},zm.defines,{MAX_STEP:Math.sqrt(this.width*this.width+this.height*this.height)}),uniforms:ea.clone(zm.uniforms),vertexShader:zm.vertexShader,fragmentShader:zm.fragmentShader,blending:b}),this.ssrMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.ssrMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.ssrMaterial.defines.SELECTIVE=this.selective,this.ssrMaterial.needsUpdate=!0,this.ssrMaterial.uniforms.tMetalness.value=this.metalnessRenderTarget.texture,this.ssrMaterial.uniforms.tDepth.value=this.beautyRenderTarget.depthTexture,this.ssrMaterial.uniforms.cameraNear.value=this.camera.near,this.ssrMaterial.uniforms.cameraFar.value=this.camera.far,this.ssrMaterial.uniforms.thickness.value=this.thickness,this.ssrMaterial.uniforms.resolution.value.set(this.width,this.height),this.ssrMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssrMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.normalMaterial=new Fc,this.normalMaterial.blending=b,this.metalnessOnMaterial=new ds({color:"white"}),this.metalnessOffMaterial=new ds({color:"black"}),this.blurMaterial=new na({defines:Object.assign({},jm.defines),uniforms:ea.clone(jm.uniforms),vertexShader:jm.vertexShader,fragmentShader:jm.fragmentShader}),this.blurMaterial.uniforms.tDiffuse.value=this.ssrRenderTarget.texture,this.blurMaterial.uniforms.resolution.value.set(this.width,this.height),this.blurMaterial2=new na({defines:Object.assign({},jm.defines),uniforms:ea.clone(jm.uniforms),vertexShader:jm.vertexShader,fragmentShader:jm.fragmentShader}),this.blurMaterial2.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.blurMaterial2.uniforms.resolution.value.set(this.width,this.height),this.depthRenderMaterial=new na({defines:Object.assign({},Gm),uniforms:ea.clone(Hm),vertexShader:Vm,fragmentShader:Wm,blending:b}),this.depthRenderMaterial.uniforms.tDepth.value=this.beautyRenderTarget.depthTexture,this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new na({uniforms:ea.clone(pm.uniforms),vertexShader:pm.vertexShader,fragmentShader:pm.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:G,blendDst:H,blendEquation:P,blendSrcAlpha:G,blendDstAlpha:H,blendEquationAlpha:P}),this.fsQuad=new Am(null),this.originalClearColor=new ls}dispose(){this.beautyRenderTarget.dispose(),this.prevRenderTarget.dispose(),this.normalRenderTarget.dispose(),this.metalnessRenderTarget.dispose(),this.ssrRenderTarget.dispose(),this.blurRenderTarget.dispose(),this.blurRenderTarget2.dispose(),this.normalMaterial.dispose(),this.metalnessOnMaterial.dispose(),this.metalnessOffMaterial.dispose(),this.blurMaterial.dispose(),this.blurMaterial2.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this.fsQuad.dispose()}render(t,e){switch(t.setRenderTarget(this.beautyRenderTarget),t.clear(),this.groundReflector&&(this.groundReflector.visible=!1,this.groundReflector.doRender(this.renderer,this.scene,this.camera),this.groundReflector.visible=!0),t.render(this.scene,this.camera),this.groundReflector&&(this.groundReflector.visible=!1),this.renderOverride(t,this.normalMaterial,this.normalRenderTarget,0,0),this.selective&&this.renderMetalness(t,this.metalnessOnMaterial,this.metalnessRenderTarget,0,0),this.ssrMaterial.uniforms.opacity.value=this.opacity,this.ssrMaterial.uniforms.maxDistance.value=this.maxDistance,this.ssrMaterial.uniforms.thickness.value=this.thickness,this.renderPass(t,this.ssrMaterial,this.ssrRenderTarget),this.blur&&(this.renderPass(t,this.blurMaterial,this.blurRenderTarget),this.renderPass(t,this.blurMaterial2,this.blurRenderTarget2)),this.output){case qm.OUTPUT.Default:this.bouncing?(this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=b,this.renderPass(t,this.copyMaterial,this.prevRenderTarget),this.blur?this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget2.texture:this.copyMaterial.uniforms.tDiffuse.value=this.ssrRenderTarget.texture,this.copyMaterial.blending=I,this.renderPass(t,this.copyMaterial,this.prevRenderTarget),this.copyMaterial.uniforms.tDiffuse.value=this.prevRenderTarget.texture,this.copyMaterial.blending=b,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e)):(this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=b,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e),this.blur?this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget2.texture:this.copyMaterial.uniforms.tDiffuse.value=this.ssrRenderTarget.texture,this.copyMaterial.blending=I,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e));break;case qm.OUTPUT.SSR:this.blur?this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget2.texture:this.copyMaterial.uniforms.tDiffuse.value=this.ssrRenderTarget.texture,this.copyMaterial.blending=b,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e),this.bouncing&&(this.blur?this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget2.texture:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=b,this.renderPass(t,this.copyMaterial,this.prevRenderTarget),this.copyMaterial.uniforms.tDiffuse.value=this.ssrRenderTarget.texture,this.copyMaterial.blending=I,this.renderPass(t,this.copyMaterial,this.prevRenderTarget));break;case qm.OUTPUT.Beauty:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=b,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case qm.OUTPUT.Depth:this.renderPass(t,this.depthRenderMaterial,this.renderToScreen?null:e);break;case qm.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=b,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case qm.OUTPUT.Metalness:this.copyMaterial.uniforms.tDiffuse.value=this.metalnessRenderTarget.texture,this.copyMaterial.blending=b,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;default:console.warn("THREE.SSRPass: Unknown output type.")}}renderPass(t,e,n,i,r){this.originalClearColor.copy(t.getClearColor(this.tempColor));const s=t.getClearAlpha(this.tempColor),a=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.fsQuad.material=e,this.fsQuad.render(t),t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}renderOverride(t,e,n,i,r){this.originalClearColor.copy(t.getClearColor(this.tempColor));const s=t.getClearAlpha(this.tempColor),a=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,i=e.clearColor||i,r=e.clearAlpha||r,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.scene.overrideMaterial=e,t.render(this.scene,this.camera),this.scene.overrideMaterial=null,t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}renderMetalness(t,e,n,i,r){this.originalClearColor.copy(t.getClearColor(this.tempColor));const s=t.getClearAlpha(this.tempColor),a=t.autoClear,o=this.scene.background,l=this.scene.fog;t.setRenderTarget(n),t.autoClear=!1,this.scene.background=null,this.scene.fog=null,i=e.clearColor||i,r=e.clearAlpha||r,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.scene.traverseVisible((t=>{t._SSRPassBackupMaterial=t.material,this._selects.includes(t)?t.material=this.metalnessOnMaterial:t.material=this.metalnessOffMaterial})),t.render(this.scene,this.camera),this.scene.traverseVisible((t=>{t.material=t._SSRPassBackupMaterial})),t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s),this.scene.background=o,this.scene.fog=l}setSize(t,e){this.width=t,this.height=e,this.ssrMaterial.defines.MAX_STEP=Math.sqrt(t*t+e*e),this.ssrMaterial.needsUpdate=!0,this.beautyRenderTarget.setSize(t,e),this.prevRenderTarget.setSize(t,e),this.ssrRenderTarget.setSize(t,e),this.normalRenderTarget.setSize(t,e),this.metalnessRenderTarget.setSize(t,e),this.blurRenderTarget.setSize(t,e),this.blurRenderTarget2.setSize(t,e),this.ssrMaterial.uniforms.resolution.value.set(t,e),this.ssrMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssrMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.blurMaterial.uniforms.resolution.value.set(t,e),this.blurMaterial2.uniforms.resolution.value.set(t,e)}}qm.OUTPUT={Default:0,SSR:1,Beauty:3,Depth:4,Normal:5,Metalness:7};const Xm={name:"BokehShader",defines:{DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tColor:{value:null},tDepth:{value:null},focus:{value:1},aspect:{value:1},aperture:{value:.025},maxblur:{value:.01},nearClip:{value:1},farClip:{value:1e3}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\t#include \n\n\t\tvarying vec2 vUv;\n\n\t\tuniform sampler2D tColor;\n\t\tuniform sampler2D tDepth;\n\n\t\tuniform float maxblur; // max blur amount\n\t\tuniform float aperture; // aperture - bigger values for shallower depth of field\n\n\t\tuniform float nearClip;\n\t\tuniform float farClip;\n\n\t\tuniform float focus;\n\t\tuniform float aspect;\n\n\t\t#include \n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\t#if DEPTH_PACKING == 1\n\t\t\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );\n\t\t\t#else\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, nearClip, farClip );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, nearClip, farClip );\n\t\t\t#endif\n\t\t}\n\n\n\t\tvoid main() {\n\n\t\t\tvec2 aspectcorrect = vec2( 1.0, aspect );\n\n\t\t\tfloat viewZ = getViewZ( getDepth( vUv ) );\n\n\t\t\tfloat factor = ( focus + viewZ ); // viewZ is <= 0, so this is a difference equation\n\n\t\t\tvec2 dofblur = vec2 ( clamp( factor * aperture, -maxblur, maxblur ) );\n\n\t\t\tvec2 dofblur9 = dofblur * 0.9;\n\t\t\tvec2 dofblur7 = dofblur * 0.7;\n\t\t\tvec2 dofblur4 = dofblur * 0.4;\n\n\t\t\tvec4 col = vec4( 0.0 );\n\n\t\t\tcol += texture2D( tColor, vUv.xy );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur );\n\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur9 );\n\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur7 );\n\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.4, 0.0 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur4 );\n\n\t\t\tgl_FragColor = col / 41.0;\n\t\t\tgl_FragColor.a = 1.0;\n\n\t\t}"},Ym=new gr;class Jm{constructor(t){t=t||{},this.zNear=!0===t.webGL?-1:0,this.vertices={near:[new Qi,new Qi,new Qi,new Qi],far:[new Qi,new Qi,new Qi,new Qi]},void 0!==t.projectionMatrix&&this.setFromProjectionMatrix(t.projectionMatrix,t.maxFar||1e4)}setFromProjectionMatrix(t,e){const n=this.zNear,i=0===t.elements[11];return Ym.copy(t).invert(),this.vertices.near[0].set(1,1,n),this.vertices.near[1].set(1,-1,n),this.vertices.near[2].set(-1,-1,n),this.vertices.near[3].set(-1,1,n),this.vertices.near.forEach((function(t){t.applyMatrix4(Ym)})),this.vertices.far[0].set(1,1,1),this.vertices.far[1].set(1,-1,1),this.vertices.far[2].set(-1,-1,1),this.vertices.far[3].set(-1,1,1),this.vertices.far.forEach((function(t){t.applyMatrix4(Ym);const n=Math.abs(t.z);i?t.z*=Math.min(e/n,1):t.multiplyScalar(Math.min(e/n,1))})),this.vertices}split(t,e){for(;t.length>e.length;)e.push(new Jm);e.length=t.length;for(let n=0;n 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\t// Iridescence F0 approximation\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\n\nIncidentLight directLight;\n\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tpointLight = pointLights[ i ];\n\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tSpotLight spotLight;\n \tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tspotLight = spotLights[ i ];\n\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\n \t\t// spot lights are ordered [shadows with maps, shadows without maps, maps without shadows, none]\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) && defined( USE_CSM ) && defined( CSM_CASCADES )\n\n\tDirectionalLight directionalLight;\n\tfloat linearDepth = (vViewPosition.z) / (shadowFar - cameraNear);\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\n\t#if defined( USE_SHADOWMAP ) && defined( CSM_FADE )\n\t\tvec2 cascade;\n\t\tfloat cascadeCenter;\n\t\tfloat closestEdge;\n\t\tfloat margin;\n\t\tfloat csmx;\n\t\tfloat csmy;\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\t\tdirectionalLight = directionalLights[ i ];\n\t\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\n\t\t\t#if ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\t\t\t// NOTE: Depth gets larger away from the camera.\n\t\t\t\t// cascade.x is closer, cascade.y is further\n\t\t\t\tcascade = CSM_cascades[ i ];\n\t\t\t\tcascadeCenter = ( cascade.x + cascade.y ) / 2.0;\n\t\t\t\tclosestEdge = linearDepth < cascadeCenter ? cascade.x : cascade.y;\n\t\t\t\tmargin = 0.25 * pow( closestEdge, 2.0 );\n\t\t\t\tcsmx = cascade.x - margin / 2.0;\n\t\t\t\tcsmy = cascade.y + margin / 2.0;\n\t\t\t\tif( linearDepth >= csmx && ( linearDepth < csmy || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 ) ) {\n\n\t\t\t\t\tfloat dist = min( linearDepth - csmx, csmy - linearDepth );\n\t\t\t\t\tfloat ratio = clamp( dist / margin, 0.0, 1.0 );\n\n\t\t\t\t\tvec3 prevColor = directLight.color;\n\t\t\t\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\t\t\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n\t\t\t\t\tbool shouldFadeLastCascade = UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth > cascadeCenter;\n\t\t\t\t\tdirectLight.color = mix( prevColor, directLight.color, shouldFadeLastCascade ? ratio : 1.0 );\n\n\t\t\t\t\tReflectedLight prevLight = reflectedLight;\n\t\t\t\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t\t\t\t\tbool shouldBlend = UNROLLED_LOOP_INDEX != CSM_CASCADES - 1 || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth < cascadeCenter;\n\t\t\t\t\tfloat blendRatio = shouldBlend ? ratio : 1.0;\n\n\t\t\t\t\treflectedLight.directDiffuse = mix( prevLight.directDiffuse, reflectedLight.directDiffuse, blendRatio );\n\t\t\t\t\treflectedLight.directSpecular = mix( prevLight.directSpecular, reflectedLight.directSpecular, blendRatio );\n\t\t\t\t\treflectedLight.indirectDiffuse = mix( prevLight.indirectDiffuse, reflectedLight.indirectDiffuse, blendRatio );\n\t\t\t\t\treflectedLight.indirectSpecular = mix( prevLight.indirectSpecular, reflectedLight.indirectSpecular, blendRatio );\n\n\t\t\t\t}\n\t\t\t#endif\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#elif defined (USE_SHADOWMAP)\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\t\tdirectionalLight = directionalLights[ i ];\n\t\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\n\t\t\t#if ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\n\t\t\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\t\t\tif(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y) directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n\t\t\t\tif(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && (linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1)) RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t\t\t#endif\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#elif ( NUM_DIR_LIGHT_SHADOWS > 0 )\n\t\t// note: no loop here - all CSM lights are in fact one light only\n\t\tgetDirectionalLightInfo( directionalLights[0], directLight );\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t#endif\n\n\t#if ( NUM_DIR_LIGHTS > NUM_DIR_LIGHT_SHADOWS)\n\t\t// compute the lights not casting shadows (if any)\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = NUM_DIR_LIGHT_SHADOWS; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\t\tdirectionalLight = directionalLights[ i ];\n\n\t\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\n\t\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#endif\n\n#endif\n\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) && !defined( USE_CSM ) && !defined( CSM_CASCADES )\n\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tdirectionalLight = directionalLights[ i ];\n\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n\tRectAreaLight rectAreaLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if defined( RE_IndirectDiffuse )\n\n\tvec3 iblIrradiance = vec3( 0.0 );\n\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n\t#if defined( USE_LIGHT_PROBES )\n\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\n\t#endif\n\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#endif\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n\n#endif\n",lights_pars_begin:"\n#if defined( USE_CSM ) && defined( CSM_CASCADES )\nuniform vec2 CSM_cascades[CSM_CASCADES];\nuniform float cameraNear;\nuniform float shadowFar;\n#endif\n\t"+Pd.lights_pars_begin},Zm=new gr,$m=new Jm({webGL:!0}),tg=new Qi,eg=new Hi,ng=[],ig=[],rg=new gr,sg=new gr,ag=new Qi(0,1,0),og={type:"change"},lg={type:"start"},cg={type:"end"},hg=new mr,ug=new ho,dg=Math.cos(70*li.DEG2RAD),pg=new Qi,fg=2*Math.PI,mg=-1,gg=1e-6;function Ag(t){!1!==this.enabled&&(0===this._pointers.length&&(this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),this._isTrackingPointer(t)||(this._addPointer(t),"touch"===t.pointerType?this._onTouchStart(t):this._onMouseDown(t)))}function vg(t){!1!==this.enabled&&("touch"===t.pointerType?this._onTouchMove(t):this._onMouseMove(t))}function yg(t){switch(this._removePointer(t),this._pointers.length){case 0:this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(cg),this.state=mg;break;case 1:const e=this._pointers[0],n=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:n.x,pageY:n.y})}}function _g(t){let e;switch(t.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case f.DOLLY:if(!1===this.enableZoom)return;this._handleMouseDownDolly(t),this.state=1;break;case f.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===this.enablePan)return;this._handleMouseDownPan(t),this.state=2}else{if(!1===this.enableRotate)return;this._handleMouseDownRotate(t),this.state=0}break;case f.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===this.enableRotate)return;this._handleMouseDownRotate(t),this.state=0}else{if(!1===this.enablePan)return;this._handleMouseDownPan(t),this.state=2}break;default:this.state=mg}this.state!==mg&&this.dispatchEvent(lg)}function xg(t){switch(this.state){case 0:if(!1===this.enableRotate)return;this._handleMouseMoveRotate(t);break;case 1:if(!1===this.enableZoom)return;this._handleMouseMoveDolly(t);break;case 2:if(!1===this.enablePan)return;this._handleMouseMovePan(t)}}function wg(t){!1!==this.enabled&&!1!==this.enableZoom&&this.state===mg&&(t.preventDefault(),this.dispatchEvent(lg),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(cg))}function Cg(t){!1!==this.enabled&&this._handleKeyDown(t)}function Eg(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case m.ROTATE:if(!1===this.enableRotate)return;this._handleTouchStartRotate(t),this.state=3;break;case m.PAN:if(!1===this.enablePan)return;this._handleTouchStartPan(t),this.state=4;break;default:this.state=mg}break;case 2:switch(this.touches.TWO){case m.DOLLY_PAN:if(!1===this.enableZoom&&!1===this.enablePan)return;this._handleTouchStartDollyPan(t),this.state=5;break;case m.DOLLY_ROTATE:if(!1===this.enableZoom&&!1===this.enableRotate)return;this._handleTouchStartDollyRotate(t),this.state=6;break;default:this.state=mg}break;default:this.state=mg}this.state!==mg&&this.dispatchEvent(lg)}function Mg(t){switch(this._trackPointer(t),this.state){case 3:if(!1===this.enableRotate)return;this._handleTouchMoveRotate(t),this.update();break;case 4:if(!1===this.enablePan)return;this._handleTouchMovePan(t),this.update();break;case 5:if(!1===this.enableZoom&&!1===this.enablePan)return;this._handleTouchMoveDollyPan(t),this.update();break;case 6:if(!1===this.enableZoom&&!1===this.enableRotate)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=mg}}function Sg(t){!1!==this.enabled&&t.preventDefault()}function bg(t){"Control"===t.key&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Ig(t){"Control"===t.key&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Tg(t,e=!1){const n=null!==t[0].index,i=new Set(Object.keys(t[0].attributes)),r=new Set(Object.keys(t[0].morphAttributes)),s={},a={},o=t[0].morphTargetsRelative,l=new Fs;let c=0;for(let h=0;h=2.0 are supported.")));const l=new CA(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t=0&&void 0===a[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}l.setExtensions(s),l.setPlugins(a),l.parse(n,i)}parseAsync(t,e){const n=this;return new Promise((function(i,r){n.parse(t,e,i,r)}))}}function Lg(){let t={};return{get:function(e){return t[e]},add:function(e,n){t[e]=n},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const Ug={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Ng{constructor(t){this.parser=t,this.name=Ug.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let n=0,i=e.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,s)}}class Jg{constructor(t){this.parser=t,this.name=Ug.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const t=n.options.manager.getHandler(a.uri);null!==t&&(o=t)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(t,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class Kg{constructor(t){this.parser=t,this.name=Ug.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const t=n.options.manager.getHandler(a.uri);null!==t&&(o=t)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(t,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class Zg{constructor(t){this.name=Ug.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){const t=n.extensions[this.name],i=this.parser.getDependency("buffer",t.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then((function(e){const n=t.byteOffset||0,i=t.byteLength||0,s=t.count,a=t.byteStride,o=new Uint8Array(e,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,a,o,t.mode,t.filter).then((function(t){return t.buffer})):r.ready.then((function(){const e=new ArrayBuffer(s*a);return r.decodeGltfBuffer(new Uint8Array(e),s,a,o,t.mode,t.filter),e}))}))}return null}}class $g{constructor(t){this.name=Ug.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,n=e.nodes[t];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const i=e.meshes[n.mesh];for(const t of i.primitives)if(t.mode!==lA.TRIANGLES&&t.mode!==lA.TRIANGLE_STRIP&&t.mode!==lA.TRIANGLE_FAN&&void 0!==t.mode)return null;const r=n.extensions[this.name].attributes,s=[],a={};for(const t in r)s.push(this.parser.getDependency("accessor",r[t]).then((e=>(a[t]=e,a[t]))));return s.length<1?null:(s.push(this.parser.createNodeMesh(t)),Promise.all(s).then((t=>{const e=t.pop(),n=e.isGroup?e.children:[e],i=t[0].count,r=[];for(const t of n){const e=new gr,n=new Qi,s=new ki,o=new Qi(1,1,1),l=new ao(t.geometry,t.material,i);for(let t=0;t-1,s=r?t.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||n&&i<17||r&&s<98?this.textureLoader=new xh(this.options.manager):this.textureLoader=new Jh(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new mh(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(t){return t._markDefs&&t._markDefs()})),Promise.all(this._invokeAll((function(t){return t.beforeRoot&&t.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(e){const s={scene:e[0][i.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:i.asset,parser:n,userData:{}};return gA(r,s,i),AA(s,i),Promise.all(n._invokeAll((function(t){return t.afterRoot&&t.afterRoot(s)}))).then((function(){for(const t of s.scenes)t.updateMatrixWorld();t(s)}))})).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=e.length;n{const n=this.associations.get(t);null!=n&&this.associations.set(e,n);for(const[n,i]of t.children.entries())r(i,e.children[n])};return r(n,i),i.name+="_instance_"+t.uses[e]++,i}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let n=0;n=2&&p.setY(e,h[t*s+1]),s>=3&&p.setZ(e,h[t*s+2]),s>=4&&p.setW(e,h[t*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=u}return p}))}loadTexture(t){const e=this.json,n=this.options,i=e.textures[t].source,r=e.images[i];let s=this.textureLoader;if(r.uri){const t=n.manager.getHandler(r.uri);null!==t&&(s=t)}return this.loadTextureImage(t,i,s)}loadTextureImage(t,e,n){const i=this,r=this.json,s=r.textures[t],a=r.images[e],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(e,n).then((function(e){e.flipY=!1,e.name=s.name||a.name||"",""===e.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(e.name=a.uri);const n=(r.samplers||{})[s.sampler]||{};return e.magFilter=hA[n.magFilter]||Lt,e.minFilter=hA[n.minFilter]||Ft,e.wrapS=uA[n.wrapS]||St,e.wrapT=uA[n.wrapT]||St,e.generateMipmaps=!e.isCompressedTexture&&e.minFilter!==Tt&&e.minFilter!==Lt,i.associations.set(e,{textures:t}),e})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(t,e){const n=this.json,i=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then((t=>t.clone()));const r=n.images[t],s=self.URL||self.webkitURL;let a=r.uri||"",o=!1;if(void 0!==r.bufferView)a=this.getDependency("bufferView",r.bufferView).then((function(t){o=!0;const e=new Blob([t],{type:r.mimeType});return a=s.createObjectURL(e),a}));else if(void 0===r.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const l=Promise.resolve(a).then((function(t){return new Promise((function(n,r){let s=n;!0===e.isImageBitmapLoader&&(s=function(t){const e=new Ri(t);e.needsUpdate=!0,n(e)}),e.load(Hh.resolveURL(t,i.path),s,void 0,r)}))})).then((function(t){var e;return!0===o&&s.revokeObjectURL(a),AA(t,r),t.userData.mimeType=r.mimeType||((e=r.uri).search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":e.search(/\.ktx2($|\?)/i)>0||0===e.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),t})).catch((function(t){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),t}));return this.sourceCache[t]=l,l}assignTexture(t,e,n,i){const r=this;return this.getDependency("texture",n.index).then((function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),r.extensions[Ug.KHR_TEXTURE_TRANSFORM]){const t=void 0!==n.extensions?n.extensions[Ug.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=r.associations.get(s);s=r.extensions[Ug.KHR_TEXTURE_TRANSFORM].extendTexture(s,t),r.associations.set(s,e)}}return void 0!==i&&(s.colorSpace=i),t[e]=s,s}))}assignFinalMaterial(t){const e=t.geometry;let n=t.material;const i=void 0===e.attributes.tangent,r=void 0!==e.attributes.color,s=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new qo,us.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,e.sizeAttenuation=!1,this.cache.add(t,e)),n=e}else if(t.isLine){const t="LineBasicMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new Po,us.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,this.cache.add(t,e)),n=e}if(i||r||s){let t="ClonedMaterial:"+n.uuid+":";i&&(t+="derivative-tangents:"),r&&(t+="vertex-colors:"),s&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=n.clone(),r&&(e.vertexColors=!0),s&&(e.flatShading=!0),i&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(n))),n=e}t.material=n}getMaterialType(){return Pc}loadMaterial(t){const e=this,n=this.json,i=this.extensions,r=n.materials[t];let s;const a={},o=[];if((r.extensions||{})[Ug.KHR_MATERIALS_UNLIT]){const t=i[Ug.KHR_MATERIALS_UNLIT];s=t.getMaterialType(),o.push(t.extendParams(a,r,e))}else{const n=r.pbrMetallicRoughness||{};if(a.color=new ls(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const t=n.baseColorFactor;a.color.setRGB(t[0],t[1],t[2],un),a.opacity=t[3]}void 0!==n.baseColorTexture&&o.push(e.assignTexture(a,"map",n.baseColorTexture,hn)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(o.push(e.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),o.push(e.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),s=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),o.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,a)}))))}!0===r.doubleSided&&(a.side=S);const l=r.alphaMode||"OPAQUE";if("BLEND"===l?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,"MASK"===l&&(a.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&s!==ds&&(o.push(e.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new ci(1,1),void 0!==r.normalTexture.scale)){const t=r.normalTexture.scale;a.normalScale.set(t,t)}if(void 0!==r.occlusionTexture&&s!==ds&&(o.push(e.assignTexture(a,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(a.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&s!==ds){const t=r.emissiveFactor;a.emissive=(new ls).setRGB(t[0],t[1],t[2],un)}return void 0!==r.emissiveTexture&&s!==ds&&o.push(e.assignTexture(a,"emissiveMap",r.emissiveTexture,hn)),Promise.all(o).then((function(){const n=new s(a);return r.name&&(n.name=r.name),AA(n,r),e.associations.set(n,{materials:t}),r.extensions&&gA(i,n,r),n}))}createUniqueName(t){const e=Su.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,n=this.extensions,i=this.primitiveCache;function r(t){return n[Ug.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then((function(n){return EA(n,t,e)}))}const s=[];for(let n=0,a=t.length;n0&&vA(u,r),u.name=e.createUniqueName(r.name||"mesh_"+t),AA(u,r),h.extensions&&gA(i,u,h),e.assignFinalMaterial(u),l.push(u)}for(let n=0,i=l.length;n1?new tl:1===e.length?e[0]:new Hr,a!==e[0])for(let t=0,n=e.length;t{const e=new Map;for(const[t,n]of i.associations)(t instanceof us||t instanceof Ri)&&e.set(t,n);return t.traverse((t=>{const n=i.associations.get(t);null!=n&&e.set(t,n)})),e})(r),r}))}_createAnimationTracks(t,e,n,i,r){const s=[],a=t.name?t.name:t.uuid,o=[];let l;switch(fA[r.path]===fA.weights?t.traverse((function(t){t.morphTargetInfluences&&o.push(t.name?t.name:t.uuid)})):o.push(a),fA[r.path]){case fA.weights:l=nh;break;case fA.rotation:l=rh;break;case fA.position:case fA.scale:l=ah;break;default:l=1===n.itemSize?nh:ah}const c=void 0!==i.interpolation?mA[i.interpolation]:je,h=this._getArrayFromAccessor(n);for(let t=0,n=o.length;tt.toBlob(n,e)));let n;return"image/jpeg"===e?n=.92:"image/webp"===e&&(n=.8),t.convertToBlob({type:e,quality:n})}class zA{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r"+p}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map},this.textureUtils=null}setPlugins(t){this.plugins=t}setTextureUtils(t){this.textureUtils=t}async writeAsync(t,e,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(t),await Promise.all(this.pending);const i=this,r=i.buffers,s=i.json;n=i.options;const a=i.extensionsUsed,o=i.extensionsRequired,l=new Blob(r,{type:"application/octet-stream"}),c=Object.keys(a),h=Object.keys(o);if(c.length>0&&(s.extensionsUsed=c),h.length>0&&(s.extensionsRequired=h),s.buffers&&s.buffers.length>0&&(s.buffers[0].byteLength=l.size),!0===n.binary){const t=new FileReader;t.readAsArrayBuffer(l),t.onloadend=function(){const n=OA(t.result),i=new DataView(new ArrayBuffer(8));i.setUint32(0,n.byteLength,!0),i.setUint32(4,5130562,!0);const r=OA((a=JSON.stringify(s),(new TextEncoder).encode(a).buffer),32);var a;const o=new DataView(new ArrayBuffer(8));o.setUint32(0,r.byteLength,!0),o.setUint32(4,1313821514,!0);const l=new ArrayBuffer(12),c=new DataView(l);c.setUint32(0,1179937895,!0),c.setUint32(4,2,!0);const h=12+o.byteLength+r.byteLength+i.byteLength+n.byteLength;c.setUint32(8,h,!0);const u=new Blob([l,o,r,i,n],{type:"application/octet-stream"}),d=new FileReader;d.readAsArrayBuffer(u),d.onloadend=function(){e(d.result)}}}else if(s.buffers&&s.buffers.length>0){const t=new FileReader;t.readAsDataURL(l),t.onloadend=function(){const n=t.result;s.buffers[0].uri=n,e(s)}}else e(s)}serializeUserData(t,e){if(0===Object.keys(t.userData).length)return;const n=this.options,i=this.extensionsUsed;try{const r=JSON.parse(JSON.stringify(t.userData));if(n.includeCustomExtensions&&r.gltfExtensions){void 0===e.extensions&&(e.extensions={});for(const t in r.gltfExtensions)e.extensions[t]=r.gltfExtensions[t],i[t]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(e.extras=r)}catch(e){console.warn("THREE.GLTFExporter: userData of '"+t.name+"' won't be serialized because of JSON.stringify error - "+e.message)}}getUID(t,e=!1){if(!1===this.uids.has(t)){const e=new Map;e.set(!0,this.uid++),e.set(!1,this.uid++),this.uids.set(t,e)}return this.uids.get(t).get(e)}isNormalizedNormalAttribute(t){if(this.cache.attributesNormalized.has(t))return!1;const e=new Qi;for(let n=0,i=t.count;n5e-4)return!1;return!0}createNormalizedNormalAttribute(t){const e=this.cache;if(e.attributesNormalized.has(t))return e.attributesNormalized.get(t);const n=t.clone(),i=new Qi;for(let t=0,e=n.count;t4?i=t.array[r*t.itemSize+n]:(0===n?i=t.getX(r):1===n?i=t.getY(r):2===n?i=t.getZ(r):3===n&&(i=t.getW(r)),!0===t.normalized&&(i=li.normalize(i,t.array))),5126===e?c.setFloat32(h,i,!0):5124===e?c.setInt32(h,i,!0):5125===e?c.setUint32(h,i,!0):e===TA?c.setInt16(h,i,!0):e===BA?c.setUint16(h,i,!0):e===bA?c.setInt8(h,i):e===IA&&c.setUint8(h,i),h+=a}h%o!=0&&(h+=o-h%o)}const u={buffer:this.processBuffer(c.buffer),byteOffset:this.byteOffset,byteLength:l};return void 0!==r&&(u.target=r),r===RA&&(u.byteStride=o),this.byteOffset+=l,s.bufferViews.push(u),{id:s.bufferViews.length-1,byteLength:0}}processBufferViewImage(t){const e=this,n=e.json;return n.bufferViews||(n.bufferViews=[]),new Promise((function(i){const r=new FileReader;r.readAsArrayBuffer(t),r.onloadend=function(){const t=OA(r.result),s={buffer:e.processBuffer(t),byteOffset:e.byteOffset,byteLength:t.byteLength};e.byteOffset+=t.byteLength,i(n.bufferViews.push(s)-1)}}))}processAccessor(t,e,n,i){const r=this.json;let s;if(t.array.constructor===Float32Array)s=5126;else if(t.array.constructor===Int32Array)s=5124;else if(t.array.constructor===Uint32Array)s=5125;else if(t.array.constructor===Int16Array)s=TA;else if(t.array.constructor===Uint16Array)s=BA;else if(t.array.constructor===Int8Array)s=bA;else{if(t.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+t.array.constructor.name);s=IA}if(void 0===n&&(n=0),void 0!==i&&i!==1/0||(i=t.count),0===i)return null;const a=function(t,e,n){const i={min:new Array(t.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(t.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let r=e;r4?n=t.array[r*t.itemSize+e]:(0===e?n=t.getX(r):1===e?n=t.getY(r):2===e?n=t.getZ(r):3===e&&(n=t.getW(r)),!0===t.normalized&&(n=li.normalize(n,t.array))),i.min[e]=Math.min(i.min[e],n),i.max[e]=Math.max(i.max[e],n)}return i}(t,n,i);let o;void 0!==e&&(o=t===e.index?34963:RA);const l=this.processBufferView(t,s,n,i,o),c={bufferView:l.id,byteOffset:l.byteOffset,componentType:s,count:i,max:a.max,min:a.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[t.itemSize]};return!0===t.normalized&&(c.normalized=!0),r.accessors||(r.accessors=[]),r.accessors.push(c)-1}processImage(t,e,n,i="image/png"){if(null!==t){const r=this,s=r.cache,a=r.json,o=r.options,l=r.pending;s.images.has(t)||s.images.set(t,{});const c=s.images.get(t),h=i+":flipY/"+n.toString();if(void 0!==c[h])return c[h];a.images||(a.images=[]);const u={mimeType:i},d=kA();d.width=Math.min(t.width,o.maxTextureSize),d.height=Math.min(t.height,o.maxTextureSize);const p=d.getContext("2d",{willReadFrequently:!0});if(!0===n&&(p.translate(0,d.height),p.scale(1,-1)),void 0!==t.data){e!==$t&&console.error("GLTFExporter: Only RGBAFormat is supported.",e),(t.width>o.maxTextureSize||t.height>o.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",t);const n=new Uint8ClampedArray(t.height*t.width*4);for(let e=0;er.processBufferViewImage(t))).then((t=>{u.bufferView=t}))):void 0!==d.toDataURL?u.uri=d.toDataURL(i):l.push(QA(d,i).then((t=>(new FileReader).readAsDataURL(t))).then((t=>{u.uri=t})));const f=a.images.push(u)-1;return c[h]=f,f}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(t){const e=this.json;e.samplers||(e.samplers=[]);const n={magFilter:PA[t.magFilter],minFilter:PA[t.minFilter],wrapS:PA[t.wrapS],wrapT:PA[t.wrapT]};return e.samplers.push(n)-1}async processTextureAsync(t){const e=this.options,n=this.cache,i=this.json;if(n.textures.has(t))return n.textures.get(t);i.textures||(i.textures=[]),t instanceof il&&(t=await this.decompressTextureAsync(t,e.maxTextureSize));let r=t.userData.mimeType;"image/webp"===r&&(r="image/png");const s={sampler:this.processSampler(t),source:this.processImage(t.image,t.format,t.flipY,r)};t.name&&(s.name=t.name),await this._invokeAllAsync((async function(e){e.writeTexture&&await e.writeTexture(t,s)}));const a=i.textures.push(s)-1;return n.textures.set(t,a),a}async processMaterialAsync(t){const e=this.cache,n=this.json;if(e.materials.has(t))return e.materials.get(t);if(t.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);const i={pbrMetallicRoughness:{}};!0!==t.isMeshStandardMaterial&&!0!==t.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const r=t.color.toArray().concat([t.opacity]);if(NA(r,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=r),t.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=t.metalness,i.pbrMetallicRoughness.roughnessFactor=t.roughness):(i.pbrMetallicRoughness.metallicFactor=0,i.pbrMetallicRoughness.roughnessFactor=1),t.metalnessMap||t.roughnessMap){const e=await this.buildMetalRoughTextureAsync(t.metalnessMap,t.roughnessMap),n={index:await this.processTextureAsync(e),texCoord:e.channel};this.applyTextureTransform(n,e),i.pbrMetallicRoughness.metallicRoughnessTexture=n}if(t.map){const e={index:await this.processTextureAsync(t.map),texCoord:t.map.channel};this.applyTextureTransform(e,t.map),i.pbrMetallicRoughness.baseColorTexture=e}if(t.emissive){const e=t.emissive;if(Math.max(e.r,e.g,e.b)>0&&(i.emissiveFactor=t.emissive.toArray()),t.emissiveMap){const e={index:await this.processTextureAsync(t.emissiveMap),texCoord:t.emissiveMap.channel};this.applyTextureTransform(e,t.emissiveMap),i.emissiveTexture=e}}if(t.normalMap){const e={index:await this.processTextureAsync(t.normalMap),texCoord:t.normalMap.channel};t.normalScale&&1!==t.normalScale.x&&(e.scale=t.normalScale.x),this.applyTextureTransform(e,t.normalMap),i.normalTexture=e}if(t.aoMap){const e={index:await this.processTextureAsync(t.aoMap),texCoord:t.aoMap.channel};1!==t.aoMapIntensity&&(e.strength=t.aoMapIntensity),this.applyTextureTransform(e,t.aoMap),i.occlusionTexture=e}t.transparent?i.alphaMode="BLEND":t.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=t.alphaTest),t.side===S&&(i.doubleSided=!0),""!==t.name&&(i.name=t.name),this.serializeUserData(t,i),await this._invokeAllAsync((async function(e){e.writeMaterialAsync&&await e.writeMaterialAsync(t,i)}));const s=n.materials.push(i)-1;return e.materials.set(t,s),s}async processMeshAsync(t){const e=this.cache,n=this.json,i=[t.geometry.uuid];if(Array.isArray(t.material))for(let e=0,n=t.material.length;e0){const n=[],i=[],r={};if(void 0!==t.morphTargetDictionary)for(const e in t.morphTargetDictionary)r[t.morphTargetDictionary[e]]=e;for(let a=0;a0&&(o.extras={},o.extras.targetNames=i)}const f=Array.isArray(t.material);if(f&&0===s.groups.length)return null;let m=!1;if(f&&null===s.index){const t=[];for(let e=0,n=s.attributes.position.count;e0&&(n.targets=h),null!==s.index){let i=this.getUID(s.index);void 0===A[t].start&&void 0===A[t].count||(i+=":"+A[t].start+":"+A[t].count),e.attributes.has(i)?n.indices=e.attributes.get(i):(n.indices=this.processAccessor(s.index,s,A[t].start,A[t].count),e.attributes.set(i,n.indices)),null===n.indices&&delete n.indices}const i=await this.processMaterialAsync(g[A[t].materialIndex]);null!==i&&(n.material=i),c.push(n)}!0===m&&s.setIndex(null),o.primitives=c,n.meshes||(n.meshes=[]),await this._invokeAllAsync((function(e){e.writeMesh&&e.writeMesh(t,o)}));const v=n.meshes.push(o)-1;return e.meshes.set(r,v),v}detectMeshQuantization(t,e){if(this.extensionsUsed[DA])return;let n;switch(e.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}e.normalized&&(n+=" normalized");const i=t.split("_",1)[0];MA[i]&&MA[i].includes(n)&&(this.extensionsUsed[DA]=!0,this.extensionsRequired[DA]=!0)}processCamera(t){const e=this.json;e.cameras||(e.cameras=[]);const n=t.isOrthographicCamera,i={type:n?"orthographic":"perspective"};return n?i.orthographic={xmag:2*t.right,ymag:2*t.top,zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near}:i.perspective={aspectRatio:t.aspect,yfov:li.degToRad(t.fov),zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near},""!==t.name&&(i.name=t.type),e.cameras.push(i)-1}processAnimation(t,e){const n=this.json,i=this.nodeMap;n.animations||(n.animations=[]);const r=(t=SA.Utils.mergeMorphTargetTracks(t.clone(),e)).tracks,s=[],a=[];for(let t=0;t0){const e=[];for(let i=0,r=t.children.length;i0&&(r.children=e)}await this._invokeAllAsync((function(e){e.writeNode&&e.writeNode(t,r)}));const s=e.nodes.push(r)-1;return i.set(t,s),s}async processSceneAsync(t){const e=this.json,n=this.options;e.scenes||(e.scenes=[],e.scene=0);const i={};""!==t.name&&(i.name=t.name),e.scenes.push(i);const r=[];for(let e=0,i=t.children.length;e0&&(i.nodes=r),this.serializeUserData(t,i)}async processObjectsAsync(t){const e=new fa;e.name="AuxScene";for(let n=0;n0&&await this.processObjectsAsync(n);for(let t=0;t0&&(s.range=t.distance)):t.isSpotLight&&(s.type="spot",t.distance>0&&(s.range=t.distance),s.spot={},s.spot.innerConeAngle=(1-t.penumbra)*t.angle,s.spot.outerConeAngle=t.angle),void 0!==t.decay&&2!==t.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),!t.target||t.target.parent===t&&0===t.target.position.x&&0===t.target.position.y&&-1===t.target.position.z||console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),r[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},r[this.name]=!0);const a=i.extensions[this.name].lights;a.push(s),e.extensions=e.extensions||{},e.extensions[this.name]={light:a.length-1}}}class HA{constructor(t){this.writer=t,this.name="KHR_materials_unlit"}async writeMaterialAsync(t,e){if(!t.isMeshBasicMaterial)return;const n=this.writer.extensionsUsed;e.extensions=e.extensions||{},e.extensions[this.name]={},n[this.name]=!0,e.pbrMetallicRoughness.metallicFactor=0,e.pbrMetallicRoughness.roughnessFactor=.9}}class VA{constructor(t){this.writer=t,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.clearcoat)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.clearcoatFactor=t.clearcoat,t.clearcoatMap){const e={index:await n.processTextureAsync(t.clearcoatMap),texCoord:t.clearcoatMap.channel};n.applyTextureTransform(e,t.clearcoatMap),r.clearcoatTexture=e}if(r.clearcoatRoughnessFactor=t.clearcoatRoughness,t.clearcoatRoughnessMap){const e={index:await n.processTextureAsync(t.clearcoatRoughnessMap),texCoord:t.clearcoatRoughnessMap.channel};n.applyTextureTransform(e,t.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=e}if(t.clearcoatNormalMap){const e={index:await n.processTextureAsync(t.clearcoatNormalMap),texCoord:t.clearcoatNormalMap.channel};1!==t.clearcoatNormalScale.x&&(e.scale=t.clearcoatNormalScale.x),n.applyTextureTransform(e,t.clearcoatNormalMap),r.clearcoatNormalTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class WA{constructor(t){this.writer=t,this.name="KHR_materials_dispersion"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.dispersion)return;const n=this.writer.extensionsUsed,i={};i.dispersion=t.dispersion,e.extensions=e.extensions||{},e.extensions[this.name]=i,n[this.name]=!0}}class jA{constructor(t){this.writer=t,this.name="KHR_materials_iridescence"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.iridescence)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.iridescenceFactor=t.iridescence,t.iridescenceMap){const e={index:await n.processTextureAsync(t.iridescenceMap),texCoord:t.iridescenceMap.channel};n.applyTextureTransform(e,t.iridescenceMap),r.iridescenceTexture=e}if(r.iridescenceIor=t.iridescenceIOR,r.iridescenceThicknessMinimum=t.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=t.iridescenceThicknessRange[1],t.iridescenceThicknessMap){const e={index:await n.processTextureAsync(t.iridescenceThicknessMap),texCoord:t.iridescenceThicknessMap.channel};n.applyTextureTransform(e,t.iridescenceThicknessMap),r.iridescenceThicknessTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class qA{constructor(t){this.writer=t,this.name="KHR_materials_transmission"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.transmission)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.transmissionFactor=t.transmission,t.transmissionMap){const e={index:await n.processTextureAsync(t.transmissionMap),texCoord:t.transmissionMap.channel};n.applyTextureTransform(e,t.transmissionMap),r.transmissionTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class XA{constructor(t){this.writer=t,this.name="KHR_materials_volume"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.transmission)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.thicknessFactor=t.thickness,t.thicknessMap){const e={index:await n.processTextureAsync(t.thicknessMap),texCoord:t.thicknessMap.channel};n.applyTextureTransform(e,t.thicknessMap),r.thicknessTexture=e}t.attenuationDistance!==1/0&&(r.attenuationDistance=t.attenuationDistance),r.attenuationColor=t.attenuationColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class YA{constructor(t){this.writer=t,this.name="KHR_materials_ior"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||1.5===t.ior)return;const n=this.writer.extensionsUsed,i={};i.ior=t.ior,e.extensions=e.extensions||{},e.extensions[this.name]=i,n[this.name]=!0}}class JA{constructor(t){this.writer=t,this.name="KHR_materials_specular"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||1===t.specularIntensity&&t.specularColor.equals(UA)&&!t.specularIntensityMap&&!t.specularColorMap)return;const n=this.writer,i=n.extensionsUsed,r={};if(t.specularIntensityMap){const e={index:await n.processTextureAsync(t.specularIntensityMap),texCoord:t.specularIntensityMap.channel};n.applyTextureTransform(e,t.specularIntensityMap),r.specularTexture=e}if(t.specularColorMap){const e={index:await n.processTextureAsync(t.specularColorMap),texCoord:t.specularColorMap.channel};n.applyTextureTransform(e,t.specularColorMap),r.specularColorTexture=e}r.specularFactor=t.specularIntensity,r.specularColorFactor=t.specularColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class KA{constructor(t){this.writer=t,this.name="KHR_materials_sheen"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0==t.sheen)return;const n=this.writer,i=n.extensionsUsed,r={};if(t.sheenRoughnessMap){const e={index:await n.processTextureAsync(t.sheenRoughnessMap),texCoord:t.sheenRoughnessMap.channel};n.applyTextureTransform(e,t.sheenRoughnessMap),r.sheenRoughnessTexture=e}if(t.sheenColorMap){const e={index:await n.processTextureAsync(t.sheenColorMap),texCoord:t.sheenColorMap.channel};n.applyTextureTransform(e,t.sheenColorMap),r.sheenColorTexture=e}r.sheenRoughnessFactor=t.sheenRoughness,r.sheenColorFactor=t.sheenColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class ZA{constructor(t){this.writer=t,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0==t.anisotropy)return;const n=this.writer,i=n.extensionsUsed,r={};if(t.anisotropyMap){const e={index:await n.processTextureAsync(t.anisotropyMap)};n.applyTextureTransform(e,t.anisotropyMap),r.anisotropyTexture=e}r.anisotropyStrength=t.anisotropy,r.anisotropyRotation=t.anisotropyRotation,e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class $A{constructor(t){this.writer=t,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(t,e){if(!t.isMeshStandardMaterial||1===t.emissiveIntensity)return;const n=this.writer.extensionsUsed,i={};i.emissiveStrength=t.emissiveIntensity,e.extensions=e.extensions||{},e.extensions[this.name]=i,n[this.name]=!0}}class tv{constructor(t){this.writer=t,this.name="EXT_materials_bump"}async writeMaterialAsync(t,e){if(!t.isMeshStandardMaterial||1===t.bumpScale&&!t.bumpMap)return;const n=this.writer,i=n.extensionsUsed,r={};if(t.bumpMap){const e={index:await n.processTextureAsync(t.bumpMap),texCoord:t.bumpMap.channel};n.applyTextureTransform(e,t.bumpMap),r.bumpTexture=e}r.bumpFactor=t.bumpScale,e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class ev{constructor(t){this.writer=t,this.name="EXT_mesh_gpu_instancing"}writeNode(t,e){if(!t.isInstancedMesh)return;const n=this.writer,i=t,r=new Float32Array(3*i.count),s=new Float32Array(4*i.count),a=new Float32Array(3*i.count),o=new gr,l=new Qi,c=new ki,h=new Qi;for(let t=0;tt.times[t.times.length-1]){if(Math.abs(t.times[t.times.length-1]-e)e){r.set(t.times.slice(0,l+1),0),r[l+1]=e,r.set(t.times.slice(l+1),l+2),s.set(t.values.slice(0,(l+1)*i),0),s.set(a.evaluate(e),(l+1)*i),s.set(t.values.slice((l+1)*i),(l+2)*i),o=l+1;break}}return t.times=r,t.values=s,o},mergeMorphTargetTracks:function(t,e){const n=[],i={},r=t.tracks;for(let t=0;t{const e=t.draco,a=new e.Decoder;try{const t=function(t,e,i,r){const s=r.attributeIDs,a=r.attributeTypes;let o,l;const c=e.GetEncodedGeometryType(i);if(c===t.TRIANGULAR_MESH)o=new t.Mesh,l=e.DecodeArrayToMesh(i,i.byteLength,o);else{if(c!==t.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new t.PointCloud,l=e.DecodeArrayToPointCloud(i,i.byteLength,o)}if(!l.ok()||0===o.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const h={index:null,attributes:[]};for(const i in s){const l=self[a[i]];let c,u;if(r.useUniqueIDs)u=s[i],c=e.GetAttributeByUniqueId(o,u);else{if(u=e.GetAttributeId(o,t[s[i]]),-1===u)continue;c=e.GetAttribute(o,u)}const d=n(t,e,o,i,l,c);"color"===i&&(d.vertexColorSpace=r.vertexColorSpace),h.attributes.push(d)}return c===t.TRIANGULAR_MESH&&(h.index=function(t,e,n){const i=3*n.num_faces(),r=4*i,s=t._malloc(r);e.GetTrianglesUInt32Array(n,r,s);const a=new Uint32Array(t.HEAPF32.buffer,s,i).slice();return t._free(s),{array:a,itemSize:1}}(t,e,o)),t.destroy(o),h}(e,a,new Int8Array(i),s),o=t.attributes.map((t=>t.array.buffer));t.index&&o.push(t.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:t},o)}catch(t){console.error(t),self.postMessage({type:"error",id:r.id,error:t.message})}finally{e.destroy(a)}}))}}}var rv=Uint8Array,sv=Uint16Array,av=Int32Array,ov=new rv([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),lv=new rv([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),cv=new rv([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),hv=function(t,e){for(var n=new sv(31),i=0;i<31;++i)n[i]=e+=1<>1|(21845&vv)<<1;yv=(61680&(yv=(52428&yv)>>2|(13107&yv)<<2))>>4|(3855&yv)<<4,Av[vv]=((65280&yv)>>8|(255&yv)<<8)>>1}var _v=function(t,e,n){for(var i=t.length,r=0,s=new sv(e);r>l]=c}else for(a=new sv(i),r=0;r>15-t[r]);return a},xv=new rv(288);for(vv=0;vv<144;++vv)xv[vv]=8;for(vv=144;vv<256;++vv)xv[vv]=9;for(vv=256;vv<280;++vv)xv[vv]=7;for(vv=280;vv<288;++vv)xv[vv]=8;var wv=new rv(32);for(vv=0;vv<32;++vv)wv[vv]=5;var Cv=_v(xv,9,0),Ev=_v(xv,9,1),Mv=_v(wv,5,0),Sv=_v(wv,5,1),bv=function(t){for(var e=t[0],n=1;ne&&(e=t[n]);return e},Iv=function(t,e,n){var i=e/8|0;return(t[i]|t[i+1]<<8)>>(7&e)&n},Tv=function(t,e){var n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(7&e)},Bv=function(t){return(t+7)/8|0},Rv=function(t,e,n){return(null==e||e<0)&&(e=0),(null==n||n>t.length)&&(n=t.length),new rv(t.subarray(e,n))},Dv=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Pv=function(t,e,n){var i=new Error(e||Dv[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,Pv),!n)throw i;return i},Lv=function(t,e,n){n<<=7&e;var i=e/8|0;t[i]|=n,t[i+1]|=n>>8},Uv=function(t,e,n){n<<=7&e;var i=e/8|0;t[i]|=n,t[i+1]|=n>>8,t[i+2]|=n>>16},Nv=function(t,e){for(var n=[],i=0;id&&(d=s[i].s);var p=new sv(d+1),f=Fv(n[h-1],p,0);if(f>e){i=0;var m=0,g=f-e,A=1<e))break;m+=A-(1<>=g;m>0;){var y=s[i].s;p[y]=0&&m;--i){var _=s[i].s;p[_]==e&&(--p[_],++m)}f=e}return{t:new rv(p),l:f}},Fv=function(t,e,n){return-1==t.s?Math.max(Fv(t.l,e,n+1),Fv(t.r,e,n+1)):e[t.s]=n},Ov=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new sv(++e),i=0,r=t[0],s=1,a=function(t){n[i++]=t},o=1;o<=e;++o)if(t[o]==r&&o!=e)++s;else{if(!r&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(r),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(r);s=1,r=t[o]}return{c:n.subarray(0,i),n:e}},kv=function(t,e){for(var n=0,i=0;i>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var s=0;s4&&!S[cv[I-1]];--I);var T,B,R,D,P=c+5<<3,L=kv(r,xv)+kv(s,wv)+a,U=kv(r,d)+kv(s,m)+a+14+3*I+kv(C,S)+2*C[16]+3*C[17]+7*C[18];if(l>=0&&P<=L&&P<=U)return Qv(e,h,t.subarray(l,l+c));if(Lv(e,h,1+(U15&&(Lv(e,h,k[E]>>5&127),h+=k[E]>>12)}}}else T=Cv,B=xv,R=Mv,D=wv;for(E=0;E255){Uv(e,h,T[257+(Q=z>>18&31)]),h+=B[Q+257],Q>7&&(Lv(e,h,z>>23&31),h+=ov[Q]);var G=31&z;Uv(e,h,R[G]),h+=D[G],G>3&&(Uv(e,h,z>>5&8191),h+=lv[G])}else Uv(e,h,T[z]),h+=B[z]}return Uv(e,h,T[256]),h+B[256]},Gv=new av([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Hv=new rv(0),Vv=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var n=e,i=9;--i;)n=(1&n&&-306674912)^n>>>1;t[e]=n}return t}(),Wv=function(){var t=-1;return{p:function(e){for(var n=t,i=0;i>>8;t=n},d:function(){return~t}}},jv=function(t,e,n,i,r){if(!r&&(r={l:1},e.dictionary)){var s=e.dictionary.subarray(-32768),a=new rv(s.length+t.length);a.set(s),a.set(t,s.length),t=a,r.w=s.length}return function(t,e,n,i,r,s){var a=s.z||t.length,o=new rv(i+a+5*(1+Math.ceil(a/7e3))+r),l=o.subarray(i,o.length-r),c=s.l,h=7&(s.r||0);if(e){h&&(l[0]=s.r>>3);for(var u=Gv[e-1],d=u>>13,p=8191&u,f=(1<7e3||S>24576)&&(D>423||!c)){h=zv(t,l,0,_,x,w,E,S,I,M-I,h),S=C=E=0,I=M;for(var P=0;P<286;++P)x[P]=0;for(P=0;P<30;++P)w[P]=0}var L=2,U=0,N=p,F=B-R&32767;if(D>2&&T==y(M-F))for(var O=Math.min(d,D)-1,k=Math.min(32767,M),Q=Math.min(258,D);F<=k&&--N&&B!=R;){if(t[M+L]==t[M+L-F]){for(var z=0;zL){if(L=z,U=F,z>O)break;var G=Math.min(F,z-2),H=0;for(P=0;PH&&(H=W,R=V)}}}F+=(B=R)-(R=m[B])&32767}if(U){_[S++]=268435456|pv[L]<<18|gv[U];var j=31&pv[L],q=31&gv[U];E+=ov[j]+lv[q],++x[257+j],++w[q],b=M+L,++C}else _[S++]=t[M],++x[t[M]]}}for(M=Math.max(M,b);M=a&&(l[h/8|0]=c,X=a),h=Qv(l,h+1,t.subarray(M,X))}s.i=a}return Rv(o,0,i+Bv(h)+r)}(t,null==e.level?6:e.level,null==e.mem?r.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+e.mem,n,i,r)},qv=function(t,e){var n={};for(var i in t)n[i]=t[i];for(var i in e)n[i]=e[i];return n},Xv=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8};function Yv(t,e){return jv(t,e||{},0,0)}function Jv(t,e){return function(t,e,n,i){var r=t.length,s=i?i.length:0;if(!r||e.f&&!e.l)return n||new rv(0);var a=!n,o=a||2!=e.i,l=e.i;a&&(n=new rv(3*r));var c=function(t){var e=n.length;if(t>e){var i=new rv(Math.max(2*e,t));i.set(n),n=i}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,m=e.m,g=e.n,A=8*r;do{if(!p){h=Iv(t,u,1);var v=Iv(t,u+1,3);if(u+=3,!v){var y=t[(B=Bv(u)+4)-4]|t[B-3]<<8,_=B+y;if(_>r){l&&Pv(0);break}o&&c(d+y),n.set(t.subarray(B,_),d),e.b=d+=y,e.p=u=8*_,e.f=h;continue}if(1==v)p=Ev,f=Sv,m=9,g=5;else if(2==v){var x=Iv(t,u,31)+257,w=Iv(t,u+10,15)+4,C=x+Iv(t,u+5,31)+1;u+=14;for(var E=new rv(C),M=new rv(19),S=0;S>4)<16)E[S++]=B;else{var D=0,P=0;for(16==B?(P=3+Iv(t,u,3),u+=2,D=E[S-1]):17==B?(P=3+Iv(t,u,7),u+=3):18==B&&(P=11+Iv(t,u,127),u+=7);P--;)E[S++]=D}}var L=E.subarray(0,x),U=E.subarray(x);m=bv(L),g=bv(U),p=_v(L,m,1),f=_v(U,g,1)}else Pv(1);if(u>A){l&&Pv(0);break}}o&&c(d+131072);for(var N=(1<>4;if((u+=15&D)>A){l&&Pv(0);break}if(D||Pv(2),k<256)n[d++]=k;else{if(256==k){O=u,p=null;break}var Q=k-254;if(k>264){var z=ov[S=k-257];Q=Iv(t,u,(1<>4;if(G||Pv(3),u+=15&G,U=mv[H],H>3&&(z=lv[H],U+=Tv(t,u)&(1<A){l&&Pv(0);break}o&&c(d+131072);var V=d+Q;if(d>4>7||(n[0]<<8|n[1])%31)&&Pv(6,"invalid zlib data"),(n[1]>>5&1)==+!i&&Pv(6,"invalid zlib data: "+(32&n[1]?"need":"unexpected")+" dictionary"),2+(n[1]>>3&4)),-4),{i:2},e&&e.out,e&&e.dictionary);var n,i}var Kv=function(t,e,n,i){for(var r in t){var s=t[r],a=e+r,o=i;Array.isArray(s)&&(o=qv(i,s[1]),s=s[0]),s instanceof rv?n[a]=[s,o]:(n[a+="/"]=[new rv(0),o],Kv(s,a,n,i))}},Zv="undefined"!=typeof TextEncoder&&new TextEncoder,$v="undefined"!=typeof TextDecoder&&new TextDecoder;try{$v.decode(Hv,{stream:!0})}catch(t){}function ty(t,e){if(e){for(var n=new rv(t.length),i=0;i>1)),a=0,o=function(t){s[a++]=t};for(i=0;is.length){var l=new rv(a+8+(r-i<<1));l.set(s),s=l}var c=t.charCodeAt(i);c<128||e?o(c):c<2048?(o(192|c>>6),o(128|63&c)):c>55295&&c<57344?(o(240|(c=65536+(1047552&c)|1023&t.charCodeAt(++i))>>18),o(128|c>>12&63),o(128|c>>6&63),o(128|63&c)):(o(224|c>>12),o(128|c>>6&63),o(128|63&c))}return Rv(s,0,a)}var ey=function(t){var e=0;if(t)for(var n in t){var i=t[n].length;i>65535&&Pv(9),e+=i+4}return e},ny=function(t,e,n,i,r,s,a,o){var l=i.length,c=n.extra,h=o&&o.length,u=ey(c);Xv(t,e,null!=a?33639248:67324752),e+=4,null!=a&&(t[e++]=20,t[e++]=n.os),t[e]=20,e+=2,t[e++]=n.flag<<1|(s<0&&8),t[e++]=r&&8,t[e++]=255&n.compression,t[e++]=n.compression>>8;var d=new Date(null==n.mtime?Date.now():n.mtime),p=d.getFullYear()-1980;if((p<0||p>119)&&Pv(10),Xv(t,e,p<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>1),e+=4,-1!=s&&(Xv(t,e,n.crc),Xv(t,e+4,s<0?-s-2:s),Xv(t,e+8,n.size)),Xv(t,e+12,l),Xv(t,e+14,u),e+=16,null!=a&&(Xv(t,e,h),Xv(t,e+6,n.attrs),Xv(t,e+10,a),e+=14),t.set(i,e),e+=l,u)for(var f in c){var m=c[f],g=m.length;Xv(t,e,+f),Xv(t,e+2,g),t.set(m,e+4),e+=4+g}return h&&(t.set(o,e),e+=h),e};function iy(t,e,n){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const i=n/Math.max(t.width,t.height),r=document.createElement("canvas");r.width=t.width*Math.min(1,i),r.height=t.height*Math.min(1,i);const s=r.getContext("2d");return!0===e&&(s.translate(0,r.height),s.scale(1,-1)),s.drawImage(t,0,0,r.width,r.height),r}throw new Error("THREE.USDZExporter: No valid image data found. Unable to process texture.")}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout;function ry(t){const e=t.elements;return`( ${sy(e,0)}, ${sy(e,4)}, ${sy(e,8)}, ${sy(e,12)} )`}function sy(t,e){return`(${t[e+0]}, ${t[e+1]}, ${t[e+2]}, ${t[e+3]})`}function ay(t,e){if(void 0===t)return console.warn("USDZExporter: Normals missing."),Array(e).fill("(0, 0, 0)").join(", ");const n=[];for(let e=0;e0?"st"+i.channel:"st",l={1e3:"repeat",1001:"clamp",1002:"mirror"},c=i.repeat.clone(),h=i.offset.clone(),u=i.rotation,d=Math.sin(u),p=Math.cos(u);return h.y=1-h.y-c.y,n?(h.x=h.x/c.x,h.y=h.y/c.y,h.x+=d/c.x,h.y+=p-1):(h.x+=d*c.x,h.y+=(1-p)*c.y),`\n\t\tdef Shader "PrimvarReader_${r}"\n\t\t{\n\t\t\tuniform token info:id = "UsdPrimvarReader_float2"\n\t\t\tfloat2 inputs:fallback = (0.0, 0.0)\n\t\t\ttoken inputs:varname = "${o}"\n\t\t\tfloat2 outputs:result\n\t\t}\n\n\t\tdef Shader "Transform2d_${r}"\n\t\t{\n\t\t\tuniform token info:id = "UsdTransform2d"\n\t\t\ttoken inputs:in.connect = \n\t\t\tfloat inputs:rotation = ${(u*(180/Math.PI)).toFixed(7)}\n\t\t\tfloat2 inputs:scale = ${hy(c)}\n\t\t\tfloat2 inputs:translation = ${hy(h)}\n\t\t\tfloat2 outputs:result\n\t\t}\n\n\t\tdef Shader "Texture_${i.id}_${r}"\n\t\t{\n\t\t\tuniform token info:id = "UsdUVTexture"\n\t\t\tasset inputs:file = @textures/Texture_${a}.png@\n\t\t\tfloat2 inputs:st.connect = \n\t\t\t${void 0!==s?"float4 inputs:scale = "+function(t){return`(${t.r}, ${t.g}, ${t.b}, 1.0)`}(s):""}\n\t\t\ttoken inputs:sourceColorSpace = "${i.colorSpace===cn?"raw":"sRGB"}"\n\t\t\ttoken inputs:wrapS = "${l[i.wrapS]}"\n\t\t\ttoken inputs:wrapT = "${l[i.wrapT]}"\n\t\t\tfloat outputs:r\n\t\t\tfloat outputs:g\n\t\t\tfloat outputs:b\n\t\t\tfloat3 outputs:rgb\n\t\t\t${t.transparent||t.alphaTest>0?"float outputs:a":""}\n\t\t}`}return t.side===S&&console.warn("THREE.USDZExporter: USDZ does not support double sided materials",t),null!==t.map?(r.push(`${i}color3f inputs:diffuseColor.connect = `),t.transparent?r.push(`${i}float inputs:opacity.connect = `):t.alphaTest>0&&(r.push(`${i}float inputs:opacity.connect = `),r.push(`${i}float inputs:opacityThreshold = ${t.alphaTest}`)),s.push(a(t.map,"diffuse",t.color))):r.push(`${i}color3f inputs:diffuseColor = ${cy(t.color)}`),null!==t.emissiveMap?(r.push(`${i}color3f inputs:emissiveColor.connect = `),s.push(a(t.emissiveMap,"emissive",new ls(t.emissive.r*t.emissiveIntensity,t.emissive.g*t.emissiveIntensity,t.emissive.b*t.emissiveIntensity)))):t.emissive.getHex()>0&&r.push(`${i}color3f inputs:emissiveColor = ${cy(t.emissive)}`),null!==t.normalMap&&(r.push(`${i}normal3f inputs:normal.connect = `),s.push(a(t.normalMap,"normal"))),null!==t.aoMap&&(r.push(`${i}float inputs:occlusion.connect = `),s.push(a(t.aoMap,"occlusion",new ls(t.aoMapIntensity,t.aoMapIntensity,t.aoMapIntensity)))),null!==t.roughnessMap?(r.push(`${i}float inputs:roughness.connect = `),s.push(a(t.roughnessMap,"roughness",new ls(t.roughness,t.roughness,t.roughness)))):r.push(`${i}float inputs:roughness = ${t.roughness}`),null!==t.metalnessMap?(r.push(`${i}float inputs:metallic.connect = `),s.push(a(t.metalnessMap,"metallic",new ls(t.metalness,t.metalness,t.metalness)))):r.push(`${i}float inputs:metallic = ${t.metalness}`),null!==t.alphaMap?(r.push(`${i}float inputs:opacity.connect = `),r.push(`${i}float inputs:opacityThreshold = 0.0001`),s.push(a(t.alphaMap,"opacity"))):r.push(`${i}float inputs:opacity = ${t.opacity}`),t.isMeshPhysicalMaterial&&(null!==t.clearcoatMap?(r.push(`${i}float inputs:clearcoat.connect = `),s.push(a(t.clearcoatMap,"clearcoat",new ls(t.clearcoat,t.clearcoat,t.clearcoat)))):r.push(`${i}float inputs:clearcoat = ${t.clearcoat}`),null!==t.clearcoatRoughnessMap?(r.push(`${i}float inputs:clearcoatRoughness.connect = `),s.push(a(t.clearcoatRoughnessMap,"clearcoatRoughness",new ls(t.clearcoatRoughness,t.clearcoatRoughness,t.clearcoatRoughness)))):r.push(`${i}float inputs:clearcoatRoughness = ${t.clearcoatRoughness}`),r.push(`${i}float inputs:ior = ${t.ior}`)),`\n\tdef Material "Material_${t.id}"\n\t{\n\t\tdef Shader "PreviewSurface"\n\t\t{\n\t\t\tuniform token info:id = "UsdPreviewSurface"\n${r.join("\n")}\n\t\t\tint inputs:useSpecularWorkflow = 0\n\t\t\ttoken outputs:surface\n\t\t}\n\n\t\ttoken outputs:surface.connect = \n\n${s.join("\n")}\n\n\t}\n`}function cy(t){return`(${t.r}, ${t.g}, ${t.b})`}function hy(t){return`(${t.x}, ${t.y})`}const uy=new Qi,dy=new ki,py=new Qi;const fy=new gr,my=new gr,gy=new Qi,Ay=new Yu,vy=new ho,yy=new Qi,_y=new is;class xy{constructor(){this.tolerance=-1,this.faces=[],this.newFaces=[],this.assigned=new My,this.unassigned=new My,this.vertices=[]}setFromPoints(t){if(t.length>=4){this.makeEmpty();for(let e=0,n=t.length;ethis.tolerance)return!1;return!0}intersectRay(t,e){const n=this.faces;let i=-1/0,r=1/0;for(let e=0,s=n.length;e0&&o>=0)return null;const l=0!==o?-a/o:0;if(!(l<=0)&&(o>0?r=Math.min(l,r):i=Math.max(l,i),i>r))return null}return i!==-1/0?t.at(i,e):t.at(r,e),e}intersectsRay(t){return null!==this.intersectRay(t,gy)}makeEmpty(){return this.faces=[],this.vertices=[],this}addVertexToFace(t,e){return t.face=e,null===e.outside?this.assigned.append(t):this.assigned.insertBefore(e.outside,t),e.outside=t,this}removeVertexFromFace(t,e){return t===e.outside&&(null!==t.next&&t.next.face===e?e.outside=t.next:e.outside=null),this.assigned.remove(t),this}removeAllVerticesFromFace(t){if(null!==t.outside){const e=t.outside;let n=t.outside;for(;null!==n.next&&n.next.face===t;)n=n.next;return this.assigned.removeSubList(e,n),e.prev=n.next=null,t.outside=null,e}}deleteFaceVertices(t,e){const n=this.removeAllVerticesFromFace(t);if(void 0!==n)if(void 0===e)this.unassigned.appendChain(n);else{let t=n;do{const n=t.next;e.distanceToPoint(t.point)>this.tolerance?this.addVertexToFace(t,e):this.unassigned.append(t),t=n}while(null!==t)}return this}resolveUnassignedPoints(t){if(!1===this.unassigned.isEmpty()){let e=this.unassigned.first();do{const n=e.next;let i=this.tolerance,r=null;for(let n=0;ni&&(i=t,r=s),i>1e3*this.tolerance)break}}null!==r&&this.addVertexToFace(e,r),e=n}while(null!==e)}return this}computeExtremes(){const t=new Qi,e=new Qi,n=[],i=[];for(let t=0;t<3;t++)n[t]=i[t]=this.vertices[0];t.copy(this.vertices[0].point),e.copy(this.vertices[0].point);for(let r=0,s=this.vertices.length;re.getComponent(t)&&(e.setComponent(t,a.getComponent(t)),i[t]=s)}return this.tolerance=3*Number.EPSILON*(Math.max(Math.abs(t.x),Math.abs(e.x))+Math.max(Math.abs(t.y),Math.abs(e.y))+Math.max(Math.abs(t.z),Math.abs(e.z))),{min:n,max:i}}computeInitialHull(){const t=this.vertices,e=this.computeExtremes(),n=e.min,i=e.max;let r=0,s=0;for(let t=0;t<3;t++){const e=i[t].point.getComponent(t)-n[t].point.getComponent(t);e>r&&(r=e,s=t)}const a=n[s],o=i[s];let l,c;r=0,Ay.set(a.point,o.point);for(let e=0,n=this.vertices.length;er&&(r=t,l=n)}}r=-1,vy.setFromCoplanarPoints(a.point,o.point,l.point);for(let e=0,n=this.vertices.length;er&&(r=t,c=n)}}const h=[];if(vy.distanceToPoint(c.point)<0){h.push(wy.create(a,o,l),wy.create(c,o,a),wy.create(c,l,o),wy.create(c,a,l));for(let t=0;t<3;t++){const e=(t+1)%3;h[t+1].getEdge(2).setTwin(h[0].getEdge(e)),h[t+1].getEdge(1).setTwin(h[e+1].getEdge(0))}}else{h.push(wy.create(a,l,o),wy.create(c,a,o),wy.create(c,o,l),wy.create(c,l,a));for(let t=0;t<3;t++){const e=(t+1)%3;h[t+1].getEdge(2).setTwin(h[0].getEdge((3-t)%3)),h[t+1].getEdge(0).setTwin(h[e+1].getEdge(1))}}for(let t=0;t<4;t++)this.faces.push(h[t]);for(let e=0,n=t.length;er&&(r=i,t=this.faces[e])}null!==t&&this.addVertexToFace(n,t)}}return this}reindexFaces(){const t=[];for(let e=0;ee&&(e=r,t=i),i=i.next}while(null!==i&&i.face===n);return t}}computeHorizon(t,e,n,i){let r;this.deleteFaceVertices(n),n.mark=1,r=null===e?e=n.getEdge(0):e.next;do{const e=r.twin,n=e.face;0===n.mark&&(n.distanceToPoint(t)>this.tolerance?this.computeHorizon(t,e,n,i):i.push(r)),r=r.next}while(r!==e);return this}addAdjoiningFace(t,e){const n=wy.create(t,e.tail(),e.head());return this.faces.push(n),n.getEdge(-1).setTwin(e.twin),n.getEdge(0)}addNewFaces(t,e){this.newFaces=[];let n=null,i=null;for(let r=0;r0;)e=e.next,t--;for(;t<0;)e=e.prev,t++;return e}compute(){const t=this.edge.tail(),e=this.edge.head(),n=this.edge.next.head();return _y.set(t.point,e.point,n.point),_y.getNormal(this.normal),_y.getMidpoint(this.midpoint),this.area=_y.getArea(),this.constant=this.normal.dot(this.midpoint),this}distanceToPoint(t){return this.normal.dot(t)-this.constant}}class Cy{constructor(t,e){this.vertex=t,this.prev=null,this.next=null,this.twin=null,this.face=e}head(){return this.vertex}tail(){return this.prev?this.prev.vertex:null}length(){const t=this.head(),e=this.tail();return null!==e?e.point.distanceTo(t.point):-1}lengthSquared(){const t=this.head(),e=this.tail();return null!==e?e.point.distanceToSquared(t.point):-1}setTwin(t){return this.twin=t,t.twin=this,this}}class Ey{constructor(t){this.point=t,this.prev=null,this.next=null,this.face=null}}class My{constructor(){this.head=null,this.tail=null}first(){return this.head}last(){return this.tail}clear(){return this.head=this.tail=null,this}insertBefore(t,e){return e.prev=t.prev,e.next=t,null===e.prev?this.head=e:e.prev.next=e,t.prev=e,this}insertAfter(t,e){return e.prev=t,e.next=t.next,null===e.next?this.tail=e:e.next.prev=e,t.next=e,this}append(t){return null===this.head?this.head=t:this.tail.next=t,t.prev=this.tail,t.next=null,this.tail=t,this}appendChain(t){for(null===this.head?this.head=t:this.tail.next=t,t.prev=this.tail;null!==t.next;)t=t.next;return this.tail=t,this}remove(t){return null===t.prev?this.head=t.next:t.prev.next=t.next,null===t.next?this.tail=t.prev:t.next.prev=t.prev,this}removeSubList(t,e){return null===t.prev?this.head=e.next:t.prev.next=e.next,null===e.next?this.tail=t.prev:e.next.prev=t.prev,this}isEmpty(){return null===this.head}}function Sy(t,e){switch(e){case hn:t.convertSRGBToLinear();break;case un:case cn:break;default:console.warn("WARNING: LightProbeGenerator convertColorToLinear() encountered an unsupported color space.")}return t}class by{constructor(t,e,n,i,r){this.xrLight=t,this.renderer=e,this.lightProbe=n,this.xrWebGLBinding=null,this.estimationStartCallback=r,this.frameCallback=this.onXRFrame.bind(this);const s=e.xr.getSession();if(i&&"XRWebGLBinding"in window){const n=new ua(16);t.environment=n.texture;const i=e.getContext();switch(s.preferredReflectionFormat){case"srgba8":i.getExtension("EXT_sRGB");break;case"rgba16f":i.getExtension("OES_texture_half_float")}this.xrWebGLBinding=new XRWebGLBinding(s,i),this.lightProbe.addEventListener("reflectionchange",(()=>{this.updateReflection()}))}s.requestAnimationFrame(this.frameCallback)}updateReflection(){const t=this.renderer.properties.get(this.xrLight.environment);if(t){const e=this.xrWebGLBinding.getReflectionCubeMap(this.lightProbe);e&&(t.__webglTexture=e,this.xrLight.environment.needsPMREMUpdate=!0)}}onXRFrame(t,e){if(!this.xrLight)return;e.session.requestAnimationFrame(this.frameCallback);const n=e.getLightEstimate(this.lightProbe);if(n){this.xrLight.lightProbe.sh.fromArray(n.sphericalHarmonicsCoefficients),this.xrLight.lightProbe.intensity=1;const t=Math.max(1,Math.max(n.primaryLightIntensity.x,Math.max(n.primaryLightIntensity.y,n.primaryLightIntensity.z)));this.xrLight.directionalLight.color.setRGB(n.primaryLightIntensity.x/t,n.primaryLightIntensity.y/t,n.primaryLightIntensity.z/t),this.xrLight.directionalLight.intensity=t,this.xrLight.directionalLight.position.copy(n.primaryLightDirection),this.estimationStartCallback&&(this.estimationStartCallback(),this.estimationStartCallback=null)}}dispose(){this.xrLight=null,this.renderer=null,this.lightProbe=null,this.xrWebGLBinding=null}}class Iy{constructor(t=4){this.pool=t,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(t){if(!this.workers[t]){const e=this.workerCreator();e.addEventListener("message",this._onMessage.bind(this,t)),this.workers[t]=e}}_getIdleWorker(){for(let t=0;t{const i=this._getIdleWorker();-1!==i?(this._initWorker(i),this.workerStatus|=1<t.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const Ty=9,By=15,Ry=16,Dy=22,Py=37,Ly=43,Uy=76,Ny=83,Fy=97,Oy=100,ky=103,Qy=109,zy=165,Gy=166,Hy=1000066e3;class Vy{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}}class Wy{constructor(t,e,n,i){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(t.buffer,t.byteOffset+e,n),this._littleEndian=i,this._offset=0}_nextUint8(){const t=this._dataView.getUint8(this._offset);return this._offset+=1,t}_nextUint16(){const t=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,t}_nextUint32(){const t=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,t}_nextUint64(){const t=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,t}_nextInt32(){const t=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,t}_nextUint8Array(t){const e=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,t);return this._offset+=t,e}_skip(t){return this._offset+=t,this}_scan(t,e){void 0===e&&(e=0);const n=this._offset;let i=0;for(;this._dataView.getUint8(this._offset)!==e&&it.arrayBuffer())).then((t=>WebAssembly.instantiate(t,Ky))).then(this._init):WebAssembly.instantiate(Buffer.from($y,"base64"),Ky).then(this._init),Xy)}_init(t){Yy=t.instance,Ky.env.emscripten_notify_memory_growth(0)}decode(t,e=0){if(!Yy)throw new Error("ZSTDDecoder: Await .init() before decoding.");const n=t.byteLength,i=Yy.exports.malloc(n);Jy.set(t,i),e=e||Number(Yy.exports.ZSTD_findDecompressedSize(i,n));const r=Yy.exports.malloc(e),s=Yy.exports.ZSTD_decompress(r,e,i,n),a=Jy.slice(r,r+s);return Yy.exports.free(i),Yy.exports.free(r),a}}const $y="AGFzbQEAAAABpQEVYAF/AX9gAn9/AGADf39/AX9gBX9/f39/AX9gAX8AYAJ/fwF/YAR/f39/AX9gA39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gAn9/AX5gAn5+AX5gAABgBX9/f39/AGAGf39/f39/AGAIf39/f39/f38AYAl/f39/f39/f38AYAABf2AIf39/f39/f38Bf2ANf39/f39/f39/f39/fwF/YAF/AX4CJwEDZW52H2Vtc2NyaXB0ZW5fbm90aWZ5X21lbW9yeV9ncm93dGgABANpaAEFAAAFAgEFCwACAQABAgIFBQcAAwABDgsBAQcAEhMHAAUBDAQEAAANBwQCAgYCBAgDAwMDBgEACQkHBgICAAYGAgQUBwYGAwIGAAMCAQgBBwUGCgoEEQAEBAEIAwgDBQgDEA8IAAcABAUBcAECAgUEAQCAAgYJAX8BQaCgwAILB2AHBm1lbW9yeQIABm1hbGxvYwAoBGZyZWUAJgxaU1REX2lzRXJyb3IAaBlaU1REX2ZpbmREZWNvbXByZXNzZWRTaXplAFQPWlNURF9kZWNvbXByZXNzAEoGX3N0YXJ0ACQJBwEAQQELASQKussBaA8AIAAgACgCBCABajYCBAsZACAAKAIAIAAoAgRBH3F0QQAgAWtBH3F2CwgAIABBiH9LC34BBH9BAyEBIAAoAgQiA0EgTQRAIAAoAggiASAAKAIQTwRAIAAQDQ8LIAAoAgwiAiABRgRAQQFBAiADQSBJGw8LIAAgASABIAJrIANBA3YiBCABIARrIAJJIgEbIgJrIgQ2AgggACADIAJBA3RrNgIEIAAgBCgAADYCAAsgAQsUAQF/IAAgARACIQIgACABEAEgAgv3AQECfyACRQRAIABCADcCACAAQQA2AhAgAEIANwIIQbh/DwsgACABNgIMIAAgAUEEajYCECACQQRPBEAgACABIAJqIgFBfGoiAzYCCCAAIAMoAAA2AgAgAUF/ai0AACIBBEAgAEEIIAEQFGs2AgQgAg8LIABBADYCBEF/DwsgACABNgIIIAAgAS0AACIDNgIAIAJBfmoiBEEBTQRAIARBAWtFBEAgACABLQACQRB0IANyIgM2AgALIAAgAS0AAUEIdCADajYCAAsgASACakF/ai0AACIBRQRAIABBADYCBEFsDwsgAEEoIAEQFCACQQN0ams2AgQgAgsWACAAIAEpAAA3AAAgACABKQAINwAICy8BAX8gAUECdEGgHWooAgAgACgCAEEgIAEgACgCBGprQR9xdnEhAiAAIAEQASACCyEAIAFCz9bTvtLHq9lCfiAAfEIfiUKHla+vmLbem55/fgsdAQF/IAAoAgggACgCDEYEfyAAKAIEQSBGBUEACwuCBAEDfyACQYDAAE8EQCAAIAEgAhBnIAAPCyAAIAJqIQMCQCAAIAFzQQNxRQRAAkAgAkEBSARAIAAhAgwBCyAAQQNxRQRAIAAhAgwBCyAAIQIDQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADTw0BIAJBA3ENAAsLAkAgA0F8cSIEQcAASQ0AIAIgBEFAaiIFSw0AA0AgAiABKAIANgIAIAIgASgCBDYCBCACIAEoAgg2AgggAiABKAIMNgIMIAIgASgCEDYCECACIAEoAhQ2AhQgAiABKAIYNgIYIAIgASgCHDYCHCACIAEoAiA2AiAgAiABKAIkNgIkIAIgASgCKDYCKCACIAEoAiw2AiwgAiABKAIwNgIwIAIgASgCNDYCNCACIAEoAjg2AjggAiABKAI8NgI8IAFBQGshASACQUBrIgIgBU0NAAsLIAIgBE8NAQNAIAIgASgCADYCACABQQRqIQEgAkEEaiICIARJDQALDAELIANBBEkEQCAAIQIMAQsgA0F8aiIEIABJBEAgACECDAELIAAhAgNAIAIgAS0AADoAACACIAEtAAE6AAEgAiABLQACOgACIAIgAS0AAzoAAyABQQRqIQEgAkEEaiICIARNDQALCyACIANJBEADQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADRw0ACwsgAAsMACAAIAEpAAA3AAALQQECfyAAKAIIIgEgACgCEEkEQEEDDwsgACAAKAIEIgJBB3E2AgQgACABIAJBA3ZrIgE2AgggACABKAAANgIAQQALDAAgACABKAIANgAAC/cCAQJ/AkAgACABRg0AAkAgASACaiAASwRAIAAgAmoiBCABSw0BCyAAIAEgAhALDwsgACABc0EDcSEDAkACQCAAIAFJBEAgAwRAIAAhAwwDCyAAQQNxRQRAIAAhAwwCCyAAIQMDQCACRQ0EIAMgAS0AADoAACABQQFqIQEgAkF/aiECIANBAWoiA0EDcQ0ACwwBCwJAIAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQhBSAGQQR2IQRBICAAdCIAQQFyIQkgASgCACEPQQAhAiADIQYCQANAIAlBAkggAiAPS3JFBEAgAiEHAkAgCARAA0AgBEH//wNxQf//A0YEQCAHQRhqIQcgBiAQSQR/IAZBAmoiBigAACAFdgUgBUEQaiEFIARBEHYLIQQMAQsLA0AgBEEDcSIIQQNGBEAgBUECaiEFIARBAnYhBCAHQQNqIQcMAQsLIAcgCGoiByAPSw0EIAVBAmohBQNAIAIgB0kEQCANIAJBAXRqQQA7AQAgAkEBaiECDAELCyAGIA5LQQAgBiAFQQN1aiIHIAxLG0UEQCAHKAAAIAVBB3EiBXYhBAwCCyAEQQJ2IQQLIAYhBwsCfyALQX9qIAQgAEF/anEiBiAAQQF0QX9qIgggCWsiEUkNABogBCAIcSIEQQAgESAEIABIG2shBiALCyEIIA0gAkEBdGogBkF/aiIEOwEAIAlBASAGayAEIAZBAUgbayEJA0AgCSAASARAIABBAXUhACALQX9qIQsMAQsLAn8gByAOS0EAIAcgBSAIaiIFQQN1aiIGIAxLG0UEQCAFQQdxDAELIAUgDCIGIAdrQQN0awshBSACQQFqIQIgBEUhCCAGKAAAIAVBH3F2IQQMAQsLQWwgCUEBRyAFQSBKcg0BGiABIAJBf2o2AgAgBiAFQQdqQQN1aiADawwBC0FQCyEAIApBEGokACAACwkAQQFBBSAAGwsMACAAIAEoAAA2AAALqgMBCn8jAEHwAGsiCiQAIAJBAWohDiAAQQhqIQtBgIAEIAVBf2p0QRB1IQxBACECQQEhBkEBIAV0IglBf2oiDyEIA0AgAiAORkUEQAJAIAEgAkEBdCINai8BACIHQf//A0YEQCALIAhBA3RqIAI2AgQgCEF/aiEIQQEhBwwBCyAGQQAgDCAHQRB0QRB1ShshBgsgCiANaiAHOwEAIAJBAWohAgwBCwsgACAFNgIEIAAgBjYCACAJQQN2IAlBAXZqQQNqIQxBACEAQQAhBkEAIQIDQCAGIA5GBEADQAJAIAAgCUYNACAKIAsgAEEDdGoiASgCBCIGQQF0aiICIAIvAQAiAkEBajsBACABIAUgAhAUayIIOgADIAEgAiAIQf8BcXQgCWs7AQAgASAEIAZBAnQiAmooAgA6AAIgASACIANqKAIANgIEIABBAWohAAwBCwsFIAEgBkEBdGouAQAhDUEAIQcDQCAHIA1ORQRAIAsgAkEDdGogBjYCBANAIAIgDGogD3EiAiAISw0ACyAHQQFqIQcMAQsLIAZBAWohBgwBCwsgCkHwAGokAAsjAEIAIAEQCSAAhUKHla+vmLbem55/fkLj3MqV/M7y9YV/fAsQACAAQn43AwggACABNgIACyQBAX8gAARAIAEoAgQiAgRAIAEoAgggACACEQEADwsgABAmCwsfACAAIAEgAi8BABAINgIAIAEQBBogACACQQRqNgIEC0oBAX9BoCAoAgAiASAAaiIAQX9MBEBBiCBBMDYCAEF/DwsCQCAAPwBBEHRNDQAgABBmDQBBiCBBMDYCAEF/DwtBoCAgADYCACABC9cBAQh/Qbp/IQoCQCACKAIEIgggAigCACIJaiIOIAEgAGtLDQBBbCEKIAkgBCADKAIAIgtrSw0AIAAgCWoiBCACKAIIIgxrIQ0gACABQWBqIg8gCyAJQQAQKSADIAkgC2o2AgACQAJAIAwgBCAFa00EQCANIQUMAQsgDCAEIAZrSw0CIAcgDSAFayIAaiIBIAhqIAdNBEAgBCABIAgQDxoMAgsgBCABQQAgAGsQDyEBIAIgACAIaiIINgIEIAEgAGshBAsgBCAPIAUgCEEBECkLIA4hCgsgCgubAgEBfyMAQYABayINJAAgDSADNgJ8AkAgAkEDSwRAQX8hCQwBCwJAAkACQAJAIAJBAWsOAwADAgELIAZFBEBBuH8hCQwEC0FsIQkgBS0AACICIANLDQMgACAHIAJBAnQiAmooAgAgAiAIaigCABA7IAEgADYCAEEBIQkMAwsgASAJNgIAQQAhCQwCCyAKRQRAQWwhCQwCC0EAIQkgC0UgDEEZSHINAUEIIAR0QQhqIQBBACECA0AgAiAATw0CIAJBQGshAgwAAAsAC0FsIQkgDSANQfwAaiANQfgAaiAFIAYQFSICEAMNACANKAJ4IgMgBEsNACAAIA0gDSgCfCAHIAggAxAYIAEgADYCACACIQkLIA1BgAFqJAAgCQsLACAAIAEgAhALGgsQACAALwAAIAAtAAJBEHRyCy8AAn9BuH8gAUEISQ0AGkFyIAAoAAQiAEF3Sw0AGkG4fyAAQQhqIgAgACABSxsLCwkAIAAgATsAAAsDAAELigYBBX8gACAAKAIAIgVBfnE2AgBBACAAIAVBAXZqQYQgKAIAIgQgAEYbIQECQAJAIAAoAgQiAkUNACACKAIAIgNBAXENACACQQhqIgUgA0EBdkF4aiIDQQggA0EISxtnQR9zQQJ0QYAfaiIDKAIARgRAIAMgAigCDDYCAAsgAigCCCIDBEAgAyACKAIMNgIECyACKAIMIgMEQCADIAIoAgg2AgALIAIgAigCACAAKAIAQX5xajYCAEGEICEAAkACQCABRQ0AIAEgAjYCBCABKAIAIgNBAXENASADQQF2QXhqIgNBCCADQQhLG2dBH3NBAnRBgB9qIgMoAgAgAUEIakYEQCADIAEoAgw2AgALIAEoAggiAwRAIAMgASgCDDYCBAsgASgCDCIDBEAgAyABKAIINgIAQYQgKAIAIQQLIAIgAigCACABKAIAQX5xajYCACABIARGDQAgASABKAIAQQF2akEEaiEACyAAIAI2AgALIAIoAgBBAXZBeGoiAEEIIABBCEsbZ0Efc0ECdEGAH2oiASgCACEAIAEgBTYCACACIAA2AgwgAkEANgIIIABFDQEgACAFNgIADwsCQCABRQ0AIAEoAgAiAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAigCACABQQhqRgRAIAIgASgCDDYCAAsgASgCCCICBEAgAiABKAIMNgIECyABKAIMIgIEQCACIAEoAgg2AgBBhCAoAgAhBAsgACAAKAIAIAEoAgBBfnFqIgI2AgACQCABIARHBEAgASABKAIAQQF2aiAANgIEIAAoAgAhAgwBC0GEICAANgIACyACQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgIoAgAhASACIABBCGoiAjYCACAAIAE2AgwgAEEANgIIIAFFDQEgASACNgIADwsgBUEBdkF4aiIBQQggAUEISxtnQR9zQQJ0QYAfaiICKAIAIQEgAiAAQQhqIgI2AgAgACABNgIMIABBADYCCCABRQ0AIAEgAjYCAAsLDgAgAARAIABBeGoQJQsLgAIBA38CQCAAQQ9qQXhxQYQgKAIAKAIAQQF2ayICEB1Bf0YNAAJAQYQgKAIAIgAoAgAiAUEBcQ0AIAFBAXZBeGoiAUEIIAFBCEsbZ0Efc0ECdEGAH2oiASgCACAAQQhqRgRAIAEgACgCDDYCAAsgACgCCCIBBEAgASAAKAIMNgIECyAAKAIMIgFFDQAgASAAKAIINgIAC0EBIQEgACAAKAIAIAJBAXRqIgI2AgAgAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAygCACECIAMgAEEIaiIDNgIAIAAgAjYCDCAAQQA2AgggAkUNACACIAM2AgALIAELtwIBA38CQAJAIABBASAAGyICEDgiAA0AAkACQEGEICgCACIARQ0AIAAoAgAiA0EBcQ0AIAAgA0EBcjYCACADQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgAgAEEIakYEQCABIAAoAgw2AgALIAAoAggiAQRAIAEgACgCDDYCBAsgACgCDCIBBEAgASAAKAIINgIACyACECchAkEAIQFBhCAoAgAhACACDQEgACAAKAIAQX5xNgIAQQAPCyACQQ9qQXhxIgMQHSICQX9GDQIgAkEHakF4cSIAIAJHBEAgACACaxAdQX9GDQMLAkBBhCAoAgAiAUUEQEGAICAANgIADAELIAAgATYCBAtBhCAgADYCACAAIANBAXRBAXI2AgAMAQsgAEUNAQsgAEEIaiEBCyABC7kDAQJ/IAAgA2ohBQJAIANBB0wEQANAIAAgBU8NAiAAIAItAAA6AAAgAEEBaiEAIAJBAWohAgwAAAsACyAEQQFGBEACQCAAIAJrIgZBB00EQCAAIAItAAA6AAAgACACLQABOgABIAAgAi0AAjoAAiAAIAItAAM6AAMgAEEEaiACIAZBAnQiBkHAHmooAgBqIgIQFyACIAZB4B5qKAIAayECDAELIAAgAhAMCyACQQhqIQIgAEEIaiEACwJAAkACQAJAIAUgAU0EQCAAIANqIQEgBEEBRyAAIAJrQQ9Kcg0BA0AgACACEAwgAkEIaiECIABBCGoiACABSQ0ACwwFCyAAIAFLBEAgACEBDAQLIARBAUcgACACa0EPSnINASAAIQMgAiEEA0AgAyAEEAwgBEEIaiEEIANBCGoiAyABSQ0ACwwCCwNAIAAgAhAHIAJBEGohAiAAQRBqIgAgAUkNAAsMAwsgACEDIAIhBANAIAMgBBAHIARBEGohBCADQRBqIgMgAUkNAAsLIAIgASAAa2ohAgsDQCABIAVPDQEgASACLQAAOgAAIAFBAWohASACQQFqIQIMAAALAAsLQQECfyAAIAAoArjgASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigCACACaiAAQQZ2IgFBAnRBsB5qKAIAaiAAQSBxIgBFaiABRSAAQQV2cWoFQbh/CwsdACAAKAKQ4gEQWiAAQQA2AqDiASAAQgA3A5DiAQu1AwEFfyMAQZACayIKJABBuH8hBgJAIAVFDQAgBCwAACIIQf8BcSEHAkAgCEF/TARAIAdBgn9qQQF2IgggBU8NAkFsIQYgB0GBf2oiBUGAAk8NAiAEQQFqIQdBACEGA0AgBiAFTwRAIAUhBiAIIQcMAwUgACAGaiAHIAZBAXZqIgQtAABBBHY6AAAgACAGQQFyaiAELQAAQQ9xOgAAIAZBAmohBgwBCwAACwALIAcgBU8NASAAIARBAWogByAKEFMiBhADDQELIAYhBEEAIQYgAUEAQTQQECEJQQAhBQNAIAQgBkcEQCAAIAZqIggtAAAiAUELSwRAQWwhBgwDBSAJIAFBAnRqIgEgASgCAEEBajYCACAGQQFqIQZBASAILQAAdEEBdSAFaiEFDAILAAsLQWwhBiAFRQ0AIAUQFEEBaiIBQQxLDQAgAyABNgIAQQFBASABdCAFayIDEBQiAXQgA0cNACAAIARqIAFBAWoiADoAACAJIABBAnRqIgAgACgCAEEBajYCACAJKAIEIgBBAkkgAEEBcXINACACIARBAWo2AgAgB0EBaiEGCyAKQZACaiQAIAYLxhEBDH8jAEHwAGsiBSQAQWwhCwJAIANBCkkNACACLwAAIQogAi8AAiEJIAIvAAQhByAFQQhqIAQQDgJAIAMgByAJIApqakEGaiIMSQ0AIAUtAAohCCAFQdgAaiACQQZqIgIgChAGIgsQAw0BIAVBQGsgAiAKaiICIAkQBiILEAMNASAFQShqIAIgCWoiAiAHEAYiCxADDQEgBUEQaiACIAdqIAMgDGsQBiILEAMNASAAIAFqIg9BfWohECAEQQRqIQZBASELIAAgAUEDakECdiIDaiIMIANqIgIgA2oiDiEDIAIhBCAMIQcDQCALIAMgEElxBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgCS0AAyELIAcgBiAFQUBrIAgQAkECdGoiCS8BADsAACAFQUBrIAktAAIQASAJLQADIQogBCAGIAVBKGogCBACQQJ0aiIJLwEAOwAAIAVBKGogCS0AAhABIAktAAMhCSADIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgDS0AAyENIAAgC2oiCyAGIAVB2ABqIAgQAkECdGoiAC8BADsAACAFQdgAaiAALQACEAEgAC0AAyEAIAcgCmoiCiAGIAVBQGsgCBACQQJ0aiIHLwEAOwAAIAVBQGsgBy0AAhABIActAAMhByAEIAlqIgkgBiAFQShqIAgQAkECdGoiBC8BADsAACAFQShqIAQtAAIQASAELQADIQQgAyANaiIDIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgACALaiEAIAcgCmohByAEIAlqIQQgAyANLQADaiEDIAVB2ABqEA0gBUFAaxANciAFQShqEA1yIAVBEGoQDXJFIQsMAQsLIAQgDksgByACS3INAEFsIQsgACAMSw0BIAxBfWohCQNAQQAgACAJSSAFQdgAahAEGwRAIAAgBiAFQdgAaiAIEAJBAnRqIgovAQA7AAAgBUHYAGogCi0AAhABIAAgCi0AA2oiACAGIAVB2ABqIAgQAkECdGoiCi8BADsAACAFQdgAaiAKLQACEAEgACAKLQADaiEADAEFIAxBfmohCgNAIAVB2ABqEAQgACAKS3JFBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgACAJLQADaiEADAELCwNAIAAgCk0EQCAAIAYgBUHYAGogCBACQQJ0aiIJLwEAOwAAIAVB2ABqIAktAAIQASAAIAktAANqIQAMAQsLAkAgACAMTw0AIAAgBiAFQdgAaiAIEAIiAEECdGoiDC0AADoAACAMLQADQQFGBEAgBUHYAGogDC0AAhABDAELIAUoAlxBH0sNACAFQdgAaiAGIABBAnRqLQACEAEgBSgCXEEhSQ0AIAVBIDYCXAsgAkF9aiEMA0BBACAHIAxJIAVBQGsQBBsEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiIAIAYgBUFAayAIEAJBAnRqIgcvAQA7AAAgBUFAayAHLQACEAEgACAHLQADaiEHDAEFIAJBfmohDANAIAVBQGsQBCAHIAxLckUEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwNAIAcgDE0EQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwJAIAcgAk8NACAHIAYgBUFAayAIEAIiAEECdGoiAi0AADoAACACLQADQQFGBEAgBUFAayACLQACEAEMAQsgBSgCREEfSw0AIAVBQGsgBiAAQQJ0ai0AAhABIAUoAkRBIUkNACAFQSA2AkQLIA5BfWohAgNAQQAgBCACSSAFQShqEAQbBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2oiACAGIAVBKGogCBACQQJ0aiIELwEAOwAAIAVBKGogBC0AAhABIAAgBC0AA2ohBAwBBSAOQX5qIQIDQCAFQShqEAQgBCACS3JFBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsDQCAEIAJNBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsCQCAEIA5PDQAgBCAGIAVBKGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBKGogAi0AAhABDAELIAUoAixBH0sNACAFQShqIAYgAEECdGotAAIQASAFKAIsQSFJDQAgBUEgNgIsCwNAQQAgAyAQSSAFQRBqEAQbBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2oiACAGIAVBEGogCBACQQJ0aiICLwEAOwAAIAVBEGogAi0AAhABIAAgAi0AA2ohAwwBBSAPQX5qIQIDQCAFQRBqEAQgAyACS3JFBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsDQCADIAJNBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsCQCADIA9PDQAgAyAGIAVBEGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBEGogAi0AAhABDAELIAUoAhRBH0sNACAFQRBqIAYgAEECdGotAAIQASAFKAIUQSFJDQAgBUEgNgIUCyABQWwgBUHYAGoQCiAFQUBrEApxIAVBKGoQCnEgBUEQahAKcRshCwwJCwAACwALAAALAAsAAAsACwAACwALQWwhCwsgBUHwAGokACALC7UEAQ5/IwBBEGsiBiQAIAZBBGogABAOQVQhBQJAIARB3AtJDQAgBi0ABCEHIANB8ARqQQBB7AAQECEIIAdBDEsNACADQdwJaiIJIAggBkEIaiAGQQxqIAEgAhAxIhAQA0UEQCAGKAIMIgQgB0sNASADQdwFaiEPIANBpAVqIREgAEEEaiESIANBqAVqIQEgBCEFA0AgBSICQX9qIQUgCCACQQJ0aigCAEUNAAsgAkEBaiEOQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgASALaiAKNgIAIAVBAWohBSAKIAxqIQoMAQsLIAEgCjYCAEEAIQUgBigCCCELA0AgBSALRkUEQCABIAUgCWotAAAiDEECdGoiDSANKAIAIg1BAWo2AgAgDyANQQF0aiINIAw6AAEgDSAFOgAAIAVBAWohBQwBCwtBACEBIANBADYCqAUgBEF/cyAHaiEJQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgAyALaiABNgIAIAwgBSAJanQgAWohASAFQQFqIQUMAQsLIAcgBEEBaiIBIAJrIgRrQQFqIQgDQEEBIQUgBCAIT0UEQANAIAUgDk9FBEAgBUECdCIJIAMgBEE0bGpqIAMgCWooAgAgBHY2AgAgBUEBaiEFDAELCyAEQQFqIQQMAQsLIBIgByAPIAogESADIAIgARBkIAZBAToABSAGIAc6AAYgACAGKAIENgIACyAQIQULIAZBEGokACAFC8ENAQt/IwBB8ABrIgUkAEFsIQkCQCADQQpJDQAgAi8AACEKIAIvAAIhDCACLwAEIQYgBUEIaiAEEA4CQCADIAYgCiAMampBBmoiDUkNACAFLQAKIQcgBUHYAGogAkEGaiICIAoQBiIJEAMNASAFQUBrIAIgCmoiAiAMEAYiCRADDQEgBUEoaiACIAxqIgIgBhAGIgkQAw0BIAVBEGogAiAGaiADIA1rEAYiCRADDQEgACABaiIOQX1qIQ8gBEEEaiEGQQEhCSAAIAFBA2pBAnYiAmoiCiACaiIMIAJqIg0hAyAMIQQgCiECA0AgCSADIA9JcQRAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAACAGIAVBQGsgBxACQQF0aiIILQAAIQsgBUFAayAILQABEAEgAiALOgAAIAYgBUEoaiAHEAJBAXRqIggtAAAhCyAFQShqIAgtAAEQASAEIAs6AAAgBiAFQRBqIAcQAkEBdGoiCC0AACELIAVBEGogCC0AARABIAMgCzoAACAGIAVB2ABqIAcQAkEBdGoiCC0AACELIAVB2ABqIAgtAAEQASAAIAs6AAEgBiAFQUBrIAcQAkEBdGoiCC0AACELIAVBQGsgCC0AARABIAIgCzoAASAGIAVBKGogBxACQQF0aiIILQAAIQsgBUEoaiAILQABEAEgBCALOgABIAYgBUEQaiAHEAJBAXRqIggtAAAhCyAFQRBqIAgtAAEQASADIAs6AAEgA0ECaiEDIARBAmohBCACQQJqIQIgAEECaiEAIAkgBUHYAGoQDUVxIAVBQGsQDUVxIAVBKGoQDUVxIAVBEGoQDUVxIQkMAQsLIAQgDUsgAiAMS3INAEFsIQkgACAKSw0BIApBfWohCQNAIAVB2ABqEAQgACAJT3JFBEAgBiAFQdgAaiAHEAJBAXRqIggtAAAhCyAFQdgAaiAILQABEAEgACALOgAAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAASAAQQJqIQAMAQsLA0AgBUHYAGoQBCAAIApPckUEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCwNAIAAgCkkEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCyAMQX1qIQADQCAFQUBrEAQgAiAAT3JFBEAgBiAFQUBrIAcQAkEBdGoiCi0AACEJIAVBQGsgCi0AARABIAIgCToAACAGIAVBQGsgBxACQQF0aiIKLQAAIQkgBUFAayAKLQABEAEgAiAJOgABIAJBAmohAgwBCwsDQCAFQUBrEAQgAiAMT3JFBEAgBiAFQUBrIAcQAkEBdGoiAC0AACEKIAVBQGsgAC0AARABIAIgCjoAACACQQFqIQIMAQsLA0AgAiAMSQRAIAYgBUFAayAHEAJBAXRqIgAtAAAhCiAFQUBrIAAtAAEQASACIAo6AAAgAkEBaiECDAELCyANQX1qIQADQCAFQShqEAQgBCAAT3JFBEAgBiAFQShqIAcQAkEBdGoiAi0AACEKIAVBKGogAi0AARABIAQgCjoAACAGIAVBKGogBxACQQF0aiICLQAAIQogBUEoaiACLQABEAEgBCAKOgABIARBAmohBAwBCwsDQCAFQShqEAQgBCANT3JFBEAgBiAFQShqIAcQAkEBdGoiAC0AACECIAVBKGogAC0AARABIAQgAjoAACAEQQFqIQQMAQsLA0AgBCANSQRAIAYgBUEoaiAHEAJBAXRqIgAtAAAhAiAFQShqIAAtAAEQASAEIAI6AAAgBEEBaiEEDAELCwNAIAVBEGoQBCADIA9PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIAYgBUEQaiAHEAJBAXRqIgAtAAAhAiAFQRBqIAAtAAEQASADIAI6AAEgA0ECaiEDDAELCwNAIAVBEGoQBCADIA5PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIANBAWohAwwBCwsDQCADIA5JBEAgBiAFQRBqIAcQAkEBdGoiAC0AACECIAVBEGogAC0AARABIAMgAjoAACADQQFqIQMMAQsLIAFBbCAFQdgAahAKIAVBQGsQCnEgBUEoahAKcSAFQRBqEApxGyEJDAELQWwhCQsgBUHwAGokACAJC8oCAQR/IwBBIGsiBSQAIAUgBBAOIAUtAAIhByAFQQhqIAIgAxAGIgIQA0UEQCAEQQRqIQIgACABaiIDQX1qIQQDQCAFQQhqEAQgACAET3JFBEAgAiAFQQhqIAcQAkEBdGoiBi0AACEIIAVBCGogBi0AARABIAAgCDoAACACIAVBCGogBxACQQF0aiIGLQAAIQggBUEIaiAGLQABEAEgACAIOgABIABBAmohAAwBCwsDQCAFQQhqEAQgACADT3JFBEAgAiAFQQhqIAcQAkEBdGoiBC0AACEGIAVBCGogBC0AARABIAAgBjoAACAAQQFqIQAMAQsLA0AgACADT0UEQCACIAVBCGogBxACQQF0aiIELQAAIQYgBUEIaiAELQABEAEgACAGOgAAIABBAWohAAwBCwsgAUFsIAVBCGoQChshAgsgBUEgaiQAIAILtgMBCX8jAEEQayIGJAAgBkEANgIMIAZBADYCCEFUIQQCQAJAIANBQGsiDCADIAZBCGogBkEMaiABIAIQMSICEAMNACAGQQRqIAAQDiAGKAIMIgcgBi0ABEEBaksNASAAQQRqIQogBkEAOgAFIAYgBzoABiAAIAYoAgQ2AgAgB0EBaiEJQQEhBANAIAQgCUkEQCADIARBAnRqIgEoAgAhACABIAU2AgAgACAEQX9qdCAFaiEFIARBAWohBAwBCwsgB0EBaiEHQQAhBSAGKAIIIQkDQCAFIAlGDQEgAyAFIAxqLQAAIgRBAnRqIgBBASAEdEEBdSILIAAoAgAiAWoiADYCACAHIARrIQhBACEEAkAgC0EDTQRAA0AgBCALRg0CIAogASAEakEBdGoiACAIOgABIAAgBToAACAEQQFqIQQMAAALAAsDQCABIABPDQEgCiABQQF0aiIEIAg6AAEgBCAFOgAAIAQgCDoAAyAEIAU6AAIgBCAIOgAFIAQgBToABCAEIAg6AAcgBCAFOgAGIAFBBGohAQwAAAsACyAFQQFqIQUMAAALAAsgAiEECyAGQRBqJAAgBAutAQECfwJAQYQgKAIAIABHIAAoAgBBAXYiAyABa0F4aiICQXhxQQhHcgR/IAIFIAMQJ0UNASACQQhqC0EQSQ0AIAAgACgCACICQQFxIAAgAWpBD2pBeHEiASAAa0EBdHI2AgAgASAANgIEIAEgASgCAEEBcSAAIAJBAXZqIAFrIgJBAXRyNgIAQYQgIAEgAkH/////B3FqQQRqQYQgKAIAIABGGyABNgIAIAEQJQsLygIBBX8CQAJAAkAgAEEIIABBCEsbZ0EfcyAAaUEBR2oiAUEESSAAIAF2cg0AIAFBAnRB/B5qKAIAIgJFDQADQCACQXhqIgMoAgBBAXZBeGoiBSAATwRAIAIgBUEIIAVBCEsbZ0Efc0ECdEGAH2oiASgCAEYEQCABIAIoAgQ2AgALDAMLIARBHksNASAEQQFqIQQgAigCBCICDQALC0EAIQMgAUEgTw0BA0AgAUECdEGAH2ooAgAiAkUEQCABQR5LIQIgAUEBaiEBIAJFDQEMAwsLIAIgAkF4aiIDKAIAQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgBGBEAgASACKAIENgIACwsgAigCACIBBEAgASACKAIENgIECyACKAIEIgEEQCABIAIoAgA2AgALIAMgAygCAEEBcjYCACADIAAQNwsgAwvhCwINfwV+IwBB8ABrIgckACAHIAAoAvDhASIINgJcIAEgAmohDSAIIAAoAoDiAWohDwJAAkAgBUUEQCABIQQMAQsgACgCxOABIRAgACgCwOABIREgACgCvOABIQ4gAEEBNgKM4QFBACEIA0AgCEEDRwRAIAcgCEECdCICaiAAIAJqQazQAWooAgA2AkQgCEEBaiEIDAELC0FsIQwgB0EYaiADIAQQBhADDQEgB0EsaiAHQRhqIAAoAgAQEyAHQTRqIAdBGGogACgCCBATIAdBPGogB0EYaiAAKAIEEBMgDUFgaiESIAEhBEEAIQwDQCAHKAIwIAcoAixBA3RqKQIAIhRCEIinQf8BcSEIIAcoAkAgBygCPEEDdGopAgAiFUIQiKdB/wFxIQsgBygCOCAHKAI0QQN0aikCACIWQiCIpyEJIBVCIIghFyAUQiCIpyECAkAgFkIQiKdB/wFxIgNBAk8EQAJAIAZFIANBGUlyRQRAIAkgB0EYaiADQSAgBygCHGsiCiAKIANLGyIKEAUgAyAKayIDdGohCSAHQRhqEAQaIANFDQEgB0EYaiADEAUgCWohCQwBCyAHQRhqIAMQBSAJaiEJIAdBGGoQBBoLIAcpAkQhGCAHIAk2AkQgByAYNwNIDAELAkAgA0UEQCACBEAgBygCRCEJDAMLIAcoAkghCQwBCwJAAkAgB0EYakEBEAUgCSACRWpqIgNBA0YEQCAHKAJEQX9qIgMgA0VqIQkMAQsgA0ECdCAHaigCRCIJIAlFaiEJIANBAUYNAQsgByAHKAJINgJMCwsgByAHKAJENgJIIAcgCTYCRAsgF6chAyALBEAgB0EYaiALEAUgA2ohAwsgCCALakEUTwRAIAdBGGoQBBoLIAgEQCAHQRhqIAgQBSACaiECCyAHQRhqEAQaIAcgB0EYaiAUQhiIp0H/AXEQCCAUp0H//wNxajYCLCAHIAdBGGogFUIYiKdB/wFxEAggFadB//8DcWo2AjwgB0EYahAEGiAHIAdBGGogFkIYiKdB/wFxEAggFqdB//8DcWo2AjQgByACNgJgIAcoAlwhCiAHIAk2AmggByADNgJkAkACQAJAIAQgAiADaiILaiASSw0AIAIgCmoiEyAPSw0AIA0gBGsgC0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdBKGogACgCBBATQQAhBCAHQeAAaiEMIAdB5ABqIQoDQCAHQShqEARBAksgBCAXTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEJIAcoAkggBygCREEDdGopAgAiH0IgiKchCCAeQiCIISAgHUIgiKchAgJAIB9CEIinQf8BcSIDQQJPBEACQCAGRSADQRlJckUEQCAIIAdBKGogA0EgIAcoAixrIg0gDSADSxsiDRAFIAMgDWsiA3RqIQggB0EoahAEGiADRQ0BIAdBKGogAxAFIAhqIQgMAQsgB0EoaiADEAUgCGohCCAHQShqEAQaCyAHKQJUISEgByAINgJUIAcgITcDWAwBCwJAIANFBEAgAgRAIAcoAlQhCAwDCyAHKAJYIQgMAQsCQAJAIAdBKGpBARAFIAggAkVqaiIDQQNGBEAgBygCVEF/aiIDIANFaiEIDAELIANBAnQgB2ooAlQiCCAIRWohCCADQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAg2AlQLICCnIQMgCQRAIAdBKGogCRAFIANqIQMLIAkgC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgAmohAgsgB0EoahAEGiAHIAcoAmggAmoiCSADajYCaCAKIAwgCCAJSxsoAgAhDSAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogB0EoaiAfQhiIp0H/AXEQCCEOIAdB8ABqIARBBHRqIgsgCSANaiAIazYCDCALIAg2AgggCyADNgIEIAsgAjYCACAHIA4gH6dB//8DcWo2AkQgBEEBaiEEDAELCyAEIBdIDQEgEkFgaiEYIAdB4ABqIRogB0HkAGohGyABIQMDQCAHQShqEARBAksgBCAFTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEIIAcoAkggBygCREEDdGopAgAiH0IgiKchCSAeQiCIISAgHUIgiKchDAJAIB9CEIinQf8BcSICQQJPBEACQCAGRSACQRlJckUEQCAJIAdBKGogAkEgIAcoAixrIgogCiACSxsiChAFIAIgCmsiAnRqIQkgB0EoahAEGiACRQ0BIAdBKGogAhAFIAlqIQkMAQsgB0EoaiACEAUgCWohCSAHQShqEAQaCyAHKQJUISEgByAJNgJUIAcgITcDWAwBCwJAIAJFBEAgDARAIAcoAlQhCQwDCyAHKAJYIQkMAQsCQAJAIAdBKGpBARAFIAkgDEVqaiICQQNGBEAgBygCVEF/aiICIAJFaiEJDAELIAJBAnQgB2ooAlQiCSAJRWohCSACQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAk2AlQLICCnIRQgCARAIAdBKGogCBAFIBRqIRQLIAggC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgDGohDAsgB0EoahAEGiAHIAcoAmggDGoiGSAUajYCaCAbIBogCSAZSxsoAgAhHCAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogByAHQShqIB9CGIinQf8BcRAIIB+nQf//A3FqNgJEIAcgB0HwAGogBEEDcUEEdGoiDSkDCCIdNwPIASAHIA0pAwAiHjcDwAECQAJAAkAgBygCvAEiDiAepyICaiIWIBNLDQAgAyAHKALEASIKIAJqIgtqIBhLDQAgEiADayALQSBqTw0BCyAHIAcpA8gBNwMQIAcgBykDwAE3AwggAyASIAdBCGogB0G8AWogEyAPIBUgERAeIQsMAQsgAiADaiEIIAMgDhAHIAJBEU8EQCADQRBqIQIDQCACIA5BEGoiDhAHIAJBEGoiAiAISQ0ACwsgCCAdpyIOayECIAcgFjYCvAEgDiAIIA9rSwRAIA4gCCAVa0sEQEFsIQsMAgsgESACIA9rIgJqIhYgCmogEU0EQCAIIBYgChAPGgwCCyAIIBZBACACaxAPIQggByACIApqIgo2AsQBIAggAmshCCAPIQILIA5BEE8EQCAIIApqIQoDQCAIIAIQByACQRBqIQIgCEEQaiIIIApJDQALDAELAkAgDkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgDkECdCIKQcAeaigCAGoiAhAXIAIgCkHgHmooAgBrIQIgBygCxAEhCgwBCyAIIAIQDAsgCkEJSQ0AIAggCmohCiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAKSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAKSQ0ACwsgCxADBEAgCyEQDAQFIA0gDDYCACANIBkgHGogCWs2AgwgDSAJNgIIIA0gFDYCBCAEQQFqIQQgAyALaiEDDAILAAsLIAQgBUgNASAEIBdrIQtBACEEA0AgCyAFSARAIAcgB0HwAGogC0EDcUEEdGoiAikDCCIdNwPIASAHIAIpAwAiHjcDwAECQAJAAkAgBygCvAEiDCAepyICaiIKIBNLDQAgAyAHKALEASIJIAJqIhBqIBhLDQAgEiADayAQQSBqTw0BCyAHIAcpA8gBNwMgIAcgBykDwAE3AxggAyASIAdBGGogB0G8AWogEyAPIBUgERAeIRAMAQsgAiADaiEIIAMgDBAHIAJBEU8EQCADQRBqIQIDQCACIAxBEGoiDBAHIAJBEGoiAiAISQ0ACwsgCCAdpyIGayECIAcgCjYCvAEgBiAIIA9rSwRAIAYgCCAVa0sEQEFsIRAMAgsgESACIA9rIgJqIgwgCWogEU0EQCAIIAwgCRAPGgwCCyAIIAxBACACaxAPIQggByACIAlqIgk2AsQBIAggAmshCCAPIQILIAZBEE8EQCAIIAlqIQYDQCAIIAIQByACQRBqIQIgCEEQaiIIIAZJDQALDAELAkAgBkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgBkECdCIGQcAeaigCAGoiAhAXIAIgBkHgHmooAgBrIQIgBygCxAEhCQwBCyAIIAIQDAsgCUEJSQ0AIAggCWohBiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAGSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAGSQ0ACwsgEBADDQMgC0EBaiELIAMgEGohAwwBCwsDQCAEQQNHBEAgACAEQQJ0IgJqQazQAWogAiAHaigCVDYCACAEQQFqIQQMAQsLIAcoArwBIQgLQbp/IRAgEyAIayIAIBIgA2tLDQAgAwR/IAMgCCAAEAsgAGoFQQALIAFrIRALIAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY0AAQMyIFEAMiBg0AIANBHzYCfCADIANB/ABqIANB+ABqIAQgBCAFaiAGGyIEIAEgAmoiAiAEaxAVIgUQAw0AIAMoAnwiBkEfSw0AIAMoAngiB0EJTw0AIABBiCBqIAMgBkGAC0GADCAHEBggA0E0NgJ8IAMgA0H8AGogA0H4AGogBCAFaiIEIAIgBGsQFSIFEAMNACADKAJ8IgZBNEsNACADKAJ4IgdBCk8NACAAQZAwaiADIAZBgA1B4A4gBxAYIANBIzYCfCADIANB/ABqIANB+ABqIAQgBWoiBCACIARrEBUiBRADDQAgAygCfCIGQSNLDQAgAygCeCIHQQpPDQAgACADIAZBwBBB0BEgBxAYIAQgBWoiBEEMaiIFIAJLDQAgAiAFayEFQQAhAgNAIAJBA0cEQCAEKAAAIgZBf2ogBU8NAiAAIAJBAnRqQZzQAWogBjYCACACQQFqIQIgBEEEaiEEDAELCyAEIAFrIQgLIANBgAFqJAAgCAtGAQN/IABBCGohAyAAKAIEIQJBACEAA0AgACACdkUEQCABIAMgAEEDdGotAAJBFktqIQEgAEEBaiEADAELCyABQQggAmt0C4YDAQV/Qbh/IQcCQCADRQ0AIAItAAAiBEUEQCABQQA2AgBBAUG4fyADQQFGGw8LAn8gAkEBaiIFIARBGHRBGHUiBkF/Sg0AGiAGQX9GBEAgA0EDSA0CIAUvAABBgP4BaiEEIAJBA2oMAQsgA0ECSA0BIAItAAEgBEEIdHJBgIB+aiEEIAJBAmoLIQUgASAENgIAIAVBAWoiASACIANqIgNLDQBBbCEHIABBEGogACAFLQAAIgVBBnZBI0EJIAEgAyABa0HAEEHQEUHwEiAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBmCBqIABBCGogBUEEdkEDcUEfQQggASABIAZqIAgbIgEgAyABa0GAC0GADEGAFyAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBoDBqIABBBGogBUECdkEDcUE0QQkgASABIAZqIAgbIgEgAyABa0GADUHgDkGQGSAAKAKM4QEgACgCnOIBIAQQHyIAEAMNACAAIAFqIAJrIQcLIAcLrQMBCn8jAEGABGsiCCQAAn9BUiACQf8BSw0AGkFUIANBDEsNABogAkEBaiELIABBBGohCUGAgAQgA0F/anRBEHUhCkEAIQJBASEEQQEgA3QiB0F/aiIMIQUDQCACIAtGRQRAAkAgASACQQF0Ig1qLwEAIgZB//8DRgRAIAkgBUECdGogAjoAAiAFQX9qIQVBASEGDAELIARBACAKIAZBEHRBEHVKGyEECyAIIA1qIAY7AQAgAkEBaiECDAELCyAAIAQ7AQIgACADOwEAIAdBA3YgB0EBdmpBA2ohBkEAIQRBACECA0AgBCALRkUEQCABIARBAXRqLgEAIQpBACEAA0AgACAKTkUEQCAJIAJBAnRqIAQ6AAIDQCACIAZqIAxxIgIgBUsNAAsgAEEBaiEADAELCyAEQQFqIQQMAQsLQX8gAg0AGkEAIQIDfyACIAdGBH9BAAUgCCAJIAJBAnRqIgAtAAJBAXRqIgEgAS8BACIBQQFqOwEAIAAgAyABEBRrIgU6AAMgACABIAVB/wFxdCAHazsBACACQQFqIQIMAQsLCyEFIAhBgARqJAAgBQvjBgEIf0FsIQcCQCACQQNJDQACQAJAAkACQCABLQAAIgNBA3EiCUEBaw4DAwEAAgsgACgCiOEBDQBBYg8LIAJBBUkNAkEDIQYgASgAACEFAn8CQAJAIANBAnZBA3EiCEF+aiIEQQFNBEAgBEEBaw0BDAILIAVBDnZB/wdxIQQgBUEEdkH/B3EhAyAIRQwCCyAFQRJ2IQRBBCEGIAVBBHZB//8AcSEDQQAMAQsgBUEEdkH//w9xIgNBgIAISw0DIAEtAARBCnQgBUEWdnIhBEEFIQZBAAshBSAEIAZqIgogAksNAgJAIANBgQZJDQAgACgCnOIBRQ0AQQAhAgNAIAJBg4ABSw0BIAJBQGshAgwAAAsACwJ/IAlBA0YEQCABIAZqIQEgAEHw4gFqIQIgACgCDCEGIAUEQCACIAMgASAEIAYQXwwCCyACIAMgASAEIAYQXQwBCyAAQbjQAWohAiABIAZqIQEgAEHw4gFqIQYgAEGo0ABqIQggBQRAIAggBiADIAEgBCACEF4MAQsgCCAGIAMgASAEIAIQXAsQAw0CIAAgAzYCgOIBIABBATYCiOEBIAAgAEHw4gFqNgLw4QEgCUECRgRAIAAgAEGo0ABqNgIMCyAAIANqIgBBiOMBakIANwAAIABBgOMBakIANwAAIABB+OIBakIANwAAIABB8OIBakIANwAAIAoPCwJ/AkACQAJAIANBAnZBA3FBf2oiBEECSw0AIARBAWsOAgACAQtBASEEIANBA3YMAgtBAiEEIAEvAABBBHYMAQtBAyEEIAEQIUEEdgsiAyAEaiIFQSBqIAJLBEAgBSACSw0CIABB8OIBaiABIARqIAMQCyEBIAAgAzYCgOIBIAAgATYC8OEBIAEgA2oiAEIANwAYIABCADcAECAAQgA3AAggAEIANwAAIAUPCyAAIAM2AoDiASAAIAEgBGo2AvDhASAFDwsCfwJAAkACQCADQQJ2QQNxQX9qIgRBAksNACAEQQFrDgIAAgELQQEhByADQQN2DAILQQIhByABLwAAQQR2DAELIAJBBEkgARAhIgJBj4CAAUtyDQFBAyEHIAJBBHYLIQIgAEHw4gFqIAEgB2otAAAgAkEgahAQIQEgACACNgKA4gEgACABNgLw4QEgB0EBaiEHCyAHC0sAIABC+erQ0OfJoeThADcDICAAQgA3AxggAELP1tO+0ser2UI3AxAgAELW64Lu6v2J9eAANwMIIABCADcDACAAQShqQQBBKBAQGgviAgICfwV+IABBKGoiASAAKAJIaiECAn4gACkDACIDQiBaBEAgACkDECIEQgeJIAApAwgiBUIBiXwgACkDGCIGQgyJfCAAKQMgIgdCEol8IAUQGSAEEBkgBhAZIAcQGQwBCyAAKQMYQsXP2bLx5brqJ3wLIAN8IQMDQCABQQhqIgAgAk0EQEIAIAEpAAAQCSADhUIbiUKHla+vmLbem55/fkLj3MqV/M7y9YV/fCEDIAAhAQwBCwsCQCABQQRqIgAgAksEQCABIQAMAQsgASgAAK1Ch5Wvr5i23puef34gA4VCF4lCz9bTvtLHq9lCfkL5893xmfaZqxZ8IQMLA0AgACACSQRAIAAxAABCxc/ZsvHluuonfiADhUILiUKHla+vmLbem55/fiEDIABBAWohAAwBCwsgA0IhiCADhULP1tO+0ser2UJ+IgNCHYggA4VC+fPd8Zn2masWfiIDQiCIIAOFC+8CAgJ/BH4gACAAKQMAIAKtfDcDAAJAAkAgACgCSCIDIAJqIgRBH00EQCABRQ0BIAAgA2pBKGogASACECAgACgCSCACaiEEDAELIAEgAmohAgJ/IAMEQCAAQShqIgQgA2ogAUEgIANrECAgACAAKQMIIAQpAAAQCTcDCCAAIAApAxAgACkAMBAJNwMQIAAgACkDGCAAKQA4EAk3AxggACAAKQMgIABBQGspAAAQCTcDICAAKAJIIQMgAEEANgJIIAEgA2tBIGohAQsgAUEgaiACTQsEQCACQWBqIQMgACkDICEFIAApAxghBiAAKQMQIQcgACkDCCEIA0AgCCABKQAAEAkhCCAHIAEpAAgQCSEHIAYgASkAEBAJIQYgBSABKQAYEAkhBSABQSBqIgEgA00NAAsgACAFNwMgIAAgBjcDGCAAIAc3AxAgACAINwMICyABIAJPDQEgAEEoaiABIAIgAWsiBBAgCyAAIAQ2AkgLCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQEBogAwVBun8LCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQCxogAwVBun8LC6gCAQZ/IwBBEGsiByQAIABB2OABaikDAEKAgIAQViEIQbh/IQUCQCAEQf//B0sNACAAIAMgBBBCIgUQAyIGDQAgACgCnOIBIQkgACAHQQxqIAMgAyAFaiAGGyIKIARBACAFIAYbayIGEEAiAxADBEAgAyEFDAELIAcoAgwhBCABRQRAQbp/IQUgBEEASg0BCyAGIANrIQUgAyAKaiEDAkAgCQRAIABBADYCnOIBDAELAkACQAJAIARBBUgNACAAQdjgAWopAwBCgICACFgNAAwBCyAAQQA2ApziAQwBCyAAKAIIED8hBiAAQQA2ApziASAGQRRPDQELIAAgASACIAMgBSAEIAgQOSEFDAELIAAgASACIAMgBSAEIAgQOiEFCyAHQRBqJAAgBQtnACAAQdDgAWogASACIAAoAuzhARAuIgEQAwRAIAEPC0G4fyECAkAgAQ0AIABB7OABaigCACIBBEBBYCECIAAoApjiASABRw0BC0EAIQIgAEHw4AFqKAIARQ0AIABBkOEBahBDCyACCycBAX8QVyIERQRAQUAPCyAEIAAgASACIAMgBBBLEE8hACAEEFYgAAs/AQF/AkACQAJAIAAoAqDiAUEBaiIBQQJLDQAgAUEBaw4CAAECCyAAEDBBAA8LIABBADYCoOIBCyAAKAKU4gELvAMCB38BfiMAQRBrIgkkAEG4fyEGAkAgBCgCACIIQQVBCSAAKALs4QEiBRtJDQAgAygCACIHQQFBBSAFGyAFEC8iBRADBEAgBSEGDAELIAggBUEDakkNACAAIAcgBRBJIgYQAw0AIAEgAmohCiAAQZDhAWohCyAIIAVrIQIgBSAHaiEHIAEhBQNAIAcgAiAJECwiBhADDQEgAkF9aiICIAZJBEBBuH8hBgwCCyAJKAIAIghBAksEQEFsIQYMAgsgB0EDaiEHAn8CQAJAAkAgCEEBaw4CAgABCyAAIAUgCiAFayAHIAYQSAwCCyAFIAogBWsgByAGEEcMAQsgBSAKIAVrIActAAAgCSgCCBBGCyIIEAMEQCAIIQYMAgsgACgC8OABBEAgCyAFIAgQRQsgAiAGayECIAYgB2ohByAFIAhqIQUgCSgCBEUNAAsgACkD0OABIgxCf1IEQEFsIQYgDCAFIAFrrFINAQsgACgC8OABBEBBaiEGIAJBBEkNASALEEQhDCAHKAAAIAynRw0BIAdBBGohByACQXxqIQILIAMgBzYCACAEIAI2AgAgBSABayEGCyAJQRBqJAAgBgsuACAAECsCf0EAQQAQAw0AGiABRSACRXJFBEBBYiAAIAEgAhA9EAMNARoLQQALCzcAIAEEQCAAIAAoAsTgASABKAIEIAEoAghqRzYCnOIBCyAAECtBABADIAFFckUEQCAAIAEQWwsL0QIBB38jAEEQayIGJAAgBiAENgIIIAYgAzYCDCAFBEAgBSgCBCEKIAUoAgghCQsgASEIAkACQANAIAAoAuzhARAWIQsCQANAIAQgC0kNASADKAAAQXBxQdDUtMIBRgRAIAMgBBAiIgcQAw0EIAQgB2shBCADIAdqIQMMAQsLIAYgAzYCDCAGIAQ2AggCQCAFBEAgACAFEE5BACEHQQAQA0UNAQwFCyAAIAogCRBNIgcQAw0ECyAAIAgQUCAMQQFHQQAgACAIIAIgBkEMaiAGQQhqEEwiByIDa0EAIAMQAxtBCkdyRQRAQbh/IQcMBAsgBxADDQMgAiAHayECIAcgCGohCEEBIQwgBigCDCEDIAYoAgghBAwBCwsgBiADNgIMIAYgBDYCCEG4fyEHIAQNASAIIAFrIQcMAQsgBiADNgIMIAYgBDYCCAsgBkEQaiQAIAcLRgECfyABIAAoArjgASICRwRAIAAgAjYCxOABIAAgATYCuOABIAAoArzgASEDIAAgATYCvOABIAAgASADIAJrajYCwOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEEdCAAbiECCyAAQQh2IgEgAkEYbCIAQYwIaigCAGwgAEGICGooAgBqIgJBA3YgAmogAEGACGooAgAgAEGECGooAgAgAWxqSQs3ACAAIAMgBCAFQYAQEDMiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQMgVBuH8LC78DAQN/IwBBIGsiBSQAIAVBCGogAiADEAYiAhADRQRAIAAgAWoiB0F9aiEGIAUgBBAOIARBBGohAiAFLQACIQMDQEEAIAAgBkkgBUEIahAEGwRAIAAgAiAFQQhqIAMQAkECdGoiBC8BADsAACAFQQhqIAQtAAIQASAAIAQtAANqIgQgAiAFQQhqIAMQAkECdGoiAC8BADsAACAFQQhqIAAtAAIQASAEIAAtAANqIQAMAQUgB0F+aiEEA0AgBUEIahAEIAAgBEtyRQRAIAAgAiAFQQhqIAMQAkECdGoiBi8BADsAACAFQQhqIAYtAAIQASAAIAYtAANqIQAMAQsLA0AgACAES0UEQCAAIAIgBUEIaiADEAJBAnRqIgYvAQA7AAAgBUEIaiAGLQACEAEgACAGLQADaiEADAELCwJAIAAgB08NACAAIAIgBUEIaiADEAIiA0ECdGoiAC0AADoAACAALQADQQFGBEAgBUEIaiAALQACEAEMAQsgBSgCDEEfSw0AIAVBCGogAiADQQJ0ai0AAhABIAUoAgxBIUkNACAFQSA2AgwLIAFBbCAFQQhqEAobIQILCwsgBUEgaiQAIAILkgIBBH8jAEFAaiIJJAAgCSADQTQQCyEDAkAgBEECSA0AIAMgBEECdGooAgAhCSADQTxqIAgQIyADQQE6AD8gAyACOgA+QQAhBCADKAI8IQoDQCAEIAlGDQEgACAEQQJ0aiAKNgEAIARBAWohBAwAAAsAC0EAIQkDQCAGIAlGRQRAIAMgBSAJQQF0aiIKLQABIgtBAnRqIgwoAgAhBCADQTxqIAotAABBCHQgCGpB//8DcRAjIANBAjoAPyADIAcgC2siCiACajoAPiAEQQEgASAKa3RqIQogAygCPCELA0AgACAEQQJ0aiALNgEAIARBAWoiBCAKSQ0ACyAMIAo2AgAgCUEBaiEJDAELCyADQUBrJAALowIBCX8jAEHQAGsiCSQAIAlBEGogBUE0EAsaIAcgBmshDyAHIAFrIRADQAJAIAMgCkcEQEEBIAEgByACIApBAXRqIgYtAAEiDGsiCGsiC3QhDSAGLQAAIQ4gCUEQaiAMQQJ0aiIMKAIAIQYgCyAPTwRAIAAgBkECdGogCyAIIAUgCEE0bGogCCAQaiIIQQEgCEEBShsiCCACIAQgCEECdGooAgAiCEEBdGogAyAIayAHIA4QYyAGIA1qIQgMAgsgCUEMaiAOECMgCUEBOgAPIAkgCDoADiAGIA1qIQggCSgCDCELA0AgBiAITw0CIAAgBkECdGogCzYBACAGQQFqIQYMAAALAAsgCUHQAGokAA8LIAwgCDYCACAKQQFqIQoMAAALAAs0ACAAIAMgBCAFEDYiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQNAVBuH8LCyMAIAA/AEEQdGtB//8DakEQdkAAQX9GBEBBAA8LQQAQAEEBCzsBAX8gAgRAA0AgACABIAJBgCAgAkGAIEkbIgMQCyEAIAFBgCBqIQEgAEGAIGohACACIANrIgINAAsLCwYAIAAQAwsLqBUJAEGICAsNAQAAAAEAAAACAAAAAgBBoAgLswYBAAAAAQAAAAIAAAACAAAAJgAAAIIAAAAhBQAASgAAAGcIAAAmAAAAwAEAAIAAAABJBQAASgAAAL4IAAApAAAALAIAAIAAAABJBQAASgAAAL4IAAAvAAAAygIAAIAAAACKBQAASgAAAIQJAAA1AAAAcwMAAIAAAACdBQAASgAAAKAJAAA9AAAAgQMAAIAAAADrBQAASwAAAD4KAABEAAAAngMAAIAAAABNBgAASwAAAKoKAABLAAAAswMAAIAAAADBBgAATQAAAB8NAABNAAAAUwQAAIAAAAAjCAAAUQAAAKYPAABUAAAAmQQAAIAAAABLCQAAVwAAALESAABYAAAA2gQAAIAAAABvCQAAXQAAACMUAABUAAAARQUAAIAAAABUCgAAagAAAIwUAABqAAAArwUAAIAAAAB2CQAAfAAAAE4QAAB8AAAA0gIAAIAAAABjBwAAkQAAAJAHAACSAAAAAAAAAAEAAAABAAAABQAAAA0AAAAdAAAAPQAAAH0AAAD9AAAA/QEAAP0DAAD9BwAA/Q8AAP0fAAD9PwAA/X8AAP3/AAD9/wEA/f8DAP3/BwD9/w8A/f8fAP3/PwD9/38A/f//AP3//wH9//8D/f//B/3//w/9//8f/f//P/3//38AAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABEAAAASAAAAEwAAABQAAAAVAAAAFgAAABcAAAAYAAAAGQAAABoAAAAbAAAAHAAAAB0AAAAeAAAAHwAAAAMAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAAAAwAAAANAAAADgAAAA8AAAAQAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAZAAAAGgAAABsAAAAcAAAAHQAAAB4AAAAfAAAAIAAAACEAAAAiAAAAIwAAACUAAAAnAAAAKQAAACsAAAAvAAAAMwAAADsAAABDAAAAUwAAAGMAAACDAAAAAwEAAAMCAAADBAAAAwgAAAMQAAADIAAAA0AAAAOAAAADAAEAQeAPC1EBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAEAAAABQAAAAcAAAAIAAAACQAAAAoAAAALAAAADAAAAA0AAAAOAAAADwAAABAAQcQQC4sBAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABIAAAAUAAAAFgAAABgAAAAcAAAAIAAAACgAAAAwAAAAQAAAAIAAAAAAAQAAAAIAAAAEAAAACAAAABAAAAAgAAAAQAAAAIAAAAAAAQBBkBIL5gQBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAAAEAAAAEAAAACAAAAAAAAAABAAEBBgAAAAAAAAQAAAAAEAAABAAAAAAgAAAFAQAAAAAAAAUDAAAAAAAABQQAAAAAAAAFBgAAAAAAAAUHAAAAAAAABQkAAAAAAAAFCgAAAAAAAAUMAAAAAAAABg4AAAAAAAEFEAAAAAAAAQUUAAAAAAABBRYAAAAAAAIFHAAAAAAAAwUgAAAAAAAEBTAAAAAgAAYFQAAAAAAABwWAAAAAAAAIBgABAAAAAAoGAAQAAAAADAYAEAAAIAAABAAAAAAAAAAEAQAAAAAAAAUCAAAAIAAABQQAAAAAAAAFBQAAACAAAAUHAAAAAAAABQgAAAAgAAAFCgAAAAAAAAULAAAAAAAABg0AAAAgAAEFEAAAAAAAAQUSAAAAIAABBRYAAAAAAAIFGAAAACAAAwUgAAAAAAADBSgAAAAAAAYEQAAAABAABgRAAAAAIAAHBYAAAAAAAAkGAAIAAAAACwYACAAAMAAABAAAAAAQAAAEAQAAACAAAAUCAAAAIAAABQMAAAAgAAAFBQAAACAAAAUGAAAAIAAABQgAAAAgAAAFCQAAACAAAAULAAAAIAAABQwAAAAAAAAGDwAAACAAAQUSAAAAIAABBRQAAAAgAAIFGAAAACAAAgUcAAAAIAADBSgAAAAgAAQFMAAAAAAAEAYAAAEAAAAPBgCAAAAAAA4GAEAAAAAADQYAIABBgBcLhwIBAAEBBQAAAAAAAAUAAAAAAAAGBD0AAAAAAAkF/QEAAAAADwX9fwAAAAAVBf3/HwAAAAMFBQAAAAAABwR9AAAAAAAMBf0PAAAAABIF/f8DAAAAFwX9/38AAAAFBR0AAAAAAAgE/QAAAAAADgX9PwAAAAAUBf3/DwAAAAIFAQAAABAABwR9AAAAAAALBf0HAAAAABEF/f8BAAAAFgX9/z8AAAAEBQ0AAAAQAAgE/QAAAAAADQX9HwAAAAATBf3/BwAAAAEFAQAAABAABgQ9AAAAAAAKBf0DAAAAABAF/f8AAAAAHAX9//8PAAAbBf3//wcAABoF/f//AwAAGQX9//8BAAAYBf3//wBBkBkLhgQBAAEBBgAAAAAAAAYDAAAAAAAABAQAAAAgAAAFBQAAAAAAAAUGAAAAAAAABQgAAAAAAAAFCQAAAAAAAAULAAAAAAAABg0AAAAAAAAGEAAAAAAAAAYTAAAAAAAABhYAAAAAAAAGGQAAAAAAAAYcAAAAAAAABh8AAAAAAAAGIgAAAAAAAQYlAAAAAAABBikAAAAAAAIGLwAAAAAAAwY7AAAAAAAEBlMAAAAAAAcGgwAAAAAACQYDAgAAEAAABAQAAAAAAAAEBQAAACAAAAUGAAAAAAAABQcAAAAgAAAFCQAAAAAAAAUKAAAAAAAABgwAAAAAAAAGDwAAAAAAAAYSAAAAAAAABhUAAAAAAAAGGAAAAAAAAAYbAAAAAAAABh4AAAAAAAAGIQAAAAAAAQYjAAAAAAABBicAAAAAAAIGKwAAAAAAAwYzAAAAAAAEBkMAAAAAAAUGYwAAAAAACAYDAQAAIAAABAQAAAAwAAAEBAAAABAAAAQFAAAAIAAABQcAAAAgAAAFCAAAACAAAAUKAAAAIAAABQsAAAAAAAAGDgAAAAAAAAYRAAAAAAAABhQAAAAAAAAGFwAAAAAAAAYaAAAAAAAABh0AAAAAAAAGIAAAAAAAEAYDAAEAAAAPBgOAAAAAAA4GA0AAAAAADQYDIAAAAAAMBgMQAAAAAAsGAwgAAAAACgYDBABBpB0L2QEBAAAAAwAAAAcAAAAPAAAAHwAAAD8AAAB/AAAA/wAAAP8BAAD/AwAA/wcAAP8PAAD/HwAA/z8AAP9/AAD//wAA//8BAP//AwD//wcA//8PAP//HwD//z8A//9/AP///wD///8B////A////wf///8P////H////z////9/AAAAAAEAAAACAAAABAAAAAAAAAACAAAABAAAAAgAAAAAAAAAAQAAAAIAAAABAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAACAAAAAcAAAAIAAAACQAAAAoAAAALAEGgIAsDwBBQ",t_=new WeakMap;let e_,n_=0;class i_ extends dh{constructor(t){super(t),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new Iy,this.workerSourceURL="",this.workerConfig=null,"undefined"!=typeof MSC_TRANSCODER&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(t){return this.transcoderPath=t,this}setWorkerLimit(t){return this.workerPool.setWorkerLimit(t),this}async detectSupportAsync(t){return this.workerConfig={astcSupported:await t.hasFeatureAsync("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:await t.hasFeatureAsync("texture-compression-etc1"),etc2Supported:await t.hasFeatureAsync("texture-compression-etc2"),dxtSupported:await t.hasFeatureAsync("texture-compression-bc"),bptcSupported:await t.hasFeatureAsync("texture-compression-bptc"),pvrtcSupported:await t.hasFeatureAsync("texture-compression-pvrtc")},this}detectSupport(t){return!0===t.isWebGPURenderer?this.workerConfig={astcSupported:t.hasFeature("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:t.hasFeature("texture-compression-etc1"),etc2Supported:t.hasFeature("texture-compression-etc2"),dxtSupported:t.hasFeature("texture-compression-bc"),bptcSupported:t.hasFeature("texture-compression-bptc"),pvrtcSupported:t.hasFeature("texture-compression-pvrtc")}:this.workerConfig={astcSupported:t.extensions.has("WEBGL_compressed_texture_astc"),astcHDRSupported:t.extensions.has("WEBGL_compressed_texture_astc")&&t.extensions.get("WEBGL_compressed_texture_astc").getSupportedProfiles().includes("hdr"),etc1Supported:t.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:t.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:t.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:t.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:t.extensions.has("WEBGL_compressed_texture_pvrtc")||t.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},this}init(){if(!this.transcoderPending){const t=new mh(this.manager);t.setPath(this.transcoderPath),t.setWithCredentials(this.withCredentials);const e=t.loadAsync("basis_transcoder.js"),n=new mh(this.manager);n.setPath(this.transcoderPath),n.setResponseType("arraybuffer"),n.setWithCredentials(this.withCredentials);const i=n.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([e,i]).then((([t,e])=>{const n=i_.BasisWorker.toString(),i=["/* constants */","let _EngineFormat = "+JSON.stringify(i_.EngineFormat),"let _EngineType = "+JSON.stringify(i_.EngineType),"let _TranscoderFormat = "+JSON.stringify(i_.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(i_.BasisFormat),"/* basis_transcoder.js */",t,"/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i])),this.transcoderBinary=e,this.workerPool.setWorkerCreator((()=>{const t=new Worker(this.workerSourceURL),e=this.transcoderBinary.slice(0);return t.postMessage({type:"init",config:this.workerConfig,transcoderBinary:e},[e]),t}))})),n_>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),n_++}return this.transcoderPending}load(t,e,n,i){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const r=new mh(this.manager);r.setResponseType("arraybuffer"),r.setWithCredentials(this.withCredentials),r.load(t,(t=>{this.parse(t,e,i)}),n,i)}parse(t,e,n){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if(t_.has(t))return t_.get(t).promise.then(e).catch(n);this._createTexture(t).then((t=>e?e(t):null)).catch(n)}_createTextureFrom(t,e){const{type:n,error:i,data:{faces:r,width:s,height:a,format:o,type:l,dfdFlags:c}}=t;if("error"===n)return Promise.reject(i);let h;if(6===e.faceCount)h=new sl(r,o,l);else{const t=r[0].mipmaps;h=e.layerCount>1?new rl(t,s,a,e.layerCount,o,l):new il(t,s,a,o,l)}return h.minFilter=1===r[0].mipmaps.length?Lt:Ft,h.magFilter=Lt,h.generateMipmaps=!1,h.needsUpdate=!0,h.colorSpace=o_(e),h.premultiplyAlpha=!!(1&c),h}async _createTexture(t,e={}){const n=function(t){const e=new Uint8Array(t.buffer,t.byteOffset,jy.length);if(e[0]!==jy[0]||e[1]!==jy[1]||e[2]!==jy[2]||e[3]!==jy[3]||e[4]!==jy[4]||e[5]!==jy[5]||e[6]!==jy[6]||e[7]!==jy[7]||e[8]!==jy[8]||e[9]!==jy[9]||e[10]!==jy[10]||e[11]!==jy[11])throw new Error("Missing KTX 2.0 identifier.");const n=new Vy,i=17*Uint32Array.BYTES_PER_ELEMENT,r=new Wy(t,jy.length,i,!0);n.vkFormat=r._nextUint32(),n.typeSize=r._nextUint32(),n.pixelWidth=r._nextUint32(),n.pixelHeight=r._nextUint32(),n.pixelDepth=r._nextUint32(),n.layerCount=r._nextUint32(),n.faceCount=r._nextUint32();const s=r._nextUint32();n.supercompressionScheme=r._nextUint32();const a=r._nextUint32(),o=r._nextUint32(),l=r._nextUint32(),c=r._nextUint32(),h=r._nextUint64(),u=r._nextUint64(),d=new Wy(t,jy.length+i,3*s*8,!0);for(let e=0;e{const e=new Zy;await e.init(),t(e)}))),n=await e_);const i=[];for(let r=0;r>r),a=Math.max(1,t.pixelHeight>>r),o=t.pixelDepth?Math.max(1,t.pixelDepth>>r):0,l=t.levels[r];let c,h;if(0===t.supercompressionScheme)c=l.levelData;else{if(2!==t.supercompressionScheme)throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");c=n.decode(l.levelData,l.uncompressedByteLength)}h=a_[e]===Wt?new Float32Array(c.buffer,c.byteOffset,c.byteLength/Float32Array.BYTES_PER_ELEMENT):a_[e]===jt?new Uint16Array(c.buffer,c.byteOffset,c.byteLength/Uint16Array.BYTES_PER_ELEMENT):c,i.push({data:h,width:s,height:a,depth:o})}let r;if(r_.has(s_[e]))r=0===t.pixelDepth?new Xa(i[0].data,t.pixelWidth,t.pixelHeight):new Fi(i[0].data,t.pixelWidth,t.pixelHeight,t.pixelDepth);else{if(t.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");r=new il(i,t.pixelWidth,t.pixelHeight),r.minFilter=1===i.length?Lt:Ft,r.magFilter=Lt}return r.mipmaps=i,r.type=a_[e],r.format=s_[e],r.colorSpace=o_(t),r.needsUpdate=!0,Promise.resolve(r)}(n);const r=e,s=this.init().then((()=>this.workerPool.postMessage({type:"transcode",buffer:t,taskConfig:r},[t]))).then((t=>this._createTextureFrom(t.data,n)));return t_.set(t,{promise:s}),s}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),n_--,this}}i_.BasisFormat={ETC1S:0,UASTC:1,UASTC_HDR:2},i_.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16,BC6H:22,RGB_HALF:24,RGBA_HALF:25},i_.EngineFormat={RGBAFormat:$t,RGBA_ASTC_4x4_Format:xe,RGB_BPTC_UNSIGNED_Format:Fe,RGBA_BPTC_Format:Ue,RGBA_ETC2_EAC_Format:_e,RGBA_PVRTC_4BPPV1_Format:ge,RGBA_S3TC_DXT5_Format:pe,RGB_ETC1_Format:ve,RGB_ETC2_Format:ye,RGB_PVRTC_4BPPV1_Format:fe,RGBA_S3TC_DXT1_Format:ue},i_.EngineType={UnsignedByteType:kt,HalfFloatType:jt,FloatType:Wt},i_.BasisWorker=function(){let t,e,n;const i=_EngineFormat,r=_EngineType,s=_TranscoderFormat,a=_BasisFormat;self.addEventListener("message",(function(i){const s=i.data;switch(s.type){case"init":t=s.config,o=s.transcoderBinary,e=new Promise((t=>{n={wasmBinary:o,onRuntimeInitialized:t},BASIS(n)})).then((()=>{n.initializeBasis(),void 0===n.KTX2File&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")}));break;case"transcode":e.then((()=>{try{const{faces:e,buffers:i,width:o,height:u,hasAlpha:d,format:p,type:f,dfdFlags:m}=function(e){const i=new n.KTX2File(new Uint8Array(e));function s(){i.close(),i.delete()}if(!i.isValid())throw s(),new Error("THREE.KTX2Loader:\tInvalid or unsupported .ktx2 file");let o;if(i.isUASTC())o=a.UASTC;else if(i.isETC1S())o=a.ETC1S;else{if(!i.isHDR())throw new Error("THREE.KTX2Loader: Unknown Basis encoding");o=a.UASTC_HDR}const u=i.getWidth(),d=i.getHeight(),p=i.getLayers()||1,f=i.getLevels(),m=i.getFaces(),g=i.getHasAlpha(),A=i.getDFDFlags(),{transcoderFormat:v,engineFormat:y,engineType:_}=function(e,n,i,r){const s=l[e];for(let a=0;a1?(o=c.origWidth,l=c.origHeight):(o=c.width,l=c.height);let h=new Uint8Array(i.getImageTranscodedSizeInBytes(n,e,0,v));const u=i.transcodeImage(h,n,e,t,v,0,-1,-1);if(_===r.HalfFloatType&&(h=new Uint16Array(h.buffer,h.byteOffset,h.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!u)throw s(),new Error("THREE.KTX2Loader: .transcodeImage failed.");a.push(h)}const c=h(a);e.push({data:c,width:o,height:l}),w.push(c.buffer)}x.push({mipmaps:e,width:u,height:d,format:y,type:_})}return s(),{faces:x,buffers:w,width:u,height:d,hasAlpha:g,dfdFlags:A,format:y,type:_}}(s.buffer);self.postMessage({type:"transcode",id:s.id,data:{faces:e,width:o,height:u,hasAlpha:d,format:p,type:f,dfdFlags:m}},i)}catch(t){console.error(t),self.postMessage({type:"error",id:s.id,error:t.message})}}))}var o}));const o=[{if:"astcSupported",basisFormat:[a.UASTC],transcoderFormat:[s.ASTC_4x4,s.ASTC_4x4],engineFormat:[i.RGBA_ASTC_4x4_Format,i.RGBA_ASTC_4x4_Format],engineType:[r.UnsignedByteType],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.BC7_M5,s.BC7_M5],engineFormat:[i.RGBA_BPTC_Format,i.RGBA_BPTC_Format],engineType:[r.UnsignedByteType],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.BC1,s.BC3],engineFormat:[i.RGBA_S3TC_DXT1_Format,i.RGBA_S3TC_DXT5_Format],engineType:[r.UnsignedByteType],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.ETC1,s.ETC2],engineFormat:[i.RGB_ETC2_Format,i.RGBA_ETC2_EAC_Format],engineType:[r.UnsignedByteType],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.ETC1],engineFormat:[i.RGB_ETC1_Format],engineType:[r.UnsignedByteType],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.PVRTC1_4_RGB,s.PVRTC1_4_RGBA],engineFormat:[i.RGB_PVRTC_4BPPV1_Format,i.RGBA_PVRTC_4BPPV1_Format],engineType:[r.UnsignedByteType],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0},{if:"bptcSupported",basisFormat:[a.UASTC_HDR],transcoderFormat:[s.BC6H],engineFormat:[i.RGB_BPTC_UNSIGNED_Format],engineType:[r.HalfFloatType],priorityHDR:1,needsPowerOfTwo:!1},{basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.RGBA32,s.RGBA32],engineFormat:[i.RGBAFormat,i.RGBAFormat],engineType:[r.UnsignedByteType,r.UnsignedByteType],priorityETC1S:100,priorityUASTC:100,needsPowerOfTwo:!1},{basisFormat:[a.UASTC_HDR],transcoderFormat:[s.RGBA_HALF],engineFormat:[i.RGBAFormat],engineType:[r.HalfFloatType],priorityHDR:100,needsPowerOfTwo:!1}],l={[a.ETC1S]:o.filter((t=>t.basisFormat.includes(a.ETC1S))).sort(((t,e)=>t.priorityUASTC-e.priorityUASTC)),[a.UASTC]:o.filter((t=>t.basisFormat.includes(a.UASTC))).sort(((t,e)=>t.priorityUASTC-e.priorityUASTC)),[a.UASTC_HDR]:o.filter((t=>t.basisFormat.includes(a.UASTC_HDR))).sort(((t,e)=>t.priorityHDR-e.priorityHDR))};function c(t){return t<=2||!(t&t-1)&&0!==t}function h(t){if(1===t.length)return t[0];let e=0;for(let n=0;nt&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Y"===i.name&&Math.abs(E_.copy(D_).applyQuaternion(e).dot(this.eye))>t&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Z"===i.name&&Math.abs(E_.copy(P_).applyQuaternion(e).dot(this.eye))>t&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"XY"===i.name&&Math.abs(E_.copy(P_).applyQuaternion(e).dot(this.eye)).9&&(i.visible=!1)),"Y"===this.axis&&(u_.setFromEuler(C_.set(0,0,Math.PI/2)),i.quaternion.copy(e).multiply(u_),Math.abs(E_.copy(D_).applyQuaternion(e).dot(this.eye))>.9&&(i.visible=!1)),"Z"===this.axis&&(u_.setFromEuler(C_.set(0,Math.PI/2,0)),i.quaternion.copy(e).multiply(u_),Math.abs(E_.copy(P_).applyQuaternion(e).dot(this.eye))>.9&&(i.visible=!1)),"XYZE"===this.axis&&(u_.setFromEuler(C_.set(0,Math.PI/2,0)),E_.copy(this.rotationAxis),i.quaternion.setFromRotationMatrix(S_.lookAt(M_,E_,D_)),i.quaternion.multiply(u_),i.visible=this.dragging),"E"===this.axis&&(i.visible=!1)):"START"===i.name?(i.position.copy(this.worldPositionStart),i.visible=this.dragging):"END"===i.name?(i.position.copy(this.worldPosition),i.visible=this.dragging):"DELTA"===i.name?(i.position.copy(this.worldPositionStart),i.quaternion.copy(this.worldQuaternionStart),c_.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),c_.applyQuaternion(this.worldQuaternionStart.clone().invert()),i.scale.copy(c_),i.visible=this.dragging):(i.quaternion.copy(e),this.dragging?i.position.copy(this.worldPositionStart):i.position.copy(this.worldPosition),this.axis&&(i.visible=-1!==this.axis.search(i.name)))}super.updateMatrixWorld(t)}}class k_ extends Ys{constructor(){super(new _c(1e5,1e5,2,2),new ds({visible:!1,wireframe:!0,side:S,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(t){let e=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(e="local"),L_.copy(R_).applyQuaternion("local"===e?this.worldQuaternion:I_),U_.copy(D_).applyQuaternion("local"===e?this.worldQuaternion:I_),N_.copy(P_).applyQuaternion("local"===e?this.worldQuaternion:I_),E_.copy(U_),this.mode){case"translate":case"scale":switch(this.axis){case"X":E_.copy(this.eye).cross(L_),T_.copy(L_).cross(E_);break;case"Y":E_.copy(this.eye).cross(U_),T_.copy(U_).cross(E_);break;case"Z":E_.copy(this.eye).cross(N_),T_.copy(N_).cross(E_);break;case"XY":T_.copy(N_);break;case"YZ":T_.copy(L_);break;case"XZ":E_.copy(N_),T_.copy(U_);break;case"XYZ":case"E":T_.set(0,0,0)}break;default:T_.set(0,0,0)}0===T_.length()?this.quaternion.copy(this.cameraQuaternion):(B_.lookAt(c_.set(0,0,0),T_,E_),this.quaternion.setFromRotationMatrix(B_)),super.updateMatrixWorld(t)}}const Q_="csm_DiffuseColor",z_="csm_Roughness",G_="csm_Metalness",H_="csm_Emissive",V_="csm_AO",W_="csm_Bump",j_="csm_FragNormal",q_="csm_Clearcoat",X_="csm_ClearcoatRoughness",Y_="csm_ClearcoatNormal",J_="csm_Transmission",K_="csm_Thickness",Z_="csm_Iridescence",$_="csm_PointSize",tx="csm_FragColor",ex="csm_DepthAlpha",nx="csm_UnlitFac",ix="csm_Position",rx="csm_PositionRaw",sx="csm_Normal",ax={[`${ix}`]:"*",[`${rx}`]:"*",[`${sx}`]:"*",[`${ex}`]:"*",[`${$_}`]:["PointsMaterial"],[`${Q_}`]:"*",[`${tx}`]:"*",[`${j_}`]:"*",[`${nx}`]:"*",[`${H_}`]:["MeshStandardMaterial","MeshPhysicalMaterial"],[`${z_}`]:["MeshStandardMaterial","MeshPhysicalMaterial"],[`${G_}`]:["MeshStandardMaterial","MeshPhysicalMaterial"],[`${Z_}`]:["MeshStandardMaterial","MeshPhysicalMaterial"],[`${V_}`]:["MeshStandardMaterial","MeshPhysicalMaterial","MeshBasicMaterial","MeshLambertMaterial","MeshPhongMaterial","MeshToonMaterial"],[`${W_}`]:["MeshLambertMaterial","MeshMatcapMaterial","MeshNormalMaterial","MeshPhongMaterial","MeshPhysicalMaterial","MeshStandardMaterial","MeshToonMaterial","ShadowMaterial"],[`${q_}`]:["MeshPhysicalMaterial"],[`${X_}`]:["MeshPhysicalMaterial"],[`${Y_}`]:["MeshPhysicalMaterial"],[`${J_}`]:["MeshPhysicalMaterial"],[`${K_}`]:["MeshPhysicalMaterial"]},ox={"*":{"#include ":Pd.lights_physical_fragment,"#include ":Pd.transmission_fragment},[`${sx}`]:{"#include ":`\n vec3 objectNormal = ${sx};\n #ifdef USE_TANGENT\n\t vec3 objectTangent = vec3( tangent.xyz );\n #endif\n `},[`${ix}`]:{"#include ":`\n vec3 transformed = ${ix};\n `},[`${rx}`]:{"#include ":`\n vec4 csm_internal_positionUnprojected = ${rx};\n mat4x4 csm_internal_unprojectMatrix = projectionMatrix * modelViewMatrix;\n #ifdef USE_INSTANCING\n csm_internal_unprojectMatrix = csm_internal_unprojectMatrix * instanceMatrix;\n #endif\n csm_internal_positionUnprojected = inverse(csm_internal_unprojectMatrix) * csm_internal_positionUnprojected;\n vec3 transformed = csm_internal_positionUnprojected.xyz;\n `},[`${$_}`]:{"gl_PointSize = size;":`\n gl_PointSize = ${$_};\n `},[`${Q_}`]:{"#include ":`\n #include \n diffuseColor = ${Q_};\n `},[`${tx}`]:{"#include ":`\n #include \n gl_FragColor = mix(gl_FragColor, ${tx}, ${nx});\n `},[`${H_}`]:{"vec3 totalEmissiveRadiance = emissive;":`\n vec3 totalEmissiveRadiance = ${H_};\n `},[`${z_}`]:{"#include ":`\n #include \n roughnessFactor = ${z_};\n `},[`${G_}`]:{"#include ":`\n #include \n metalnessFactor = ${G_};\n `},[`${V_}`]:{"#include ":`\n #include \n reflectedLight.indirectDiffuse *= 1. - ${V_};\n `},[`${W_}`]:{"#include ":`\n #include \n\n vec3 csm_internal_orthogonal = ${W_} - (dot(${W_}, normal) * normal);\n vec3 csm_internal_projectedbump = mat3(csm_internal_vModelViewMatrix) * csm_internal_orthogonal;\n normal = normalize(normal - csm_internal_projectedbump);\n `},[`${j_}`]:{"#include ":`\n #include \n normal = ${j_};\n `},[`${ex}`]:{"gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );":`\n gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity * 1.0 - ${ex} );\n `,"gl_FragColor = packDepthToRGBA( fragCoordZ );":`\n if(${ex} < 1.0) discard;\n gl_FragColor = packDepthToRGBA( dist );\n `,"gl_FragColor = packDepthToRGBA( dist );":`\n if(${ex} < 1.0) discard;\n gl_FragColor = packDepthToRGBA( dist );\n `},[`${q_}`]:{"material.clearcoat = clearcoat;":`material.clearcoat = ${q_};`},[`${X_}`]:{"material.clearcoatRoughness = clearcoatRoughness;":`material.clearcoatRoughness = ${X_};`},[`${Y_}`]:{"#include ":"\n vec3 csm_coat_internal_orthogonal = csm_ClearcoatNormal - (dot(csm_ClearcoatNormal, nonPerturbedNormal) * nonPerturbedNormal);\n vec3 csm_coat_internal_projectedbump = mat3(csm_internal_vModelViewMatrix) * csm_coat_internal_orthogonal;\n vec3 clearcoatNormal = normalize(nonPerturbedNormal - csm_coat_internal_projectedbump);\n "},[`${J_}`]:{"material.transmission = transmission;":`\n material.transmission = ${J_};\n `},[`${K_}`]:{"material.thickness = thickness;":`\n material.thickness = ${K_};\n `},[`${Z_}`]:{"material.iridescence = iridescence;":`\n material.iridescence = ${Z_};\n `}},lx={clearcoat:[q_,Y_,X_],transmission:[J_],iridescence:[Z_]};function cx(t){return t.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,"")}const hx="row",ux="row-reverse",dx="column",px="column-reverse";function fx(t,e,n,i){let r=n,s="getWidth",a="x",o="y";0===e.indexOf(dx)&&(s="getHeight",a="y",o="x");for(let e=0;e{let o;switch(n){case Ax:case"right":case"bottom":o=0===e.indexOf(hx)?-s+a[i]()/2+(a.margin||0):s-a[i]()/2-(a.margin||0);break;case mx:case"left":case"top":o=0===e.indexOf(hx)?s-a[i]()/2-(a.margin||0):-s+a[i]()/2+(a.margin||0)}t.childrenPos[a.id][r]=o||0}))}function _x(t){-1!==wx.indexOf(t)&&console.warn(`alignItems === '${t}' is deprecated and will be remove in 7.x.x. Fallback are 'start'|'end'`)}const xx=[mx,gx,Ax,vx,"top","right","bottom","left"],wx=["top","right","bottom","left"],Cx="start",Ex="center",Mx="end",Sx="space-around",bx="space-between",Ix="space-evenly";function Tx(t,e,n,i){const r=t.getJustifyContent();-1===Bx.indexOf(r)&&console.warn(`justifyContent === '${r}' is not supported`);const s=0===e.indexOf("row")?"width":"height",a=t.getChildrenSideSum(s),o=("width"===s?t.getInnerWidth():t.getInnerHeight())-a,l=function(t,e){switch(t){case Mx:return e;case Ex:return e/2}return 0}(r,2*n-a*Math.sign(n)),c=function(t,e,n,i){const r=Array(t.length).fill(0);if(e>0)switch(n){case bx:if(t.length>1){const n=e/(t.length-1)*i;r[0]=0;for(let e=1;e1){const n=e/(t.length+1)*i;for(let e=0;e1){const n=e/t.length*i,s=n/2;r[0]=s;for(let e=1;e{t.childrenPos[e.id][h]-=l-c[n]}))}const Bx=[Cx,Ex,Mx,Sx,bx,Ix];function Rx(t){return class extends t{constructor(t){super(t),this.isBoxComponent=!0,this.childrenPos={}}getInnerWidth(){const t=this.getContentDirection();switch(t){case"row":case"row-reverse":return this.width-(2*this.padding||0)||this.getChildrenSideSum("width");case"column":case"column-reverse":return this.getHighestChildSizeOn("width");default:console.error(`Invalid contentDirection : ${t}`)}}getInnerHeight(){const t=this.getContentDirection();switch(t){case"row":case"row-reverse":return this.getHighestChildSizeOn("height");case"column":case"column-reverse":return this.height-(2*this.padding||0)||this.getChildrenSideSum("height");default:console.error(`Invalid contentDirection : ${t}`)}}getChildrenSideSum(t){return this.childrenBoxes.reduce(((e,n)=>{const i=2*n.margin||0;return e+("width"===t?n.getWidth()+i:n.getHeight()+i)}),0)}setPosFromParentRecords(){this.parentUI&&this.parentUI.childrenPos[this.id]&&(this.position.x=this.parentUI.childrenPos[this.id].x,this.position.y=this.parentUI.childrenPos[this.id].y)}computeChildrenPosition(){if(this.children.length>0){const t=this.getContentDirection();let e;switch(t){case hx:e=-this.getInnerWidth()/2;break;case ux:e=this.getInnerWidth()/2;break;case dx:e=this.getInnerHeight()/2;break;case px:e=-this.getInnerHeight()/2}const n=-Math.sign(e);fx(this,t,e,n),Tx(this,t,e,n),yx(this,t)}}getHighestChildSizeOn(t){return this.childrenBoxes.reduce(((e,n)=>{const i=n.margin||0,r="width"===t?n.getWidth()+2*i:n.getHeight()+2*i;return Math.max(e,r)}),0)}getWidth(){return this.parentUI&&"stretch"===this.parentUI.getAlignItems()&&-1!==this.parentUI.getContentDirection().indexOf("column")?this.parentUI.getWidth()-(2*this.parentUI.padding||0):this.width||this.getInnerWidth()+(2*this.padding||0)}getHeight(){return this.parentUI&&"stretch"===this.parentUI.getAlignItems()&&-1!==this.parentUI.getContentDirection().indexOf("row")?this.parentUI.getHeight()-(2*this.parentUI.padding||0):this.height||this.getInnerHeight()+(2*this.padding||0)}}}const Dx={"\t":"\t","\n":"\n","\r":"\r"," ":" "},Px="normal",Lx="nowrap",Ux="pre",Nx="pre-line",Fx="pre-wrap",Ox=function(t,e){switch(e){case Lx:case Px:t=t.replace(/\n/g," ");case Nx:t=t.replace(/[ ]{2,}/g," ")}return t},kx=function(t){switch(t){case Ux:case Fx:case Nx:return"mandatory"}},Qx=function(t,e,n,i){const r=t[e];switch(i.WHITESPACE){case Px:case Nx:case Fx:if("mandatory"===r.lineBreak)return!0;const s=r.kerning?r.kerning:0,a=r.xoffset?r.xoffset:0;if(n+(r.xadvance?r.xadvance:r.width)+a+s>i.INNER_WIDTH)return!0;const o=Vx(t,e,i);return function(t,e,n,i){return!(!t||!t.glyph)&&!(e+n-1}(t[e-1],n,o,i);case Ux:return"mandatory"===r.lineBreak;default:return!1}},zx=function(t,e){const n=t[0],i=t[t.length-1];switch(e){case Fx:n.glyph&&"\n"===n.glyph&&t.length>1&&Hx([n],t[1]),i.glyph&&"\n"===i.glyph&&t.length>1&&Gx([i],t[t.length-2]);break;case Nx:case Lx:case Px:let r,s=[];for(let e=0;ee))break;s.push(n),r=t[e+1]}Hx(s,r),s=[],r=null;for(let e=t.length-1;e>0;e--){const n=t[e];if(!(n.glyph&&Dx[n.glyph]&&e>0))break;s.push(n),r=t[e-1]}Gx(s,r);break;case Ux:break;default:return console.warn(`whiteSpace: '${e}' is not valid`),0}return n.offsetX};function Gx(t,e){if(e)for(let n=0;n{switch(e){case Yx:case Xx:case Wx:return-n/2;case Jx:case jx:return-t.width+n/2;case qx:return-t.width/2;case Kx:return i?-t.width/2:-n/2;default:console.warn(`textAlign: '${e}' is not valid`)}};function tw(t){return class extends t{computeInlinesPosition(){const t=this.getWidth()-(2*this.padding||0),e=this.getHeight()-(2*this.padding||0),n=this.getJustifyContent(),i=this.getTextAlign(),r=this.getInterLine(),s=this.computeLines();s.interLine=r;const a=Math.abs(s.height),o=(()=>{switch(n){case"start":return e/2;case"end":return a-e/2;case"center":return a/2;default:console.warn(`justifyContent: '${n}' is not valid`)}})();s.forEach((t=>{t.y+=o,t.forEach((t=>{t.offsetY+=o}))})),Zx(s,i,t),this.lines=s}calculateBestFit(t){if(0!==this.childrenInlines.length)switch(t){case"grow":this.calculateGrowFit();break;case"shrink":this.calculateShrinkFit();break;case"auto":this.calculateAutoFit()}}calculateGrowFit(){const t=this.getHeight()-(2*this.padding||0);let e=1;const n=this.childrenInlines.find((t=>t.isText));let i,r=1,s=2,a=n._fitFontSize?n._fitFontSize/n.getFontSize():1;do{if(i=this.calculateHeight(a),i>t){if(a<=r){this.childrenInlines.forEach((t=>{t.isInlineBlock||(t._fitFontSize=t.getFontSize())}));break}s=a,a-=(s-r)/2}else{if(Math.abs(t-i)<.075)break;Math.abs(a-s)<5e-10&&(s*=2),r=a,a+=(s-r)/2}}while(++e<=10)}calculateShrinkFit(){const t=this.getHeight()-(2*this.padding||0);let e=1;const n=this.childrenInlines.find((t=>t.isText));let i,r=0,s=1,a=n._fitFontSize?n._fitFontSize/n.getFontSize():1;do{if(i=this.calculateHeight(a),i>t)s=a,a-=(s-r)/2;else{if(a>=s){this.childrenInlines.forEach((t=>{t.isInlineBlock||(t._fitFontSize=t.getFontSize())}));break}if(Math.abs(t-i)<.075)break;r=a,a+=(s-r)/2}}while(++e<=10)}calculateAutoFit(){const t=this.getHeight()-(2*this.padding||0);let e=1;const n=this.childrenInlines.find((t=>t.isText));let i,r=0,s=2,a=n._fitFontSize?n._fitFontSize/n.getFontSize():1;do{if(i=this.calculateHeight(a),i>t)s=a,a-=(s-r)/2;else{if(Math.abs(t-i)<.075)break;Math.abs(a-s)<5e-10&&(s*=2),r=a,a+=(s-r)/2}}while(++e<=10)}computeLines(){const t=this.getWidth()-(2*this.padding||0),e=[[]];e.height=0;const n=this.getInterLine();this.childrenInlines.reduce(((n,i)=>{if(!i.inlines)return;const r=i._fitFontSize||i.getFontSize(),s=i.isText?i.getLetterSpacing()*r:0,a=i.getWhiteSpace(),o=i.getBreakOn(),l={WHITESPACE:a,LETTERSPACING:s,BREAKON:o,INNER_WIDTH:t},c=i.inlines.reduce(((t,n,i,r)=>{const a=n.kerning?n.kerning:0,o=n.xoffset?n.xoffset:0,c=n.xadvance?n.xadvance:n.width;return Qx(r,i,t,l)?(e.push([n]),n.offsetX=o,0===n.width?0:c+s):(e[e.length-1].push(n),n.offsetX=t+o+a,t+c+a+s)}),n);return c}),0);let i=0,r=0,s=-n/2;return e.forEach((t=>{if(t.lineHeight=t.reduce(((t,e)=>{const n=void 0!==e.lineHeight?e.lineHeight:e.height;return Math.max(t,n)}),0),t.lineBase=t.reduce(((t,e)=>{const n=void 0!==e.lineBase?e.lineBase:e.height;return Math.max(t,n)}),0),t.width=0,t.height=t.lineHeight,t[0]){const e=this.getWhiteSpace(),a=zx(t,e);t.forEach((t=>{t.offsetX-=a})),t.width=this.computeLineWidth(t),t.width>i&&(i=t.width),t.forEach((e=>{e.offsetY=s-e.height-e.anchor,e.lineHeight{e.isInlineBlock||(e._fitFontSize=e.getFontSize()*t,e.calculateInlines(e._fitFontSize))}));const e=this.computeLines();return Math.abs(e.height)}computeLineWidth(t){const e=t[0],n=t[t.length-1];return n.offsetX+n.width+e.offsetX}}}const ew=new mh,nw=[],iw={},rw=new xh,sw=[],aw={},ow={};function lw(t){if(t._kernings)return;const e={};for(let n=0;n{const n=JSON.parse(t);lw(n),iw[e]=n;for(const t of Object.keys(ow))e===ow[t].jsonURL&&ow[t].component._updateFontFamily(n)}))),ow[t.id]||(ow[t.id]={component:t}),ow[t.id].jsonURL=e,iw[e]&&t._updateFontFamily(iw[e])}(t,e):(ow[t.id]||(ow[t.id]={component:t}),lw(e),ow[t.id].json=e,t._updateFontFamily(e))},setFontTexture:function(t,e){-1===sw.indexOf(e)&&(sw.push(e),rw.load(e,(t=>{t.generateMipmaps=!1,t.minFilter=Lt,t.magFilter=Lt,aw[e]=t;for(const n of Object.keys(ow))e===ow[n].textureURL&&ow[n].component._updateFontTexture(t)}))),ow[t.id]||(ow[t.id]={component:t}),ow[t.id].textureURL=e,aw[e]&&t._updateFontTexture(aw[e])},getFontOf:function t(e){const n=ow[e.id];return!n&&e.parentUI?t(e.parentUI):n},addFont:function(t,e,n){n.generateMipmaps=!1,n.minFilter=Lt,n.magFilter=Lt,nw.push(t),iw[t]=e,lw(e),n&&(sw.push(t),aw[t]=n)}};class hw{static requestUpdate(t,e,n,i){t.traverse((t=>{t.isUI&&(this.requestedUpdates[t.id]?(e&&(this.requestedUpdates[t.id].updateParsing=!0),n&&(this.requestedUpdates[t.id].updateLayout=!0),i&&(this.requestedUpdates[t.id].updateInner=!0)):this.requestedUpdates[t.id]={updateParsing:e,updateLayout:n,updateInner:i,needCallback:e||n||i})}))}static register(t){this.components.includes(t)||this.components.push(t)}static disposeOf(t){const e=this.components.indexOf(t);e>-1&&this.components.splice(e,1)}static update(){if(Object.keys(this.requestedUpdates).length>0){const t=this.components.filter((t=>!t.parentUI));t.forEach((t=>this.traverseParsing(t))),t.forEach((t=>this.traverseUpdates(t)))}}static traverseParsing(t){const e=this.requestedUpdates[t.id];e&&e.updateParsing&&(t.parseParams(),e.updateParsing=!1),t.childrenUIs.forEach((t=>this.traverseParsing(t)))}static traverseUpdates(t){const e=this.requestedUpdates[t.id];delete this.requestedUpdates[t.id],e&&e.updateLayout&&(e.updateLayout=!1,t.updateLayout()),e&&e.updateInner&&(e.updateInner=!1,t.updateInner()),t.childrenUIs.forEach((t=>{this.traverseUpdates(t)})),e&&e.needCallback&&t.onAfterUpdate()}}hw.components=[],hw.requestedUpdates={};const uw={container:null,fontFamily:null,fontSize:.05,fontKerning:"normal",bestFit:"none",offset:.01,interLine:.01,breakOn:"- ,.:?!\n",whiteSpace:Nx,contentDirection:dx,alignItems:gx,justifyContent:Cx,textAlign:qx,textType:"MSDF",fontColor:new ls(16777215),fontOpacity:1,fontPXRange:4,fontSupersampling:!0,borderRadius:.01,borderWidth:0,borderColor:new ls("black"),borderOpacity:1,backgroundSize:"cover",backgroundColor:new ls(2236962),backgroundWhiteColor:new ls(16777215),backgroundOpacity:.8,backgroundOpaqueOpacity:1,getDefaultTexture:function(){if(!dw){const t=document.createElement("canvas").getContext("2d");t.canvas.width=1,t.canvas.height=1,t.fillStyle="#ffffff",t.fillRect(0,0,1,1),dw=new al(t.canvas),dw.isDefault=!0}return dw},hiddenOverflow:!1,letterSpacing:0};let dw;function pw(t){return class extends t{constructor(t){super(t),this.states={},this.currentState=void 0,this.isUI=!0,this.autoLayout=!0,this.childrenUIs=[],this.childrenBoxes=[],this.childrenTexts=[],this.childrenInlines=[],this.parentUI=null,this.addEventListener("added",this._rebuildParentUI),this.addEventListener("removed",this._rebuildParentUI)}getClippingPlanes(){const t=[];if(this.parentUI){if(this.isBlock&&this.parentUI.getHiddenOverflow()){const e=this.parentUI.getHeight()/2-(this.parentUI.padding||0),n=this.parentUI.getWidth()/2-(this.parentUI.padding||0),i=[new ho(new Qi(0,1,0),e),new ho(new Qi(0,-1,0),e),new ho(new Qi(1,0,0),n),new ho(new Qi(-1,0,0),n)];i.forEach((t=>{t.applyMatrix4(this.parent.matrixWorld)})),t.push(...i)}this.parentUI.parentUI&&t.push(...this.parentUI.getClippingPlanes())}return t}getHighestParent(){return this.parentUI?this.parent.getHighestParent():this}_getProperty(t){return void 0===this[t]&&this.parentUI?this.parent._getProperty(t):void 0!==this[t]?this[t]:uw[t]}getFontSize(){return this._getProperty("fontSize")}getFontKerning(){return this._getProperty("fontKerning")}getLetterSpacing(){return this._getProperty("letterSpacing")}getFontTexture(){return void 0===this.fontTexture&&this.parentUI?this.parent._getProperty("fontTexture"):void 0!==this.fontTexture?this.fontTexture:uw.getDefaultTexture()}getFontFamily(){return this._getProperty("fontFamily")}getBreakOn(){return this._getProperty("breakOn")}getWhiteSpace(){return this._getProperty("whiteSpace")}getTextAlign(){return this._getProperty("textAlign")}getTextType(){return this._getProperty("textType")}getFontColor(){return this._getProperty("fontColor")}getFontSupersampling(){return this._getProperty("fontSupersampling")}getFontOpacity(){return this._getProperty("fontOpacity")}getFontPXRange(){return this._getProperty("fontPXRange")}getBorderRadius(){return this._getProperty("borderRadius")}getBorderWidth(){return this._getProperty("borderWidth")}getBorderColor(){return this._getProperty("borderColor")}getBorderOpacity(){return this._getProperty("borderOpacity")}getContainer(){return!this.threeOBJ&&this.parent?this.parent.getContainer():this.threeOBJ?this:uw.container}getParentsNumber(t){return t=t||0,this.parentUI?this.parentUI.getParentsNumber(t+1):t}getBackgroundOpacity(){return this.backgroundOpacity||0===this.backgroundOpacity?this.backgroundOpacity:uw.backgroundOpacity}getBackgroundColor(){return this.backgroundColor||uw.backgroundColor}getBackgroundTexture(){return this.backgroundTexture||uw.getDefaultTexture()}getAlignContent(){return this.alignContent||uw.alignContent}getAlignItems(){return this.alignItems||uw.alignItems}getContentDirection(){return this.contentDirection||uw.contentDirection}getJustifyContent(){return this.justifyContent||uw.justifyContent}getInterLine(){return void 0===this.interLine?uw.interLine:this.interLine}getOffset(){return void 0===this.offset?uw.offset:this.offset}getBackgroundSize(){return void 0===this.backgroundSize?uw.backgroundSize:this.backgroundSize}getHiddenOverflow(){return void 0===this.hiddenOverflow?uw.hiddenOverflow:this.hiddenOverflow}getBestFit(){return void 0===this.bestFit?uw.bestFit:this.bestFit}_rebuildChildrenLists(){this.childrenUIs=this.children.filter((t=>t.isUI)),this.childrenBoxes=this.children.filter((t=>t.isBoxComponent)),this.childrenInlines=this.children.filter((t=>t.isInline)),this.childrenTexts=this.children.filter((t=>t.isText))}_rebuildParentUI=()=>{this.parent&&this.parent.isUI?this.parentUI=this.parent:this.parentUI=null};add(){for(const t of Object.keys(arguments))arguments[t].isInline&&this.update(null,!0);const t=super.add(...arguments);return this._rebuildChildrenLists(),t}remove(){for(const t of Object.keys(arguments))arguments[t].isInline&&this.update(null,!0);const t=super.remove(...arguments);return this._rebuildChildrenLists(),t}update(t,e,n){hw.requestUpdate(this,t,e,n)}onAfterUpdate(){}_updateFontFamily(t){this.fontFamily=t,this.traverse((t=>{t.isUI&&t.update(!0,!0,!1)})),this.getHighestParent().update(!1,!0,!1)}_updateFontTexture(t){this.fontTexture=t,this.getHighestParent().update(!1,!0,!1)}set(t){let e,n,i;if(hw.register(this),t&&JSON.stringify(t)!==JSON.stringify({})){t.alignContent&&(t.alignItems=t.alignContent,t.textAlign||(t.textAlign=t.alignContent),console.warn("`alignContent` property has been deprecated, please rely on `alignItems` and `textAlign` instead."),delete t.alignContent),t.alignItems&&_x(t.alignItems);for(const r of Object.keys(t))if(this[r]!=t[r])switch(r){case"content":case"fontSize":case"fontKerning":case"breakOn":case"whiteSpace":this.isText&&(e=!0),n=!0,this[r]=t[r];break;case"bestFit":this.isBlock&&(e=!0,n=!0),this[r]=t[r];break;case"width":case"height":case"padding":(this.isInlineBlock||this.isBlock&&"none"!=this.getBestFit())&&(e=!0),n=!0,this[r]=t[r];break;case"letterSpacing":case"interLine":this.isBlock&&"none"!=this.getBestFit()&&(e=!0),n=!0,this[r]=t[r];break;case"margin":case"contentDirection":case"justifyContent":case"alignContent":case"alignItems":case"textAlign":case"textType":n=!0,this[r]=t[r];break;case"fontColor":case"fontOpacity":case"fontSupersampling":case"offset":case"backgroundColor":case"backgroundOpacity":case"backgroundTexture":case"backgroundSize":case"borderRadius":case"borderWidth":case"borderColor":case"borderOpacity":i=!0,this[r]=t[r];break;case"hiddenOverflow":this[r]=t[r]}t.fontFamily&&cw.setFontFamily(this,t.fontFamily),t.fontTexture&&cw.setFontTexture(this,t.fontTexture),this.parentUI&&"none"!=this.parentUI.getBestFit()&&this.parentUI.update(!0,!0,!1),this.update(e,n,i),n&&this.getHighestParent().update(!1,!0,!1)}}setupState(t){this.states[t.state]={attributes:t.attributes,onSet:t.onSet}}setState(t){const e=this.states[t];e?t!==this.currentState&&(this.currentState=t,e.onSet&&e.onSet(),e.attributes&&this.set(e.attributes)):console.warn(`state "${t}" does not exist within this component:`,this.name)}clear(){this.traverse((t=>{hw.disposeOf(t),t.material&&t.material.dispose(),t.geometry&&t.geometry.dispose()}))}}}function fw(t){return class extends t{constructor(t){super(t),this.textUniforms={u_texture:{value:this.getFontTexture()},u_color:{value:this.getFontColor()},u_opacity:{value:this.getFontOpacity()},u_pxRange:{value:this.getFontPXRange()},u_useRGSS:{value:this.getFontSupersampling()}},this.backgroundUniforms={u_texture:{value:this.getBackgroundTexture()},u_color:{value:this.getBackgroundColor()},u_opacity:{value:this.getBackgroundOpacity()},u_backgroundMapping:{value:this.getBackgroundSize()},u_borderWidth:{value:this.getBorderWidth()},u_borderColor:{value:this.getBorderColor()},u_borderRadiusTopLeft:{value:this.getBorderRadius()},u_borderRadiusTopRight:{value:this.getBorderRadius()},u_borderRadiusBottomRight:{value:this.getBorderRadius()},u_borderRadiusBottomLeft:{value:this.getBorderRadius()},u_borderOpacity:{value:this.getBorderOpacity()},u_size:{value:new ci(1,1)},u_tSize:{value:new ci(1,1)}}}updateBackgroundMaterial(){this.backgroundUniforms.u_texture.value=this.getBackgroundTexture(),this.backgroundUniforms.u_tSize.value.set(this.backgroundUniforms.u_texture.value.image.width,this.backgroundUniforms.u_texture.value.image.height),this.size&&this.backgroundUniforms.u_size.value.copy(this.size),this.backgroundUniforms.u_texture.value.isDefault?(this.backgroundUniforms.u_color.value=this.getBackgroundColor(),this.backgroundUniforms.u_opacity.value=this.getBackgroundOpacity()):(this.backgroundUniforms.u_color.value=this.backgroundColor||uw.backgroundWhiteColor,this.backgroundUniforms.u_opacity.value=this.backgroundOpacity||0===this.backgroundOpacity?this.backgroundOpacity:uw.backgroundOpaqueOpacity),this.backgroundUniforms.u_backgroundMapping.value=(()=>{switch(this.getBackgroundSize()){case"stretch":return 0;case"contain":return 1;case"cover":return 2}})();const t=this.getBorderRadius();this.backgroundUniforms.u_borderWidth.value=this.getBorderWidth(),this.backgroundUniforms.u_borderColor.value=this.getBorderColor(),this.backgroundUniforms.u_borderOpacity.value=this.getBorderOpacity(),Array.isArray(t)?(this.backgroundUniforms.u_borderRadiusTopLeft.value=t[0],this.backgroundUniforms.u_borderRadiusTopRight.value=t[1],this.backgroundUniforms.u_borderRadiusBottomRight.value=t[2],this.backgroundUniforms.u_borderRadiusBottomLeft.value=t[3]):(this.backgroundUniforms.u_borderRadiusTopLeft.value=t,this.backgroundUniforms.u_borderRadiusTopRight.value=t,this.backgroundUniforms.u_borderRadiusBottomRight.value=t,this.backgroundUniforms.u_borderRadiusBottomLeft.value=t)}updateTextMaterial(){this.textUniforms.u_texture.value=this.getFontTexture(),this.textUniforms.u_color.value=this.getFontColor(),this.textUniforms.u_opacity.value=this.getFontOpacity(),this.textUniforms.u_pxRange.value=this.getFontPXRange(),this.textUniforms.u_useRGSS.value=this.getFontSupersampling()}getBackgroundMaterial(){return this.backgroundMaterial&&this.backgroundUniforms||(this.backgroundMaterial=this._makeBackgroundMaterial()),this.backgroundMaterial}getFontMaterial(){return this.fontMaterial&&this.textUniforms||(this.fontMaterial=this._makeTextMaterial()),this.fontMaterial}_makeTextMaterial(){return new na({uniforms:this.textUniforms,transparent:!0,clipping:!0,vertexShader:mw,fragmentShader:gw,extensions:{derivatives:!0}})}_makeBackgroundMaterial(){return new na({uniforms:this.backgroundUniforms,transparent:!0,clipping:!0,vertexShader:Aw,fragmentShader:vw,extensions:{derivatives:!0}})}updateClippingPlanes(t){const e=void 0!==t?t:this.getClippingPlanes();JSON.stringify(e)!==JSON.stringify(this.clippingPlanes)&&(this.clippingPlanes=e,this.fontMaterial&&(this.fontMaterial.clippingPlanes=this.clippingPlanes),this.backgroundMaterial&&(this.backgroundMaterial.clippingPlanes=this.clippingPlanes))}}}const mw="\nvarying vec2 vUv;\n\n#include \n\nvoid main() {\n\n\tvUv = uv;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\tgl_Position.z -= 0.00001;\n\n\t#include \n\n}\n",gw="\n\nuniform sampler2D u_texture;\nuniform vec3 u_color;\nuniform float u_opacity;\nuniform float u_pxRange;\nuniform bool u_useRGSS;\n\nvarying vec2 vUv;\n\n#include \n\n// functions from the original msdf repo:\n// https://github.com/Chlumsky/msdfgen#using-a-multi-channel-distance-field\n\nfloat median(float r, float g, float b) {\n\treturn max(min(r, g), min(max(r, g), b));\n}\n\nfloat screenPxRange() {\n\tvec2 unitRange = vec2(u_pxRange)/vec2(textureSize(u_texture, 0));\n\tvec2 screenTexSize = vec2(1.0)/fwidth(vUv);\n\treturn max(0.5*dot(unitRange, screenTexSize), 1.0);\n}\n\nfloat tap(vec2 offsetUV) {\n\tvec3 msd = texture( u_texture, offsetUV ).rgb;\n\tfloat sd = median(msd.r, msd.g, msd.b);\n\tfloat screenPxDistance = screenPxRange() * (sd - 0.5);\n\tfloat alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\n\treturn alpha;\n}\n\nvoid main() {\n\n\tfloat alpha;\n\n\tif ( u_useRGSS ) {\n\n\t\t// shader-based supersampling based on https://bgolus.medium.com/sharper-mipmapping-using-shader-based-supersampling-ed7aadb47bec\n\t\t// per pixel partial derivatives\n\t\tvec2 dx = dFdx(vUv);\n\t\tvec2 dy = dFdy(vUv);\n\n\t\t// rotated grid uv offsets\n\t\tvec2 uvOffsets = vec2(0.125, 0.375);\n\t\tvec2 offsetUV = vec2(0.0, 0.0);\n\n\t\t// supersampled using 2x2 rotated grid\n\t\talpha = 0.0;\n\t\toffsetUV.xy = vUv + uvOffsets.x * dx + uvOffsets.y * dy;\n\t\talpha += tap(offsetUV);\n\t\toffsetUV.xy = vUv - uvOffsets.x * dx - uvOffsets.y * dy;\n\t\talpha += tap(offsetUV);\n\t\toffsetUV.xy = vUv + uvOffsets.y * dx - uvOffsets.x * dy;\n\t\talpha += tap(offsetUV);\n\t\toffsetUV.xy = vUv - uvOffsets.y * dx + uvOffsets.x * dy;\n\t\talpha += tap(offsetUV);\n\t\talpha *= 0.25;\n\n\t} else {\n\n\t\talpha = tap( vUv );\n\n\t}\n\n\n\t// apply the opacity\n\talpha *= u_opacity;\n\n\t// this is useful to avoid z-fighting when quads overlap because of kerning\n\tif ( alpha < 0.02) discard;\n\n\n\tgl_FragColor = vec4( u_color, alpha );\n\n\t#include \n\n}\n",Aw="\nvarying vec2 vUv;\n\n#include \n\nvoid main() {\n\n\tvUv = uv;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\n\t#include \n\n}\n",vw="\n\nuniform sampler2D u_texture;\nuniform vec3 u_color;\nuniform float u_opacity;\n\nuniform float u_borderRadiusTopLeft;\nuniform float u_borderRadiusTopRight;\nuniform float u_borderRadiusBottomLeft;\nuniform float u_borderRadiusBottomRight;\nuniform float u_borderWidth;\nuniform vec3 u_borderColor;\nuniform float u_borderOpacity;\nuniform vec2 u_size;\nuniform vec2 u_tSize;\nuniform int u_backgroundMapping;\n\nvarying vec2 vUv;\n\n#include \n\nfloat getEdgeDist() {\n\tvec2 ndc = vec2( vUv.x * 2.0 - 1.0, vUv.y * 2.0 - 1.0 );\n\tvec2 planeSpaceCoord = vec2( u_size.x * 0.5 * ndc.x, u_size.y * 0.5 * ndc.y );\n\tvec2 corner = u_size * 0.5;\n\tvec2 offsetCorner = corner - abs( planeSpaceCoord );\n\tfloat innerRadDist = min( offsetCorner.x, offsetCorner.y ) * -1.0;\n\tif (vUv.x < 0.5 && vUv.y >= 0.5) {\n\t\tfloat roundedDist = length( max( abs( planeSpaceCoord ) - u_size * 0.5 + u_borderRadiusTopLeft, 0.0 ) ) - u_borderRadiusTopLeft;\n\t\tfloat s = step( innerRadDist * -1.0, u_borderRadiusTopLeft );\n\t\treturn mix( innerRadDist, roundedDist, s );\n\t}\n\tif (vUv.x >= 0.5 && vUv.y >= 0.5) {\n\t\tfloat roundedDist = length( max( abs( planeSpaceCoord ) - u_size * 0.5 + u_borderRadiusTopRight, 0.0 ) ) - u_borderRadiusTopRight;\n\t\tfloat s = step( innerRadDist * -1.0, u_borderRadiusTopRight );\n\t\treturn mix( innerRadDist, roundedDist, s );\n\t}\n\tif (vUv.x >= 0.5 && vUv.y < 0.5) {\n\t\tfloat roundedDist = length( max( abs( planeSpaceCoord ) - u_size * 0.5 + u_borderRadiusBottomRight, 0.0 ) ) - u_borderRadiusBottomRight;\n\t\tfloat s = step( innerRadDist * -1.0, u_borderRadiusBottomRight );\n\t\treturn mix( innerRadDist, roundedDist, s );\n\t}\n\tif (vUv.x < 0.5 && vUv.y < 0.5) {\n\t\tfloat roundedDist = length( max( abs( planeSpaceCoord ) - u_size * 0.5 + u_borderRadiusBottomLeft, 0.0 ) ) - u_borderRadiusBottomLeft;\n\t\tfloat s = step( innerRadDist * -1.0, u_borderRadiusBottomLeft );\n\t\treturn mix( innerRadDist, roundedDist, s );\n\t}\n}\n\nvec4 sampleTexture() {\n\tfloat textureRatio = u_tSize.x / u_tSize.y;\n\tfloat panelRatio = u_size.x / u_size.y;\n\tvec2 uv = vUv;\n\tif ( u_backgroundMapping == 1 ) { // contain\n\t\tif ( textureRatio < panelRatio ) { // repeat on X\n\t\t\tfloat newX = uv.x * ( panelRatio / textureRatio );\n\t\t\tnewX += 0.5 - 0.5 * ( panelRatio / textureRatio );\n\t\t\tuv.x = newX;\n\t\t} else { // repeat on Y\n\t\t\tfloat newY = uv.y * ( textureRatio / panelRatio );\n\t\t\tnewY += 0.5 - 0.5 * ( textureRatio / panelRatio );\n\t\t\tuv.y = newY;\n\t\t}\n\t} else if ( u_backgroundMapping == 2 ) { // cover\n\t\tif ( textureRatio < panelRatio ) { // stretch on Y\n\t\t\tfloat newY = uv.y * ( textureRatio / panelRatio );\n\t\t\tnewY += 0.5 - 0.5 * ( textureRatio / panelRatio );\n\t\t\tuv.y = newY;\n\t\t} else { // stretch on X\n\t\t\tfloat newX = uv.x * ( panelRatio / textureRatio );\n\t\t\tnewX += 0.5 - 0.5 * ( panelRatio / textureRatio );\n\t\t\tuv.x = newX;\n\t\t}\n\t}\n\treturn texture2D( u_texture, uv ).rgba;\n}\n\nvoid main() {\n\n\tfloat edgeDist = getEdgeDist();\n\tfloat change = fwidth( edgeDist );\n\n\tvec4 textureSample = sampleTexture();\n\tvec3 blendedColor = textureSample.rgb * u_color;\n\n\tfloat alpha = smoothstep( change, 0.0, edgeDist );\n\tfloat blendedOpacity = u_opacity * textureSample.a * alpha;\n\n\tvec4 frameColor = vec4( blendedColor, blendedOpacity );\n\n\tif ( u_borderWidth <= 0.0 ) {\n\t\tgl_FragColor = frameColor;\n\t} else {\n\t\tvec4 borderColor = vec4( u_borderColor, u_borderOpacity * alpha );\n\t\tfloat stp = smoothstep( edgeDist + change, edgeDist, u_borderWidth * -1.0 );\n\t\tgl_FragColor = mix( frameColor, borderColor, stp );\n\t}\n\n\t#include \n}\n";class yw extends Ys{constructor(t){super(new _c,t),this.castShadow=!0,this.receiveShadow=!0,this.name="MeshUI-Frame"}}let _w=null;function xw(...t){if(!_w)throw new Error("Cannot use mixins with Base null");let e=_w;_w=null;let n,i=t.length;for(;--i>=0;)n=t[i],e=n(e);return e}xw.withBase=t=>(_w=t,xw);class ww extends(xw.withBase(Hr)(Rx,tw,fw,pw)){constructor(t){super(t),this.isBlock=!0,this.size=new ci(1,1),this.frame=new yw(this.getBackgroundMaterial()),this.frame.onBeforeRender=()=>{this.updateClippingPlanes&&this.updateClippingPlanes()},this.add(this.frame),this.set(t)}parseParams(){const t=this.getBestFit();"none"!=t&&this.childrenTexts.length?this.calculateBestFit(t):this.childrenTexts.forEach((t=>{t._fitFontSize=void 0}))}updateLayout(){const t=this.getWidth(),e=this.getHeight();t&&e?(this.size.set(t,e),this.frame.scale.set(t,e,1),this.frame&&this.updateBackgroundMaterial(),this.frame.renderOrder=this.getParentsNumber(),this.autoLayout&&this.setPosFromParentRecords(),this.childrenInlines.length&&this.computeInlinesPosition(),this.computeChildrenPosition(),this.parentUI&&(this.position.z=this.getOffset())):console.warn("Block got no dimension from its parameters or from children parameters")}updateInner(){this.parentUI&&(this.position.z=this.getOffset()),this.frame&&this.updateBackgroundMaterial()}}function Cw(t){return class extends t{constructor(t){super(t),this.isInline=!0}}}class Ew extends _c{constructor(t,e){const n=t.glyph,i=t.fontSize;super(t.width,t.height),null===n.match(/\s/g)?(-1===e.info.charset.indexOf(n)&&console.error(`The character '${n}' is not included in the font characters set.`),this.mapUVs(e,n),this.transformGeometry(t)):(this.nullifyUVs(),this.scale(0,0,1),this.translate(0,i/2,0))}mapUVs(t,e){const n=t.chars.find((t=>t.char===e)),i=t.common,r=n.x/i.scaleW,s=(n.x+n.width)/i.scaleW,a=1-(n.y+n.height)/i.scaleH,o=1-n.y/i.scaleH,l=this.attributes.uv;for(let t=0;t{switch(t){case 0:return[r,o];case 1:return[s,o];case 2:return[r,a];case 3:return[s,a]}})(),l.setXY(t,e,n)}}nullifyUVs(){const t=this.attributes.uv;for(let e=0;et.char===i));let a=s?s.width*r:n/3,o=s?s.height*r:0;0===a&&(a=s?s.xadvance*r:n),0===o&&(o=.7*n),"\n"===i&&(a=0);const l=s?s.xadvance*r:a,c=s?s.xoffset*r:0;return{width:a,height:o,anchor:s?s.yoffset*r:0,xadvance:l,xoffset:c}},getGlyphPairKerning:function(t,e){const n=t._kernings;return n[e]?n[e]:0},buildText:function(){const t=[];this.inlines.forEach(((e,n)=>{t[n]=new Ew(e,this.getFontFamily()),t[n].translate(e.offsetX,e.offsetY,0)}));const e=Tg(t);return new Ys(e,this.getFontMaterial())}};function Sw(t){return class extends t{createText(){const t=this,e=(()=>{if("MSDF"===this.getTextType())return Mw.buildText.call(this);console.warn(`'${this.getTextType()}' is not a supported text type.\nSee https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type`)})();return e.renderOrder=1/0,e.onBeforeRender=function(){t.updateClippingPlanes&&t.updateClippingPlanes()},e}getGlyphDimensions(t){if("MSDF"===t.textType)return Mw.getGlyphDimensions(t);console.warn(`'${t.textType}' is not a supported text type.\nSee https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type`)}getGlyphPairKerning(t,e,n){if("MSDF"===t)return Mw.getGlyphPairKerning(e,n);console.warn(`'${t}' is not a supported text type.\nSee https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type`)}}}const bw=function t(e){e.children.forEach((n=>{n.children.length>0&&t(n),e.remove(n),hw.disposeOf(n),n.material&&n.material.dispose(),n.geometry&&n.geometry.dispose()})),e.children=[]};class Iw extends(xw.withBase(Hr)(Cw,Sw,fw,pw)){constructor(t){super(t),this.isText=!0,this.set(t)}parseParams(){this.calculateInlines(this._fitFontSize||this.getFontSize())}updateLayout(){bw(this),this.inlines&&(this.textContent=this.createText(),this.updateTextMaterial(),this.add(this.textContent)),this.position.z=this.getOffset()}updateInner(){this.position.z=this.getOffset(),this.textContent&&this.updateTextMaterial()}calculateInlines(t){const e=this.content,n=this.getFontFamily(),i=this.getBreakOn(),r=this.getTextType(),s=this.getWhiteSpace();if(!n||"string"==typeof n)return void(cw.getFontOf(this)||console.warn("no font was found"));if(!this.content)return void(this.inlines=null);if(!r)return void console.error("You must provide a 'textType' attribute so three-mesh-ui knows how to render your text.\n See https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type");const a=Ox(e,s),o=Array.from?Array.from(a):String(a).split(""),l=t/n.info.size,c=n.common.lineHeight*l,h=n.common.base*l,u=o.map((e=>{const a=this.getGlyphDimensions({textType:r,glyph:e,font:n,fontSize:t});let o=null;return s!==Lx&&(i.includes(e)||e.match(/\s/g))&&(o="possible"),e.match(/\n/g)&&(o=kx(s)),{height:a.height,width:a.width,anchor:a.anchor,xadvance:a.xadvance,xoffset:a.xoffset,lineBreak:o,glyph:e,fontSize:t,lineHeight:c,lineBase:h}}));if("none"!==this.getFontKerning())for(let e=1;e{this.updateClippingPlanes&&this.updateClippingPlanes()},this.add(this.frame),this.set(t)}parseParams(){this.width||console.warn("inlineBlock has no width. Set to 0.3 by default"),this.height||console.warn("inlineBlock has no height. Set to 0.3 by default"),this.inlines=[{height:this.height||.3,width:this.width||.3,anchor:0,lineBreak:"possible"}]}updateLayout(){const t=this.getWidth(),e=this.getHeight();if(this.inlines){const t=this.inlines[0];this.position.set(t.width/2,t.height/2,0),this.position.x+=t.offsetX,this.position.y+=t.offsetY}this.size.set(t,e),this.frame.scale.set(t,e,1),this.frame&&this.updateBackgroundMaterial(),this.frame.renderOrder=this.getParentsNumber(),this.childrenInlines.length&&this.computeInlinesPosition(),this.computeChildrenPosition(),this.position.z=this.getOffset()}updateInner(){this.position.z=this.getOffset(),this.frame&&this.updateBackgroundMaterial()}}const Bw=[[[{width:.1,chars:[{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"l",upperCase:"L"}]},{width:.1,chars:[{lowerCase:"m",upperCase:"M"}]}],[{width:.2,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"n",upperCase:"N"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Rw=[[[{width:.1,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"l",upperCase:"L"}]}],[{width:.15,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"n",upperCase:"N"}]},{width:.1,chars:[{lowerCase:"m",upperCase:"M"}]},{width:.15,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Dw=[[[{width:1/12,chars:[{lowerCase:"й",upperCase:"Й"},{lowerCase:"q",upperCase:"Q"}]},{width:1/12,chars:[{lowerCase:"ц",upperCase:"Ц"},{lowerCase:"w",upperCase:"W"}]},{width:1/12,chars:[{lowerCase:"у",upperCase:"У"},{lowerCase:"e",upperCase:"E"}]},{width:1/12,chars:[{lowerCase:"к",upperCase:"К"},{lowerCase:"r",upperCase:"R"}]},{width:1/12,chars:[{lowerCase:"е",upperCase:"Е"},{lowerCase:"t",upperCase:"T"}]},{width:1/12,chars:[{lowerCase:"н",upperCase:"Н"},{lowerCase:"y",upperCase:"Y"}]},{width:1/12,chars:[{lowerCase:"г",upperCase:"Г"},{lowerCase:"u",upperCase:"U"}]},{width:1/12,chars:[{lowerCase:"ш",upperCase:"Ш"},{lowerCase:"i",upperCase:"I"}]},{width:1/12,chars:[{lowerCase:"щ",upperCase:"Щ"},{lowerCase:"o",upperCase:"O"}]},{width:1/12,chars:[{lowerCase:"з",upperCase:"З"},{lowerCase:"p",upperCase:"P"}]},{width:1/12,chars:[{lowerCase:"х",upperCase:"Х"},{lowerCase:"{",upperCase:"["}]},{width:1/12,chars:[{lowerCase:"ъ",upperCase:"Ъ"},{lowerCase:"}",upperCase:"]"}]}],[{width:1/12,chars:[{lowerCase:"ф",upperCase:"Ф"},{lowerCase:"a",upperCase:"A"}]},{width:1/12,chars:[{lowerCase:"ы",upperCase:"Ы"},{lowerCase:"s",upperCase:"S"}]},{width:1/12,chars:[{lowerCase:"в",upperCase:"В"},{lowerCase:"d",upperCase:"D"}]},{width:1/12,chars:[{lowerCase:"а",upperCase:"А"},{lowerCase:"f",upperCase:"F"}]},{width:1/12,chars:[{lowerCase:"п",upperCase:"П"},{lowerCase:"g",upperCase:"G"}]},{width:1/12,chars:[{lowerCase:"р",upperCase:"Р"},{lowerCase:"h",upperCase:"H"}]},{width:1/12,chars:[{lowerCase:"о",upperCase:"О"},{lowerCase:"j",upperCase:"J"}]},{width:1/12,chars:[{lowerCase:"л",upperCase:"Л"},{lowerCase:"k",upperCase:"K"}]},{width:1/12,chars:[{lowerCase:"д",upperCase:"Д"},{lowerCase:"l",upperCase:"L"}]},{width:1/12,chars:[{lowerCase:"ж",upperCase:"Ж"},{lowerCase:":",upperCase:";"}]},{width:1/12,chars:[{lowerCase:"э",upperCase:"Э"},{lowerCase:'"',upperCase:"'"}]},{width:1/12,chars:[{lowerCase:"ё",upperCase:"Ё"},{lowerCase:"|",upperCase:"\\"}]}],[{width:.125,command:"shift",chars:[{icon:"shift"}]},{width:1/12,chars:[{lowerCase:"я",upperCase:"Я"},{lowerCase:"z",upperCase:"Z"}]},{width:1/12,chars:[{lowerCase:"ч",upperCase:"Ч"},{lowerCase:"x",upperCase:"X"}]},{width:1/12,chars:[{lowerCase:"с",upperCase:"С"},{lowerCase:"c",upperCase:"C"}]},{width:1/12,chars:[{lowerCase:"м",upperCase:"М"},{lowerCase:"v",upperCase:"V"}]},{width:1/12,chars:[{lowerCase:"и",upperCase:"И"},{lowerCase:"b",upperCase:"B"}]},{width:1/12,chars:[{lowerCase:"т",upperCase:"Т"},{lowerCase:"n",upperCase:"N"}]},{width:1/12,chars:[{lowerCase:"ь",upperCase:"Ь"},{lowerCase:"m",upperCase:"M"}]},{width:1/12,chars:[{lowerCase:"б",upperCase:"Б"},{lowerCase:",",upperCase:""}]},{width:1/12,chars:[{lowerCase:"ю",upperCase:"Ю"},{lowerCase:".",upperCase:""}]},{width:.125,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.15,command:"switch-set",chars:[{lowerCase:"eng"}]},{width:.15,command:"switch",chars:[{lowerCase:".?12"}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.3,command:"switch",chars:[{lowerCase:"АБВ"}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Pw=[[[{width:1/11,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:1/11,chars:[{lowerCase:"w",upperCase:"W"}]},{width:1/11,chars:[{lowerCase:"e",upperCase:"E"}]},{width:1/11,chars:[{lowerCase:"r",upperCase:"R"}]},{width:1/11,chars:[{lowerCase:"t",upperCase:"T"}]},{width:1/11,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:1/11,chars:[{lowerCase:"u",upperCase:"U"}]},{width:1/11,chars:[{lowerCase:"i",upperCase:"I"}]},{width:1/11,chars:[{lowerCase:"o",upperCase:"O"}]},{width:1/11,chars:[{lowerCase:"p",upperCase:"P"}]},{width:1/11,chars:[{lowerCase:"ü",upperCase:"Ü"}]}],[{width:1/11,chars:[{lowerCase:"a",upperCase:"A"}]},{width:1/11,chars:[{lowerCase:"s",upperCase:"S"}]},{width:1/11,chars:[{lowerCase:"d",upperCase:"D"}]},{width:1/11,chars:[{lowerCase:"f",upperCase:"F"}]},{width:1/11,chars:[{lowerCase:"g",upperCase:"G"}]},{width:1/11,chars:[{lowerCase:"h",upperCase:"H"}]},{width:1/11,chars:[{lowerCase:"j",upperCase:"J"}]},{width:1/11,chars:[{lowerCase:"k",upperCase:"K"}]},{width:1/11,chars:[{lowerCase:"l",upperCase:"L"}]},{width:1/11,chars:[{lowerCase:"ö",upperCase:"Ö"}]},{width:1/11,chars:[{lowerCase:"ä",upperCase:"Ä"}]}],[{width:2/11,command:"shift",chars:[{icon:"shift"}]},{width:1/11,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:1/11,chars:[{lowerCase:"x",upperCase:"X"}]},{width:1/11,chars:[{lowerCase:"c",upperCase:"C"}]},{width:1/11,chars:[{lowerCase:"v",upperCase:"V"}]},{width:1/11,chars:[{lowerCase:"b",upperCase:"B"}]},{width:1/11,chars:[{lowerCase:"n",upperCase:"N"}]},{width:1/11,chars:[{lowerCase:"m",upperCase:"M"}]},{width:2/11,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Lw=[[[{width:.1,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"l",upperCase:"L"}]},{width:.1,chars:[{lowerCase:"ñ",upperCase:"Ñ"}]}],[{width:.15,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"n",upperCase:"N"}]},{width:.1,chars:[{lowerCase:"m",upperCase:"M"}]},{width:.15,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Uw=[[[{width:.1,chars:[{lowerCase:";",upperCase:":"},{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"ς",upperCase:"ς"},{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"ε",upperCase:"Ε"},{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"ρ",upperCase:"Ρ"},{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"τ",upperCase:"Τ"},{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"υ",upperCase:"Υ"},{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"θ",upperCase:"Θ"},{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"ι",upperCase:"Ι"},{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"ο",upperCase:"Ο"},{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"π",upperCase:"Π"},{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"α",upperCase:"Α"},{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"σ",upperCase:"Σ"},{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"δ",upperCase:"Δ"},{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"φ",upperCase:"Φ"},{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"γ",upperCase:"Γ"},{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"η",upperCase:"Η"},{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"ξ",upperCase:"Ξ"},{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"κ",upperCase:"Κ"},{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"λ",upperCase:"Λ"},{lowerCase:"l",upperCase:"L"}]}],[{width:.15,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"ζ",upperCase:"Ζ"},{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"χ",upperCase:"Χ"},{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"ψ",upperCase:"Ψ"},{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"ω",upperCase:"Ω"},{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"β",upperCase:"Β"},{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"ν",upperCase:"Ν"},{lowerCase:"n",upperCase:"N"}]},{width:.1,chars:[{lowerCase:"μ",upperCase:"Μ"},{lowerCase:"m",upperCase:"M"}]},{width:.15,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.15,command:"switch-set",chars:[{lowerCase:"eng"}]},{width:.15,command:"switch",chars:[{lowerCase:".?12"}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Nw=[[[{width:1/11,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:1/11,chars:[{lowerCase:"w",upperCase:"W"}]},{width:1/11,chars:[{lowerCase:"e",upperCase:"E"}]},{width:1/11,chars:[{lowerCase:"r",upperCase:"R"}]},{width:1/11,chars:[{lowerCase:"t",upperCase:"T"}]},{width:1/11,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:1/11,chars:[{lowerCase:"u",upperCase:"U"}]},{width:1/11,chars:[{lowerCase:"i",upperCase:"I"}]},{width:1/11,chars:[{lowerCase:"o",upperCase:"O"}]},{width:1/11,chars:[{lowerCase:"p",upperCase:"P"}]},{width:1/11,chars:[{lowerCase:"å",upperCase:"Å"}]}],[{width:1/11,chars:[{lowerCase:"a",upperCase:"A"}]},{width:1/11,chars:[{lowerCase:"s",upperCase:"S"}]},{width:1/11,chars:[{lowerCase:"d",upperCase:"D"}]},{width:1/11,chars:[{lowerCase:"f",upperCase:"F"}]},{width:1/11,chars:[{lowerCase:"g",upperCase:"G"}]},{width:1/11,chars:[{lowerCase:"h",upperCase:"H"}]},{width:1/11,chars:[{lowerCase:"j",upperCase:"J"}]},{width:1/11,chars:[{lowerCase:"k",upperCase:"K"}]},{width:1/11,chars:[{lowerCase:"l",upperCase:"L"}]},{width:1/11,chars:[{lowerCase:"æ",upperCase:"Æ"}]},{width:1/11,chars:[{lowerCase:"ø",upperCase:"Ø"}]}],[{width:2/11,command:"shift",chars:[{icon:"shift"}]},{width:1/11,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:1/11,chars:[{lowerCase:"x",upperCase:"X"}]},{width:1/11,chars:[{lowerCase:"c",upperCase:"C"}]},{width:1/11,chars:[{lowerCase:"v",upperCase:"V"}]},{width:1/11,chars:[{lowerCase:"b",upperCase:"B"}]},{width:1/11,chars:[{lowerCase:"n",upperCase:"N"}]},{width:1/11,chars:[{lowerCase:"m",upperCase:"M"}]},{width:2/11,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Fw=new xh;class Ow extends(xw.withBase(Hr)(Rx,pw)){constructor(t){let e;if(t||(t={}),t.width||(t.width=1),t.height||(t.height=.4),t.margin||(t.margin=.003),t.padding||(t.padding=.01),super(t),this.currentPanel=0,this.isLowerCase=!0,this.charsetCount=1,t.language||navigator.language)switch(t.language||navigator.language){case"fr":case"fr-CH":case"fr-CA":e=Bw;break;case"ru":this.charsetCount=2,e=Dw;break;case"de":case"de-DE":case"de-AT":case"de-LI":case"de-CH":e=Pw;break;case"es":case"es-419":case"es-AR":case"es-CL":case"es-CO":case"es-ES":case"es-CR":case"es-US":case"es-HN":case"es-MX":case"es-PE":case"es-UY":case"es-VE":e=Lw;break;case"el":this.charsetCount=2,e=Uw;break;case"nord":e=Nw;break;default:e=Rw}else e=Rw;this.keys=[],this.panels=e.map((e=>{const n=t.height/e.length-2*t.margin,i=new ww({width:t.width+2*t.padding,height:t.height+2*t.padding,offset:0,padding:t.padding,fontFamily:t.fontFamily,fontTexture:t.fontTexture,backgroundColor:t.backgroundColor,backgroundOpacity:t.backgroundOpacity});return i.charset=0,i.add(...e.map((e=>{const r=new ww({width:t.width,height:n,margin:t.margin,contentDirection:"row",justifyContent:"center"});r.frame.visible=!1;const s=[];return e.forEach((e=>{const r=new ww({width:t.width*e.width-2*t.margin,height:n,margin:t.margin,justifyContent:"center",offset:0}),a=e.chars[i.charset].lowerCase||e.chars[i.charset].icon||"undif";if("enter"===a&&t.enterTexture||"shift"===a&&t.shiftTexture||"backspace"===a&&t.backspaceTexture){const e=(()=>{switch(a){case"backspace":return t.backspaceTexture;case"enter":return t.enterTexture;case"shift":return t.shiftTexture;default:console.warn("There is no icon image for this key")}})();Fw.load(e,(t=>{r.add(new Tw({width:.65*r.width,height:.65*r.height,backgroundSize:"contain",backgroundTexture:t}))}))}else r.add(new Iw({content:a,offset:0}));r.type="Key",r.info=e,r.info.input=a,r.panel=i,s.push(r),this.keys.push(r)})),r.add(...s),r}))),i})),this.add(this.panels[0]),this.set(t)}setNextPanel(){this.panels.forEach((t=>{this.remove(t)})),this.currentPanel=(this.currentPanel+1)%this.panels.length,this.add(this.panels[this.currentPanel]),this.update(!0,!0,!0)}setNextCharset(){this.panels[this.currentPanel].charset=(this.panels[this.currentPanel].charset+1)%this.charsetCount,this.keys.forEach((t=>{if(!this.panels[this.currentPanel].getObjectById(t.id))return;const e=t.info.chars[t.panel.charset]||t.info.chars[0],n=this.isLowerCase||!e.upperCase?e.lowerCase:e.upperCase;if(!t.childrenTexts.length)return;const i=t.childrenTexts[0];t.info.input=n,i.set({content:n}),i.update(!0,!0,!0)}))}toggleCase(){this.isLowerCase=!this.isLowerCase,this.keys.forEach((t=>{const e=t.info.chars[t.panel.charset]||t.info.chars[0],n=this.isLowerCase||!e.upperCase?e.lowerCase:e.upperCase;if(!t.childrenTexts.length)return;const i=t.childrenTexts[0];t.info.input=n,i.set({content:n}),i.update(!0,!0,!0)}))}parseParams(){}updateLayout(){}updateInner(){}}const kw={Block:ww,Text:Iw,InlineBlock:Tw,Keyboard:Ow,FontLibrary:cw,update:()=>hw.update(),TextAlign:l,Whitespace:o,JustifyContent:a,AlignItems:s,ContentDirection:r};void 0!==t.g&&(t.g.ThreeMeshUI=kw);const Qw=kw;function zw(t,e,n){return null===t?null:(t.point.applyMatrix4(e.matrixWorld),t.distance=t.point.distanceTo(n.ray.origin),t.object=e,t)}const Gw=0,Hw=1,Vw=2,Ww=0,jw=1,qw=2,Xw=1.25,Yw=1,Jw=32,Kw=65535,Zw=Math.pow(2,-24),$w=Symbol("SKIP_GENERATION");function tC(t){return t.index?t.index.count:t.attributes.position.count}function eC(t){return tC(t)/3}function nC(t,e=ArrayBuffer){return t>65535?new Uint32Array(new e(4*t)):new Uint16Array(new e(2*t))}function iC(t,e){const n=eC(t),i=e||t.drawRange,r=i.start/3,s=(i.start+i.count)/3,a=Math.max(0,r),o=Math.min(n,s)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function rC(t,e){if(!t.groups||!t.groups.length)return iC(t,e);const n=[],i=new Set,r=e||t.drawRange,s=r.start/3,a=(r.start+r.count)/3;for(const e of t.groups){const t=e.start/3,n=(e.start+e.count)/3;i.add(Math.max(s,t)),i.add(Math.min(a,n))}const o=Array.from(i.values()).sort(((t,e)=>t-e));for(let t=0;tl&&(l=A),ef&&(f=e);const v=t[i+2],y=t[i+3],_=v-y,x=v+y;_c&&(c=x),vm&&(m=v);const w=t[i+4],C=t[i+5],E=w-C,M=w+C;Eh&&(h=M),wg&&(g=w)}i[0]=s,i[1]=a,i[2]=o,i[3]=l,i[4]=c,i[5]=h,r[0]=u,r[1]=d,r[2]=p,r[3]=f,r[4]=m,r[5]=g}function aC(t,e,n){return n.min.x=e[t],n.min.y=e[t+1],n.min.z=e[t+2],n.max.x=e[t+3],n.max.y=e[t+4],n.max.z=e[t+5],n}function oC(t){let e=-1,n=-1/0;for(let i=0;i<3;i++){const r=t[i+3]-t[i];r>n&&(n=r,e=i)}return e}function lC(t,e){e.set(t)}function cC(t,e,n){let i,r;for(let s=0;s<3;s++){const a=s+3;i=t[s],r=e[s],n[s]=ir?i:r}}function hC(t,e,n){for(let i=0;i<3;i++){const r=e[t+2*i],s=e[t+2*i+1],a=r-s,o=r+s;an[i+3]&&(n[i+3]=o)}}function uC(t){const e=t[3]-t[0],n=t[4]-t[1],i=t[5]-t[2];return 2*(e*n+n*i+i*e)}const dC=(t,e)=>t.candidate-e.candidate,pC=new Array(32).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),fC=new Float32Array(6);class mC{constructor(){this.boundingData=new Float32Array(6)}}function gC(t,e,n,i,r,s){let a=i,o=i+r-1;const l=s.pos,c=2*s.axis;for(;;){for(;a<=o&&n[6*a+c]=l;)o--;if(!(a=l;)o--;if(!(aIC)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return MC[n+6]=a/4,a=RC(a,r),MC[n+7]=s,a}}function DC(t,e){const n=t.geometry;e.indirect&&(t._indirectBuffer=function(t,e){const n=(t.index?t.index.count:t.attributes.position.count)/3,i=n>65536,r=i?4:2,s=e?new SharedArrayBuffer(n*r):new ArrayBuffer(n*r),a=i?new Uint32Array(s):new Uint16Array(s);for(let t=0,e=a.length;tt.offset-e.offset)),r=i[i.length-1];r.count=Math.min(n-r.offset,r.count);let s=0;return i.forEach((({count:t})=>s+=t)),n!==s}(n,e.range)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),t._indirectBuffer||function(t,e){if(!t.index){const n=t.attributes.position.count,i=nC(n,e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);t.setIndex(new _s(i,1));for(let t=0;tf&&(f=s),h>f&&(f=h);const m=(f-u)/2,g=2*t;l[n+g+0]=u+m,l[n+g+1]=m+(Math.abs(u)+m)*Zw}}return l}(n),s=e.indirect?iC(n,e.range):rC(n,e.range);t._roots=s.map((n=>{const s=function(t,e,n,i,r){const{maxDepth:s,verbose:a,maxLeafTris:o,strategy:l,onProgress:c,indirect:h}=r,u=t._indirectBuffer,d=t.geometry,p=d.index?d.index.array:null,f=h?AC:gC,m=eC(d),g=new Float32Array(6);let A=!1;const v=new mC;return sC(e,n,i,v.boundingData,g),function t(n,i,r,c=null,h=0){if(!A&&h>=s&&(A=!0,a&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(d))),r<=o||h>=s)return y(i+r),n.offset=i,n.count=r,n;const m=function(t,e,n,i,r,s){let a=-1,o=0;if(s===Gw)a=oC(e),-1!==a&&(o=(e[a]+e[a+3])/2);else if(s===Hw)a=oC(t),-1!==a&&(o=function(t,e,n,i){let r=0;for(let s=e,a=e+n;s=s.candidate?hC(i,n,s.rightCacheBounds):(hC(i,n,s.leftCacheBounds),s.count++)}}for(let n=0;n=32&&(r=31);const s=pC[r];s.count++,hC(e,n,s.bounds)}const e=pC[31];lC(e.bounds,e.rightCacheBounds);for(let t=30;t>=0;t--){const e=pC[t],n=pC[t+1];cC(e.bounds,n.rightCacheBounds,e.rightCacheBounds)}let d=0;for(let e=0;e<31;e++){const n=pC[e],i=n.count,c=n.bounds,h=pC[e+1].rightCacheBounds;0!==i&&(0===d?lC(c,fC):cC(c,fC,fC)),d+=i;let u=0,p=0;0!==d&&(u=uC(fC)/s);const f=r-d;0!==f&&(p=uC(h)/s);const m=Yw+Xw*(u*d+p*f);mi?s:i}this.min=n,this.max=i}setFromPoints(t,e){let n=1/0,i=-1/0;for(let r=0,s=e.length;ri?a:i}this.min=n,this.max=i}isSeparated(t){return this.min>t.max||t.min>this.max}}PC.prototype.setFromBox=function(){const t=new Qi;return function(e,n){const i=n.min,r=n.max;let s=1/0,a=-1/0;for(let n=0;n<=1;n++)for(let o=0;o<=1;o++)for(let l=0;l<=1;l++){t.x=i.x*n+r.x*(1-n),t.y=i.y*o+r.y*(1-o),t.z=i.z*l+r.z*(1-l);const c=e.dot(t);s=Math.min(c,s),a=Math.max(c,a)}this.min=s,this.max=a}}(),new PC;const LC=function(){const t=new Qi,e=new Qi,n=new Qi;return function(i,r,s){const a=i.start,o=t,l=r.start,c=e;n.subVectors(a,l),t.subVectors(i.end,i.start),e.subVectors(r.end,r.start);const h=n.dot(c),u=c.dot(o),d=c.dot(c),p=n.dot(o),f=o.dot(o)*d-u*u;let m,g;m=0!==f?(h*u-p*d)/f:0,g=(h+m*u)/d,s.x=m,s.y=g}}(),UC=function(){const t=new ci,e=new Qi,n=new Qi;return function(i,r,s,a){LC(i,r,t);let o=t.x,l=t.y;if(o>=0&&o<=1&&l>=0&&l<=1)return i.at(o,s),void r.at(l,a);if(o>=0&&o<=1)return l<0?r.at(0,a):r.at(1,a),void i.closestPointToPoint(a,!0,s);if(l>=0&&l<=1)return o<0?i.at(0,s):i.at(1,s),void r.closestPointToPoint(s,!0,a);{let t,c;t=o<0?i.start:i.end,c=l<0?r.start:r.end;const h=e,u=n;return i.closestPointToPoint(c,!0,e),r.closestPointToPoint(t,!0,n),h.distanceToSquared(c)<=u.distanceToSquared(t)?(s.copy(h),void a.copy(c)):(s.copy(t),void a.copy(u))}}}(),NC=function(){const t=new Qi,e=new Qi,n=new ho,i=new Yu;return function(r,s){const{radius:a,center:o}=r,{a:l,b:c,c:h}=s;if(i.start=l,i.end=c,i.closestPointToPoint(o,!0,t).distanceTo(o)<=a)return!0;if(i.start=l,i.end=h,i.closestPointToPoint(o,!0,t).distanceTo(o)<=a)return!0;if(i.start=c,i.end=h,i.closestPointToPoint(o,!0,t).distanceTo(o)<=a)return!0;const u=s.getPlane(n);if(Math.abs(u.distanceToPoint(o))<=a){const t=u.projectPoint(o,e);if(s.containsPoint(t))return!0}return!1}}();function FC(t){return Math.abs(t)<1e-15}class OC extends is{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map((()=>new Qi)),this.satBounds=new Array(4).fill().map((()=>new PC)),this.points=[this.a,this.b,this.c],this.sphere=new or,this.plane=new ho,this.needsUpdate=!0}intersectsSphere(t){return NC(t,this)}update(){const t=this.a,e=this.b,n=this.c,i=this.points,r=this.satAxes,s=this.satBounds,a=r[0],o=s[0];this.getNormal(a),o.setFromPoints(a,i);const l=r[1],c=s[1];l.subVectors(t,e),c.setFromPoints(l,i);const h=r[2],u=s[2];h.subVectors(e,n),u.setFromPoints(h,i);const d=r[3],p=s[3];d.subVectors(n,t),p.setFromPoints(d,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}}OC.prototype.closestPointToSegment=function(){const t=new Qi,e=new Qi,n=new Yu;return function(i,r=null,s=null){const{start:a,end:o}=i,l=this.points;let c,h=1/0;for(let a=0;a<3;a++){const o=(a+1)%3;n.start.copy(l[a]),n.end.copy(l[o]),UC(n,i,t,e),c=t.distanceToSquared(e),c=2){(1===s?n.start:n.end).copy(p),r=2;break}if(r++,2===r&&-1===s)break}}return r}return function(a,h=null,p=!1){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(t.copy(a),t.update(),a=t);const m=this.plane,g=a.plane;if(Math.abs(m.normal.dot(g.normal))>1-1e-10){const t=this.satBounds,o=this.satAxes;n[0]=a.a,n[1]=a.b,n[2]=a.c;for(let e=0;e<4;e++){const r=t[e],s=o[e];if(i.setFromPoints(s,n),r.isSeparated(i))return!1}const l=a.satBounds,c=a.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let t=0;t<4;t++){const n=l[t],r=c[t];if(i.setFromPoints(r,e),n.isSeparated(i))return!1}for(let t=0;t<4;t++){const a=o[t];for(let t=0;t<4;t++){const o=c[t];if(s.crossVectors(a,o),i.setFromPoints(s,e),r.setFromPoints(s,n),i.isSeparated(r))return!1}}return h&&(p||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),h.start.set(0,0,0),h.end.set(0,0,0)),!0}{const t=f(this,g,u);if(1===t&&a.containsPoint(u.end))return h&&(h.start.copy(u.end),h.end.copy(u.end)),!0;if(2!==t)return!1;const e=f(a,m,d);if(1===e&&this.containsPoint(d.end))return h&&(h.start.copy(d.end),h.end.copy(d.end)),!0;if(2!==e)return!1;if(u.delta(o),d.delta(l),o.dot(l)<0){let t=d.start;d.start=d.end,d.end=t}const n=u.start.dot(o),i=u.end.dot(o),r=d.start.dot(o),s=d.end.dot(o);return(n===s||r===i||i0?h.start.copy(u.start):h.start.copy(d.start),c.subVectors(u.end,d.end),c.dot(o)<0?h.end.copy(u.end):h.end.copy(d.end)),!0)}}}(),OC.prototype.distanceToPoint=function(){const t=new Qi;return function(e){return this.closestPointToPoint(e,t),e.distanceTo(t)}}(),OC.prototype.distanceToTriangle=function(){const t=new Qi,e=new Qi,n=["a","b","c"],i=new Yu,r=new Yu;return function(s,a=null,o=null){const l=a||o?i:null;if(this.intersectsTriangle(s,l))return(a||o)&&(a&&l.getCenter(a),o&&l.getCenter(o)),0;let c=1/0;for(let e=0;e<3;e++){let i;const r=n[e],l=s[r];this.closestPointToPoint(l,t),i=l.distanceToSquared(t),inew Qi)),this.satAxes=new Array(3).fill().map((()=>new Qi)),this.satBounds=new Array(3).fill().map((()=>new PC)),this.alignedSatBounds=new Array(3).fill().map((()=>new PC)),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),n&&this.matrix.copy(n)}set(t,e,n){this.min.copy(t),this.max.copy(e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}}kC.prototype.update=function(){const t=this.matrix,e=this.min,n=this.max,i=this.points;for(let r=0;r<=1;r++)for(let s=0;s<=1;s++)for(let a=0;a<=1;a++){const o=i[1*r|2*s|4*a];o.x=r?n.x:e.x,o.y=s?n.y:e.y,o.z=a?n.z:e.z,o.applyMatrix4(t)}const r=this.satBounds,s=this.satAxes,a=i[0];for(let t=0;t<3;t++){const e=s[t],n=r[t],o=i[1<new Yu)),n=new Array(12).fill().map((()=>new Yu)),i=new Qi,r=new Qi;return function(s,a=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(s))return(o||l)&&(s.getCenter(r),this.closestPointToPoint(r,i),s.closestPointToPoint(i,r),o&&o.copy(i),l&&l.copy(r)),0;const c=a*a,h=s.min,u=s.max,d=this.points;let p=1/0;for(let t=0;t<8;t++){const e=d[t];r.copy(e).clamp(h,u);const n=e.distanceToSquared(r);if(nnew OC))}}const GC=new zC,HC=new class{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const t=[];let e=null;this.setBuffer=n=>{e&&t.push(e),e=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{e=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,0!==t.length&&this.setBuffer(t.pop())}}};let VC,WC;const jC=[],qC=new QC((()=>new Hi));function XC(t,e,n,i,r,s){VC=qC.getPrimitive(),WC=qC.getPrimitive(),jC.push(VC,WC),HC.setBuffer(t._roots[e]);const a=YC(0,t.geometry,n,i,r,s);HC.clearBuffer(),qC.releasePrimitive(VC),qC.releasePrimitive(WC),jC.pop(),jC.pop();const o=jC.length;return o>0&&(WC=jC[o-1],VC=jC[o-2]),a}function YC(t,e,n,i,r=null,s=0,a=0){const{float32Array:o,uint16Array:l,uint32Array:c}=HC;let h=2*t;if(vC(h,l)){const u=yC(t,c),d=_C(h,l);return aC(t,o,VC),i(u,d,!1,a,s+t,VC)}{const p=xC(t),f=wC(t,c);let m,g,A,v,y=p,_=f;if(r&&(A=VC,v=WC,aC(y,o,A),aC(_,o,v),m=r(A),g=r(v),g=169,$C=new Qi,tE=new Qi,eE=new Qi,nE=new ci,iE=new ci,rE=new ci,sE=new Qi,aE=new Qi,oE=new Qi,lE=new Qi;function cE(t,e,n,i,r,s,a){const o=3*i;let l=o+0,c=o+1,h=o+2;const u=t.index;t.index&&(l=u.getX(l),c=u.getX(c),h=u.getX(h));const{position:d,normal:p,uv:f,uv1:m}=t.attributes,g=function(t,e,n,i,r,s,a,o,l,c,h){$C.fromBufferAttribute(e,s),tE.fromBufferAttribute(e,a),eE.fromBufferAttribute(e,o);const u=function(t,e,n,i,r,s,a,o){let l;if(l=s===M?t.intersectTriangle(i,n,e,!0,r):t.intersectTriangle(e,n,i,s!==S,r),null===l)return null;const c=t.origin.distanceTo(r);return co?null:{distance:c,point:r.clone()}}(t,$C,tE,eE,lE,l,c,h);if(u){const e=new Qi;is.getBarycoord(lE,$C,tE,eE,e),i&&(nE.fromBufferAttribute(i,s),iE.fromBufferAttribute(i,a),rE.fromBufferAttribute(i,o),u.uv=is.getInterpolation(lE,$C,tE,eE,nE,iE,rE,new ci)),r&&(nE.fromBufferAttribute(r,s),iE.fromBufferAttribute(r,a),rE.fromBufferAttribute(r,o),u.uv1=is.getInterpolation(lE,$C,tE,eE,nE,iE,rE,new ci)),n&&(sE.fromBufferAttribute(n,s),aE.fromBufferAttribute(n,a),oE.fromBufferAttribute(n,o),u.normal=is.getInterpolation(lE,$C,tE,eE,sE,aE,oE,new Qi),u.normal.dot(t.direction)>0&&u.normal.multiplyScalar(-1));const l={a:s,b:a,c:o,normal:new Qi,materialIndex:0};is.getNormal($C,tE,eE,l.normal),u.face=l,u.faceIndex=s,ZC&&(u.barycoord=e)}return u}(n,d,p,f,m,l,c,h,e,s,a);return g?(g.faceIndex=i,r&&r.push(g),g):null}function hE(t,e,n,i){const r=t.a,s=t.b,a=t.c;let o=e,l=e+1,c=e+2;n&&(o=n.getX(o),l=n.getX(l),c=n.getX(c)),r.x=i.getX(o),r.y=i.getY(o),r.z=i.getZ(o),s.x=i.getX(l),s.y=i.getY(l),s.z=i.getZ(l),a.x=i.getX(c),a.y=i.getY(c),a.z=i.getZ(c)}const uE=new Qi,dE=new Qi,pE=new Qi,fE=new ci,mE=new ci,gE=new ci;function AE(t,e,n,i){const r=e.getIndex().array,s=e.getAttribute("position"),a=e.getAttribute("uv"),o=r[3*n],l=r[3*n+1],c=r[3*n+2];uE.fromBufferAttribute(s,o),dE.fromBufferAttribute(s,l),pE.fromBufferAttribute(s,c);let h=0;const u=e.groups,d=3*n;for(let t=0,e=u.length;t=n&&du&&(u=a),od&&(d=o),lp&&(p=l)}return(l[t+0]!==n||l[t+1]!==s||l[t+2]!==h||l[t+3]!==u||l[t+4]!==d||l[t+5]!==p)&&(l[t+0]=n,l[t+1]=s,l[t+2]=h,l[t+3]=u,l[t+4]=d,l[t+5]=p,!0)}{const i=t+8,r=a[t+6],o=i+n,c=r+n;let h=s,d=!1,p=!1;e?h||(d=e.has(o),p=e.has(c),h=!d&&!p):(d=!0,p=!0);const f=h||p;let m=!1;(h||d)&&(m=u(i,n,h));let g=!1;f&&(g=u(r,n,h));const A=m||g;if(A)for(let e=0;e<3;e++){const n=i+e,s=r+e,a=l[n],o=l[n+3],c=l[s],h=l[s+3];l[t+e]=ah?o:h}return A}}}function _E(t,e,n,i,r){let s,a,o,l,c,h;const u=1/n.direction.x,d=1/n.direction.y,p=1/n.direction.z,f=n.origin.x,m=n.origin.y,g=n.origin.z;let A=e[t],v=e[t+3],y=e[t+1],_=e[t+3+1],x=e[t+2],w=e[t+3+2];return u>=0?(s=(A-f)*u,a=(v-f)*u):(s=(v-f)*u,a=(A-f)*u),d>=0?(o=(y-m)*d,l=(_-m)*d):(o=(_-m)*d,l=(y-m)*d),!(s>l||o>a)&&((o>s||isNaN(s))&&(s=o),(l=0?(c=(x-g)*p,h=(w-g)*p):(c=(w-g)*p,h=(x-g)*p),!(s>h||c>a)&&((c>s||s!=s)&&(s=c),(h=i))}function xE(t,e,n,i,r,s,a){HC.setBuffer(t._roots[e]),wE(0,t,n,i,r,s,a),HC.clearBuffer()}function wE(t,e,n,i,r,s,a){const{float32Array:o,uint16Array:l,uint32Array:c}=HC,h=2*t;if(vC(h,l))!function(t,e,n,i,r,s,a,o){const{geometry:l,_indirectBuffer:c}=t;for(let t=i,c=i+r;t=0;let u,d;h?(u=xC(t),d=wC(t,l)):(u=wC(t,l),d=xC(t));const p=_E(u,a,i,r,s)?ME(u,e,n,i,r,s):null;if(p){const t=p.point[c];if(h?t<=a[d+o]:t>=a[d+o+3])return p}const f=_E(d,a,i,r,s)?ME(d,e,n,i,r,s):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}const SE=new Hi,bE=new OC,IE=new OC,TE=new gr,BE=new kC,RE=new kC;function DE(t,e,n,i){HC.setBuffer(t._roots[e]);const r=PE(0,t,n,i);return HC.clearBuffer(),r}function PE(t,e,n,i,r=null){const{float32Array:s,uint16Array:a,uint32Array:o}=HC;let l=2*t;if(null===r&&(n.boundingBox||n.computeBoundingBox(),BE.set(n.boundingBox.min,n.boundingBox.max,i),r=BE),!vC(l,a)){const a=t+8,l=o[t+6];return aC(a,s,SE),r.intersectsBox(SE)&&PE(a,e,n,i,r)?!0:(aC(l,s,SE),!(!r.intersectsBox(SE)||!PE(l,e,n,i,r)))}{const r=e.geometry,c=r.index,h=r.attributes.position,u=n.index,d=n.attributes.position,p=yC(t,o),f=_C(l,a);if(TE.copy(i).invert(),n.boundsTree){aC(t,s,RE),RE.matrix.copy(TE),RE.needsUpdate=!0;const e=n.boundsTree.shapecast({intersectsBounds:t=>RE.intersectsBox(t),intersectsTriangle:t=>{t.a.applyMatrix4(i),t.b.applyMatrix4(i),t.c.applyMatrix4(i),t.needsUpdate=!0;for(let e=3*p,n=3*(f+p);eUE.distanceToBox(t),intersectsBounds:(t,e,n)=>n{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:t=>NE.distanceToBox(t),intersectsBounds:(t,e,n)=>n{for(let a=e,o=e+r;ad&&(d=a),op&&(p=o),lf&&(f=l)}}return(l[n+0]!==s||l[n+1]!==c||l[n+2]!==u||l[n+3]!==d||l[n+4]!==p||l[n+5]!==f)&&(l[n+0]=s,l[n+1]=c,l[n+2]=u,l[n+3]=d,l[n+4]=p,l[n+5]=f,!0)}{const t=n+8,i=a[n+6],r=t+s,o=i+s;let h=c,d=!1,p=!1;e?h||(d=e.has(r),p=e.has(o),h=!d&&!p):(d=!0,p=!0);const f=h||p;let m=!1;(h||d)&&(m=u(t,s,h));let g=!1;f&&(g=u(i,s,h));const A=m||g;if(A)for(let e=0;e<3;e++){const r=t+e,s=i+e,a=l[r],o=l[r+3],c=l[s],h=l[s+3];l[n+e]=ah?o:h}return A}}}function VE(t,e,n,i,r,s,a){HC.setBuffer(t._roots[e]),WE(0,t,n,i,r,s,a),HC.clearBuffer()}function WE(t,e,n,i,r,s,a){const{float32Array:o,uint16Array:l,uint32Array:c}=HC,h=2*t;if(vC(h,l))!function(t,e,n,i,r,s,a,o){const{geometry:l,_indirectBuffer:c}=t;for(let t=i,h=i+r;t=0;let u,d;h?(u=xC(t),d=wC(t,l)):(u=wC(t,l),d=xC(t));const p=_E(u,a,i,r,s)?XE(u,e,n,i,r,s):null;if(p){const t=p.point[c];if(h?t<=a[d+o]:t>=a[d+o+3])return p}const f=_E(d,a,i,r,s)?XE(d,e,n,i,r,s):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}const YE=new Hi,JE=new OC,KE=new OC,ZE=new gr,$E=new kC,tM=new kC;function eM(t,e,n,i){HC.setBuffer(t._roots[e]);const r=nM(0,t,n,i);return HC.clearBuffer(),r}function nM(t,e,n,i,r=null){const{float32Array:s,uint16Array:a,uint32Array:o}=HC;let l=2*t;if(null===r&&(n.boundingBox||n.computeBoundingBox(),$E.set(n.boundingBox.min,n.boundingBox.max,i),r=$E),!vC(l,a)){const a=t+8,l=o[t+6];return aC(a,s,YE),r.intersectsBox(YE)&&nM(a,e,n,i,r)?!0:(aC(l,s,YE),!(!r.intersectsBox(YE)||!nM(l,e,n,i,r)))}{const r=e.geometry,c=r.index,h=r.attributes.position,u=n.index,d=n.attributes.position,p=yC(t,o),f=_C(l,a);if(ZE.copy(i).invert(),n.boundsTree){aC(t,s,tM),tM.matrix.copy(ZE),tM.needsUpdate=!0;const r=n.boundsTree.shapecast({intersectsBounds:t=>tM.intersectsBox(t),intersectsTriangle:t=>{t.a.applyMatrix4(i),t.b.applyMatrix4(i),t.c.applyMatrix4(i),t.needsUpdate=!0;for(let n=p,i=f+p;nrM.distanceToBox(t),intersectsBounds:(t,e,n)=>n{if(e.boundsTree){const o=e.boundsTree;return o.shapecast({boundsTraverseOrder:t=>sM.distanceToBox(t),intersectsBounds:(t,e,n)=>n{for(let x=e,w=e+a;xnew Hi)),mM=new Hi,gM=new Hi,AM=new Hi,vM=new Hi;let yM=!1;function _M(t,e,n,i,r,s=0,a=0,o=0,l=0,c=null,h=!1){let u,d;h?(u=pM,d=dM):(u=dM,d=pM);const p=u.float32Array,f=u.uint32Array,m=u.uint16Array,g=d.float32Array,A=d.uint32Array,v=d.uint16Array,y=2*e,_=vC(2*t,m),x=vC(y,v);let w=!1;if(x&&_)w=h?r(yC(e,A),_C(2*e,v),yC(t,f),_C(2*t,m),l,a+e,o,s+t):r(yC(t,f),_C(2*t,m),yC(e,A),_C(2*e,v),o,s+t,l,a+e);else if(x){const c=fM.getPrimitive();aC(e,g,c),c.applyMatrix4(n);const u=xC(t),d=wC(t,f);aC(u,p,mM),aC(d,p,gM);const m=c.intersectsBox(mM),A=c.intersectsBox(gM);w=m&&_M(e,u,i,n,r,a,s,l,o+1,c,!h)||A&&_M(e,d,i,n,r,a,s,l,o+1,c,!h),fM.releasePrimitive(c)}else{const u=xC(e),d=wC(e,A);aC(u,g,AM),aC(d,g,vM);const m=c.intersectsBox(AM),v=c.intersectsBox(vM);if(m&&v)w=_M(t,u,n,i,r,s,a,o,l+1,c,h)||_M(t,d,n,i,r,s,a,o,l+1,c,h);else if(m)if(_)w=_M(t,u,n,i,r,s,a,o,l+1,c,h);else{const e=fM.getPrimitive();e.copy(AM).applyMatrix4(n);const c=xC(t),d=wC(t,f);aC(c,p,mM),aC(d,p,gM);const m=e.intersectsBox(mM),g=e.intersectsBox(gM);w=m&&_M(u,c,i,n,r,a,s,l,o+1,e,!h)||g&&_M(u,d,i,n,r,a,s,l,o+1,e,!h),fM.releasePrimitive(e)}else if(v)if(_)w=_M(t,d,n,i,r,s,a,o,l+1,c,h);else{const e=fM.getPrimitive();e.copy(vM).applyMatrix4(n);const c=xC(t),u=wC(t,f);aC(c,p,mM),aC(u,p,gM);const m=e.intersectsBox(mM),g=e.intersectsBox(gM);w=m&&_M(d,c,i,n,r,a,s,l,o+1,e,!h)||g&&_M(d,u,i,n,r,a,s,l,o+1,e,!h),fM.releasePrimitive(e)}}return w}const xM=new kC,wM=new Hi,CM={strategy:Gw,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class EM{static serialize(t,e={}){e={cloneBuffers:!0,...e};const n=t.geometry,i=t._roots,r=t._indirectBuffer,s=n.getIndex();let a;return a=e.cloneBuffers?{roots:i.map((t=>t.slice())),index:s?s.array.slice():null,indirectBuffer:r?r.slice():null}:{roots:i,index:s?s.array:null,indirectBuffer:r},a}static deserialize(t,e,n={}){n={setIndex:!0,indirect:Boolean(t.indirectBuffer),...n};const{index:i,roots:r,indirectBuffer:s}=t,a=new EM(e,{...n,[$w]:!0});if(a._roots=r,a._indirectBuffer=s||null,n.setIndex){const n=e.getIndex();if(null===n){const n=new _s(t.index,1,!1);e.setIndex(n)}else n.array!==i&&(n.array.set(i),n.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(t,e={}){if(!t.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");if((e=Object.assign({...CM,[$w]:!1},e)).useSharedArrayBuffer&&!uM())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=t,this._roots=null,this._indirectBuffer=null,e[$w]||(DC(this,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new Hi))),this.resolveTriangleIndex=e.indirect?t=>this._indirectBuffer[t]:t=>t}refit(t=null){return(this.indirect?HE:yE)(this,t)}traverse(t,e=0){const n=this._roots[e],i=new Uint32Array(n),r=new Uint16Array(n);!function e(s,a=0){const o=2*s,l=r[o+15]===Kw;if(l){const e=i[s+6],c=r[o+14];t(a,l,new Float32Array(n,4*s,6),e,c)}else{const r=s+8,o=i[s+6],c=i[s+7];t(a,l,new Float32Array(n,4*s,6),c)||(e(r,a+1),e(o,a+1))}}(0)}raycast(t,e=E,n=0,i=1/0){const r=this._roots,s=this.geometry,a=[],o=e.isMaterial,l=Array.isArray(e),c=s.groups,h=o?e.side:e,u=this.indirect?VE:xE;for(let s=0,o=r.length;s!!t(i,r,s,o,l)||n(i,r,this,a,s,o,e)}else s||(s=a?(t,i,r,s)=>n(t,i,this,a,r,s,e):(t,e,n)=>n);let o=!1,l=0;const c=this._roots;for(let t=0,e=c.length;t{const e=this.resolveTriangleIndex(t);hE(s,3*e,a,o)}:t=>{hE(s,3*t,a,o)},c=GC.getPrimitive(),h=t.geometry.index,u=t.geometry.attributes.position,d=t.indirect?e=>{const n=t.resolveTriangleIndex(e);hE(c,3*n,h,u)}:t=>{hE(c,3*t,h,u)};if(r){const t=(t,n,i,a,o,h,u,p)=>{for(let f=i,m=i+a;fxM.intersectsBox(t),intersectsTriangle:t=>xM.intersectsTriangle(t)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n={},i={},r=0,s=1/0){return(this.indirect?hM:zE)(this,t,e,n,i,r,s)}closestPointToPoint(t,e={},n=0,i=1/0){return function(t,e,n={},i=0,r=1/0){const s=i*i,a=r*r;let o=1/0,l=null;if(t.shapecast({boundsTraverseOrder:t=>(JC.copy(e).clamp(t.min,t.max),JC.distanceToSquared(e)),intersectsBounds:(t,e,n)=>n{t.closestPointToPoint(e,JC);const i=e.distanceToSquared(JC);return i{aC(0,new Float32Array(e),wM),t.union(wM)})),t}}const MM=parseInt(p)>=166,SM=new mr,bM=new Qi,IM=new gr,TM=Ys.prototype.raycast,BM=Do.prototype.raycast,RM=new Qi,DM=new Ys,PM=[];function LM(t,e){this.isBatchedMesh?UM.call(this,t,e):NM.call(this,t,e)}function UM(t,e){if(this.boundsTrees){const n=this.boundsTrees,i=this._drawInfo||this._instanceInfo,r=this._drawRanges||this._geometryInfo,s=this.matrixWorld;DM.material=this.material,DM.geometry=this.geometry;const a=DM.geometry.boundsTree,o=DM.geometry.drawRange;null===DM.geometry.boundingSphere&&(DM.geometry.boundingSphere=new or);for(let a=0,o=i.length;a{if(t>=i||e)return s++,!0;r&&s++}),n);let a=0;const o=new Float32Array(24*s);let l,c;e.traverse(((t,e,n)=>{const s=t>=i||e;if(s||r){aC(0,n,zM);const{min:t,max:e}=zM;for(let n=-1;n<=1;n+=2){const i=n<0?t.x:e.x;for(let n=-1;n<=1;n+=2){const r=n<0?t.y:e.y;for(let n=-1;n<=1;n+=2){const s=n<0?t.z:e.z;o[a+0]=i,o[a+1]=r,o[a+2]=s,a+=3}}}return s}}),n),c=this.displayEdges?new Uint8Array([0,4,1,5,2,6,3,7,0,2,1,3,4,6,5,7,0,1,2,3,4,5,6,7]):new Uint8Array([0,1,2,2,1,3,4,6,5,6,7,5,1,4,5,0,4,1,2,3,6,3,7,6,0,2,4,2,6,4,1,5,3,3,5,7]),l=o.length>65535?new Uint32Array(c.length*s):new Uint16Array(c.length*s);const h=c.length;for(let t=0;tn;){const t=this._roots.pop();t.geometry.dispose(),this.remove(t)}for(let t=0;t=this._roots.length){const r=new HM(e,i,n,t);this.add(r),this._roots.push(r)}const o=this._roots[t];o.bvh=e,o.depth=n,o.displayParents=s,o.displayEdges=a,o.material=a?i:r,o.update()}}updateMatrixWorld(...t){const e=this.mesh,n=this.parent;null!==e&&(e.updateWorldMatrix(!0,!1),n?this.matrix.copy(n.matrixWorld).invert().multiply(e.matrixWorld):this.matrix.copy(e.matrixWorld),(e.isInstancedMesh||e.isBatchedMesh)&&(e.getMatrixAt(this.objectIndex,GM),this.matrix.multiply(GM)),this.matrix.decompose(this.position,this.quaternion,this.scale)),super.updateMatrixWorld(...t)}copy(t){this.depth=t.depth,this.mesh=t.mesh,this.bvh=t.bvh,this.opacity=t.opacity,this.color.copy(t.color)}clone(){return new VM(this.mesh,this.bvh,this.depth)}dispose(){this.edgeMaterial.dispose(),this.meshMaterial.dispose();const t=this.children;for(let e=0,n=t.length;efunction(t,e){const n={nodeCount:0,leafNodeCount:0,depth:{min:1/0,max:-1/0},tris:{min:1/0,max:-1/0},splits:[0,0,0],surfaceAreaScore:0};return t.traverse(((t,e,i,r,s)=>{const a=i[3]-i[0],o=i[4]-i[1],l=i[5]-i[2],c=2*(a*o+o*l+l*a);n.nodeCount++,e?(n.leafNodeCount++,n.depth.min=Math.min(t,n.depth.min),n.depth.max=Math.max(t,n.depth.max),n.tris.min=Math.min(s,n.tris.min),n.tris.max=Math.max(s,n.tris.max),n.surfaceAreaScore+=c*Xw*s):(n.splits[r]++,n.surfaceAreaScore+=c*Yw)}),e),n.tris.min===1/0&&(n.tris.min=0,n.tris.max=0),n.depth.min===1/0&&(n.depth.min=0,n.depth.max=0),n}(t,n)))}function JM(t){const e=new Set,n=[t];let i=0;for(;n.length;){const t=n.pop();if(!e.has(t)){e.add(t);for(let e in t){if(!Object.hasOwn(t,e))continue;i+=XM(e);const r=t[e];!r||"object"!=typeof r&&"function"!=typeof r?i+=XM(r):/(Uint|Int|Float)(8|16|32)Array/.test(r.constructor.name)||uM()&&r instanceof SharedArrayBuffer||r instanceof ArrayBuffer?i+=r.byteLength:n.push(r)}}}return i}function KM(t){const e=t.geometry,n=[],i=e.index,r=e.getAttribute("position");let s=!0;return t.traverse(((e,a,o,l,c)=>{const h={depth:e,isLeaf:a,boundingData:o,offset:l,count:c};n[e]=h,aC(0,o,WM);const u=n[e-1];if(a)for(let e=l,n=l+c;e{const a={bounds:aC(0,i,new Hi)};n?(a.count=s,a.offset=r):(a.left=null,a.right=null),e[t]=a;const o=e[t-1];o&&(null===o.left?o.left=a:o.right=a)})),e[0]}function $M(t){switch(t){case 1:return se;case 2:return oe;case 3:case 4:return ce}}class tS extends Xa{constructor(){super(),this.minFilter=Tt,this.magFilter=Tt,this.generateMipmaps=!1,this.overrideItemSize=null,this._forcedType=null}updateFrom(t){const e=this.overrideItemSize,n=t.itemSize,i=t.count;if(null!==e){if(n*i%e!=0)throw new Error("VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.");t.itemSize=e,t.count=i*n/e}const r=t.itemSize,s=t.count,a=t.normalized,o=t.array.constructor,l=o.BYTES_PER_ELEMENT;let c,h,u,d,p=this._forcedType,f=r;if(null===p)switch(o){case Float32Array:p=Wt;break;case Uint8Array:case Uint16Array:case Uint32Array:p=Vt;break;case Int8Array:case Int16Array:case Int32Array:p=Ht}let m=function(t){switch(t){case 1:return"R";case 2:return"RG";case 3:case 4:return"RGBA"}throw new Error}(r);switch(p){case Wt:u=1,h=function(t){switch(t){case 1:return re;case 2:return ae;case 3:case 4:return $t}}(r),a&&1===l?(d=o,m+="8",o===Uint8Array?c=kt:(c=Qt,m+="_SNORM")):(d=Float32Array,m+="32F",c=Wt);break;case Ht:m+=8*l+"I",u=a?Math.pow(2,8*o.BYTES_PER_ELEMENT-1):1,h=$M(r),1===l?(d=Int8Array,c=Qt):2===l?(d=Int16Array,c=zt):(d=Int32Array,c=Ht);break;case Vt:m+=8*l+"UI",u=a?Math.pow(2,8*o.BYTES_PER_ELEMENT-1):1,h=$M(r),1===l?(d=Uint8Array,c=kt):2===l?(d=Uint16Array,c=Gt):(d=Uint32Array,c=Vt)}3!==f||h!==$t&&h!==ce||(f=4);const g=Math.ceil(Math.sqrt(s))||1,A=new d(f*g*g),v=t.normalized;t.normalized=!1;for(let e=0;e=2&&(A[n+1]=t.getY(e)/u),r>=3&&(A[n+2]=t.getZ(e)/u,4===f&&(A[n+3]=1)),r>=4&&(A[n+3]=t.getW(e)/u)}t.normalized=v,this.internalFormat=m,this.format=h,this.type=c,this.image.width=g,this.image.height=g,this.image.data=A,this.needsUpdate=!0,this.dispose(),t.itemSize=n,t.count=i}}class eS extends tS{constructor(){super(),this._forcedType=Vt}}class nS extends tS{constructor(){super(),this._forcedType=Ht}}class iS extends tS{constructor(){super(),this._forcedType=Wt}}class rS{constructor(){this.index=new eS,this.position=new iS,this.bvhBounds=new Xa,this.bvhContents=new Xa,this._cachedIndexAttr=null,this.index.overrideItemSize=3}updateFrom(t){const{geometry:e}=t;if(function(t,e,n){const i=t._roots;if(1!==i.length)throw new Error("MeshBVHUniformStruct: Multi-root BVHs not supported.");const r=i[0],s=new Uint16Array(r),a=new Uint32Array(r),o=new Float32Array(r),l=r.byteLength/Jw,c=2*Math.ceil(Math.sqrt(l/2)),h=new Float32Array(4*c*c),u=Math.ceil(Math.sqrt(l)),d=new Uint32Array(2*u*u);for(let t=0;t=2&&e.setY(s,t.getY(r)),i>=3&&e.setZ(s,t.getZ(r)),i>=4&&e.setW(s,t.getW(r))}}else{const i=e.array,r=i.constructor,s=i.BYTES_PER_ELEMENT*t.itemSize*n;new r(i.buffer,s,t.array.length).set(t.array)}}function vS(t,e,n){const i=t.elements,r=e.elements;for(let t=0,e=r.length;t{t.traverseVisible((t=>{t.isMesh&&e.push(t)}))})),this.meshes=e,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(e.length).fill().map((()=>new Fs)),this._diffMap=new WeakMap}getMaterials(){const t=[];return this.meshes.forEach((e=>{Array.isArray(e.material)?t.push(...e.material):t.push(e.material)})),t}generate(t=new Fs){let e=[];const{meshes:n,useGroups:i,_intermediateGeometry:r,_diffMap:s}=this;for(let t=0,i=n.length;t{const i=t(e),r=t(n);return ir?1:0}):this._unloadPriorityCallback=t}constructor(){this.minSize=6e3,this.maxSize=8e3,this.minBytesSize=322122547.2,this.maxBytesSize=429496729.6,this.unloadPercent=.05,this.autoMarkUnused=!0,this.itemSet=new Map,this.itemList=[],this.usedSet=new Set,this.callbacks=new Map,this.unloadingHandle=-1,this.cachedBytes=0,this.bytesMap=new Map,this.loadedSet=new Set,this._unloadPriorityCallback=null,this.computeMemoryUsageCallback=()=>null;const t=this.itemSet;this.defaultPriorityCallback=e=>t.get(e)}isFull(){return this.itemSet.size>=this.maxSize||this.cachedBytes>=this.maxBytesSize}getMemoryUsage(t){return this.bytesMap.get(t)??null}add(t,e){const n=this.itemSet;if(n.has(t))return!1;if(this.isFull())return!1;const i=this.usedSet,r=this.itemList,s=this.callbacks,a=this.bytesMap;r.push(t),i.add(t),n.set(t,Date.now()),s.set(t,e);const o=this.computeMemoryUsageCallback(t);return this.cachedBytes+=o||0,a.set(t,o),!0}has(t){return this.itemSet.has(t)}remove(t){const e=this.usedSet,n=this.itemSet,i=this.itemList,r=this.bytesMap,s=this.callbacks,a=this.loadedSet;if(n.has(t)){this.cachedBytes-=r.get(t)||0,r.delete(t),s.get(t)(t);const o=i.indexOf(t);return i.splice(o,1),e.delete(t),n.delete(t),s.delete(t),a.delete(t),!0}return!1}setLoaded(t,e){const{itemSet:n,loadedSet:i}=this;n.has(t)&&(!0===e?i.add(t):i.delete(t))}updateMemoryUsage(t){const e=this.itemSet,n=this.bytesMap;if(!e.has(t))return;this.cachedBytes-=n.get(t)||0;const i=this.computeMemoryUsageCallback(t);n.set(t,i),this.cachedBytes+=i}markUsed(t){const e=this.itemSet,n=this.usedSet;e.has(t)&&!n.has(t)&&(e.set(t,Date.now()),n.add(t))}markUnused(t){this.usedSet.delete(t)}markAllUnused(){this.usedSet.clear()}unloadUnusedContent(){const{unloadPercent:t,minSize:e,maxSize:n,itemList:i,itemSet:r,usedSet:s,loadedSet:a,callbacks:o,bytesMap:l,minBytesSize:c,maxBytesSize:h}=this,u=i.length-s.size,d=i.length-a.size,p=Math.max(Math.min(i.length-e,u),0),f=this.cachedBytes-c,m=this.unloadPriorityCallback||this.defaultPriorityCallback;let g=!1;const A=p>0&&u>0||d&&i.length>n;if(u&&this.cachedBytes>c||d&&this.cachedBytes>h||A){i.sort(((t,e)=>{const n=s.has(t);if(n===s.has(e)){const n=a.has(t);return n===a.has(e)?-m(t,e):n?1:-1}return n?1:-1}));const d=Math.max(e*t,p*t),A=Math.ceil(Math.min(d,u,p)),v=Math.max(t*f,t*c),y=Math.min(v,f);let _=0,x=0;for(;this.cachedBytes-x>h||i.length-_>n;){const t=i[_],e=l.get(t)||0;if(s.has(t)&&a.has(t)||this.cachedBytes-x-e=A)break;x+=e,_++}i.splice(0,_).forEach((t=>{this.cachedBytes-=l.get(t)||0,o.get(t)(t),l.delete(t),r.delete(t),o.delete(t),a.delete(t),s.delete(t)})),g=_0}g&&(this.unloadingHandle=requestAnimationFrame((()=>this.scheduleUnload())))}scheduleUnload(){cancelAnimationFrame(this.unloadingHandle),this.scheduled||(this.scheduled=!0,queueMicrotask((()=>{this.scheduled=!1,this.unloadUnusedContent()})))}}class DS{constructor(){this.maxJobs=6,this.items=[],this.callbacks=new Map,this.currJobs=0,this.scheduled=!1,this.autoUpdate=!0,this.priorityCallback=()=>{throw new Error("PriorityQueue: PriorityCallback function not defined.")},this.schedulingCallback=t=>{requestAnimationFrame(t)},this._runjobs=()=>{this.tryRunJobs(),this.scheduled=!1}}sort(){const t=this.priorityCallback;this.items.sort(t)}add(t,e){return new Promise(((n,i)=>{const r=this.items,s=this.callbacks;r.push(t),s.set(t,((...t)=>e(...t).then(n).catch(i))),this.autoUpdate&&this.scheduleJobRun()}))}remove(t){const e=this.items,n=this.callbacks,i=e.indexOf(t);-1!==i&&(e.splice(i,1),n.delete(t))}tryRunJobs(){this.sort();const t=this.items,e=this.callbacks,n=this.maxJobs;let i=this.currJobs;for(;n>i&&t.length>0;){i++;const n=t.pop(),r=e.get(n);e.delete(n),r(n).then((()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()})).catch((()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()}))}this.currJobs=i}scheduleJobRun(){this.scheduled||(this.schedulingCallback(this._runjobs),this.scheduled=!0)}}const PS=-1,LS=0,US=1,NS=2,FS=3,OS=6378137,kS=1/298.257223563,QS=-(kS*OS-OS);function zS(t){return t===FS||t===PS}function GS(t,e){return t.__lastFrameVisited===e&&t.__used}function HS(t,e){t.__lastFrameVisited!==e.frameCount&&(t.__lastFrameVisited=e.frameCount,t.__used=!1,t.__inFrustum=!1,t.__isLeaf=!1,t.__visible=!1,t.__active=!1,t.__error=1/0,t.__distanceFromCamera=1/0,t.__childrenWereVisible=!1,t.__allChildrenLoaded=!1,t.__inFrustum=e.tileInView(t),e.calculateError(t))}function VS(t,e){if(e.ensureChildrenArePreprocessed(t),HS(t,e),jS(t,e),!t.__hasRenderableContent){const n=t.children;for(let t=0,i=n.length;t0&&t.__depth+1>=e.maxDepth)}(t,e))return void jS(t,e);let n=!1,i=!1;const r=t.children;for(let t=0,s=r.length;te.setTileVisible&&e.setTileVisible(t,r)))),t.__wasSetActive=i,t.__wasSetVisible=r,t.__usedLastFrame=n;const s=t.children;for(let t=0,n=s.length;tt.__depthFromRenderedParent!==e.__depthFromRenderedParent?t.__depthFromRenderedParent>e.__depthFromRenderedParent?-1:1:t.__inFrustum!==e.__inFrustum?t.__inFrustum?1:-1:t.__used!==e.__used?t.__used?1:-1:t.__error!==e.__error?t.__error>e.__error?1:-1:t.__distanceFromCamera!==e.__distanceFromCamera?t.__distanceFromCamera>e.__distanceFromCamera?-1:1:0,$S=(t,e)=>t.__depthFromRenderedParent!==e.__depthFromRenderedParent?t.__depthFromRenderedParent>e.__depthFromRenderedParent?1:-1:t.__loadingState!==e.__loadingState?t.__loadingState>e.__loadingState?-1:1:t.__lastFrameVisited!==e.__lastFrameVisited?t.__lastFrameVisited>e.__lastFrameVisited?-1:1:t.__hasUnrenderableContent!==e.__hasUnrenderableContent?t.__hasUnrenderableContent?-1:1:t.__error!==e.__error?t.__error>e.__error?-1:1:0;class tb{get root(){const t=this.rootTileSet;return t?t.root:null}get loadProgress(){const t=this.stats,e=t.downloading+t.parsing,n=t.inCacheSinceLoad;return 0===n?1:1-e/n}constructor(t=null){this.rootLoadingState=LS,this.rootTileSet=null,this.rootURL=t,this.fetchOptions={},this.plugins=[],this.queuedTiles=[],this.cachedSinceLoadComplete=new Set;const e=new RS;e.unloadPriorityCallback=$S;const n=new DS;n.maxJobs=10,n.priorityCallback=ZS;const i=new DS;i.maxJobs=1,i.priorityCallback=ZS,this.visibleTiles=new Set,this.activeTiles=new Set,this.usedSet=new Set,this.lruCache=e,this.downloadQueue=n,this.parseQueue=i,this.stats={inCacheSinceLoad:0,inCache:0,parsing:0,downloading:0,failed:0,inFrustum:0,used:0,active:0,visible:0},this.frameCount=0,this.errorTarget=6,this.errorThreshold=1/0,this.displayActiveTiles=!1,this.maxDepth=1/0}registerPlugin(t){if(!0===t[KS])throw new Error("TilesRendererBase: A plugin can only be registered to a single tile set");const e=this.plugins,n=t.priority||0;let i=0;for(let t=0;tn));t++);e.splice(i,0,t),t[KS]=!0,t.init&&t.init(this)}unregisterPlugin(t){const e=this.plugins;if("string"==typeof t&&(t=this.getPluginByName(name)),e.includes(t)){const n=e.indexOf(t);return e.splice(n,1),t.dispose&&t.dispose(),!0}return!1}getPluginByName(t){return this.plugins.find((e=>e.name===t))||null}traverse(t,e){this.root&&function(t,e=null,n=null){const i=[];for(i.push(t),i.push(null),i.push(0);i.length>0;){const t=i.pop(),r=i.pop(),s=i.pop();if(e&&e(s,r,t))return void(n&&n(s,r,t));const a=s.children;if(a)for(let e=a.length-1;e>=0;e--)i.push(a[e]),i.push(s),i.push(t+1);n&&n(s,r,t)}}(this.root,((e,...n)=>(this.ensureChildrenArePreprocessed(e),!!t&&t(e,...n))),e)}queueTileForDownload(t){t.__loadingState===LS&&this.queuedTiles.push(t)}markTileUsed(t){this.usedSet.add(t),this.lruCache.markUsed(t)}update(){const{lruCache:t,usedSet:e,stats:n,root:i}=this;if(this.rootLoadingState===LS&&(this.rootLoadingState=US,this.invokeOnePlugin((t=>t.loadRootTileSet&&t.loadRootTileSet())).then((()=>this.rootLoadingState=FS)).catch((t=>{this.rootLoadingState=PS,console.error(t)}))),!i)return;n.inFrustum=0,n.used=0,n.active=0,n.visible=0,this.frameCount++,e.forEach((e=>t.markUnused(e))),e.clear(),qS(i,this),XS(i,this),YS(i,this),JS(i,this);const r=this.queuedTiles;r.sort(t.unloadPriorityCallback);for(let e=0,n=r.length;e{t.__loadingState===PS&&(t.__loadingState=LS)})),t.failed=0)}dispose(){this.invokeAllPlugins((t=>{t!==this&&t.dispose&&t.dispose()}));const t=this.lruCache,e=[];this.traverse((t=>(e.push(t),!1)));for(let n=0,i=e.length;ne.setTileVisible&&e.setTileVisible(t,!1))),t.__visible=!1),t.__active&&(this.setTileActive(t,!1),t.__active=!1)}preprocessNode(t,e,n=null){if(t.content&&(!("uri"in t.content)&&"url"in t.content&&(t.content.uri=t.content.url,delete t.content.url),t.content.boundingVolume&&!("box"in t.content.boundingVolume||"sphere"in t.content.boundingVolume||"region"in t.content.boundingVolume)&&delete t.content.boundingVolume),t.parent=n,t.children=t.children||[],t.content?.uri){const e=BS(t.content.uri);t.__hasContent=!0,t.__hasUnrenderableContent=Boolean(e&&/json$/.test(e)),t.__hasRenderableContent=!t.__hasUnrenderableContent}else t.__hasContent=!1,t.__hasUnrenderableContent=!1,t.__hasRenderableContent=!1;t.__distanceFromCamera=1/0,t.__error=1/0,t.__inFrustum=!1,t.__isLeaf=!1,t.__usedLastFrame=!1,t.__used=!1,t.__wasSetVisible=!1,t.__visible=!1,t.__childrenWereVisible=!1,t.__allChildrenLoaded=!1,t.__wasSetActive=!1,t.__active=!1,t.__loadingState=LS,null===n?(t.__depth=0,t.__depthFromRenderedParent=t.__hasRenderableContent?1:0,t.refine=t.refine||"REPLACE"):(t.__depth=n.__depth+1,t.__depthFromRenderedParent=n.__depthFromRenderedParent+(t.__hasRenderableContent?1:0),t.refine=t.refine||n.refine),t.__basePath=e,t.__lastFrameVisited=-1,this.invokeAllPlugins((i=>{i!==this&&i.preprocessNode&&i.preprocessNode(t,e,n)}))}setTileActive(t,e){e?this.activeTiles.add(t):this.activeTiles.delete(t)}setTileVisible(t,e){e?this.visibleTiles.add(t):this.visibleTiles.delete(t)}calculateError(t){return 0}tileInView(t){return!0}ensureChildrenArePreprocessed(t){const e=t.children;for(let n=0,i=e.length;nparseInt(t)));console.assert(r<=1,"TilesRenderer: asset.version is expected to be a 1.x or a compatible version."),1===r&&s>0&&console.warn("TilesRenderer: tiles versions at 1.1 or higher have limited support. Some new extensions and features may not be supported.");let a=e.replace(/\/[^/]*\/?$/,"");a=new URL(a,window.location.href).toString(),this.preprocessNode(t.root,a,n)}loadRootTileSet(){let t=this.rootURL;this.invokeAllPlugins((e=>t=e.preprocessURL?e.preprocessURL(t,null):t));const e=this.invokeOnePlugin((e=>e.fetchData&&e.fetchData(t,this.fetchOptions))).then((e=>{if(e.ok)return e.json();throw new Error(`TilesRenderer: Failed to load tileset "${t}" with status ${e.status} : ${e.statusText}`)})).then((e=>{this.preprocessTileSet(e,t),this.rootTileSet=e}));return e.catch((e=>{console.error(e),this.rootTileSet=null,this.dispatchEvent({type:"load-error",tile:null,error:e,uri:t})})),e}requestTileContents(t){if(t.__loadingState!==LS)return;let e=!1,n=new URL(t.content.uri,t.__basePath+"/").toString();this.invokeAllPlugins((e=>n=e.preprocessURL?e.preprocessURL(n,t):n));const i=this.stats,r=this.lruCache,s=this.downloadQueue,a=this.parseQueue,o=BS(n),l=new AbortController,c=l.signal;return r.add(t,(n=>{l.abort(),e?n.children.length=0:this.invokeAllPlugins((t=>{t.disposeTile&&t.disposeTile(n)})),i.inCache--,this.cachedSinceLoadComplete.has(t)&&(this.cachedSinceLoadComplete.delete(t),i.inCacheSinceLoad--),n.__loadingState===US?i.downloading--:n.__loadingState===NS&&i.parsing--,n.__loadingState=LS,a.remove(n),s.remove(n)}))?(0===i.parsing&&0===i.downloading&&this.dispatchEvent({type:"tiles-load-start"}),this.cachedSinceLoadComplete.add(t),i.inCacheSinceLoad++,i.inCache++,i.downloading++,t.__loadingState=US,s.add(t,(t=>c.aborted?Promise.resolve():this.invokeOnePlugin((t=>t.fetchData&&t.fetchData(n,{...this.fetchOptions,signal:c}))))).then((t=>{if(!c.aborted){if(t.ok)return"json"===o?t.json():t.arrayBuffer();throw new Error(`Failed to load model with error code ${t.status}`)}})).then((r=>{if(!c.aborted)return i.downloading--,i.parsing++,t.__loadingState=NS,a.add(t,(i=>c.aborted?Promise.resolve():"json"===o&&r.root?(this.preprocessTileSet(r,n,t),t.children.push(r.root),e=!0,Promise.resolve()):this.invokeOnePlugin((t=>t.parseTile&&t.parseTile(r,i,o,n,c)))))})).then((()=>{c.aborted||(i.parsing--,t.__loadingState=FS,r.setLoaded(t,!0),null===r.getMemoryUsage(t)&&(r.isFull()&&r.computeMemoryUsageCallback(t)>0?r.remove(t):r.updateMemoryUsage(t)),t.cached.scene&&this.dispatchEvent({type:"load-model",scene:t.cached.scene,tile:t}))})).catch((e=>{c.aborted||("AbortError"!==e.name?(a.remove(t),s.remove(t),t.__loadingState===NS?i.parsing--:t.__loadingState===US&&i.downloading--,i.failed++,console.error(`TilesRenderer : Failed to load tile at url "${t.content.uri}".`),console.error(e),t.__loadingState=PS,r.setLoaded(t,!0),this.dispatchEvent({type:"load-error",tile:t,error:e,uri:n})):r.remove(t))})).finally((()=>{0===i.parsing&&0===i.downloading&&(this.cachedSinceLoadComplete.clear(),i.inCacheSinceLoad=0,this.dispatchEvent({type:"tiles-load-end"}))}))):void 0}getAttributions(t=[]){return this.invokeAllPlugins((e=>e!==this&&e.getAttributions&&e.getAttributions(t))),t}invokeOnePlugin(t){const e=[...this.plugins,this];for(let n=0;na+o)throw new Error("FeatureTable: Feature data read outside binary body length.");return d}}return s}getBuffer(t,e){const{buffer:n,binOffset:i}=this;return n.slice(i+t,i+t+e)}}class sb{constructor(t){this.batchTable=t;const e=t.header.extensions["3DTILES_batch_table_hierarchy"];this.classes=e.classes;for(const t of this.classes){const e=t.instances;for(const n in e)t.instances[n]=this._parseProperty(e[n],t.length,n)}if(this.instancesLength=e.instancesLength,this.classIds=this._parseProperty(e.classIds,this.instancesLength,"classIds"),e.parentCounts?this.parentCounts=this._parseProperty(e.parentCounts,this.instancesLength,"parentCounts"):this.parentCounts=new Array(this.instancesLength).fill(1),e.parentIds){const t=this.parentCounts.reduce(((t,e)=>t+e),0);this.parentIds=this._parseProperty(e.parentIds,t,"parentIds")}else this.parentIds=null;this.instancesIds=[];const n={};for(const t of this.classIds)n[t]=n[t]??0,this.instancesIds.push(n[t]),n[t]++}_parseProperty(t,e,n){if(Array.isArray(t))return t;{const{buffer:i,binOffset:r}=this.batchTable;return ib(i,r+t.byteOffset,e,"SCALAR",t.componentType||"UNSIGNED_SHORT",n)}}getDataFromId(t,e={}){const n=this.parentCounts[t];if(this.parentIds&&n>0){let i=0;for(let e=0;e=this.count)throw new Error(`BatchTable: id value "${t}" out of bounds for "${this.count}" features number.`);for(const n of this.getKeys())"extensions"!==n&&(e[n]=super.getData(n,this.count)[t]);for(const n in this.extensions){const i=this.extensions[n];i.getDataFromId instanceof Function&&(e[n]=e[n]||{},i.getDataFromId(t,e[n]))}return e}getPropertyArray(t){return super.getData(t,this.count)}}class ob{constructor(){this.fetchOptions={},this.workingPath=""}load(t){return console.warn('Loader: "load" function has been deprecated in favor of "loadAsync".'),this.loadAsync(t)}loadAsync(t){return fetch(t,this.fetchOptions).then((e=>{if(!e.ok)throw new Error(`Failed to load file "${t}" with status ${e.status} : ${e.statusText}`);return e.arrayBuffer()})).then((e=>(""===this.workingPath&&(this.workingPath=this.workingPathForURL(t)),this.parse(e))))}resolveExternalURL(t){return/^[^\\/]/.test(t)&&!/^http/.test(t)?this.workingPath+"/"+t:t}workingPathForURL(t){const e=t.split(/[\\/]/g);return e.pop(),e.join("/")+"/"}parse(t){throw new Error("LoaderBase: Parse not implemented.")}}function lb(t){let e;if(e=t instanceof DataView?t:new DataView(t),"{"===String.fromCharCode(e.getUint8(0)))return null;let n="";for(let t=0;t<4;t++)n+=String.fromCharCode(e.getUint8(t));return n}class cb extends ob{parse(t){const e=new DataView(t),n=lb(e);console.assert("b3dm"===n);const i=e.getUint32(4,!0);console.assert(1===i);const r=e.getUint32(8,!0);console.assert(r===t.byteLength);const s=e.getUint32(12,!0),a=e.getUint32(16,!0),o=e.getUint32(20,!0),l=e.getUint32(24,!0),c=t.slice(28,28+s+a),h=new rb(c,0,s,a),u=28+s+a,d=t.slice(u,u+o+l),p=new ab(d,h.getData("BATCH_LENGTH"),0,o,l),f=u+o+l;return{version:i,featureTable:h,batchTable:p,glbBytes:new Uint8Array(t,f,r-f)}}}class hb extends cb{constructor(t=uh){super(),this.manager=t,this.adjustmentTransform=new gr}parse(t){const e=super.parse(t),n=e.glbBytes.slice().buffer;return new Promise(((t,i)=>{const r=this.manager,s=this.fetchOptions,a=r.getHandler("path.gltf")||new Pg(r);"include"===s.credentials&&"cors"===s.mode&&a.setCrossOrigin("use-credentials"),"credentials"in s&&a.setWithCredentials("include"===s.credentials),s.headers&&a.setRequestHeader(s.headers);let o=this.workingPath;!/[\\/]$/.test(o)&&o.length&&(o+="/");const l=this.adjustmentTransform;a.parse(n,o,(n=>{const{batchTable:i,featureTable:r}=e,{scene:s}=n,a=r.getData("RTC_CENTER");a&&(s.position.x+=a[0],s.position.y+=a[1],s.position.z+=a[2]),n.scene.updateMatrix(),n.scene.matrix.multiply(l),n.scene.matrix.decompose(n.scene.position,n.scene.quaternion,n.scene.scale),n.batchTable=i,n.featureTable=r,s.batchTable=i,s.featureTable=r,t(n)}),i)}))}}class ub extends ob{parse(t){const e=new DataView(t),n=lb(e);console.assert("pnts"===n);const i=e.getUint32(4,!0);console.assert(1===i);const r=e.getUint32(8,!0);console.assert(r===t.byteLength);const s=e.getUint32(12,!0),a=e.getUint32(16,!0),o=e.getUint32(20,!0),l=e.getUint32(24,!0),c=t.slice(28,28+s+a),h=new rb(c,0,s,a),u=28+s+a,d=t.slice(u,u+o+l),p=new ab(d,h.getData("BATCH_LENGTH")||h.getData("POINTS_LENGTH"),0,o,l);return Promise.resolve({version:i,featureTable:h,batchTable:p})}}function db(t){const e=t>>11,n=t>>5&63,i=31&t;return[Math.round(e/31*255),Math.round(n/63*255),Math.round(i/31*255)]}const pb=new ci;function fb(t,e,n=new Qi){pb.set(t,e).divideScalar(256).multiplyScalar(2).subScalar(1),n.set(pb.x,pb.y,1-Math.abs(pb.x)-Math.abs(pb.y));const i=li.clamp(-n.z,0,1);return n.x>=0?n.setX(n.x-i):n.setX(n.x+i),n.y>=0?n.setY(n.y-i):n.setY(n.y+i),n.normalize(),n}const mb={RGB:"color",POSITION:"position"};class gb extends ub{constructor(t=uh){super(),this.manager=t}parse(t){return super.parse(t).then((async t=>{const{featureTable:e,batchTable:n}=t,i=new qo,r=e.header.extensions,s=new Qi;let a;if(r&&r["3DTILES_draco_point_compression"]){const{byteOffset:t,byteLength:n,properties:s}=r["3DTILES_draco_point_compression"],o=this.manager.getHandler("draco.drc");if(null==o)throw new Error("PNTSLoader: dracoLoader not available.");const l={};for(const t in s)t in mb&&t in s&&(l[mb[t]]=s[t]);const c={attributeIDs:l,attributeTypes:{position:"Float32Array",color:"Uint8Array"},useUniqueIDs:!0},h=e.getBuffer(t,n);a=await o.decodeGeometry(h,c),a.attributes.color&&(i.vertexColors=!0)}else{const t=e.getData("POINTS_LENGTH"),n=e.getData("POSITION",t,"FLOAT","VEC3"),r=e.getData("NORMAL",t,"FLOAT","VEC3"),o=e.getData("NORMAL",t,"UNSIGNED_BYTE","VEC2"),l=e.getData("RGB",t,"UNSIGNED_BYTE","VEC3"),c=e.getData("RGBA",t,"UNSIGNED_BYTE","VEC4"),h=e.getData("RGB565",t,"UNSIGNED_SHORT","SCALAR"),u=e.getData("CONSTANT_RGBA",t,"UNSIGNED_BYTE","VEC4"),d=e.getData("POSITION_QUANTIZED",t,"UNSIGNED_SHORT","VEC3"),p=e.getData("QUANTIZED_VOLUME_SCALE",t,"FLOAT","VEC3"),f=e.getData("QUANTIZED_VOLUME_OFFSET",t,"FLOAT","VEC3");if(a=new Fs,d){const e=new Float32Array(3*t);for(let n=0;n{if(!e.ok)throw new Error(`I3DMLoaderBase : Failed to load file "${t}" with status ${e.status} : ${e.statusText}`);return e.arrayBuffer()})).then((t=>{A=new Uint8Array(t)}))}return v.then((()=>({version:i,featureTable:u,batchTable:f,glbBytes:A,gltfWorkingPath:y})))}}const vb=new Gu,yb=new Qi,_b={};function xb(t){const{x:e,y:n,z:i}=t;t.x=i,t.y=e,t.z=n}function wb(t){const{x:e,y:n,z:i}=t;t.z=e,t.x=n,t.y=i}function Cb(t){return-(t-Math.PI/2)}function Eb(t){return-t+Math.PI/2}function Mb(t,e="E",n="W"){const i=t<0?n:e,r=~~(t=Math.abs(t)),s=60*(t-r),a=~~s;return`${r}° ${a}' ${~~(60*(s-a))}" ${i}`}function Sb(t,e,n=!1){const i=function(t,e,n={}){return vb.theta=e,vb.phi=Eb(t),yb.setFromSpherical(vb),vb.setFromVector3(yb),n.lat=Cb(vb.phi),n.lon=vb.theta,n}(t,e,_b);let r,s;return n?(r=`${(li.RAD2DEG*i.lat).toFixed(4)}°`,s=`${(li.RAD2DEG*i.lon).toFixed(4)}°`):(r=Mb(li.RAD2DEG*i.lat,"N","S"),s=Mb(li.RAD2DEG*i.lon,"E","W")),`${r} ${s}`}const bb=new Gu,Ib=new Qi,Tb=new Qi,Bb=new Qi,Rb=new gr,Db=new gr,Pb=new or,Lb=new Sr,Ub=new Qi,Nb=new Qi,Fb=new Qi,Ob=new Qi,kb=new mr,Qb=0,zb=1,Gb=2;class Hb{constructor(t=1,e=1,n=1){this.name="",this.radius=new Qi(t,e,n)}intersectRay(t,e){return Rb.makeScale(...this.radius).invert(),Pb.center.set(0,0,0),Pb.radius=1,kb.copy(t).applyMatrix4(Rb),kb.intersectSphere(Pb,e)?(Rb.makeScale(...this.radius),e.applyMatrix4(Rb),e):null}getEastNorthUpFrame(t,e,n){return this.getEastNorthUpAxes(t,e,Ub,Nb,Fb,Ob),n.makeBasis(Ub,Nb,Fb).setPosition(Ob)}getEastNorthUpAxes(t,e,n,i,r,s=Ob){this.getCartographicToPosition(t,e,0,s),this.getCartographicToNormal(t,e,r),n.set(-s.y,s.x,0).normalize(),i.crossVectors(r,n).normalize()}getAzElRollFromRotationMatrix(t,e,n,i,r=Qb){return r===zb?(Lb.set(-Math.PI/2,0,0,"XYZ"),Db.makeRotationFromEuler(Lb).premultiply(n)):r===Gb?(Lb.set(-Math.PI/2,0,Math.PI,"XYZ"),Db.makeRotationFromEuler(Lb).premultiply(n)):Db.copy(n),this.getEastNorthUpFrame(t,e,Rb).invert(),Db.premultiply(Rb),Lb.setFromRotationMatrix(Db,"ZXY"),i.azimuth=-Lb.z,i.elevation=Lb.x,i.roll=Lb.y,i}getRotationMatrixFromAzElRoll(t,e,n,i,r,s,a=Qb){return this.getEastNorthUpFrame(t,e,Rb),Lb.set(i,r,-n,"ZXY"),s.makeRotationFromEuler(Lb).premultiply(Rb).setPosition(0,0,0),a===zb?(Lb.set(Math.PI/2,0,0,"XYZ"),Db.makeRotationFromEuler(Lb),s.multiply(Db)):a===Gb&&(Lb.set(-Math.PI/2,0,Math.PI,"XYZ"),Db.makeRotationFromEuler(Lb),s.multiply(Db)),s}getFrame(t,e,n,i,r,s,a,o=Qb){return this.getRotationMatrixFromAzElRoll(t,e,n,i,r,a,o),this.getCartographicToPosition(t,e,s,Ob),a.setPosition(Ob),a}getCartographicToPosition(t,e,n,i){this.getCartographicToNormal(t,e,Ib);const r=this.radius;Tb.copy(Ib),Tb.x*=r.x**2,Tb.y*=r.y**2,Tb.z*=r.z**2;const s=Math.sqrt(Ib.dot(Tb));return Tb.divideScalar(s),i.copy(Tb).addScaledVector(Ib,n)}getPositionToCartographic(t,e){this.getPositionToSurfacePoint(t,Tb),this.getPositionToNormal(t,Ib);const n=Bb.subVectors(t,Tb);return e.lon=Math.atan2(Ib.y,Ib.x),e.lat=Math.asin(Ib.z),e.height=Math.sign(n.dot(t))*n.length(),e}getCartographicToNormal(t,e,n){return bb.set(1,Eb(t),e),n.setFromSpherical(bb).normalize(),xb(n),n}getPositionToNormal(t,e){const n=this.radius;return e.copy(t),e.x/=n.x**2,e.y/=n.y**2,e.z/=n.z**2,e.normalize(),e}getPositionToSurfacePoint(t,e){const n=this.radius,i=1/n.x**2,r=1/n.y**2,s=1/n.z**2,a=t.x*t.x*i,o=t.y*t.y*r,l=t.z*t.z*s,c=a+o+l,h=Math.sqrt(1/c),u=Tb.copy(t).multiplyScalar(h);if(c<.1)return isFinite(h)?e.copy(u):null;const d=Bb.set(u.x*i*2,u.y*r*2,u.z*s*2);let p,f,m,g,A,v,y,_,x,w,C,E=(1-h)*t.length()/(.5*d.length()),M=0;do{E-=M,m=1/(1+E*i),g=1/(1+E*r),A=1/(1+E*s),v=m*m,y=g*g,_=A*A,x=v*m,w=y*g,C=_*A,p=a*v+o*y+l*_-1,f=a*x*i+o*w*r+l*C*s,M=p/(-2*f)}while(Math.abs(p)>1e-12);return e.set(t.x*m,t.y*g,t.z*A)}calculateHorizonDistance(t,e){const n=this.calculateEffectiveRadius(t);return Math.sqrt(2*n*e+e**2)}calculateEffectiveRadius(t){const e=this.radius.x,n=1-this.radius.z**2/e**2,i=t*li.DEG2RAD,r=Math.sin(i)**2;return e/Math.sqrt(1-n*r)}getPositionElevation(t){this.getPositionToSurfacePoint(t,Tb);const e=Bb.subVectors(t,Tb);return Math.sign(e.dot(t))*e.length()}copy(t){return this.radius.copy(t.radius),this}clone(){return(new this.constructor).copy(this)}}const Vb=new Hb(OS,OS,QS);Vb.name="WGS84 Earth";const Wb=new Qi,jb=new Qi,qb=new Qi,Xb=new Qi,Yb=new ki,Jb=new Qi,Kb=new gr,Zb=new gr,$b=new Qi,tI=new gr,eI=new ki,nI={};class iI extends Ab{constructor(t=uh){super(),this.manager=t,this.adjustmentTransform=new gr,this.ellipsoid=Vb.clone()}resolveExternalURL(t){return this.manager.resolveURL(super.resolveExternalURL(t))}parse(t){return super.parse(t).then((t=>{const{featureTable:e,batchTable:n}=t,i=t.glbBytes.slice().buffer;return new Promise(((r,s)=>{const a=this.fetchOptions,o=this.manager,l=o.getHandler("path.gltf")||new Pg(o);"include"===a.credentials&&"cors"===a.mode&&l.setCrossOrigin("use-credentials"),"credentials"in a&&l.setWithCredentials("include"===a.credentials),a.headers&&l.setRequestHeader(a.headers);let c=t.gltfWorkingPath??this.workingPath;/[\\/]$/.test(c)||(c+="/");const h=this.adjustmentTransform;l.parse(i,c,(t=>{const i=e.getData("INSTANCES_LENGTH"),s=e.getData("POSITION",i,"FLOAT","VEC3"),a=e.getData("NORMAL_UP",i,"FLOAT","VEC3"),o=e.getData("NORMAL_RIGHT",i,"FLOAT","VEC3"),l=e.getData("SCALE_NON_UNIFORM",i,"FLOAT","VEC3"),c=e.getData("SCALE",i,"FLOAT","SCALAR"),u=e.getData("RTC_CENTER"),d=e.getData("EAST_NORTH_UP");["QUANTIZED_VOLUME_OFFSET","QUANTIZED_VOLUME_SCALE","POSITION_QUANTIZED","NORMAL_UP_OCT32P","NORMAL_RIGHT_OCT32P"].forEach((t=>{t in e.header&&console.warn(`I3DMLoader: Unsupported FeatureTable feature "${t}" detected.`)}));const p=new Qi;for(let t=0;t{if(t.isMesh){m.push(t);const{geometry:e,material:n}=t,r=new ao(e,n,i);r.position.copy(p),u&&(r.position.x+=u[0],r.position.y+=u[1],r.position.z+=u[2]),f.push(r)}}));for(let t=0;t{const e=new tl;return t.forEach((t=>{e.add(t.scene)})),{tiles:t,scene:e}}))}}const aI=new gr;class oI extends tl{constructor(t){super(),this.name="TilesRenderer.TilesGroup",this.tilesRenderer=t}raycast(t,e){return!this.tilesRenderer.optimizeRaycast||(this.tilesRenderer.raycast(t,e),!1)}updateMatrixWorld(t){if(this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldNeedsUpdate||t){null===this.parent?aI.copy(this.matrix):aI.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1;const t=aI.elements,e=this.matrixWorld.elements;let n=!1;for(let i=0;i<16;i++){const r=t[i],s=e[i];if(Math.abs(r-s)>Number.EPSILON){n=!0;break}}if(n){this.matrixWorld.copy(aI);const t=this.children;for(let e=0,n=t.length;en.raycastTile&&n.raycastTile(t,r,e,i)))||e.intersectObject(r,!0,i)}function fI(t,e,n,i=null){const{group:r,activeTiles:s}=t;t.ensureChildrenArePreprocessed(e),null===i&&(i=cI,lI.copy(r.matrixWorld).invert(),i.copy(n.ray).applyMatrix4(lI));const a=[],o=e.children;for(let t=0,e=o.length;tc)break;const h=fI(t,o,n,i);if(h){const t=h.distance*h.distance;tnew Qi)),this.planes=new Array(6).fill().map((()=>new ho))}clampPoint(t,e){return e.copy(t).applyMatrix4(this.inverseTransform).clamp(this.box.min,this.box.max).applyMatrix4(this.transform)}distanceToPoint(t){return this.clampPoint(t,vI).distanceTo(t)}containsPoint(t){return vI.copy(t).applyMatrix4(this.inverseTransform),this.box.containsPoint(vI)}intersectsRay(t){return yI.copy(t).applyMatrix4(this.inverseTransform),yI.intersectsBox(this.box)}intersectRay(t,e){return yI.copy(t).applyMatrix4(this.inverseTransform),yI.intersectBox(this.box,e)?(e.applyMatrix4(this.transform),e):null}update(){const{points:t,inverseTransform:e,transform:n,box:i}=this;e.copy(n).invert();const{min:r,max:s}=i;let a=0;for(let e=-1;e<=1;e+=2)for(let i=-1;i<=1;i+=2)for(let o=-1;o<=1;o+=2)t[a].set(e<0?r.x:s.x,i<0?r.y:s.y,o<0?r.z:s.z).applyMatrix4(n),a++;this.updatePlanes()}updatePlanes(){gI.copy(this.box.min).applyMatrix4(this.transform),AI.copy(this.box.max).applyMatrix4(this.transform),vI.set(0,0,1).transformDirection(this.transform),this.planes[0].setFromNormalAndCoplanarPoint(vI,gI),this.planes[1].setFromNormalAndCoplanarPoint(vI,AI).negate(),vI.set(0,1,0).transformDirection(this.transform),this.planes[2].setFromNormalAndCoplanarPoint(vI,gI),this.planes[3].setFromNormalAndCoplanarPoint(vI,AI).negate(),vI.set(1,0,0).transformDirection(this.transform),this.planes[4].setFromNormalAndCoplanarPoint(vI,gI),this.planes[5].setFromNormalAndCoplanarPoint(vI,AI).negate()}intersectsFrustum(t){const{points:e}=this,{planes:n}=t;for(let t=0;t<6;t++){const i=n[t];let r=-1/0;for(let t=0;t<8;t++){const n=e[t],s=i.distanceToPoint(n);r=r=e&&a<=n&&o>=i&&o<=r){const e=TI(t);u.push(e),this.getCartographicToPosition(a,o,l,e)}}}return u}getBoundingBox(t,e){BI();const{latStart:n,latEnd:i,lonStart:r,lonEnd:s}=this;if(i-nr?i:r}intersectsFrustum(t){const e=this.obb||this.regionObb,n=this.sphere;return!(n&&!t.intersectsSphere(n))&&!(e&&!e.intersectsFrustum(t))&&Boolean(n||e)}getOBB(t,e){const n=this.obb||this.regionObb;n?(t.copy(n.box),e.copy(n.transform)):(this.getAABB(t),e.identity())}getAABB(t){if(this.sphere)this.sphere.getBoundingBox(t);else{const e=this.obb||this.regionObb;t.copy(e.box).applyMatrix4(e.transform)}}getSphere(t){if(this.sphere)t.copy(this.sphere);else if(this.region)this.region.getBoundingSphere(t);else{const e=this.obb||this.regionObb;e.box.getBoundingSphere(t),t.applyMatrix4(e.transform)}}setObbData(t,e){const n=new _I;DI.set(t[3],t[4],t[5]),PI.set(t[6],t[7],t[8]),LI.set(t[9],t[10],t[11]);const i=DI.length(),r=PI.length(),s=LI.length();DI.normalize(),PI.normalize(),LI.normalize(),0===i&&DI.crossVectors(PI,LI),0===r&&PI.crossVectors(DI,LI),0===s&&LI.crossVectors(DI,PI),n.transform.set(DI.x,PI.x,LI.x,t[0],DI.y,PI.y,LI.y,t[1],DI.z,PI.z,LI.z,t[2],0,0,0,1).premultiply(e),n.box.min.set(-i,-r,-s),n.box.max.set(i,r,s),n.update(),this.obb=n}setSphereData(t,e,n,i,r){const s=new or;s.center.set(t,e,n),s.radius=i,s.applyMatrix4(r),this.sphere=s}setRegionData(t,e,n,i,r,s,a){const o=new RI(...t.radius,n,r,e,i,s,a),l=new _I;o.getBoundingBox(l.box,l.transform),l.update(),this.region=o,this.regionObb=l}}const OI=new hi;class kI extends fo{constructor(){super(),this.points=Array(8).fill().map((()=>new Qi))}setFromProjectionMatrix(t,e){super.setFromProjectionMatrix(t,e),this.calculateFrustumPoints()}calculateFrustumPoints(){const{planes:t,points:e}=this;[[t[0],t[3],t[4]],[t[1],t[3],t[4]],[t[0],t[2],t[4]],[t[1],t[2],t[4]],[t[0],t[3],t[5]],[t[1],t[3],t[5]],[t[0],t[2],t[5]],[t[1],t[2],t[5]]].forEach(((t,n)=>{!function(t,e,n,i){const r=OI.set(t.normal.x,t.normal.y,t.normal.z,e.normal.x,e.normal.y,e.normal.z,n.normal.x,n.normal.y,n.normal.z);i.set(-t.constant,-e.constant,-n.constant),i.applyMatrix3(r.invert())}(t[0],t[1],t[2],e[n])}))}}const QI=new gr,zI=new Sr,GI=Symbol("INITIAL_FRUSTUM_CULLED"),HI=new gr,VI=new gr,WI=new Qi,jI=new ci,qI=new Qi(1,0,0),XI=new Qi(0,1,0);function YI(t,e){t.traverse((t=>{t.frustumCulled=t[GI]&&e}))}class JI extends tb{get autoDisableRendererCulling(){return this._autoDisableRendererCulling}set autoDisableRendererCulling(t){this._autoDisableRendererCulling!==t&&(super._autoDisableRendererCulling=t,this.forEachLoadedModel((e=>{YI(e,!t)})))}constructor(...t){super(...t),this.group=new oI(this),this.ellipsoid=Vb.clone(),this.cameras=[],this.cameraMap=new Map,this.cameraInfo=[],this.optimizeRaycast=!0,this._upRotationMatrix=new gr,this.lruCache.computeMemoryUsageCallback=t=>t.cached.bytesUsed??null,this._autoDisableRendererCulling=!0;const e=new hh;e.setURLModifier((t=>this.preprocessURL?this.preprocessURL(t):t)),this.manager=e,this._listeners={}}addEventListener(...t){Kn.prototype.addEventListener.call(this,...t)}hasEventListener(...t){Kn.prototype.hasEventListener.call(this,...t)}removeEventListener(...t){Kn.prototype.removeEventListener.call(this,...t)}dispatchEvent(...t){Kn.prototype.dispatchEvent.call(this,...t)}getBoundingBox(t){if(!this.root)return!1;const e=this.root.cached.boundingVolume;return!!e&&(e.getAABB(t),!0)}getOrientedBoundingBox(t,e){if(!this.root)return!1;const n=this.root.cached.boundingVolume;return!!n&&(n.getOBB(t,e),!0)}getBoundingSphere(t){if(!this.root)return!1;const e=this.root.cached.boundingVolume;return!!e&&(e.getSphere(t),!0)}forEachLoadedModel(t){this.traverse((e=>{const n=e.cached.scene;n&&t(n,e)}))}raycast(t,e){if(this.root)if(t.firstHitOnly){const n=fI(this,this.root,t);n&&e.push(n)}else mI(this,this.root,t,e)}hasCamera(t){return this.cameraMap.has(t)}setCamera(t){const e=this.cameras,n=this.cameraMap;return!n.has(t)&&(n.set(t,new ci),e.push(t),this.dispatchEvent({type:"add-camera",camera:t}),!0)}setResolution(t,e,n){const i=this.cameraMap;if(!i.has(t))return!1;const r=e.isVector2?e.x:e,s=e.isVector2?e.y:n,a=i.get(t);return a.width===r&&a.height===s||(a.set(r,s),this.dispatchEvent({type:"camera-resolution-change"})),!0}setResolutionFromRenderer(t,e){return e.getSize(jI).multiplyScalar(e.getPixelRatio()),this.setResolution(t,jI.x,jI.y)}deleteCamera(t){const e=this.cameras,n=this.cameraMap;if(n.has(t)){const i=e.indexOf(t);return e.splice(i,1),n.delete(t),this.dispatchEvent({type:"delete-camera",camera:t}),!0}return!1}preprocessTileSet(t,e,n){super.preprocessTileSet(t,e,n),queueMicrotask((()=>{this.dispatchEvent({type:"load-tile-set",tileSet:t,url:e})}))}loadRootTileSet(...t){return super.loadRootTileSet(...t).then((()=>{const{asset:t,extensions:e={}}=this.rootTileSet;switch((t&&t.gltfUpAxis||"y").toLowerCase()){case"x":this._upRotationMatrix.makeRotationAxis(XI,-Math.PI/2);break;case"y":this._upRotationMatrix.makeRotationAxis(qI,Math.PI/2)}if("3DTILES_ellipsoid"in e){const t=e["3DTILES_ellipsoid"],{ellipsoid:n}=this;n.name=t.body,t.radii?n.radius.set(...t.radii):n.radius.set(1,1,1)}this.dispatchEvent({type:"load-content"})}))}update(){let t=null;if(this.invokeAllPlugins((e=>{if(e.doTilesNeedUpdate){const n=e.doTilesNeedUpdate();t=null===t?n:t||n}})),!1===t)return this.dispatchEvent({type:"update-before"}),void this.dispatchEvent({type:"update-after"});this.dispatchEvent({type:"update-before"});const e=this.group,n=this.cameras,i=this.cameraMap,r=this.cameraInfo;if(0!==n.length){for(;r.length>n.length;)r.pop();for(;r.length1e-6&&console.warn("ThreeTilesRenderer : Non uniform scale used for tile which may cause issues when calculating screen space error.");for(let t=0,s=r.length;tt.scene));break}case"gltf":case"glb":{const e=h.getHandler("path.gltf")||h.getHandler("path.glb")||new Pg(h);e.setWithCredentials("include"===c.credentials),e.setRequestHeader(c.headers||{}),"include"===c.credentials&&"cors"===c.mode&&e.setCrossOrigin("use-credentials");let n=e.resourcePath||e.path||l;!/[\\/]$/.test(n)&&n.length&&(n+="/"),u=e.parseAsync(t,n).then((t=>{const{scene:e}=t;return e.updateMatrix(),e.matrix.multiply(p).decompose(e.position,e.quaternion,e.scale),t}));break}default:console.warn(`TilesRenderer: Content type "${f}" not supported.`),u=Promise.resolve(null)}const m=await u;let g,A;m.isObject3D?(g=m,A=null):(g=m.scene,A=m),await this.invokeAllPlugins((t=>t.processTileModel&&t.processTileModel(g,n))),g.updateMatrix(),g.matrix.premultiply(d),g.matrix.decompose(g.position,g.quaternion,g.scale),g.traverse((t=>{t[GI]=t.frustumCulled})),YI(g,!this.autoDisableRendererCulling);const v=[],y=[],_=[];if(g.traverse((t=>{if(t.geometry&&y.push(t.geometry),t.material){const e=t.material;v.push(t.material);for(const t in e){const n=e[t];n&&n.isTexture&&_.push(n)}}})),s.aborted)for(let t=0,e=_.length;t{if(t.geometry&&!i.has(t.geometry)&&(r+=Rg(t.geometry),i.add(t.geometry)),t.material){const e=t.material;for(const t in e){const s=e[t];if(s&&s.isTexture&&!i.has(s)){const{format:t,type:e,image:a}=s,{width:o,height:l}=a,c=n.getByteLength(o,l,t,e);r+=s.generateMipmaps?4*c/3:c,i.add(s)}}}})),r}(g)}disposeTile(t){super.disposeTile(t);const e=t.cached;if(e.scene){const n=e.materials,i=e.geometry,r=e.textures,s=e.scene.parent;e.scene.traverse((t=>{t.userData.meshFeatures&&t.userData.meshFeatures.dispose(),t.userData.structuralMetadata&&t.userData.structuralMetadata.dispose()}));for(let t=0,e=i.length;t{},this.pivotMesh.scale.setScalar(.25),this.raycaster=new ku,this.raycaster.firstHitOnly=!0,this.up=new Qi(0,1,0),this.clock=new su,this.fallbackPlane=new ho(new Qi(0,1,0),0),this.useFallbackPlane=!0,this._detachCallback=null,this._upInitialized=!1,this._lastUsedState=0,this._zoomPointWasSet=!1,this._tilesOnChangeCallback=()=>this.zoomPointSet=!1,n&&this.attach(n),e&&this.setCamera(e),t&&this.setScene(t),i&&this.setTilesRenderer(i)}setScene(t){this.scene=t}setCamera(t){this.camera=t,this._upInitialized=!1,this.zoomDirectionSet=!1,this.zoomPointSet=!1,this.needsUpdate=!0,this.raycaster.camera=t,this.resetState()}setTilesRenderer(t){this.tilesRenderer&&this.tilesRenderer.removeEventListener("tile-visibility-change",this._tilesOnChangeCallback),this.tilesRenderer=t,null!==this.tilesRenderer&&(this.tilesRenderer.addEventListener("tile-visibility-change",this._tilesOnChangeCallback),null===this.scene&&this.setScene(this.tilesRenderer.group))}attach(t){if(this.domElement)throw new Error("EnvironmentControls: Controls already attached to element");this.domElement=t,this.pointerTracker.domElement=t,t.style.touchAction="none";let e=!1;const n=t=>{t.preventDefault()},i=t=>{"Shift"===t.key&&(e=!0)},r=t=>{"Shift"===t.key&&(e=!1)},s=t=>{t.preventDefault();const{camera:n,raycaster:i,domElement:r,up:s,pivotMesh:a,pointerTracker:o}=this;if(o.addPointer(t),this.needsUpdate=!0,o.isPointerTouch())if(a.visible=!1,0===o.getPointerCount())r.setPointerCapture(t.pointerId);else if(o.getPointerCount()>2)return void this.resetState();o.getCenterPoint(ET),aT(ET.x,ET.y,r,ET),lT(i,ET,n);const l=Math.abs(i.ray.direction.dot(s));if(l{t.preventDefault(),this.zoomDirectionSet=!1,this.zoomPointSet=!1,0!==this.state&&(this.needsUpdate=!0);const{pointerTracker:e}=this;e.setHoverEvent(t),e.updatePointer(t)&&(e.isPointerTouch()&&2===e.getPointerCount()&&(a||(a=!0,queueMicrotask((()=>{a=!1,e.getCenterPoint(bT);const t=e.getStartTouchPointerDistance(),n=e.getTouchPointerDistance(),i=n-t;if(0===this.state||4===this.state){e.getCenterPoint(bT),e.getStartCenterPoint(IT);const t=2*window.devicePixelRatio,n=bT.distanceTo(IT);(Math.abs(i)>t||n>t)&&(Math.abs(i)>n?(this.setState(3),this.zoomDirectionSet=!1):this.setState(2))}if(3===this.state){const t=e.getPreviousTouchPointerDistance();this.zoomDelta+=n-t}else 2===this.state&&(this.pivotMesh.visible=this.enabled)})))),this.dispatchEvent(TT))},l=e=>{const{pointerTracker:n}=this;n.deletePointer(e),"touch"===n.getPointerType()&&0===n.getPointerCount()&&t.releasePointerCapture(e.pointerId),this.resetState(),this.needsUpdate=!0},c=t=>{t.preventDefault();const{pointerTracker:e}=this;let n;switch(e.setHoverEvent(t),e.updatePointer(t),this.dispatchEvent(BT),t.deltaMode){case 2:n=100*t.deltaY;break;case 1:n=16*t.deltaY;break;case 0:n=t.deltaY}const i=Math.sign(n),r=Math.log(Math.abs(n)+1);this.zoomDelta-=3*i*r,this.needsUpdate=!0,this._lastUsedState=3,this.dispatchEvent(RT)},h=t=>{const{pointerTracker:n}=this;e=!1,t.buttons!==n.getPointerButtons()&&(n.deletePointer(t),this.resetState())};t.addEventListener("contextmenu",n),t.addEventListener("keydown",i),t.addEventListener("keyup",r),t.addEventListener("pointerdown",s),t.addEventListener("pointermove",o),t.addEventListener("pointerup",l),t.addEventListener("wheel",c,{passive:!1}),t.addEventListener("pointerenter",h),this._detachCallback=()=>{t.removeEventListener("contextmenu",n),t.removeEventListener("keydown",i),t.removeEventListener("keyup",r),t.removeEventListener("pointerdown",s),t.removeEventListener("pointermove",o),t.removeEventListener("pointerup",l),t.removeEventListener("wheel",c),t.removeEventListener("pointerenter",h)}}getUpDirection(t,e){e.copy(this.up)}getCameraUpDirection(t){this.getUpDirection(this.camera.position,t)}getPivotPoint(t){let e=null;3===this._lastUsedState?this._zoomPointWasSet&&(e=t.copy(this.zoomPoint)):2!==this._lastUsedState&&1!==this._lastUsedState||(e=t.copy(this.pivotPoint));const{camera:n,raycaster:i}=this;null!==e&&(pT.copy(e).project(n),(pT.x<-1||pT.x>1||pT.y<-1||pT.y>1)&&(e=null)),lT(i,{x:0,y:0},n);const r=this._raycast(i);return r&&(null===e||r.distance0?1/Math.abs(e):e;i*=c,i>1?ln.zoom*i&&(i=1),n.zoom*=i,n.updateProjectionMatrix(),t&&(aT(ET.x,ET.y,a,xT),xT.unproject(n),n.position.sub(xT).add(_T),n.updateMatrixWorld())}else{this._updateZoomDirection();const s=pT.copy(e);if(this.zoomPointSet||this._updateZoomPoint()){const s=t.distanceTo(n.position);if(h<0){const t=Math.min(0,s-r);h=h*s*c*.0025,h=Math.max(h,t)}else{const t=Math.max(0,s-i);h=h*Math.max(s-i,0)*c*.0025,h=Math.min(h,t)}n.position.addScaledVector(e,h),n.updateMatrixWorld()}else{const t=this._getPointBelowCamera();if(t){const e=t.distance;s.set(0,0,-1).transformDirection(n.matrixWorld),n.position.addScaledVector(s,h*e*.01),n.updateMatrixWorld()}}}}_updateZoomDirection(){if(this.zoomDirectionSet)return;const{domElement:t,raycaster:e,camera:n,zoomDirection:i,pointerTracker:r}=this;r.getLatestPoint(ET),aT(ET.x,ET.y,t,_T),lT(e,_T,n),i.copy(e.ray.direction).normalize(),this.zoomDirectionSet=!0}_updateZoomPoint(){const{camera:t,zoomDirectionSet:e,zoomDirection:n,raycaster:i,zoomPoint:r,pointerTracker:s,domElement:a}=this;if(this._zoomPointWasSet=!1,!e)return!1;t.isOrthographicCamera&&s.getLatestPoint(CT)?(aT(CT.x,CT.y,a,CT),lT(i,CT,t)):(i.ray.origin.copy(t.position),i.ray.direction.copy(n),i.near=0,i.far=1/0);const o=this._raycast(i);return!!o&&(r.copy(o.point),this.zoomPointSet=!0,this._zoomPointWasSet=!0,!0)}_getPointBelowCamera(t=this.camera.position,e=this.up){const{raycaster:n}=this;n.ray.direction.copy(e).multiplyScalar(-1),n.ray.origin.copy(t).addScaledVector(e,1e5),n.near=0,n.far=1/0;const i=this._raycast(n);return i&&(i.distance-=1e5),i}_updatePosition(t){const{raycaster:e,camera:n,pivotPoint:i,up:r,pointerTracker:s,domElement:a,state:o,dragInertia:l,enableDamping:c}=this;if(1===o){if(s.getCenterPoint(ET),aT(ET.x,ET.y,a,ET),vT.setFromNormalAndCoplanarPoint(r,i),lT(e,ET,n),Math.abs(e.ray.direction.dot(r))0?(l=Math.min(c-r-.01,l),l=Math.max(0,l)):(l=Math.max(c-s,l),l=Math.min(0,l)),AT.setFromAxisAngle(yT,o),sT(n,AT,uT),i.matrixWorld.premultiply(uT),gT.set(-1,0,0).transformDirection(i.matrixWorld),AT.setFromAxisAngle(gT,l),sT(n,AT,uT),i.matrixWorld.premultiply(uT),i.matrixWorld.decompose(i.position,i.quaternion,pT)}_setFrame(t,e){const{up:n,camera:i,state:r,zoomPoint:s,zoomDirectionSet:a,zoomPointSet:o,reorientOnDrag:l,scaleZoomOrientationAtEdges:c}=this;i.updateMatrixWorld(),AT.setFromUnitVectors(n,t);const h=r;if(a&&(o||this._updateZoomPoint())){if(this.getUpDirection(s,pT),c){let t=Math.max(pT.dot(n)-.6,0)/.4;t=li.mapLinear(t,0,.5,0,1),t=Math.min(t,1),i.isOrthographicCamera&&(t*=.1),AT.slerp(wT,1-t)}sT(s,AT,uT),i.matrixWorld.premultiply(uT),i.matrixWorld.decompose(i.position,i.quaternion,pT),this.zoomDirectionSet=!1,this._updateZoomDirection()}else 1===h&&l&&e&&(sT(e,AT,uT),i.matrixWorld.premultiply(uT),i.matrixWorld.decompose(i.position,i.quaternion,pT));n.copy(t),i.updateMatrixWorld()}_raycast(t){const{scene:e,useFallbackPlane:n,fallbackPlane:i}=this,r=t.intersectObject(e)[0]||null;if(r)return r;if(n){const e=i;if(t.ray.intersectPlane(e,pT))return{point:pT.clone(),distance:t.ray.origin.distanceTo(pT)}}return null}}const PT=new gr,LT=new gr,UT=new Qi,NT=new Qi,FT=new Qi,OT=new Qi,kT=new Qi,QT=new Qi,zT=new Qi,GT=new ki,HT=new Qi,VT=new Qi,WT={},jT=new mr,qT=new Hb,XT=new ci;class YT extends DT{get ellipsoid(){return this.tilesRenderer?this.tilesRenderer.ellipsoid:null}get tilesGroup(){return this.tilesRenderer?this.tilesRenderer.group:null}constructor(t=null,e=null,n=null,i=null){super(t,e,n),this.isGlobeControls=!0,this._dragMode=0,this._rotationMode=0,this.maxZoom=.01,this.nearMargin=.25,this.farMargin=0,this.useFallbackPlane=!1,this.reorientOnDrag=!1,this.dragQuaternion=new ki,this.setTilesRenderer(i)}setScene(t){null===t&&null!==this.tilesRenderer?super.setScene(this.tilesRenderer.group):super.setScene(t)}getPivotPoint(t){const{camera:e,tilesGroup:n,ellipsoid:i}=this;return OT.set(0,0,-1).transformDirection(e.matrixWorld),PT.copy(n.matrixWorld).invert(),jT.origin.copy(e.position),jT.direction.copy(OT),jT.applyMatrix4(PT),oT(jT,i,NT),NT.applyMatrix4(n.matrixWorld),(null===super.getPivotPoint(t)||t.distanceTo(jT.origin)>NT.distanceTo(jT.origin))&&t.copy(NT),t}getVectorToCenter(t){const{tilesGroup:e,camera:n}=this;return t.setFromMatrixPosition(e.matrixWorld).sub(n.position)}getDistanceToCenter(){return this.getVectorToCenter(NT).length()}getUpDirection(t,e){const{tilesGroup:n,ellipsoid:i}=this;PT.copy(n.matrixWorld).invert(),NT.copy(t).applyMatrix4(PT),i.getPositionToNormal(NT,e),e.transformDirection(n.matrixWorld)}getCameraUpDirection(t){const{tilesGroup:e,ellipsoid:n,camera:i}=this;i.isOrthographicCamera?(this._getVirtualOrthoCameraPosition(NT),PT.copy(e.matrixWorld).invert(),NT.applyMatrix4(PT),n.getPositionToNormal(NT,t),t.transformDirection(e.matrixWorld)):this.getUpDirection(i.position,t)}update(t=Math.min(this.clock.getDelta(),.064)){if(!this.enabled||!this.tilesGroup||!this.camera||0===t)return;const{camera:e,pivotMesh:n}=this;this._isNearControls()?this.scaleZoomOrientationAtEdges=this.zoomDelta<0:(0!==this.state&&1!==this._dragMode&&1!==this._rotationMode&&(n.visible=!1),this.scaleZoomOrientationAtEdges=!1),super.update(t),this.adjustCamera(e)}adjustCamera(t){super.adjustCamera(t);const{tilesGroup:e,ellipsoid:n,nearMargin:i,farMargin:r}=this,s=Math.max(...n.radius);if(t.isPerspectiveCamera){const a=NT.setFromMatrixPosition(e.matrixWorld).sub(t.position).length(),o=i*s,l=li.clamp((a-s)/o,0,1),c=li.lerp(1,1e3,l);t.near=Math.max(c,a-s-o);const h=PT.copy(e.matrixWorld).invert();UT.copy(t.position).applyMatrix4(h),n.getPositionToCartographic(UT,WT);const u=Math.max(n.getPositionElevation(UT),400),d=n.calculateHorizonDistance(WT.lat,u);t.far=2.5*d+.1+s*r,t.updateProjectionMatrix()}else{this._getVirtualOrthoCameraPosition(t.position,t),t.updateMatrixWorld(),PT.copy(t.matrixWorld).invert(),NT.setFromMatrixPosition(e.matrixWorld).applyMatrix4(PT);const n=-NT.z;t.near=n-s*(1+i),t.far=n+.1+s*r,t.position.addScaledVector(OT,t.near),t.far-=t.near,t.near=0,t.updateProjectionMatrix(),t.updateMatrixWorld()}}resetState(){super.resetState(),this._dragMode=0,this._rotationMode=0}_updatePosition(t){if(1!==this.state){const{enableDamping:e,tilesGroup:n,dragQuaternion:i,dragInertia:r,camera:s}=this;e&&(1!==i.w||0===i.x&&0===i.y&&0===i.z||(i.w=Math.min(i.w,1-1e-9)),FT.setFromMatrixPosition(n.matrixWorld),GT.identity().slerp(i,r.x*t),sT(FT,GT,LT),s.matrixWorld.premultiply(LT),s.matrixWorld.decompose(s.position,s.quaternion,NT))}else{0===this._dragMode&&(this._dragMode=this._isNearControls()?1:-1);const{raycaster:e,camera:n,pivotPoint:i,pointerTracker:r,domElement:s,tilesGroup:a}=this,o=UT,l=QT;r.getCenterPoint(XT),aT(XT.x,XT.y,s,XT),lT(e,XT,n),PT.copy(a.matrixWorld).invert(),e.ray.applyMatrix4(PT);const c=NT.copy(i).applyMatrix4(PT).length();qT.radius.setScalar(c),n.isPerspectiveCamera?qT.intersectRay(e.ray,NT)||function(t,e,n){const i=t.origin.length(),r=Math.acos(e/i);n.copy(t.origin).multiplyScalar(-1).normalize();const s=rT.crossVectors(n,t.direction).normalize();n.multiplyScalar(-1).applyAxisAngle(s,-r).normalize().multiplyScalar(e)}(e.ray,c,NT):oT(e.ray,qT,NT),NT.applyMatrix4(a.matrixWorld),FT.setFromMatrixPosition(a.matrixWorld),o.subVectors(i,FT).normalize(),l.subVectors(NT,FT).normalize(),GT.setFromUnitVectors(l,o),sT(FT,GT,LT),n.matrixWorld.premultiply(LT),n.matrixWorld.decompose(n.position,n.quaternion,NT);const{dragInertia:h,dragQuaternion:u}=this;r.getMoveDistance()/t<2*window.devicePixelRatio?(u.slerp(GT,.5),h.set(1/t,0,0)):(u.copy(GT),h.set(1/t,0,0))}this._alignCameraUp(this.up)}_updateRotation(...t){1===this._rotationMode||this._isNearControls()?(this._rotationMode=1,super._updateRotation(...t)):(this.pivotMesh.visible=!1,this._rotationMode=-1),this._alignCameraUp(this.up)}_updateZoom(){const{zoomDelta:t,ellipsoid:e,zoomSpeed:n,zoomPoint:i,camera:r,maxZoom:s}=this,a=li.clamp(li.mapLinear(Math.abs(t),0,20,0,1),0,1);if(this._isNearControls()||t>0){if(this._updateZoomDirection(),t<0&&(this.zoomPointSet||this._updateZoomPoint())){OT.set(0,0,-1).transformDirection(r.matrixWorld).normalize(),VT.copy(this.up).multiplyScalar(-1),this.getUpDirection(i,HT);const t=li.clamp(li.mapLinear(-HT.dot(VT),1,.95,0,1),0,1),e=1-OT.dot(VT),n=r.isOrthographicCamera?.05:1,s=li.clamp(3*a,0,1),o=Math.min(t*e*n*s,.1);VT.lerpVectors(OT,VT,o).normalize(),GT.setFromUnitVectors(OT,VT),sT(i,GT,LT),r.matrixWorld.premultiply(LT),r.matrixWorld.decompose(r.position,r.quaternion,VT),this.zoomDirection.subVectors(i,r.position).normalize()}super._updateZoom()}else if(r.isPerspectiveCamera){const i=this._getPerspectiveTransitionDistance(),r=this._getMaxPerspectiveDistance(),s=li.mapLinear(this.getDistanceToCenter(),i,r,0,1);this._tiltTowardsCenter(li.lerp(0,.4,s*a)),this._alignCameraUpToNorth(li.lerp(0,.2,s*a));const o=t*(this.getDistanceToCenter()-e.radius.x)*n*.0025,l=Math.max(o,Math.min(this.getDistanceToCenter()-r,0));this.getVectorToCenter(NT).normalize(),this.camera.position.addScaledVector(NT,l),this.camera.updateMatrixWorld(),this.zoomDelta=0}else{const t=this._getOrthographicTransitionZoom(),e=this._getMinOrthographicZoom(),i=li.mapLinear(r.zoom,t,e,0,1);this._tiltTowardsCenter(li.lerp(0,.4,i*a)),this._alignCameraUpToNorth(li.lerp(0,.2,i*a));const o=this.zoomDelta,l=Math.pow(.95,Math.abs(.05*o)),c=o>0?1/Math.abs(l):l,h=e/r.zoom,u=Math.max(c*n,Math.min(h,1));r.zoom=Math.min(s,r.zoom*u),r.updateProjectionMatrix(),this.zoomDelta=0,this.zoomDirectionSet=!1}}_alignCameraUpToNorth(t){const{tilesGroup:e}=this;zT.set(0,0,1).transformDirection(e.matrixWorld),this._alignCameraUp(zT,t)}_alignCameraUp(t,e=null){const{camera:n}=this;OT.set(0,0,-1).transformDirection(n.matrixWorld),kT.set(-1,0,0).transformDirection(n.matrixWorld),QT.crossVectors(t,OT),null===e&&(e=1-Math.abs(OT.dot(t)),e=li.mapLinear(e,0,1,-.01,1),e=li.clamp(e,0,1)**2),QT.lerp(kT,1-e).normalize(),GT.setFromUnitVectors(kT,QT),n.quaternion.premultiply(GT),n.updateMatrixWorld()}_tiltTowardsCenter(t){const{camera:e,tilesGroup:n}=this;OT.set(0,0,-1).transformDirection(e.matrixWorld).normalize(),NT.setFromMatrixPosition(n.matrixWorld).sub(e.position).normalize(),NT.lerp(OT,1-t).normalize(),GT.setFromUnitVectors(OT,NT),e.quaternion.premultiply(GT),e.updateMatrixWorld()}_getPerspectiveTransitionDistance(){const{camera:t,ellipsoid:e}=this;if(!t.isPerspectiveCamera)throw new Error;const n=Math.max(...e.radius),i=2*Math.atan(Math.tan(li.DEG2RAD*t.fov*.5)*t.aspect),r=n/Math.tan(li.DEG2RAD*t.fov*.5),s=n/Math.tan(.5*i);return Math.max(r,s)}_getMaxPerspectiveDistance(){const{camera:t,ellipsoid:e}=this;if(!t.isPerspectiveCamera)throw new Error;const n=Math.max(...e.radius),i=2*Math.atan(Math.tan(li.DEG2RAD*t.fov*.5)*t.aspect),r=n/Math.tan(li.DEG2RAD*t.fov*.5),s=n/Math.tan(.5*i);return 2*Math.max(r,s)}_getOrthographicTransitionZoom(){const{camera:t,ellipsoid:e}=this;if(!t.isOrthographicCamera)throw new Error;const n=t.top-t.bottom,i=t.right-t.left;return 2*Math.max(n,i)/(2*Math.max(...e.radius))}_getMinOrthographicZoom(){const{camera:t,ellipsoid:e}=this;if(!t.isOrthographicCamera)throw new Error;const n=t.top-t.bottom,i=t.right-t.left;return.7*Math.min(n,i)/(2*Math.max(...e.radius))}_getVirtualOrthoCameraPosition(t,e=this.camera){const{tilesGroup:n,ellipsoid:i}=this;if(!e.isOrthographicCamera)throw new Error;PT.copy(n.matrixWorld).invert(),jT.origin.copy(e.position),jT.direction.set(0,0,-1).transformDirection(e.matrixWorld),jT.applyMatrix4(PT),oT(jT,i,UT),UT.applyMatrix4(n.matrixWorld);const r=e.top-e.bottom,s=e.right-e.left,a=Math.max(r,s)/e.zoom;OT.set(0,0,-1).transformDirection(e.matrixWorld);const o=UT.sub(e.position).dot(OT);t.copy(e.position).addScaledVector(OT,o-4*a)}_isNearControls(){const{camera:t}=this;return t.isPerspectiveCamera?this.getDistanceToCenter()this._getOrthographicTransitionZoom()}}const JT=new Qi,KT=new Qi,ZT=new Uh,$T=new Qi,tB=new Qi,eB=new Qi,nB=new ki,iB=new ki;class rB extends Kn{get animating(){return 0!==this._alpha&&1!==this._alpha}get camera(){return 0===this._alpha?this.perspectiveCamera:1===this._alpha?this.orthographicCamera:this.transitionCamera}get mode(){return 0===this._target?"perspective":"orthographic"}set mode(t){if(t===this.mode)return;const e=this.camera;"perspective"===t?(this._target=0,this._alpha=0):(this._target=1,this._alpha=1),this.dispatchEvent({type:"camera-change",camera:this.camera,prevCamera:e})}constructor(t=new oa,e=new Uh){super(),this.perspectiveCamera=t,this.orthographicCamera=e,this.transitionCamera=new oa,this.orthographicPositionalZoom=!0,this.orthographicOffset=50,this.fixedPoint=new Qi,this.duration=200,this.autoSync=!0,this.easeFunction=t=>t,this._target=0,this._alpha=0,this._clock=new su}toggle(){this._target=1===this._target?0:1,this._clock.getDelta(),this.dispatchEvent({type:"toggle"})}update(t=Math.min(this._clock.getDelta(),.064)){this.autoSync&&this.syncCameras();const{perspectiveCamera:e,orthographicCamera:n,transitionCamera:i,camera:r}=this,s=1e3*t;if(this._alpha!==this._target){const t=Math.sign(this._target-this._alpha)*s/this.duration;this._alpha=li.clamp(this._alpha+t,0,1),this.dispatchEvent({type:"change"})}const a=r;let o=null;0===this._alpha?o=e:1===this._alpha?o=n:(o=i,this._updateTransitionCamera()),a!==o&&(o===i&&this.dispatchEvent({type:"transition-start"}),this.dispatchEvent({type:"camera-change",camera:o,prevCamera:a}),a===i&&this.dispatchEvent({type:"transition-end"}))}syncCameras(){const t=this._getFromCamera(),{perspectiveCamera:e,orthographicCamera:n,transitionCamera:i,fixedPoint:r}=this;if(JT.set(0,0,-1).transformDirection(t.matrixWorld).normalize(),t.isPerspectiveCamera){if(this.orthographicPositionalZoom)n.position.copy(e.position).addScaledVector(JT,-this.orthographicOffset),n.rotation.copy(e.rotation),n.updateMatrixWorld();else{const t=KT.subVectors(r,n.position).dot(JT),i=KT.subVectors(r,e.position).dot(JT);KT.copy(e.position).addScaledVector(JT,i),n.rotation.copy(e.rotation),n.position.copy(KT).addScaledVector(JT,-t),n.updateMatrixWorld()}const t=Math.abs(KT.subVectors(e.position,r).dot(JT)),i=2*Math.tan(li.DEG2RAD*e.fov*.5)*t,s=n.top-n.bottom;n.zoom=s/i,n.updateProjectionMatrix()}else{const t=Math.abs(KT.subVectors(n.position,r).dot(JT)),i=(n.top-n.bottom)/n.zoom*.5/Math.tan(li.DEG2RAD*e.fov*.5);e.rotation.copy(n.rotation),e.position.copy(n.position).addScaledVector(JT,t).addScaledVector(JT,-i),e.updateMatrixWorld(),this.orthographicPositionalZoom&&(n.position.copy(e.position).addScaledVector(JT,-this.orthographicOffset),n.updateMatrixWorld())}i.position.copy(e.position),i.rotation.copy(e.rotation)}_getTransitionDirection(){return Math.sign(this._target-this._alpha)}_getToCamera(){const t=this._getTransitionDirection();return 0===t?0===this._target?this.perspectiveCamera:this.orthographicCamera:t>0?this.orthographicCamera:this.perspectiveCamera}_getFromCamera(){const t=this._getTransitionDirection();return 0===t?0===this._target?this.perspectiveCamera:this.orthographicCamera:t>0?this.perspectiveCamera:this.orthographicCamera}_updateTransitionCamera(){const{perspectiveCamera:t,orthographicCamera:e,transitionCamera:n,fixedPoint:i}=this,r=this.easeFunction(this._alpha);JT.set(0,0,-1).transformDirection(e.matrixWorld).normalize(),ZT.copy(e),ZT.position.addScaledVector(JT,e.near),e.far-=e.near,e.near=0,JT.set(0,0,-1).transformDirection(t.matrixWorld).normalize();const s=Math.abs(KT.subVectors(t.position,i).dot(JT)),a=2*Math.tan(li.DEG2RAD*t.fov*.5)*s,o=iB.slerpQuaternions(t.quaternion,ZT.quaternion,r),l=li.lerp(t.fov,1,r),c=.5*a/Math.tan(li.DEG2RAD*l*.5),h=eB.copy(ZT.position).sub(i).applyQuaternion(nB.copy(ZT.quaternion).invert()),u=tB.copy(t.position).sub(i).applyQuaternion(nB.copy(t.quaternion).invert()),d=$T.lerpVectors(u,h,r);d.z-=Math.abs(d.z)-c;const p=-(u.z-d.z),f=-(h.z-d.z),m=li.lerp(p+t.near,f+ZT.near,r),g=li.lerp(p+t.far,f+ZT.far,r),A=Math.max(g,0)-Math.max(m,0);n.aspect=t.aspect,n.fov=l,n.near=Math.max(m,1e-5*A),n.far=g,n.position.copy(d).applyQuaternion(o).add(i),n.quaternion.copy(o),n.updateProjectionMatrix(),n.updateMatrixWorld()}}const{clamp:sB}=li;class aB{constructor(){this.duration=250,this.fadeCount=0,this._lastTick=-1,this._fadeState=new Map,this.onFadeComplete=null,this.onFadeStart=null,this.onFadeSetComplete=null,this.onFadeSetStart=null}deleteObject(t){t&&this.completeFade(t)}guaranteeState(t){const e=this._fadeState;return!e.has(t)&&(e.set(t,{fadeInTarget:0,fadeOutTarget:0,fadeIn:0,fadeOut:0}),!0)}completeFade(t){const e=this._fadeState;if(!e.has(t))return;const n=0===e.get(t).fadeOutTarget;e.delete(t),this.fadeCount--,this.onFadeComplete&&this.onFadeComplete(t,n),0===this.fadeCount&&this.onFadeSetComplete&&this.onFadeSetComplete()}completeAllFades(){this._fadeState.forEach(((t,e)=>{this.completeFade(e)}))}forEachObject(t){this._fadeState.forEach(((e,n)=>{t(n,e)}))}fadeIn(t){const e=this.guaranteeState(t),n=this._fadeState.get(t);n.fadeInTarget=1,n.fadeOutTarget=0,n.fadeOut=0,e&&(this.fadeCount++,1===this.fadeCount&&this.onFadeSetStart&&this.onFadeSetStart(),this.onFadeStart&&this.onFadeStart(t))}fadeOut(t){const e=this.guaranteeState(t),n=this._fadeState.get(t);n.fadeOutTarget=1,e&&(n.fadeInTarget=1,n.fadeIn=1,this.fadeCount++,1===this.fadeCount&&this.onFadeSetStart&&this.onFadeSetStart(),this.onFadeStart&&this.onFadeStart(t))}isFading(t){return this._fadeState.has(t)}isFadingOut(t){const e=this._fadeState.get(t);return e&&1===e.fadeOutTarget}update(){const t=window.performance.now();-1===this._lastTick&&(this._lastTick=t);const e=sB((t-this._lastTick)/this.duration,0,1);this._lastTick=t,this._fadeState.forEach(((t,n)=>{const{fadeOutTarget:i,fadeInTarget:r}=t;let{fadeOut:s,fadeIn:a}=t;const o=Math.sign(r-a);a=sB(a+o*e,0,1);const l=Math.sign(i-s);s=sB(s+l*e,0,1),t.fadeIn=a,t.fadeOut=s,((1===s||0===s)&&(1===a||0===a)||s>=a)&&this.completeFade(n)}))}}function oB(t,e){const n={fadeIn:{value:0},fadeOut:{value:0},fadeTexture:{value:null}};return t.defines={...t.defines||{},FEATURE_FADE:0},t.onBeforeCompile=t=>{e&&e(t),t.uniforms={...t.uniforms,...n},t.vertexShader=t.vertexShader.replace(/void\s+main\(\)\s+{/,(t=>`\n\t\t\t\t\t#ifdef USE_BATCHING_FRAG\n\n\t\t\t\t\tvarying float vBatchId;\n\n\t\t\t\t\t#endif\n\n\t\t\t\t\t${t}\n\n\t\t\t\t\t\t#ifdef USE_BATCHING_FRAG\n\n\t\t\t\t\t\t// add 0.5 to the value to avoid floating error that may cause flickering\n\t\t\t\t\t\tvBatchId = getIndirectIndex( gl_DrawID ) + 0.5;\n\n\t\t\t\t\t\t#endif\n\t\t\t\t`)),t.fragmentShader=t.fragmentShader.replace(/void main\(/,(t=>`\n\t\t\t\t#if FEATURE_FADE\n\n\t\t\t\t// adapted from https://www.shadertoy.com/view/Mlt3z8\n\t\t\t\tfloat bayerDither2x2( vec2 v ) {\n\n\t\t\t\t\treturn mod( 3.0 * v.y + 2.0 * v.x, 4.0 );\n\n\t\t\t\t}\n\n\t\t\t\tfloat bayerDither4x4( vec2 v ) {\n\n\t\t\t\t\tvec2 P1 = mod( v, 2.0 );\n\t\t\t\t\tvec2 P2 = floor( 0.5 * mod( v, 4.0 ) );\n\t\t\t\t\treturn 4.0 * bayerDither2x2( P1 ) + bayerDither2x2( P2 );\n\n\t\t\t\t}\n\n\t\t\t\t// the USE_BATCHING define is not available in fragment shaders\n\t\t\t\t#ifdef USE_BATCHING_FRAG\n\n\t\t\t\t// functions for reading the fade state of a given batch id\n\t\t\t\tuniform sampler2D fadeTexture;\n\t\t\t\tvarying float vBatchId;\n\t\t\t\tvec2 getFadeValues( const in float i ) {\n\n\t\t\t\t\tint size = textureSize( fadeTexture, 0 ).x;\n\t\t\t\t\tint j = int( i );\n\t\t\t\t\tint x = j % size;\n\t\t\t\t\tint y = j / size;\n\t\t\t\t\treturn texelFetch( fadeTexture, ivec2( x, y ), 0 ).rg;\n\n\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\tuniform float fadeIn;\n\t\t\t\tuniform float fadeOut;\n\n\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t\t${t}\n\t\t\t`)).replace(/#include /,(t=>`\n\n\t\t\t\t${t}\n\n\t\t\t\t#if FEATURE_FADE\n\n\t\t\t\t#ifdef USE_BATCHING_FRAG\n\n\t\t\t\tvec2 fadeValues = getFadeValues( vBatchId );\n\t\t\t\tfloat fadeIn = fadeValues.r;\n\t\t\t\tfloat fadeOut = fadeValues.g;\n\n\t\t\t\t#endif\n\n\t\t\t\tfloat bayerValue = bayerDither4x4( floor( mod( gl_FragCoord.xy, 4.0 ) ) );\n\t\t\t\tfloat bayerBins = 16.0;\n\t\t\t\tfloat dither = ( 0.5 + bayerValue ) / bayerBins;\n\t\t\t\tif ( dither >= fadeIn ) {\n\n\t\t\t\t\tdiscard;\n\n\t\t\t\t}\n\n\t\t\t\tif ( dither < fadeOut ) {\n\n\t\t\t\t\tdiscard;\n\n\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t`))},n}class lB{constructor(){this._fadeParams=new WeakMap,this.fading=0}setFade(t,e,n){if(!t)return;const i=this._fadeParams;t.traverse((t=>{const r=t.material;if(r){const t=i.get(r);t.fadeIn.value=e,t.fadeOut.value=n;const s=Number(!(0===e||1===e)||!(0===n||1===n));r.defines.FEATURE_FADE!==s&&(this.fading+=1===s?1:-1,r.defines.FEATURE_FADE=s,r.needsUpdate=!0)}}))}prepareScene(t){t.traverse((t=>{t.material&&this.prepareMaterial(t.material)}))}deleteScene(t){if(!t)return;const e=this._fadeParams;t.traverse((t=>{const n=t.material;n&&(e.delete(n),n.onBeforeCompile=()=>{},n.needsUpdate=!0)}))}prepareMaterial(t){const e=this._fadeParams;e.has(t)||e.set(t,oB(t))}}class cB{constructor(t,e=new ds){this.other=t,this.material=e,this.visible=!0,this.parent=null,this._instanceInfo=[],this._visibilityChanged=!0;const n=new Proxy(this,{get(e,i){if(i in e)return e[i];{const r=t[i];return r instanceof Function?(...t)=>(e.syncInstances(),r.call(n,...t)):t[i]}},set:(e,n,i)=>(n in e?e[n]=i:t[n]=i,!0),deleteProperty:(e,n)=>n in e?delete e[n]:delete t[n]});return n}syncInstances(){const t=this._instanceInfo,e=this.other._instanceInfo;for(;e.length>t.length;){const n=t.length;t.push(new Proxy({visible:!1},{get:(t,i)=>i in t?t[i]:e[n][i],set:(t,i,r)=>(i in t?t[i]=r:e[n][i]=r,!0)}))}}}class hB extends cB{constructor(...t){super(...t);const e=this.material,n=oB(e,e.onBeforeCompile);e.defines.FEATURE_FADE=1,e.defines.USE_BATCHING_FRAG=1,e.needsUpdate=!0,this.fadeTexture=null,this._fadeParams=n}setFadeAt(t,e,n){this._initFadeTexture(),this.fadeTexture.setValueAt(t,255*e,255*n)}_initFadeTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=t*t*2,n=this.fadeTexture;if(!n||n.image.data.length!==e){const i=new Uint8Array(e),r=new uB(i,t,t,ae,kt);if(n){n.dispose();const t=n.image.data,e=this.fadeTexture.image.data,i=Math.min(t.length,e.length);e.set(new t.constructor(t.buffer,0,i))}this.fadeTexture=r,this._fadeParams.fadeTexture.value=r,r.needsUpdate=!0}}dispose(){this.fadeTexture&&this.fadeTexture.dispose()}}class uB extends Xa{setValueAt(t,...e){const{data:n,width:i,height:r}=this.image,s=Math.floor(n.length/(i*r));let a=!1;for(let i=0;i{const e=t.cached.scene;e&&(e.visible=t.__inFrustum),this.forEachBatchIds(t,((e,n,i)=>{n.setVisibleAt(e,t.__inFrustum),i.batchedMesh.setVisibleAt(e,t.__inFrustum)}))})),a{if(!r.has(t))return;const n=t.matrixWorld,i=r.get(t);n.decompose(fB,gB,AB),i.decompose(pB,mB,AB);const s=gB.angleTo(mB),a=fB.distanceTo(pB);e=e&&(s>.25||a>.1)})),e&&t.completeAllFades()}if(l.forEach((t=>{r.get(t).copy(t.matrixWorld)})),t.forEachObject(((n,{fadeIn:i,fadeOut:r})=>{const a=n.cached.scene,o=t.isFadingOut(n);s.markTileUsed(n),a&&(e.setFade(a,i,r),o&&(a.visible=!0)),this.forEachBatchIds(n,((t,e,n)=>{e.setFadeAt(t,i,r),e.setVisibleAt(t,!0),n.batchedMesh.setVisibleAt(t,!1)}))})),o){const t=s.getPluginByName("BATCHED_TILES_PLUGIN").batchedMesh.material;o.material.map=t.map}}function _B(t){return"OCTREE"===t.__implicitRoot.implicitTiling.subdivisionScheme}function xB(t){return _B(t)?8:4}class wB{constructor(t,e){this.parent=t,this.children=[],this.__level=t.__level+1,this.__implicitRoot=t.__implicitRoot,this.__subtreeIdx=e,[this.__x,this.__y,this.__z]=function(t,e){return e?[2*e.__x+t.__subtreeIdx%2,2*e.__y+Math.floor(t.__subtreeIdx/2)%2,_B(t)?2*e.__z+Math.floor(t.__subtreeIdx/4)%2:0]:[0,0,0]}(this,t)}static copy(t){const e={children:[]};return e.__level=t.__level,e.__implicitRoot=t.__implicitRoot,e.__subtreeIdx=t.__subtreeIdx,[e.__x,e.__y,e.__z]=[t.__x,t.__y,t.__z],e.boundingVolume=t.boundingVolume,e.geometricError=t.geometricError,e}}class CB extends ob{constructor(t){super(),this.tile=t,this.rootTile=t.__implicitRoot}parseBuffer(t){const e=new DataView(t);let n=0;const i=lb(e);console.assert("subt"===i,'SUBTREELoader: The magic bytes equal "subt".'),n+=4;const r=e.getUint32(n,!0);console.assert(1===r,'SUBTREELoader: The version listed in the header is "1".'),n+=4;const s=e.getUint32(n,!0);n+=8;const a=e.getUint32(n,!0);n+=8;const o=JSON.parse(nb(new Uint8Array(t,n,s)));return n+=s,{version:r,subtreeJson:o,subtreeByte:t.slice(n,n+a)}}parse(t){const e=this.parseBuffer(t),n=e.subtreeJson;n.contentAvailabilityHeaders=[].concat(n.contentAvailability);const i=this.preprocessBuffers(n.buffers),r=this.preprocessBufferViews(n.bufferViews,i);this.markActiveBufferViews(n,r);const s=this.requestActiveBuffers(i,e.subtreeByte),a=this.parseActiveBufferViews(r,s);this.parseAvailability(e,n,a),this.expandSubtree(this.tile,e)}markActiveBufferViews(t,e){let n;const i=t.tileAvailability;isNaN(i.bitstream)?isNaN(i.bufferView)||(n=e[i.bufferView]):n=e[i.bitstream],n&&(n.isActive=!0,n.bufferHeader.isActive=!0);const r=t.contentAvailabilityHeaders;for(let t=0;t>Math.log2(r)];if(!this.getBit(e._tileAvailability,a)){i.push(void 0);continue}const l=this.deriveChildTile(e,o,a,t);o.children.push(l),i.push(l)}n=i,i=[]}return n}deriveChildTile(t,e,n,i){const r=new wB(e,i);r.boundingVolume=this.getTileBoundingVolume(r),r.geometricError=this.getGeometricError(r);for(let e=0;t&&e=t.lengthBits)throw new Error("Bit index out of bounds.");if(void 0!==t.constant)return t.constant;const n=e>>3,i=e%8;return 1==(new Uint8Array(t.bitstream)[n]>>i&1)}getTileBoundingVolume(t){const e={};if(this.rootTile.boundingVolume.region){const n=[...this.rootTile.boundingVolume.region],i=n[0],r=n[2],s=n[1],a=n[3],o=(r-i)/Math.pow(2,t.__level),l=(a-s)/Math.pow(2,t.__level);n[0]=i+o*t.__x,n[2]=i+o*(t.__x+1),n[1]=s+l*t.__y,n[3]=s+l*(t.__y+1);for(let t=0;t<4;t++){const e=n[t];e<-Math.PI?n[t]+=2*Math.PI:e>Math.PI&&(n[t]-=2*Math.PI)}if(_B(t)){const e=n[4],i=(n[5]-e)/Math.pow(2,t.__level);n[4]=e+i*t.__z,n[5]=e+i*(t.__z+1)}e.region=n}if(this.rootTile.boundingVolume.box){const n=[...this.rootTile.boundingVolume.box],i=2**t.__level-1,r=Math.pow(2,-t.__level),s=_B(t)?3:2;for(let e=0;eMath.PI&&(n-=fg),i<-Math.PI?i+=fg:i>Math.PI&&(i-=fg),this._spherical.theta=n<=i?Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),!0===this.enableDamping?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const t=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=t!=this._spherical.radius}if(pg.setFromSpherical(this._spherical),pg.applyQuaternion(this._quatInverse),e.copy(this.target).add(pg),this.object.lookAt(this.target),!0===this.enableDamping?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let t=null;if(this.object.isPerspectiveCamera){const e=pg.length();t=this._clampDistance(e*this._scale);const n=e-t;this.object.position.addScaledVector(this._dollyDirection,n),this.object.updateMatrixWorld(),r=!!n}else if(this.object.isOrthographicCamera){const e=new Qi(this._mouse.x,this._mouse.y,0);e.unproject(this.object);const n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=n!==this.object.zoom;const i=new Qi(this._mouse.x,this._mouse.y,0);i.unproject(this.object),this.object.position.sub(i).add(e),this.object.updateMatrixWorld(),t=pg.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;null!==t&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(t).add(this.object.position):(hg.origin.copy(this.object.position),hg.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(hg.direction))gg||8*(1-this._lastQuaternion.dot(this.object.quaternion))>gg||this._lastTargetPosition.distanceToSquared(this.target)>gg)&&(this.dispatchEvent(og),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0)}_getAutoRotationAngle(t){return null!==t?fg/60*this.autoRotateSpeed*t:fg/60/60*this.autoRotateSpeed}_getZoomScale(t){const e=Math.abs(.01*t);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){pg.setFromMatrixColumn(e,0),pg.multiplyScalar(-t),this._panOffset.add(pg)}_panUp(t,e){!0===this.screenSpacePanning?pg.setFromMatrixColumn(e,1):(pg.setFromMatrixColumn(e,0),pg.crossVectors(this.object.up,pg)),pg.multiplyScalar(t),this._panOffset.add(pg)}_pan(t,e){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;pg.copy(i).sub(this.target);let r=pg.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*r/n.clientHeight,this.object.matrix),this._panUp(2*e*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),i=t-n.left,r=e-n.top,s=n.width,a=n.height;this._mouse.x=i/s*2-1,this._mouse.y=-r/a*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(fg*this._rotateDelta.x/e.clientHeight),this._rotateUp(fg*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(fg*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(-fg*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(fg*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(-fg*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(1===this._pointers.length)this._rotateStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(t){if(1===this._pointers.length)this._panStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._panStart.set(n,i)}}_handleTouchStartDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,i=t.pageY-e.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(1==this._pointers.length)this._rotateEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._rotateEnd.set(n,i)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(fg*this._rotateDelta.x/e.clientHeight),this._rotateUp(fg*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(1===this._pointers.length)this._panEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,i=t.pageY-e.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const s=.5*(t.pageX+e.x),a=.5*(t.pageY+e.y);this._updateZoomParameters(s,a)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;es.distanceTo(i[2])?r[2]:i[2];let o=s.distanceTo(a);if(this.fade){const t=this.camera,e=Math.max(t.far,this.maxFar),i=n.vertices.far[0].z/(e-t.near);o+=.25*Math.pow(i,2)*(e-t.near)}t.left=-o/2,t.right=o/2,t.top=o/2,t.bottom=-o/2,t.updateProjectionMatrix()}}getBreaks(){const t=this.camera,e=Math.min(t.far,this.maxFar);switch(this.breaks.length=0,this.mode){case"uniform":n(this.cascades,t.near,e,this.breaks);break;case"logarithmic":i(this.cascades,t.near,e,this.breaks);break;case"practical":!function(t,e,r,s,a){ng.length=0,ig.length=0,i(t,e,r,ig),n(t,e,r,ng);for(let e=1;e{this.parse(t,e,i)}),n,i)}parse(t,e,n=()=>{}){this.decodeDracoFile(t,e,null,null,hn,n).catch(n)}decodeDracoFile(t,e,n,i,r=un,s=()=>{}){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:r};return this.decodeGeometry(t,a).then(e).catch(s)}decodeGeometry(t,e){const n=JSON.stringify(e);if(nv.has(t)){const e=nv.get(t);if(e.key===n)return e.promise;if(0===t.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const r=this.workerNextTaskID++,s=t.byteLength,a=this._getWorker(r,s).then((n=>(i=n,new Promise(((n,s)=>{i._callbacks[r]={resolve:n,reject:s},i.postMessage({type:"decode",id:r,taskConfig:e,buffer:t},[t])}))))).then((t=>this._createGeometry(t.geometry)));return a.catch((()=>!0)).then((()=>{i&&r&&this._releaseTask(i,r)})),nv.set(t,{key:n,promise:a}),a}_createGeometry(t){const e=new Fs;t.index&&e.setIndex(new _s(t.index.array,1));for(let n=0;n{n.load(t,e,void 0,i)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const t="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then((e=>{const n=e[0];t||(this.decoderConfig.wasmBinary=e[1]);const i=iv.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),this.decoderPending}_getWorker(t,e){return this._initDecoder().then((()=>{if(this.workerPool.lengthe._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[t]=e,n._taskLoad+=e,n}))}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map((t=>t._taskLoad)))}dispose(){for(let t=0;t{if(t.isMesh){const e=t.geometry,i=t.material;if(i.isMeshStandardMaterial){const a="geometries/Geometry_"+e.id+".usda";if(!(a in n)){const t=function(t){const e=function(t){const e=t.attributes,n=e.position.count;return`\n\tdef Mesh "Geometry"\n\t{\n\t\tint[] faceVertexCounts = [${function(t){const e=null!==t.index?t.index.count:t.attributes.position.count;return Array(e/3).fill(3).join(", ")}(t)}]\n\t\tint[] faceVertexIndices = [${function(t){const e=t.index,n=[];if(null!==e)for(let t=0;t0?n:"",r=t["uv"+i];void 0!==r&&(e+=`\n\t\ttexCoord2f[] primvars:st${i} = [${oy(r)}] (\n\t\t\tinterpolation = "vertex"\n\t\t)`)}const n=t.color;return void 0!==n&&(e+=`\n\tcolor3f[] primvars:displayColor = [${ay(n,n.count)}] (\n\t\tinterpolation = "vertex"\n\t\t)`),e}(e)}\n\t\tuniform token subdivisionScheme = "none"\n\t}\n`}(t);return`\ndef "Geometry"\n{\n${e}\n}\n`}(e);n[a]=function(t){let e='#usda 1.0\n(\n\tcustomLayerData = {\n\t\tstring creator = "Three.js USDZExporter"\n\t}\n\tdefaultPrim = "Root"\n\tmetersPerUnit = 1\n\tupAxis = "Y"\n)\n\n';return e+=t,ty(e)}(t)}i.uuid in s||(s[i.uuid]=i),r+=function(t,e,n){const i="Object_"+t.id,r=ry(t.matrixWorld);return t.matrixWorld.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",t),`def Xform "${i}" (\n\tprepend references = @./geometries/Geometry_${e.id}.usda@\n\tprepend apiSchemas = ["MaterialBindingAPI"]\n)\n{\n\tmatrix4d xformOp:transform = ${r}\n\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\trel material:binding = \n}\n\n`}(t,e,i)}else console.warn("THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)",t)}else t.isCamera&&(r+=function(t){const e=t.name?t.name:"Camera_"+t.id,n=ry(t.matrixWorld);return t.matrixWorld.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",t),t.isOrthographicCamera?`def Camera "${e}"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ${n}\n\t\t\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\t\t\tfloat2 clippingRange = (${t.near.toPrecision(7)}, ${t.far.toPrecision(7)})\n\t\t\tfloat horizontalAperture = ${(10*(Math.abs(t.left)+Math.abs(t.right))).toPrecision(7)}\n\t\t\tfloat verticalAperture = ${(10*(Math.abs(t.top)+Math.abs(t.bottom))).toPrecision(7)}\n\t\t\ttoken projection = "orthographic"\n\t\t}\n\t\n\t`:`def Camera "${e}"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ${n}\n\t\t\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\t\t\tfloat2 clippingRange = (${t.near.toPrecision(7)}, ${t.far.toPrecision(7)})\n\t\t\tfloat focalLength = ${t.getFocalLength().toPrecision(7)}\n\t\t\tfloat focusDistance = ${t.focus.toPrecision(7)}\n\t\t\tfloat horizontalAperture = ${t.getFilmWidth().toPrecision(7)}\n\t\t\ttoken projection = "perspective"\n\t\t\tfloat verticalAperture = ${t.getFilmHeight().toPrecision(7)}\n\t\t}\n\t\n\t`}(t))})),r+="\n\t\t}\n\t}\n}\n\n",r+=function(t,e,n=!1){const i=[];for(const r in t){const s=t[r];i.push(ly(s,e,n))}return`def "Materials"\n{\n${i.join("")}\n}\n\n`}(s,a,e.quickLookCompatible),n[i]=ty(r),r=null;for(const t in a){let i=a[t];if(!0===i.isCompressedTexture){if(null===this.textureUtils)throw new Error("THREE.USDZExporter: setTextureUtils() must be called to process compressed textures.");i=await this.textureUtils.decompress(i)}const r=iy(i.image,i.flipY,e.maxTextureSize),s=await new Promise((t=>r.toBlob(t,"image/png",1)));n[`textures/Texture_${t}.png`]=new Uint8Array(await s.arrayBuffer())}let o=0;for(const t in n){const e=n[t];o+=34+t.length;const i=63&o;if(4!==i){const r=new Uint8Array(64-i);n[t]=[e,{extra:{12345:r}}]}o=e.length}return function(t,e){e||(e={});var n={},i=[];Kv(t,"",n,e);var r=0,s=0;for(var a in n){var o=n[a],l=o[0],c=o[1],h=0==c.level?0:8,u=(C=ty(a)).length,d=c.comment,p=d&&ty(d),f=p&&p.length,m=ey(c.extra);u>65535&&Pv(11);var g=h?Yv(l,c):l,A=g.length,v=Wv();v.p(l),i.push(qv(c,{size:l.length,crc:v.d(),c:g,f:C,m:p,u:u!=a.length||p&&d.length!=f,o:r,compression:h})),r+=30+u+m+A,s+=76+2*(u+m)+(f||0)+A}for(var y=new rv(s+22),_=r,x=s-r,w=0;w(r=o.indexOf("\n"))&&s=t.byteLength||!(l=n(t)))&&e(1,"no header found"),(c=l.match(/^#\?(\S+)/))||e(3,"bad initial token"),o.valid|=1,o.programtype=c[1],o.string+=l+"\n";l=n(t),!1!==l;)if(o.string+=l+"\n","#"!==l.charAt(0)){if((c=l.match(i))&&(o.gamma=parseFloat(c[1])),(c=l.match(r))&&(o.exposure=parseFloat(c[1])),(c=l.match(s))&&(o.valid|=2,o.format=c[1]),(c=l.match(a))&&(o.valid|=4,o.height=parseInt(c[1],10),o.width=parseInt(c[2],10)),2&o.valid&&4&o.valid)break}else o.comments+=l+"\n";return 2&o.valid||e(3,"missing format specifier"),4&o.valid||e(3,"missing image size specifier"),o}(s),o=a.width,l=a.height,c=function(t,n,i){const r=n;if(r<8||r>32767||2!==t[0]||2!==t[1]||128&t[2])return new Uint8Array(t);r!==(t[2]<<8|t[3])&&e(3,"wrong scanline width");const s=new Uint8Array(4*n*i);s.length||e(4,"unable to allocate buffer space");let a=0,o=0;const l=4*r,c=new Uint8Array(4),h=new Uint8Array(l);let u=i;for(;u>0&&ot.byteLength&&e(1),c[0]=t[o++],c[1]=t[o++],c[2]=t[o++],c[3]=t[o++],2==c[0]&&2==c[1]&&(c[2]<<8|c[3])==r||e(3,"bad rgbe scanline format");let n,i=0;for(;i128;if(r&&(n-=128),(0===n||i+n>l)&&e(3,"bad scanline data"),r){const e=t[o++];for(let t=0;t>n&(1<>6}const h={c:0,lc:0};function u(t,e,n,i){t=t<<8|F(n,i),e+=8,h.c=t,h.lc=e}const d={c:0,lc:0};function p(t,e,n,i,r,s,a,o,l){if(t==e){i<8&&(u(n,i,r,s),n=h.c,i=h.lc);let t=n>>(i-=8);if(t=new Uint8Array([t])[0],o.value+t>l)return!1;const e=a[o.value-1];for(;t-- >0;)a[o.value++]=e}else{if(!(o.value32767?e-65536:e}const g={a:0,b:0};function A(t,e){const n=m(t),i=m(e),r=n+(1&i)+(i>>1),s=r,a=r-i;g.a=s,g.b=a}function v(t,e){const n=f(t),i=f(e),r=n-(i>>1)&65535,s=i+r-32768&65535;g.a=s,g.b=r}function y(t,e,n,i,r,s,a){const o=a<16384,l=n>r?r:n;let c,h,u=1;for(;u<=l;)u<<=1;for(u>>=1,c=u,u>>=1;u>=1;){h=0;const a=h+s*(r-c),l=s*u,d=s*c,p=i*u,f=i*c;let m,y,_,x;for(;h<=a;h+=d){let r=h;const s=h+i*(n-c);for(;r<=s;r+=f){const n=r+p,i=r+l,s=i+p;o?(A(t[r+e],t[i+e]),m=g.a,_=g.b,A(t[n+e],t[s+e]),y=g.a,x=g.b,A(m,y),t[r+e]=g.a,t[n+e]=g.b,A(_,x),t[i+e]=g.a,t[s+e]=g.b):(v(t[r+e],t[i+e]),m=g.a,_=g.b,v(t[n+e],t[s+e]),y=g.a,x=g.b,v(m,y),t[r+e]=g.a,t[n+e]=g.b,v(_,x),t[i+e]=g.a,t[s+e]=g.b)}if(n&u){const n=r+l;o?A(t[r+e],t[n+e]):v(t[r+e],t[n+e]),m=g.a,t[n+e]=g.b,t[r+e]=m}}if(r&u){let r=h;const s=h+i*(n-c);for(;r<=s;r+=f){const n=r+p;o?A(t[r+e],t[n+e]):v(t[r+e],t[n+e]),m=g.a,t[n+e]=g.b,t[r+e]=m}}c=u,u>>=1}return h}function _(t,e,r,f,m,g){const A=r.value,v=N(e,r),y=N(e,r);r.value+=4;const _=N(e,r);if(r.value+=4,v<0||v>=i||y<0||y>=i)throw new Error("Something wrong with HUF_ENCSIZE");const x=new Array(i),w=new Array(16384);if(function(t){for(let e=0;e<16384;e++)t[e]={},t[e].len=0,t[e].lit=0,t[e].p=null}(w),function(t,e,n,r,l,c){const h=e;let u=0,d=0;for(;r<=l;r++){if(h.value-e.value>n)return!1;a(6,u,d,t,h);const i=s.l;if(u=s.c,d=s.lc,c[r]=i,63==i){if(h.value-e.value>n)throw new Error("Something wrong with hufUnpackEncTable");a(8,u,d,t,h);let i=s.l+6;if(u=s.c,d=s.lc,r+i>l+1)throw new Error("Something wrong with hufUnpackEncTable");for(;i--;)c[r++]=0;r--}else if(i>=59){let t=i-59+2;if(r+t>l+1)throw new Error("Something wrong with hufUnpackEncTable");for(;t--;)c[r++]=0;r--}}!function(t){for(let t=0;t<=58;++t)o[t]=0;for(let e=0;e0;--t){const n=e+o[t]>>1;o[t]=e,e=n}for(let e=0;e0&&(t[e]=n|o[n]++<<6)}}(c)}(t,r,f-(r.value-A),v,y,x),_>8*(f-(r.value-A)))throw new Error("Something wrong with hufUncompress");!function(t,e,i,r){for(;e<=i;e++){const i=c(t[e]),s=l(t[e]);if(i>>s)throw new Error("Invalid table entry");if(s>n){const t=r[i>>s-n];if(t.len)throw new Error("Invalid table entry");if(t.lit++,t.p){const e=t.p;t.p=new Array(t.lit);for(let n=0;n0;a--){const a=r[(i<=n;){const s=e[g>>A-n&16383];if(s.len)A-=s.len,p(s.lit,a,g,A,i,r,f,m,v),g=d.c,A=d.lc;else{if(!s.p)throw new Error("hufDecode issues");let e;for(e=0;e=n&&c(t[s.p[e]])==(g>>A-n&(1<>=_,A-=_;A>0;){const t=e[g<s||(e[r++]=t[n++],r>s));)e[r++]=t[i++]}function C(t){let e=t.byteLength;const n=new Array;let i=0;const r=new DataView(t);for(;e>0;){const t=r.getInt8(i++);if(t<0){const s=-t;e-=s+1;for(let t=0;t>8==255?r+=255&i:(n[r]=i,r++),t.value++}function M(t){const e=.5*Math.cos(.7853975),n=.5*Math.cos(3.14159/16),i=.5*Math.cos(3.14159/8),r=.5*Math.cos(3*3.14159/16),s=.5*Math.cos(.981746875),a=.5*Math.cos(3*3.14159/8),o=.5*Math.cos(1.374445625),l=new Array(4),c=new Array(4),h=new Array(4),u=new Array(4);for(let d=0;d<8;++d){const p=8*d;l[0]=i*t[p+2],l[1]=a*t[p+2],l[2]=i*t[p+6],l[3]=a*t[p+6],c[0]=n*t[p+1]+r*t[p+3]+s*t[p+5]+o*t[p+7],c[1]=r*t[p+1]-o*t[p+3]-n*t[p+5]-s*t[p+7],c[2]=s*t[p+1]-n*t[p+3]+o*t[p+5]+r*t[p+7],c[3]=o*t[p+1]-s*t[p+3]+r*t[p+5]-n*t[p+7],h[0]=e*(t[p+0]+t[p+4]),h[3]=e*(t[p+0]-t[p+4]),h[1]=l[0]+l[3],h[2]=l[1]-l[2],u[0]=h[0]+h[1],u[1]=h[3]+h[2],u[2]=h[3]-h[2],u[3]=h[0]-h[1],t[p+0]=u[0]+c[0],t[p+1]=u[1]+c[1],t[p+2]=u[2]+c[2],t[p+3]=u[3]+c[3],t[p+4]=u[3]-c[3],t[p+5]=u[2]-c[2],t[p+6]=u[1]-c[1],t[p+7]=u[0]-c[0]}for(let d=0;d<8;++d)l[0]=i*t[16+d],l[1]=a*t[16+d],l[2]=i*t[48+d],l[3]=a*t[48+d],c[0]=n*t[8+d]+r*t[24+d]+s*t[40+d]+o*t[56+d],c[1]=r*t[8+d]-o*t[24+d]-n*t[40+d]-s*t[56+d],c[2]=s*t[8+d]-n*t[24+d]+o*t[40+d]+r*t[56+d],c[3]=o*t[8+d]-s*t[24+d]+r*t[40+d]-n*t[56+d],h[0]=e*(t[d]+t[32+d]),h[3]=e*(t[d]-t[32+d]),h[1]=l[0]+l[3],h[2]=l[1]-l[2],u[0]=h[0]+h[1],u[1]=h[3]+h[2],u[2]=h[3]-h[2],u[3]=h[0]-h[1],t[0+d]=u[0]+c[0],t[8+d]=u[1]+c[1],t[16+d]=u[2]+c[2],t[24+d]=u[3]+c[3],t[32+d]=u[3]-c[3],t[40+d]=u[2]-c[2],t[48+d]=u[1]-c[1],t[56+d]=u[0]-c[0]}function S(t){for(let e=0;e<64;++e){const n=t[0][e],i=t[1][e],r=t[2][e];t[0][e]=n+1.5747*r,t[1][e]=n-.1873*i-.4682*r,t[2][e]=n+1.8556*i}}function b(t,e,n){for(let s=0;s<64;++s)e[n+s]=As.toHalfFloat((i=t[s])<=1?Math.sign(i)*Math.pow(Math.abs(i),2.2):Math.sign(i)*Math.pow(r,Math.abs(i)-1));var i}function I(t){return new DataView(t.array.buffer,t.offset.value,t.size)}function T(t){const e=t.viewer.buffer.slice(t.offset.value,t.offset.value+t.size),n=new Uint8Array(C(e)),i=new Uint8Array(n.length);return x(n),w(n,i),new DataView(i.buffer)}function B(t){const e=Jv(t.array.slice(t.offset.value,t.offset.value+t.size)),n=new Uint8Array(e.length);return x(e),w(e,n),new DataView(n.buffer)}function R(t){const n=t.viewer,i={value:t.offset.value},r=new Uint16Array(t.columns*t.lines*(t.inputChannels.length*t.type)),s=new Uint8Array(8192);let a=0;const o=new Array(t.inputChannels.length);for(let e=0,n=t.inputChannels.length;e=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(l<=c)for(let t=0;t>3]&1<<(7&r))&&(n[i++]=r);const r=i-1;for(;i0;){const t=L(e.buffer,n),i=O(e,n),r=i>>2&3,o=new Int8Array([(i>>4)-1])[0],l=O(e,n);s.push({name:t,index:o,type:l,compression:r}),a-=t.length+3}const o=Z.channels,l=new Array(t.inputChannels.length);for(let e=0;e=0&&(c.idx[i.index]=e),t.offset=e)}}let h,u,d;if(r.acCompressedSize>0)switch(r.acCompression){case 0:h=new Uint16Array(r.totalAcUncompressedCount),_(t.array,e,n,r.acCompressedSize,h,r.totalAcUncompressedCount);break;case 1:const i=Jv(t.array.slice(n.value,n.value+r.totalAcUncompressedCount));h=new Uint16Array(i.buffer),n.value+=r.totalAcUncompressedCount}if(r.dcCompressedSize>0){const e={array:t.array,offset:n,size:r.dcCompressedSize};u=new Uint16Array(B(e).buffer),n.value+=r.dcCompressedSize}r.rleRawSize>0&&(d=C(Jv(t.array.slice(n.value,n.value+r.rleCompressedSize)).buffer),n.value+=r.rleCompressedSize);let p=0;const f=new Array(l.length);for(let t=0;t>10,n=1023&t;return(t>>15?-1:1)*(e?31===e?n?NaN:1/0:Math.pow(2,e-15)*(1+n/1024):n/1024*6103515625e-14)}function H(t,e){const n=t.getUint16(e.value,!0);return e.value+=2,n}function V(t,e){return G(H(t,e))}function W(t,e,n,i,r){return"string"===i||"stringvector"===i||"iccProfile"===i?function(t,e,n){const i=(new TextDecoder).decode(new Uint8Array(t).slice(e.value,e.value+n));return e.value=e.value+n,i}(e,n,r):"chlist"===i?function(t,e,n,i){const r=n.value,s=[];for(;n.value>4]}}(t,n):"lineOrder"===i?function(t,e){return["INCREASING_Y","DECREASING_Y","RANDOM_Y"][O(t,e)]}(t,n):"float"===i?Q(t,n):"v2f"===i?function(t,e){return[Q(t,e),Q(t,e)]}(t,n):"v3f"===i?function(t,e){return[Q(t,e),Q(t,e),Q(t,e)]}(t,n):"int"===i?U(t,n):"rational"===i?function(t,e){return[U(t,e),N(t,e)]}(t,n):"timecode"===i?function(t,e){return[N(t,e),N(t,e)]}(t,n):"preview"===i?(n.value+=r,"skipped"):void(n.value+=r)}function j(t,e,n,i){const r=new Array(t);for(let s=0;st.width?t.width-s:t.blockWidth,t.lines=a+t.blockHeight>t.height?t.height-a:t.blockHeight;const o=t.columns*t.totalBytes,l=t.sizet.height?t.height-r:t.blockHeight;const s=t.columns*t.totalBytes,a=t.size=t.height)continue;const l=e*s,c=(t.height-1-o)*t.outLineWidth;for(let e=0;et:s.scanOrder=t=>s.height-1-t,4==s.outputChannels?(s.format=$t,s.colorSpace=un):(s.format=re,s.colorSpace=cn),t.spec.singleTile){s.blockHeight=t.tiles.ySize,s.blockWidth=t.tiles.xSize;const n=function(t,e,n){let i=0;switch(t.levelMode){case"ONE_LEVEL":i=1;break;case"MIPMAP_LEVELS":i=function(t,e){const n=Math.log2(t);return"ROUND_DOWN"==e?Math.floor(n):Math.ceil(n)}(Math.max(e,n),t.roundingMode)+1;break;case"RIPMAP_LEVELS":throw new Error("THREE.EXRLoader: RIPMAP_LEVELS tiles currently unsupported.")}return i}(t.tiles,s.width,s.height),r=j(n,s.width,t.tiles.xSize,t.tiles.roundingMode),a=j(n,s.height,t.tiles.ySize,t.tiles.roundingMode);s.tileCount=r[0]*a[0];for(let t=0;t{const r=t.xr.getSession();"requestLightProbe"in r&&r.requestLightProbe({reflectionFormat:r.preferredReflectionFormat}).then((r=>{n=new by(this,t,r,e,(()=>{i=!0,this.dispatchEvent({type:"estimationstart"})}))}))})),t.xr.addEventListener("sessionend",(()=>{n&&(n.dispose(),n=null),i&&this.dispatchEvent({type:"estimationend"})})),this.dispose=()=>{n&&(n.dispose(),n=null),this.remove(this.lightProbe),this.lightProbe=null,this.remove(this.directionalLight),this.directionalLight=null,this.environment=null}}},e.TransformControls=class extends Id{constructor(t,e=null){super(void 0,e);const n=new F_(this);this._root=n;const i=new O_;this._gizmo=i,n.add(i);const r=new k_;this._plane=r,n.add(r);const s=this;function a(t,e){let n=e;Object.defineProperty(s,t,{get:function(){return void 0!==n?n:e},set:function(e){n!==e&&(n=e,r[t]=e,i[t]=e,s.dispatchEvent({type:t+"-changed",value:e}),s.dispatchEvent(p_))}}),s[t]=e,r[t]=e,i[t]=e}a("camera",t),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const o=new Qi,l=new Qi,c=new ki,h=new ki,u=new Qi,d=new ki,p=new Qi,f=new Qi,m=new Qi,g=new Qi;a("worldPosition",o),a("worldPositionStart",l),a("worldQuaternion",c),a("worldQuaternionStart",h),a("cameraPosition",u),a("cameraQuaternion",d),a("pointStart",p),a("pointEnd",f),a("rotationAxis",m),a("rotationAngle",0),a("eye",g),this._offset=new Qi,this._startNorm=new Qi,this._endNorm=new Qi,this._cameraScale=new Qi,this._parentPosition=new Qi,this._parentQuaternion=new ki,this._parentQuaternionInv=new ki,this._parentScale=new Qi,this._worldScaleStart=new Qi,this._worldQuaternionInv=new ki,this._worldScale=new Qi,this._positionStart=new Qi,this._quaternionStart=new ki,this._scaleStart=new Qi,this._getPointer=A_.bind(this),this._onPointerDown=y_.bind(this),this._onPointerHover=v_.bind(this),this._onPointerMove=__.bind(this),this._onPointerUp=x_.bind(this),null!==e&&this.connect()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(t){if(void 0===this.object||!0===this.dragging)return;null!==t&&l_.setFromCamera(t,this.camera);const e=w_(this._gizmo.picker[this.mode],l_);this.axis=e?e.object.name:null}pointerDown(t){if(void 0!==this.object&&!0!==this.dragging&&(null==t||0===t.button)&&null!==this.axis){null!==t&&l_.setFromCamera(t,this.camera);const e=w_(this._plane,l_,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,f_.mode=this.mode,this.dispatchEvent(f_)}}pointerMove(t){const e=this.axis,n=this.mode,i=this.object;let r=this.space;if("scale"===n?r="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(r="world"),void 0===i||null===e||!1===this.dragging||null!==t&&-1!==t.button)return;null!==t&&l_.setFromCamera(t,this.camera);const s=w_(this._plane,l_,!0);if(s){if(this.pointEnd.copy(s.point).sub(this.worldPositionStart),"translate"===n)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===r&&"XYZ"!==e&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===e.indexOf("X")&&(this._offset.x=0),-1===e.indexOf("Y")&&(this._offset.y=0),-1===e.indexOf("Z")&&(this._offset.z=0),"local"===r&&"XYZ"!==e?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===r&&(i.position.applyQuaternion(u_.copy(this._quaternionStart).invert()),-1!==e.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),"world"===r&&(i.parent&&i.position.add(c_.setFromMatrixPosition(i.parent.matrixWorld)),-1!==e.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(c_.setFromMatrixPosition(i.parent.matrixWorld)))),i.position.x=Math.max(this.minX,Math.min(this.maxX,i.position.x)),i.position.y=Math.max(this.minY,Math.min(this.maxY,i.position.y)),i.position.z=Math.max(this.minZ,Math.min(this.maxZ,i.position.z));else if("scale"===n){if(-1!==e.search("XYZ")){let t=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(t*=-1),h_.set(t,t,t)}else c_.copy(this.pointStart),h_.copy(this.pointEnd),c_.applyQuaternion(this._worldQuaternionInv),h_.applyQuaternion(this._worldQuaternionInv),h_.divide(c_),-1===e.search("X")&&(h_.x=1),-1===e.search("Y")&&(h_.y=1),-1===e.search("Z")&&(h_.z=1);i.scale.copy(this._scaleStart).multiply(h_),this.scaleSnap&&(-1!==e.search("X")&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Z")&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===n){this._offset.copy(this.pointEnd).sub(this.pointStart);const t=20/this.worldPosition.distanceTo(c_.setFromMatrixPosition(this.camera.matrixWorld));let n=!1;"XYZE"===e?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(c_.copy(this.rotationAxis).cross(this.eye))*t):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(d_[e]),c_.copy(d_[e]),"local"===r&&c_.applyQuaternion(this.worldQuaternion),c_.cross(this.eye),0===c_.length()?n=!0:this.rotationAngle=this._offset.dot(c_.normalize())*t),("E"===e||n)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===r&&"E"!==e&&"XYZE"!==e?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(u_.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(u_.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(p_),this.dispatchEvent(g_)}}pointerUp(t){null!==t&&0!==t.button||(this.dragging&&null!==this.axis&&(m_.mode=this.mode,this.dispatchEvent(m_)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(t){return this.object=t,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(p_),this.dispatchEvent(g_),this.pointStart.copy(this.pointEnd))}getRaycaster(){return l_}getMode(){return this.mode}setMode(t){this.mode=t}setTranslationSnap(t){this.translationSnap=t}setRotationSnap(t){this.rotationSnap=t}setScaleSnap(t){this.scaleSnap=t}setSize(t){this.size=t}setSpace(t){this.space=t}},e.CSS3DRenderer=class{constructor(t={}){const e=this;let n,i,r,s;const a={camera:{style:""},objects:new WeakMap},o=void 0!==t.element?t.element:document.createElement("div");o.style.overflow="hidden",this.domElement=o;const l=document.createElement("div");l.style.transformOrigin="0 0",l.style.pointerEvents="none",o.appendChild(l);const c=document.createElement("div");function h(t){return Math.abs(t)<1e-10?0:t}function u(t){const e=t.elements;return"matrix3d("+h(e[0])+","+h(-e[1])+","+h(e[2])+","+h(e[3])+","+h(e[4])+","+h(-e[5])+","+h(e[6])+","+h(e[7])+","+h(e[8])+","+h(-e[9])+","+h(e[10])+","+h(e[11])+","+h(e[12])+","+h(-e[13])+","+h(e[14])+","+h(e[15])+")"}function d(t){const e=t.elements;return"translate(-50%,-50%)matrix3d("+h(e[0])+","+h(e[1])+","+h(e[2])+","+h(e[3])+","+h(-e[4])+","+h(-e[5])+","+h(-e[6])+","+h(-e[7])+","+h(e[8])+","+h(e[9])+","+h(e[10])+","+h(e[11])+","+h(e[12])+","+h(e[13])+","+h(e[14])+","+h(e[15])+")"}function p(t){t.isCSS3DObject&&(t.element.style.display="none");for(let e=0,n=t.children.length;e{this._fadeMaterialManager.prepareScene(t)},this._onDisposeModel=({tile:t,scene:e})=>{this._fadeManager.deleteObject(t),this._fadeMaterialManager.deleteScene(e)},this._onAddCamera=({camera:t})=>{this._prevCameraTransforms.set(t,new gr)},this._onDeleteCamera=({camera:t})=>{this._prevCameraTransforms.delete(t)},this._onTileVisibilityChange=({tile:t,visible:e})=>{const n=t.cached.scene;n&&(n.visible=!0),this.forEachBatchIds(t,((t,e,n)=>{e.setFadeAt(t,0,0),e.setVisibleAt(t,!1),n.batchedMesh.setVisibleAt(t,!1)}))},this._onUpdateBefore=()=>{vB.call(this)},this._onUpdateAfter=()=>{yB.call(this)},t.addEventListener("load-model",this._onLoadModel),t.addEventListener("dispose-model",this._onDisposeModel),t.addEventListener("add-camera",this._onAddCamera),t.addEventListener("delete-camera",this._onDeleteCamera),t.addEventListener("update-before",this._onUpdateBefore),t.addEventListener("update-after",this._onUpdateAfter),t.addEventListener("tile-visibility-change",this._onTileVisibilityChange);const e=this._fadeManager;e.onFadeSetStart=()=>{t.dispatchEvent({type:"fade-start"}),t.dispatchEvent({type:"force-rerender"})},e.onFadeSetComplete=()=>{t.dispatchEvent({type:"fade-end"}),t.dispatchEvent({type:"force-rerender"})},e.onFadeComplete=(e,n)=>{this._fadeMaterialManager.setFade(e.cached.scene,0,0),this.forEachBatchIds(e,((t,e,i)=>{e.setFadeAt(t,0,0),e.setVisibleAt(t,!1),i.batchedMesh.setVisibleAt(t,n)})),n||(t.invokeOnePlugin((t=>t!==this&&t.setTileVisible&&t.setTileVisible(e,!1))),this._fadingOutCount--)};const n=new Map;t.cameras.forEach((t=>{n.set(t,new gr)})),t.forEachLoadedModel(((t,e)=>{this._onLoadModel({scene:t})})),this.tiles=t,this._fadeManager=e,this._prevCameraTransforms=n}initBatchedMesh(){const t=this.tiles.getPluginByName("BATCHED_TILES_PLUGIN")?.batchedMesh;if(t){if(null===this.batchedMesh){this._onBatchedMeshDispose=()=>{this.batchedMesh.dispose(),this.batchedMesh.removeFromParent(),this.batchedMesh=null,t.removeEventListener("dispose",this._onBatchedMeshDispose)};const e=t.material.clone();e.onBeforeCompile=t.material.onBeforeCompile,this.batchedMesh=new hB(t,e),this.tiles.group.add(this.batchedMesh)}}else null!==this.batchedMesh&&(this._onBatchedMeshDispose(),this._onBatchedMeshDispose=null)}setTileVisible(t,e){const n=this._fadeManager,i=n.isFading(t);if(n.isFadingOut(t)&&this._fadingOutCount--,e?1===t.__depthFromRenderedParent?((t[dB]||this.fadeRootTiles)&&this._fadeManager.fadeIn(t),t[dB]=!0):this._fadeManager.fadeIn(t):(this._fadingOutCount++,n.fadeOut(t)),i)return!0;const r=this._fadeManager.isFading(t);return!(e||!r)}dispose(){const t=this.tiles;this._fadeManager.completeAllFades(),null!==this.batchedMesh&&this._onBatchedMeshDispose(),t.removeEventListener("load-model",this._onLoadModel),t.removeEventListener("dispose-model",this._onDisposeModel),t.removeEventListener("add-camera",this._onAddCamera),t.removeEventListener("delete-camera",this._onDeleteCamera),t.removeEventListener("update-before",this._onUpdateBefore),t.removeEventListener("update-after",this._onUpdateAfter),t.removeEventListener("tile-visibility-change",this._onTileVisibilityChange),t.forEachLoadedModel(((t,e)=>{this._fadeManager.deleteObject(e),t&&(t.visible=!0)}))}forEachBatchIds(t,e){if(this.initBatchedMesh(),this.batchedMesh){const n=this.tiles.getPluginByName("BATCHED_TILES_PLUGIN"),i=n.getTileBatchIds(t);i&&i.forEach((t=>{e(t,this.batchedMesh,n)}))}}},d.ImplicitTilingPlugin=class{constructor(){this.name="IMPLICIT_TILING_PLUGIN"}init(t){this.tiles=t}preprocessNode(t,e,n){t.implicitTiling?(t.__hasUnrenderableContent=!0,t.__hasRenderableContent=!1,t.__subtreeIdx=0,t.__implicitRoot=t,t.__x=0,t.__y=0,t.__z=0,t.__level=0):/.subtree$/i.test(t.content?.uri)&&(t.__hasUnrenderableContent=!0,t.__hasRenderableContent=!1)}parseTile(t,e,n){if(/^subtree$/i.test(n))return new CB(e).parse(t),Promise.resolve()}preprocessURL(t,e){if(e&&e.implicitTiling){const t=e.implicitTiling.subtrees.uri.replace("{level}",e.__level).replace("{x}",e.__x).replace("{y}",e.__y).replace("{z}",e.__z);return new URL(t,e.__basePath+"/").toString()}return t}disposeTile(t){/.subtree$/i.test(t.content?.uri)&&(t.children.length=0)}},window.THREE=e,window.ThreeMeshUI=Qw,window.ThreeMeshBVH=h,window.TILES=d,window.CustomShaderMaterial=class extends us{constructor({baseMaterial:t,vertexShader:e,fragmentShader:n,uniforms:i,patchMap:r,cacheKey:s,...a}){if(!t)throw new Error("CustomShaderMaterial: baseMaterial is required.");let o;if(function(t){try{new t}catch(t){if(t.message.indexOf("is not a constructor")>=0)return!1}return!0}(t)){const e=0===Object.keys(a).length;o=new t(e?void 0:a)}else o=t,Object.assign(o,a);if(["ShaderMaterial","RawShaderMaterial"].includes(o.type))throw new Error(`CustomShaderMaterial does not support ${o.type} as a base material.`);super(),this.uniforms={},this.vertexShader="",this.fragmentShader="";const l=o;l.name=`CustomShaderMaterial<${o.name||o.type}>`,l.update=this.update.bind(l),l.__csm={prevOnBeforeCompile:o.onBeforeCompile,baseMaterial:o,vertexShader:e,fragmentShader:n,uniforms:i,patchMap:r,cacheKey:s};const c={...l.uniforms||{},...i||{}};l.uniforms=this.uniforms=c,l.vertexShader=this.vertexShader=e||"",l.fragmentShader=this.fragmentShader=n||"",l.update({fragmentShader:l.fragmentShader,vertexShader:l.vertexShader,uniforms:l.uniforms,patchMap:r,cacheKey:s}),Object.assign(this,l);const h=Object.getOwnPropertyDescriptors(Object.getPrototypeOf(l));for(const t in h){const e=h[t];(e.get||e.set)&&Object.defineProperty(this,t,e)}return Object.defineProperty(this,"type",{get:()=>o.type,set(t){o.type=t}}),this}update({fragmentShader:t,vertexShader:e,uniforms:n,cacheKey:i,patchMap:r}){const s=cx(e||""),a=cx(t||""),o=this;n&&(o.uniforms=n),e&&(o.vertexShader=e),t&&(o.fragmentShader=t),Object.entries(lx).forEach((([t,e])=>{for(const n in e){const i=e[n];(a&&a.includes(i)||s&&s.includes(i))&&(o[t]||(o[t]=1))}}));const l=o.__csm.prevOnBeforeCompile,c=(t,e,n)=>{let i,r="";if(e){const t=e.search(/void\s+main\s*\(\s*\)\s*{/);if(-1!==t){r=e.slice(0,t);let n=0,s=-1;for(let i=t;i{null==l||l(t,e);const i=r||{},h=o.type,u=h?`#define IS_${h.toUpperCase()};\n`:"#define IS_UNKNOWN;\n";t.vertexShader=u+"#define IS_VERTEX\n"+t.vertexShader,t.fragmentShader=u+"#define IS_FRAGMENT\n"+t.fragmentShader;const d=e=>{for(const n in e){const i="*"===n||s&&s.includes(n);if("*"===n||a&&a.includes(n)||i){const i=ax[n];if(i&&"*"!==i&&(Array.isArray(i)?!i.includes(h):i!==h))return void console.error(`CustomShaderMaterial: ${n} is not available in ${h}. Shader cannot compile.`);const r=e[n];for(const e in r){const n=r[e];if("object"==typeof n){const i=n.type,r=n.value;"fs"===i?t.fragmentShader=t.fragmentShader.replace(e,r):"vs"===i&&(t.vertexShader=t.vertexShader.replace(e,r))}else n&&(t.vertexShader=t.vertexShader.replace(e,n),t.fragmentShader=t.fragmentShader.replace(e,n))}}}};d(ox),d(i),t.vertexShader=c(t.vertexShader,s,!1),t.fragmentShader=c(t.fragmentShader,a,!0),n&&(t.uniforms={...t.uniforms,...o.uniforms}),o.uniforms=t.uniforms};const h=o.customProgramCacheKey;o.customProgramCacheKey=()=>((null==i?void 0:i())||function(t){let e=0;for(let n=0;n>>0)}((s||"")+(a||"")))+(null==h?void 0:h.call(o)),o.needsUpdate=!0}clone(){const t=this;return new t.constructor({baseMaterial:t.__csm.baseMaterial.clone(),vertexShader:t.__csm.vertexShader,fragmentShader:t.__csm.fragmentShader,uniforms:t.__csm.uniforms,patchMap:t.__csm.patchMap,cacheKey:t.__csm.cacheKey})}}})(); \ No newline at end of file +(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})}};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var e={};t.r(e),t.d(e,{ACESFilmicToneMapping:()=>ft,AddEquation:()=>P,AddOperation:()=>ct,AdditiveAnimationBlendMode:()=>Ze,AdditiveBlending:()=>T,AgXToneMapping:()=>gt,AlphaFormat:()=>Kt,AlwaysCompare:()=>Fn,AlwaysDepth:()=>tt,AlwaysStencilFunc:()=>Tn,AmbientLight:()=>Hh,AnimationAction:()=>Pu,AnimationClip:()=>dh,AnimationLoader:()=>xh,AnimationMixer:()=>Uu,AnimationObjectGroup:()=>Du,AnimationUtils:()=>$c,ArcCurve:()=>ml,ArrayCamera:()=>cu,ArrowHelper:()=>Bd,AttachedBindMode:()=>vt,Audio:()=>Au,AudioAnalyser:()=>Cu,AudioContext:()=>iu,AudioListener:()=>gu,AudioLoader:()=>ru,AxesHelper:()=>Rd,BackSide:()=>M,BasicDepthPacking:()=>nn,BasicShadowMap:()=>_,BatchedMesh:()=>Fo,Bone:()=>Za,BooleanKeyframeTrack:()=>sh,Box2:()=>Ku,Box3:()=>Vi,Box3Helper:()=>Md,BoxGeometry:()=>$s,BoxHelper:()=>Ed,BufferAttribute:()=>ws,BufferGeometry:()=>ks,BufferGeometryLoader:()=>Jh,ByteType:()=>Qt,Cache:()=>fh,Camera:()=>sa,CameraHelper:()=>xd,CanvasTexture:()=>ul,CapsuleGeometry:()=>Nl,CatmullRomCurve3:()=>xl,CineonToneMapping:()=>pt,CircleGeometry:()=>Fl,ClampToEdgeWrapping:()=>bt,Clock:()=>hu,Color:()=>cs,ColorKeyframeTrack:()=>ah,ColorManagement:()=>Ci,CompressedArrayTexture:()=>cl,CompressedCubeTexture:()=>hl,CompressedTexture:()=>ll,CompressedTextureLoader:()=>wh,ConeGeometry:()=>kl,ConstantAlphaFactor:()=>K,ConstantColorFactor:()=>Y,Controls:()=>Pd,CubeCamera:()=>ua,CubeReflectionMapping:()=>xt,CubeRefractionMapping:()=>wt,CubeTexture:()=>da,CubeTextureLoader:()=>Eh,CubeUVReflectionMapping:()=>Mt,CubicBezierCurve:()=>Ml,CubicBezierCurve3:()=>Sl,CubicInterpolant:()=>eh,CullFaceBack:()=>A,CullFaceFront:()=>v,CullFaceFrontBack:()=>y,CullFaceNone:()=>g,Curve:()=>pl,CurvePath:()=>Pl,CustomBlending:()=>D,CustomToneMapping:()=>mt,CylinderGeometry:()=>Ol,Cylindrical:()=>Xu,Data3DTexture:()=>Oi,DataArrayTexture:()=>Ni,DataTexture:()=>$a,DataTextureLoader:()=>Mh,DataUtils:()=>vs,DecrementStencilOp:()=>vn,DecrementWrapStencilOp:()=>_n,DefaultLoadingManager:()=>gh,DepthFormat:()=>ne,DepthStencilFormat:()=>ie,DepthTexture:()=>dl,DetachedBindMode:()=>yt,DirectionalLight:()=>Gh,DirectionalLightHelper:()=>vd,DiscreteInterpolant:()=>ih,DodecahedronGeometry:()=>zl,DoubleSide:()=>S,DstAlphaFactor:()=>V,DstColorFactor:()=>j,DynamicCopyUsage:()=>Wn,DynamicDrawUsage:()=>kn,DynamicReadUsage:()=>Gn,EdgesGeometry:()=>jl,EllipseCurve:()=>fl,EqualCompare:()=>Dn,EqualDepth:()=>it,EqualStencilFunc:()=>En,EquirectangularReflectionMapping:()=>Ct,EquirectangularRefractionMapping:()=>Et,Euler:()=>br,EventDispatcher:()=>Zn,ExtrudeGeometry:()=>xc,FileLoader:()=>_h,Float16BufferAttribute:()=>Bs,Float32BufferAttribute:()=>Rs,FloatType:()=>Wt,Fog:()=>va,FogExp2:()=>Aa,FramebufferTexture:()=>ol,FrontSide:()=>E,Frustum:()=>yo,GLBufferAttribute:()=>Gu,GLSL1:()=>qn,GLSL3:()=>Xn,GreaterCompare:()=>Ln,GreaterDepth:()=>st,GreaterEqualCompare:()=>Nn,GreaterEqualDepth:()=>rt,GreaterEqualStencilFunc:()=>In,GreaterStencilFunc:()=>Sn,GridHelper:()=>pd,Group:()=>fa,HalfFloatType:()=>jt,HemisphereLight:()=>Ih,HemisphereLightHelper:()=>dd,IcosahedronGeometry:()=>Cc,ImageBitmapLoader:()=>eu,ImageLoader:()=>Ch,ImageUtils:()=>bi,IncrementStencilOp:()=>An,IncrementWrapStencilOp:()=>yn,InstancedBufferAttribute:()=>io,InstancedBufferGeometry:()=>Yh,InstancedInterleavedBuffer:()=>zu,InstancedMesh:()=>uo,Int16BufferAttribute:()=>Ss,Int32BufferAttribute:()=>Is,Int8BufferAttribute:()=>Cs,IntType:()=>Ht,InterleavedBuffer:()=>_a,InterleavedBufferAttribute:()=>wa,Interpolant:()=>th,InterpolateDiscrete:()=>We,InterpolateLinear:()=>je,InterpolateSmooth:()=>qe,InvertStencilOp:()=>xn,KeepStencilOp:()=>mn,KeyframeTrack:()=>rh,LOD:()=>za,LatheGeometry:()=>Ul,Layers:()=>Ir,LessCompare:()=>Rn,LessDepth:()=>et,LessEqualCompare:()=>Pn,LessEqualDepth:()=>nt,LessEqualStencilFunc:()=>Mn,LessStencilFunc:()=>Cn,Light:()=>bh,LightProbe:()=>jh,Line:()=>jo,Line3:()=>td,LineBasicMaterial:()=>Oo,LineCurve:()=>bl,LineCurve3:()=>Il,LineDashedMaterial:()=>qc,LineLoop:()=>Ko,LineSegments:()=>Jo,LinearFilter:()=>Lt,LinearInterpolant:()=>nh,LinearMipMapLinearFilter:()=>Ot,LinearMipMapNearestFilter:()=>Nt,LinearMipmapLinearFilter:()=>Ft,LinearMipmapNearestFilter:()=>Ut,LinearSRGBColorSpace:()=>un,LinearToneMapping:()=>ut,LinearTransfer:()=>dn,Loader:()=>Ah,LoaderUtils:()=>Xh,LoadingManager:()=>mh,LoopOnce:()=>Ge,LoopPingPong:()=>Ve,LoopRepeat:()=>He,LuminanceAlphaFormat:()=>ee,LuminanceFormat:()=>te,MOUSE:()=>f,Material:()=>ds,MaterialLoader:()=>qh,MathUtils:()=>ci,Matrix2:()=>Yu,Matrix3:()=>ui,Matrix4:()=>Ar,MaxEquation:()=>F,Mesh:()=>Ks,MeshBasicMaterial:()=>ps,MeshDepthMaterial:()=>Vc,MeshDistanceMaterial:()=>Wc,MeshLambertMaterial:()=>Hc,MeshMatcapMaterial:()=>jc,MeshNormalMaterial:()=>Gc,MeshPhongMaterial:()=>Qc,MeshPhysicalMaterial:()=>kc,MeshStandardMaterial:()=>Oc,MeshToonMaterial:()=>zc,MinEquation:()=>N,MirroredRepeatWrapping:()=>It,MixOperation:()=>lt,MultiplyBlending:()=>R,MultiplyOperation:()=>ot,NearestFilter:()=>Tt,NearestMipMapLinearFilter:()=>Pt,NearestMipMapNearestFilter:()=>Rt,NearestMipmapLinearFilter:()=>Dt,NearestMipmapNearestFilter:()=>Bt,NeutralToneMapping:()=>At,NeverCompare:()=>Bn,NeverDepth:()=>$,NeverStencilFunc:()=>wn,NoBlending:()=>b,NoColorSpace:()=>cn,NoToneMapping:()=>ht,NormalAnimationBlendMode:()=>Ke,NormalBlending:()=>I,NotEqualCompare:()=>Un,NotEqualDepth:()=>at,NotEqualStencilFunc:()=>bn,NumberKeyframeTrack:()=>oh,Object3D:()=>Vr,ObjectLoader:()=>Kh,ObjectSpaceNormalMap:()=>ln,OctahedronGeometry:()=>Ec,OneFactor:()=>k,OneMinusConstantAlphaFactor:()=>Z,OneMinusConstantColorFactor:()=>J,OneMinusDstAlphaFactor:()=>W,OneMinusDstColorFactor:()=>q,OneMinusSrcAlphaFactor:()=>H,OneMinusSrcColorFactor:()=>z,OrthographicCamera:()=>Qh,PCFShadowMap:()=>x,PCFSoftShadowMap:()=>w,PMREMGenerator:()=>ap,Path:()=>Ll,PerspectiveCamera:()=>ca,Plane:()=>go,PlaneGeometry:()=>Mc,PlaneHelper:()=>Sd,PointLight:()=>kh,PointLightHelper:()=>ld,Points:()=>il,PointsMaterial:()=>Zo,PolarGridHelper:()=>fd,PolyhedronGeometry:()=>Ql,PositionalAudio:()=>wu,PropertyBinding:()=>Ru,PropertyMixer:()=>Eu,QuadraticBezierCurve:()=>Tl,QuadraticBezierCurve3:()=>Bl,Quaternion:()=>Qi,QuaternionKeyframeTrack:()=>ch,QuaternionLinearInterpolant:()=>lh,RED_GREEN_RGTC2_Format:()=>Qe,RED_RGTC1_Format:()=>Oe,REVISION:()=>p,RGBADepthPacking:()=>rn,RGBAFormat:()=>$t,RGBAIntegerFormat:()=>ce,RGBA_ASTC_10x10_Format:()=>De,RGBA_ASTC_10x5_Format:()=>Te,RGBA_ASTC_10x6_Format:()=>Be,RGBA_ASTC_10x8_Format:()=>Re,RGBA_ASTC_12x10_Format:()=>Pe,RGBA_ASTC_12x12_Format:()=>Le,RGBA_ASTC_4x4_Format:()=>xe,RGBA_ASTC_5x4_Format:()=>we,RGBA_ASTC_5x5_Format:()=>Ce,RGBA_ASTC_6x5_Format:()=>Ee,RGBA_ASTC_6x6_Format:()=>Me,RGBA_ASTC_8x5_Format:()=>Se,RGBA_ASTC_8x6_Format:()=>be,RGBA_ASTC_8x8_Format:()=>Ie,RGBA_BPTC_Format:()=>Ue,RGBA_ETC2_EAC_Format:()=>_e,RGBA_PVRTC_2BPPV1_Format:()=>Ae,RGBA_PVRTC_4BPPV1_Format:()=>ge,RGBA_S3TC_DXT1_Format:()=>ue,RGBA_S3TC_DXT3_Format:()=>de,RGBA_S3TC_DXT5_Format:()=>pe,RGBDepthPacking:()=>sn,RGBFormat:()=>Zt,RGBIntegerFormat:()=>le,RGB_BPTC_SIGNED_Format:()=>Ne,RGB_BPTC_UNSIGNED_Format:()=>Fe,RGB_ETC1_Format:()=>ve,RGB_ETC2_Format:()=>ye,RGB_PVRTC_2BPPV1_Format:()=>me,RGB_PVRTC_4BPPV1_Format:()=>fe,RGB_S3TC_DXT1_Format:()=>he,RGDepthPacking:()=>an,RGFormat:()=>ae,RGIntegerFormat:()=>oe,RawShaderMaterial:()=>Fc,Ray:()=>gr,Raycaster:()=>Vu,RectAreaLight:()=>Vh,RedFormat:()=>re,RedIntegerFormat:()=>se,ReinhardToneMapping:()=>dt,RenderTarget:()=>Li,RenderTarget3D:()=>Nu,RenderTargetArray:()=>Fu,RepeatWrapping:()=>St,ReplaceStencilOp:()=>gn,ReverseSubtractEquation:()=>U,RingGeometry:()=>Sc,SIGNED_RED_GREEN_RGTC2_Format:()=>ze,SIGNED_RED_RGTC1_Format:()=>ke,SRGBColorSpace:()=>hn,SRGBTransfer:()=>pn,Scene:()=>ya,ShaderChunk:()=>Od,ShaderLib:()=>Qd,ShaderMaterial:()=>ra,ShadowMaterial:()=>Nc,Shape:()=>ql,ShapeGeometry:()=>bc,ShapePath:()=>Dd,ShapeUtils:()=>vc,ShortType:()=>zt,Skeleton:()=>no,SkeletonHelper:()=>ad,SkinnedMesh:()=>Ka,Source:()=>Ti,Sphere:()=>lr,SphereGeometry:()=>Ic,Spherical:()=>qu,SphericalHarmonics3:()=>Wh,SplineCurve:()=>Rl,SpotLight:()=>Lh,SpotLightHelper:()=>nd,Sprite:()=>Fa,SpriteMaterial:()=>Ca,SrcAlphaFactor:()=>G,SrcAlphaSaturateFactor:()=>X,SrcColorFactor:()=>Q,StaticCopyUsage:()=>Vn,StaticDrawUsage:()=>On,StaticReadUsage:()=>zn,StereoCamera:()=>lu,StreamCopyUsage:()=>jn,StreamDrawUsage:()=>Qn,StreamReadUsage:()=>Hn,StringKeyframeTrack:()=>hh,SubtractEquation:()=>L,SubtractiveBlending:()=>B,TOUCH:()=>m,TangentSpaceNormalMap:()=>on,TetrahedronGeometry:()=>Tc,Texture:()=>Di,TextureLoader:()=>Sh,TextureUtils:()=>Ud,TimestampQuery:()=>Kn,TorusGeometry:()=>Bc,TorusKnotGeometry:()=>Rc,Triangle:()=>rs,TriangleFanDrawMode:()=>en,TriangleStripDrawMode:()=>tn,TrianglesDrawMode:()=>$e,TubeGeometry:()=>Dc,UVMapping:()=>_t,Uint16BufferAttribute:()=>bs,Uint32BufferAttribute:()=>Ts,Uint8BufferAttribute:()=>Es,Uint8ClampedBufferAttribute:()=>Ms,Uniform:()=>Ou,UniformsGroup:()=>Qu,UniformsLib:()=>kd,UniformsUtils:()=>ia,UnsignedByteType:()=>kt,UnsignedInt248Type:()=>Yt,UnsignedInt5999Type:()=>Jt,UnsignedIntType:()=>Vt,UnsignedShort4444Type:()=>qt,UnsignedShort5551Type:()=>Xt,UnsignedShortType:()=>Gt,VSMShadowMap:()=>C,Vector2:()=>hi,Vector3:()=>zi,Vector4:()=>Pi,VectorKeyframeTrack:()=>uh,VideoFrameTexture:()=>al,VideoTexture:()=>sl,WebGL3DRenderTarget:()=>ki,WebGLArrayRenderTarget:()=>Fi,WebGLCoordinateSystem:()=>Yn,WebGLCubeRenderTarget:()=>pa,WebGLRenderTarget:()=>Ui,WebGLRenderer:()=>mm,WebGLUtils:()=>lm,WebGPUCoordinateSystem:()=>Jn,WebXRController:()=>ga,WireframeGeometry:()=>Pc,WrapAroundEnding:()=>Je,ZeroCurvatureEnding:()=>Xe,ZeroFactor:()=>O,ZeroSlopeEnding:()=>Ye,ZeroStencilOp:()=>fn,createCanvasElement:()=>Ai});var n={};t.r(n),t.d(n,{ru:()=>Lg,pP:()=>Dg,_c:()=>Ug});var i={};t.r(i);var r={};t.r(r),t.d(r,{COLUMN:()=>mx,COLUMN_REVERSE:()=>gx,ROW:()=>px,ROW_REVERSE:()=>fx,contentDirection:()=>Ax});var s={};t.r(s),t.d(s,{CENTER:()=>yx,END:()=>_x,START:()=>vx,STRETCH:()=>xx,alignItems:()=>wx,warnAboutDeprecatedAlignItems:()=>Cx});var a={};t.r(a),t.d(a,{CENTER:()=>bx,END:()=>Ix,SPACE_AROUND:()=>Tx,SPACE_BETWEEN:()=>Bx,SPACE_EVENLY:()=>Rx,START:()=>Sx,justifyContent:()=>Dx});var o={};t.r(o),t.d(o,{NORMAL:()=>Nx,NOWRAP:()=>Fx,PRE:()=>Ox,PRE_LINE:()=>kx,PRE_WRAP:()=>Qx,WHITE_CHARS:()=>Ux,collapseWhitespaceOnInlines:()=>Vx,collapseWhitespaceOnString:()=>zx,newlineBreakability:()=>Gx,shouldBreak:()=>Hx});var l={};t.r(l),t.d(l,{CENTER:()=>Jx,JUSTIFY:()=>Kx,JUSTIFY_CENTER:()=>tw,JUSTIFY_LEFT:()=>Zx,JUSTIFY_RIGHT:()=>$x,LEFT:()=>Xx,RIGHT:()=>Yx,textAlign:()=>ew});var c={};t.r(c),t.d(c,{bvh_distance_functions:()=>bS,bvh_ray_functions:()=>IS,bvh_struct_definitions:()=>TS,common_functions:()=>SS});var h={};t.r(h),t.d(h,{AVERAGE:()=>jw,BVHShaderGLSL:()=>c,CENTER:()=>Ww,CONTAINED:()=>Jw,ExtendedTriangle:()=>zC,FloatVertexAttributeTexture:()=>aS,INTERSECTED:()=>Yw,IntVertexAttributeTexture:()=>sS,MeshBVH:()=>bM,MeshBVHHelper:()=>qM,MeshBVHUniformStruct:()=>oS,NOT_INTERSECTED:()=>Xw,OrientedBox:()=>GC,SAH:()=>qw,StaticGeometryGenerator:()=>MS,UIntVertexAttributeTexture:()=>rS,VertexAttributeTexture:()=>iS,acceleratedRaycast:()=>FM,computeBatchedBoundsTree:()=>GM,computeBoundsTree:()=>QM,disposeBatchedBoundsTree:()=>HM,disposeBoundsTree:()=>zM,estimateMemoryInBytes:()=>$M,getBVHExtremes:()=>ZM,getJSONStructure:()=>eS,getTriangleHitPointInfo:()=>_E,shaderDistanceFunction:()=>RS,shaderIntersectFunction:()=>DS,shaderStructs:()=>BS,validateBounds:()=>tS});var u={};t.r(u),t.d(u,{latitudeToSphericalPhi:()=>bb,sphericalPhiToLatitude:()=>Sb,swapToGeoFrame:()=>Eb,swapToThreeFrame:()=>Mb,toLatLonString:()=>Tb});var d={};t.r(d),t.d(d,{B3DMLoader:()=>pb,B3DMLoaderBase:()=>db,CAMERA_FRAME:()=>Vb,CMPTLoader:()=>lI,CMPTLoaderBase:()=>oI,CameraTransitionManager:()=>oB,ENU_FRAME:()=>Hb,Ellipsoid:()=>jb,EllipsoidRegion:()=>LI,EnvironmentControls:()=>UT,FAILED:()=>NS,GeoUtils:()=>u,GlobeControls:()=>ZT,I3DMLoader:()=>aI,I3DMLoaderBase:()=>_b,LOADED:()=>QS,LOADING:()=>OS,LRUCache:()=>LS,LoaderBase:()=>hb,OBJECT_FRAME:()=>Wb,PARSING:()=>kS,PNTSLoader:()=>yb,PNTSLoaderBase:()=>fb,PriorityQueue:()=>US,TilesRenderer:()=>$I,TilesRendererBase:()=>ib,UNLOADED:()=>FS,WGS84_ELLIPSOID:()=>qb,WGS84_FLATTENING:()=>GS,WGS84_HEIGHT:()=>HS,WGS84_RADIUS:()=>zS});const p="173",f={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},m={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},g=0,A=1,v=2,y=3,_=0,x=1,w=2,C=3,E=0,M=1,S=2,b=0,I=1,T=2,B=3,R=4,D=5,P=100,L=101,U=102,N=103,F=104,O=200,k=201,Q=202,z=203,G=204,H=205,V=206,W=207,j=208,q=209,X=210,Y=211,J=212,K=213,Z=214,$=0,tt=1,et=2,nt=3,it=4,rt=5,st=6,at=7,ot=0,lt=1,ct=2,ht=0,ut=1,dt=2,pt=3,ft=4,mt=5,gt=6,At=7,vt="attached",yt="detached",_t=300,xt=301,wt=302,Ct=303,Et=304,Mt=306,St=1e3,bt=1001,It=1002,Tt=1003,Bt=1004,Rt=1004,Dt=1005,Pt=1005,Lt=1006,Ut=1007,Nt=1007,Ft=1008,Ot=1008,kt=1009,Qt=1010,zt=1011,Gt=1012,Ht=1013,Vt=1014,Wt=1015,jt=1016,qt=1017,Xt=1018,Yt=1020,Jt=35902,Kt=1021,Zt=1022,$t=1023,te=1024,ee=1025,ne=1026,ie=1027,re=1028,se=1029,ae=1030,oe=1031,le=1032,ce=1033,he=33776,ue=33777,de=33778,pe=33779,fe=35840,me=35841,ge=35842,Ae=35843,ve=36196,ye=37492,_e=37496,xe=37808,we=37809,Ce=37810,Ee=37811,Me=37812,Se=37813,be=37814,Ie=37815,Te=37816,Be=37817,Re=37818,De=37819,Pe=37820,Le=37821,Ue=36492,Ne=36494,Fe=36495,Oe=36283,ke=36284,Qe=36285,ze=36286,Ge=2200,He=2201,Ve=2202,We=2300,je=2301,qe=2302,Xe=2400,Ye=2401,Je=2402,Ke=2500,Ze=2501,$e=0,tn=1,en=2,nn=3200,rn=3201,sn=3202,an=3203,on=0,ln=1,cn="",hn="srgb",un="srgb-linear",dn="linear",pn="srgb",fn=0,mn=7680,gn=7681,An=7682,vn=7683,yn=34055,_n=34056,xn=5386,wn=512,Cn=513,En=514,Mn=515,Sn=516,bn=517,In=518,Tn=519,Bn=512,Rn=513,Dn=514,Pn=515,Ln=516,Un=517,Nn=518,Fn=519,On=35044,kn=35048,Qn=35040,zn=35045,Gn=35049,Hn=35041,Vn=35046,Wn=35050,jn=35042,qn="100",Xn="300 es",Yn=2e3,Jn=2001,Kn={COMPUTE:"compute",RENDER:"render"};class Zn{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){const n=this._listeners;return void 0!==n&&void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){const n=this._listeners;if(void 0===n)return;const i=n[t];if(void 0!==i){const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}dispatchEvent(t){const e=this._listeners;if(void 0===e)return;const n=e[t.type];if(void 0!==n){t.target=this;const e=n.slice(0);for(let n=0,i=e.length;n>8&255]+$n[t>>16&255]+$n[t>>24&255]+"-"+$n[255&e]+$n[e>>8&255]+"-"+$n[e>>16&15|64]+$n[e>>24&255]+"-"+$n[63&n|128]+$n[n>>8&255]+"-"+$n[n>>16&255]+$n[n>>24&255]+$n[255&i]+$n[i>>8&255]+$n[i>>16&255]+$n[i>>24&255]).toLowerCase()}function ri(t,e,n){return Math.max(e,Math.min(n,t))}function si(t,e){return(t%e+e)%e}function ai(t,e,n){return(1-n)*t+n*e}function oi(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function li(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const ci={DEG2RAD:ei,RAD2DEG:ni,generateUUID:ii,clamp:ri,euclideanModulo:si,mapLinear:function(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)},inverseLerp:function(t,e,n){return t!==e?(n-t)/(e-t):0},lerp:ai,damp:function(t,e,n,i){return ai(t,e,1-Math.exp(-n*i))},pingpong:function(t,e=1){return e-Math.abs(si(t,2*e)-e)},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-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())},seededRandom:function(t){void 0!==t&&(ti=t);let e=ti+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(t){return t*ei},radToDeg:function(t){return t*ni},isPowerOfTwo:function(t){return!(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,n,i,r){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),c=s((e+i)/2),h=a((e+i)/2),u=s((e-i)/2),d=a((e-i)/2),p=s((i-e)/2),f=a((i-e)/2);switch(r){case"XYX":t.set(o*h,l*u,l*d,o*c);break;case"YZY":t.set(l*d,o*h,l*u,o*c);break;case"ZXZ":t.set(l*u,l*d,o*h,o*c);break;case"XZX":t.set(o*h,l*f,l*p,o*c);break;case"YXY":t.set(l*p,o*h,l*f,o*c);break;case"ZYZ":t.set(l*f,l*p,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:li,denormalize:oi};class hi{constructor(t=0,e=0){hi.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(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(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=ri(this.x,t.x,e.x),this.y=ri(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=ri(this.x,t,e),this.y=ri(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ri(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(ri(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*n-s*i+t.x,this.y=r*i+s*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ui{constructor(t,e,n,i,r,s,a,o,l){ui.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,s,a,o,l)}set(t,e,n,i,r,s,a,o,l){const c=this.elements;return c[0]=t,c[1]=i,c[2]=a,c[3]=e,c[4]=r,c[5]=o,c[6]=n,c[7]=s,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const 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}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],a=n[3],o=n[6],l=n[1],c=n[4],h=n[7],u=n[2],d=n[5],p=n[8],f=i[0],m=i[3],g=i[6],A=i[1],v=i[4],y=i[7],_=i[2],x=i[5],w=i[8];return r[0]=s*f+a*A+o*_,r[3]=s*m+a*v+o*x,r[6]=s*g+a*y+o*w,r[1]=l*f+c*A+h*_,r[4]=l*m+c*v+h*x,r[7]=l*g+c*y+h*w,r[2]=u*f+d*A+p*_,r[5]=u*m+d*v+p*x,r[8]=u*g+d*y+p*w,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8];return e*s*c-e*a*l-n*r*c+n*a*o+i*r*l-i*s*o}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8],h=c*s-a*l,u=a*o-c*r,d=l*r-s*o,p=e*h+n*u+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return t[0]=h*f,t[1]=(i*l-c*n)*f,t[2]=(a*n-i*s)*f,t[3]=u*f,t[4]=(c*e-i*o)*f,t[5]=(i*r-a*e)*f,t[6]=d*f,t[7]=(n*o-l*e)*f,t[8]=(s*e-n*r)*f,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,s,a){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*s+l*a)+s+t,-i*l,i*o,-i*(-l*s+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(di.makeScale(t,e)),this}rotate(t){return this.premultiply(di.makeRotation(-t)),this}translate(t,e){return this.premultiply(di.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const di=new ui;function pi(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}const fi={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function mi(t,e){return new fi[t](e)}function gi(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Ai(){const t=gi("canvas");return t.style.display="block",t}const vi={};function yi(t){t in vi||(vi[t]=!0,console.warn(t))}const _i=(new ui).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),xi=(new ui).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function wi(){const t={enabled:!0,workingColorSpace:un,spaces:{},convert:function(t,e,n){return!1!==this.enabled&&e!==n&&e&&n?(this.spaces[e].transfer===pn&&(t.r=Ei(t.r),t.g=Ei(t.g),t.b=Ei(t.b)),this.spaces[e].primaries!==this.spaces[n].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===pn&&(t.r=Mi(t.r),t.g=Mi(t.g),t.b=Mi(t.b)),t):t},fromWorkingColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return t===cn?dn:this.spaces[t].transfer},getLuminanceCoefficients:function(t,e=this.workingColorSpace){return t.fromArray(this.spaces[e].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,e,n){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],i=[.3127,.329];return t.define({[un]:{primaries:e,whitePoint:i,transfer:dn,toXYZ:_i,fromXYZ:xi,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:hn},outputColorSpaceConfig:{drawingBufferColorSpace:hn}},[hn]:{primaries:e,whitePoint:i,transfer:pn,toXYZ:_i,fromXYZ:xi,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:hn}}}),t}const Ci=wi();function Ei(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Mi(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let Si;class bi{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===Si&&(Si=gi("canvas")),Si.width=t.width,Si.height=t.height;const n=Si.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Si}return e.toDataURL("image/png")}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=gi("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let t=0;t0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==_t)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case St:t.x=t.x-Math.floor(t.x);break;case bt:t.x=t.x<0?0:1;break;case It: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 St:t.y=t.y-Math.floor(t.y);break;case bt:t.y=t.y<0?0:1;break;case It:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}Di.DEFAULT_IMAGE=null,Di.DEFAULT_MAPPING=_t,Di.DEFAULT_ANISOTROPY=1;class Pi{constructor(t=0,e=0,n=0,i=1){Pi.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(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(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(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(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(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(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(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(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(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}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*e+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*e+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*e+s[7]*n+s[11]*i+s[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const 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(t){let e,n,i,r;const s=.01,a=.1,o=t.elements,l=o[0],c=o[4],h=o[8],u=o[1],d=o[5],p=o[9],f=o[2],m=o[6],g=o[10];if(Math.abs(c-u)o&&t>A?tA?o=0?1:-1,i=1-e*e;if(i>Number.EPSILON){const r=Math.sqrt(i),s=Math.atan2(r,e*n);t=Math.sin(t*s)/r,a=Math.sin(a*s)/r}const r=a*n;if(o=o*t+u*r,l=l*t+d*r,c=c*t+p*r,h=h*t+f*r,t===1-a){const t=1/Math.sqrt(o*o+l*l+c*c+h*h);o*=t,l*=t,c*=t,h*=t}}t[e]=o,t[e+1]=l,t[e+2]=c,t[e+3]=h}static multiplyQuaternionsFlat(t,e,n,i,r,s){const a=n[i],o=n[i+1],l=n[i+2],c=n[i+3],h=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return t[e]=a*p+c*h+o*d-l*u,t[e+1]=o*p+c*u+l*h-a*d,t[e+2]=l*p+c*d+a*u-o*h,t[e+3]=c*p-a*h-o*u-l*d,t}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(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,r=t._z,s=t._order,a=Math.cos,o=Math.sin,l=a(n/2),c=a(i/2),h=a(r/2),u=o(n/2),d=o(i/2),p=o(r/2);switch(s){case"XYZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"YXZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"ZXY":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"ZYX":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"YZX":this._x=u*c*h+l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h-u*d*p;break;case"XZY":this._x=u*c*h-l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],r=e[8],s=e[1],a=e[5],o=e[9],l=e[2],c=e[6],h=e[10],u=n+a+h;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(c-o)*t,this._y=(r-l)*t,this._z=(s-i)*t}else if(n>a&&n>h){const t=2*Math.sqrt(1+n-a-h);this._w=(c-o)/t,this._x=.25*t,this._y=(i+s)/t,this._z=(r+l)/t}else if(a>h){const t=2*Math.sqrt(1+a-n-h);this._w=(r-l)/t,this._x=(i+s)/t,this._y=.25*t,this._z=(o+c)/t}else{const t=2*Math.sqrt(1+h-n-a);this._w=(s-i)/t,this._x=(r+l)/t,this._y=(o+c)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return nMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(ri(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let 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(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,r=t._z,s=t._w,a=e._x,o=e._y,l=e._z,c=e._w;return this._x=n*c+s*a+i*l-r*o,this._y=i*c+s*o+r*a-n*l,this._z=r*c+s*l+n*o-i*a,this._w=s*c-n*a-i*o-r*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const n=this._x,i=this._y,r=this._z,s=this._w;let a=s*t._w+n*t._x+i*t._y+r*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=s,this._x=n,this._y=i,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const t=1-e;return this._w=t*s+e*this._w,this._x=t*n+e*this._x,this._y=t*i+e*this._y,this._z=t*r+e*this._z,this.normalize(),this}const l=Math.sqrt(o),c=Math.atan2(l,a),h=Math.sin((1-e)*c)/l,u=Math.sin(e*c)/l;return this._w=s*h+this._w*u,this._x=n*h+this._x*u,this._y=i*h+this._y*u,this._z=r*h+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class zi{constructor(t=0,e=0,n=0){zi.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(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(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(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Hi.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Hi.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=t.elements,s=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,r=t.x,s=t.y,a=t.z,o=t.w,l=2*(s*i-a*n),c=2*(a*e-r*i),h=2*(r*n-s*e);return this.x=e+o*l+s*h-a*c,this.y=n+o*c+a*l-r*h,this.z=i+o*h+r*c-s*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(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(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(t,e){return this.x=ri(this.x,t.x,e.x),this.y=ri(this.y,t.y,e.y),this.z=ri(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=ri(this.x,t,e),this.y=ri(this.y,t,e),this.z=ri(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ri(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(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(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,r=t.z,s=e.x,a=e.y,o=e.z;return this.x=i*o-r*a,this.y=r*s-n*o,this.z=n*a-i*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Gi.copy(this).projectOnVector(t),this.sub(Gi)}reflect(t){return this.sub(Gi.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(ri(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Gi=new zi,Hi=new Qi;class Vi{constructor(t=new zi(1/0,1/0,1/0),e=new zi(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(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(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,ji),ji.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(tr),er.subVectors(this.max,tr),Xi.subVectors(t.a,tr),Yi.subVectors(t.b,tr),Ji.subVectors(t.c,tr),Ki.subVectors(Yi,Xi),Zi.subVectors(Ji,Yi),$i.subVectors(Xi,Ji);let e=[0,-Ki.z,Ki.y,0,-Zi.z,Zi.y,0,-$i.z,$i.y,Ki.z,0,-Ki.x,Zi.z,0,-Zi.x,$i.z,0,-$i.x,-Ki.y,Ki.x,0,-Zi.y,Zi.x,0,-$i.y,$i.x,0];return!!rr(e,Xi,Yi,Ji,er)&&(e=[1,0,0,0,1,0,0,0,1],!!rr(e,Xi,Yi,Ji,er)&&(nr.crossVectors(Ki,Zi),e=[nr.x,nr.y,nr.z],rr(e,Xi,Yi,Ji,er)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ji).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(ji).length()),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(Wi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Wi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Wi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Wi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Wi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Wi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Wi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Wi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Wi)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Wi=[new zi,new zi,new zi,new zi,new zi,new zi,new zi,new zi],ji=new zi,qi=new Vi,Xi=new zi,Yi=new zi,Ji=new zi,Ki=new zi,Zi=new zi,$i=new zi,tr=new zi,er=new zi,nr=new zi,ir=new zi;function rr(t,e,n,i,r){for(let s=0,a=t.length-3;s<=a;s+=3){ir.fromArray(t,s);const a=r.x*Math.abs(ir.x)+r.y*Math.abs(ir.y)+r.z*Math.abs(ir.z),o=e.dot(ir),l=n.dot(ir),c=i.dot(ir);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>a)return!1}return!0}const sr=new Vi,ar=new zi,or=new zi;class lr{constructor(t=new zi,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):sr.setFromPoints(t).getCenter(n);let i=0;for(let e=0,r=t.length;ethis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;ar.subVectors(t,this.center);const e=ar.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.addScaledVector(ar,n/t),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(or.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(ar.copy(t.center).add(or)),this.expandByPoint(ar.copy(t.center).sub(or))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const cr=new zi,hr=new zi,ur=new zi,dr=new zi,pr=new zi,fr=new zi,mr=new zi;class gr{constructor(t=new zi,e=new zi(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,cr)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=cr.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(cr.copy(this.origin).addScaledVector(this.direction,e),cr.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){hr.copy(t).add(e).multiplyScalar(.5),ur.copy(e).sub(t).normalize(),dr.copy(this.origin).sub(hr);const r=.5*t.distanceTo(e),s=-this.direction.dot(ur),a=dr.dot(this.direction),o=-dr.dot(ur),l=dr.lengthSq(),c=Math.abs(1-s*s);let h,u,d,p;if(c>0)if(h=s*o-a,u=s*a-o,p=r*c,h>=0)if(u>=-p)if(u<=p){const t=1/c;h*=t,u*=t,d=h*(h+s*u+2*a)+u*(s*h+u+2*o)+l}else u=r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u=-r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u<=-p?(h=Math.max(0,-(-s*r+a)),u=h>0?-r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l):u<=p?(h=0,u=Math.min(Math.max(-r,-o),r),d=u*(u+2*o)+l):(h=Math.max(0,-(s*r+a)),u=h>0?r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l);else u=s>0?-r:r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(hr).addScaledVector(ur,u),d}intersectSphere(t,e){cr.subVectors(t.center,this.origin);const n=cr.dot(this.direction),i=cr.dot(cr)-n*n,r=t.radius*t.radius;if(i>r)return null;const s=Math.sqrt(r-i),a=n-s,o=n+s;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,s,a,o;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,u=this.origin;return l>=0?(n=(t.min.x-u.x)*l,i=(t.max.x-u.x)*l):(n=(t.max.x-u.x)*l,i=(t.min.x-u.x)*l),c>=0?(r=(t.min.y-u.y)*c,s=(t.max.y-u.y)*c):(r=(t.max.y-u.y)*c,s=(t.min.y-u.y)*c),n>s||r>i?null:((r>n||isNaN(n))&&(n=r),(s=0?(a=(t.min.z-u.z)*h,o=(t.max.z-u.z)*h):(a=(t.max.z-u.z)*h,o=(t.min.z-u.z)*h),n>o||a>i?null:((a>n||n!=n)&&(n=a),(o=0?n:i,e)))}intersectsBox(t){return null!==this.intersectBox(t,cr)}intersectTriangle(t,e,n,i,r){pr.subVectors(e,t),fr.subVectors(n,t),mr.crossVectors(pr,fr);let s,a=this.direction.dot(mr);if(a>0){if(i)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}dr.subVectors(this.origin,t);const o=s*this.direction.dot(fr.crossVectors(dr,fr));if(o<0)return null;const l=s*this.direction.dot(pr.cross(dr));if(l<0)return null;if(o+l>a)return null;const c=-s*dr.dot(mr);return c<0?null:this.at(c/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class Ar{constructor(t,e,n,i,r,s,a,o,l,c,h,u,d,p,f,m){Ar.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,s,a,o,l,c,h,u,d,p,f,m)}set(t,e,n,i,r,s,a,o,l,c,h,u,d,p,f,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=i,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=c,g[10]=h,g[14]=u,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new Ar).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,i=1/vr.setFromMatrixColumn(t,0).length(),r=1/vr.setFromMatrixColumn(t,1).length(),s=1/vr.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*s,e[9]=n[9]*s,e[10]=n[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,r=t.z,s=Math.cos(n),a=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(r),h=Math.sin(r);if("XYZ"===t.order){const t=s*c,n=s*h,i=a*c,r=a*h;e[0]=o*c,e[4]=-o*h,e[8]=l,e[1]=n+i*l,e[5]=t-r*l,e[9]=-a*o,e[2]=r-t*l,e[6]=i+n*l,e[10]=s*o}else if("YXZ"===t.order){const t=o*c,n=o*h,i=l*c,r=l*h;e[0]=t+r*a,e[4]=i*a-n,e[8]=s*l,e[1]=s*h,e[5]=s*c,e[9]=-a,e[2]=n*a-i,e[6]=r+t*a,e[10]=s*o}else if("ZXY"===t.order){const t=o*c,n=o*h,i=l*c,r=l*h;e[0]=t-r*a,e[4]=-s*h,e[8]=i+n*a,e[1]=n+i*a,e[5]=s*c,e[9]=r-t*a,e[2]=-s*l,e[6]=a,e[10]=s*o}else if("ZYX"===t.order){const t=s*c,n=s*h,i=a*c,r=a*h;e[0]=o*c,e[4]=i*l-n,e[8]=t*l+r,e[1]=o*h,e[5]=r*l+t,e[9]=n*l-i,e[2]=-l,e[6]=a*o,e[10]=s*o}else if("YZX"===t.order){const t=s*o,n=s*l,i=a*o,r=a*l;e[0]=o*c,e[4]=r-t*h,e[8]=i*h+n,e[1]=h,e[5]=s*c,e[9]=-a*c,e[2]=-l*c,e[6]=n*h+i,e[10]=t-r*h}else if("XZY"===t.order){const t=s*o,n=s*l,i=a*o,r=a*l;e[0]=o*c,e[4]=-h,e[8]=l*c,e[1]=t*h+r,e[5]=s*c,e[9]=n*h-i,e[2]=i*h-n,e[6]=a*c,e[10]=r*h+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(_r,t,xr)}lookAt(t,e,n){const i=this.elements;return Er.subVectors(t,e),0===Er.lengthSq()&&(Er.z=1),Er.normalize(),wr.crossVectors(n,Er),0===wr.lengthSq()&&(1===Math.abs(n.z)?Er.x+=1e-4:Er.z+=1e-4,Er.normalize(),wr.crossVectors(n,Er)),wr.normalize(),Cr.crossVectors(Er,wr),i[0]=wr.x,i[4]=Cr.x,i[8]=Er.x,i[1]=wr.y,i[5]=Cr.y,i[9]=Er.y,i[2]=wr.z,i[6]=Cr.z,i[10]=Er.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,s=n[0],a=n[4],o=n[8],l=n[12],c=n[1],h=n[5],u=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],A=n[3],v=n[7],y=n[11],_=n[15],x=i[0],w=i[4],C=i[8],E=i[12],M=i[1],S=i[5],b=i[9],I=i[13],T=i[2],B=i[6],R=i[10],D=i[14],P=i[3],L=i[7],U=i[11],N=i[15];return r[0]=s*x+a*M+o*T+l*P,r[4]=s*w+a*S+o*B+l*L,r[8]=s*C+a*b+o*R+l*U,r[12]=s*E+a*I+o*D+l*N,r[1]=c*x+h*M+u*T+d*P,r[5]=c*w+h*S+u*B+d*L,r[9]=c*C+h*b+u*R+d*U,r[13]=c*E+h*I+u*D+d*N,r[2]=p*x+f*M+m*T+g*P,r[6]=p*w+f*S+m*B+g*L,r[10]=p*C+f*b+m*R+g*U,r[14]=p*E+f*I+m*D+g*N,r[3]=A*x+v*M+y*T+_*P,r[7]=A*w+v*S+y*B+_*L,r[11]=A*C+v*b+y*R+_*U,r[15]=A*E+v*I+y*D+_*N,this}multiplyScalar(t){const 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}determinant(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],s=t[1],a=t[5],o=t[9],l=t[13],c=t[2],h=t[6],u=t[10],d=t[14];return t[3]*(+r*o*h-i*l*h-r*a*u+n*l*u+i*a*d-n*o*d)+t[7]*(+e*o*d-e*l*u+r*s*u-i*s*d+i*l*c-r*o*c)+t[11]*(+e*l*h-e*a*d-r*s*h+n*s*d+r*a*c-n*l*c)+t[15]*(-i*a*c-e*o*h+e*a*u+i*s*h-n*s*u+n*o*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8],h=t[9],u=t[10],d=t[11],p=t[12],f=t[13],m=t[14],g=t[15],A=h*m*l-f*u*l+f*o*d-a*m*d-h*o*g+a*u*g,v=p*u*l-c*m*l-p*o*d+s*m*d+c*o*g-s*u*g,y=c*f*l-p*h*l+p*a*d-s*f*d-c*a*g+s*h*g,_=p*h*o-c*f*o-p*a*u+s*f*u+c*a*m-s*h*m,x=e*A+n*v+i*y+r*_;if(0===x)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/x;return t[0]=A*w,t[1]=(f*u*r-h*m*r-f*i*d+n*m*d+h*i*g-n*u*g)*w,t[2]=(a*m*r-f*o*r+f*i*l-n*m*l-a*i*g+n*o*g)*w,t[3]=(h*o*r-a*u*r-h*i*l+n*u*l+a*i*d-n*o*d)*w,t[4]=v*w,t[5]=(c*m*r-p*u*r+p*i*d-e*m*d-c*i*g+e*u*g)*w,t[6]=(p*o*r-s*m*r-p*i*l+e*m*l+s*i*g-e*o*g)*w,t[7]=(s*u*r-c*o*r+c*i*l-e*u*l-s*i*d+e*o*d)*w,t[8]=y*w,t[9]=(p*h*r-c*f*r-p*n*d+e*f*d+c*n*g-e*h*g)*w,t[10]=(s*f*r-p*a*r+p*n*l-e*f*l-s*n*g+e*a*g)*w,t[11]=(c*a*r-s*h*r-c*n*l+e*h*l+s*n*d-e*a*d)*w,t[12]=_*w,t[13]=(c*f*i-p*h*i+p*n*u-e*f*u-c*n*m+e*h*m)*w,t[14]=(p*a*i-s*f*i-p*n*o+e*f*o+s*n*m-e*a*m)*w,t[15]=(s*h*i-c*a*i+c*n*o-e*h*o-s*n*u+e*a*u)*w,this}scale(t){const e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),r=1-n,s=t.x,a=t.y,o=t.z,l=r*s,c=r*a;return this.set(l*s+n,l*a-i*o,l*o+i*a,0,l*a+i*o,c*a+n,c*o-i*s,0,l*o-i*a,c*o+i*s,r*o*o+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,s){return this.set(1,n,r,0,t,1,s,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,r=e._x,s=e._y,a=e._z,o=e._w,l=r+r,c=s+s,h=a+a,u=r*l,d=r*c,p=r*h,f=s*c,m=s*h,g=a*h,A=o*l,v=o*c,y=o*h,_=n.x,x=n.y,w=n.z;return i[0]=(1-(f+g))*_,i[1]=(d+y)*_,i[2]=(p-v)*_,i[3]=0,i[4]=(d-y)*x,i[5]=(1-(u+g))*x,i[6]=(m+A)*x,i[7]=0,i[8]=(p+v)*w,i[9]=(m-A)*w,i[10]=(1-(u+f))*w,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;let r=vr.set(i[0],i[1],i[2]).length();const s=vr.set(i[4],i[5],i[6]).length(),a=vr.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],yr.copy(this);const o=1/r,l=1/s,c=1/a;return yr.elements[0]*=o,yr.elements[1]*=o,yr.elements[2]*=o,yr.elements[4]*=l,yr.elements[5]*=l,yr.elements[6]*=l,yr.elements[8]*=c,yr.elements[9]*=c,yr.elements[10]*=c,e.setFromRotationMatrix(yr),n.x=r,n.y=s,n.z=a,this}makePerspective(t,e,n,i,r,s,a=Yn){const o=this.elements,l=2*r/(e-t),c=2*r/(n-i),h=(e+t)/(e-t),u=(n+i)/(n-i);let d,p;if(a===Yn)d=-(s+r)/(s-r),p=-2*s*r/(s-r);else{if(a!==Jn)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);d=-s/(s-r),p=-s*r/(s-r)}return o[0]=l,o[4]=0,o[8]=h,o[12]=0,o[1]=0,o[5]=c,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,n,i,r,s,a=Yn){const o=this.elements,l=1/(e-t),c=1/(n-i),h=1/(s-r),u=(e+t)*l,d=(n+i)*c;let p,f;if(a===Yn)p=(s+r)*h,f=-2*h;else{if(a!==Jn)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=r*h,f=-1*h}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=f,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const vr=new zi,yr=new Ar,_r=new zi(0,0,0),xr=new zi(1,1,1),wr=new zi,Cr=new zi,Er=new zi,Mr=new Ar,Sr=new Qi;class br{constructor(t=0,e=0,n=0,i=br.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}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(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,r=i[0],s=i[4],a=i[8],o=i[1],l=i[5],c=i[9],h=i[2],u=i[6],d=i[10];switch(e){case"XYZ":this._y=Math.asin(ri(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-ri(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(ri(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-ri(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(ri(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-ri(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Mr.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Mr,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Sr.setFromEuler(this),this.setFromQuaternion(Sr,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(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(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}br.DEFAULT_ORDER="XYZ";class Ir{constructor(){this.mask=1}set(t){this.mask=1<>>0}enable(t){this.mask|=1<1){for(let t=0;t1){for(let t=0;t0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map((t=>({boxInitialized:t.boxInitialized,boxMin:t.box.min.toArray(),boxMax:t.box.max.toArray(),sphereInitialized:t.sphereInitialized,sphereRadius:t.sphere.radius,sphereCenter:t.sphere.center.toArray()}))),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),null!==this.boundingBox&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const n=e.shapes;if(Array.isArray(n))for(let e=0,i=n.length;e0){i.children=[];for(let e=0;e0){i.animations=[];for(let e=0;e0&&(n.geometries=e),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),a.length>0&&(n.images=a),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),h.length>0&&(n.nodes=h)}return n.object=i,n;function s(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,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.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,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.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){Wr.subVectors(i,e),jr.subVectors(n,e),qr.subVectors(t,e);const s=Wr.dot(Wr),a=Wr.dot(jr),o=Wr.dot(qr),l=jr.dot(jr),c=jr.dot(qr),h=s*l-a*a;if(0===h)return r.set(0,0,0),null;const u=1/h,d=(l*o-a*c)*u,p=(s*c-a*o)*u;return r.set(1-d-p,p,d)}static containsPoint(t,e,n,i){return null!==this.getBarycoord(t,e,n,i,Xr)&&Xr.x>=0&&Xr.y>=0&&Xr.x+Xr.y<=1}static getInterpolation(t,e,n,i,r,s,a,o){return null===this.getBarycoord(t,e,n,i,Xr)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,Xr.x),o.addScaledVector(s,Xr.y),o.addScaledVector(a,Xr.z),o)}static getInterpolatedAttribute(t,e,n,i,r,s){return es.setScalar(0),ns.setScalar(0),is.setScalar(0),es.fromBufferAttribute(t,e),ns.fromBufferAttribute(t,n),is.fromBufferAttribute(t,i),s.setScalar(0),s.addScaledVector(es,r.x),s.addScaledVector(ns,r.y),s.addScaledVector(is,r.z),s}static isFrontFacing(t,e,n,i){return Wr.subVectors(n,e),jr.subVectors(t,e),Wr.cross(jr).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Wr.subVectors(this.c,this.b),jr.subVectors(this.a,this.b),.5*Wr.cross(jr).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return rs.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return rs.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return rs.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return rs.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return rs.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,r=this.c;let s,a;Yr.subVectors(i,n),Jr.subVectors(r,n),Zr.subVectors(t,n);const o=Yr.dot(Zr),l=Jr.dot(Zr);if(o<=0&&l<=0)return e.copy(n);$r.subVectors(t,i);const c=Yr.dot($r),h=Jr.dot($r);if(c>=0&&h<=c)return e.copy(i);const u=o*h-c*l;if(u<=0&&o>=0&&c<=0)return s=o/(o-c),e.copy(n).addScaledVector(Yr,s);ts.subVectors(t,r);const d=Yr.dot(ts),p=Jr.dot(ts);if(p>=0&&d<=p)return e.copy(r);const f=d*l-o*p;if(f<=0&&l>=0&&p<=0)return a=l/(l-p),e.copy(n).addScaledVector(Jr,a);const m=c*p-d*h;if(m<=0&&h-c>=0&&d-p>=0)return Kr.subVectors(r,i),a=(h-c)/(h-c+(d-p)),e.copy(i).addScaledVector(Kr,a);const g=1/(m+f+u);return s=f*g,a=u*g,e.copy(n).addScaledVector(Yr,s).addScaledVector(Jr,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const ss={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},as={h:0,s:0,l:0},os={h:0,s:0,l:0};function ls(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}class cs{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(void 0===e&&void 0===n){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=hn){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,Ci.toWorkingColorSpace(this,e),this}setRGB(t,e,n,i=Ci.workingColorSpace){return this.r=t,this.g=e,this.b=n,Ci.toWorkingColorSpace(this,i),this}setHSL(t,e,n,i=Ci.workingColorSpace){if(t=si(t,1),e=ri(e,0,1),n=ri(n,0,1),0===e)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+e):n+e-n*e,r=2*n-i;this.r=ls(r,i,t+1/3),this.g=ls(r,i,t),this.b=ls(r,i,t-1/3)}return Ci.toWorkingColorSpace(this,i),this}setStyle(t,e=hn){function n(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(n,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=hn){const n=ss[t.toLowerCase()];return void 0!==n?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Ei(t.r),this.g=Ei(t.g),this.b=Ei(t.b),this}copyLinearToSRGB(t){return this.r=Mi(t.r),this.g=Mi(t.g),this.b=Mi(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=hn){return Ci.fromWorkingColorSpace(hs.copy(this),t),65536*Math.round(ri(255*hs.r,0,255))+256*Math.round(ri(255*hs.g,0,255))+Math.round(ri(255*hs.b,0,255))}getHexString(t=hn){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Ci.workingColorSpace){Ci.fromWorkingColorSpace(hs.copy(this),e);const n=hs.r,i=hs.g,r=hs.b,s=Math.max(n,i,r),a=Math.min(n,i,r);let o,l;const c=(a+s)/2;if(a===s)o=0,l=0;else{const t=s-a;switch(l=c<=.5?t/(s+a):t/(2-s-a),s){case n:o=(i-r)/t+(i0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n:console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}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),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.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.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.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,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),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.normalMapType=this.normalMapType,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.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==I&&(n.blending=this.blending),this.side!==E&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),this.blendSrc!==G&&(n.blendSrc=this.blendSrc),this.blendDst!==H&&(n.blendDst=this.blendDst),this.blendEquation!==P&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==nt&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Tn&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==mn&&(n.stencilFail=this.stencilFail),this.stencilZFail!==mn&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==mn&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),e){const e=i(t.textures),r=i(t.images);e.length>0&&(n.textures=e),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,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.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let i=0;i!==t;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class ps extends ds{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new cs(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new br,this.combine=ot,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const fs=ms();function ms(){const t=new ArrayBuffer(4),e=new Float32Array(t),n=new Uint32Array(t),i=new Uint32Array(512),r=new Uint32Array(512);for(let t=0;t<256;++t){const e=t-127;e<-27?(i[t]=0,i[256|t]=32768,r[t]=24,r[256|t]=24):e<-14?(i[t]=1024>>-e-14,i[256|t]=1024>>-e-14|32768,r[t]=-e-1,r[256|t]=-e-1):e<=15?(i[t]=e+15<<10,i[256|t]=e+15<<10|32768,r[t]=13,r[256|t]=13):e<128?(i[t]=31744,i[256|t]=64512,r[t]=24,r[256|t]=24):(i[t]=31744,i[256|t]=64512,r[t]=13,r[256|t]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let t=1;t<1024;++t){let e=t<<13,n=0;for(;!(8388608&e);)e<<=1,n-=8388608;e&=-8388609,n+=947912704,s[t]=e|n}for(let t=1024;t<2048;++t)s[t]=939524096+(t-1024<<13);for(let t=1;t<31;++t)a[t]=t<<23;a[31]=1199570944,a[32]=2147483648;for(let t=33;t<63;++t)a[t]=2147483648+(t-32<<23);a[63]=3347054592;for(let t=1;t<64;++t)32!==t&&(o[t]=1024);return{floatView:e,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}function gs(t){Math.abs(t)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),t=ri(t,-65504,65504),fs.floatView[0]=t;const e=fs.uint32View[0],n=e>>23&511;return fs.baseTable[n]+((8388607&e)>>fs.shiftTable[n])}function As(t){const e=t>>10;return fs.uint32View[0]=fs.mantissaTable[fs.offsetTable[e]+(1023&t)]+fs.exponentTable[e],fs.floatView[0]}const vs={toHalfFloat:gs,fromHalfFloat:As},ys=new zi,_s=new hi;let xs=0;class ws{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:xs++}),this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=n,this.usage=On,this.updateRanges=[],this.gpuType=Wt,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;ie.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Vi);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new zi(-1/0,-1/0,-1/0),new zi(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const e in n){const i=n[e];t.data.attributes[e]=i.toJSON(t.data)}const i={};let r=!1;for(const e in this.morphAttributes){const n=this.morphAttributes[e],s=[];for(let e=0,i=n.length;e0&&(i[e]=s,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;null!==n&&this.setIndex(n.clone(e));const i=t.attributes;for(const t in i){const n=i[t];this.setAttribute(t,n.clone(e))}const r=t.morphAttributes;for(const t in r){const n=[],i=r[t];for(let t=0,r=i.length;t0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t(t.far-t.near)**2)return}Qs.copy(r).invert(),zs.copy(t.ray).applyMatrix4(Qs),null!==n.boundingBox&&!1===zs.intersectsBox(n.boundingBox)||this._computeIntersections(t,e,zs)}}_computeIntersections(t,e,n){let i;const r=this.geometry,s=this.material,a=r.index,o=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,h=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==a)if(Array.isArray(s))for(let r=0,o=u.length;rn.far?null:{distance:c,point:Js.clone(),object:t}}(t,e,n,i,Vs,Ws,js,Ys);if(h){const t=new zi;rs.getBarycoord(Ys,Vs,Ws,js,t),r&&(h.uv=rs.getInterpolatedAttribute(r,o,l,c,t,new hi)),s&&(h.uv1=rs.getInterpolatedAttribute(s,o,l,c,t,new hi)),a&&(h.normal=rs.getInterpolatedAttribute(a,o,l,c,t,new zi),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const e={a:o,b:l,c,normal:new zi,materialIndex:0};rs.getNormal(Vs,Ws,js,e.normal),h.face=e,h.barycoord=t}return h}class $s extends ks{constructor(t=1,e=1,n=1,i=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};const a=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);const o=[],l=[],c=[],h=[];let u=0,d=0;function p(t,e,n,i,r,s,p,f,m,g,A){const v=s/m,y=p/g,_=s/2,x=p/2,w=f/2,C=m+1,E=g+1;let M=0,S=0;const b=new zi;for(let s=0;s0?1:-1,c.push(b.x,b.y,b.z),h.push(o/m),h.push(1-s/g),M+=1}}for(let t=0;t0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const t in this.extensions)!0===this.extensions[t]&&(n[t]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class sa extends Vr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ar,this.projectionMatrix=new Ar,this.projectionMatrixInverse=new Ar,this.coordinateSystem=Yn}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}const aa=new zi,oa=new hi,la=new hi;class ca extends sa{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*ni*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*ei*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*ni*Math.atan(Math.tan(.5*ei*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){aa.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(aa.x,aa.y).multiplyScalar(-t/aa.z),aa.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(aa.x,aa.y).multiplyScalar(-t/aa.z)}getViewSize(t,e){return this.getViewBounds(t,oa,la),e.subVectors(la,oa)}setViewOffset(t,e,n,i,r,s){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*ei*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i;const s=this.view;if(null!==this.view&&this.view.enabled){const t=s.fullWidth,a=s.fullHeight;r+=s.offsetX*i/t,e-=s.offsetY*n/a,i*=s.width/t,n*=s.height/a}const a=this.filmOffset;0!==a&&(r+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const ha=-90;class ua extends Vr{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new ca(ha,1,t,e);i.layers=this.layers,this.add(i);const r=new ca(ha,1,t,e);r.layers=this.layers,this.add(r);const s=new ca(ha,1,t,e);s.layers=this.layers,this.add(s);const a=new ca(ha,1,t,e);a.layers=this.layers,this.add(a);const o=new ca(ha,1,t,e);o.layers=this.layers,this.add(o);const l=new ca(ha,1,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,r,s,a,o]=e;for(const t of e)this.remove(t);if(t===Yn)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(t!==Jn)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const t of e)this.add(t),t.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,s,a,o,l,c]=this.children,h=t.getRenderTarget(),u=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,i),t.render(e,r),t.setRenderTarget(n,1,i),t.render(e,s),t.setRenderTarget(n,2,i),t.render(e,a),t.setRenderTarget(n,3,i),t.render(e,o),t.setRenderTarget(n,4,i),t.render(e,l),n.texture.generateMipmaps=f,t.setRenderTarget(n,5,i),t.render(e,c),t.setRenderTarget(h,u,d),t.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class da extends Di{constructor(t,e,n,i,r,s,a,o,l,c){super(t=void 0!==t?t:[],e=void 0!==e?e:xt,n,i,r,s,a,o,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class pa extends Ui{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];this.texture=new da(i,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:Lt}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={tEquirect:{value:null}},i="\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",r="\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",s=new $s(5,5,5),a=new ra({name:"CubemapFromEquirect",uniforms:ta(n),vertexShader:i,fragmentShader:r,side:M,blending:b});a.uniforms.tEquirect.value=e;const o=new Ks(s,a),l=e.minFilter;return e.minFilter===Ft&&(e.minFilter=Lt),new ua(1,10,this).update(t,o),e.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(t,e,n,i){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,n,i);t.setRenderTarget(r)}}class fa extends Vr{constructor(){super(),this.isGroup=!0,this.type="Group"}}const ma={type:"move"};class ga{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new fa,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new fa,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new zi,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new zi),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new fa,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new zi,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new zi),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,e,n){let i=null,r=null,s=null;const a=this._targetRay,o=this._grip,l=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState){if(l&&t.hand){s=!0;for(const i of t.hand.values()){const t=e.getJointPose(i,n),r=this._getHandJoint(l,i);null!==t&&(r.matrix.fromArray(t.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=t.radius),r.visible=null!==t}const i=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],a=i.position.distanceTo(r.position),o=.02,c=.005;l.inputState.pinching&&a>o+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&a<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==a&&(i=e.getPose(t.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(ma)))}return null!==a&&(a.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==s),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const n=new fa;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}class Aa{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new cs(t),this.density=e}clone(){return new Aa(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class va{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new cs(t),this.near=e,this.far=n}clone(){return new va(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class ya extends Vr{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new br,this.environmentIntensity=1,this.environmentRotation=new br,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class _a{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=On,this.updateRanges=[],this.version=0,this.uuid=ii()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;it.far||e.push({distance:o,point:Ma.clone(),uv:rs.getInterpolation(Ma,Ra,Da,Pa,La,Ua,Na,new hi),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function Oa(t,e,n,i,r,s){Ia.subVectors(t,n).addScalar(.5).multiply(i),void 0!==r?(Ta.x=s*Ia.x-r*Ia.y,Ta.y=r*Ia.x+s*Ia.y):Ta.copy(Ia),t.copy(e),t.x+=Ta.x,t.y+=Ta.y,t.applyMatrix4(Ba)}const ka=new zi,Qa=new zi;class za extends Vr{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let t=0,n=e.length;t0){let n,i;for(n=1,i=e.length;n0){ka.setFromMatrixPosition(this.matrixWorld);const n=t.ray.origin.distanceTo(ka);this.getObjectForDistance(n).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){ka.setFromMatrixPosition(t.matrixWorld),Qa.setFromMatrixPosition(this.matrixWorld);const n=ka.distanceTo(Qa)/t.zoom;let i,r;for(e[0].object.visible=!0,i=1,r=e.length;i=t))break;e[i-1].object.visible=!1,e[i].object.visible=!0}for(this._currentLevel=i-1;i1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||mo.getNormalMatrix(t),i=this.coplanarPoint(po).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const Ao=new lr,vo=new zi;class yo{constructor(t=new go,e=new go,n=new go,i=new go,r=new go,s=new go){this.planes=[t,e,n,i,r,s]}set(t,e,n,i,r,s){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(s),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=Yn){const n=this.planes,i=t.elements,r=i[0],s=i[1],a=i[2],o=i[3],l=i[4],c=i[5],h=i[6],u=i[7],d=i[8],p=i[9],f=i[10],m=i[11],g=i[12],A=i[13],v=i[14],y=i[15];if(n[0].setComponents(o-r,u-l,m-d,y-g).normalize(),n[1].setComponents(o+r,u+l,m+d,y+g).normalize(),n[2].setComponents(o+s,u+c,m+p,y+A).normalize(),n[3].setComponents(o-s,u-c,m-p,y-A).normalize(),n[4].setComponents(o-a,u-h,m-f,y-v).normalize(),e===Yn)n[5].setComponents(o+a,u+h,m+f,y+v).normalize();else{if(e!==Jn)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);n[5].setComponents(a,h,f,v).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),Ao.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),Ao.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Ao)}intersectsSprite(t){return Ao.center.set(0,0,0),Ao.radius=.7071067811865476,Ao.applyMatrix4(t.matrixWorld),this.intersectsSphere(Ao)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let t=0;t<6;t++)if(e[t].distanceToPoint(n)0?t.max.x:t.min.x,vo.y=i.normal.y>0?t.max.y:t.min.y,vo.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(vo)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function _o(t,e){return t-e}function xo(t,e){return t.z-e.z}function wo(t,e){return e.z-t.z}class Co{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,e,n,i){const r=this.pool,s=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const a=r[this.index];s.push(a),this.index++,a.start=t,a.count=e,a.z=n,a.index=i}reset(){this.list.length=0,this.index=0}}const Eo=new Ar,Mo=new cs(1,1,1),So=new yo,bo=new Vi,Io=new lr,To=new zi,Bo=new zi,Ro=new zi,Do=new Co,Po=new Ks,Lo=[];function Uo(t,e,n=0){const i=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const r=t.count;for(let s=0;s65535?new Uint32Array(i):new Uint16Array(i);e.setIndex(new ws(t,1))}this._geometryInitialized=!0}}_validateGeometry(t){const e=this.geometry;if(Boolean(t.getIndex())!==Boolean(e.getIndex()))throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in e.attributes){if(!t.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=t.getAttribute(n),r=e.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(t){const e=this._instanceInfo;if(t<0||t>=e.length||!1===e[t].active)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${t}. Instance is either out of range or has been deleted.`)}validateGeometryId(t){const e=this._geometryInfo;if(t<0||t>=e.length||!1===e[t].active)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${t}. Geometry is either out of range or has been deleted.`)}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Vi);const t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const e={visible:!0,active:!0,geometryIndex:t};let n=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(_o),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=e):(n=this._instanceInfo.length,this._instanceInfo.push(e));const i=this._matricesTexture;Eo.identity().toArray(i.image.data,16*n),i.needsUpdate=!0;const r=this._colorsTexture;return r&&(Mo.toArray(r.image.data,4*n),r.needsUpdate=!0),this._visibilityChanged=!0,n}addGeometry(t,e=-1,n=-1){this._initializeGeometry(t),this._validateGeometry(t);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=-1===e?t.getAttribute("position").count:e;const s=t.getIndex();if(null!==s&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=-1===n?s.count:n),-1!==i.indexStart&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let a;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(_o),a=this._availableGeometryIds.shift(),r[a]=i):(a=this._geometryCount,this._geometryCount++,r.push(i)),this.setGeometryAt(a,t),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,a}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const n=this.geometry,i=null!==n.getIndex(),r=n.getIndex(),s=e.getIndex(),a=this._geometryInfo[t];if(i&&s.count>a.reservedIndexCount||e.attributes.position.count>a.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const o=a.vertexStart,l=a.reservedVertexCount;a.vertexCount=e.getAttribute("position").count;for(const t in n.attributes){const i=e.getAttribute(t),r=n.getAttribute(t);Uo(i,r,o);const s=i.itemSize;for(let t=i.count,e=l;t=e.length||!1===e[t].active)return this;const n=this._instanceInfo;for(let e=0,i=n.length;ee)).sort(((t,e)=>n[t].vertexStart-n[e].vertexStart)),r=this.geometry;for(let s=0,a=n.length;s=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(null===i.boundingBox){const t=new Vi,e=n.index,r=n.attributes.position;for(let n=i.start,s=i.start+i.count;n=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[t];if(null===i.boundingSphere){const e=new lr;this.getBoundingBoxAt(t,bo),bo.getCenter(e.center);const r=n.index,s=n.attributes.position;let a=0;for(let t=i.start,n=i.start+i.count;tt.active));if(Math.max(...n.map((t=>t.vertexStart+t.reservedVertexCount)))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map((t=>t.indexStart+t.reservedIndexCount)))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`);const i=this.geometry;i.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new ks,this._initializeGeometry(i));const r=this.geometry;i.index&&No(i.index.array,r.index.array);for(const t in i.attributes)No(i.attributes[t].array,r.attributes[t].array)}raycast(t,e){const n=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,s=this.geometry;Po.material=this.material,Po.geometry.index=s.index,Po.geometry.attributes=s.attributes,null===Po.geometry.boundingBox&&(Po.geometry.boundingBox=new Vi),null===Po.geometry.boundingSphere&&(Po.geometry.boundingSphere=new lr);for(let s=0,a=n.length;s({...t,boundingBox:null!==t.boundingBox?t.boundingBox.clone():null,boundingSphere:null!==t.boundingSphere?t.boundingSphere.clone():null}))),this._instanceInfo=t._instanceInfo.map((t=>({...t}))),this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(t,e,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=i.getIndex(),a=null===s?1:s.array.BYTES_PER_ELEMENT,o=this._instanceInfo,l=this._multiDrawStarts,c=this._multiDrawCounts,h=this._geometryInfo,u=this.perObjectFrustumCulled,d=this._indirectTexture,p=d.image.data;u&&(Eo.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),So.setFromProjectionMatrix(Eo,t.coordinateSystem));let f=0;if(this.sortObjects){Eo.copy(this.matrixWorld).invert(),To.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Eo),Bo.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Eo);for(let t=0,e=o.length;t0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;ti)return;Vo.applyMatrix4(t.matrixWorld);const l=e.ray.origin.distanceTo(Vo);return le.far?void 0:{distance:l,point:Wo.clone().applyMatrix4(t.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:t}}const Xo=new zi,Yo=new zi;class Jo extends jo{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[];for(let t=0,i=e.count;t0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;tr.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class sl extends Di{constructor(t,e,n,i,r,s,a,o,l){super(t,e,n,i,r,s,a,o,l),this.isVideoTexture=!0,this.minFilter=void 0!==s?s:Lt,this.magFilter=void 0!==r?r:Lt,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback((function e(){c.needsUpdate=!0,t.requestVideoFrameCallback(e)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;!1=="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class al extends sl{constructor(t,e,n,i,r,s,a,o){super({},t,e,n,i,r,s,a,o),this.isVideoFrameTexture=!0}update(){}clone(){return(new this.constructor).copy(this)}setFrame(t){this.image=t,this.needsUpdate=!0}}class ol extends Di{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=Tt,this.minFilter=Tt,this.generateMipmaps=!1,this.needsUpdate=!0}}class ll extends Di{constructor(t,e,n,i,r,s,a,o,l,c,h,u){super(null,s,a,o,l,c,i,r,h,u),this.isCompressedTexture=!0,this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class cl extends ll{constructor(t,e,n,i,r,s){super(t,e,n,r,s),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=bt,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class hl extends ll{constructor(t,e,n){super(void 0,t[0].width,t[0].height,e,n,xt),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}}class ul extends Di{constructor(t,e,n,i,r,s,a,o,l){super(t,e,n,i,r,s,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class dl extends Di{constructor(t,e,n,i,r,s,a,o,l,c=ne){if(c!==ne&&c!==ie)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===ne&&(n=Vt),void 0===n&&c===ie&&(n=Yt),super(null,i,r,s,a,o,c,n,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=void 0!==a?a:Tt,this.minFilter=void 0!==o?o:Tt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}class pl{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,i=this.getPoint(0),r=0;e.push(0);for(let s=1;s<=t;s++)n=this.getPoint(s/t),r+=n.distanceTo(i),e.push(r),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const n=this.getLengths();let i=0;const r=n.length;let s;s=e||t*n[r-1];let a,o=0,l=r-1;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),a=n[i]-s,a<0)o=i+1;else{if(!(a>0)){l=i;break}l=i-1}if(i=l,n[i]===s)return i/(r-1);const c=n[i];return(i+(s-c)/(n[i+1]-c))/(r-1)}getTangent(t,e){const n=1e-4;let i=t-n,r=t+n;i<0&&(i=0),r>1&&(r=1);const s=this.getPoint(i),a=this.getPoint(r),o=e||(s.isVector2?new hi:new zi);return o.copy(a).sub(s).normalize(),o}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new zi,i=[],r=[],s=[],a=new zi,o=new Ar;for(let e=0;e<=t;e++){const n=e/t;i[e]=this.getTangentAt(n,new zi)}r[0]=new zi,s[0]=new zi;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),h=Math.abs(i[0].y),u=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),u<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),s[0].crossVectors(i[0],r[0]);for(let e=1;e<=t;e++){if(r[e]=r[e-1].clone(),s[e]=s[e-1].clone(),a.crossVectors(i[e-1],i[e]),a.length()>Number.EPSILON){a.normalize();const t=Math.acos(ri(i[e-1].dot(i[e]),-1,1));r[e].applyMatrix4(o.makeRotationAxis(a,t))}s[e].crossVectors(i[e],r[e])}if(!0===e){let e=Math.acos(ri(r[0].dot(r[t]),-1,1));e/=t,i[0].dot(a.crossVectors(r[0],r[t]))>0&&(e=-e);for(let n=1;n<=t;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],e*n)),s[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:s}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class fl extends pl{constructor(t=0,e=0,n=1,i=1,r=0,s=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=s,this.aClockwise=a,this.aRotation=o}getPoint(t,e=new hi){const n=e,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const s=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?a=i[(l-1)%r]:(Al.subVectors(i[0],i[1]).add(i[0]),a=Al);const h=i[l%r],u=i[(l+1)%r];if(this.closed||l+2i.length-2?i.length-1:s+1],h=i[s>i.length-3?i.length-1:s+2];return n.set(wl(a,o.x,l.x,c.x,h.x),wl(a,o.y,l.y,c.y,h.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e=n){const t=i[r]-n,s=this.curves[r],a=s.getLength(),o=0===a?0:1-t/a;return s.getPointAt(o,e)}r++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,i=this.curves.length;n1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e0){const t=l.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class Ul extends ks{constructor(t=[new hi(0,-.5),new hi(.5,0),new hi(0,.5)],e=12,n=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=ri(i,0,2*Math.PI);const r=[],s=[],a=[],o=[],l=[],c=1/e,h=new zi,u=new hi,d=new zi,p=new zi,f=new zi;let m=0,g=0;for(let e=0;e<=t.length-1;e++)switch(e){case 0:m=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,d.x=1*g,d.y=-m,d.z=0*g,f.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case t.length-1:o.push(f.x,f.y,f.z);break;default:m=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,d.x=1*g,d.y=-m,d.z=0*g,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),o.push(d.x,d.y,d.z),f.copy(p)}for(let r=0;r<=e;r++){const d=n+r*c*i,p=Math.sin(d),f=Math.cos(d);for(let n=0;n<=t.length-1;n++){h.x=t[n].x*p,h.y=t[n].y,h.z=t[n].x*f,s.push(h.x,h.y,h.z),u.x=r/e,u.y=n/(t.length-1),a.push(u.x,u.y);const i=o[3*n+0]*p,c=o[3*n+1],d=o[3*n+0]*f;l.push(i,c,d)}}for(let n=0;n0||0!==i)&&(c.push(s,a,l),v+=3),(e>0||i!==r-1)&&(c.push(a,o,l),v+=3)}l.addGroup(g,v,0),g+=v}(),!1===s&&(t>0&&A(!0),e>0&&A(!1)),this.setIndex(c),this.setAttribute("position",new Rs(h,3)),this.setAttribute("normal",new Rs(u,3)),this.setAttribute("uv",new Rs(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ol(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class kl extends Ol{constructor(t=1,e=1,n=32,i=1,r=!1,s=0,a=2*Math.PI){super(0,t,e,n,i,r,s,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:s,thetaLength:a}}static fromJSON(t){return new kl(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Ql extends ks{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};const r=[],s=[];function a(t,e,n,i){const r=i+1,s=[];for(let i=0;i<=r;i++){s[i]=[];const a=t.clone().lerp(n,i/r),o=e.clone().lerp(n,i/r),l=r-i;for(let t=0;t<=l;t++)s[i][t]=0===t&&i===r?a:a.clone().lerp(o,t/l)}for(let t=0;t.9&&a<.1&&(e<.2&&(s[t+0]+=1),n<.2&&(s[t+2]+=1),i<.2&&(s[t+4]+=1))}}()}(),this.setAttribute("position",new Rs(r,3)),this.setAttribute("normal",new Rs(r.slice(),3)),this.setAttribute("uv",new Rs(s,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ql(t.vertices,t.indices,t.radius,t.details)}}class zl extends Ql{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,i=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new zl(t.radius,t.detail)}}const Gl=new zi,Hl=new zi,Vl=new zi,Wl=new rs;class jl extends ks{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},null!==t){const n=4,i=Math.pow(10,n),r=Math.cos(ei*e),s=t.getIndex(),a=t.getAttribute("position"),o=s?s.count:a.count,l=[0,0,0],c=["a","b","c"],h=new Array(3),u={},d=[];for(let t=0;t0)for(s=e;s=e;s-=i)a=mc(s,t[s],t[s+1],a);return a&&cc(a,a.next)&&(gc(a),a=a.next),a}function Yl(t,e){if(!t)return t;e||(e=t);let n,i=t;do{if(n=!1,i.steiner||!cc(i,i.next)&&0!==lc(i.prev,i,i.next))i=i.next;else{if(gc(i),i=e=i.prev,i===i.next)break;n=!0}}while(n||i!==e);return e}function Jl(t,e,n,i,r,s,a){if(!t)return;!a&&s&&function(t,e,n,i){let r=t;do{0===r.z&&(r.z=rc(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,n,i,r,s,a,o,l,c=1;do{for(n=t,t=null,s=null,a=0;n;){for(a++,i=n,o=0,e=0;e0||l>0&&i;)0!==o&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,o--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;n=i}s.nextZ=null,c*=2}while(a>1)}(r)}(t,i,r,s);let o,l,c=t;for(;t.prev!==t.next;)if(o=t.prev,l=t.next,s?Zl(t,i,r,s):Kl(t))e.push(o.i/n|0),e.push(t.i/n|0),e.push(l.i/n|0),gc(t),t=l.next,c=l.next;else if((t=l)===c){a?1===a?Jl(t=$l(Yl(t),e,n),e,n,i,r,s,2):2===a&&tc(t,e,n,i,r,s):Jl(Yl(t),e,n,i,r,s,1);break}}function Kl(t){const e=t.prev,n=t,i=t.next;if(lc(e,n,i)>=0)return!1;const r=e.x,s=n.x,a=i.x,o=e.y,l=n.y,c=i.y,h=rs?r>a?r:a:s>a?s:a,p=o>l?o>c?o:c:l>c?l:c;let f=i.next;for(;f!==e;){if(f.x>=h&&f.x<=d&&f.y>=u&&f.y<=p&&ac(r,o,s,l,a,c,f.x,f.y)&&lc(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Zl(t,e,n,i){const r=t.prev,s=t,a=t.next;if(lc(r,s,a)>=0)return!1;const o=r.x,l=s.x,c=a.x,h=r.y,u=s.y,d=a.y,p=ol?o>c?o:c:l>c?l:c,g=h>u?h>d?h:d:u>d?u:d,A=rc(p,f,e,n,i),v=rc(m,g,e,n,i);let y=t.prevZ,_=t.nextZ;for(;y&&y.z>=A&&_&&_.z<=v;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==a&&ac(o,h,l,u,c,d,y.x,y.y)&&lc(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==r&&_!==a&&ac(o,h,l,u,c,d,_.x,_.y)&&lc(_.prev,_,_.next)>=0)return!1;_=_.nextZ}for(;y&&y.z>=A;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==a&&ac(o,h,l,u,c,d,y.x,y.y)&&lc(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;_&&_.z<=v;){if(_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==r&&_!==a&&ac(o,h,l,u,c,d,_.x,_.y)&&lc(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function $l(t,e,n){let i=t;do{const r=i.prev,s=i.next.next;!cc(r,s)&&hc(r,i,i.next,s)&&pc(r,s)&&pc(s,r)&&(e.push(r.i/n|0),e.push(i.i/n|0),e.push(s.i/n|0),gc(i),gc(i.next),i=t=s),i=i.next}while(i!==t);return Yl(i)}function tc(t,e,n,i,r,s){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&oc(a,t)){let o=fc(a,t);return a=Yl(a,a.next),o=Yl(o,o.next),Jl(a,e,n,i,r,s,0),void Jl(o,e,n,i,r,s,0)}t=t.next}a=a.next}while(a!==t)}function ec(t,e){return t.x-e.x}function nc(t,e){const n=function(t,e){let n,i=e,r=-1/0;const s=t.x,a=t.y;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){const t=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=s&&t>r&&(r=t,n=i.x=i.x&&i.x>=l&&s!==i.x&&ac(an.x||i.x===n.x&&ic(n,i)))&&(n=i,u=h)),i=i.next}while(i!==o);return n}(t,e);if(!n)return e;const i=fc(n,t);return Yl(i,i.next),Yl(n,n.next)}function ic(t,e){return lc(t.prev,t,e.prev)<0&&lc(e.next,t,t.next)<0}function rc(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function sc(t){let e=t,n=t;do{(e.x=(t-a)*(s-o)&&(t-a)*(i-o)>=(n-a)*(e-o)&&(n-a)*(s-o)>=(r-a)*(i-o)}function oc(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&hc(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(pc(t,e)&&pc(e,t)&&function(t,e){let n=t,i=!1;const r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&r<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(lc(t.prev,t,e.prev)||lc(t,e.prev,e))||cc(t,e)&&lc(t.prev,t,t.next)>0&&lc(e.prev,e,e.next)>0)}function lc(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function cc(t,e){return t.x===e.x&&t.y===e.y}function hc(t,e,n,i){const r=dc(lc(t,e,n)),s=dc(lc(t,e,i)),a=dc(lc(n,i,t)),o=dc(lc(n,i,e));return r!==s&&a!==o||!(0!==r||!uc(t,n,e))||!(0!==s||!uc(t,i,e))||!(0!==a||!uc(n,t,i))||!(0!==o||!uc(n,e,i))}function uc(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function dc(t){return t>0?1:t<0?-1:0}function pc(t,e){return lc(t.prev,t,t.next)<0?lc(t,e,t.next)>=0&&lc(t,t.prev,e)>=0:lc(t,e,t.prev)<0||lc(t,t.next,e)<0}function fc(t,e){const n=new Ac(t.i,t.x,t.y),i=new Ac(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function mc(t,e,n,i){const r=new Ac(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function gc(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Ac(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class vc{static area(t){const e=t.length;let n=0;for(let i=e-1,r=0;r80*n){o=c=t[0],l=h=t[1];for(let e=n;ec&&(c=u),d>h&&(h=d);p=Math.max(c-o,h-l),p=0!==p?32767/p:0}return Jl(s,a,n,o,l,p,0),a}(n,i);for(let t=0;t2&&t[e-1].equals(t[0])&&t.pop()}function _c(t,e){for(let n=0;nNumber.EPSILON){const u=Math.sqrt(h),d=Math.sqrt(l*l+c*c),p=e.x-o/u,f=e.y+a/u,m=((n.x-c/d-p)*c-(n.y+l/d-f)*l)/(a*c-o*l);i=p+a*m-t.x,r=f+o*m-t.y;const g=i*i+r*r;if(g<=2)return new hi(i,r);s=Math.sqrt(g/2)}else{let t=!1;a>Number.EPSILON?l>Number.EPSILON&&(t=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(o)===Math.sign(c)&&(t=!0),t?(i=-o,r=a,s=Math.sqrt(h)):(i=a,r=o,s=Math.sqrt(h/2))}return new hi(i/s,r/s)}const R=[];for(let t=0,e=S.length,n=e-1,i=t+1;t=0;t--){const e=t/p,n=h*Math.cos(e*Math.PI/2),i=u*Math.sin(e*Math.PI/2)+d;for(let t=0,e=S.length;t=0;){const i=n;let r=n-1;r<0&&(r=t.length-1);for(let t=0,n=o+2*p;t0)&&d.push(e,r,l),(t!==n-1||o0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class Qc extends ds{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new cs(16777215),this.specular=new cs(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new cs(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new hi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new br,this.combine=ot,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class zc extends ds{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new cs(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new cs(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new hi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class Gc extends ds{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new hi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class Hc extends ds{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new cs(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new cs(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new hi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new br,this.combine=ot,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Vc extends ds{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=nn,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,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}}class Wc extends ds{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}class jc extends ds{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new cs(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new hi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}}class qc extends Oo{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function Xc(t,e,n){return!t||!n&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)}function Yc(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Jc(t){const e=t.length,n=new Array(e);for(let t=0;t!==e;++t)n[t]=t;return n.sort((function(e,n){return t[e]-t[n]})),n}function Kc(t,e,n){const i=t.length,r=new t.constructor(i);for(let s=0,a=0;a!==i;++s){const i=n[s]*e;for(let n=0;n!==e;++n)r[a++]=t[i+n]}return r}function Zc(t,e,n,i){let r=1,s=t[0];for(;void 0!==s&&void 0===s[i];)s=t[r++];if(void 0===s)return;let a=s[i];if(void 0!==a)if(Array.isArray(a))do{a=s[i],void 0!==a&&(e.push(s.time),n.push.apply(n,a)),s=t[r++]}while(void 0!==s);else if(void 0!==a.toArray)do{a=s[i],void 0!==a&&(e.push(s.time),a.toArray(n,n.length)),s=t[r++]}while(void 0!==s);else do{a=s[i],void 0!==a&&(e.push(s.time),n.push(a)),s=t[r++]}while(void 0!==s)}const $c={convertArray:Xc,isTypedArray:Yc,getKeyframeOrder:Jc,sortedArray:Kc,flattenJSON:Zc,subclip:function(t,e,n,i,r=30){const s=t.clone();s.name=e;const a=[];for(let t=0;t=i)){l.push(e.times[t]);for(let n=0;ns.tracks[t].times[0]&&(o=s.tracks[t].times[0]);for(let t=0;t=i.times[u]){const t=u*l+o,e=t+l-o;d=i.values.slice(t,e)}else{const t=i.createInterpolant(),e=o,n=l-o;t.evaluate(s),d=t.resultBuffer.slice(e,n)}"quaternion"===r&&(new Qi).fromArray(d).normalize().conjugate().toArray(d);const p=a.times.length;for(let t=0;t=r)break t;{const a=e[1];t=r)break e}s=n,n=0}}for(;n>>1;te;)--s;if(++s,0!==r||s!==i){r>=s&&(s=Math.max(s,1),r=s-1);const t=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*t,s*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let s=null;for(let e=0;e!==r;e++){const i=n[e];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,i),t=!1;break}if(null!==s&&s>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,i,s),t=!1;break}s=i}if(void 0!==i&&Yc(i))for(let e=0,n=i.length;e!==n;++e){const n=i[e];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,n),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===qe,r=t.length-1;let s=1;for(let a=1;a0){t[s]=t[r];for(let t=r*n,i=s*n,a=0;a!==n;++a)e[i+a]=e[t+a];++s}return s!==t.length?(this.times=t.slice(0,s),this.values=e.slice(0,s*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}rh.prototype.TimeBufferType=Float32Array,rh.prototype.ValueBufferType=Float32Array,rh.prototype.DefaultInterpolation=je;class sh extends rh{constructor(t,e,n){super(t,e,n)}}sh.prototype.ValueTypeName="bool",sh.prototype.ValueBufferType=Array,sh.prototype.DefaultInterpolation=We,sh.prototype.InterpolantFactoryMethodLinear=void 0,sh.prototype.InterpolantFactoryMethodSmooth=void 0;class ah extends rh{}ah.prototype.ValueTypeName="color";class oh extends rh{}oh.prototype.ValueTypeName="number";class lh extends th{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(n-e)/(i-e);let l=t*a;for(let t=l+a;l!==t;l+=4)Qi.slerpFlat(r,0,s,l-a,s,l,o);return r}}class ch extends rh{InterpolantFactoryMethodLinear(t){return new lh(this.times,this.values,this.getValueSize(),t)}}ch.prototype.ValueTypeName="quaternion",ch.prototype.InterpolantFactoryMethodSmooth=void 0;class hh extends rh{constructor(t,e,n){super(t,e,n)}}hh.prototype.ValueTypeName="string",hh.prototype.ValueBufferType=Array,hh.prototype.DefaultInterpolation=We,hh.prototype.InterpolantFactoryMethodLinear=void 0,hh.prototype.InterpolantFactoryMethodSmooth=void 0;class uh extends rh{}uh.prototype.ValueTypeName="vector";class dh{constructor(t="",e=-1,n=[],i=Ke){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=ii(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let t=0,r=n.length;t!==r;++t)e.push(ph(n[t]).scale(i));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,i=n.length;t!==i;++t)e.push(rh.toJSON(n[t]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const r=e.length,s=[];for(let t=0;t1){const t=s[1];let e=i[t];e||(i[t]=e=[]),e.push(n)}}const s=[];for(const t in i)s.push(this.CreateFromMorphTargetSequence(t,i[t],e,n));return s}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(t,e,n,i,r){if(0!==n.length){const s=[],a=[];Zc(n,s,a,i),0!==s.length&&r.push(new t(e,s,a))}},i=[],r=t.name||"default",s=t.fps||30,a=t.blendMode;let o=t.length||-1;const l=t.hierarchy||[];for(let t=0;t{e&&e(r),this.manager.itemEnd(t)}),0),r;if(void 0!==vh[t])return void vh[t].push({onLoad:e,onProgress:n,onError:i});vh[t]=[],vh[t].push({onLoad:e,onProgress:n,onError:i});const s=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(s).then((e=>{if(200===e.status||0===e.status){if(0===e.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===e.body||void 0===e.body.getReader)return e;const n=vh[t],i=e.body.getReader(),r=e.headers.get("X-File-Size")||e.headers.get("Content-Length"),s=r?parseInt(r):0,a=0!==s;let o=0;const l=new ReadableStream({start(t){!function e(){i.read().then((({done:i,value:r})=>{if(i)t.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:s});for(let t=0,e=n.length;t{t.error(e)}))}()}});return new Response(l)}throw new yh(`fetch for "${e.url}" responded with ${e.status}: ${e.statusText}`,e)})).then((t=>{switch(o){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then((t=>(new DOMParser).parseFromString(t,a)));case"json":return t.json();default:if(void 0===a)return t.text();{const e=/charset="?([^;"\s]*)"?/i.exec(a),n=e&&e[1]?e[1].toLowerCase():void 0,i=new TextDecoder(n);return t.arrayBuffer().then((t=>i.decode(t)))}}})).then((e=>{fh.add(t,e);const n=vh[t];delete vh[t];for(let t=0,i=n.length;t{const n=vh[t];if(void 0===n)throw this.manager.itemError(t),e;delete vh[t];for(let t=0,i=n.length;t{this.manager.itemEnd(t)})),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class xh extends Ah{constructor(t){super(t)}load(t,e,n,i){const r=this,s=new _h(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(n){try{e(r.parse(JSON.parse(n)))}catch(e){i?i(e):console.error(e),r.manager.itemError(t)}}),n,i)}parse(t){const e=[];for(let n=0;n0:i.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const r=t.uniforms[e];switch(i.uniforms[e]={},r.type){case"t":i.uniforms[e].value=n(r.value);break;case"c":i.uniforms[e].value=(new cs).setHex(r.value);break;case"v2":i.uniforms[e].value=(new hi).fromArray(r.value);break;case"v3":i.uniforms[e].value=(new zi).fromArray(r.value);break;case"v4":i.uniforms[e].value=(new Pi).fromArray(r.value);break;case"m3":i.uniforms[e].value=(new ui).fromArray(r.value);break;case"m4":i.uniforms[e].value=(new Ar).fromArray(r.value);break;default:i.uniforms[e].value=r.value}}if(void 0!==t.defines&&(i.defines=t.defines),void 0!==t.vertexShader&&(i.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(i.fragmentShader=t.fragmentShader),void 0!==t.glslVersion&&(i.glslVersion=t.glslVersion),void 0!==t.extensions)for(const e in t.extensions)i.extensions[e]=t.extensions[e];if(void 0!==t.lights&&(i.lights=t.lights),void 0!==t.clipping&&(i.clipping=t.clipping),void 0!==t.size&&(i.size=t.size),void 0!==t.sizeAttenuation&&(i.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(i.map=n(t.map)),void 0!==t.matcap&&(i.matcap=n(t.matcap)),void 0!==t.alphaMap&&(i.alphaMap=n(t.alphaMap)),void 0!==t.bumpMap&&(i.bumpMap=n(t.bumpMap)),void 0!==t.bumpScale&&(i.bumpScale=t.bumpScale),void 0!==t.normalMap&&(i.normalMap=n(t.normalMap)),void 0!==t.normalMapType&&(i.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),i.normalScale=(new hi).fromArray(e)}return void 0!==t.displacementMap&&(i.displacementMap=n(t.displacementMap)),void 0!==t.displacementScale&&(i.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(i.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(i.roughnessMap=n(t.roughnessMap)),void 0!==t.metalnessMap&&(i.metalnessMap=n(t.metalnessMap)),void 0!==t.emissiveMap&&(i.emissiveMap=n(t.emissiveMap)),void 0!==t.emissiveIntensity&&(i.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(i.specularMap=n(t.specularMap)),void 0!==t.specularIntensityMap&&(i.specularIntensityMap=n(t.specularIntensityMap)),void 0!==t.specularColorMap&&(i.specularColorMap=n(t.specularColorMap)),void 0!==t.envMap&&(i.envMap=n(t.envMap)),void 0!==t.envMapRotation&&i.envMapRotation.fromArray(t.envMapRotation),void 0!==t.envMapIntensity&&(i.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(i.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(i.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(i.lightMap=n(t.lightMap)),void 0!==t.lightMapIntensity&&(i.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(i.aoMap=n(t.aoMap)),void 0!==t.aoMapIntensity&&(i.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(i.gradientMap=n(t.gradientMap)),void 0!==t.clearcoatMap&&(i.clearcoatMap=n(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(i.clearcoatNormalMap=n(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(i.clearcoatNormalScale=(new hi).fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(i.iridescenceMap=n(t.iridescenceMap)),void 0!==t.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(t.iridescenceThicknessMap)),void 0!==t.transmissionMap&&(i.transmissionMap=n(t.transmissionMap)),void 0!==t.thicknessMap&&(i.thicknessMap=n(t.thicknessMap)),void 0!==t.anisotropyMap&&(i.anisotropyMap=n(t.anisotropyMap)),void 0!==t.sheenColorMap&&(i.sheenColorMap=n(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(i.sheenRoughnessMap=n(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return qh.createMaterialFromType(t)}static createMaterialFromType(t){return new{ShadowMaterial:Nc,SpriteMaterial:Ca,RawShaderMaterial:Fc,ShaderMaterial:ra,PointsMaterial:Zo,MeshPhysicalMaterial:kc,MeshStandardMaterial:Oc,MeshPhongMaterial:Qc,MeshToonMaterial:zc,MeshNormalMaterial:Gc,MeshLambertMaterial:Hc,MeshDepthMaterial:Vc,MeshDistanceMaterial:Wc,MeshBasicMaterial:ps,MeshMatcapMaterial:jc,LineDashedMaterial:qc,LineBasicMaterial:Oo,Material:ds}[t]}}class Xh{static decodeText(t){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let n=0,i=t.length;n0){const n=new mh(e);r=new Ch(n),r.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e0){i=new Ch(this.manager),i.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e{const e=new Vi;e.min.fromArray(t.boxMin),e.max.fromArray(t.boxMax);const n=new lr;return n.radius=t.sphereRadius,n.center.fromArray(t.sphereCenter),{boxInitialized:t.boxInitialized,box:e,sphereInitialized:t.sphereInitialized,sphere:n}})),s._maxInstanceCount=t.maxInstanceCount,s._maxVertexCount=t.maxVertexCount,s._maxIndexCount=t.maxIndexCount,s._geometryInitialized=t.geometryInitialized,s._geometryCount=t.geometryCount,s._matricesTexture=h(t.matricesTexture.uuid),void 0!==t.colorsTexture&&(s._colorsTexture=h(t.colorsTexture.uuid));break;case"LOD":s=new za;break;case"Line":s=new jo(l(t.geometry),c(t.material));break;case"LineLoop":s=new Ko(l(t.geometry),c(t.material));break;case"LineSegments":s=new Jo(l(t.geometry),c(t.material));break;case"PointCloud":case"Points":s=new il(l(t.geometry),c(t.material));break;case"Sprite":s=new Fa(c(t.material));break;case"Group":s=new fa;break;case"Bone":s=new Za;break;default:s=new Vr}if(s.uuid=t.uuid,void 0!==t.name&&(s.name=t.name),void 0!==t.matrix?(s.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(s.matrixAutoUpdate=t.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(void 0!==t.position&&s.position.fromArray(t.position),void 0!==t.rotation&&s.rotation.fromArray(t.rotation),void 0!==t.quaternion&&s.quaternion.fromArray(t.quaternion),void 0!==t.scale&&s.scale.fromArray(t.scale)),void 0!==t.up&&s.up.fromArray(t.up),void 0!==t.castShadow&&(s.castShadow=t.castShadow),void 0!==t.receiveShadow&&(s.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(s.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(s.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(s.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(s.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&s.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(s.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(s.visible=t.visible),void 0!==t.frustumCulled&&(s.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(s.renderOrder=t.renderOrder),void 0!==t.userData&&(s.userData=t.userData),void 0!==t.layers&&(s.layers.mask=t.layers),void 0!==t.children){const a=t.children;for(let t=0;t{e&&e(n),r.manager.itemEnd(t)})).catch((t=>{i&&i(t)})):(setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s);const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader;const o=fetch(t,a).then((function(t){return t.blob()})).then((function(t){return createImageBitmap(t,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(n){return fh.add(t,n),e&&e(n),r.manager.itemEnd(t),n})).catch((function(e){i&&i(e),fh.remove(t),r.manager.itemError(t),r.manager.itemEnd(t)}));fh.add(t,o),r.manager.itemStart(t)}}let nu;class iu{static getContext(){return void 0===nu&&(nu=new(window.AudioContext||window.webkitAudioContext)),nu}static setContext(t){nu=t}}class ru extends Ah{constructor(t){super(t)}load(t,e,n,i){const r=this,s=new _h(this.manager);function a(e){i?i(e):console.error(e),r.manager.itemError(t)}s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(t){try{const n=t.slice(0);iu.getContext().decodeAudioData(n,(function(t){e(t)})).catch(a)}catch(t){a(t)}}),n,i)}}const su=new Ar,au=new Ar,ou=new Ar;class lu{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new ca,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new ca,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,ou.copy(t.projectionMatrix);const n=e.eyeSep/2,i=n*e.near/e.focus,r=e.near*Math.tan(ei*e.fov*.5)/e.zoom;let s,a;au.elements[12]=-n,su.elements[12]=n,s=-r*e.aspect+i,a=r*e.aspect+i,ou.elements[0]=2*e.near/(a-s),ou.elements[8]=(a+s)/(a-s),this.cameraL.projectionMatrix.copy(ou),s=-r*e.aspect-i,a=r*e.aspect-i,ou.elements[0]=2*e.near/(a-s),ou.elements[8]=(a+s)/(a-s),this.cameraR.projectionMatrix.copy(ou)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(au),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(su)}}class cu extends ca{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t,this.index=0}}class hu{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=uu(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=uu();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function uu(){return performance.now()}const du=new zi,pu=new Qi,fu=new zi,mu=new zi;class gu extends Vr{constructor(){super(),this.type="AudioListener",this.context=iu.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new hu}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(du,pu,fu),mu.set(0,0,-1).applyQuaternion(pu),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(du.x,t),e.positionY.linearRampToValueAtTime(du.y,t),e.positionZ.linearRampToValueAtTime(du.z,t),e.forwardX.linearRampToValueAtTime(mu.x,t),e.forwardY.linearRampToValueAtTime(mu.y,t),e.forwardZ.linearRampToValueAtTime(mu.z,t),e.upX.linearRampToValueAtTime(n.x,t),e.upY.linearRampToValueAtTime(n.y,t),e.upZ.linearRampToValueAtTime(n.z,t)}else e.setPosition(du.x,du.y,du.z),e.setOrientation(mu.x,mu.y,mu.z,n.x,n.y,n.z)}}class Au extends Vr{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(t=0){if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(this.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let t=e,r=e+e;t!==r;++t)if(n[t]!==n[t+e]){a.setValue(n,i);break}}saveOriginalState(){const t=this.binding,e=this.buffer,n=this.valueSize,i=n*this._origIndex;t.getValue(e,i);for(let t=n,r=i;t!==r;++t)e[t]=e[i+t%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n=.5)for(let i=0;i!==r;++i)t[e+i]=t[n+i]}_slerp(t,e,n,i){Qi.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,r){const s=this._workIndex*r;Qi.multiplyQuaternionsFlat(t,s,t,e,t,n),Qi.slerpFlat(t,e,t,e,t,s,i)}_lerp(t,e,n,i,r){const s=1-i;for(let a=0;a!==r;++a){const r=e+a;t[r]=t[r]*s+t[n+a]*i}}_lerpAdditive(t,e,n,i,r){for(let s=0;s!==r;++s){const r=e+s;t[r]=t[r]+t[n+s]*i}}}const Mu="\\[\\]\\.:\\/",Su=new RegExp("["+Mu+"]","g"),bu="[^"+Mu+"]",Iu="[^"+Mu.replace("\\.","")+"]",Tu=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",bu)+/(WCOD+)?/.source.replace("WCOD",Iu)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",bu)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",bu)+"$"),Bu=["material","materials","bones","map"];class Ru{constructor(t,e,n){this.path=e,this.parsedPath=n||Ru.parseTrackName(e),this.node=Ru.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new Ru.Composite(t,e,n):new Ru(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(Su,"")}static parseTrackName(t){const e=Tu.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const t=n.nodeName.substring(i+1);-1!==Bu.indexOf(t)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=t)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(void 0!==n)return n}if(t.children){const n=function(t){for(let i=0;i=r){const s=r++,c=t[s];e[c.uuid]=l,t[l]=c,e[o]=s,t[s]=a;for(let t=0,e=i;t!==e;++t){const e=n[t],i=e[s],r=e[l];e[l]=i,e[s]=r}}}this.nCachedObjects_=r}uncache(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,s=t.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,l=e[o];if(void 0!==l)if(delete e[o],l0&&(e[a.uuid]=l),t[l]=a,t.pop();for(let t=0,e=i;t!==e;++t){const e=n[t];e[l]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){const n=this._bindingsIndicesByPath;let i=n[t];const r=this._bindings;if(void 0!==i)return r[i];const s=this._paths,a=this._parsedPaths,o=this._objects,l=o.length,c=this.nCachedObjects_,h=new Array(l);i=r.length,n[t]=i,s.push(t),a.push(e),r.push(h);for(let n=c,i=o.length;n!==i;++n){const i=o[n];h[n]=new Ru(i,t,e)}return h}unsubscribe_(t){const e=this._bindingsIndicesByPath,n=e[t];if(void 0!==n){const i=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length-1,o=s[a];e[t[a]]=n,s[n]=o,s.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}}class Pu{constructor(t,e,n=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=i;const r=e.tracks,s=r.length,a=new Array(s),o={endingStart:Xe,endingEnd:Xe};for(let t=0;t!==s;++t){const e=r[t].createInterpolant(null);a[t]=e,e.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=He,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}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){const n=this._clip.duration,i=t._clip.duration,r=i/n,s=n/i;t.warp(1,r,e),this.warp(s,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){const i=this._mixer,r=i.time,s=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=r,o[1]=r+n,l[0]=t/s,l[1]=e/s,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,i){if(!this.enabled)return void this._updateWeight(t);const r=this._startTime;if(null!==r){const i=(t-r)*n;i<0||0===n?e=0:(this._startTime=null,e=n*i)}e*=this._updateTimeScale(t);const s=this._updateTime(e),a=this._updateWeight(t);if(a>0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===Ze)for(let n=0,i=t.length;n!==i;++n)t[n].evaluate(s),e[n].accumulateAdditive(a);else for(let n=0,r=t.length;n!==r;++n)t[n].evaluate(s),e[n].accumulate(i,a)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const n=this._timeScaleInterpolant;null!==n&&(e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e))}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,n=this.loop;let i=this.time+t,r=this._loopCount;const s=n===Ve;if(0===t)return-1===r||!s||1&~r?i:e-i;if(n===Ge){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else{if(!(i<0)){this.time=i;break t}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),i>=e||i<0){const n=Math.floor(i/e);i-=e*n,r+=Math.abs(n);const a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===a){const e=t<0;this._setEndings(e,!e,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(s&&!(1&~r))return e-i}return i}_setEndings(t,e,n){const i=this._interpolantSettings;n?(i.endingStart=Ye,i.endingEnd=Ye):(i.endingStart=t?this.zeroSlopeAtStart?Ye:Xe:Je,i.endingEnd=e?this.zeroSlopeAtEnd?Ye:Xe:Je)}_scheduleFading(t,e,n){const i=this._mixer,r=i.time;let s=this._weightInterpolant;null===s&&(s=i._lendControlInterpolant(),this._weightInterpolant=s);const a=s.parameterPositions,o=s.sampleValues;return a[0]=r,o[0]=e,a[1]=r+t,o[1]=n,this}}const Lu=new Float32Array(1);class Uu extends Zn{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const n=t._localRoot||this._root,i=t._clip.tracks,r=i.length,s=t._propertyBindings,a=t._interpolants,o=n.uuid,l=this._bindingsByRootAndName;let c=l[o];void 0===c&&(c={},l[o]=c);for(let t=0;t!==r;++t){const r=i[t],l=r.name;let h=c[l];if(void 0!==h)++h.referenceCount,s[t]=h;else{if(h=s[t],void 0!==h){null===h._cacheIndex&&(++h.referenceCount,this._addInactiveBinding(h,o,l));continue}const i=e&&e._propertyBindings[t].binding.parsedPath;h=new Eu(Ru.create(n,l,i),r.ValueTypeName,r.getValueSize()),++h.referenceCount,this._addInactiveBinding(h,o,l),s[t]=h}a[t].resultBuffer=h.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,n=t._clip.uuid,i=this._actionsByClip[n];this._bindAction(t,i&&i.knownActions[0]),this._addInactiveAction(t,n,e)}const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,n=e.length;t!==n;++t){const n=e[t];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const 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(t){const e=t._cacheIndex;return null!==e&&e=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,n=this._nActiveActions,i=this.time+=t,r=Math.sign(t),s=this._accuIndex^=1;for(let a=0;a!==n;++a)e[a]._update(i,t,r,s);const a=this._bindings,o=this._nActiveBindings;for(let t=0;t!==o;++t)a[t].apply(s);return this}setTime(t){this.time=0;for(let t=0;t=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}containsBox(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(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ju).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Zu=new zi,$u=new zi;class td{constructor(t=new zi,e=new zi){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){Zu.subVectors(t,this.start),$u.subVectors(this.end,this.start);const n=$u.dot($u);let i=$u.dot(Zu)/n;return e&&(i=ri(i,0,1)),i}closestPointToPoint(t,e,n){const i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}const ed=new zi;class nd extends Vr{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const n=new ks,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let t=0,e=1,n=32;t1)for(let n=0;n.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{bd.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(bd,e)}}setLength(t,e=.2*t,n=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class Rd extends Jo{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=new ks;n.setAttribute("position",new Rs(e,3)),n.setAttribute("color",new Rs([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(n,new Oo({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,n){const i=new cs,r=this.geometry.attributes.color.array;return i.set(t),i.toArray(r,0),i.toArray(r,3),i.set(e),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Dd{constructor(){this.type="ShapePath",this.color=new cs,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Ll,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,n,i){return this.currentPath.quadraticCurveTo(t,e,n,i),this}bezierCurveTo(t,e,n,i,r,s){return this.currentPath.bezierCurveTo(t,e,n,i,r,s),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(t,e){const n=e.length;let i=!1;for(let r=n-1,s=0;sNumber.EPSILON){if(l<0&&(n=e[s],o=-o,a=e[r],l=-l),t.ya.y)continue;if(t.y===n.y){if(t.x===n.x)return!0}else{const e=l*(t.x-n.x)-o*(t.y-n.y);if(0===e)return!0;if(e<0)continue;i=!i}}else{if(t.y!==n.y)continue;if(a.x<=t.x&&t.x<=n.x||n.x<=t.x&&t.x<=a.x)return!0}}return i}const n=vc.isClockWise,i=this.subPaths;if(0===i.length)return[];let r,s,a;const o=[];if(1===i.length)return s=i[0],a=new ql,a.curves=s.curves,o.push(a),o;let l=!n(i[0].getPoints());l=t?!l:l;const c=[],h=[];let u,d,p=[],f=0;h[f]=void 0,p[f]=[];for(let e=0,a=i.length;e1){let t=!1,n=0;for(let t=0,e=h.length;t0&&!1===t&&(p=c)}for(let t=0,e=h.length;te?(t.repeat.x=1,t.repeat.y=n/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2):(t.repeat.x=e/n,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0),t},cover:function(t,e){const n=t.image&&t.image.width?t.image.width/t.image.height:1;return n>e?(t.repeat.x=e/n,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0):(t.repeat.x=1,t.repeat.y=n/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2),t},fill:function(t){return t.repeat.x=1,t.repeat.y=1,t.offset.x=0,t.offset.y=0,t},getByteLength:Ld};function Nd(){let t=null,e=!1,n=null,i=null;function r(e,s){n(e,s),i=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==n&&(i=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function Fd(t){const e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);const i=e.get(n);i&&(t.deleteBuffer(i.buffer),e.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){const t=e.get(n);return void((!t||t.versiont.start-e.start));let e=0;for(let t=1;t 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 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 max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\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}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\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};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\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}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( 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.a );\n}\nvec4 sRGBTransferOETF( 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.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, 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, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\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",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\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",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\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",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.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};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.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};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_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}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, 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 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\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\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}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\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 depth, const in float near, const in float far ) {\n\treturn depth * ( 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 depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\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\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), 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( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), 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 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\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 shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\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\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",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\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\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\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( 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}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\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 \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \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#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\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_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\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}",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 \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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 \n#include \n#include \n#include \nvoid main() {\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\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\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\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\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\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\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \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\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\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\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\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\tvec4 diffuseColor = vec4( diffuse, opacity );\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 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\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#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\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\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \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\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \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\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\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\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \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 + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \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\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_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\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\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\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},kd={common:{diffuse:{value:new cs(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ui},alphaMap:{value:null},alphaMapTransform:{value:new ui},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ui}},envmap:{envMap:{value:null},envMapRotation:{value:new ui},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ui}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ui}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ui},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ui},normalScale:{value:new hi(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ui},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ui}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ui}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ui}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new cs(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new cs(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ui},alphaTest:{value:0},uvTransform:{value:new ui}},sprite:{diffuse:{value:new cs(16777215)},opacity:{value:1},center:{value:new hi(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ui},alphaMap:{value:null},alphaMapTransform:{value:new ui},alphaTest:{value:0}}},Qd={basic:{uniforms:ea([kd.common,kd.specularmap,kd.envmap,kd.aomap,kd.lightmap,kd.fog]),vertexShader:Od.meshbasic_vert,fragmentShader:Od.meshbasic_frag},lambert:{uniforms:ea([kd.common,kd.specularmap,kd.envmap,kd.aomap,kd.lightmap,kd.emissivemap,kd.bumpmap,kd.normalmap,kd.displacementmap,kd.fog,kd.lights,{emissive:{value:new cs(0)}}]),vertexShader:Od.meshlambert_vert,fragmentShader:Od.meshlambert_frag},phong:{uniforms:ea([kd.common,kd.specularmap,kd.envmap,kd.aomap,kd.lightmap,kd.emissivemap,kd.bumpmap,kd.normalmap,kd.displacementmap,kd.fog,kd.lights,{emissive:{value:new cs(0)},specular:{value:new cs(1118481)},shininess:{value:30}}]),vertexShader:Od.meshphong_vert,fragmentShader:Od.meshphong_frag},standard:{uniforms:ea([kd.common,kd.envmap,kd.aomap,kd.lightmap,kd.emissivemap,kd.bumpmap,kd.normalmap,kd.displacementmap,kd.roughnessmap,kd.metalnessmap,kd.fog,kd.lights,{emissive:{value:new cs(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Od.meshphysical_vert,fragmentShader:Od.meshphysical_frag},toon:{uniforms:ea([kd.common,kd.aomap,kd.lightmap,kd.emissivemap,kd.bumpmap,kd.normalmap,kd.displacementmap,kd.gradientmap,kd.fog,kd.lights,{emissive:{value:new cs(0)}}]),vertexShader:Od.meshtoon_vert,fragmentShader:Od.meshtoon_frag},matcap:{uniforms:ea([kd.common,kd.bumpmap,kd.normalmap,kd.displacementmap,kd.fog,{matcap:{value:null}}]),vertexShader:Od.meshmatcap_vert,fragmentShader:Od.meshmatcap_frag},points:{uniforms:ea([kd.points,kd.fog]),vertexShader:Od.points_vert,fragmentShader:Od.points_frag},dashed:{uniforms:ea([kd.common,kd.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Od.linedashed_vert,fragmentShader:Od.linedashed_frag},depth:{uniforms:ea([kd.common,kd.displacementmap]),vertexShader:Od.depth_vert,fragmentShader:Od.depth_frag},normal:{uniforms:ea([kd.common,kd.bumpmap,kd.normalmap,kd.displacementmap,{opacity:{value:1}}]),vertexShader:Od.meshnormal_vert,fragmentShader:Od.meshnormal_frag},sprite:{uniforms:ea([kd.sprite,kd.fog]),vertexShader:Od.sprite_vert,fragmentShader:Od.sprite_frag},background:{uniforms:{uvTransform:{value:new ui},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Od.background_vert,fragmentShader:Od.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ui}},vertexShader:Od.backgroundCube_vert,fragmentShader:Od.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Od.cube_vert,fragmentShader:Od.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Od.equirect_vert,fragmentShader:Od.equirect_frag},distanceRGBA:{uniforms:ea([kd.common,kd.displacementmap,{referencePosition:{value:new zi},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Od.distanceRGBA_vert,fragmentShader:Od.distanceRGBA_frag},shadow:{uniforms:ea([kd.lights,kd.fog,{color:{value:new cs(0)},opacity:{value:1}}]),vertexShader:Od.shadow_vert,fragmentShader:Od.shadow_frag}};Qd.physical={uniforms:ea([Qd.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ui},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ui},clearcoatNormalScale:{value:new hi(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ui},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ui},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ui},sheen:{value:0},sheenColor:{value:new cs(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ui},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ui},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ui},transmissionSamplerSize:{value:new hi},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ui},attenuationDistance:{value:0},attenuationColor:{value:new cs(0)},specularColor:{value:new cs(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ui},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ui},anisotropyVector:{value:new hi},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ui}}]),vertexShader:Od.meshphysical_vert,fragmentShader:Od.meshphysical_frag};const zd={r:0,b:0,g:0},Gd=new br,Hd=new Ar;function Vd(t,e,n,i,r,s,a){const o=new cs(0);let l,c,h=!0===s?0:1,u=null,d=0,p=null;function f(t){let i=!0===t.isScene?t.background:null;return i&&i.isTexture&&(i=(t.backgroundBlurriness>0?n:e).get(i)),i}function m(e,n){e.getRGB(zd,na(t)),i.buffers.color.setClear(zd.r,zd.g,zd.b,n,a)}return{getClearColor:function(){return o},setClearColor:function(t,e=1){o.set(t),h=e,m(o,h)},getClearAlpha:function(){return h},setClearAlpha:function(t){h=t,m(o,h)},render:function(e){let n=!1;const r=f(e);null===r?m(o,h):r&&r.isColor&&(m(r,1),n=!0);const s=t.xr.getEnvironmentBlendMode();"additive"===s?i.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===s&&i.buffers.color.setClear(0,0,0,0,a),(t.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))},addToRenderList:function(e,n){const i=f(n);i&&(i.isCubeTexture||i.mapping===Mt)?(void 0===c&&(c=new Ks(new $s(1,1,1),new ra({name:"BackgroundCubeMaterial",uniforms:ta(Qd.backgroundCube.uniforms),vertexShader:Qd.backgroundCube.vertexShader,fragmentShader:Qd.backgroundCube.fragmentShader,side:M,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(t,e,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),Gd.copy(n.backgroundRotation),Gd.x*=-1,Gd.y*=-1,Gd.z*=-1,i.isCubeTexture&&!1===i.isRenderTargetTexture&&(Gd.y*=-1,Gd.z*=-1),c.material.uniforms.envMap.value=i,c.material.uniforms.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Hd.makeRotationFromEuler(Gd)),c.material.toneMapped=Ci.getTransfer(i.colorSpace)!==pn,u===i&&d===i.version&&p===t.toneMapping||(c.material.needsUpdate=!0,u=i,d=i.version,p=t.toneMapping),c.layers.enableAll(),e.unshift(c,c.geometry,c.material,0,0,null)):i&&i.isTexture&&(void 0===l&&(l=new Ks(new Mc(2,2),new ra({name:"BackgroundMaterial",uniforms:ta(Qd.background.uniforms),vertexShader:Qd.background.vertexShader,fragmentShader:Qd.background.fragmentShader,side:E,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=i,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.toneMapped=Ci.getTransfer(i.colorSpace)!==pn,!0===i.matrixAutoUpdate&&i.updateMatrix(),l.material.uniforms.uvTransform.value.copy(i.matrix),u===i&&d===i.version&&p===t.toneMapping||(l.material.needsUpdate=!0,u=i,d=i.version,p=t.toneMapping),l.layers.enableAll(),e.unshift(l,l.geometry,l.material,0,0,null))},dispose:function(){void 0!==c&&(c.geometry.dispose(),c.material.dispose(),c=void 0),void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}}}function Wd(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),i={},r=c(null);let s=r,a=!1;function o(e){return t.bindVertexArray(e)}function l(e){return t.deleteVertexArray(e)}function c(t){const e=[],i=[],r=[];for(let t=0;t=0){const n=r[e];let i=a[e];if(void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;o++}return s.attributesNum!==o||s.index!==i}(n,m,l,g),A&&function(t,e,n,i){const r={},a=e.attributes;let o=0;const l=n.getAttributes();for(const e in l)if(l[e].location>=0){let n=a[e];void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[e]=i,o++}s.attributes=r,s.attributesNum=o,s.index=i}(n,m,l,g),null!==g&&e.update(g,t.ELEMENT_ARRAY_BUFFER),(A||a)&&(a=!1,function(n,i,r,s){h();const a=s.attributes,o=r.getAttributes(),l=i.defaultAttributeValues;for(const i in o){const r=o[i];if(r.location>=0){let o=a[i];if(void 0===o&&("instanceMatrix"===i&&n.instanceMatrix&&(o=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(o=n.instanceColor)),void 0!==o){const i=o.normalized,a=o.itemSize,l=e.get(o);if(void 0===l)continue;const c=l.buffer,h=l.type,p=l.bytesPerElement,m=h===t.INT||h===t.UNSIGNED_INT||o.gpuType===Ht;if(o.isInterleavedBufferAttribute){const e=o.data,l=e.stride,g=o.offset;if(e.isInstancedInterleavedBuffer){for(let t=0;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"}let a=void 0!==n.precision?n.precision:"highp";const o=s(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const l=!0===n.logarithmicDepthBuffer,c=!0===n.reverseDepthBuffer&&e.has("EXT_clip_control"),h=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),u=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===e.has("EXT_texture_filter_anisotropic")){const n=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:s,textureFormatReadable:function(e){return e===$t||i.convert(e)===t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const r=n===jt&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(n!==kt&&i.convert(n)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==Wt&&!r)},precision:a,logarithmicDepthBuffer:l,reverseDepthBuffer:c,maxTextures:h,maxVertexTextures:u,maxTextureSize:t.getParameter(t.MAX_TEXTURE_SIZE),maxCubemapSize:t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:t.getParameter(t.MAX_VERTEX_ATTRIBS),maxVertexUniforms:t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:t.getParameter(t.MAX_VARYING_VECTORS),maxFragmentUniforms:t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),vertexTextures:u>0,maxSamples:t.getParameter(t.MAX_SAMPLES)}}function Xd(t){const e=this;let n=null,i=0,r=!1,s=!1;const a=new go,o=new ui,l={value:null,needsUpdate:!1};function c(t,n,i,r){const s=null!==t?t.length:0;let c=null;if(0!==s){if(c=l.value,!0!==r||null===c){const e=i+4*s,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length0),e.numPlanes=i,e.numIntersection=0);else{const t=s?0:i,e=4*t;let r=f.clippingState||null;l.value=r,r=c(u,o,e,h);for(let t=0;t!==e;++t)r[t]=n[t];f.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=t}}}function Yd(t){let e=new WeakMap;function n(t,e){return e===Ct?t.mapping=xt:e===Et&&(t.mapping=wt),t}function i(t){const n=t.target;n.removeEventListener("dispose",i);const r=e.get(n);void 0!==r&&(e.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping;if(s===Ct||s===Et){if(e.has(r))return n(e.get(r).texture,r.mapping);{const s=r.image;if(s&&s.height>0){const a=new pa(s.height);return a.fromEquirectangularTexture(t,r),e.set(r,a),r.addEventListener("dispose",i),n(a.texture,r.mapping)}return null}}}return r},dispose:function(){e=new WeakMap}}}const Jd=[.125,.215,.35,.446,.526,.582],Kd=new Qh,Zd=new cs;let $d=null,tp=0,ep=0,np=!1;const ip=(1+Math.sqrt(5))/2,rp=1/ip,sp=[new zi(-ip,rp,0),new zi(ip,rp,0),new zi(-rp,0,ip),new zi(rp,0,ip),new zi(0,ip,-rp),new zi(0,ip,rp),new zi(-1,1,-1),new zi(1,1,-1),new zi(-1,1,1),new zi(1,1,1)];class ap{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,i=100){$d=this._renderer.getRenderTarget(),tp=this._renderer.getActiveCubeFace(),ep=this._renderer.getActiveMipmapLevel(),np=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,n,i,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=hp(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=cp(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;tt-4?o=Jd[a-t+4-1]:0===a&&(o=0),i.push(o);const l=1/(s-2),c=-l,h=1+l,u=[c,c,h,c,h,h,c,c,h,h,c,h],d=6,p=6,f=3,m=2,g=1,A=new Float32Array(f*p*d),v=new Float32Array(m*p*d),y=new Float32Array(g*p*d);for(let t=0;t2?0:-1,i=[e,n,0,e+2/3,n,0,e+2/3,n+1,0,e,n,0,e+2/3,n+1,0,e,n+1,0];A.set(i,f*p*t),v.set(u,m*p*t);const r=[t,t,t,t,t,t];y.set(r,g*p*t)}const _=new ks;_.setAttribute("position",new ws(A,f)),_.setAttribute("uv",new ws(v,m)),_.setAttribute("faceIndex",new ws(y,g)),e.push(_),r>4&&r--}return{lodPlanes:e,sizeLods:n,sigmas:i}}(i)),this._blurMaterial=function(t,e,n){const i=new Float32Array(20),r=new zi(0,1,0);return new ra({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:b,depthTest:!1,depthWrite:!1})}(i,t,e)}return i}_compileMaterial(t){const e=new Ks(this._lodPlanes[0],t);this._renderer.compile(e,Kd)}_sceneToCubeUV(t,e,n,i){const r=new ca(90,1,e,n),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,c=o.toneMapping;o.getClearColor(Zd),o.toneMapping=ht,o.autoClear=!1;const h=new ps({name:"PMREM.Background",side:M,depthWrite:!1,depthTest:!1}),u=new Ks(new $s,h);let d=!1;const p=t.background;p?p.isColor&&(h.color.copy(p),t.background=null,d=!0):(h.color.copy(Zd),d=!0);for(let e=0;e<6;e++){const n=e%3;0===n?(r.up.set(0,s[e],0),r.lookAt(a[e],0,0)):1===n?(r.up.set(0,0,s[e]),r.lookAt(0,a[e],0)):(r.up.set(0,s[e],0),r.lookAt(0,0,a[e]));const l=this._cubeSize;lp(i,n*l,e>2?l:0,l,l),o.setRenderTarget(i),d&&o.render(u,r),o.render(t,r)}u.geometry.dispose(),u.material.dispose(),o.toneMapping=c,o.autoClear=l,t.background=p}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===xt||t.mapping===wt;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=hp()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=cp());const r=i?this._cubemapMaterial:this._equirectMaterial,s=new Ks(this._lodPlanes[0],r);r.uniforms.envMap.value=t;const a=this._cubeSize;lp(e,0,0,3*a,2*a),n.setRenderTarget(e),n.render(s,Kd)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodPlanes.length;for(let e=1;e20&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let t=0;t<20;++t){const e=t/p,n=Math.exp(-e*e/2);m.push(n),0===t?g+=n:tA-4?i-A+4:0),4*(this._cubeSize-v),3*v,2*v),o.setRenderTarget(e),o.render(c,Kd)}}function op(t,e,n){const i=new Ui(t,e,n);return i.texture.mapping=Mt,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function lp(t,e,n,i,r){t.viewport.set(e,n,i,r),t.scissor.set(e,n,i,r)}function cp(){return new ra({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:b,depthTest:!1,depthWrite:!1})}function hp(){return new ra({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:b,depthTest:!1,depthWrite:!1})}function up(t){let e=new WeakMap,n=null;function i(t){const n=t.target;n.removeEventListener("dispose",i);const r=e.get(n);void 0!==r&&(e.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping,a=s===Ct||s===Et,o=s===xt||s===wt;if(a||o){let s=e.get(r);const l=void 0!==s?s.texture.pmremVersion:0;if(r.isRenderTargetTexture&&r.pmremVersion!==l)return null===n&&(n=new ap(t)),s=a?n.fromEquirectangular(r,s):n.fromCubemap(r,s),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),s.texture;if(void 0!==s)return s.texture;{const l=r.image;return a&&l&&l.height>0||o&&l&&function(t){let e=0;for(let n=0;n<6;n++)void 0!==t[n]&&e++;return 6===e}(l)?(null===n&&(n=new ap(t)),s=a?n.fromEquirectangular(r):n.fromCubemap(r),s.texture.pmremVersion=r.pmremVersion,e.set(r,s),r.addEventListener("dispose",i),s.texture):null}}}return r},dispose:function(){e=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function dp(t){const e={};function n(n){if(void 0!==e[n])return e[n];let i;switch(n){case"WEBGL_depth_texture":i=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=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":i=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":i=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=t.getExtension(n)}return e[n]=i,i}return{has:function(t){return null!==n(t)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(t){const e=n(t);return null===e&&yi("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function pp(t,e,n,i){const r={},s=new WeakMap;function a(t){const o=t.target;null!==o.index&&e.remove(o.index);for(const t in o.attributes)e.remove(o.attributes[t]);o.removeEventListener("dispose",a),delete r[o.id];const l=s.get(o);l&&(e.remove(l),s.delete(o)),i.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,n.memory.geometries--}function o(t){const n=[],i=t.index,r=t.attributes.position;let a=0;if(null!==i){const t=i.array;a=i.version;for(let e=0,i=t.length;ee.maxTextureSize&&(_=Math.ceil(y/e.maxTextureSize),y=e.maxTextureSize);const x=new Float32Array(y*_*4*h),w=new Ni(x,y,_,h);w.type=Wt,w.needsUpdate=!0;const C=4*v;for(let M=0;M0)return t;const r=e*n;let s=Cp[r];if(void 0===s&&(s=new Float32Array(r),Cp[r]=s),0!==e){i.toArray(s,0);for(let i=1,r=0;i!==e;++i)r+=n,t[i].toArray(s,r)}return s}function Tp(t,e){if(t.length!==e.length)return!1;for(let n=0,i=t.length;n":" "} ${r}: ${n[t]}`)}return i.join("\n")}(t.getShaderSource(e),i)}return r}function If(t,e){const n=function(t){Ci._getMatrix(Sf,Ci.workingColorSpace,t);const e=`mat3( ${Sf.elements.map((t=>t.toFixed(4)))} )`;switch(Ci.getTransfer(t)){case dn:return[e,"LinearTransferOETF"];case pn:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}(e);return[`vec4 ${t}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}function Tf(t,e){let n;switch(e){case ut:n="Linear";break;case dt:n="Reinhard";break;case pt:n="Cineon";break;case ft:n="ACESFilmic";break;case gt:n="AgX";break;case At:n="Neutral";break;case mt:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const Bf=new zi;function Rf(t){return""!==t}function Df(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Pf(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Lf=/^[ \t]*#include +<([\w\d./]+)>/gm;function Uf(t){return t.replace(Lf,Ff)}const Nf=new Map;function Ff(t,e){let n=Od[e];if(void 0===n){const t=Nf.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");n=Od[t],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,t)}return Uf(n)}const Of=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function kf(t){return t.replace(Of,Qf)}function Qf(t,e,n,i){let r="";for(let t=parseInt(e);t0&&(g+="\n"),A=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f].filter(Rf).join("\n"),A.length>0&&(A+="\n")):(g=[zf(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#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.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Rf).join("\n"),A=[zf(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+h:"",n.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==ht?"#define TONE_MAPPING":"",n.toneMapping!==ht?Od.tonemapping_pars_fragment:"",n.toneMapping!==ht?Tf("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Od.colorspace_pars_fragment,If("linearToOutputTexel",n.outputColorSpace),(Ci.getLuminanceCoefficients(Bf),["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${Bf.x.toFixed(4)}, ${Bf.y.toFixed(4)}, ${Bf.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Rf).join("\n")),a=Uf(a),a=Df(a,n),a=Pf(a,n),o=Uf(o),o=Df(o,n),o=Pf(o,n),a=kf(a),o=kf(o),!0!==n.isRawShaderMaterial&&(v="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,A=["#define varying in",n.glslVersion===Xn?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Xn?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+A);const y=v+g+a,_=v+A+o,E=Ef(r,r.VERTEX_SHADER,y),M=Ef(r,r.FRAGMENT_SHADER,_);function S(e){if(t.debug.checkShaderErrors){const n=r.getProgramInfoLog(m).trim(),i=r.getShaderInfoLog(E).trim(),s=r.getShaderInfoLog(M).trim();let a=!0,o=!0;if(!1===r.getProgramParameter(m,r.LINK_STATUS))if(a=!1,"function"==typeof t.debug.onShaderError)t.debug.onShaderError(r,m,E,M);else{const t=bf(r,E,"vertex"),i=bf(r,M,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(m,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+e.name+"\nMaterial Type: "+e.type+"\n\nProgram Info Log: "+n+"\n"+t+"\n"+i)}else""!==n?console.warn("THREE.WebGLProgram: Program Info Log:",n):""!==i&&""!==s||(o=!1);o&&(e.diagnostics={runnable:a,programLog:n,vertexShader:{log:i,prefix:g},fragmentShader:{log:s,prefix:A}})}r.deleteShader(E),r.deleteShader(M),b=new Cf(r,m),I=function(t,e){const n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r0,J=s.clearcoat>0,K=s.dispersion>0,Z=s.iridescence>0,$=s.sheen>0,tt=s.transmission>0,et=Y&&!!s.anisotropyMap,nt=J&&!!s.clearcoatMap,it=J&&!!s.clearcoatNormalMap,rt=J&&!!s.clearcoatRoughnessMap,st=Z&&!!s.iridescenceMap,at=Z&&!!s.iridescenceThicknessMap,ot=$&&!!s.sheenColorMap,lt=$&&!!s.sheenRoughnessMap,ct=!!s.specularMap,ut=!!s.specularColorMap,dt=!!s.specularIntensityMap,pt=tt&&!!s.transmissionMap,ft=tt&&!!s.thicknessMap,mt=!!s.gradientMap,gt=!!s.alphaMap,At=s.alphaTest>0,vt=!!s.alphaHash,yt=!!s.extensions;let _t=ht;s.toneMapped&&(null!==L&&!0!==L.isXRRenderTarget||(_t=t.toneMapping));const xt={shaderID:C,shaderType:s.type,shaderName:s.name,vertexShader:T,fragmentShader:B,defines:s.defines,customVertexShaderID:R,customFragmentShaderID:D,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:p,batching:F,batchingColor:F&&null!==A._colorsTexture,instancing:N,instancingColor:N&&null!==A.instanceColor,instancingMorph:N&&null!==A.morphTexture,supportsVertexTextures:d,outputColorSpace:null===L?t.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:un,alphaToCoverage:!!s.alphaToCoverage,map:O,matcap:k,envMap:Q,envMapMode:Q&&x.mapping,envMapCubeUVHeight:w,aoMap:z,lightMap:G,bumpMap:H,normalMap:V,displacementMap:d&&W,emissiveMap:j,normalMapObjectSpace:V&&s.normalMapType===ln,normalMapTangentSpace:V&&s.normalMapType===on,metalnessMap:q,roughnessMap:X,anisotropy:Y,anisotropyMap:et,clearcoat:J,clearcoatMap:nt,clearcoatNormalMap:it,clearcoatRoughnessMap:rt,dispersion:K,iridescence:Z,iridescenceMap:st,iridescenceThicknessMap:at,sheen:$,sheenColorMap:ot,sheenRoughnessMap:lt,specularMap:ct,specularColorMap:ut,specularIntensityMap:dt,transmission:tt,transmissionMap:pt,thicknessMap:ft,gradientMap:mt,opaque:!1===s.transparent&&s.blending===I&&!1===s.alphaToCoverage,alphaMap:gt,alphaTest:At,alphaHash:vt,combine:s.combine,mapUv:O&&m(s.map.channel),aoMapUv:z&&m(s.aoMap.channel),lightMapUv:G&&m(s.lightMap.channel),bumpMapUv:H&&m(s.bumpMap.channel),normalMapUv:V&&m(s.normalMap.channel),displacementMapUv:W&&m(s.displacementMap.channel),emissiveMapUv:j&&m(s.emissiveMap.channel),metalnessMapUv:q&&m(s.metalnessMap.channel),roughnessMapUv:X&&m(s.roughnessMap.channel),anisotropyMapUv:et&&m(s.anisotropyMap.channel),clearcoatMapUv:nt&&m(s.clearcoatMap.channel),clearcoatNormalMapUv:it&&m(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:rt&&m(s.clearcoatRoughnessMap.channel),iridescenceMapUv:st&&m(s.iridescenceMap.channel),iridescenceThicknessMapUv:at&&m(s.iridescenceThicknessMap.channel),sheenColorMapUv:ot&&m(s.sheenColorMap.channel),sheenRoughnessMapUv:lt&&m(s.sheenRoughnessMap.channel),specularMapUv:ct&&m(s.specularMap.channel),specularColorMapUv:ut&&m(s.specularColorMap.channel),specularIntensityMapUv:dt&&m(s.specularIntensityMap.channel),transmissionMapUv:pt&&m(s.transmissionMap.channel),thicknessMapUv:ft&&m(s.thicknessMap.channel),alphaMapUv:gt&&m(s.alphaMap.channel),vertexTangents:!!y.attributes.tangent&&(V||Y),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!y.attributes.color&&4===y.attributes.color.itemSize,pointsUvs:!0===A.isPoints&&!!y.attributes.uv&&(O||gt),fog:!!v,useFog:!0===s.fog,fogExp2:!!v&&v.isFogExp2,flatShading:!0===s.flatShading,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:u,reverseDepthBuffer:U,skinning:!0===A.isSkinnedMesh,morphTargets:void 0!==y.morphAttributes.position,morphNormals:void 0!==y.morphAttributes.normal,morphColors:void 0!==y.morphAttributes.color,morphTargetsCount:b,morphTextureStride:P,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:s.dithering,shadowMapEnabled:t.shadowMap.enabled&&h.length>0,shadowMapType:t.shadowMap.type,toneMapping:_t,decodeVideoTexture:O&&!0===s.map.isVideoTexture&&Ci.getTransfer(s.map.colorSpace)===pn,decodeVideoTextureEmissive:j&&!0===s.emissiveMap.isVideoTexture&&Ci.getTransfer(s.emissiveMap.colorSpace)===pn,premultipliedAlpha:s.premultipliedAlpha,doubleSided:s.side===S,flipSided:s.side===M,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionClipCullDistance:yt&&!0===s.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(yt&&!0===s.extensions.multiDraw||F)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:s.customProgramCacheKey()};return xt.vertexUv1s=c.has(1),xt.vertexUv2s=c.has(2),xt.vertexUv3s=c.has(3),c.clear(),xt},getProgramCacheKey:function(e){const n=[];if(e.shaderID?n.push(e.shaderID):(n.push(e.customVertexShaderID),n.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)n.push(t),n.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.numLightProbes),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(n,e),function(t,e){o.disableAll(),e.supportsVertexTextures&&o.enable(0),e.instancing&&o.enable(1),e.instancingColor&&o.enable(2),e.instancingMorph&&o.enable(3),e.matcap&&o.enable(4),e.envMap&&o.enable(5),e.normalMapObjectSpace&&o.enable(6),e.normalMapTangentSpace&&o.enable(7),e.clearcoat&&o.enable(8),e.iridescence&&o.enable(9),e.alphaTest&&o.enable(10),e.vertexColors&&o.enable(11),e.vertexAlphas&&o.enable(12),e.vertexUv1s&&o.enable(13),e.vertexUv2s&&o.enable(14),e.vertexUv3s&&o.enable(15),e.vertexTangents&&o.enable(16),e.anisotropy&&o.enable(17),e.alphaHash&&o.enable(18),e.batching&&o.enable(19),e.dispersion&&o.enable(20),e.batchingColor&&o.enable(21),t.push(o.mask),o.disableAll(),e.fog&&o.enable(0),e.useFog&&o.enable(1),e.flatShading&&o.enable(2),e.logarithmicDepthBuffer&&o.enable(3),e.reverseDepthBuffer&&o.enable(4),e.skinning&&o.enable(5),e.morphTargets&&o.enable(6),e.morphNormals&&o.enable(7),e.morphColors&&o.enable(8),e.premultipliedAlpha&&o.enable(9),e.shadowMapEnabled&&o.enable(10),e.doubleSided&&o.enable(11),e.flipSided&&o.enable(12),e.useDepthPacking&&o.enable(13),e.dithering&&o.enable(14),e.transmission&&o.enable(15),e.sheen&&o.enable(16),e.opaque&&o.enable(17),e.pointsUvs&&o.enable(18),e.decodeVideoTexture&&o.enable(19),e.decodeVideoTextureEmissive&&o.enable(20),e.alphaToCoverage&&o.enable(21),t.push(o.mask)}(n,e),n.push(t.outputColorSpace)),n.push(e.customProgramCacheKey),n.join()},getUniforms:function(t){const e=f[t.type];let n;if(e){const t=Qd[e];n=ia.clone(t.uniforms)}else n=t.uniforms;return n},acquireProgram:function(e,n){let i;for(let t=0,e=h.length;t0?i.push(h):!0===a.transparent?r.push(h):n.push(h)},unshift:function(t,e,a,o,l,c){const h=s(t,e,a,o,l,c);a.transmission>0?i.unshift(h):!0===a.transparent?r.unshift(h):n.unshift(h)},finish:function(){for(let n=e,i=t.length;n1&&n.sort(t||Xf),i.length>1&&i.sort(e||Yf),r.length>1&&r.sort(e||Yf)}}}function Kf(){let t=new WeakMap;return{get:function(e,n){const i=t.get(e);let r;return void 0===i?(r=new Jf,t.set(e,[r])):n>=i.length?(r=new Jf,i.push(r)):r=i[n],r},dispose:function(){t=new WeakMap}}}function Zf(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new zi,color:new cs};break;case"SpotLight":n={position:new zi,direction:new zi,color:new cs,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new zi,color:new cs,distance:0,decay:0};break;case"HemisphereLight":n={direction:new zi,skyColor:new cs,groundColor:new cs};break;case"RectAreaLight":n={color:new cs,position:new zi,halfWidth:new zi,halfHeight:new zi}}return t[e.id]=n,n}}}let $f=0;function tm(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function em(t){const e=new Zf,n=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new hi};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new hi,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=n,n}}}(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let t=0;t<9;t++)i.probe.push(new zi);const r=new zi,s=new Ar,a=new Ar;return{setup:function(r){let s=0,a=0,o=0;for(let t=0;t<9;t++)i.probe[t].set(0,0,0);let l=0,c=0,h=0,u=0,d=0,p=0,f=0,m=0,g=0,A=0,v=0;r.sort(tm);for(let t=0,y=r.length;t0&&(!0===t.has("OES_texture_float_linear")?(i.rectAreaLTC1=kd.LTC_FLOAT_1,i.rectAreaLTC2=kd.LTC_FLOAT_2):(i.rectAreaLTC1=kd.LTC_HALF_1,i.rectAreaLTC2=kd.LTC_HALF_2)),i.ambient[0]=s,i.ambient[1]=a,i.ambient[2]=o;const y=i.hash;y.directionalLength===l&&y.pointLength===c&&y.spotLength===h&&y.rectAreaLength===u&&y.hemiLength===d&&y.numDirectionalShadows===p&&y.numPointShadows===f&&y.numSpotShadows===m&&y.numSpotMaps===g&&y.numLightProbes===v||(i.directional.length=l,i.spot.length=h,i.rectArea.length=u,i.point.length=c,i.hemi.length=d,i.directionalShadow.length=p,i.directionalShadowMap.length=p,i.pointShadow.length=f,i.pointShadowMap.length=f,i.spotShadow.length=m,i.spotShadowMap.length=m,i.directionalShadowMatrix.length=p,i.pointShadowMatrix.length=f,i.spotLightMatrix.length=m+g-A,i.spotLightMap.length=g,i.numSpotLightShadowsWithMaps=A,i.numLightProbes=v,y.directionalLength=l,y.pointLength=c,y.spotLength=h,y.rectAreaLength=u,y.hemiLength=d,y.numDirectionalShadows=p,y.numPointShadows=f,y.numSpotShadows=m,y.numSpotMaps=g,y.numLightProbes=v,i.version=$f++)},setupView:function(t,e){let n=0,o=0,l=0,c=0,h=0;const u=e.matrixWorldInverse;for(let e=0,d=t.length;e=r.length?(s=new nm(t),r.push(s)):s=r[i],s},dispose:function(){e=new WeakMap}}}function rm(t,e,n){let i=new yo;const r=new hi,s=new hi,a=new Pi,o=new Vc({depthPacking:rn}),l=new Wc,c={},h=n.maxTextureSize,u={[E]:M,[M]:E,[S]:S},d=new ra({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new hi},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const f=new ks;f.setAttribute("position",new ws(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new Ks(f,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=x;let A=this.type;function v(n,i){const s=e.update(m);d.defines.VSM_SAMPLES!==n.blurSamples&&(d.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Ui(r.x,r.y)),d.uniforms.shadow_pass.value=n.map.texture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,t.setRenderTarget(n.mapPass),t.clear(),t.renderBufferDirect(i,null,s,d,m,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,t.setRenderTarget(n.map),t.clear(),t.renderBufferDirect(i,null,s,p,m,null)}function y(e,n,i,r){let s=null;const a=!0===i.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===i.isPointLight?l:o,t.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const t=s.uuid,e=n.uuid;let i=c[t];void 0===i&&(i={},c[t]=i);let r=i[e];void 0===r&&(r=s.clone(),i[e]=r,n.addEventListener("dispose",w)),s=r}return s.visible=n.visible,s.wireframe=n.wireframe,s.side=r===C?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],s.alphaMap=n.alphaMap,s.alphaTest=n.alphaTest,s.map=n.map,s.clipShadows=n.clipShadows,s.clippingPlanes=n.clippingPlanes,s.clipIntersection=n.clipIntersection,s.displacementMap=n.displacementMap,s.displacementScale=n.displacementScale,s.displacementBias=n.displacementBias,s.wireframeLinewidth=n.wireframeLinewidth,s.linewidth=n.linewidth,!0===i.isPointLight&&!0===s.isMeshDistanceMaterial&&(t.properties.get(s).light=i),s}function _(n,r,s,a,o){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&o===C)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);const i=e.update(n),l=n.material;if(Array.isArray(l)){const e=i.groups;for(let c=0,h=e.length;ch||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/m.x),r.x=s.x*m.x,u.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/m.y),r.y=s.y*m.y,u.mapSize.y=s.y)),null===u.map||!0===p||!0===f){const t=this.type!==C?{minFilter:Tt,magFilter:Tt}:{};null!==u.map&&u.map.dispose(),u.map=new Ui(r.x,r.y,t),u.map.texture.name=c.name+".shadowMap",u.camera.updateProjectionMatrix()}t.setRenderTarget(u.map),t.clear();const g=u.getViewportCount();for(let t=0;t=1):-1!==gt.indexOf("OpenGL ES")&&(mt=parseFloat(/^OpenGL ES (\d)/.exec(gt)[1]),ft=mt>=2);let At=null,vt={};const yt=t.getParameter(t.SCISSOR_BOX),_t=t.getParameter(t.VIEWPORT),xt=(new Pi).fromArray(yt),wt=(new Pi).fromArray(_t);function Ct(e,n,i,r){const s=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let a=0;an||r.height>n)&&(i=n/Math.max(r.width,r.height)),i<1){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&t instanceof VideoFrame){const n=Math.floor(i*r.width),s=Math.floor(i*r.height);void 0===u&&(u=f(n,s));const a=e?f(n,s):u;return a.width=n,a.height=s,a.getContext("2d").drawImage(t,0,0,n,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+n+"x"+s+")."),a}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),t}return t}function g(t){return t.generateMipmaps}function A(e){t.generateMipmap(e)}function v(e){return e.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:e.isWebGL3DRenderTarget?t.TEXTURE_3D:e.isWebGLArrayRenderTarget||e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function y(n,i,r,s,a=!1){if(null!==n){if(void 0!==t[n])return t[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=i;if(i===t.RED&&(r===t.FLOAT&&(o=t.R32F),r===t.HALF_FLOAT&&(o=t.R16F),r===t.UNSIGNED_BYTE&&(o=t.R8)),i===t.RED_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.R8UI),r===t.UNSIGNED_SHORT&&(o=t.R16UI),r===t.UNSIGNED_INT&&(o=t.R32UI),r===t.BYTE&&(o=t.R8I),r===t.SHORT&&(o=t.R16I),r===t.INT&&(o=t.R32I)),i===t.RG&&(r===t.FLOAT&&(o=t.RG32F),r===t.HALF_FLOAT&&(o=t.RG16F),r===t.UNSIGNED_BYTE&&(o=t.RG8)),i===t.RG_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RG8UI),r===t.UNSIGNED_SHORT&&(o=t.RG16UI),r===t.UNSIGNED_INT&&(o=t.RG32UI),r===t.BYTE&&(o=t.RG8I),r===t.SHORT&&(o=t.RG16I),r===t.INT&&(o=t.RG32I)),i===t.RGB_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGB8UI),r===t.UNSIGNED_SHORT&&(o=t.RGB16UI),r===t.UNSIGNED_INT&&(o=t.RGB32UI),r===t.BYTE&&(o=t.RGB8I),r===t.SHORT&&(o=t.RGB16I),r===t.INT&&(o=t.RGB32I)),i===t.RGBA_INTEGER&&(r===t.UNSIGNED_BYTE&&(o=t.RGBA8UI),r===t.UNSIGNED_SHORT&&(o=t.RGBA16UI),r===t.UNSIGNED_INT&&(o=t.RGBA32UI),r===t.BYTE&&(o=t.RGBA8I),r===t.SHORT&&(o=t.RGBA16I),r===t.INT&&(o=t.RGBA32I)),i===t.RGB&&r===t.UNSIGNED_INT_5_9_9_9_REV&&(o=t.RGB9_E5),i===t.RGBA){const e=a?dn:Ci.getTransfer(s);r===t.FLOAT&&(o=t.RGBA32F),r===t.HALF_FLOAT&&(o=t.RGBA16F),r===t.UNSIGNED_BYTE&&(o=e===pn?t.SRGB8_ALPHA8:t.RGBA8),r===t.UNSIGNED_SHORT_4_4_4_4&&(o=t.RGBA4),r===t.UNSIGNED_SHORT_5_5_5_1&&(o=t.RGB5_A1)}return o!==t.R16F&&o!==t.R32F&&o!==t.RG16F&&o!==t.RG32F&&o!==t.RGBA16F&&o!==t.RGBA32F||e.get("EXT_color_buffer_float"),o}function _(e,n){let i;return e?null===n||n===Vt||n===Yt?i=t.DEPTH24_STENCIL8:n===Wt?i=t.DEPTH32F_STENCIL8:n===Gt&&(i=t.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===Vt||n===Yt?i=t.DEPTH_COMPONENT24:n===Wt?i=t.DEPTH_COMPONENT32F:n===Gt&&(i=t.DEPTH_COMPONENT16),i}function x(t,e){return!0===g(t)||t.isFramebufferTexture&&t.minFilter!==Tt&&t.minFilter!==Lt?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function w(t){const e=t.target;e.removeEventListener("dispose",w),function(t){const e=i.get(t);if(void 0===e.__webglInit)return;const n=t.source,r=d.get(n);if(r){const i=r[e.__cacheKey];i.usedTimes--,0===i.usedTimes&&E(t),0===Object.keys(r).length&&d.delete(n)}i.remove(t)}(e),e.isVideoTexture&&h.delete(e)}function C(e){const n=e.target;n.removeEventListener("dispose",C),function(e){const n=i.get(e);if(e.depthTexture&&(e.depthTexture.dispose(),i.remove(e.depthTexture)),e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++){if(Array.isArray(n.__webglFramebuffer[e]))for(let i=0;i0&&s.__version!==e.version){const t=e.image;if(null===t)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==t.complete)return void D(s,e,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(t.TEXTURE_2D,s.__webglTexture,t.TEXTURE0+r)}const b={[St]:t.REPEAT,[bt]:t.CLAMP_TO_EDGE,[It]:t.MIRRORED_REPEAT},I={[Tt]:t.NEAREST,[Bt]:t.NEAREST_MIPMAP_NEAREST,[Dt]:t.NEAREST_MIPMAP_LINEAR,[Lt]:t.LINEAR,[Ut]:t.LINEAR_MIPMAP_NEAREST,[Ft]:t.LINEAR_MIPMAP_LINEAR},T={[Bn]:t.NEVER,[Fn]:t.ALWAYS,[Rn]:t.LESS,[Pn]:t.LEQUAL,[Dn]:t.EQUAL,[Nn]:t.GEQUAL,[Ln]:t.GREATER,[Un]:t.NOTEQUAL};function B(n,s){if(s.type!==Wt||!1!==e.has("OES_texture_float_linear")||s.magFilter!==Lt&&s.magFilter!==Ut&&s.magFilter!==Dt&&s.magFilter!==Ft&&s.minFilter!==Lt&&s.minFilter!==Ut&&s.minFilter!==Dt&&s.minFilter!==Ft||console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(n,t.TEXTURE_WRAP_S,b[s.wrapS]),t.texParameteri(n,t.TEXTURE_WRAP_T,b[s.wrapT]),n!==t.TEXTURE_3D&&n!==t.TEXTURE_2D_ARRAY||t.texParameteri(n,t.TEXTURE_WRAP_R,b[s.wrapR]),t.texParameteri(n,t.TEXTURE_MAG_FILTER,I[s.magFilter]),t.texParameteri(n,t.TEXTURE_MIN_FILTER,I[s.minFilter]),s.compareFunction&&(t.texParameteri(n,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(n,t.TEXTURE_COMPARE_FUNC,T[s.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){if(s.magFilter===Tt)return;if(s.minFilter!==Dt&&s.minFilter!==Ft)return;if(s.type===Wt&&!1===e.has("OES_texture_float_linear"))return;if(s.anisotropy>1||i.get(s).__currentAnisotropy){const a=e.get("EXT_texture_filter_anisotropic");t.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),i.get(s).__currentAnisotropy=s.anisotropy}}}function R(e,n){let i=!1;void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",w));const r=n.source;let s=d.get(r);void 0===s&&(s={},d.set(r,s));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(n);if(o!==e.__cacheKey){void 0===s[o]&&(s[o]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,i=!0),s[o].usedTimes++;const r=s[e.__cacheKey];void 0!==r&&(s[e.__cacheKey].usedTimes--,0===r.usedTimes&&E(n)),e.__cacheKey=o,e.__webglTexture=s[o].texture}return i}function D(e,a,o){let l=t.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(l=t.TEXTURE_2D_ARRAY),a.isData3DTexture&&(l=t.TEXTURE_3D);const c=R(e,a),h=a.source;n.bindTexture(l,e.__webglTexture,t.TEXTURE0+o);const u=i.get(h);if(h.version!==u.__version||!0===c){n.activeTexture(t.TEXTURE0+o);const e=Ci.getPrimaries(Ci.workingColorSpace),i=a.colorSpace===cn?null:Ci.getPrimaries(a.colorSpace),d=a.colorSpace===cn||e===i?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);let p=m(a.image,!1,r.maxTextureSize);p=Q(a,p);const f=s.convert(a.format,a.colorSpace),v=s.convert(a.type);let w,C=y(a.internalFormat,f,v,a.colorSpace,a.isVideoTexture);B(l,a);const E=a.mipmaps,M=!0!==a.isVideoTexture,S=void 0===u.__version||!0===c,b=h.dataReady,I=x(a,p);if(a.isDepthTexture)C=_(a.format===ie,a.type),S&&(M?n.texStorage2D(t.TEXTURE_2D,1,C,p.width,p.height):n.texImage2D(t.TEXTURE_2D,0,C,p.width,p.height,0,f,v,null));else if(a.isDataTexture)if(E.length>0){M&&S&&n.texStorage2D(t.TEXTURE_2D,I,C,E[0].width,E[0].height);for(let e=0,i=E.length;e0){const i=Ld(w.width,w.height,a.format,a.type);for(const r of a.layerUpdates){const s=w.data.subarray(r*i/w.data.BYTES_PER_ELEMENT,(r+1)*i/w.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,r,w.width,w.height,1,f,s)}a.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,w.width,w.height,p.depth,f,w.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,e,C,w.width,w.height,p.depth,0,w.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else M?b&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,e,0,0,0,w.width,w.height,p.depth,f,v,w.data):n.texImage3D(t.TEXTURE_2D_ARRAY,e,C,w.width,w.height,p.depth,0,f,v,w.data)}else{M&&S&&n.texStorage2D(t.TEXTURE_2D,I,C,E[0].width,E[0].height);for(let e=0,i=E.length;e0){const e=Ld(p.width,p.height,a.format,a.type);for(const i of a.layerUpdates){const r=p.data.subarray(i*e/p.data.BYTES_PER_ELEMENT,(i+1)*e/p.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,i,p.width,p.height,1,f,v,r)}a.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,f,v,p.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,C,p.width,p.height,p.depth,0,f,v,p.data);else if(a.isData3DTexture)M?(S&&n.texStorage3D(t.TEXTURE_3D,I,C,p.width,p.height,p.depth),b&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,f,v,p.data)):n.texImage3D(t.TEXTURE_3D,0,C,p.width,p.height,p.depth,0,f,v,p.data);else if(a.isFramebufferTexture){if(S)if(M)n.texStorage2D(t.TEXTURE_2D,I,C,p.width,p.height);else{let e=p.width,i=p.height;for(let r=0;r>=1,i>>=1}}else if(E.length>0){if(M&&S){const e=z(E[0]);n.texStorage2D(t.TEXTURE_2D,I,C,e.width,e.height)}for(let e=0,i=E.length;e>h),i=Math.max(1,r.height>>h);c===t.TEXTURE_3D||c===t.TEXTURE_2D_ARRAY?n.texImage3D(c,h,p,e,i,r.depth,0,u,d,null):n.texImage2D(c,h,p,e,i,0,u,d,null)}n.bindFramebuffer(t.FRAMEBUFFER,e),k(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,l,c,m.__webglTexture,0,O(r)):(c===t.TEXTURE_2D||c>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,l,c,m.__webglTexture,h),n.bindFramebuffer(t.FRAMEBUFFER,null)}function L(e,n,i){if(t.bindRenderbuffer(t.RENDERBUFFER,e),n.depthBuffer){const r=n.depthTexture,s=r&&r.isDepthTexture?r.type:null,a=_(n.stencilBuffer,s),l=n.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,c=O(n);k(n)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,c,a,n.width,n.height):i?t.renderbufferStorageMultisample(t.RENDERBUFFER,c,a,n.width,n.height):t.renderbufferStorage(t.RENDERBUFFER,a,n.width,n.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,l,t.RENDERBUFFER,e)}else{const e=n.textures;for(let r=0;r{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,t.removeEventListener("dispose",e)};t.addEventListener("dispose",e),r.__depthDisposeCallback=e}r.__boundDepthTexture=t}if(e.depthTexture&&!r.__autoAllocateDepthBuffer){if(s)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const s=i.get(r.depthTexture);s.__renderTarget=r,s.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),S(r.depthTexture,0);const a=s.__webglTexture,l=O(r);if(r.depthTexture.format===ne)k(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0,l):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,a,0);else{if(r.depthTexture.format!==ie)throw new Error("Unknown depthTexture format");k(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0,l):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,a,0)}}(r.__webglFramebuffer,e)}else if(s){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[i]),void 0===r.__webglDepthbuffer[i])r.__webglDepthbuffer[i]=t.createRenderbuffer(),L(r.__webglDepthbuffer[i],e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,s=r.__webglDepthbuffer[i];t.bindRenderbuffer(t.RENDERBUFFER,s),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,s)}}else if(n.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=t.createRenderbuffer(),L(r.__webglDepthbuffer,e,!1);else{const n=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,i=r.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,i),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,i)}n.bindFramebuffer(t.FRAMEBUFFER,null)}const N=[],F=[];function O(t){return Math.min(r.maxSamples,t.samples)}function k(t){const n=i.get(t);return t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function Q(t,e){const n=t.colorSpace,i=t.format,r=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||n!==un&&n!==cn&&(Ci.getTransfer(n)===pn?i===$t&&r===kt||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",n)),e}function z(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement?(c.width=t.naturalWidth||t.width,c.height=t.naturalHeight||t.height):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?(c.width=t.displayWidth,c.height=t.displayHeight):(c.width=t.width,c.height=t.height),c}this.allocateTextureUnit=function(){const t=M;return t>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+r.maxTextures),M+=1,t},this.resetTextureUnits=function(){M=0},this.setTexture2D=S,this.setTexture2DArray=function(e,r){const s=i.get(e);e.version>0&&s.__version!==e.version?D(s,e,r):n.bindTexture(t.TEXTURE_2D_ARRAY,s.__webglTexture,t.TEXTURE0+r)},this.setTexture3D=function(e,r){const s=i.get(e);e.version>0&&s.__version!==e.version?D(s,e,r):n.bindTexture(t.TEXTURE_3D,s.__webglTexture,t.TEXTURE0+r)},this.setTextureCube=function(e,a){const o=i.get(e);e.version>0&&o.__version!==e.version?function(e,a,o){if(6!==a.image.length)return;const l=R(e,a),c=a.source;n.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+o);const h=i.get(c);if(c.version!==h.__version||!0===l){n.activeTexture(t.TEXTURE0+o);const e=Ci.getPrimaries(Ci.workingColorSpace),i=a.colorSpace===cn?null:Ci.getPrimaries(a.colorSpace),u=a.colorSpace===cn||e===i?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,u);const d=a.isCompressedTexture||a.image[0].isCompressedTexture,p=a.image[0]&&a.image[0].isDataTexture,f=[];for(let t=0;t<6;t++)f[t]=d||p?p?a.image[t].image:a.image[t]:m(a.image[t],!0,r.maxCubemapSize),f[t]=Q(a,f[t]);const v=f[0],_=s.convert(a.format,a.colorSpace),w=s.convert(a.type),C=y(a.internalFormat,_,w,a.colorSpace),E=!0!==a.isVideoTexture,M=void 0===h.__version||!0===l,S=c.dataReady;let b,I=x(a,v);if(B(t.TEXTURE_CUBE_MAP,a),d){E&&M&&n.texStorage2D(t.TEXTURE_CUBE_MAP,I,C,v.width,v.height);for(let e=0;e<6;e++){b=f[e].mipmaps;for(let i=0;i0&&I++;const e=z(f[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,I,C,e.width,e.height)}for(let e=0;e<6;e++)if(p){E?S&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,f[e].width,f[e].height,_,w,f[e].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,C,f[e].width,f[e].height,0,_,w,f[e].data);for(let i=0;i1;if(u||(void 0===l.__webglTexture&&(l.__webglTexture=t.createTexture()),l.__version=r.version,a.memory.textures++),h){o.__webglFramebuffer=[];for(let e=0;e<6;e++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[e]=[];for(let n=0;n0){o.__webglFramebuffer=[];for(let e=0;e0&&!1===k(e)){o.__webglMultisampledFramebuffer=t.createFramebuffer(),o.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let n=0;n0)for(let i=0;i0)for(let n=0;n0)if(!1===k(e)){const r=e.textures,s=e.width,a=e.height;let o=t.COLOR_BUFFER_BIT;const c=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,h=i.get(e),u=r.length>1;if(u)for(let e=0;e= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Ks(new Mc(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class hm extends Zn{constructor(t,e){super();const n=this;let i=null,r=1,s=null,a="local-floor",o=1,l=null,c=null,h=null,u=null,d=null,p=null;const f=new cm,m=e.getContextAttributes();let g=null,A=null;const v=[],y=[],_=new hi;let x=null;const w=new ca;w.viewport=new Pi;const C=new ca;C.viewport=new Pi;const E=[w,C],M=new cu;let S=null,b=null;function I(t){const e=y.indexOf(t.inputSource);if(-1===e)return;const n=v[e];void 0!==n&&(n.update(t.inputSource,t.frame,l||s),n.dispatchEvent({type:t.type,data:t.inputSource}))}function T(){i.removeEventListener("select",I),i.removeEventListener("selectstart",I),i.removeEventListener("selectend",I),i.removeEventListener("squeeze",I),i.removeEventListener("squeezestart",I),i.removeEventListener("squeezeend",I),i.removeEventListener("end",T),i.removeEventListener("inputsourceschange",B);for(let t=0;t=0&&(y[i]=null,v[i].disconnect(n))}for(let e=0;e=y.length){y.push(n),i=t;break}if(null===y[t]){y[t]=n,i=t;break}}if(-1===i)break}const r=v[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=v[t];return void 0===e&&(e=new ga,v[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=v[t];return void 0===e&&(e=new ga,v[t]=e),e.getGripSpace()},this.getHand=function(t){let e=v[t];return void 0===e&&(e=new ga,v[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){a=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(t){l=t},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(c){if(i=c,null!==i){if(g=t.getRenderTarget(),i.addEventListener("select",I),i.addEventListener("selectstart",I),i.addEventListener("selectend",I),i.addEventListener("squeeze",I),i.addEventListener("squeezestart",I),i.addEventListener("squeezeend",I),i.addEventListener("end",T),i.addEventListener("inputsourceschange",B),!0!==m.xrCompatible&&await e.makeXRCompatible(),x=t.getPixelRatio(),t.getSize(_),"undefined"!=typeof XRWebGLBinding&&"createProjectionLayer"in XRWebGLBinding.prototype){let n=null,s=null,a=null;m.depth&&(a=m.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,n=m.stencil?ie:ne,s=m.stencil?Yt:Vt);const o={colorFormat:e.RGBA8,depthFormat:a,scaleFactor:r};h=new XRWebGLBinding(i,e),u=h.createProjectionLayer(o),i.updateRenderState({layers:[u]}),t.setPixelRatio(1),t.setSize(u.textureWidth,u.textureHeight,!1),A=new Ui(u.textureWidth,u.textureHeight,{format:$t,type:kt,depthTexture:new dl(u.textureWidth,u.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:m.stencil,colorSpace:t.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:!1===u.ignoreDepthValues})}else{const n={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,e,n),i.updateRenderState({baseLayer:d}),t.setPixelRatio(1),t.setSize(d.framebufferWidth,d.framebufferHeight,!1),A=new Ui(d.framebufferWidth,d.framebufferHeight,{format:$t,type:kt,colorSpace:t.outputColorSpace,stencilBuffer:m.stencil})}A.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await i.requestReferenceSpace(a),U.setContext(i),U.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode},this.getDepthTexture=function(){return f.getDepthTexture()};const R=new zi,D=new zi;function P(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===i)return;let e=t.near,n=t.far;null!==f.texture&&(f.depthNear>0&&(e=f.depthNear),f.depthFar>0&&(n=f.depthFar)),M.near=C.near=w.near=e,M.far=C.far=w.far=n,S===M.near&&b===M.far||(i.updateRenderState({depthNear:M.near,depthFar:M.far}),S=M.near,b=M.far),w.layers.mask=2|t.layers.mask,C.layers.mask=4|t.layers.mask,M.layers.mask=w.layers.mask|C.layers.mask;const r=t.parent,s=M.cameras;P(M,r);for(let t=0;t0&&(t.alphaTest.value=i.alphaTest);const r=e.get(i),s=r.envMap,a=r.envMapRotation;s&&(t.envMap.value=s,um.copy(a),um.x*=-1,um.y*=-1,um.z*=-1,s.isCubeTexture&&!1===s.isRenderTargetTexture&&(um.y*=-1,um.z*=-1),t.envMapRotation.value.setFromMatrix4(dm.makeRotationFromEuler(um)),t.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,t.reflectivity.value=i.reflectivity,t.ior.value=i.ior,t.refractionRatio.value=i.refractionRatio),i.lightMap&&(t.lightMap.value=i.lightMap,t.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,t.lightMapTransform)),i.aoMap&&(t.aoMap.value=i.aoMap,t.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,t.aoMapTransform))}return{refreshFogUniforms:function(e,n){n.color.getRGB(e.fogColor.value,na(t)),n.isFog?(e.fogNear.value=n.near,e.fogFar.value=n.far):n.isFogExp2&&(e.fogDensity.value=n.density)},refreshMaterialUniforms:function(t,r,s,a,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(t,r):r.isMeshToonMaterial?(i(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,r)):r.isMeshPhongMaterial?(i(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,r)):r.isMeshStandardMaterial?(i(t,r),function(t,e){t.metalness.value=e.metalness,e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap,n(e.metalnessMap,t.metalnessMapTransform)),t.roughness.value=e.roughness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap,n(e.roughnessMap,t.roughnessMapTransform)),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}(t,r),r.isMeshPhysicalMaterial&&function(t,e,i){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,n(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,n(e.sheenRoughnessMap,t.sheenRoughnessMapTransform))),e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,n(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,n(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,n(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),e.side===M&&t.clearcoatNormalScale.value.negate())),e.dispersion>0&&(t.dispersion.value=e.dispersion),e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,n(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,n(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform))),e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=i.texture,t.transmissionSamplerSize.value.set(i.width,i.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,n(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,n(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor)),e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,n(e.anisotropyMap,t.anisotropyMapTransform))),t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,n(e.specularColorMap,t.specularColorMapTransform)),e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,n(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,r,o)):r.isMeshMatcapMaterial?(i(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,r)):r.isMeshDepthMaterial?i(t,r):r.isMeshDistanceMaterial?(i(t,r),function(t,n){const i=e.get(n).light;t.referencePosition.value.setFromMatrixPosition(i.matrixWorld),t.nearDistance.value=i.shadow.camera.near,t.farDistance.value=i.shadow.camera.far}(t,r)):r.isMeshNormalMaterial?i(t,r):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform))}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,i,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*i,t.scale.value=.5*r,e.map&&(t.map.value=e.map,n(e.map,t.uvTransform)),e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform)),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r,s,a):r.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,n(e.map,t.mapTransform)),e.alphaMap&&(t.alphaMap.value=e.alphaMap,n(e.alphaMap,t.alphaMapTransform)),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function fm(t,e,n,i){let r={},s={},a=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(t,e,n,i){const r=t.value,s=e+"_"+n;if(void 0===i[s])return i[s]="number"==typeof r||"boolean"==typeof r?r:r.clone(),!0;{const t=i[s];if("number"==typeof r||"boolean"==typeof r){if(t!==r)return i[s]=r,!0}else if(!1===t.equals(r))return t.copy(r),!0}return!1}function c(t){const e={boundary:0,storage:0};return"number"==typeof t||"boolean"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4?(e.boundary=64,e.storage=64):t.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",t),e}function h(e){const n=e.target;n.removeEventListener("dispose",h);const i=a.indexOf(n.__bindingPointIndex);a.splice(i,1),t.deleteBuffer(r[n.id]),delete r[n.id],delete s[n.id]}return{bind:function(t,e){const n=e.program;i.uniformBlockBinding(t,n)},update:function(n,u){let d=r[n.id];void 0===d&&(function(t){const e=t.uniforms;let n=0;for(let t=0,i=e.length;t0&&(n+=16-i),t.__size=n,t.__cache={}}(n),d=function(e){const n=function(){for(let t=0;t0),u=!!n.morphAttributes.position,d=!!n.morphAttributes.normal,p=!!n.morphAttributes.color;let f=ht;i.toneMapped&&(null!==b&&!0!==b.isXRRenderTarget||(f=_.toneMapping));const m=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,g=void 0!==m?m.length:0,v=it.get(i),y=A.state.lights;if(!0===V&&(!0===W||t!==T)){const e=t===T&&i.id===I;mt.setState(i,t,e)}let x=!1;i.version===v.__version?v.needsLights&&v.lightsStateVersion!==y.state.version||v.outputColorSpace!==o||r.isBatchedMesh&&!1===v.batching?x=!0:r.isBatchedMesh||!0!==v.batching?r.isBatchedMesh&&!0===v.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===v.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===v.instancing?x=!0:r.isInstancedMesh||!0!==v.instancing?r.isSkinnedMesh&&!1===v.skinning?x=!0:r.isSkinnedMesh||!0!==v.skinning?r.isInstancedMesh&&!0===v.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===v.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===v.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===v.instancingMorph&&null!==r.morphTexture||v.envMap!==l||!0===i.fog&&v.fog!==s?x=!0:void 0===v.numClippingPlanes||v.numClippingPlanes===mt.numPlanes&&v.numIntersection===mt.numIntersection?(v.vertexAlphas!==c||v.vertexTangents!==h||v.morphTargets!==u||v.morphNormals!==d||v.morphColors!==p||v.toneMapping!==f||v.morphTargetsCount!==g)&&(x=!0):x=!0:x=!0:x=!0:x=!0:(x=!0,v.__version=i.version);let w=v.currentProgram;!0===x&&(w=Jt(i,e,r));let C=!1,E=!1,M=!1;const S=w.getUniforms(),B=v.uniforms;if(et.useProgram(w.program)&&(C=!0,E=!0,M=!0),i.id!==I&&(I=i.id,E=!0),C||T!==t){et.buffers.depth.getReversed()?(j.copy(t.projectionMatrix),function(t){const e=t.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}(j),function(t){const e=t.elements;-1===e[11]?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=1-e[14])}(j),S.setValue(Et,"projectionMatrix",j)):S.setValue(Et,"projectionMatrix",t.projectionMatrix),S.setValue(Et,"viewMatrix",t.matrixWorldInverse);const e=S.map.cameraPosition;void 0!==e&&e.setValue(Et,X.setFromMatrixPosition(t.matrixWorld)),tt.logarithmicDepthBuffer&&S.setValue(Et,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&S.setValue(Et,"isOrthographic",!0===t.isOrthographicCamera),T!==t&&(T=t,E=!0,M=!0)}if(r.isSkinnedMesh){S.setOptional(Et,r,"bindMatrix"),S.setOptional(Et,r,"bindMatrixInverse");const t=r.skeleton;t&&(null===t.boneTexture&&t.computeBoneTexture(),S.setValue(Et,"boneTexture",t.boneTexture,rt))}r.isBatchedMesh&&(S.setOptional(Et,r,"batchingTexture"),S.setValue(Et,"batchingTexture",r._matricesTexture,rt),S.setOptional(Et,r,"batchingIdTexture"),S.setValue(Et,"batchingIdTexture",r._indirectTexture,rt),S.setOptional(Et,r,"batchingColorTexture"),null!==r._colorsTexture&&S.setValue(Et,"batchingColorTexture",r._colorsTexture,rt));const R=n.morphAttributes;var D,P;if(void 0===R.position&&void 0===R.normal&&void 0===R.color||vt.update(r,n,w),(E||v.receiveShadow!==r.receiveShadow)&&(v.receiveShadow=r.receiveShadow,S.setValue(Et,"receiveShadow",r.receiveShadow)),i.isMeshGouraudMaterial&&null!==i.envMap&&(B.envMap.value=l,B.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1),i.isMeshStandardMaterial&&null===i.envMap&&null!==e.environment&&(B.envMapIntensity.value=e.environmentIntensity),E&&(S.setValue(Et,"toneMappingExposure",_.toneMappingExposure),v.needsLights&&(P=M,(D=B).ambientLightColor.needsUpdate=P,D.lightProbe.needsUpdate=P,D.directionalLights.needsUpdate=P,D.directionalLightShadows.needsUpdate=P,D.pointLights.needsUpdate=P,D.pointLightShadows.needsUpdate=P,D.spotLights.needsUpdate=P,D.spotLightShadows.needsUpdate=P,D.rectAreaLights.needsUpdate=P,D.hemisphereLights.needsUpdate=P),s&&!0===i.fog&&dt.refreshFogUniforms(B,s),dt.refreshMaterialUniforms(B,i,F,N,A.state.transmissionRenderTarget[t.id]),Cf.upload(Et,Kt(v),B,rt)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(Cf.upload(Et,Kt(v),B,rt),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&S.setValue(Et,"center",r.center),S.setValue(Et,"modelViewMatrix",r.modelViewMatrix),S.setValue(Et,"normalMatrix",r.normalMatrix),S.setValue(Et,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const t=i.uniformsGroups;for(let e=0,n=t.length;e{function n(){i.forEach((function(t){it.get(t).currentProgram.isReady()&&i.delete(t)})),0!==i.size?setTimeout(n,10):e(t)}null!==$.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)}))};let Pt=null;function Lt(){Nt.stop()}function Ut(){Nt.start()}const Nt=new Nd;function Ot(t,e,n,i){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)n=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)A.pushLight(t),t.castShadow&&A.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||H.intersectsSprite(t)){i&&Y.setFromMatrixPosition(t.matrixWorld).applyMatrix4(q);const e=ct.update(t),r=t.material;r.visible&&g.push(t,e,r,n,Y.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||H.intersectsObject(t))){const e=ct.update(t),r=t.material;if(i&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),Y.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),Y.copy(e.boundingSphere.center)),Y.applyMatrix4(t.matrixWorld).applyMatrix4(q)),Array.isArray(r)){const i=e.groups;for(let s=0,a=i.length;s0&&Ht(r,e,n),s.length>0&&Ht(s,e,n),a.length>0&&Ht(a,e,n),et.buffers.depth.setTest(!0),et.buffers.depth.setMask(!0),et.buffers.color.setMask(!0),et.setPolygonOffset(!1)}function zt(t,e,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;void 0===A.state.transmissionRenderTarget[i.id]&&(A.state.transmissionRenderTarget[i.id]=new Ui(1,1,{generateMipmaps:!0,type:$.has("EXT_color_buffer_half_float")||$.has("EXT_color_buffer_float")?jt:kt,minFilter:Ft,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ci.workingColorSpace}));const s=A.state.transmissionRenderTarget[i.id],a=i.viewport||B;s.setSize(a.z*_.transmissionResolutionScale,a.w*_.transmissionResolutionScale);const o=_.getRenderTarget();_.setRenderTarget(s),_.getClearColor(P),L=_.getClearAlpha(),L<1&&_.setClearColor(16777215,.5),_.clear(),K&&At.render(n);const l=_.toneMapping;_.toneMapping=ht;const c=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),A.setupLightsView(i),!0===V&&mt.setGlobalState(_.clippingPlanes,i),Ht(t,n,i),rt.updateMultisampleRenderTarget(s),rt.updateRenderTargetMipmap(s),!1===$.has("WEBGL_multisampled_render_to_texture")){let t=!1;for(let r=0,s=e.length;r0)for(let e=0,s=n.length;e0&&zt(i,r,t,e),K&&At.render(t),Qt(g,t,e);null!==b&&0===C&&(rt.updateMultisampleRenderTarget(b),rt.updateRenderTargetMipmap(b)),!0===t.isScene&&t.onAfterRender(_,t,e),wt.resetDefaultState(),I=-1,T=null,y.pop(),y.length>0?(A=y[y.length-1],!0===V&&mt.setGlobalState(_.clippingPlanes,A.state.camera)):A=null,v.pop(),g=v.length>0?v[v.length-1]:null},this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return b},this.setRenderTargetTextures=function(t,e,n){it.get(t.texture).__webglTexture=e,it.get(t.depthTexture).__webglTexture=n;const i=it.get(t);i.__hasExternalTextures=!0,i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===$.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(t,e){const n=it.get(t);n.__webglFramebuffer=e,n.__useDefaultFramebuffer=void 0===e};const $t=Et.createFramebuffer();this.setRenderTarget=function(t,e=0,n=0){b=t,w=e,C=n;let i=!0,r=null,s=!1,a=!1;if(t){const o=it.get(t);if(void 0!==o.__useDefaultFramebuffer)et.bindFramebuffer(Et.FRAMEBUFFER,null),i=!1;else if(void 0===o.__webglFramebuffer)rt.setupRenderTarget(t);else if(o.__hasExternalTextures)rt.rebindTextures(t,it.get(t.texture).__webglTexture,it.get(t.depthTexture).__webglTexture);else if(t.depthBuffer){const e=t.depthTexture;if(o.__boundDepthTexture!==e){if(null!==e&&it.has(e)&&(t.width!==e.image.width||t.height!==e.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");rt.setupDepthRenderbuffer(t)}}const l=t.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(a=!0);const c=it.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(r=Array.isArray(c[e])?c[e][n]:c[e],s=!0):r=t.samples>0&&!1===rt.useMultisampledRTT(t)?it.get(t).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,B.copy(t.viewport),R.copy(t.scissor),D=t.scissorTest}else B.copy(Q).multiplyScalar(F).floor(),R.copy(z).multiplyScalar(F).floor(),D=G;if(0!==n&&(r=$t),et.bindFramebuffer(Et.FRAMEBUFFER,r)&&i&&et.drawBuffers(t,r),et.viewport(B),et.scissor(R),et.setScissorTest(D),s){const i=it.get(t.texture);Et.framebufferTexture2D(Et.FRAMEBUFFER,Et.COLOR_ATTACHMENT0,Et.TEXTURE_CUBE_MAP_POSITIVE_X+e,i.__webglTexture,n)}else if(a){const i=it.get(t.texture),r=e;Et.framebufferTextureLayer(Et.FRAMEBUFFER,Et.COLOR_ATTACHMENT0,i.__webglTexture,n,r)}else if(null!==t&&0!==n){const e=it.get(t.texture);Et.framebufferTexture2D(Et.FRAMEBUFFER,Et.COLOR_ATTACHMENT0,Et.TEXTURE_2D,e.__webglTexture,n)}I=-1},this.readRenderTargetPixels=function(t,e,n,i,r,s,a){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=it.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){et.bindFramebuffer(Et.FRAMEBUFFER,o);try{const a=t.texture,o=a.format,l=a.type;if(!tt.textureFormatReadable(o))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!tt.textureTypeReadable(l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r&&Et.readPixels(e,n,i,r,xt.convert(o),xt.convert(l),s)}finally{const t=null!==b?it.get(b).__webglFramebuffer:null;et.bindFramebuffer(Et.FRAMEBUFFER,t)}}},this.readRenderTargetPixelsAsync=async function(t,e,n,i,r,s,a){if(!t||!t.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=it.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){const a=t.texture,l=a.format,c=a.type;if(!tt.textureFormatReadable(l))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!tt.textureTypeReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r){et.bindFramebuffer(Et.FRAMEBUFFER,o);const t=Et.createBuffer();Et.bindBuffer(Et.PIXEL_PACK_BUFFER,t),Et.bufferData(Et.PIXEL_PACK_BUFFER,s.byteLength,Et.STREAM_READ),Et.readPixels(e,n,i,r,xt.convert(l),xt.convert(c),0);const a=null!==b?it.get(b).__webglFramebuffer:null;et.bindFramebuffer(Et.FRAMEBUFFER,a);const h=Et.fenceSync(Et.SYNC_GPU_COMMANDS_COMPLETE,0);return Et.flush(),await function(t,e){return new Promise((function(n,i){setTimeout((function r(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(r,4);break;default:n()}}),4)}))}(Et,h),Et.bindBuffer(Et.PIXEL_PACK_BUFFER,t),Et.getBufferSubData(Et.PIXEL_PACK_BUFFER,0,s),Et.deleteBuffer(t),Et.deleteSync(h),s}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(t,e=null,n=0){!0!==t.isTexture&&(yi("WebGLRenderer: copyFramebufferToTexture function signature has changed."),e=arguments[0]||null,t=arguments[1]);const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),s=Math.floor(t.image.height*i),a=null!==e?e.x:0,o=null!==e?e.y:0;rt.setTexture2D(t,0),Et.copyTexSubImage2D(Et.TEXTURE_2D,n,0,0,a,o,r,s),et.unbindTexture()};const te=Et.createFramebuffer(),ee=Et.createFramebuffer();this.copyTextureToTexture=function(t,e,n=null,i=null,r=0,s=null){let a,o,l,c,h,u,d,p,f;!0!==t.isTexture&&(yi("WebGLRenderer: copyTextureToTexture function signature has changed."),i=arguments[0]||null,t=arguments[1],e=arguments[2],s=arguments[3]||0,n=null),null===s&&(0!==r?(yi("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),s=r,r=0):s=0);const m=t.isCompressedTexture?t.mipmaps[s]:t.image;if(null!==n)a=n.max.x-n.min.x,o=n.max.y-n.min.y,l=n.isBox3?n.max.z-n.min.z:1,c=n.min.x,h=n.min.y,u=n.isBox3?n.min.z:0;else{const e=Math.pow(2,-r);a=Math.floor(m.width*e),o=Math.floor(m.height*e),l=t.isDataArrayTexture?m.depth:t.isData3DTexture?Math.floor(m.depth*e):1,c=0,h=0,u=0}null!==i?(d=i.x,p=i.y,f=i.z):(d=0,p=0,f=0);const g=xt.convert(e.format),A=xt.convert(e.type);let v;e.isData3DTexture?(rt.setTexture3D(e,0),v=Et.TEXTURE_3D):e.isDataArrayTexture||e.isCompressedArrayTexture?(rt.setTexture2DArray(e,0),v=Et.TEXTURE_2D_ARRAY):(rt.setTexture2D(e,0),v=Et.TEXTURE_2D),Et.pixelStorei(Et.UNPACK_FLIP_Y_WEBGL,e.flipY),Et.pixelStorei(Et.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),Et.pixelStorei(Et.UNPACK_ALIGNMENT,e.unpackAlignment);const y=Et.getParameter(Et.UNPACK_ROW_LENGTH),_=Et.getParameter(Et.UNPACK_IMAGE_HEIGHT),x=Et.getParameter(Et.UNPACK_SKIP_PIXELS),w=Et.getParameter(Et.UNPACK_SKIP_ROWS),C=Et.getParameter(Et.UNPACK_SKIP_IMAGES);Et.pixelStorei(Et.UNPACK_ROW_LENGTH,m.width),Et.pixelStorei(Et.UNPACK_IMAGE_HEIGHT,m.height),Et.pixelStorei(Et.UNPACK_SKIP_PIXELS,c),Et.pixelStorei(Et.UNPACK_SKIP_ROWS,h),Et.pixelStorei(Et.UNPACK_SKIP_IMAGES,u);const E=t.isDataArrayTexture||t.isData3DTexture,M=e.isDataArrayTexture||e.isData3DTexture;if(t.isDepthTexture){const n=it.get(t),i=it.get(e),m=it.get(n.__renderTarget),g=it.get(i.__renderTarget);et.bindFramebuffer(Et.READ_FRAMEBUFFER,m.__webglFramebuffer),et.bindFramebuffer(Et.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n\n\n\t\tvarying vec2 vUv;\n\n\t\t#if DIFFUSE_TEXTURE == 1\n\t\tuniform sampler2D tDiffuse;\n\t\t#endif\n\n\t\tuniform highp sampler2D tDepth;\n\t\tuniform highp sampler2D tNormal;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraInverseProjectionMatrix;\n\n\t\tuniform float scale;\n\t\tuniform float intensity;\n\t\tuniform float bias;\n\t\tuniform float kernelRadius;\n\t\tuniform float minResolution;\n\t\tuniform vec2 size;\n\t\tuniform float randomSeed;\n\n\t\t// RGBA depth\n\n\t\t#include \n\n\t\tvec4 getDefaultColor( const in vec2 screenPosition ) {\n\t\t\t#if DIFFUSE_TEXTURE == 1\n\t\t\treturn texture2D( tDiffuse, vUv );\n\t\t\t#else\n\t\t\treturn vec4( 1.0 );\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n\t\t\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n\t\t\tvec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );\n\t\t\tclipPosition *= clipW; // unprojection.\n\n\t\t\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;\n\t\t}\n\n\t\tvec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPosition ) {\n\t\t\treturn unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );\n\t\t}\n\n\t\tfloat scaleDividedByCameraFar;\n\t\tfloat minResolutionMultipliedByCameraFar;\n\n\t\tfloat getOcclusion( const in vec3 centerViewPosition, const in vec3 centerViewNormal, const in vec3 sampleViewPosition ) {\n\t\t\tvec3 viewDelta = sampleViewPosition - centerViewPosition;\n\t\t\tfloat viewDistance = length( viewDelta );\n\t\t\tfloat scaledScreenDistance = scaleDividedByCameraFar * viewDistance;\n\n\t\t\treturn max(0.0, (dot(centerViewNormal, viewDelta) - minResolutionMultipliedByCameraFar) / scaledScreenDistance - bias) / (1.0 + pow2( scaledScreenDistance ) );\n\t\t}\n\n\t\t// moving costly divides into consts\n\t\tconst float ANGLE_STEP = PI2 * float( NUM_RINGS ) / float( NUM_SAMPLES );\n\t\tconst float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );\n\n\t\tfloat getAmbientOcclusion( const in vec3 centerViewPosition ) {\n\t\t\t// precompute some variables require in getOcclusion.\n\t\t\tscaleDividedByCameraFar = scale / cameraFar;\n\t\t\tminResolutionMultipliedByCameraFar = minResolution * cameraFar;\n\t\t\tvec3 centerViewNormal = getViewNormal( centerViewPosition, vUv );\n\n\t\t\t// jsfiddle that shows sample pattern: https://jsfiddle.net/a16ff1p7/\n\t\t\tfloat angle = rand( vUv + randomSeed ) * PI2;\n\t\t\tvec2 radius = vec2( kernelRadius * INV_NUM_SAMPLES ) / size;\n\t\t\tvec2 radiusStep = radius;\n\n\t\t\tfloat occlusionSum = 0.0;\n\t\t\tfloat weightSum = 0.0;\n\n\t\t\tfor( int i = 0; i < NUM_SAMPLES; i ++ ) {\n\t\t\t\tvec2 sampleUv = vUv + vec2( cos( angle ), sin( angle ) ) * radius;\n\t\t\t\tradius += radiusStep;\n\t\t\t\tangle += ANGLE_STEP;\n\n\t\t\t\tfloat sampleDepth = getDepth( sampleUv );\n\t\t\t\tif( sampleDepth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tfloat sampleViewZ = getViewZ( sampleDepth );\n\t\t\t\tvec3 sampleViewPosition = getViewPosition( sampleUv, sampleDepth, sampleViewZ );\n\t\t\t\tocclusionSum += getOcclusion( centerViewPosition, centerViewNormal, sampleViewPosition );\n\t\t\t\tweightSum += 1.0;\n\t\t\t}\n\n\t\t\tif( weightSum == 0.0 ) discard;\n\n\t\t\treturn occlusionSum * ( intensity / weightSum );\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat centerDepth = getDepth( vUv );\n\t\t\tif( centerDepth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\tdiscard;\n\t\t\t}\n\n\t\t\tfloat centerViewZ = getViewZ( centerDepth );\n\t\t\tvec3 viewPosition = getViewPosition( vUv, centerDepth, centerViewZ );\n\n\t\t\tfloat ambientOcclusion = getAmbientOcclusion( viewPosition );\n\n\t\t\tgl_FragColor = getDefaultColor( vUv );\n\t\t\tgl_FragColor.xyz *= 1.0 - ambientOcclusion;\n\t\t}"},Mm={name:"DepthLimitedBlurShader",defines:{KERNEL_RADIUS:4,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDiffuse:{value:null},size:{value:new hi(512,512)},sampleUvOffsets:{value:[new hi(0,0)]},sampleWeights:{value:[1]},tDepth:{value:null},cameraNear:{value:10},cameraFar:{value:1e3},depthCutoff:{value:10}},vertexShader:"\n\n\t\t#include \n\n\t\tuniform vec2 size;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec2 vInvSize;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tvInvSize = 1.0 / size;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\n\t\t#include \n\t\t#include \n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tDepth;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform float depthCutoff;\n\n\t\tuniform vec2 sampleUvOffsets[ KERNEL_RADIUS + 1 ];\n\t\tuniform float sampleWeights[ KERNEL_RADIUS + 1 ];\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec2 vInvSize;\n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\t#if DEPTH_PACKING == 1\n\t\t\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );\n\t\t\t#else\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth( vUv );\n\t\t\tif( depth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\tdiscard;\n\t\t\t}\n\n\t\t\tfloat centerViewZ = -getViewZ( depth );\n\t\t\tbool rBreak = false, lBreak = false;\n\n\t\t\tfloat weightSum = sampleWeights[0];\n\t\t\tvec4 diffuseSum = texture2D( tDiffuse, vUv ) * weightSum;\n\n\t\t\tfor( int i = 1; i <= KERNEL_RADIUS; i ++ ) {\n\n\t\t\t\tfloat sampleWeight = sampleWeights[i];\n\t\t\t\tvec2 sampleUvOffset = sampleUvOffsets[i] * vInvSize;\n\n\t\t\t\tvec2 sampleUv = vUv + sampleUvOffset;\n\t\t\t\tfloat viewZ = -getViewZ( getDepth( sampleUv ) );\n\n\t\t\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) rBreak = true;\n\n\t\t\t\tif( ! rBreak ) {\n\t\t\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;\n\t\t\t\t\tweightSum += sampleWeight;\n\t\t\t\t}\n\n\t\t\t\tsampleUv = vUv - sampleUvOffset;\n\t\t\t\tviewZ = -getViewZ( getDepth( sampleUv ) );\n\n\t\t\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) lBreak = true;\n\n\t\t\t\tif( ! lBreak ) {\n\t\t\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;\n\t\t\t\t\tweightSum += sampleWeight;\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tgl_FragColor = diffuseSum / weightSum;\n\t\t}"},Sm={createSampleWeights:function(t,e){const n=[];for(let i=0;i<=t;i++)n.push(bm(i,e));return n},createSampleOffsets:function(t,e){const n=[];for(let i=0;i<=t;i++)n.push(e.clone().multiplyScalar(i));return n},configure:function(t,e,n,i){t.defines.KERNEL_RADIUS=e,t.uniforms.sampleUvOffsets.value=Sm.createSampleOffsets(e,i),t.uniforms.sampleWeights.value=Sm.createSampleWeights(e,n),t.needsUpdate=!0}};function bm(t,e){return Math.exp(-t*t/(e*e*2))/(Math.sqrt(2*Math.PI)*e)}class Im extends Am{constructor(t,e,n=new hi(256,256)){super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.originalClearColor=new cs,this._oldClearColor=new cs,this.oldClearAlpha=1,this.params={output:0,saoBias:.5,saoIntensity:.18,saoScale:1,saoKernelRadius:100,saoMinResolution:0,saoBlur:!0,saoBlurRadius:8,saoBlurStdDev:4,saoBlurDepthCutoff:.01},this.resolution=new hi(n.x,n.y),this.saoRenderTarget=new Ui(this.resolution.x,this.resolution.y,{type:jt}),this.blurIntermediateRenderTarget=this.saoRenderTarget.clone();const i=new dl;i.format=ie,i.type=Yt,this.normalRenderTarget=new Ui(this.resolution.x,this.resolution.y,{minFilter:Tt,magFilter:Tt,type:jt,depthTexture:i}),this.normalMaterial=new Gc,this.normalMaterial.blending=b,this.saoMaterial=new ra({defines:Object.assign({},Em.defines),fragmentShader:Em.fragmentShader,vertexShader:Em.vertexShader,uniforms:ia.clone(Em.uniforms)}),this.saoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.saoMaterial.uniforms.tDepth.value=i,this.saoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.saoMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.blending=b,this.vBlurMaterial=new ra({uniforms:ia.clone(Mm.uniforms),defines:Object.assign({},Mm.defines),vertexShader:Mm.vertexShader,fragmentShader:Mm.fragmentShader}),this.vBlurMaterial.defines.DEPTH_PACKING=0,this.vBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.vBlurMaterial.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.vBlurMaterial.uniforms.tDepth.value=i,this.vBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.vBlurMaterial.blending=b,this.hBlurMaterial=new ra({uniforms:ia.clone(Mm.uniforms),defines:Object.assign({},Mm.defines),vertexShader:Mm.vertexShader,fragmentShader:Mm.fragmentShader}),this.hBlurMaterial.defines.DEPTH_PACKING=0,this.hBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.hBlurMaterial.uniforms.tDiffuse.value=this.blurIntermediateRenderTarget.texture,this.hBlurMaterial.uniforms.tDepth.value=i,this.hBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.hBlurMaterial.blending=b,this.materialCopy=new ra({uniforms:ia.clone(gm.uniforms),vertexShader:gm.vertexShader,fragmentShader:gm.fragmentShader,blending:b}),this.materialCopy.transparent=!0,this.materialCopy.depthTest=!1,this.materialCopy.depthWrite=!1,this.materialCopy.blending=D,this.materialCopy.blendSrc=j,this.materialCopy.blendDst=O,this.materialCopy.blendEquation=P,this.materialCopy.blendSrcAlpha=V,this.materialCopy.blendDstAlpha=O,this.materialCopy.blendEquationAlpha=P,this.fsQuad=new _m(null)}render(t,e,n){this.renderToScreen&&(this.materialCopy.blending=b,this.materialCopy.uniforms.tDiffuse.value=n.texture,this.materialCopy.needsUpdate=!0,this.renderPass(t,this.materialCopy,null)),t.getClearColor(this._oldClearColor),this.oldClearAlpha=t.getClearAlpha();const i=t.autoClear;t.autoClear=!1,this.saoMaterial.uniforms.bias.value=this.params.saoBias,this.saoMaterial.uniforms.intensity.value=this.params.saoIntensity,this.saoMaterial.uniforms.scale.value=this.params.saoScale,this.saoMaterial.uniforms.kernelRadius.value=this.params.saoKernelRadius,this.saoMaterial.uniforms.minResolution.value=this.params.saoMinResolution,this.saoMaterial.uniforms.cameraNear.value=this.camera.near,this.saoMaterial.uniforms.cameraFar.value=this.camera.far;const r=this.params.saoBlurDepthCutoff*(this.camera.far-this.camera.near);this.vBlurMaterial.uniforms.depthCutoff.value=r,this.hBlurMaterial.uniforms.depthCutoff.value=r,this.vBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.vBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.hBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.hBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.params.saoBlurRadius=Math.floor(this.params.saoBlurRadius),this.prevStdDev===this.params.saoBlurStdDev&&this.prevNumSamples===this.params.saoBlurRadius||(Sm.configure(this.vBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new hi(0,1)),Sm.configure(this.hBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new hi(1,0)),this.prevStdDev=this.params.saoBlurStdDev,this.prevNumSamples=this.params.saoBlurRadius),this.renderOverride(t,this.normalMaterial,this.normalRenderTarget,7829503,1),this.renderPass(t,this.saoMaterial,this.saoRenderTarget,16777215,1),this.params.saoBlur&&(this.renderPass(t,this.vBlurMaterial,this.blurIntermediateRenderTarget,16777215,1),this.renderPass(t,this.hBlurMaterial,this.saoRenderTarget,16777215,1));const s=this.materialCopy;this.params.output===Im.OUTPUT.Normal?(this.materialCopy.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.materialCopy.needsUpdate=!0):(this.materialCopy.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.materialCopy.needsUpdate=!0),this.params.output===Im.OUTPUT.Default?s.blending=D:s.blending=b,this.renderPass(t,s,this.renderToScreen?null:n),t.setClearColor(this._oldClearColor,this.oldClearAlpha),t.autoClear=i}renderPass(t,e,n,i,r){t.getClearColor(this.originalClearColor);const s=t.getClearAlpha(),a=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.fsQuad.material=e,this.fsQuad.render(t),t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}renderOverride(t,e,n,i,r){t.getClearColor(this.originalClearColor);const s=t.getClearAlpha(),a=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,i=e.clearColor||i,r=e.clearAlpha||r,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.scene.overrideMaterial=e,t.render(this.scene,this.camera),this.scene.overrideMaterial=null,t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}setSize(t,e){this.saoRenderTarget.setSize(t,e),this.blurIntermediateRenderTarget.setSize(t,e),this.normalRenderTarget.setSize(t,e),this.saoMaterial.uniforms.size.value.set(t,e),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.needsUpdate=!0,this.vBlurMaterial.uniforms.size.value.set(t,e),this.vBlurMaterial.needsUpdate=!0,this.hBlurMaterial.uniforms.size.value.set(t,e),this.hBlurMaterial.needsUpdate=!0}dispose(){this.saoRenderTarget.dispose(),this.blurIntermediateRenderTarget.dispose(),this.normalRenderTarget.dispose(),this.normalMaterial.dispose(),this.saoMaterial.dispose(),this.vBlurMaterial.dispose(),this.hBlurMaterial.dispose(),this.materialCopy.dispose(),this.fsQuad.dispose()}}Im.OUTPUT={Default:0,SAO:1,Normal:2};const Tm={name:"GTAOShader",defines:{PERSPECTIVE_CAMERA:1,SAMPLES:16,NORMAL_VECTOR_TYPE:1,DEPTH_SWIZZLING:"x",SCREEN_SPACE_RADIUS:0,SCREEN_SPACE_RADIUS_SCALE:100,SCENE_CLIP_BOX:0},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new hi},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new Ar},cameraProjectionMatrixInverse:{value:new Ar},cameraWorldMatrix:{value:new Ar},radius:{value:.25},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},scale:{value:1},sceneBoxMin:{value:new zi(-1,-1,-1)},sceneBoxMax:{value:new zi(1,1,1)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\t\tvarying vec2 vUv;\n\t\tuniform highp sampler2D tNormal;\n\t\tuniform highp sampler2D tDepth;\n\t\tuniform sampler2D tNoise;\n\t\tuniform vec2 resolution;\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraProjectionMatrixInverse;\t\t\n\t\tuniform mat4 cameraWorldMatrix;\n\t\tuniform float radius;\n\t\tuniform float distanceExponent;\n\t\tuniform float thickness;\n\t\tuniform float distanceFallOff;\n\t\tuniform float scale;\n\t\t#if SCENE_CLIP_BOX == 1\n\t\t\tuniform vec3 sceneBoxMin;\n\t\t\tuniform vec3 sceneBoxMax;\n\t\t#endif\n\t\t\n\t\t#include \n\t\t#include \n\n\t\t#ifndef FRAGMENT_OUTPUT\n\t\t#define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)\n\t\t#endif\n\n\t\tvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n\t\t\tvec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n\t\t\tvec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n\t\t\treturn viewSpacePosition.xyz / viewSpacePosition.w;\n\t\t}\n\n\t\tfloat getDepth(const vec2 uv) { \n\t\t\treturn textureLod(tDepth, uv.xy, 0.0).DEPTH_SWIZZLING;\n\t\t}\n\n\t\tfloat fetchDepth(const ivec2 uv) { \n\t\t\treturn texelFetch(tDepth, uv.xy, 0).DEPTH_SWIZZLING;\n\t\t}\n\n\t\tfloat getViewZ(const in float depth) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\t\treturn perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#else\n\t\t\t\treturn orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 computeNormalFromDepth(const vec2 uv) {\n\t\t\tvec2 size = vec2(textureSize(tDepth, 0));\n\t\t\tivec2 p = ivec2(uv * size);\n\t\t\tfloat c0 = fetchDepth(p);\n\t\t\tfloat l2 = fetchDepth(p - ivec2(2, 0));\n\t\t\tfloat l1 = fetchDepth(p - ivec2(1, 0));\n\t\t\tfloat r1 = fetchDepth(p + ivec2(1, 0));\n\t\t\tfloat r2 = fetchDepth(p + ivec2(2, 0));\n\t\t\tfloat b2 = fetchDepth(p - ivec2(0, 2));\n\t\t\tfloat b1 = fetchDepth(p - ivec2(0, 1));\n\t\t\tfloat t1 = fetchDepth(p + ivec2(0, 1));\n\t\t\tfloat t2 = fetchDepth(p + ivec2(0, 2));\n\t\t\tfloat dl = abs((2.0 * l1 - l2) - c0);\n\t\t\tfloat dr = abs((2.0 * r1 - r2) - c0);\n\t\t\tfloat db = abs((2.0 * b1 - b2) - c0);\n\t\t\tfloat dt = abs((2.0 * t1 - t2) - c0);\n\t\t\tvec3 ce = getViewPosition(uv, c0).xyz;\n\t\t\tvec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n\t\t\tvec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n\t\t\treturn normalize(cross(dpdx, dpdy));\n\t\t}\n\n\t\tvec3 getViewNormal(const vec2 uv) {\n\t\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\t\treturn normalize(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\t\treturn unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#else\n\t\t\t\treturn computeNormalFromDepth(uv);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 getSceneUvAndDepth(vec3 sampleViewPos) {\n\t\t\tvec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);\n\t\t\tvec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;\n\t\t\tfloat sampleSceneDepth = getDepth(sampleUv);\n\t\t\treturn vec3(sampleUv, sampleSceneDepth);\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth(vUv.xy);\n\t\t\tif (depth >= 1.0) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvec3 viewPos = getViewPosition(vUv, depth);\n\t\t\tvec3 viewNormal = getViewNormal(vUv);\n\n\t\t\tfloat radiusToUse = radius;\n\t\t\tfloat distanceFalloffToUse = thickness;\n\t\t\t#if SCREEN_SPACE_RADIUS == 1\n\t\t\t\tfloat radiusScale = getViewPosition(vec2(0.5 + float(SCREEN_SPACE_RADIUS_SCALE) / resolution.x, 0.0), depth).x;\n\t\t\t\tradiusToUse *= radiusScale;\n\t\t\t\tdistanceFalloffToUse *= radiusScale;\n\t\t\t#endif\n\n\t\t\t#if SCENE_CLIP_BOX == 1\n\t\t\t\tvec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;\n\t\t\t\tfloat boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));\n\t\t\t\tif (boxDistance > radiusToUse) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t#endif\n\t\t\t\n\t\t\tvec2 noiseResolution = vec2(textureSize(tNoise, 0));\n\t\t\tvec2 noiseUv = vUv * resolution / noiseResolution;\n\t\t\tvec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n\t\t\tvec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;\n\t\t\tvec3 tangent = normalize(vec3(randomVec.xy, 0.));\n\t\t\tvec3 bitangent = vec3(-tangent.y, tangent.x, 0.);\n\t\t\tmat3 kernelMatrix = mat3(tangent, bitangent, vec3(0., 0., 1.));\n\n\t\t\tconst int DIRECTIONS = SAMPLES < 30 ? 3 : 5;\n\t\t\tconst int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n\t\t\tfloat ao = 0.0;\n\t\t\tfor (int i = 0; i < DIRECTIONS; ++i) {\n\t\t\t\t\n\t\t\t\tfloat angle = float(i) / float(DIRECTIONS) * PI;\n\t\t\t\tvec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w); \n\t\t\t\tsampleDir.xyz = normalize(kernelMatrix * sampleDir.xyz);\n\n\t\t\t\tvec3 viewDir = normalize(-viewPos.xyz);\n\t\t\t\tvec3 sliceBitangent = normalize(cross(sampleDir.xyz, viewDir));\n\t\t\t\tvec3 sliceTangent = cross(sliceBitangent, viewDir);\n\t\t\t\tvec3 normalInSlice = normalize(viewNormal - sliceBitangent * dot(viewNormal, sliceBitangent));\n\t\t\t\t\n\t\t\t\tvec3 tangentToNormalInSlice = cross(normalInSlice, sliceBitangent);\n\t\t\t\tvec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice), dot(viewDir, -tangentToNormalInSlice));\n\t\t\t\t\n\t\t\t\tfor (int j = 0; j < STEPS; ++j) {\n\t\t\t\t\tvec3 sampleViewOffset = sampleDir.xyz * radiusToUse * sampleDir.w * pow(float(j + 1) / float(STEPS), distanceExponent);\t\n\n\t\t\t\t\tvec3 sampleSceneUvDepth = getSceneUvAndDepth(viewPos + sampleViewOffset);\n\t\t\t\t\tvec3 sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\tvec3 viewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\tcosHorizons.x += max(0., (sampleCosHorizon - cosHorizons.x) * mix(1., 2. / float(j + 2), distanceFallOff));\n\t\t\t\t\t}\t\t\n\n\t\t\t\t\tsampleSceneUvDepth = getSceneUvAndDepth(viewPos - sampleViewOffset);\n\t\t\t\t\tsampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\tviewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\tcosHorizons.y += max(0., (sampleCosHorizon - cosHorizons.y) * mix(1., 2. / float(j + 2), distanceFallOff));\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tvec2 sinHorizons = sqrt(1. - cosHorizons * cosHorizons);\n\t\t\t\tfloat nx = dot(normalInSlice, sliceTangent);\n\t\t\t\tfloat ny = dot(normalInSlice, viewDir);\n\t\t\t\tfloat nxb = 1. / 2. * (acos(cosHorizons.y) - acos(cosHorizons.x) + sinHorizons.x * cosHorizons.x - sinHorizons.y * cosHorizons.y);\n\t\t\t\tfloat nyb = 1. / 2. * (2. - cosHorizons.x * cosHorizons.x - cosHorizons.y * cosHorizons.y);\n\t\t\t\tfloat occlusion = nx * nxb + ny * nyb;\n\t\t\t\tao += occlusion;\n\t\t\t}\n\n\t\t\tao = clamp(ao / float(DIRECTIONS), 0., 1.);\t\t\n\t\t#if SCENE_CLIP_BOX == 1\n\t\t\tao = mix(ao, 1., smoothstep(0., radiusToUse, boxDistance));\n\t\t#endif\n\t\t\tao = pow(ao, scale);\n\n\t\t\tgl_FragColor = FRAGMENT_OUTPUT;\n\t\t}"},Bm={PERSPECTIVE_CAMERA:1},Rm={tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},Dm="\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",Pm="\n\t\tuniform sampler2D tDepth;\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tvarying vec2 vUv;\n\n\t\t#include \n\n\t\tfloat getLinearDepth( const in vec2 screenPosition ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\t\tfloat fragCoordZ = texture2D( tDepth, screenPosition ).x;\n\t\t\t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n\t\t\t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat depth = getLinearDepth( vUv );\n\t\t\tgl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );\n\n\t\t}",Lm={tDiffuse:{value:null},intensity:{value:1}},Um="\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",Nm="\n\t\tuniform float intensity;\n\t\tuniform sampler2D tDiffuse;\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = vec4(mix(vec3(1.), texel.rgb, intensity), texel.a);\n\t\t}";const Fm={name:"PoissonDenoiseShader",defines:{SAMPLES:16,SAMPLE_VECTORS:Om(16,2,1),NORMAL_VECTOR_TYPE:1,DEPTH_VALUE_SOURCE:0},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new hi},cameraProjectionMatrixInverse:{value:new Ar},lumaPhi:{value:5},depthPhi:{value:5},normalPhi:{value:5},radius:{value:4},index:{value:0}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tNormal;\n\t\tuniform sampler2D tDepth;\n\t\tuniform sampler2D tNoise;\n\t\tuniform vec2 resolution;\n\t\tuniform mat4 cameraProjectionMatrixInverse;\n\t\tuniform float lumaPhi;\n\t\tuniform float depthPhi;\n\t\tuniform float normalPhi;\n\t\tuniform float radius;\n\t\tuniform int index;\n\t\t\n\t\t#include \n\t\t#include \n\n\t\t#ifndef SAMPLE_LUMINANCE\n\t\t#define SAMPLE_LUMINANCE dot(vec3(0.2125, 0.7154, 0.0721), a)\n\t\t#endif\n\n\t\t#ifndef FRAGMENT_OUTPUT\n\t\t#define FRAGMENT_OUTPUT vec4(denoised, 1.)\n\t\t#endif\n\n\t\tfloat getLuminance(const in vec3 a) {\n\t\t\treturn SAMPLE_LUMINANCE;\n\t\t}\n\n\t\tconst vec3 poissonDisk[SAMPLES] = SAMPLE_VECTORS;\n\n\t\tvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n\t\t\tvec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n\t\t\tvec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n\t\t\treturn viewSpacePosition.xyz / viewSpacePosition.w;\n\t\t}\n\t\t\n\t\tfloat getDepth(const vec2 uv) {\n\t\t#if DEPTH_VALUE_SOURCE == 1 \n\t\t\treturn textureLod(tDepth, uv.xy, 0.0).a;\n\t\t#else\n\t\t\treturn textureLod(tDepth, uv.xy, 0.0).r;\n\t\t#endif\n\t\t}\n\n\t\tfloat fetchDepth(const ivec2 uv) {\n\t\t\t#if DEPTH_VALUE_SOURCE == 1 \n\t\t\t\treturn texelFetch(tDepth, uv.xy, 0).a;\n\t\t\t#else\n\t\t\t\treturn texelFetch(tDepth, uv.xy, 0).r;\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 computeNormalFromDepth(const vec2 uv) {\n\t\t\tvec2 size = vec2(textureSize(tDepth, 0));\n\t\t\tivec2 p = ivec2(uv * size);\n\t\t\tfloat c0 = fetchDepth(p);\n\t\t\tfloat l2 = fetchDepth(p - ivec2(2, 0));\n\t\t\tfloat l1 = fetchDepth(p - ivec2(1, 0));\n\t\t\tfloat r1 = fetchDepth(p + ivec2(1, 0));\n\t\t\tfloat r2 = fetchDepth(p + ivec2(2, 0));\n\t\t\tfloat b2 = fetchDepth(p - ivec2(0, 2));\n\t\t\tfloat b1 = fetchDepth(p - ivec2(0, 1));\n\t\t\tfloat t1 = fetchDepth(p + ivec2(0, 1));\n\t\t\tfloat t2 = fetchDepth(p + ivec2(0, 2));\n\t\t\tfloat dl = abs((2.0 * l1 - l2) - c0);\n\t\t\tfloat dr = abs((2.0 * r1 - r2) - c0);\n\t\t\tfloat db = abs((2.0 * b1 - b2) - c0);\n\t\t\tfloat dt = abs((2.0 * t1 - t2) - c0);\n\t\t\tvec3 ce = getViewPosition(uv, c0).xyz;\n\t\t\tvec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n\t\t\t\t\t\t\t\t\t: -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n\t\t\tvec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n\t\t\t\t\t\t\t\t\t: -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n\t\t\treturn normalize(cross(dpdx, dpdy));\n\t\t}\n\n\t\tvec3 getViewNormal(const vec2 uv) {\n\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\treturn normalize(textureLod(tNormal, uv, 0.).rgb);\n\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\treturn unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n\t\t#else\n\t\t\treturn computeNormalFromDepth(uv);\n\t\t#endif\n\t\t}\n\n\t\tvoid denoiseSample(in vec3 center, in vec3 viewNormal, in vec3 viewPos, in vec2 sampleUv, inout vec3 denoised, inout float totalWeight) {\n\t\t\tvec4 sampleTexel = textureLod(tDiffuse, sampleUv, 0.0);\n\t\t\tfloat sampleDepth = getDepth(sampleUv);\n\t\t\tvec3 sampleNormal = getViewNormal(sampleUv);\n\t\t\tvec3 neighborColor = sampleTexel.rgb;\n\t\t\tvec3 viewPosSample = getViewPosition(sampleUv, sampleDepth);\n\t\t\t\n\t\t\tfloat normalDiff = dot(viewNormal, sampleNormal);\n\t\t\tfloat normalSimilarity = pow(max(normalDiff, 0.), normalPhi);\n\t\t\tfloat lumaDiff = abs(getLuminance(neighborColor) - getLuminance(center));\n\t\t\tfloat lumaSimilarity = max(1.0 - lumaDiff / lumaPhi, 0.0);\n\t\t\tfloat depthDiff = abs(dot(viewPos - viewPosSample, viewNormal));\n\t\t\tfloat depthSimilarity = max(1. - depthDiff / depthPhi, 0.);\n\t\t\tfloat w = lumaSimilarity * depthSimilarity * normalSimilarity;\n\t\t\n\t\t\tdenoised += w * neighborColor;\n\t\t\ttotalWeight += w;\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth(vUv.xy);\t\n\t\t\tvec3 viewNormal = getViewNormal(vUv);\t\n\t\t\tif (depth == 1. || dot(viewNormal, viewNormal) == 0.) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvec4 texel = textureLod(tDiffuse, vUv, 0.0);\n\t\t\tvec3 center = texel.rgb;\n\t\t\tvec3 viewPos = getViewPosition(vUv, depth);\n\n\t\t\tvec2 noiseResolution = vec2(textureSize(tNoise, 0));\n\t\t\tvec2 noiseUv = vUv * resolution / noiseResolution;\n\t\t\tvec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n \t\tvec2 noiseVec = vec2(sin(noiseTexel[index % 4] * 2. * PI), cos(noiseTexel[index % 4] * 2. * PI));\n \t\tmat2 rotationMatrix = mat2(noiseVec.x, -noiseVec.y, noiseVec.x, noiseVec.y);\n\t\t\n\t\t\tfloat totalWeight = 1.0;\n\t\t\tvec3 denoised = texel.rgb;\n\t\t\tfor (int i = 0; i < SAMPLES; i++) {\n\t\t\t\tvec3 sampleDir = poissonDisk[i];\n\t\t\t\tvec2 offset = rotationMatrix * (sampleDir.xy * (1. + sampleDir.z * (radius - 1.)) / resolution);\n\t\t\t\tvec2 sampleUv = vUv + offset;\n\t\t\t\tdenoiseSample(center, viewNormal, viewPos, sampleUv, denoised, totalWeight);\n\t\t\t}\n\t\t\n\t\t\tif (totalWeight > 0.) { \n\t\t\t\tdenoised /= totalWeight;\n\t\t\t}\n\t\t\tgl_FragColor = FRAGMENT_OUTPUT;\n\t\t}"};function Om(t,e,n){const i=function(t,e,n){const i=[];for(let r=0;ru?(d=1,p=0):(d=0,p=1);const f=h-d+l,m=u-p+l,g=h-1+2*l,A=u-1+2*l,v=255&a,y=255&o,_=this.perm[v+this.perm[y]]%12,x=this.perm[v+d+this.perm[y+p]]%12,w=this.perm[v+1+this.perm[y+1]]%12;let C=.5-h*h-u*u;C<0?n=0:(C*=C,n=C*C*this.dot(this.grad3[_],h,u));let E=.5-f*f-m*m;E<0?i=0:(E*=E,i=E*E*this.dot(this.grad3[x],f,m));let M=.5-g*g-A*A;return M<0?r=0:(M*=M,r=M*M*this.dot(this.grad3[w],g,A)),70*(n+i+r)}noise3d(t,e,n){let i,r,s,a;const o=(t+e+n)*(1/3),l=Math.floor(t+o),c=Math.floor(e+o),h=Math.floor(n+o),u=1/6,d=(l+c+h)*u,p=t-(l-d),f=e-(c-d),m=n-(h-d);let g,A,v,y,_,x;p>=f?f>=m?(g=1,A=0,v=0,y=1,_=1,x=0):p>=m?(g=1,A=0,v=0,y=1,_=0,x=1):(g=0,A=0,v=1,y=1,_=0,x=1):fx?32:0)+(_>w?16:0)+(x>w?8:0)+(_>C?4:0)+(x>C?2:0)+(w>C?1:0),M=s[E][0]>=3?1:0,S=s[E][1]>=3?1:0,b=s[E][2]>=3?1:0,I=s[E][3]>=3?1:0,T=s[E][0]>=2?1:0,B=s[E][1]>=2?1:0,R=s[E][2]>=2?1:0,D=s[E][3]>=2?1:0,P=s[E][0]>=1?1:0,L=s[E][1]>=1?1:0,U=s[E][2]>=1?1:0,N=s[E][3]>=1?1:0,F=_-M+l,O=x-S+l,k=w-b+l,Q=C-I+l,z=_-T+2*l,G=x-B+2*l,H=w-R+2*l,V=C-D+2*l,W=_-P+3*l,j=x-L+3*l,q=w-U+3*l,X=C-N+3*l,Y=_-1+4*l,J=x-1+4*l,K=w-1+4*l,Z=C-1+4*l,$=255&m,tt=255&g,et=255&A,nt=255&v,it=a[$+a[tt+a[et+a[nt]]]]%32,rt=a[$+M+a[tt+S+a[et+b+a[nt+I]]]]%32,st=a[$+T+a[tt+B+a[et+R+a[nt+D]]]]%32,at=a[$+P+a[tt+L+a[et+U+a[nt+N]]]]%32,ot=a[$+1+a[tt+1+a[et+1+a[nt+1]]]]%32;let lt=.6-_*_-x*x-w*w-C*C;lt<0?c=0:(lt*=lt,c=lt*lt*this.dot4(r[it],_,x,w,C));let ct=.6-F*F-O*O-k*k-Q*Q;ct<0?h=0:(ct*=ct,h=ct*ct*this.dot4(r[rt],F,O,k,Q));let ht=.6-z*z-G*G-H*H-V*V;ht<0?u=0:(ht*=ht,u=ht*ht*this.dot4(r[st],z,G,H,V));let ut=.6-W*W-j*j-q*q-X*X;ut<0?d=0:(ut*=ut,d=ut*ut*this.dot4(r[at],W,j,q,X));let dt=.6-Y*Y-J*J-K*K-Z*Z;return dt<0?p=0:(dt*=dt,p=dt*dt*this.dot4(r[ot],Y,J,K,Z)),27*(c+h+u+d+p)}}class Qm extends Am{constructor(t,e,n,i,r,s,a){super(),this.width=void 0!==n?n:512,this.height=void 0!==i?i:512,this.clear=!0,this.camera=e,this.scene=t,this.output=0,this._renderGBuffer=!0,this._visibilityCache=new Map,this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=function(t=5){const e=Math.floor(t)%2==0?Math.floor(t)+1:Math.floor(t),n=function(t){const e=Math.floor(t)%2==0?Math.floor(t)+1:Math.floor(t),n=e*e,i=Array(n).fill(0);let r=Math.floor(e/2),s=e-1;for(let t=1;t<=n;)-1===r&&s===e?(s=e-2,r=0):(s===e&&(s=0),r<0&&(r=e-1)),0===i[r*e+s]?(i[r*e+s]=t++,s++,r--):(s-=2,r++);return i}(e),i=n.length,r=new Uint8Array(4*i);for(let t=0;t\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 invSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float gaussianCoefficients[KERNEL_RADIUS];\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tfloat weightSum = gaussianCoefficients[0];\n\t\t\t\t\tvec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;\n\t\t\t\t\tfor( int i = 1; i < KERNEL_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = float(i);\n\t\t\t\t\t\tfloat w = gaussianCoefficients[i];\n\t\t\t\t\t\tvec2 uvOffset = direction * invSize * x;\n\t\t\t\t\t\tvec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;\n\t\t\t\t\t\tvec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;\n\t\t\t\t\t\tdiffuseSum += (sample1 + sample2) * w;\n\t\t\t\t\t\tweightSum += 2.0 * w;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n\t\t\t\t}"})}getCompositeMaterial(t){return new ra({defines:{NUM_MIPS:t},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\t\t\t\tuniform sampler2D blurTexture1;\n\t\t\t\tuniform sampler2D blurTexture2;\n\t\t\t\tuniform sampler2D blurTexture3;\n\t\t\t\tuniform sampler2D blurTexture4;\n\t\t\t\tuniform sampler2D blurTexture5;\n\t\t\t\tuniform float bloomStrength;\n\t\t\t\tuniform float bloomRadius;\n\t\t\t\tuniform float bloomFactors[NUM_MIPS];\n\t\t\t\tuniform vec3 bloomTintColors[NUM_MIPS];\n\n\t\t\t\tfloat lerpBloomFactor(const in float factor) {\n\t\t\t\t\tfloat mirrorFactor = 1.2 - factor;\n\t\t\t\t\treturn mix(factor, mirrorFactor, bloomRadius);\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tgl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );\n\t\t\t\t}"})}}Gm.BlurDirectionX=new hi(1,0),Gm.BlurDirectionY=new hi(0,1);const Hm={name:"SobelOperatorShader",uniforms:{tDiffuse:{value:null},resolution:{value:new hi}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform vec2 resolution;\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec2 texel = vec2( 1.0 / resolution.x, 1.0 / resolution.y );\n\n\t\t// kernel definition (in glsl matrices are filled in column-major order)\n\n\t\t\tconst mat3 Gx = mat3( -1, -2, -1, 0, 0, 0, 1, 2, 1 ); // x direction kernel\n\t\t\tconst mat3 Gy = mat3( -1, 0, 1, -2, 0, 2, -1, 0, 1 ); // y direction kernel\n\n\t\t// fetch the 3x3 neighbourhood of a fragment\n\n\t\t// first column\n\n\t\t\tfloat tx0y0 = texture2D( tDiffuse, vUv + texel * vec2( -1, -1 ) ).r;\n\t\t\tfloat tx0y1 = texture2D( tDiffuse, vUv + texel * vec2( -1, 0 ) ).r;\n\t\t\tfloat tx0y2 = texture2D( tDiffuse, vUv + texel * vec2( -1, 1 ) ).r;\n\n\t\t// second column\n\n\t\t\tfloat tx1y0 = texture2D( tDiffuse, vUv + texel * vec2( 0, -1 ) ).r;\n\t\t\tfloat tx1y1 = texture2D( tDiffuse, vUv + texel * vec2( 0, 0 ) ).r;\n\t\t\tfloat tx1y2 = texture2D( tDiffuse, vUv + texel * vec2( 0, 1 ) ).r;\n\n\t\t// third column\n\n\t\t\tfloat tx2y0 = texture2D( tDiffuse, vUv + texel * vec2( 1, -1 ) ).r;\n\t\t\tfloat tx2y1 = texture2D( tDiffuse, vUv + texel * vec2( 1, 0 ) ).r;\n\t\t\tfloat tx2y2 = texture2D( tDiffuse, vUv + texel * vec2( 1, 1 ) ).r;\n\n\t\t// gradient value in x direction\n\n\t\t\tfloat valueGx = Gx[0][0] * tx0y0 + Gx[1][0] * tx1y0 + Gx[2][0] * tx2y0 +\n\t\t\t\tGx[0][1] * tx0y1 + Gx[1][1] * tx1y1 + Gx[2][1] * tx2y1 +\n\t\t\t\tGx[0][2] * tx0y2 + Gx[1][2] * tx1y2 + Gx[2][2] * tx2y2;\n\n\t\t// gradient value in y direction\n\n\t\t\tfloat valueGy = Gy[0][0] * tx0y0 + Gy[1][0] * tx1y0 + Gy[2][0] * tx2y0 +\n\t\t\t\tGy[0][1] * tx0y1 + Gy[1][1] * tx1y1 + Gy[2][1] * tx2y1 +\n\t\t\t\tGy[0][2] * tx0y2 + Gy[1][2] * tx1y2 + Gy[2][2] * tx2y2;\n\n\t\t// magnitude of the total gradient\n\n\t\t\tfloat G = sqrt( ( valueGx * valueGx ) + ( valueGy * valueGy ) );\n\n\t\t\tgl_FragColor = vec4( vec3( G ), 1 );\n\n\t\t}"},Vm={name:"SSRShader",defines:{MAX_STEP:0,PERSPECTIVE_CAMERA:!0,DISTANCE_ATTENUATION:!0,FRESNEL:!0,INFINITE_THICK:!1,SELECTIVE:!1},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tMetalness:{value:null},tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null},resolution:{value:new hi},cameraProjectionMatrix:{value:new Ar},cameraInverseProjectionMatrix:{value:new Ar},opacity:{value:.5},maxDistance:{value:180},cameraRange:{value:0},thickness:{value:.018}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}\n\n\t",fragmentShader:'\n\t\t// precision highp float;\n\t\tprecision highp sampler2D;\n\t\tvarying vec2 vUv;\n\t\tuniform sampler2D tDepth;\n\t\tuniform sampler2D tNormal;\n\t\tuniform sampler2D tMetalness;\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform float cameraRange;\n\t\tuniform vec2 resolution;\n\t\tuniform float opacity;\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform float maxDistance;\n\t\tuniform float thickness;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraInverseProjectionMatrix;\n\t\t#include \n\t\tfloat pointToLineDistance(vec3 x0, vec3 x1, vec3 x2) {\n\t\t\t//x0: point, x1: linePointA, x2: linePointB\n\t\t\t//https://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html\n\t\t\treturn length(cross(x0-x1,x0-x2))/length(x2-x1);\n\t\t}\n\t\tfloat pointPlaneDistance(vec3 point,vec3 planePoint,vec3 planeNormal){\n\t\t\t// https://mathworld.wolfram.com/Point-PlaneDistance.html\n\t\t\t//// https://en.wikipedia.org/wiki/Plane_(geometry)\n\t\t\t//// http://paulbourke.net/geometry/pointlineplane/\n\t\t\tfloat a=planeNormal.x,b=planeNormal.y,c=planeNormal.z;\n\t\t\tfloat x0=point.x,y0=point.y,z0=point.z;\n\t\t\tfloat x=planePoint.x,y=planePoint.y,z=planePoint.z;\n\t\t\tfloat d=-(a*x+b*y+c*z);\n\t\t\tfloat distance=(a*x0+b*y0+c*z0+d)/sqrt(a*a+b*b+c*c);\n\t\t\treturn distance;\n\t\t}\n\t\tfloat getDepth( const in vec2 uv ) {\n\t\t\treturn texture2D( tDepth, uv ).x;\n\t\t}\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#ifdef PERSPECTIVE_CAMERA\n\t\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\t\tvec3 getViewPosition( const in vec2 uv, const in float depth/*clip space*/, const in float clipW ) {\n\t\t\tvec4 clipPosition = vec4( ( vec3( uv, depth ) - 0.5 ) * 2.0, 1.0 );//ndc\n\t\t\tclipPosition *= clipW; //clip\n\t\t\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;//view\n\t\t}\n\t\tvec3 getViewNormal( const in vec2 uv ) {\n\t\t\treturn unpackRGBToNormal( texture2D( tNormal, uv ).xyz );\n\t\t}\n\t\tvec2 viewPositionToXY(vec3 viewPosition){\n\t\t\tvec2 xy;\n\t\t\tvec4 clip=cameraProjectionMatrix*vec4(viewPosition,1);\n\t\t\txy=clip.xy;//clip\n\t\t\tfloat clipW=clip.w;\n\t\t\txy/=clipW;//NDC\n\t\t\txy=(xy+1.)/2.;//uv\n\t\t\txy*=resolution;//screen\n\t\t\treturn xy;\n\t\t}\n\t\tvoid main(){\n\t\t\t#ifdef SELECTIVE\n\t\t\t\tfloat metalness=texture2D(tMetalness,vUv).r;\n\t\t\t\tif(metalness==0.) return;\n\t\t\t#endif\n\n\t\t\tfloat depth = getDepth( vUv );\n\t\t\tfloat viewZ = getViewZ( depth );\n\t\t\tif(-viewZ>=cameraFar) return;\n\n\t\t\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ+cameraProjectionMatrix[3][3];\n\t\t\tvec3 viewPosition=getViewPosition( vUv, depth, clipW );\n\n\t\t\tvec2 d0=gl_FragCoord.xy;\n\t\t\tvec2 d1;\n\n\t\t\tvec3 viewNormal=getViewNormal( vUv );\n\n\t\t\t#ifdef PERSPECTIVE_CAMERA\n\t\t\t\tvec3 viewIncidentDir=normalize(viewPosition);\n\t\t\t\tvec3 viewReflectDir=reflect(viewIncidentDir,viewNormal);\n\t\t\t#else\n\t\t\t\tvec3 viewIncidentDir=vec3(0,0,-1);\n\t\t\t\tvec3 viewReflectDir=reflect(viewIncidentDir,viewNormal);\n\t\t\t#endif\n\n\t\t\tfloat maxReflectRayLen=maxDistance/dot(-viewIncidentDir,viewNormal);\n\t\t\t// dot(a,b)==length(a)*length(b)*cos(theta) // https://www.mathsisfun.com/algebra/vectors-dot-product.html\n\t\t\t// if(a.isNormalized&&b.isNormalized) dot(a,b)==cos(theta)\n\t\t\t// maxDistance/maxReflectRayLen=cos(theta)\n\t\t\t// maxDistance/maxReflectRayLen==dot(a,b)\n\t\t\t// maxReflectRayLen==maxDistance/dot(a,b)\n\n\t\t\tvec3 d1viewPosition=viewPosition+viewReflectDir*maxReflectRayLen;\n\t\t\t#ifdef PERSPECTIVE_CAMERA\n\t\t\t\tif(d1viewPosition.z>-cameraNear){\n\t\t\t\t\t//https://tutorial.math.lamar.edu/Classes/CalcIII/EqnsOfLines.aspx\n\t\t\t\t\tfloat t=(-cameraNear-viewPosition.z)/viewReflectDir.z;\n\t\t\t\t\td1viewPosition=viewPosition+viewReflectDir*t;\n\t\t\t\t}\n\t\t\t#endif\n\t\t\td1=viewPositionToXY(d1viewPosition);\n\n\t\t\tfloat totalLen=length(d1-d0);\n\t\t\tfloat xLen=d1.x-d0.x;\n\t\t\tfloat yLen=d1.y-d0.y;\n\t\t\tfloat totalStep=max(abs(xLen),abs(yLen));\n\t\t\tfloat xSpan=xLen/totalStep;\n\t\t\tfloat ySpan=yLen/totalStep;\n\t\t\tfor(float i=0.;i=totalStep) break;\n\t\t\t\tvec2 xy=vec2(d0.x+i*xSpan,d0.y+i*ySpan);\n\t\t\t\tif(xy.x<0.||xy.x>resolution.x||xy.y<0.||xy.y>resolution.y) break;\n\t\t\t\tfloat s=length(xy-d0)/totalLen;\n\t\t\t\tvec2 uv=xy/resolution;\n\n\t\t\t\tfloat d = getDepth(uv);\n\t\t\t\tfloat vZ = getViewZ( d );\n\t\t\t\tif(-vZ>=cameraFar) continue;\n\t\t\t\tfloat cW = cameraProjectionMatrix[2][3] * vZ+cameraProjectionMatrix[3][3];\n\t\t\t\tvec3 vP=getViewPosition( uv, d, cW );\n\n\t\t\t\t#ifdef PERSPECTIVE_CAMERA\n\t\t\t\t\t// https://comp.nus.edu.sg/~lowkl/publications/lowk_persp_interp_techrep.pdf\n\t\t\t\t\tfloat recipVPZ=1./viewPosition.z;\n\t\t\t\t\tfloat viewReflectRayZ=1./(recipVPZ+s*(1./d1viewPosition.z-recipVPZ));\n\t\t\t\t#else\n\t\t\t\t\tfloat viewReflectRayZ=viewPosition.z+s*(d1viewPosition.z-viewPosition.z);\n\t\t\t\t#endif\n\n\t\t\t\t// if(viewReflectRayZ>vZ) continue; // will cause "npm run make-screenshot webgl_postprocessing_ssr" high probability hang.\n\t\t\t\t// https://github.com/mrdoob/three.js/pull/21539#issuecomment-821061164\n\t\t\t\tif(viewReflectRayZ<=vZ){\n\n\t\t\t\t\tbool hit;\n\t\t\t\t\t#ifdef INFINITE_THICK\n\t\t\t\t\t\thit=true;\n\t\t\t\t\t#else\n\t\t\t\t\t\tfloat away=pointToLineDistance(vP,viewPosition,d1viewPosition);\n\n\t\t\t\t\t\tfloat minThickness;\n\t\t\t\t\t\tvec2 xyNeighbor=xy;\n\t\t\t\t\t\txyNeighbor.x+=1.;\n\t\t\t\t\t\tvec2 uvNeighbor=xyNeighbor/resolution;\n\t\t\t\t\t\tvec3 vPNeighbor=getViewPosition(uvNeighbor,d,cW);\n\t\t\t\t\t\tminThickness=vPNeighbor.x-vP.x;\n\t\t\t\t\t\tminThickness*=3.;\n\t\t\t\t\t\tfloat tk=max(minThickness,thickness);\n\n\t\t\t\t\t\thit=away<=tk;\n\t\t\t\t\t#endif\n\n\t\t\t\t\tif(hit){\n\t\t\t\t\t\tvec3 vN=getViewNormal( uv );\n\t\t\t\t\t\tif(dot(viewReflectDir,vN)>=0.) continue;\n\t\t\t\t\t\tfloat distance=pointPlaneDistance(vP,viewPosition,viewNormal);\n\t\t\t\t\t\tif(distance>maxDistance) break;\n\t\t\t\t\t\tfloat op=opacity;\n\t\t\t\t\t\t#ifdef DISTANCE_ATTENUATION\n\t\t\t\t\t\t\tfloat ratio=1.-(distance/maxDistance);\n\t\t\t\t\t\t\tfloat attenuation=ratio*ratio;\n\t\t\t\t\t\t\top=opacity*attenuation;\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#ifdef FRESNEL\n\t\t\t\t\t\t\tfloat fresnelCoe=(dot(viewIncidentDir,viewReflectDir)+1.)/2.;\n\t\t\t\t\t\t\top*=fresnelCoe;\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\tvec4 reflectColor=texture2D(tDiffuse,uv);\n\t\t\t\t\t\tgl_FragColor.xyz=reflectColor.xyz;\n\t\t\t\t\t\tgl_FragColor.a=op;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t'},Wm={PERSPECTIVE_CAMERA:1},jm={tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},qm="\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}\n\n\t",Xm="\n\n\t\tuniform sampler2D tDepth;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\n\t\tvarying vec2 vUv;\n\n\t\t#include \n\n\t\tfloat getLinearDepth( const in vec2 uv ) {\n\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\n\t\t\t\tfloat fragCoordZ = texture2D( tDepth, uv ).x;\n\t\t\t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n\t\t\t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n\n\t\t\t#else\n\n\t\t\t\treturn texture2D( tDepth, uv ).x;\n\n\t\t\t#endif\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tfloat depth = getLinearDepth( vUv );\n\t\t\tfloat d = 1.0 - depth;\n\t\t\t// d=(d-.999)*1000.;\n\t\t\tgl_FragColor = vec4( vec3( d ), 1.0 );\n\n\t\t}\n\n\t",Ym={name:"SSRBlurShader",uniforms:{tDiffuse:{value:null},resolution:{value:new hi},opacity:{value:.5}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}\n\n\t",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform vec2 resolution;\n\t\tvarying vec2 vUv;\n\t\tvoid main() {\n\t\t\t//reverse engineering from PhotoShop blur filter, then change coefficient\n\n\t\t\tvec2 texelSize = ( 1.0 / resolution );\n\n\t\t\tvec4 c=texture2D(tDiffuse,vUv);\n\n\t\t\tvec2 offset;\n\n\t\t\toffset=(vec2(-1,0))*texelSize;\n\t\t\tvec4 cl=texture2D(tDiffuse,vUv+offset);\n\n\t\t\toffset=(vec2(1,0))*texelSize;\n\t\t\tvec4 cr=texture2D(tDiffuse,vUv+offset);\n\n\t\t\toffset=(vec2(0,-1))*texelSize;\n\t\t\tvec4 cb=texture2D(tDiffuse,vUv+offset);\n\n\t\t\toffset=(vec2(0,1))*texelSize;\n\t\t\tvec4 ct=texture2D(tDiffuse,vUv+offset);\n\n\t\t\t// float coeCenter=.5;\n\t\t\t// float coeSide=.125;\n\t\t\tfloat coeCenter=.2;\n\t\t\tfloat coeSide=.2;\n\t\t\tfloat a=c.a*coeCenter+cl.a*coeSide+cr.a*coeSide+cb.a*coeSide+ct.a*coeSide;\n\t\t\tvec3 rgb=(c.rgb*c.a*coeCenter+cl.rgb*cl.a*coeSide+cr.rgb*cr.a*coeSide+cb.rgb*cb.a*coeSide+ct.rgb*ct.a*coeSide)/a;\n\t\t\tgl_FragColor=vec4(rgb,a);\n\n\t\t}\n\t"};class Jm extends Am{constructor({renderer:t,scene:e,camera:n,width:i,height:r,selects:s,bouncing:a=!1,groundReflector:o}){super(),this.width=void 0!==i?i:512,this.height=void 0!==r?r:512,this.clear=!0,this.renderer=t,this.scene=e,this.camera=n,this.groundReflector=o,this.opacity=Vm.uniforms.opacity.value,this.output=0,this.maxDistance=Vm.uniforms.maxDistance.value,this.thickness=Vm.uniforms.thickness.value,this.tempColor=new cs,this._selects=s,this.selective=Array.isArray(this._selects),Object.defineProperty(this,"selects",{get(){return this._selects},set(t){this._selects!==t&&(this._selects=t,Array.isArray(t)?(this.selective=!0,this.ssrMaterial.defines.SELECTIVE=!0,this.ssrMaterial.needsUpdate=!0):(this.selective=!1,this.ssrMaterial.defines.SELECTIVE=!1,this.ssrMaterial.needsUpdate=!0))}}),this._bouncing=a,Object.defineProperty(this,"bouncing",{get(){return this._bouncing},set(t){this._bouncing!==t&&(this._bouncing=t,this.ssrMaterial.uniforms.tDiffuse.value=t?this.prevRenderTarget.texture:this.beautyRenderTarget.texture)}}),this.blur=!0,this._distanceAttenuation=Vm.defines.DISTANCE_ATTENUATION,Object.defineProperty(this,"distanceAttenuation",{get(){return this._distanceAttenuation},set(t){this._distanceAttenuation!==t&&(this._distanceAttenuation=t,this.ssrMaterial.defines.DISTANCE_ATTENUATION=t,this.ssrMaterial.needsUpdate=!0)}}),this._fresnel=Vm.defines.FRESNEL,Object.defineProperty(this,"fresnel",{get(){return this._fresnel},set(t){this._fresnel!==t&&(this._fresnel=t,this.ssrMaterial.defines.FRESNEL=t,this.ssrMaterial.needsUpdate=!0)}}),this._infiniteThick=Vm.defines.INFINITE_THICK,Object.defineProperty(this,"infiniteThick",{get(){return this._infiniteThick},set(t){this._infiniteThick!==t&&(this._infiniteThick=t,this.ssrMaterial.defines.INFINITE_THICK=t,this.ssrMaterial.needsUpdate=!0)}});const l=new dl;l.type=Gt,l.minFilter=Tt,l.magFilter=Tt,this.beautyRenderTarget=new Ui(this.width,this.height,{minFilter:Tt,magFilter:Tt,type:jt,depthTexture:l,depthBuffer:!0}),this.prevRenderTarget=new Ui(this.width,this.height,{minFilter:Tt,magFilter:Tt}),this.normalRenderTarget=new Ui(this.width,this.height,{minFilter:Tt,magFilter:Tt,type:jt}),this.metalnessRenderTarget=new Ui(this.width,this.height,{minFilter:Tt,magFilter:Tt,type:jt}),this.ssrRenderTarget=new Ui(this.width,this.height,{minFilter:Tt,magFilter:Tt}),this.blurRenderTarget=this.ssrRenderTarget.clone(),this.blurRenderTarget2=this.ssrRenderTarget.clone(),this.ssrMaterial=new ra({defines:Object.assign({},Vm.defines,{MAX_STEP:Math.sqrt(this.width*this.width+this.height*this.height)}),uniforms:ia.clone(Vm.uniforms),vertexShader:Vm.vertexShader,fragmentShader:Vm.fragmentShader,blending:b}),this.ssrMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.ssrMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.ssrMaterial.defines.SELECTIVE=this.selective,this.ssrMaterial.needsUpdate=!0,this.ssrMaterial.uniforms.tMetalness.value=this.metalnessRenderTarget.texture,this.ssrMaterial.uniforms.tDepth.value=this.beautyRenderTarget.depthTexture,this.ssrMaterial.uniforms.cameraNear.value=this.camera.near,this.ssrMaterial.uniforms.cameraFar.value=this.camera.far,this.ssrMaterial.uniforms.thickness.value=this.thickness,this.ssrMaterial.uniforms.resolution.value.set(this.width,this.height),this.ssrMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssrMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.normalMaterial=new Gc,this.normalMaterial.blending=b,this.metalnessOnMaterial=new ps({color:"white"}),this.metalnessOffMaterial=new ps({color:"black"}),this.blurMaterial=new ra({defines:Object.assign({},Ym.defines),uniforms:ia.clone(Ym.uniforms),vertexShader:Ym.vertexShader,fragmentShader:Ym.fragmentShader}),this.blurMaterial.uniforms.tDiffuse.value=this.ssrRenderTarget.texture,this.blurMaterial.uniforms.resolution.value.set(this.width,this.height),this.blurMaterial2=new ra({defines:Object.assign({},Ym.defines),uniforms:ia.clone(Ym.uniforms),vertexShader:Ym.vertexShader,fragmentShader:Ym.fragmentShader}),this.blurMaterial2.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.blurMaterial2.uniforms.resolution.value.set(this.width,this.height),this.depthRenderMaterial=new ra({defines:Object.assign({},Wm),uniforms:ia.clone(jm),vertexShader:qm,fragmentShader:Xm,blending:b}),this.depthRenderMaterial.uniforms.tDepth.value=this.beautyRenderTarget.depthTexture,this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new ra({uniforms:ia.clone(gm.uniforms),vertexShader:gm.vertexShader,fragmentShader:gm.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:G,blendDst:H,blendEquation:P,blendSrcAlpha:G,blendDstAlpha:H,blendEquationAlpha:P}),this.fsQuad=new _m(null),this.originalClearColor=new cs}dispose(){this.beautyRenderTarget.dispose(),this.prevRenderTarget.dispose(),this.normalRenderTarget.dispose(),this.metalnessRenderTarget.dispose(),this.ssrRenderTarget.dispose(),this.blurRenderTarget.dispose(),this.blurRenderTarget2.dispose(),this.normalMaterial.dispose(),this.metalnessOnMaterial.dispose(),this.metalnessOffMaterial.dispose(),this.blurMaterial.dispose(),this.blurMaterial2.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this.fsQuad.dispose()}render(t,e){switch(t.setRenderTarget(this.beautyRenderTarget),t.clear(),this.groundReflector&&(this.groundReflector.visible=!1,this.groundReflector.doRender(this.renderer,this.scene,this.camera),this.groundReflector.visible=!0),t.render(this.scene,this.camera),this.groundReflector&&(this.groundReflector.visible=!1),this.renderOverride(t,this.normalMaterial,this.normalRenderTarget,0,0),this.selective&&this.renderMetalness(t,this.metalnessOnMaterial,this.metalnessRenderTarget,0,0),this.ssrMaterial.uniforms.opacity.value=this.opacity,this.ssrMaterial.uniforms.maxDistance.value=this.maxDistance,this.ssrMaterial.uniforms.thickness.value=this.thickness,this.renderPass(t,this.ssrMaterial,this.ssrRenderTarget),this.blur&&(this.renderPass(t,this.blurMaterial,this.blurRenderTarget),this.renderPass(t,this.blurMaterial2,this.blurRenderTarget2)),this.output){case Jm.OUTPUT.Default:this.bouncing?(this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=b,this.renderPass(t,this.copyMaterial,this.prevRenderTarget),this.blur?this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget2.texture:this.copyMaterial.uniforms.tDiffuse.value=this.ssrRenderTarget.texture,this.copyMaterial.blending=I,this.renderPass(t,this.copyMaterial,this.prevRenderTarget),this.copyMaterial.uniforms.tDiffuse.value=this.prevRenderTarget.texture,this.copyMaterial.blending=b,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e)):(this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=b,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e),this.blur?this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget2.texture:this.copyMaterial.uniforms.tDiffuse.value=this.ssrRenderTarget.texture,this.copyMaterial.blending=I,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e));break;case Jm.OUTPUT.SSR:this.blur?this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget2.texture:this.copyMaterial.uniforms.tDiffuse.value=this.ssrRenderTarget.texture,this.copyMaterial.blending=b,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e),this.bouncing&&(this.blur?this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget2.texture:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=b,this.renderPass(t,this.copyMaterial,this.prevRenderTarget),this.copyMaterial.uniforms.tDiffuse.value=this.ssrRenderTarget.texture,this.copyMaterial.blending=I,this.renderPass(t,this.copyMaterial,this.prevRenderTarget));break;case Jm.OUTPUT.Beauty:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=b,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case Jm.OUTPUT.Depth:this.renderPass(t,this.depthRenderMaterial,this.renderToScreen?null:e);break;case Jm.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=b,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case Jm.OUTPUT.Metalness:this.copyMaterial.uniforms.tDiffuse.value=this.metalnessRenderTarget.texture,this.copyMaterial.blending=b,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;default:console.warn("THREE.SSRPass: Unknown output type.")}}renderPass(t,e,n,i,r){this.originalClearColor.copy(t.getClearColor(this.tempColor));const s=t.getClearAlpha(this.tempColor),a=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.fsQuad.material=e,this.fsQuad.render(t),t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}renderOverride(t,e,n,i,r){this.originalClearColor.copy(t.getClearColor(this.tempColor));const s=t.getClearAlpha(this.tempColor),a=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,i=e.clearColor||i,r=e.clearAlpha||r,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.scene.overrideMaterial=e,t.render(this.scene,this.camera),this.scene.overrideMaterial=null,t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}renderMetalness(t,e,n,i,r){this.originalClearColor.copy(t.getClearColor(this.tempColor));const s=t.getClearAlpha(this.tempColor),a=t.autoClear,o=this.scene.background,l=this.scene.fog;t.setRenderTarget(n),t.autoClear=!1,this.scene.background=null,this.scene.fog=null,i=e.clearColor||i,r=e.clearAlpha||r,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.scene.traverseVisible((t=>{t._SSRPassBackupMaterial=t.material,this._selects.includes(t)?t.material=this.metalnessOnMaterial:t.material=this.metalnessOffMaterial})),t.render(this.scene,this.camera),this.scene.traverseVisible((t=>{t.material=t._SSRPassBackupMaterial})),t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s),this.scene.background=o,this.scene.fog=l}setSize(t,e){this.width=t,this.height=e,this.ssrMaterial.defines.MAX_STEP=Math.sqrt(t*t+e*e),this.ssrMaterial.needsUpdate=!0,this.beautyRenderTarget.setSize(t,e),this.prevRenderTarget.setSize(t,e),this.ssrRenderTarget.setSize(t,e),this.normalRenderTarget.setSize(t,e),this.metalnessRenderTarget.setSize(t,e),this.blurRenderTarget.setSize(t,e),this.blurRenderTarget2.setSize(t,e),this.ssrMaterial.uniforms.resolution.value.set(t,e),this.ssrMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssrMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.blurMaterial.uniforms.resolution.value.set(t,e),this.blurMaterial2.uniforms.resolution.value.set(t,e)}}Jm.OUTPUT={Default:0,SSR:1,Beauty:3,Depth:4,Normal:5,Metalness:7};const Km={name:"BokehShader",defines:{DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tColor:{value:null},tDepth:{value:null},focus:{value:1},aspect:{value:1},aperture:{value:.025},maxblur:{value:.01},nearClip:{value:1},farClip:{value:1e3}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\t#include \n\n\t\tvarying vec2 vUv;\n\n\t\tuniform sampler2D tColor;\n\t\tuniform sampler2D tDepth;\n\n\t\tuniform float maxblur; // max blur amount\n\t\tuniform float aperture; // aperture - bigger values for shallower depth of field\n\n\t\tuniform float nearClip;\n\t\tuniform float farClip;\n\n\t\tuniform float focus;\n\t\tuniform float aspect;\n\n\t\t#include \n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\t#if DEPTH_PACKING == 1\n\t\t\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );\n\t\t\t#else\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, nearClip, farClip );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, nearClip, farClip );\n\t\t\t#endif\n\t\t}\n\n\n\t\tvoid main() {\n\n\t\t\tvec2 aspectcorrect = vec2( 1.0, aspect );\n\n\t\t\tfloat viewZ = getViewZ( getDepth( vUv ) );\n\n\t\t\tfloat factor = ( focus + viewZ ); // viewZ is <= 0, so this is a difference equation\n\n\t\t\tvec2 dofblur = vec2 ( clamp( factor * aperture, -maxblur, maxblur ) );\n\n\t\t\tvec2 dofblur9 = dofblur * 0.9;\n\t\t\tvec2 dofblur7 = dofblur * 0.7;\n\t\t\tvec2 dofblur4 = dofblur * 0.4;\n\n\t\t\tvec4 col = vec4( 0.0 );\n\n\t\t\tcol += texture2D( tColor, vUv.xy );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur );\n\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur9 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur9 );\n\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur7 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur7 );\n\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.4, 0.0 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur4 );\n\t\t\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur4 );\n\n\t\t\tgl_FragColor = col / 41.0;\n\t\t\tgl_FragColor.a = 1.0;\n\n\t\t}"},Zm=new Ar;class $m{constructor(t){t=t||{},this.zNear=!0===t.webGL?-1:0,this.vertices={near:[new zi,new zi,new zi,new zi],far:[new zi,new zi,new zi,new zi]},void 0!==t.projectionMatrix&&this.setFromProjectionMatrix(t.projectionMatrix,t.maxFar||1e4)}setFromProjectionMatrix(t,e){const n=this.zNear,i=0===t.elements[11];return Zm.copy(t).invert(),this.vertices.near[0].set(1,1,n),this.vertices.near[1].set(1,-1,n),this.vertices.near[2].set(-1,-1,n),this.vertices.near[3].set(-1,1,n),this.vertices.near.forEach((function(t){t.applyMatrix4(Zm)})),this.vertices.far[0].set(1,1,1),this.vertices.far[1].set(1,-1,1),this.vertices.far[2].set(-1,-1,1),this.vertices.far[3].set(-1,1,1),this.vertices.far.forEach((function(t){t.applyMatrix4(Zm);const n=Math.abs(t.z);i?t.z*=Math.min(e/n,1):t.multiplyScalar(Math.min(e/n,1))})),this.vertices}split(t,e){for(;t.length>e.length;)e.push(new $m);e.length=t.length;for(let n=0;n 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\t// Iridescence F0 approximation\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\n\nIncidentLight directLight;\n\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tpointLight = pointLights[ i ];\n\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tSpotLight spotLight;\n \tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tspotLight = spotLights[ i ];\n\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\n \t\t// spot lights are ordered [shadows with maps, shadows without maps, maps without shadows, none]\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) && defined( USE_CSM ) && defined( CSM_CASCADES )\n\n\tDirectionalLight directionalLight;\n\tfloat linearDepth = (vViewPosition.z) / (shadowFar - cameraNear);\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\n\t#if defined( USE_SHADOWMAP ) && defined( CSM_FADE )\n\t\tvec2 cascade;\n\t\tfloat cascadeCenter;\n\t\tfloat closestEdge;\n\t\tfloat margin;\n\t\tfloat csmx;\n\t\tfloat csmy;\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\t\tdirectionalLight = directionalLights[ i ];\n\t\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\n\t\t\t#if ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\t\t\t// NOTE: Depth gets larger away from the camera.\n\t\t\t\t// cascade.x is closer, cascade.y is further\n\t\t\t\tcascade = CSM_cascades[ i ];\n\t\t\t\tcascadeCenter = ( cascade.x + cascade.y ) / 2.0;\n\t\t\t\tclosestEdge = linearDepth < cascadeCenter ? cascade.x : cascade.y;\n\t\t\t\tmargin = 0.25 * pow( closestEdge, 2.0 );\n\t\t\t\tcsmx = cascade.x - margin / 2.0;\n\t\t\t\tcsmy = cascade.y + margin / 2.0;\n\t\t\t\tif( linearDepth >= csmx && ( linearDepth < csmy || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 ) ) {\n\n\t\t\t\t\tfloat dist = min( linearDepth - csmx, csmy - linearDepth );\n\t\t\t\t\tfloat ratio = clamp( dist / margin, 0.0, 1.0 );\n\n\t\t\t\t\tvec3 prevColor = directLight.color;\n\t\t\t\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\t\t\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n\t\t\t\t\tbool shouldFadeLastCascade = UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth > cascadeCenter;\n\t\t\t\t\tdirectLight.color = mix( prevColor, directLight.color, shouldFadeLastCascade ? ratio : 1.0 );\n\n\t\t\t\t\tReflectedLight prevLight = reflectedLight;\n\t\t\t\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t\t\t\t\tbool shouldBlend = UNROLLED_LOOP_INDEX != CSM_CASCADES - 1 || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth < cascadeCenter;\n\t\t\t\t\tfloat blendRatio = shouldBlend ? ratio : 1.0;\n\n\t\t\t\t\treflectedLight.directDiffuse = mix( prevLight.directDiffuse, reflectedLight.directDiffuse, blendRatio );\n\t\t\t\t\treflectedLight.directSpecular = mix( prevLight.directSpecular, reflectedLight.directSpecular, blendRatio );\n\t\t\t\t\treflectedLight.indirectDiffuse = mix( prevLight.indirectDiffuse, reflectedLight.indirectDiffuse, blendRatio );\n\t\t\t\t\treflectedLight.indirectSpecular = mix( prevLight.indirectSpecular, reflectedLight.indirectSpecular, blendRatio );\n\n\t\t\t\t}\n\t\t\t#endif\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#elif defined (USE_SHADOWMAP)\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\t\tdirectionalLight = directionalLights[ i ];\n\t\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\n\t\t\t#if ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\n\t\t\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\t\t\tif(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y) directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n\t\t\t\tif(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && (linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1)) RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t\t\t#endif\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#elif ( NUM_DIR_LIGHT_SHADOWS > 0 )\n\t\t// note: no loop here - all CSM lights are in fact one light only\n\t\tgetDirectionalLightInfo( directionalLights[0], directLight );\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t#endif\n\n\t#if ( NUM_DIR_LIGHTS > NUM_DIR_LIGHT_SHADOWS)\n\t\t// compute the lights not casting shadows (if any)\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = NUM_DIR_LIGHT_SHADOWS; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\t\tdirectionalLight = directionalLights[ i ];\n\n\t\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\n\t\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#endif\n\n#endif\n\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) && !defined( USE_CSM ) && !defined( CSM_CASCADES )\n\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tdirectionalLight = directionalLights[ i ];\n\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n\tRectAreaLight rectAreaLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if defined( RE_IndirectDiffuse )\n\n\tvec3 iblIrradiance = vec3( 0.0 );\n\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n\t#if defined( USE_LIGHT_PROBES )\n\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\n\t#endif\n\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#endif\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n\n#endif\n",lights_pars_begin:"\n#if defined( USE_CSM ) && defined( CSM_CASCADES )\nuniform vec2 CSM_cascades[CSM_CASCADES];\nuniform float cameraNear;\nuniform float shadowFar;\n#endif\n\t"+Od.lights_pars_begin},eg=new Ar,ng=new $m({webGL:!0}),ig=new zi,rg=new Vi,sg=[],ag=[],og=new Ar,lg=new Ar,cg=new zi(0,1,0),hg={type:"change"},ug={type:"start"},dg={type:"end"},pg=new gr,fg=new go,mg=Math.cos(70*ci.DEG2RAD),gg=new zi,Ag=2*Math.PI,vg=-1,yg=1e-6;function _g(t){!1!==this.enabled&&(0===this._pointers.length&&(this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),this._isTrackingPointer(t)||(this._addPointer(t),"touch"===t.pointerType?this._onTouchStart(t):this._onMouseDown(t)))}function xg(t){!1!==this.enabled&&("touch"===t.pointerType?this._onTouchMove(t):this._onMouseMove(t))}function wg(t){switch(this._removePointer(t),this._pointers.length){case 0:this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(dg),this.state=vg;break;case 1:const e=this._pointers[0],n=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:n.x,pageY:n.y})}}function Cg(t){let e;switch(t.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case f.DOLLY:if(!1===this.enableZoom)return;this._handleMouseDownDolly(t),this.state=1;break;case f.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===this.enablePan)return;this._handleMouseDownPan(t),this.state=2}else{if(!1===this.enableRotate)return;this._handleMouseDownRotate(t),this.state=0}break;case f.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===this.enableRotate)return;this._handleMouseDownRotate(t),this.state=0}else{if(!1===this.enablePan)return;this._handleMouseDownPan(t),this.state=2}break;default:this.state=vg}this.state!==vg&&this.dispatchEvent(ug)}function Eg(t){switch(this.state){case 0:if(!1===this.enableRotate)return;this._handleMouseMoveRotate(t);break;case 1:if(!1===this.enableZoom)return;this._handleMouseMoveDolly(t);break;case 2:if(!1===this.enablePan)return;this._handleMouseMovePan(t)}}function Mg(t){!1!==this.enabled&&!1!==this.enableZoom&&this.state===vg&&(t.preventDefault(),this.dispatchEvent(ug),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(dg))}function Sg(t){!1!==this.enabled&&this._handleKeyDown(t)}function bg(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case m.ROTATE:if(!1===this.enableRotate)return;this._handleTouchStartRotate(t),this.state=3;break;case m.PAN:if(!1===this.enablePan)return;this._handleTouchStartPan(t),this.state=4;break;default:this.state=vg}break;case 2:switch(this.touches.TWO){case m.DOLLY_PAN:if(!1===this.enableZoom&&!1===this.enablePan)return;this._handleTouchStartDollyPan(t),this.state=5;break;case m.DOLLY_ROTATE:if(!1===this.enableZoom&&!1===this.enableRotate)return;this._handleTouchStartDollyRotate(t),this.state=6;break;default:this.state=vg}break;default:this.state=vg}this.state!==vg&&this.dispatchEvent(ug)}function Ig(t){switch(this._trackPointer(t),this.state){case 3:if(!1===this.enableRotate)return;this._handleTouchMoveRotate(t),this.update();break;case 4:if(!1===this.enablePan)return;this._handleTouchMovePan(t),this.update();break;case 5:if(!1===this.enableZoom&&!1===this.enablePan)return;this._handleTouchMoveDollyPan(t),this.update();break;case 6:if(!1===this.enableZoom&&!1===this.enableRotate)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=vg}}function Tg(t){!1!==this.enabled&&t.preventDefault()}function Bg(t){"Control"===t.key&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Rg(t){"Control"===t.key&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Dg(t,e=!1){const n=null!==t[0].index,i=new Set(Object.keys(t[0].attributes)),r=new Set(Object.keys(t[0].morphAttributes)),s={},a={},o=t[0].morphTargetsRelative,l=new ks;let c=0;for(let h=0;h=2.0 are supported.")));const l=new SA(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t=0&&void 0===a[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}l.setExtensions(s),l.setPlugins(a),l.parse(n,i)}parseAsync(t,e){const n=this;return new Promise((function(i,r){n.parse(t,e,i,r)}))}}function Fg(){let t={};return{get:function(e){return t[e]},add:function(e,n){t[e]=n},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const Og={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class kg{constructor(t){this.parser=t,this.name=Og.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let n=0,i=e.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,s)}}class $g{constructor(t){this.parser=t,this.name=Og.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const t=n.options.manager.getHandler(a.uri);null!==t&&(o=t)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(t,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class tA{constructor(t){this.parser=t,this.name=Og.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const t=n.options.manager.getHandler(a.uri);null!==t&&(o=t)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(t,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class eA{constructor(t){this.name=Og.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){const t=n.extensions[this.name],i=this.parser.getDependency("buffer",t.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then((function(e){const n=t.byteOffset||0,i=t.byteLength||0,s=t.count,a=t.byteStride,o=new Uint8Array(e,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,a,o,t.mode,t.filter).then((function(t){return t.buffer})):r.ready.then((function(){const e=new ArrayBuffer(s*a);return r.decodeGltfBuffer(new Uint8Array(e),s,a,o,t.mode,t.filter),e}))}))}return null}}class nA{constructor(t){this.name=Og.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,n=e.nodes[t];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const i=e.meshes[n.mesh];for(const t of i.primitives)if(t.mode!==uA.TRIANGLES&&t.mode!==uA.TRIANGLE_STRIP&&t.mode!==uA.TRIANGLE_FAN&&void 0!==t.mode)return null;const r=n.extensions[this.name].attributes,s=[],a={};for(const t in r)s.push(this.parser.getDependency("accessor",r[t]).then((e=>(a[t]=e,a[t]))));return s.length<1?null:(s.push(this.parser.createNodeMesh(t)),Promise.all(s).then((t=>{const e=t.pop(),n=e.isGroup?e.children:[e],i=t[0].count,r=[];for(const t of n){const e=new Ar,n=new zi,s=new Qi,o=new zi(1,1,1),l=new uo(t.geometry,t.material,i);for(let t=0;t-1,s=r?t.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||n&&i<17||r&&s<98?this.textureLoader=new Sh(this.options.manager):this.textureLoader=new eu(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new _h(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(t){return t._markDefs&&t._markDefs()})),Promise.all(this._invokeAll((function(t){return t.beforeRoot&&t.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(e){const s={scene:e[0][i.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:i.asset,parser:n,userData:{}};return yA(r,s,i),_A(s,i),Promise.all(n._invokeAll((function(t){return t.afterRoot&&t.afterRoot(s)}))).then((function(){for(const t of s.scenes)t.updateMatrixWorld();t(s)}))})).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=e.length;n{const n=this.associations.get(t);null!=n&&this.associations.set(e,n);for(const[n,i]of t.children.entries())r(i,e.children[n])};return r(n,i),i.name+="_instance_"+t.uses[e]++,i}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let n=0;n=2&&p.setY(e,h[t*s+1]),s>=3&&p.setZ(e,h[t*s+2]),s>=4&&p.setW(e,h[t*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=u}return p}))}loadTexture(t){const e=this.json,n=this.options,i=e.textures[t].source,r=e.images[i];let s=this.textureLoader;if(r.uri){const t=n.manager.getHandler(r.uri);null!==t&&(s=t)}return this.loadTextureImage(t,i,s)}loadTextureImage(t,e,n){const i=this,r=this.json,s=r.textures[t],a=r.images[e],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(e,n).then((function(e){e.flipY=!1,e.name=s.name||a.name||"",""===e.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(e.name=a.uri);const n=(r.samplers||{})[s.sampler]||{};return e.magFilter=pA[n.magFilter]||Lt,e.minFilter=pA[n.minFilter]||Ft,e.wrapS=fA[n.wrapS]||St,e.wrapT=fA[n.wrapT]||St,e.generateMipmaps=!e.isCompressedTexture&&e.minFilter!==Tt&&e.minFilter!==Lt,i.associations.set(e,{textures:t}),e})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(t,e){const n=this.json,i=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then((t=>t.clone()));const r=n.images[t],s=self.URL||self.webkitURL;let a=r.uri||"",o=!1;if(void 0!==r.bufferView)a=this.getDependency("bufferView",r.bufferView).then((function(t){o=!0;const e=new Blob([t],{type:r.mimeType});return a=s.createObjectURL(e),a}));else if(void 0===r.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const l=Promise.resolve(a).then((function(t){return new Promise((function(n,r){let s=n;!0===e.isImageBitmapLoader&&(s=function(t){const e=new Di(t);e.needsUpdate=!0,n(e)}),e.load(Xh.resolveURL(t,i.path),s,void 0,r)}))})).then((function(t){var e;return!0===o&&s.revokeObjectURL(a),_A(t,r),t.userData.mimeType=r.mimeType||((e=r.uri).search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":e.search(/\.ktx2($|\?)/i)>0||0===e.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),t})).catch((function(t){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),t}));return this.sourceCache[t]=l,l}assignTexture(t,e,n,i){const r=this;return this.getDependency("texture",n.index).then((function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),r.extensions[Og.KHR_TEXTURE_TRANSFORM]){const t=void 0!==n.extensions?n.extensions[Og.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=r.associations.get(s);s=r.extensions[Og.KHR_TEXTURE_TRANSFORM].extendTexture(s,t),r.associations.set(s,e)}}return void 0!==i&&(s.colorSpace=i),t[e]=s,s}))}assignFinalMaterial(t){const e=t.geometry;let n=t.material;const i=void 0===e.attributes.tangent,r=void 0!==e.attributes.color,s=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new Zo,ds.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,e.sizeAttenuation=!1,this.cache.add(t,e)),n=e}else if(t.isLine){const t="LineBasicMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new Oo,ds.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,this.cache.add(t,e)),n=e}if(i||r||s){let t="ClonedMaterial:"+n.uuid+":";i&&(t+="derivative-tangents:"),r&&(t+="vertex-colors:"),s&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=n.clone(),r&&(e.vertexColors=!0),s&&(e.flatShading=!0),i&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(n))),n=e}t.material=n}getMaterialType(){return Oc}loadMaterial(t){const e=this,n=this.json,i=this.extensions,r=n.materials[t];let s;const a={},o=[];if((r.extensions||{})[Og.KHR_MATERIALS_UNLIT]){const t=i[Og.KHR_MATERIALS_UNLIT];s=t.getMaterialType(),o.push(t.extendParams(a,r,e))}else{const n=r.pbrMetallicRoughness||{};if(a.color=new cs(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const t=n.baseColorFactor;a.color.setRGB(t[0],t[1],t[2],un),a.opacity=t[3]}void 0!==n.baseColorTexture&&o.push(e.assignTexture(a,"map",n.baseColorTexture,hn)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(o.push(e.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),o.push(e.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),s=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),o.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,a)}))))}!0===r.doubleSided&&(a.side=S);const l=r.alphaMode||"OPAQUE";if("BLEND"===l?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,"MASK"===l&&(a.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&s!==ps&&(o.push(e.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new hi(1,1),void 0!==r.normalTexture.scale)){const t=r.normalTexture.scale;a.normalScale.set(t,t)}if(void 0!==r.occlusionTexture&&s!==ps&&(o.push(e.assignTexture(a,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(a.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&s!==ps){const t=r.emissiveFactor;a.emissive=(new cs).setRGB(t[0],t[1],t[2],un)}return void 0!==r.emissiveTexture&&s!==ps&&o.push(e.assignTexture(a,"emissiveMap",r.emissiveTexture,hn)),Promise.all(o).then((function(){const n=new s(a);return r.name&&(n.name=r.name),_A(n,r),e.associations.set(n,{materials:t}),r.extensions&&yA(i,n,r),n}))}createUniqueName(t){const e=Ru.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,n=this.extensions,i=this.primitiveCache;function r(t){return n[Og.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then((function(n){return bA(n,t,e)}))}const s=[];for(let n=0,a=t.length;n0&&xA(u,r),u.name=e.createUniqueName(r.name||"mesh_"+t),_A(u,r),h.extensions&&yA(i,u,h),e.assignFinalMaterial(u),l.push(u)}for(let n=0,i=l.length;n1?new fa:1===e.length?e[0]:new Vr,a!==e[0])for(let t=0,n=e.length;t{const e=new Map;for(const[t,n]of i.associations)(t instanceof ds||t instanceof Di)&&e.set(t,n);return t.traverse((t=>{const n=i.associations.get(t);null!=n&&e.set(t,n)})),e})(r),r}))}_createAnimationTracks(t,e,n,i,r){const s=[],a=t.name?t.name:t.uuid,o=[];let l;switch(AA[r.path]===AA.weights?t.traverse((function(t){t.morphTargetInfluences&&o.push(t.name?t.name:t.uuid)})):o.push(a),AA[r.path]){case AA.weights:l=oh;break;case AA.rotation:l=ch;break;case AA.position:case AA.scale:l=uh;break;default:l=1===n.itemSize?oh:uh}const c=void 0!==i.interpolation?vA[i.interpolation]:je,h=this._getArrayFromAccessor(n);for(let t=0,n=o.length;tt.toBlob(n,e)));let n;return"image/jpeg"===e?n=.92:"image/webp"===e&&(n=.8),t.convertToBlob({type:e,quality:n})}class VA{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r"+p}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map},this.textureUtils=null}setPlugins(t){this.plugins=t}setTextureUtils(t){this.textureUtils=t}async writeAsync(t,e,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(t),await Promise.all(this.pending);const i=this,r=i.buffers,s=i.json;n=i.options;const a=i.extensionsUsed,o=i.extensionsRequired,l=new Blob(r,{type:"application/octet-stream"}),c=Object.keys(a),h=Object.keys(o);if(c.length>0&&(s.extensionsUsed=c),h.length>0&&(s.extensionsRequired=h),s.buffers&&s.buffers.length>0&&(s.buffers[0].byteLength=l.size),!0===n.binary){const t=new FileReader;t.readAsArrayBuffer(l),t.onloadend=function(){const n=zA(t.result),i=new DataView(new ArrayBuffer(8));i.setUint32(0,n.byteLength,!0),i.setUint32(4,5130562,!0);const r=zA((a=JSON.stringify(s),(new TextEncoder).encode(a).buffer),32);var a;const o=new DataView(new ArrayBuffer(8));o.setUint32(0,r.byteLength,!0),o.setUint32(4,1313821514,!0);const l=new ArrayBuffer(12),c=new DataView(l);c.setUint32(0,1179937895,!0),c.setUint32(4,2,!0);const h=12+o.byteLength+r.byteLength+i.byteLength+n.byteLength;c.setUint32(8,h,!0);const u=new Blob([l,o,r,i,n],{type:"application/octet-stream"}),d=new FileReader;d.readAsArrayBuffer(u),d.onloadend=function(){e(d.result)}}}else if(s.buffers&&s.buffers.length>0){const t=new FileReader;t.readAsDataURL(l),t.onloadend=function(){const n=t.result;s.buffers[0].uri=n,e(s)}}else e(s)}serializeUserData(t,e){if(0===Object.keys(t.userData).length)return;const n=this.options,i=this.extensionsUsed;try{const r=JSON.parse(JSON.stringify(t.userData));if(n.includeCustomExtensions&&r.gltfExtensions){void 0===e.extensions&&(e.extensions={});for(const t in r.gltfExtensions)e.extensions[t]=r.gltfExtensions[t],i[t]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(e.extras=r)}catch(e){console.warn("THREE.GLTFExporter: userData of '"+t.name+"' won't be serialized because of JSON.stringify error - "+e.message)}}getUID(t,e=!1){if(!1===this.uids.has(t)){const e=new Map;e.set(!0,this.uid++),e.set(!1,this.uid++),this.uids.set(t,e)}return this.uids.get(t).get(e)}isNormalizedNormalAttribute(t){if(this.cache.attributesNormalized.has(t))return!1;const e=new zi;for(let n=0,i=t.count;n5e-4)return!1;return!0}createNormalizedNormalAttribute(t){const e=this.cache;if(e.attributesNormalized.has(t))return e.attributesNormalized.get(t);const n=t.clone(),i=new zi;for(let t=0,e=n.count;t4?i=t.array[r*t.itemSize+n]:(0===n?i=t.getX(r):1===n?i=t.getY(r):2===n?i=t.getZ(r):3===n&&(i=t.getW(r)),!0===t.normalized&&(i=ci.normalize(i,t.array))),5126===e?c.setFloat32(h,i,!0):5124===e?c.setInt32(h,i,!0):5125===e?c.setUint32(h,i,!0):e===DA?c.setInt16(h,i,!0):e===PA?c.setUint16(h,i,!0):e===BA?c.setInt8(h,i):e===RA&&c.setUint8(h,i),h+=a}h%o!=0&&(h+=o-h%o)}const u={buffer:this.processBuffer(c.buffer),byteOffset:this.byteOffset,byteLength:l};return void 0!==r&&(u.target=r),r===LA&&(u.byteStride=o),this.byteOffset+=l,s.bufferViews.push(u),{id:s.bufferViews.length-1,byteLength:0}}processBufferViewImage(t){const e=this,n=e.json;return n.bufferViews||(n.bufferViews=[]),new Promise((function(i){const r=new FileReader;r.readAsArrayBuffer(t),r.onloadend=function(){const t=zA(r.result),s={buffer:e.processBuffer(t),byteOffset:e.byteOffset,byteLength:t.byteLength};e.byteOffset+=t.byteLength,i(n.bufferViews.push(s)-1)}}))}processAccessor(t,e,n,i){const r=this.json;let s;if(t.array.constructor===Float32Array)s=5126;else if(t.array.constructor===Int32Array)s=5124;else if(t.array.constructor===Uint32Array)s=5125;else if(t.array.constructor===Int16Array)s=DA;else if(t.array.constructor===Uint16Array)s=PA;else if(t.array.constructor===Int8Array)s=BA;else{if(t.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+t.array.constructor.name);s=RA}if(void 0===n&&(n=0),void 0!==i&&i!==1/0||(i=t.count),0===i)return null;const a=function(t,e,n){const i={min:new Array(t.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(t.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let r=e;r4?n=t.array[r*t.itemSize+e]:(0===e?n=t.getX(r):1===e?n=t.getY(r):2===e?n=t.getZ(r):3===e&&(n=t.getW(r)),!0===t.normalized&&(n=ci.normalize(n,t.array))),i.min[e]=Math.min(i.min[e],n),i.max[e]=Math.max(i.max[e],n)}return i}(t,n,i);let o;void 0!==e&&(o=t===e.index?34963:LA);const l=this.processBufferView(t,s,n,i,o),c={bufferView:l.id,byteOffset:l.byteOffset,componentType:s,count:i,max:a.max,min:a.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[t.itemSize]};return!0===t.normalized&&(c.normalized=!0),r.accessors||(r.accessors=[]),r.accessors.push(c)-1}processImage(t,e,n,i="image/png"){if(null!==t){const r=this,s=r.cache,a=r.json,o=r.options,l=r.pending;s.images.has(t)||s.images.set(t,{});const c=s.images.get(t),h=i+":flipY/"+n.toString();if(void 0!==c[h])return c[h];a.images||(a.images=[]);const u={mimeType:i},d=GA();d.width=Math.min(t.width,o.maxTextureSize),d.height=Math.min(t.height,o.maxTextureSize);const p=d.getContext("2d",{willReadFrequently:!0});if(!0===n&&(p.translate(0,d.height),p.scale(1,-1)),void 0!==t.data){e!==$t&&console.error("GLTFExporter: Only RGBAFormat is supported.",e),(t.width>o.maxTextureSize||t.height>o.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",t);const n=new Uint8ClampedArray(t.height*t.width*4);for(let e=0;er.processBufferViewImage(t))).then((t=>{u.bufferView=t}))):void 0!==d.toDataURL?u.uri=d.toDataURL(i):l.push(HA(d,i).then((t=>(new FileReader).readAsDataURL(t))).then((t=>{u.uri=t})));const f=a.images.push(u)-1;return c[h]=f,f}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(t){const e=this.json;e.samplers||(e.samplers=[]);const n={magFilter:NA[t.magFilter],minFilter:NA[t.minFilter],wrapS:NA[t.wrapS],wrapT:NA[t.wrapT]};return e.samplers.push(n)-1}async processTextureAsync(t){const e=this.options,n=this.cache,i=this.json;if(n.textures.has(t))return n.textures.get(t);i.textures||(i.textures=[]),t instanceof ll&&(t=await this.decompressTextureAsync(t,e.maxTextureSize));let r=t.userData.mimeType;"image/webp"===r&&(r="image/png");const s={sampler:this.processSampler(t),source:this.processImage(t.image,t.format,t.flipY,r)};t.name&&(s.name=t.name),await this._invokeAllAsync((async function(e){e.writeTexture&&await e.writeTexture(t,s)}));const a=i.textures.push(s)-1;return n.textures.set(t,a),a}async processMaterialAsync(t){const e=this.cache,n=this.json;if(e.materials.has(t))return e.materials.get(t);if(t.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);const i={pbrMetallicRoughness:{}};!0!==t.isMeshStandardMaterial&&!0!==t.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const r=t.color.toArray().concat([t.opacity]);if(kA(r,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=r),t.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=t.metalness,i.pbrMetallicRoughness.roughnessFactor=t.roughness):(i.pbrMetallicRoughness.metallicFactor=0,i.pbrMetallicRoughness.roughnessFactor=1),t.metalnessMap||t.roughnessMap){const e=await this.buildMetalRoughTextureAsync(t.metalnessMap,t.roughnessMap),n={index:await this.processTextureAsync(e),texCoord:e.channel};this.applyTextureTransform(n,e),i.pbrMetallicRoughness.metallicRoughnessTexture=n}if(t.map){const e={index:await this.processTextureAsync(t.map),texCoord:t.map.channel};this.applyTextureTransform(e,t.map),i.pbrMetallicRoughness.baseColorTexture=e}if(t.emissive){const e=t.emissive;if(Math.max(e.r,e.g,e.b)>0&&(i.emissiveFactor=t.emissive.toArray()),t.emissiveMap){const e={index:await this.processTextureAsync(t.emissiveMap),texCoord:t.emissiveMap.channel};this.applyTextureTransform(e,t.emissiveMap),i.emissiveTexture=e}}if(t.normalMap){const e={index:await this.processTextureAsync(t.normalMap),texCoord:t.normalMap.channel};t.normalScale&&1!==t.normalScale.x&&(e.scale=t.normalScale.x),this.applyTextureTransform(e,t.normalMap),i.normalTexture=e}if(t.aoMap){const e={index:await this.processTextureAsync(t.aoMap),texCoord:t.aoMap.channel};1!==t.aoMapIntensity&&(e.strength=t.aoMapIntensity),this.applyTextureTransform(e,t.aoMap),i.occlusionTexture=e}t.transparent?i.alphaMode="BLEND":t.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=t.alphaTest),t.side===S&&(i.doubleSided=!0),""!==t.name&&(i.name=t.name),this.serializeUserData(t,i),await this._invokeAllAsync((async function(e){e.writeMaterialAsync&&await e.writeMaterialAsync(t,i)}));const s=n.materials.push(i)-1;return e.materials.set(t,s),s}async processMeshAsync(t){const e=this.cache,n=this.json,i=[t.geometry.uuid];if(Array.isArray(t.material))for(let e=0,n=t.material.length;e0){const n=[],i=[],r={};if(void 0!==t.morphTargetDictionary)for(const e in t.morphTargetDictionary)r[t.morphTargetDictionary[e]]=e;for(let a=0;a0&&(o.extras={},o.extras.targetNames=i)}const f=Array.isArray(t.material);if(f&&0===s.groups.length)return null;let m=!1;if(f&&null===s.index){const t=[];for(let e=0,n=s.attributes.position.count;e0&&(n.targets=h),null!==s.index){let i=this.getUID(s.index);void 0===A[t].start&&void 0===A[t].count||(i+=":"+A[t].start+":"+A[t].count),e.attributes.has(i)?n.indices=e.attributes.get(i):(n.indices=this.processAccessor(s.index,s,A[t].start,A[t].count),e.attributes.set(i,n.indices)),null===n.indices&&delete n.indices}const i=await this.processMaterialAsync(g[A[t].materialIndex]);null!==i&&(n.material=i),c.push(n)}!0===m&&s.setIndex(null),o.primitives=c,n.meshes||(n.meshes=[]),await this._invokeAllAsync((function(e){e.writeMesh&&e.writeMesh(t,o)}));const v=n.meshes.push(o)-1;return e.meshes.set(r,v),v}detectMeshQuantization(t,e){if(this.extensionsUsed[UA])return;let n;switch(e.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}e.normalized&&(n+=" normalized");const i=t.split("_",1)[0];IA[i]&&IA[i].includes(n)&&(this.extensionsUsed[UA]=!0,this.extensionsRequired[UA]=!0)}processCamera(t){const e=this.json;e.cameras||(e.cameras=[]);const n=t.isOrthographicCamera,i={type:n?"orthographic":"perspective"};return n?i.orthographic={xmag:2*t.right,ymag:2*t.top,zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near}:i.perspective={aspectRatio:t.aspect,yfov:ci.degToRad(t.fov),zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near},""!==t.name&&(i.name=t.type),e.cameras.push(i)-1}processAnimation(t,e){const n=this.json,i=this.nodeMap;n.animations||(n.animations=[]);const r=(t=TA.Utils.mergeMorphTargetTracks(t.clone(),e)).tracks,s=[],a=[];for(let t=0;t0){const e=[];for(let i=0,r=t.children.length;i0&&(r.children=e)}await this._invokeAllAsync((function(e){e.writeNode&&e.writeNode(t,r)}));const s=e.nodes.push(r)-1;return i.set(t,s),s}async processSceneAsync(t){const e=this.json,n=this.options;e.scenes||(e.scenes=[],e.scene=0);const i={};""!==t.name&&(i.name=t.name),e.scenes.push(i);const r=[];for(let e=0,i=t.children.length;e0&&(i.nodes=r),this.serializeUserData(t,i)}async processObjectsAsync(t){const e=new ya;e.name="AuxScene";for(let n=0;n0&&await this.processObjectsAsync(n);for(let t=0;t0&&(s.range=t.distance)):t.isSpotLight&&(s.type="spot",t.distance>0&&(s.range=t.distance),s.spot={},s.spot.innerConeAngle=(1-t.penumbra)*t.angle,s.spot.outerConeAngle=t.angle),void 0!==t.decay&&2!==t.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),!t.target||t.target.parent===t&&0===t.target.position.x&&0===t.target.position.y&&-1===t.target.position.z||console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),r[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},r[this.name]=!0);const a=i.extensions[this.name].lights;a.push(s),e.extensions=e.extensions||{},e.extensions[this.name]={light:a.length-1}}}class jA{constructor(t){this.writer=t,this.name="KHR_materials_unlit"}async writeMaterialAsync(t,e){if(!t.isMeshBasicMaterial)return;const n=this.writer.extensionsUsed;e.extensions=e.extensions||{},e.extensions[this.name]={},n[this.name]=!0,e.pbrMetallicRoughness.metallicFactor=0,e.pbrMetallicRoughness.roughnessFactor=.9}}class qA{constructor(t){this.writer=t,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.clearcoat)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.clearcoatFactor=t.clearcoat,t.clearcoatMap){const e={index:await n.processTextureAsync(t.clearcoatMap),texCoord:t.clearcoatMap.channel};n.applyTextureTransform(e,t.clearcoatMap),r.clearcoatTexture=e}if(r.clearcoatRoughnessFactor=t.clearcoatRoughness,t.clearcoatRoughnessMap){const e={index:await n.processTextureAsync(t.clearcoatRoughnessMap),texCoord:t.clearcoatRoughnessMap.channel};n.applyTextureTransform(e,t.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=e}if(t.clearcoatNormalMap){const e={index:await n.processTextureAsync(t.clearcoatNormalMap),texCoord:t.clearcoatNormalMap.channel};1!==t.clearcoatNormalScale.x&&(e.scale=t.clearcoatNormalScale.x),n.applyTextureTransform(e,t.clearcoatNormalMap),r.clearcoatNormalTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class XA{constructor(t){this.writer=t,this.name="KHR_materials_dispersion"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.dispersion)return;const n=this.writer.extensionsUsed,i={};i.dispersion=t.dispersion,e.extensions=e.extensions||{},e.extensions[this.name]=i,n[this.name]=!0}}class YA{constructor(t){this.writer=t,this.name="KHR_materials_iridescence"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.iridescence)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.iridescenceFactor=t.iridescence,t.iridescenceMap){const e={index:await n.processTextureAsync(t.iridescenceMap),texCoord:t.iridescenceMap.channel};n.applyTextureTransform(e,t.iridescenceMap),r.iridescenceTexture=e}if(r.iridescenceIor=t.iridescenceIOR,r.iridescenceThicknessMinimum=t.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=t.iridescenceThicknessRange[1],t.iridescenceThicknessMap){const e={index:await n.processTextureAsync(t.iridescenceThicknessMap),texCoord:t.iridescenceThicknessMap.channel};n.applyTextureTransform(e,t.iridescenceThicknessMap),r.iridescenceThicknessTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class JA{constructor(t){this.writer=t,this.name="KHR_materials_transmission"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.transmission)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.transmissionFactor=t.transmission,t.transmissionMap){const e={index:await n.processTextureAsync(t.transmissionMap),texCoord:t.transmissionMap.channel};n.applyTextureTransform(e,t.transmissionMap),r.transmissionTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class KA{constructor(t){this.writer=t,this.name="KHR_materials_volume"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.transmission)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.thicknessFactor=t.thickness,t.thicknessMap){const e={index:await n.processTextureAsync(t.thicknessMap),texCoord:t.thicknessMap.channel};n.applyTextureTransform(e,t.thicknessMap),r.thicknessTexture=e}t.attenuationDistance!==1/0&&(r.attenuationDistance=t.attenuationDistance),r.attenuationColor=t.attenuationColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class ZA{constructor(t){this.writer=t,this.name="KHR_materials_ior"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||1.5===t.ior)return;const n=this.writer.extensionsUsed,i={};i.ior=t.ior,e.extensions=e.extensions||{},e.extensions[this.name]=i,n[this.name]=!0}}class $A{constructor(t){this.writer=t,this.name="KHR_materials_specular"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||1===t.specularIntensity&&t.specularColor.equals(OA)&&!t.specularIntensityMap&&!t.specularColorMap)return;const n=this.writer,i=n.extensionsUsed,r={};if(t.specularIntensityMap){const e={index:await n.processTextureAsync(t.specularIntensityMap),texCoord:t.specularIntensityMap.channel};n.applyTextureTransform(e,t.specularIntensityMap),r.specularTexture=e}if(t.specularColorMap){const e={index:await n.processTextureAsync(t.specularColorMap),texCoord:t.specularColorMap.channel};n.applyTextureTransform(e,t.specularColorMap),r.specularColorTexture=e}r.specularFactor=t.specularIntensity,r.specularColorFactor=t.specularColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class tv{constructor(t){this.writer=t,this.name="KHR_materials_sheen"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0==t.sheen)return;const n=this.writer,i=n.extensionsUsed,r={};if(t.sheenRoughnessMap){const e={index:await n.processTextureAsync(t.sheenRoughnessMap),texCoord:t.sheenRoughnessMap.channel};n.applyTextureTransform(e,t.sheenRoughnessMap),r.sheenRoughnessTexture=e}if(t.sheenColorMap){const e={index:await n.processTextureAsync(t.sheenColorMap),texCoord:t.sheenColorMap.channel};n.applyTextureTransform(e,t.sheenColorMap),r.sheenColorTexture=e}r.sheenRoughnessFactor=t.sheenRoughness,r.sheenColorFactor=t.sheenColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class ev{constructor(t){this.writer=t,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0==t.anisotropy)return;const n=this.writer,i=n.extensionsUsed,r={};if(t.anisotropyMap){const e={index:await n.processTextureAsync(t.anisotropyMap)};n.applyTextureTransform(e,t.anisotropyMap),r.anisotropyTexture=e}r.anisotropyStrength=t.anisotropy,r.anisotropyRotation=t.anisotropyRotation,e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class nv{constructor(t){this.writer=t,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(t,e){if(!t.isMeshStandardMaterial||1===t.emissiveIntensity)return;const n=this.writer.extensionsUsed,i={};i.emissiveStrength=t.emissiveIntensity,e.extensions=e.extensions||{},e.extensions[this.name]=i,n[this.name]=!0}}class iv{constructor(t){this.writer=t,this.name="EXT_materials_bump"}async writeMaterialAsync(t,e){if(!t.isMeshStandardMaterial||1===t.bumpScale&&!t.bumpMap)return;const n=this.writer,i=n.extensionsUsed,r={};if(t.bumpMap){const e={index:await n.processTextureAsync(t.bumpMap),texCoord:t.bumpMap.channel};n.applyTextureTransform(e,t.bumpMap),r.bumpTexture=e}r.bumpFactor=t.bumpScale,e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}}class rv{constructor(t){this.writer=t,this.name="EXT_mesh_gpu_instancing"}writeNode(t,e){if(!t.isInstancedMesh)return;const n=this.writer,i=t,r=new Float32Array(3*i.count),s=new Float32Array(4*i.count),a=new Float32Array(3*i.count),o=new Ar,l=new zi,c=new Qi,h=new zi;for(let t=0;tt.times[t.times.length-1]){if(Math.abs(t.times[t.times.length-1]-e)e){r.set(t.times.slice(0,l+1),0),r[l+1]=e,r.set(t.times.slice(l+1),l+2),s.set(t.values.slice(0,(l+1)*i),0),s.set(a.evaluate(e),(l+1)*i),s.set(t.values.slice((l+1)*i),(l+2)*i),o=l+1;break}}return t.times=r,t.values=s,o},mergeMorphTargetTracks:function(t,e){const n=[],i={},r=t.tracks;for(let t=0;t{const e=t.draco,a=new e.Decoder;try{const t=function(t,e,i,r){const s=r.attributeIDs,a=r.attributeTypes;let o,l;const c=e.GetEncodedGeometryType(i);if(c===t.TRIANGULAR_MESH)o=new t.Mesh,l=e.DecodeArrayToMesh(i,i.byteLength,o);else{if(c!==t.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new t.PointCloud,l=e.DecodeArrayToPointCloud(i,i.byteLength,o)}if(!l.ok()||0===o.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const h={index:null,attributes:[]};for(const i in s){const l=self[a[i]];let c,u;if(r.useUniqueIDs)u=s[i],c=e.GetAttributeByUniqueId(o,u);else{if(u=e.GetAttributeId(o,t[s[i]]),-1===u)continue;c=e.GetAttribute(o,u)}const d=n(t,e,o,i,l,c);"color"===i&&(d.vertexColorSpace=r.vertexColorSpace),h.attributes.push(d)}return c===t.TRIANGULAR_MESH&&(h.index=function(t,e,n){const i=3*n.num_faces(),r=4*i,s=t._malloc(r);e.GetTrianglesUInt32Array(n,r,s);const a=new Uint32Array(t.HEAPF32.buffer,s,i).slice();return t._free(s),{array:a,itemSize:1}}(t,e,o)),t.destroy(o),h}(e,a,new Int8Array(i),s),o=t.attributes.map((t=>t.array.buffer));t.index&&o.push(t.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:t},o)}catch(t){console.error(t),self.postMessage({type:"error",id:r.id,error:t.message})}finally{e.destroy(a)}}))}}}var ov=Uint8Array,lv=Uint16Array,cv=Int32Array,hv=new ov([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),uv=new ov([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),dv=new ov([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),pv=function(t,e){for(var n=new lv(31),i=0;i<31;++i)n[i]=e+=1<>1|(21845&xv)<<1;wv=(61680&(wv=(52428&wv)>>2|(13107&wv)<<2))>>4|(3855&wv)<<4,_v[xv]=((65280&wv)>>8|(255&wv)<<8)>>1}var Cv=function(t,e,n){for(var i=t.length,r=0,s=new lv(e);r>l]=c}else for(a=new lv(i),r=0;r>15-t[r]);return a},Ev=new ov(288);for(xv=0;xv<144;++xv)Ev[xv]=8;for(xv=144;xv<256;++xv)Ev[xv]=9;for(xv=256;xv<280;++xv)Ev[xv]=7;for(xv=280;xv<288;++xv)Ev[xv]=8;var Mv=new ov(32);for(xv=0;xv<32;++xv)Mv[xv]=5;var Sv=Cv(Ev,9,0),bv=Cv(Ev,9,1),Iv=Cv(Mv,5,0),Tv=Cv(Mv,5,1),Bv=function(t){for(var e=t[0],n=1;ne&&(e=t[n]);return e},Rv=function(t,e,n){var i=e/8|0;return(t[i]|t[i+1]<<8)>>(7&e)&n},Dv=function(t,e){var n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(7&e)},Pv=function(t){return(t+7)/8|0},Lv=function(t,e,n){return(null==e||e<0)&&(e=0),(null==n||n>t.length)&&(n=t.length),new ov(t.subarray(e,n))},Uv=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Nv=function(t,e,n){var i=new Error(e||Uv[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,Nv),!n)throw i;return i},Fv=function(t,e,n){n<<=7&e;var i=e/8|0;t[i]|=n,t[i+1]|=n>>8},Ov=function(t,e,n){n<<=7&e;var i=e/8|0;t[i]|=n,t[i+1]|=n>>8,t[i+2]|=n>>16},kv=function(t,e){for(var n=[],i=0;id&&(d=s[i].s);var p=new lv(d+1),f=Qv(n[h-1],p,0);if(f>e){i=0;var m=0,g=f-e,A=1<e))break;m+=A-(1<>=g;m>0;){var y=s[i].s;p[y]=0&&m;--i){var _=s[i].s;p[_]==e&&(--p[_],++m)}f=e}return{t:new ov(p),l:f}},Qv=function(t,e,n){return-1==t.s?Math.max(Qv(t.l,e,n+1),Qv(t.r,e,n+1)):e[t.s]=n},zv=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new lv(++e),i=0,r=t[0],s=1,a=function(t){n[i++]=t},o=1;o<=e;++o)if(t[o]==r&&o!=e)++s;else{if(!r&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(r),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(r);s=1,r=t[o]}return{c:n.subarray(0,i),n:e}},Gv=function(t,e){for(var n=0,i=0;i>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var s=0;s4&&!S[dv[I-1]];--I);var T,B,R,D,P=c+5<<3,L=Gv(r,Ev)+Gv(s,Mv)+a,U=Gv(r,d)+Gv(s,m)+a+14+3*I+Gv(C,S)+2*C[16]+3*C[17]+7*C[18];if(l>=0&&P<=L&&P<=U)return Hv(e,h,t.subarray(l,l+c));if(Fv(e,h,1+(U15&&(Fv(e,h,k[E]>>5&127),h+=k[E]>>12)}}}else T=Sv,B=Ev,R=Iv,D=Mv;for(E=0;E255){Ov(e,h,T[257+(Q=z>>18&31)]),h+=B[Q+257],Q>7&&(Fv(e,h,z>>23&31),h+=hv[Q]);var G=31&z;Ov(e,h,R[G]),h+=D[G],G>3&&(Ov(e,h,z>>5&8191),h+=uv[G])}else Ov(e,h,T[z]),h+=B[z]}return Ov(e,h,T[256]),h+B[256]},Wv=new cv([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),jv=new ov(0),qv=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var n=e,i=9;--i;)n=(1&n&&-306674912)^n>>>1;t[e]=n}return t}(),Xv=function(){var t=-1;return{p:function(e){for(var n=t,i=0;i>>8;t=n},d:function(){return~t}}},Yv=function(t,e,n,i,r){if(!r&&(r={l:1},e.dictionary)){var s=e.dictionary.subarray(-32768),a=new ov(s.length+t.length);a.set(s),a.set(t,s.length),t=a,r.w=s.length}return function(t,e,n,i,r,s){var a=s.z||t.length,o=new ov(i+a+5*(1+Math.ceil(a/7e3))+r),l=o.subarray(i,o.length-r),c=s.l,h=7&(s.r||0);if(e){h&&(l[0]=s.r>>3);for(var u=Wv[e-1],d=u>>13,p=8191&u,f=(1<7e3||S>24576)&&(D>423||!c)){h=Vv(t,l,0,_,x,w,E,S,I,M-I,h),S=C=E=0,I=M;for(var P=0;P<286;++P)x[P]=0;for(P=0;P<30;++P)w[P]=0}var L=2,U=0,N=p,F=B-R&32767;if(D>2&&T==y(M-F))for(var O=Math.min(d,D)-1,k=Math.min(32767,M),Q=Math.min(258,D);F<=k&&--N&&B!=R;){if(t[M+L]==t[M+L-F]){for(var z=0;zL){if(L=z,U=F,z>O)break;var G=Math.min(F,z-2),H=0;for(P=0;PH&&(H=W,R=V)}}}F+=(B=R)-(R=m[B])&32767}if(U){_[S++]=268435456|gv[L]<<18|yv[U];var j=31&gv[L],q=31&yv[U];E+=hv[j]+uv[q],++x[257+j],++w[q],b=M+L,++C}else _[S++]=t[M],++x[t[M]]}}for(M=Math.max(M,b);M=a&&(l[h/8|0]=c,X=a),h=Hv(l,h+1,t.subarray(M,X))}s.i=a}return Lv(o,0,i+Pv(h)+r)}(t,null==e.level?6:e.level,null==e.mem?r.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+e.mem,n,i,r)},Jv=function(t,e){var n={};for(var i in t)n[i]=t[i];for(var i in e)n[i]=e[i];return n},Kv=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8};function Zv(t,e){return Yv(t,e||{},0,0)}function $v(t,e){return function(t,e,n,i){var r=t.length,s=i?i.length:0;if(!r||e.f&&!e.l)return n||new ov(0);var a=!n,o=a||2!=e.i,l=e.i;a&&(n=new ov(3*r));var c=function(t){var e=n.length;if(t>e){var i=new ov(Math.max(2*e,t));i.set(n),n=i}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,m=e.m,g=e.n,A=8*r;do{if(!p){h=Rv(t,u,1);var v=Rv(t,u+1,3);if(u+=3,!v){var y=t[(B=Pv(u)+4)-4]|t[B-3]<<8,_=B+y;if(_>r){l&&Nv(0);break}o&&c(d+y),n.set(t.subarray(B,_),d),e.b=d+=y,e.p=u=8*_,e.f=h;continue}if(1==v)p=bv,f=Tv,m=9,g=5;else if(2==v){var x=Rv(t,u,31)+257,w=Rv(t,u+10,15)+4,C=x+Rv(t,u+5,31)+1;u+=14;for(var E=new ov(C),M=new ov(19),S=0;S>4)<16)E[S++]=B;else{var D=0,P=0;for(16==B?(P=3+Rv(t,u,3),u+=2,D=E[S-1]):17==B?(P=3+Rv(t,u,7),u+=3):18==B&&(P=11+Rv(t,u,127),u+=7);P--;)E[S++]=D}}var L=E.subarray(0,x),U=E.subarray(x);m=Bv(L),g=Bv(U),p=Cv(L,m,1),f=Cv(U,g,1)}else Nv(1);if(u>A){l&&Nv(0);break}}o&&c(d+131072);for(var N=(1<>4;if((u+=15&D)>A){l&&Nv(0);break}if(D||Nv(2),k<256)n[d++]=k;else{if(256==k){O=u,p=null;break}var Q=k-254;if(k>264){var z=hv[S=k-257];Q=Rv(t,u,(1<>4;if(G||Nv(3),u+=15&G,U=vv[H],H>3&&(z=uv[H],U+=Dv(t,u)&(1<A){l&&Nv(0);break}o&&c(d+131072);var V=d+Q;if(d>4>7||(n[0]<<8|n[1])%31)&&Nv(6,"invalid zlib data"),(n[1]>>5&1)==+!i&&Nv(6,"invalid zlib data: "+(32&n[1]?"need":"unexpected")+" dictionary"),2+(n[1]>>3&4)),-4),{i:2},e&&e.out,e&&e.dictionary);var n,i}var ty=function(t,e,n,i){for(var r in t){var s=t[r],a=e+r,o=i;Array.isArray(s)&&(o=Jv(i,s[1]),s=s[0]),s instanceof ov?n[a]=[s,o]:(n[a+="/"]=[new ov(0),o],ty(s,a,n,i))}},ey="undefined"!=typeof TextEncoder&&new TextEncoder,ny="undefined"!=typeof TextDecoder&&new TextDecoder;try{ny.decode(jv,{stream:!0})}catch(t){}function iy(t,e){if(e){for(var n=new ov(t.length),i=0;i>1)),a=0,o=function(t){s[a++]=t};for(i=0;is.length){var l=new ov(a+8+(r-i<<1));l.set(s),s=l}var c=t.charCodeAt(i);c<128||e?o(c):c<2048?(o(192|c>>6),o(128|63&c)):c>55295&&c<57344?(o(240|(c=65536+(1047552&c)|1023&t.charCodeAt(++i))>>18),o(128|c>>12&63),o(128|c>>6&63),o(128|63&c)):(o(224|c>>12),o(128|c>>6&63),o(128|63&c))}return Lv(s,0,a)}var ry=function(t){var e=0;if(t)for(var n in t){var i=t[n].length;i>65535&&Nv(9),e+=i+4}return e},sy=function(t,e,n,i,r,s,a,o){var l=i.length,c=n.extra,h=o&&o.length,u=ry(c);Kv(t,e,null!=a?33639248:67324752),e+=4,null!=a&&(t[e++]=20,t[e++]=n.os),t[e]=20,e+=2,t[e++]=n.flag<<1|(s<0&&8),t[e++]=r&&8,t[e++]=255&n.compression,t[e++]=n.compression>>8;var d=new Date(null==n.mtime?Date.now():n.mtime),p=d.getFullYear()-1980;if((p<0||p>119)&&Nv(10),Kv(t,e,p<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>1),e+=4,-1!=s&&(Kv(t,e,n.crc),Kv(t,e+4,s<0?-s-2:s),Kv(t,e+8,n.size)),Kv(t,e+12,l),Kv(t,e+14,u),e+=16,null!=a&&(Kv(t,e,h),Kv(t,e+6,n.attrs),Kv(t,e+10,a),e+=14),t.set(i,e),e+=l,u)for(var f in c){var m=c[f],g=m.length;Kv(t,e,+f),Kv(t,e+2,g),t.set(m,e+4),e+=4+g}return h&&(t.set(o,e),e+=h),e};function ay(t,e,n){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const i=n/Math.max(t.width,t.height),r=document.createElement("canvas");r.width=t.width*Math.min(1,i),r.height=t.height*Math.min(1,i);const s=r.getContext("2d");return!0===e&&(s.translate(0,r.height),s.scale(1,-1)),s.drawImage(t,0,0,r.width,r.height),r}throw new Error("THREE.USDZExporter: No valid image data found. Unable to process texture.")}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout;function oy(t){const e=t.elements;return`( ${ly(e,0)}, ${ly(e,4)}, ${ly(e,8)}, ${ly(e,12)} )`}function ly(t,e){return`(${t[e+0]}, ${t[e+1]}, ${t[e+2]}, ${t[e+3]})`}function cy(t,e){if(void 0===t)return console.warn("USDZExporter: Normals missing."),Array(e).fill("(0, 0, 0)").join(", ");const n=[];for(let e=0;e0?"st"+i.channel:"st",l={1e3:"repeat",1001:"clamp",1002:"mirror"},c=i.repeat.clone(),h=i.offset.clone(),u=i.rotation,d=Math.sin(u),p=Math.cos(u);return h.y=1-h.y-c.y,n?(h.x=h.x/c.x,h.y=h.y/c.y,h.x+=d/c.x,h.y+=p-1):(h.x+=d*c.x,h.y+=(1-p)*c.y),`\n\t\tdef Shader "PrimvarReader_${r}"\n\t\t{\n\t\t\tuniform token info:id = "UsdPrimvarReader_float2"\n\t\t\tfloat2 inputs:fallback = (0.0, 0.0)\n\t\t\ttoken inputs:varname = "${o}"\n\t\t\tfloat2 outputs:result\n\t\t}\n\n\t\tdef Shader "Transform2d_${r}"\n\t\t{\n\t\t\tuniform token info:id = "UsdTransform2d"\n\t\t\ttoken inputs:in.connect = \n\t\t\tfloat inputs:rotation = ${(u*(180/Math.PI)).toFixed(7)}\n\t\t\tfloat2 inputs:scale = ${py(c)}\n\t\t\tfloat2 inputs:translation = ${py(h)}\n\t\t\tfloat2 outputs:result\n\t\t}\n\n\t\tdef Shader "Texture_${i.id}_${r}"\n\t\t{\n\t\t\tuniform token info:id = "UsdUVTexture"\n\t\t\tasset inputs:file = @textures/Texture_${a}.png@\n\t\t\tfloat2 inputs:st.connect = \n\t\t\t${void 0!==s?"float4 inputs:scale = "+function(t){return`(${t.r}, ${t.g}, ${t.b}, 1.0)`}(s):""}\n\t\t\ttoken inputs:sourceColorSpace = "${i.colorSpace===cn?"raw":"sRGB"}"\n\t\t\ttoken inputs:wrapS = "${l[i.wrapS]}"\n\t\t\ttoken inputs:wrapT = "${l[i.wrapT]}"\n\t\t\tfloat outputs:r\n\t\t\tfloat outputs:g\n\t\t\tfloat outputs:b\n\t\t\tfloat3 outputs:rgb\n\t\t\t${t.transparent||t.alphaTest>0?"float outputs:a":""}\n\t\t}`}return t.side===S&&console.warn("THREE.USDZExporter: USDZ does not support double sided materials",t),null!==t.map?(r.push(`${i}color3f inputs:diffuseColor.connect = `),t.transparent?r.push(`${i}float inputs:opacity.connect = `):t.alphaTest>0&&(r.push(`${i}float inputs:opacity.connect = `),r.push(`${i}float inputs:opacityThreshold = ${t.alphaTest}`)),s.push(a(t.map,"diffuse",t.color))):r.push(`${i}color3f inputs:diffuseColor = ${dy(t.color)}`),null!==t.emissiveMap?(r.push(`${i}color3f inputs:emissiveColor.connect = `),s.push(a(t.emissiveMap,"emissive",new cs(t.emissive.r*t.emissiveIntensity,t.emissive.g*t.emissiveIntensity,t.emissive.b*t.emissiveIntensity)))):t.emissive.getHex()>0&&r.push(`${i}color3f inputs:emissiveColor = ${dy(t.emissive)}`),null!==t.normalMap&&(r.push(`${i}normal3f inputs:normal.connect = `),s.push(a(t.normalMap,"normal"))),null!==t.aoMap&&(r.push(`${i}float inputs:occlusion.connect = `),s.push(a(t.aoMap,"occlusion",new cs(t.aoMapIntensity,t.aoMapIntensity,t.aoMapIntensity)))),null!==t.roughnessMap?(r.push(`${i}float inputs:roughness.connect = `),s.push(a(t.roughnessMap,"roughness",new cs(t.roughness,t.roughness,t.roughness)))):r.push(`${i}float inputs:roughness = ${t.roughness}`),null!==t.metalnessMap?(r.push(`${i}float inputs:metallic.connect = `),s.push(a(t.metalnessMap,"metallic",new cs(t.metalness,t.metalness,t.metalness)))):r.push(`${i}float inputs:metallic = ${t.metalness}`),null!==t.alphaMap?(r.push(`${i}float inputs:opacity.connect = `),r.push(`${i}float inputs:opacityThreshold = 0.0001`),s.push(a(t.alphaMap,"opacity"))):r.push(`${i}float inputs:opacity = ${t.opacity}`),t.isMeshPhysicalMaterial&&(null!==t.clearcoatMap?(r.push(`${i}float inputs:clearcoat.connect = `),s.push(a(t.clearcoatMap,"clearcoat",new cs(t.clearcoat,t.clearcoat,t.clearcoat)))):r.push(`${i}float inputs:clearcoat = ${t.clearcoat}`),null!==t.clearcoatRoughnessMap?(r.push(`${i}float inputs:clearcoatRoughness.connect = `),s.push(a(t.clearcoatRoughnessMap,"clearcoatRoughness",new cs(t.clearcoatRoughness,t.clearcoatRoughness,t.clearcoatRoughness)))):r.push(`${i}float inputs:clearcoatRoughness = ${t.clearcoatRoughness}`),r.push(`${i}float inputs:ior = ${t.ior}`)),`\n\tdef Material "Material_${t.id}"\n\t{\n\t\tdef Shader "PreviewSurface"\n\t\t{\n\t\t\tuniform token info:id = "UsdPreviewSurface"\n${r.join("\n")}\n\t\t\tint inputs:useSpecularWorkflow = 0\n\t\t\ttoken outputs:surface\n\t\t}\n\n\t\ttoken outputs:surface.connect = \n\n${s.join("\n")}\n\n\t}\n`}function dy(t){return`(${t.r}, ${t.g}, ${t.b})`}function py(t){return`(${t.x}, ${t.y})`}const fy=new zi,my=new Qi,gy=new zi;const Ay=new Ar,vy=new Ar,yy=new zi,_y=new td,xy=new go,wy=new zi,Cy=new rs;class Ey{constructor(){this.tolerance=-1,this.faces=[],this.newFaces=[],this.assigned=new Iy,this.unassigned=new Iy,this.vertices=[]}setFromPoints(t){if(t.length>=4){this.makeEmpty();for(let e=0,n=t.length;ethis.tolerance)return!1;return!0}intersectRay(t,e){const n=this.faces;let i=-1/0,r=1/0;for(let e=0,s=n.length;e0&&o>=0)return null;const l=0!==o?-a/o:0;if(!(l<=0)&&(o>0?r=Math.min(l,r):i=Math.max(l,i),i>r))return null}return i!==-1/0?t.at(i,e):t.at(r,e),e}intersectsRay(t){return null!==this.intersectRay(t,yy)}makeEmpty(){return this.faces=[],this.vertices=[],this}addVertexToFace(t,e){return t.face=e,null===e.outside?this.assigned.append(t):this.assigned.insertBefore(e.outside,t),e.outside=t,this}removeVertexFromFace(t,e){return t===e.outside&&(null!==t.next&&t.next.face===e?e.outside=t.next:e.outside=null),this.assigned.remove(t),this}removeAllVerticesFromFace(t){if(null!==t.outside){const e=t.outside;let n=t.outside;for(;null!==n.next&&n.next.face===t;)n=n.next;return this.assigned.removeSubList(e,n),e.prev=n.next=null,t.outside=null,e}}deleteFaceVertices(t,e){const n=this.removeAllVerticesFromFace(t);if(void 0!==n)if(void 0===e)this.unassigned.appendChain(n);else{let t=n;do{const n=t.next;e.distanceToPoint(t.point)>this.tolerance?this.addVertexToFace(t,e):this.unassigned.append(t),t=n}while(null!==t)}return this}resolveUnassignedPoints(t){if(!1===this.unassigned.isEmpty()){let e=this.unassigned.first();do{const n=e.next;let i=this.tolerance,r=null;for(let n=0;ni&&(i=t,r=s),i>1e3*this.tolerance)break}}null!==r&&this.addVertexToFace(e,r),e=n}while(null!==e)}return this}computeExtremes(){const t=new zi,e=new zi,n=[],i=[];for(let t=0;t<3;t++)n[t]=i[t]=this.vertices[0];t.copy(this.vertices[0].point),e.copy(this.vertices[0].point);for(let r=0,s=this.vertices.length;re.getComponent(t)&&(e.setComponent(t,a.getComponent(t)),i[t]=s)}return this.tolerance=3*Number.EPSILON*(Math.max(Math.abs(t.x),Math.abs(e.x))+Math.max(Math.abs(t.y),Math.abs(e.y))+Math.max(Math.abs(t.z),Math.abs(e.z))),{min:n,max:i}}computeInitialHull(){const t=this.vertices,e=this.computeExtremes(),n=e.min,i=e.max;let r=0,s=0;for(let t=0;t<3;t++){const e=i[t].point.getComponent(t)-n[t].point.getComponent(t);e>r&&(r=e,s=t)}const a=n[s],o=i[s];let l,c;r=0,_y.set(a.point,o.point);for(let e=0,n=this.vertices.length;er&&(r=t,l=n)}}r=-1,xy.setFromCoplanarPoints(a.point,o.point,l.point);for(let e=0,n=this.vertices.length;er&&(r=t,c=n)}}const h=[];if(xy.distanceToPoint(c.point)<0){h.push(My.create(a,o,l),My.create(c,o,a),My.create(c,l,o),My.create(c,a,l));for(let t=0;t<3;t++){const e=(t+1)%3;h[t+1].getEdge(2).setTwin(h[0].getEdge(e)),h[t+1].getEdge(1).setTwin(h[e+1].getEdge(0))}}else{h.push(My.create(a,l,o),My.create(c,a,o),My.create(c,o,l),My.create(c,l,a));for(let t=0;t<3;t++){const e=(t+1)%3;h[t+1].getEdge(2).setTwin(h[0].getEdge((3-t)%3)),h[t+1].getEdge(0).setTwin(h[e+1].getEdge(1))}}for(let t=0;t<4;t++)this.faces.push(h[t]);for(let e=0,n=t.length;er&&(r=i,t=this.faces[e])}null!==t&&this.addVertexToFace(n,t)}}return this}reindexFaces(){const t=[];for(let e=0;ee&&(e=r,t=i),i=i.next}while(null!==i&&i.face===n);return t}}computeHorizon(t,e,n,i){let r;this.deleteFaceVertices(n),n.mark=1,r=null===e?e=n.getEdge(0):e.next;do{const e=r.twin,n=e.face;0===n.mark&&(n.distanceToPoint(t)>this.tolerance?this.computeHorizon(t,e,n,i):i.push(r)),r=r.next}while(r!==e);return this}addAdjoiningFace(t,e){const n=My.create(t,e.tail(),e.head());return this.faces.push(n),n.getEdge(-1).setTwin(e.twin),n.getEdge(0)}addNewFaces(t,e){this.newFaces=[];let n=null,i=null;for(let r=0;r0;)e=e.next,t--;for(;t<0;)e=e.prev,t++;return e}compute(){const t=this.edge.tail(),e=this.edge.head(),n=this.edge.next.head();return Cy.set(t.point,e.point,n.point),Cy.getNormal(this.normal),Cy.getMidpoint(this.midpoint),this.area=Cy.getArea(),this.constant=this.normal.dot(this.midpoint),this}distanceToPoint(t){return this.normal.dot(t)-this.constant}}class Sy{constructor(t,e){this.vertex=t,this.prev=null,this.next=null,this.twin=null,this.face=e}head(){return this.vertex}tail(){return this.prev?this.prev.vertex:null}length(){const t=this.head(),e=this.tail();return null!==e?e.point.distanceTo(t.point):-1}lengthSquared(){const t=this.head(),e=this.tail();return null!==e?e.point.distanceToSquared(t.point):-1}setTwin(t){return this.twin=t,t.twin=this,this}}class by{constructor(t){this.point=t,this.prev=null,this.next=null,this.face=null}}class Iy{constructor(){this.head=null,this.tail=null}first(){return this.head}last(){return this.tail}clear(){return this.head=this.tail=null,this}insertBefore(t,e){return e.prev=t.prev,e.next=t,null===e.prev?this.head=e:e.prev.next=e,t.prev=e,this}insertAfter(t,e){return e.prev=t,e.next=t.next,null===e.next?this.tail=e:e.next.prev=e,t.next=e,this}append(t){return null===this.head?this.head=t:this.tail.next=t,t.prev=this.tail,t.next=null,this.tail=t,this}appendChain(t){for(null===this.head?this.head=t:this.tail.next=t,t.prev=this.tail;null!==t.next;)t=t.next;return this.tail=t,this}remove(t){return null===t.prev?this.head=t.next:t.prev.next=t.next,null===t.next?this.tail=t.prev:t.next.prev=t.prev,this}removeSubList(t,e){return null===t.prev?this.head=e.next:t.prev.next=e.next,null===e.next?this.tail=t.prev:e.next.prev=t.prev,this}isEmpty(){return null===this.head}}function Ty(t,e){switch(e){case hn:t.convertSRGBToLinear();break;case un:case cn:break;default:console.warn("WARNING: LightProbeGenerator convertColorToLinear() encountered an unsupported color space.")}return t}class By{constructor(t,e,n,i,r){this.xrLight=t,this.renderer=e,this.lightProbe=n,this.xrWebGLBinding=null,this.estimationStartCallback=r,this.frameCallback=this.onXRFrame.bind(this);const s=e.xr.getSession();if(i&&"XRWebGLBinding"in window){const n=new pa(16);t.environment=n.texture;const i=e.getContext();switch(s.preferredReflectionFormat){case"srgba8":i.getExtension("EXT_sRGB");break;case"rgba16f":i.getExtension("OES_texture_half_float")}this.xrWebGLBinding=new XRWebGLBinding(s,i),this.lightProbe.addEventListener("reflectionchange",(()=>{this.updateReflection()}))}s.requestAnimationFrame(this.frameCallback)}updateReflection(){const t=this.renderer.properties.get(this.xrLight.environment);if(t){const e=this.xrWebGLBinding.getReflectionCubeMap(this.lightProbe);e&&(t.__webglTexture=e,this.xrLight.environment.needsPMREMUpdate=!0)}}onXRFrame(t,e){if(!this.xrLight)return;e.session.requestAnimationFrame(this.frameCallback);const n=e.getLightEstimate(this.lightProbe);if(n){this.xrLight.lightProbe.sh.fromArray(n.sphericalHarmonicsCoefficients),this.xrLight.lightProbe.intensity=1;const t=Math.max(1,Math.max(n.primaryLightIntensity.x,Math.max(n.primaryLightIntensity.y,n.primaryLightIntensity.z)));this.xrLight.directionalLight.color.setRGB(n.primaryLightIntensity.x/t,n.primaryLightIntensity.y/t,n.primaryLightIntensity.z/t),this.xrLight.directionalLight.intensity=t,this.xrLight.directionalLight.position.copy(n.primaryLightDirection),this.estimationStartCallback&&(this.estimationStartCallback(),this.estimationStartCallback=null)}}dispose(){this.xrLight=null,this.renderer=null,this.lightProbe=null,this.xrWebGLBinding=null}}class Ry{constructor(t=4){this.pool=t,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(t){if(!this.workers[t]){const e=this.workerCreator();e.addEventListener("message",this._onMessage.bind(this,t)),this.workers[t]=e}}_getIdleWorker(){for(let t=0;t{const i=this._getIdleWorker();-1!==i?(this._initWorker(i),this.workerStatus|=1<t.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const Dy=9,Py=15,Ly=16,Uy=22,Ny=37,Fy=43,Oy=76,ky=83,Qy=97,zy=100,Gy=103,Hy=109,Vy=165,Wy=166,jy=1000066e3;class qy{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}}class Xy{constructor(t,e,n,i){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(t.buffer,t.byteOffset+e,n),this._littleEndian=i,this._offset=0}_nextUint8(){const t=this._dataView.getUint8(this._offset);return this._offset+=1,t}_nextUint16(){const t=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,t}_nextUint32(){const t=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,t}_nextUint64(){const t=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,t}_nextInt32(){const t=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,t}_nextUint8Array(t){const e=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,t);return this._offset+=t,e}_skip(t){return this._offset+=t,this}_scan(t,e){void 0===e&&(e=0);const n=this._offset;let i=0;for(;this._dataView.getUint8(this._offset)!==e&&it.arrayBuffer())).then((t=>WebAssembly.instantiate(t,t_))).then(this._init):WebAssembly.instantiate(Buffer.from(n_,"base64"),t_).then(this._init),Ky)}_init(t){Zy=t.instance,t_.env.emscripten_notify_memory_growth(0)}decode(t,e=0){if(!Zy)throw new Error("ZSTDDecoder: Await .init() before decoding.");const n=t.byteLength,i=Zy.exports.malloc(n);$y.set(t,i),e=e||Number(Zy.exports.ZSTD_findDecompressedSize(i,n));const r=Zy.exports.malloc(e),s=Zy.exports.ZSTD_decompress(r,e,i,n),a=$y.slice(r,r+s);return Zy.exports.free(i),Zy.exports.free(r),a}}const n_="AGFzbQEAAAABpQEVYAF/AX9gAn9/AGADf39/AX9gBX9/f39/AX9gAX8AYAJ/fwF/YAR/f39/AX9gA39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gAn9/AX5gAn5+AX5gAABgBX9/f39/AGAGf39/f39/AGAIf39/f39/f38AYAl/f39/f39/f38AYAABf2AIf39/f39/f38Bf2ANf39/f39/f39/f39/fwF/YAF/AX4CJwEDZW52H2Vtc2NyaXB0ZW5fbm90aWZ5X21lbW9yeV9ncm93dGgABANpaAEFAAAFAgEFCwACAQABAgIFBQcAAwABDgsBAQcAEhMHAAUBDAQEAAANBwQCAgYCBAgDAwMDBgEACQkHBgICAAYGAgQUBwYGAwIGAAMCAQgBBwUGCgoEEQAEBAEIAwgDBQgDEA8IAAcABAUBcAECAgUEAQCAAgYJAX8BQaCgwAILB2AHBm1lbW9yeQIABm1hbGxvYwAoBGZyZWUAJgxaU1REX2lzRXJyb3IAaBlaU1REX2ZpbmREZWNvbXByZXNzZWRTaXplAFQPWlNURF9kZWNvbXByZXNzAEoGX3N0YXJ0ACQJBwEAQQELASQKussBaA8AIAAgACgCBCABajYCBAsZACAAKAIAIAAoAgRBH3F0QQAgAWtBH3F2CwgAIABBiH9LC34BBH9BAyEBIAAoAgQiA0EgTQRAIAAoAggiASAAKAIQTwRAIAAQDQ8LIAAoAgwiAiABRgRAQQFBAiADQSBJGw8LIAAgASABIAJrIANBA3YiBCABIARrIAJJIgEbIgJrIgQ2AgggACADIAJBA3RrNgIEIAAgBCgAADYCAAsgAQsUAQF/IAAgARACIQIgACABEAEgAgv3AQECfyACRQRAIABCADcCACAAQQA2AhAgAEIANwIIQbh/DwsgACABNgIMIAAgAUEEajYCECACQQRPBEAgACABIAJqIgFBfGoiAzYCCCAAIAMoAAA2AgAgAUF/ai0AACIBBEAgAEEIIAEQFGs2AgQgAg8LIABBADYCBEF/DwsgACABNgIIIAAgAS0AACIDNgIAIAJBfmoiBEEBTQRAIARBAWtFBEAgACABLQACQRB0IANyIgM2AgALIAAgAS0AAUEIdCADajYCAAsgASACakF/ai0AACIBRQRAIABBADYCBEFsDwsgAEEoIAEQFCACQQN0ams2AgQgAgsWACAAIAEpAAA3AAAgACABKQAINwAICy8BAX8gAUECdEGgHWooAgAgACgCAEEgIAEgACgCBGprQR9xdnEhAiAAIAEQASACCyEAIAFCz9bTvtLHq9lCfiAAfEIfiUKHla+vmLbem55/fgsdAQF/IAAoAgggACgCDEYEfyAAKAIEQSBGBUEACwuCBAEDfyACQYDAAE8EQCAAIAEgAhBnIAAPCyAAIAJqIQMCQCAAIAFzQQNxRQRAAkAgAkEBSARAIAAhAgwBCyAAQQNxRQRAIAAhAgwBCyAAIQIDQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADTw0BIAJBA3ENAAsLAkAgA0F8cSIEQcAASQ0AIAIgBEFAaiIFSw0AA0AgAiABKAIANgIAIAIgASgCBDYCBCACIAEoAgg2AgggAiABKAIMNgIMIAIgASgCEDYCECACIAEoAhQ2AhQgAiABKAIYNgIYIAIgASgCHDYCHCACIAEoAiA2AiAgAiABKAIkNgIkIAIgASgCKDYCKCACIAEoAiw2AiwgAiABKAIwNgIwIAIgASgCNDYCNCACIAEoAjg2AjggAiABKAI8NgI8IAFBQGshASACQUBrIgIgBU0NAAsLIAIgBE8NAQNAIAIgASgCADYCACABQQRqIQEgAkEEaiICIARJDQALDAELIANBBEkEQCAAIQIMAQsgA0F8aiIEIABJBEAgACECDAELIAAhAgNAIAIgAS0AADoAACACIAEtAAE6AAEgAiABLQACOgACIAIgAS0AAzoAAyABQQRqIQEgAkEEaiICIARNDQALCyACIANJBEADQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADRw0ACwsgAAsMACAAIAEpAAA3AAALQQECfyAAKAIIIgEgACgCEEkEQEEDDwsgACAAKAIEIgJBB3E2AgQgACABIAJBA3ZrIgE2AgggACABKAAANgIAQQALDAAgACABKAIANgAAC/cCAQJ/AkAgACABRg0AAkAgASACaiAASwRAIAAgAmoiBCABSw0BCyAAIAEgAhALDwsgACABc0EDcSEDAkACQCAAIAFJBEAgAwRAIAAhAwwDCyAAQQNxRQRAIAAhAwwCCyAAIQMDQCACRQ0EIAMgAS0AADoAACABQQFqIQEgAkF/aiECIANBAWoiA0EDcQ0ACwwBCwJAIAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQhBSAGQQR2IQRBICAAdCIAQQFyIQkgASgCACEPQQAhAiADIQYCQANAIAlBAkggAiAPS3JFBEAgAiEHAkAgCARAA0AgBEH//wNxQf//A0YEQCAHQRhqIQcgBiAQSQR/IAZBAmoiBigAACAFdgUgBUEQaiEFIARBEHYLIQQMAQsLA0AgBEEDcSIIQQNGBEAgBUECaiEFIARBAnYhBCAHQQNqIQcMAQsLIAcgCGoiByAPSw0EIAVBAmohBQNAIAIgB0kEQCANIAJBAXRqQQA7AQAgAkEBaiECDAELCyAGIA5LQQAgBiAFQQN1aiIHIAxLG0UEQCAHKAAAIAVBB3EiBXYhBAwCCyAEQQJ2IQQLIAYhBwsCfyALQX9qIAQgAEF/anEiBiAAQQF0QX9qIgggCWsiEUkNABogBCAIcSIEQQAgESAEIABIG2shBiALCyEIIA0gAkEBdGogBkF/aiIEOwEAIAlBASAGayAEIAZBAUgbayEJA0AgCSAASARAIABBAXUhACALQX9qIQsMAQsLAn8gByAOS0EAIAcgBSAIaiIFQQN1aiIGIAxLG0UEQCAFQQdxDAELIAUgDCIGIAdrQQN0awshBSACQQFqIQIgBEUhCCAGKAAAIAVBH3F2IQQMAQsLQWwgCUEBRyAFQSBKcg0BGiABIAJBf2o2AgAgBiAFQQdqQQN1aiADawwBC0FQCyEAIApBEGokACAACwkAQQFBBSAAGwsMACAAIAEoAAA2AAALqgMBCn8jAEHwAGsiCiQAIAJBAWohDiAAQQhqIQtBgIAEIAVBf2p0QRB1IQxBACECQQEhBkEBIAV0IglBf2oiDyEIA0AgAiAORkUEQAJAIAEgAkEBdCINai8BACIHQf//A0YEQCALIAhBA3RqIAI2AgQgCEF/aiEIQQEhBwwBCyAGQQAgDCAHQRB0QRB1ShshBgsgCiANaiAHOwEAIAJBAWohAgwBCwsgACAFNgIEIAAgBjYCACAJQQN2IAlBAXZqQQNqIQxBACEAQQAhBkEAIQIDQCAGIA5GBEADQAJAIAAgCUYNACAKIAsgAEEDdGoiASgCBCIGQQF0aiICIAIvAQAiAkEBajsBACABIAUgAhAUayIIOgADIAEgAiAIQf8BcXQgCWs7AQAgASAEIAZBAnQiAmooAgA6AAIgASACIANqKAIANgIEIABBAWohAAwBCwsFIAEgBkEBdGouAQAhDUEAIQcDQCAHIA1ORQRAIAsgAkEDdGogBjYCBANAIAIgDGogD3EiAiAISw0ACyAHQQFqIQcMAQsLIAZBAWohBgwBCwsgCkHwAGokAAsjAEIAIAEQCSAAhUKHla+vmLbem55/fkLj3MqV/M7y9YV/fAsQACAAQn43AwggACABNgIACyQBAX8gAARAIAEoAgQiAgRAIAEoAgggACACEQEADwsgABAmCwsfACAAIAEgAi8BABAINgIAIAEQBBogACACQQRqNgIEC0oBAX9BoCAoAgAiASAAaiIAQX9MBEBBiCBBMDYCAEF/DwsCQCAAPwBBEHRNDQAgABBmDQBBiCBBMDYCAEF/DwtBoCAgADYCACABC9cBAQh/Qbp/IQoCQCACKAIEIgggAigCACIJaiIOIAEgAGtLDQBBbCEKIAkgBCADKAIAIgtrSw0AIAAgCWoiBCACKAIIIgxrIQ0gACABQWBqIg8gCyAJQQAQKSADIAkgC2o2AgACQAJAIAwgBCAFa00EQCANIQUMAQsgDCAEIAZrSw0CIAcgDSAFayIAaiIBIAhqIAdNBEAgBCABIAgQDxoMAgsgBCABQQAgAGsQDyEBIAIgACAIaiIINgIEIAEgAGshBAsgBCAPIAUgCEEBECkLIA4hCgsgCgubAgEBfyMAQYABayINJAAgDSADNgJ8AkAgAkEDSwRAQX8hCQwBCwJAAkACQAJAIAJBAWsOAwADAgELIAZFBEBBuH8hCQwEC0FsIQkgBS0AACICIANLDQMgACAHIAJBAnQiAmooAgAgAiAIaigCABA7IAEgADYCAEEBIQkMAwsgASAJNgIAQQAhCQwCCyAKRQRAQWwhCQwCC0EAIQkgC0UgDEEZSHINAUEIIAR0QQhqIQBBACECA0AgAiAATw0CIAJBQGshAgwAAAsAC0FsIQkgDSANQfwAaiANQfgAaiAFIAYQFSICEAMNACANKAJ4IgMgBEsNACAAIA0gDSgCfCAHIAggAxAYIAEgADYCACACIQkLIA1BgAFqJAAgCQsLACAAIAEgAhALGgsQACAALwAAIAAtAAJBEHRyCy8AAn9BuH8gAUEISQ0AGkFyIAAoAAQiAEF3Sw0AGkG4fyAAQQhqIgAgACABSxsLCwkAIAAgATsAAAsDAAELigYBBX8gACAAKAIAIgVBfnE2AgBBACAAIAVBAXZqQYQgKAIAIgQgAEYbIQECQAJAIAAoAgQiAkUNACACKAIAIgNBAXENACACQQhqIgUgA0EBdkF4aiIDQQggA0EISxtnQR9zQQJ0QYAfaiIDKAIARgRAIAMgAigCDDYCAAsgAigCCCIDBEAgAyACKAIMNgIECyACKAIMIgMEQCADIAIoAgg2AgALIAIgAigCACAAKAIAQX5xajYCAEGEICEAAkACQCABRQ0AIAEgAjYCBCABKAIAIgNBAXENASADQQF2QXhqIgNBCCADQQhLG2dBH3NBAnRBgB9qIgMoAgAgAUEIakYEQCADIAEoAgw2AgALIAEoAggiAwRAIAMgASgCDDYCBAsgASgCDCIDBEAgAyABKAIINgIAQYQgKAIAIQQLIAIgAigCACABKAIAQX5xajYCACABIARGDQAgASABKAIAQQF2akEEaiEACyAAIAI2AgALIAIoAgBBAXZBeGoiAEEIIABBCEsbZ0Efc0ECdEGAH2oiASgCACEAIAEgBTYCACACIAA2AgwgAkEANgIIIABFDQEgACAFNgIADwsCQCABRQ0AIAEoAgAiAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAigCACABQQhqRgRAIAIgASgCDDYCAAsgASgCCCICBEAgAiABKAIMNgIECyABKAIMIgIEQCACIAEoAgg2AgBBhCAoAgAhBAsgACAAKAIAIAEoAgBBfnFqIgI2AgACQCABIARHBEAgASABKAIAQQF2aiAANgIEIAAoAgAhAgwBC0GEICAANgIACyACQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgIoAgAhASACIABBCGoiAjYCACAAIAE2AgwgAEEANgIIIAFFDQEgASACNgIADwsgBUEBdkF4aiIBQQggAUEISxtnQR9zQQJ0QYAfaiICKAIAIQEgAiAAQQhqIgI2AgAgACABNgIMIABBADYCCCABRQ0AIAEgAjYCAAsLDgAgAARAIABBeGoQJQsLgAIBA38CQCAAQQ9qQXhxQYQgKAIAKAIAQQF2ayICEB1Bf0YNAAJAQYQgKAIAIgAoAgAiAUEBcQ0AIAFBAXZBeGoiAUEIIAFBCEsbZ0Efc0ECdEGAH2oiASgCACAAQQhqRgRAIAEgACgCDDYCAAsgACgCCCIBBEAgASAAKAIMNgIECyAAKAIMIgFFDQAgASAAKAIINgIAC0EBIQEgACAAKAIAIAJBAXRqIgI2AgAgAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAygCACECIAMgAEEIaiIDNgIAIAAgAjYCDCAAQQA2AgggAkUNACACIAM2AgALIAELtwIBA38CQAJAIABBASAAGyICEDgiAA0AAkACQEGEICgCACIARQ0AIAAoAgAiA0EBcQ0AIAAgA0EBcjYCACADQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgAgAEEIakYEQCABIAAoAgw2AgALIAAoAggiAQRAIAEgACgCDDYCBAsgACgCDCIBBEAgASAAKAIINgIACyACECchAkEAIQFBhCAoAgAhACACDQEgACAAKAIAQX5xNgIAQQAPCyACQQ9qQXhxIgMQHSICQX9GDQIgAkEHakF4cSIAIAJHBEAgACACaxAdQX9GDQMLAkBBhCAoAgAiAUUEQEGAICAANgIADAELIAAgATYCBAtBhCAgADYCACAAIANBAXRBAXI2AgAMAQsgAEUNAQsgAEEIaiEBCyABC7kDAQJ/IAAgA2ohBQJAIANBB0wEQANAIAAgBU8NAiAAIAItAAA6AAAgAEEBaiEAIAJBAWohAgwAAAsACyAEQQFGBEACQCAAIAJrIgZBB00EQCAAIAItAAA6AAAgACACLQABOgABIAAgAi0AAjoAAiAAIAItAAM6AAMgAEEEaiACIAZBAnQiBkHAHmooAgBqIgIQFyACIAZB4B5qKAIAayECDAELIAAgAhAMCyACQQhqIQIgAEEIaiEACwJAAkACQAJAIAUgAU0EQCAAIANqIQEgBEEBRyAAIAJrQQ9Kcg0BA0AgACACEAwgAkEIaiECIABBCGoiACABSQ0ACwwFCyAAIAFLBEAgACEBDAQLIARBAUcgACACa0EPSnINASAAIQMgAiEEA0AgAyAEEAwgBEEIaiEEIANBCGoiAyABSQ0ACwwCCwNAIAAgAhAHIAJBEGohAiAAQRBqIgAgAUkNAAsMAwsgACEDIAIhBANAIAMgBBAHIARBEGohBCADQRBqIgMgAUkNAAsLIAIgASAAa2ohAgsDQCABIAVPDQEgASACLQAAOgAAIAFBAWohASACQQFqIQIMAAALAAsLQQECfyAAIAAoArjgASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigCACACaiAAQQZ2IgFBAnRBsB5qKAIAaiAAQSBxIgBFaiABRSAAQQV2cWoFQbh/CwsdACAAKAKQ4gEQWiAAQQA2AqDiASAAQgA3A5DiAQu1AwEFfyMAQZACayIKJABBuH8hBgJAIAVFDQAgBCwAACIIQf8BcSEHAkAgCEF/TARAIAdBgn9qQQF2IgggBU8NAkFsIQYgB0GBf2oiBUGAAk8NAiAEQQFqIQdBACEGA0AgBiAFTwRAIAUhBiAIIQcMAwUgACAGaiAHIAZBAXZqIgQtAABBBHY6AAAgACAGQQFyaiAELQAAQQ9xOgAAIAZBAmohBgwBCwAACwALIAcgBU8NASAAIARBAWogByAKEFMiBhADDQELIAYhBEEAIQYgAUEAQTQQECEJQQAhBQNAIAQgBkcEQCAAIAZqIggtAAAiAUELSwRAQWwhBgwDBSAJIAFBAnRqIgEgASgCAEEBajYCACAGQQFqIQZBASAILQAAdEEBdSAFaiEFDAILAAsLQWwhBiAFRQ0AIAUQFEEBaiIBQQxLDQAgAyABNgIAQQFBASABdCAFayIDEBQiAXQgA0cNACAAIARqIAFBAWoiADoAACAJIABBAnRqIgAgACgCAEEBajYCACAJKAIEIgBBAkkgAEEBcXINACACIARBAWo2AgAgB0EBaiEGCyAKQZACaiQAIAYLxhEBDH8jAEHwAGsiBSQAQWwhCwJAIANBCkkNACACLwAAIQogAi8AAiEJIAIvAAQhByAFQQhqIAQQDgJAIAMgByAJIApqakEGaiIMSQ0AIAUtAAohCCAFQdgAaiACQQZqIgIgChAGIgsQAw0BIAVBQGsgAiAKaiICIAkQBiILEAMNASAFQShqIAIgCWoiAiAHEAYiCxADDQEgBUEQaiACIAdqIAMgDGsQBiILEAMNASAAIAFqIg9BfWohECAEQQRqIQZBASELIAAgAUEDakECdiIDaiIMIANqIgIgA2oiDiEDIAIhBCAMIQcDQCALIAMgEElxBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgCS0AAyELIAcgBiAFQUBrIAgQAkECdGoiCS8BADsAACAFQUBrIAktAAIQASAJLQADIQogBCAGIAVBKGogCBACQQJ0aiIJLwEAOwAAIAVBKGogCS0AAhABIAktAAMhCSADIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgDS0AAyENIAAgC2oiCyAGIAVB2ABqIAgQAkECdGoiAC8BADsAACAFQdgAaiAALQACEAEgAC0AAyEAIAcgCmoiCiAGIAVBQGsgCBACQQJ0aiIHLwEAOwAAIAVBQGsgBy0AAhABIActAAMhByAEIAlqIgkgBiAFQShqIAgQAkECdGoiBC8BADsAACAFQShqIAQtAAIQASAELQADIQQgAyANaiIDIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgACALaiEAIAcgCmohByAEIAlqIQQgAyANLQADaiEDIAVB2ABqEA0gBUFAaxANciAFQShqEA1yIAVBEGoQDXJFIQsMAQsLIAQgDksgByACS3INAEFsIQsgACAMSw0BIAxBfWohCQNAQQAgACAJSSAFQdgAahAEGwRAIAAgBiAFQdgAaiAIEAJBAnRqIgovAQA7AAAgBUHYAGogCi0AAhABIAAgCi0AA2oiACAGIAVB2ABqIAgQAkECdGoiCi8BADsAACAFQdgAaiAKLQACEAEgACAKLQADaiEADAEFIAxBfmohCgNAIAVB2ABqEAQgACAKS3JFBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgACAJLQADaiEADAELCwNAIAAgCk0EQCAAIAYgBUHYAGogCBACQQJ0aiIJLwEAOwAAIAVB2ABqIAktAAIQASAAIAktAANqIQAMAQsLAkAgACAMTw0AIAAgBiAFQdgAaiAIEAIiAEECdGoiDC0AADoAACAMLQADQQFGBEAgBUHYAGogDC0AAhABDAELIAUoAlxBH0sNACAFQdgAaiAGIABBAnRqLQACEAEgBSgCXEEhSQ0AIAVBIDYCXAsgAkF9aiEMA0BBACAHIAxJIAVBQGsQBBsEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiIAIAYgBUFAayAIEAJBAnRqIgcvAQA7AAAgBUFAayAHLQACEAEgACAHLQADaiEHDAEFIAJBfmohDANAIAVBQGsQBCAHIAxLckUEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwNAIAcgDE0EQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwJAIAcgAk8NACAHIAYgBUFAayAIEAIiAEECdGoiAi0AADoAACACLQADQQFGBEAgBUFAayACLQACEAEMAQsgBSgCREEfSw0AIAVBQGsgBiAAQQJ0ai0AAhABIAUoAkRBIUkNACAFQSA2AkQLIA5BfWohAgNAQQAgBCACSSAFQShqEAQbBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2oiACAGIAVBKGogCBACQQJ0aiIELwEAOwAAIAVBKGogBC0AAhABIAAgBC0AA2ohBAwBBSAOQX5qIQIDQCAFQShqEAQgBCACS3JFBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsDQCAEIAJNBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsCQCAEIA5PDQAgBCAGIAVBKGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBKGogAi0AAhABDAELIAUoAixBH0sNACAFQShqIAYgAEECdGotAAIQASAFKAIsQSFJDQAgBUEgNgIsCwNAQQAgAyAQSSAFQRBqEAQbBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2oiACAGIAVBEGogCBACQQJ0aiICLwEAOwAAIAVBEGogAi0AAhABIAAgAi0AA2ohAwwBBSAPQX5qIQIDQCAFQRBqEAQgAyACS3JFBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsDQCADIAJNBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsCQCADIA9PDQAgAyAGIAVBEGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBEGogAi0AAhABDAELIAUoAhRBH0sNACAFQRBqIAYgAEECdGotAAIQASAFKAIUQSFJDQAgBUEgNgIUCyABQWwgBUHYAGoQCiAFQUBrEApxIAVBKGoQCnEgBUEQahAKcRshCwwJCwAACwALAAALAAsAAAsACwAACwALQWwhCwsgBUHwAGokACALC7UEAQ5/IwBBEGsiBiQAIAZBBGogABAOQVQhBQJAIARB3AtJDQAgBi0ABCEHIANB8ARqQQBB7AAQECEIIAdBDEsNACADQdwJaiIJIAggBkEIaiAGQQxqIAEgAhAxIhAQA0UEQCAGKAIMIgQgB0sNASADQdwFaiEPIANBpAVqIREgAEEEaiESIANBqAVqIQEgBCEFA0AgBSICQX9qIQUgCCACQQJ0aigCAEUNAAsgAkEBaiEOQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgASALaiAKNgIAIAVBAWohBSAKIAxqIQoMAQsLIAEgCjYCAEEAIQUgBigCCCELA0AgBSALRkUEQCABIAUgCWotAAAiDEECdGoiDSANKAIAIg1BAWo2AgAgDyANQQF0aiINIAw6AAEgDSAFOgAAIAVBAWohBQwBCwtBACEBIANBADYCqAUgBEF/cyAHaiEJQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgAyALaiABNgIAIAwgBSAJanQgAWohASAFQQFqIQUMAQsLIAcgBEEBaiIBIAJrIgRrQQFqIQgDQEEBIQUgBCAIT0UEQANAIAUgDk9FBEAgBUECdCIJIAMgBEE0bGpqIAMgCWooAgAgBHY2AgAgBUEBaiEFDAELCyAEQQFqIQQMAQsLIBIgByAPIAogESADIAIgARBkIAZBAToABSAGIAc6AAYgACAGKAIENgIACyAQIQULIAZBEGokACAFC8ENAQt/IwBB8ABrIgUkAEFsIQkCQCADQQpJDQAgAi8AACEKIAIvAAIhDCACLwAEIQYgBUEIaiAEEA4CQCADIAYgCiAMampBBmoiDUkNACAFLQAKIQcgBUHYAGogAkEGaiICIAoQBiIJEAMNASAFQUBrIAIgCmoiAiAMEAYiCRADDQEgBUEoaiACIAxqIgIgBhAGIgkQAw0BIAVBEGogAiAGaiADIA1rEAYiCRADDQEgACABaiIOQX1qIQ8gBEEEaiEGQQEhCSAAIAFBA2pBAnYiAmoiCiACaiIMIAJqIg0hAyAMIQQgCiECA0AgCSADIA9JcQRAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAACAGIAVBQGsgBxACQQF0aiIILQAAIQsgBUFAayAILQABEAEgAiALOgAAIAYgBUEoaiAHEAJBAXRqIggtAAAhCyAFQShqIAgtAAEQASAEIAs6AAAgBiAFQRBqIAcQAkEBdGoiCC0AACELIAVBEGogCC0AARABIAMgCzoAACAGIAVB2ABqIAcQAkEBdGoiCC0AACELIAVB2ABqIAgtAAEQASAAIAs6AAEgBiAFQUBrIAcQAkEBdGoiCC0AACELIAVBQGsgCC0AARABIAIgCzoAASAGIAVBKGogBxACQQF0aiIILQAAIQsgBUEoaiAILQABEAEgBCALOgABIAYgBUEQaiAHEAJBAXRqIggtAAAhCyAFQRBqIAgtAAEQASADIAs6AAEgA0ECaiEDIARBAmohBCACQQJqIQIgAEECaiEAIAkgBUHYAGoQDUVxIAVBQGsQDUVxIAVBKGoQDUVxIAVBEGoQDUVxIQkMAQsLIAQgDUsgAiAMS3INAEFsIQkgACAKSw0BIApBfWohCQNAIAVB2ABqEAQgACAJT3JFBEAgBiAFQdgAaiAHEAJBAXRqIggtAAAhCyAFQdgAaiAILQABEAEgACALOgAAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAASAAQQJqIQAMAQsLA0AgBUHYAGoQBCAAIApPckUEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCwNAIAAgCkkEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCyAMQX1qIQADQCAFQUBrEAQgAiAAT3JFBEAgBiAFQUBrIAcQAkEBdGoiCi0AACEJIAVBQGsgCi0AARABIAIgCToAACAGIAVBQGsgBxACQQF0aiIKLQAAIQkgBUFAayAKLQABEAEgAiAJOgABIAJBAmohAgwBCwsDQCAFQUBrEAQgAiAMT3JFBEAgBiAFQUBrIAcQAkEBdGoiAC0AACEKIAVBQGsgAC0AARABIAIgCjoAACACQQFqIQIMAQsLA0AgAiAMSQRAIAYgBUFAayAHEAJBAXRqIgAtAAAhCiAFQUBrIAAtAAEQASACIAo6AAAgAkEBaiECDAELCyANQX1qIQADQCAFQShqEAQgBCAAT3JFBEAgBiAFQShqIAcQAkEBdGoiAi0AACEKIAVBKGogAi0AARABIAQgCjoAACAGIAVBKGogBxACQQF0aiICLQAAIQogBUEoaiACLQABEAEgBCAKOgABIARBAmohBAwBCwsDQCAFQShqEAQgBCANT3JFBEAgBiAFQShqIAcQAkEBdGoiAC0AACECIAVBKGogAC0AARABIAQgAjoAACAEQQFqIQQMAQsLA0AgBCANSQRAIAYgBUEoaiAHEAJBAXRqIgAtAAAhAiAFQShqIAAtAAEQASAEIAI6AAAgBEEBaiEEDAELCwNAIAVBEGoQBCADIA9PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIAYgBUEQaiAHEAJBAXRqIgAtAAAhAiAFQRBqIAAtAAEQASADIAI6AAEgA0ECaiEDDAELCwNAIAVBEGoQBCADIA5PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIANBAWohAwwBCwsDQCADIA5JBEAgBiAFQRBqIAcQAkEBdGoiAC0AACECIAVBEGogAC0AARABIAMgAjoAACADQQFqIQMMAQsLIAFBbCAFQdgAahAKIAVBQGsQCnEgBUEoahAKcSAFQRBqEApxGyEJDAELQWwhCQsgBUHwAGokACAJC8oCAQR/IwBBIGsiBSQAIAUgBBAOIAUtAAIhByAFQQhqIAIgAxAGIgIQA0UEQCAEQQRqIQIgACABaiIDQX1qIQQDQCAFQQhqEAQgACAET3JFBEAgAiAFQQhqIAcQAkEBdGoiBi0AACEIIAVBCGogBi0AARABIAAgCDoAACACIAVBCGogBxACQQF0aiIGLQAAIQggBUEIaiAGLQABEAEgACAIOgABIABBAmohAAwBCwsDQCAFQQhqEAQgACADT3JFBEAgAiAFQQhqIAcQAkEBdGoiBC0AACEGIAVBCGogBC0AARABIAAgBjoAACAAQQFqIQAMAQsLA0AgACADT0UEQCACIAVBCGogBxACQQF0aiIELQAAIQYgBUEIaiAELQABEAEgACAGOgAAIABBAWohAAwBCwsgAUFsIAVBCGoQChshAgsgBUEgaiQAIAILtgMBCX8jAEEQayIGJAAgBkEANgIMIAZBADYCCEFUIQQCQAJAIANBQGsiDCADIAZBCGogBkEMaiABIAIQMSICEAMNACAGQQRqIAAQDiAGKAIMIgcgBi0ABEEBaksNASAAQQRqIQogBkEAOgAFIAYgBzoABiAAIAYoAgQ2AgAgB0EBaiEJQQEhBANAIAQgCUkEQCADIARBAnRqIgEoAgAhACABIAU2AgAgACAEQX9qdCAFaiEFIARBAWohBAwBCwsgB0EBaiEHQQAhBSAGKAIIIQkDQCAFIAlGDQEgAyAFIAxqLQAAIgRBAnRqIgBBASAEdEEBdSILIAAoAgAiAWoiADYCACAHIARrIQhBACEEAkAgC0EDTQRAA0AgBCALRg0CIAogASAEakEBdGoiACAIOgABIAAgBToAACAEQQFqIQQMAAALAAsDQCABIABPDQEgCiABQQF0aiIEIAg6AAEgBCAFOgAAIAQgCDoAAyAEIAU6AAIgBCAIOgAFIAQgBToABCAEIAg6AAcgBCAFOgAGIAFBBGohAQwAAAsACyAFQQFqIQUMAAALAAsgAiEECyAGQRBqJAAgBAutAQECfwJAQYQgKAIAIABHIAAoAgBBAXYiAyABa0F4aiICQXhxQQhHcgR/IAIFIAMQJ0UNASACQQhqC0EQSQ0AIAAgACgCACICQQFxIAAgAWpBD2pBeHEiASAAa0EBdHI2AgAgASAANgIEIAEgASgCAEEBcSAAIAJBAXZqIAFrIgJBAXRyNgIAQYQgIAEgAkH/////B3FqQQRqQYQgKAIAIABGGyABNgIAIAEQJQsLygIBBX8CQAJAAkAgAEEIIABBCEsbZ0EfcyAAaUEBR2oiAUEESSAAIAF2cg0AIAFBAnRB/B5qKAIAIgJFDQADQCACQXhqIgMoAgBBAXZBeGoiBSAATwRAIAIgBUEIIAVBCEsbZ0Efc0ECdEGAH2oiASgCAEYEQCABIAIoAgQ2AgALDAMLIARBHksNASAEQQFqIQQgAigCBCICDQALC0EAIQMgAUEgTw0BA0AgAUECdEGAH2ooAgAiAkUEQCABQR5LIQIgAUEBaiEBIAJFDQEMAwsLIAIgAkF4aiIDKAIAQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgBGBEAgASACKAIENgIACwsgAigCACIBBEAgASACKAIENgIECyACKAIEIgEEQCABIAIoAgA2AgALIAMgAygCAEEBcjYCACADIAAQNwsgAwvhCwINfwV+IwBB8ABrIgckACAHIAAoAvDhASIINgJcIAEgAmohDSAIIAAoAoDiAWohDwJAAkAgBUUEQCABIQQMAQsgACgCxOABIRAgACgCwOABIREgACgCvOABIQ4gAEEBNgKM4QFBACEIA0AgCEEDRwRAIAcgCEECdCICaiAAIAJqQazQAWooAgA2AkQgCEEBaiEIDAELC0FsIQwgB0EYaiADIAQQBhADDQEgB0EsaiAHQRhqIAAoAgAQEyAHQTRqIAdBGGogACgCCBATIAdBPGogB0EYaiAAKAIEEBMgDUFgaiESIAEhBEEAIQwDQCAHKAIwIAcoAixBA3RqKQIAIhRCEIinQf8BcSEIIAcoAkAgBygCPEEDdGopAgAiFUIQiKdB/wFxIQsgBygCOCAHKAI0QQN0aikCACIWQiCIpyEJIBVCIIghFyAUQiCIpyECAkAgFkIQiKdB/wFxIgNBAk8EQAJAIAZFIANBGUlyRQRAIAkgB0EYaiADQSAgBygCHGsiCiAKIANLGyIKEAUgAyAKayIDdGohCSAHQRhqEAQaIANFDQEgB0EYaiADEAUgCWohCQwBCyAHQRhqIAMQBSAJaiEJIAdBGGoQBBoLIAcpAkQhGCAHIAk2AkQgByAYNwNIDAELAkAgA0UEQCACBEAgBygCRCEJDAMLIAcoAkghCQwBCwJAAkAgB0EYakEBEAUgCSACRWpqIgNBA0YEQCAHKAJEQX9qIgMgA0VqIQkMAQsgA0ECdCAHaigCRCIJIAlFaiEJIANBAUYNAQsgByAHKAJINgJMCwsgByAHKAJENgJIIAcgCTYCRAsgF6chAyALBEAgB0EYaiALEAUgA2ohAwsgCCALakEUTwRAIAdBGGoQBBoLIAgEQCAHQRhqIAgQBSACaiECCyAHQRhqEAQaIAcgB0EYaiAUQhiIp0H/AXEQCCAUp0H//wNxajYCLCAHIAdBGGogFUIYiKdB/wFxEAggFadB//8DcWo2AjwgB0EYahAEGiAHIAdBGGogFkIYiKdB/wFxEAggFqdB//8DcWo2AjQgByACNgJgIAcoAlwhCiAHIAk2AmggByADNgJkAkACQAJAIAQgAiADaiILaiASSw0AIAIgCmoiEyAPSw0AIA0gBGsgC0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdBKGogACgCBBATQQAhBCAHQeAAaiEMIAdB5ABqIQoDQCAHQShqEARBAksgBCAXTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEJIAcoAkggBygCREEDdGopAgAiH0IgiKchCCAeQiCIISAgHUIgiKchAgJAIB9CEIinQf8BcSIDQQJPBEACQCAGRSADQRlJckUEQCAIIAdBKGogA0EgIAcoAixrIg0gDSADSxsiDRAFIAMgDWsiA3RqIQggB0EoahAEGiADRQ0BIAdBKGogAxAFIAhqIQgMAQsgB0EoaiADEAUgCGohCCAHQShqEAQaCyAHKQJUISEgByAINgJUIAcgITcDWAwBCwJAIANFBEAgAgRAIAcoAlQhCAwDCyAHKAJYIQgMAQsCQAJAIAdBKGpBARAFIAggAkVqaiIDQQNGBEAgBygCVEF/aiIDIANFaiEIDAELIANBAnQgB2ooAlQiCCAIRWohCCADQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAg2AlQLICCnIQMgCQRAIAdBKGogCRAFIANqIQMLIAkgC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgAmohAgsgB0EoahAEGiAHIAcoAmggAmoiCSADajYCaCAKIAwgCCAJSxsoAgAhDSAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogB0EoaiAfQhiIp0H/AXEQCCEOIAdB8ABqIARBBHRqIgsgCSANaiAIazYCDCALIAg2AgggCyADNgIEIAsgAjYCACAHIA4gH6dB//8DcWo2AkQgBEEBaiEEDAELCyAEIBdIDQEgEkFgaiEYIAdB4ABqIRogB0HkAGohGyABIQMDQCAHQShqEARBAksgBCAFTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEIIAcoAkggBygCREEDdGopAgAiH0IgiKchCSAeQiCIISAgHUIgiKchDAJAIB9CEIinQf8BcSICQQJPBEACQCAGRSACQRlJckUEQCAJIAdBKGogAkEgIAcoAixrIgogCiACSxsiChAFIAIgCmsiAnRqIQkgB0EoahAEGiACRQ0BIAdBKGogAhAFIAlqIQkMAQsgB0EoaiACEAUgCWohCSAHQShqEAQaCyAHKQJUISEgByAJNgJUIAcgITcDWAwBCwJAIAJFBEAgDARAIAcoAlQhCQwDCyAHKAJYIQkMAQsCQAJAIAdBKGpBARAFIAkgDEVqaiICQQNGBEAgBygCVEF/aiICIAJFaiEJDAELIAJBAnQgB2ooAlQiCSAJRWohCSACQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAk2AlQLICCnIRQgCARAIAdBKGogCBAFIBRqIRQLIAggC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgDGohDAsgB0EoahAEGiAHIAcoAmggDGoiGSAUajYCaCAbIBogCSAZSxsoAgAhHCAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogByAHQShqIB9CGIinQf8BcRAIIB+nQf//A3FqNgJEIAcgB0HwAGogBEEDcUEEdGoiDSkDCCIdNwPIASAHIA0pAwAiHjcDwAECQAJAAkAgBygCvAEiDiAepyICaiIWIBNLDQAgAyAHKALEASIKIAJqIgtqIBhLDQAgEiADayALQSBqTw0BCyAHIAcpA8gBNwMQIAcgBykDwAE3AwggAyASIAdBCGogB0G8AWogEyAPIBUgERAeIQsMAQsgAiADaiEIIAMgDhAHIAJBEU8EQCADQRBqIQIDQCACIA5BEGoiDhAHIAJBEGoiAiAISQ0ACwsgCCAdpyIOayECIAcgFjYCvAEgDiAIIA9rSwRAIA4gCCAVa0sEQEFsIQsMAgsgESACIA9rIgJqIhYgCmogEU0EQCAIIBYgChAPGgwCCyAIIBZBACACaxAPIQggByACIApqIgo2AsQBIAggAmshCCAPIQILIA5BEE8EQCAIIApqIQoDQCAIIAIQByACQRBqIQIgCEEQaiIIIApJDQALDAELAkAgDkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgDkECdCIKQcAeaigCAGoiAhAXIAIgCkHgHmooAgBrIQIgBygCxAEhCgwBCyAIIAIQDAsgCkEJSQ0AIAggCmohCiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAKSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAKSQ0ACwsgCxADBEAgCyEQDAQFIA0gDDYCACANIBkgHGogCWs2AgwgDSAJNgIIIA0gFDYCBCAEQQFqIQQgAyALaiEDDAILAAsLIAQgBUgNASAEIBdrIQtBACEEA0AgCyAFSARAIAcgB0HwAGogC0EDcUEEdGoiAikDCCIdNwPIASAHIAIpAwAiHjcDwAECQAJAAkAgBygCvAEiDCAepyICaiIKIBNLDQAgAyAHKALEASIJIAJqIhBqIBhLDQAgEiADayAQQSBqTw0BCyAHIAcpA8gBNwMgIAcgBykDwAE3AxggAyASIAdBGGogB0G8AWogEyAPIBUgERAeIRAMAQsgAiADaiEIIAMgDBAHIAJBEU8EQCADQRBqIQIDQCACIAxBEGoiDBAHIAJBEGoiAiAISQ0ACwsgCCAdpyIGayECIAcgCjYCvAEgBiAIIA9rSwRAIAYgCCAVa0sEQEFsIRAMAgsgESACIA9rIgJqIgwgCWogEU0EQCAIIAwgCRAPGgwCCyAIIAxBACACaxAPIQggByACIAlqIgk2AsQBIAggAmshCCAPIQILIAZBEE8EQCAIIAlqIQYDQCAIIAIQByACQRBqIQIgCEEQaiIIIAZJDQALDAELAkAgBkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgBkECdCIGQcAeaigCAGoiAhAXIAIgBkHgHmooAgBrIQIgBygCxAEhCQwBCyAIIAIQDAsgCUEJSQ0AIAggCWohBiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAGSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAGSQ0ACwsgEBADDQMgC0EBaiELIAMgEGohAwwBCwsDQCAEQQNHBEAgACAEQQJ0IgJqQazQAWogAiAHaigCVDYCACAEQQFqIQQMAQsLIAcoArwBIQgLQbp/IRAgEyAIayIAIBIgA2tLDQAgAwR/IAMgCCAAEAsgAGoFQQALIAFrIRALIAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY0AAQMyIFEAMiBg0AIANBHzYCfCADIANB/ABqIANB+ABqIAQgBCAFaiAGGyIEIAEgAmoiAiAEaxAVIgUQAw0AIAMoAnwiBkEfSw0AIAMoAngiB0EJTw0AIABBiCBqIAMgBkGAC0GADCAHEBggA0E0NgJ8IAMgA0H8AGogA0H4AGogBCAFaiIEIAIgBGsQFSIFEAMNACADKAJ8IgZBNEsNACADKAJ4IgdBCk8NACAAQZAwaiADIAZBgA1B4A4gBxAYIANBIzYCfCADIANB/ABqIANB+ABqIAQgBWoiBCACIARrEBUiBRADDQAgAygCfCIGQSNLDQAgAygCeCIHQQpPDQAgACADIAZBwBBB0BEgBxAYIAQgBWoiBEEMaiIFIAJLDQAgAiAFayEFQQAhAgNAIAJBA0cEQCAEKAAAIgZBf2ogBU8NAiAAIAJBAnRqQZzQAWogBjYCACACQQFqIQIgBEEEaiEEDAELCyAEIAFrIQgLIANBgAFqJAAgCAtGAQN/IABBCGohAyAAKAIEIQJBACEAA0AgACACdkUEQCABIAMgAEEDdGotAAJBFktqIQEgAEEBaiEADAELCyABQQggAmt0C4YDAQV/Qbh/IQcCQCADRQ0AIAItAAAiBEUEQCABQQA2AgBBAUG4fyADQQFGGw8LAn8gAkEBaiIFIARBGHRBGHUiBkF/Sg0AGiAGQX9GBEAgA0EDSA0CIAUvAABBgP4BaiEEIAJBA2oMAQsgA0ECSA0BIAItAAEgBEEIdHJBgIB+aiEEIAJBAmoLIQUgASAENgIAIAVBAWoiASACIANqIgNLDQBBbCEHIABBEGogACAFLQAAIgVBBnZBI0EJIAEgAyABa0HAEEHQEUHwEiAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBmCBqIABBCGogBUEEdkEDcUEfQQggASABIAZqIAgbIgEgAyABa0GAC0GADEGAFyAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBoDBqIABBBGogBUECdkEDcUE0QQkgASABIAZqIAgbIgEgAyABa0GADUHgDkGQGSAAKAKM4QEgACgCnOIBIAQQHyIAEAMNACAAIAFqIAJrIQcLIAcLrQMBCn8jAEGABGsiCCQAAn9BUiACQf8BSw0AGkFUIANBDEsNABogAkEBaiELIABBBGohCUGAgAQgA0F/anRBEHUhCkEAIQJBASEEQQEgA3QiB0F/aiIMIQUDQCACIAtGRQRAAkAgASACQQF0Ig1qLwEAIgZB//8DRgRAIAkgBUECdGogAjoAAiAFQX9qIQVBASEGDAELIARBACAKIAZBEHRBEHVKGyEECyAIIA1qIAY7AQAgAkEBaiECDAELCyAAIAQ7AQIgACADOwEAIAdBA3YgB0EBdmpBA2ohBkEAIQRBACECA0AgBCALRkUEQCABIARBAXRqLgEAIQpBACEAA0AgACAKTkUEQCAJIAJBAnRqIAQ6AAIDQCACIAZqIAxxIgIgBUsNAAsgAEEBaiEADAELCyAEQQFqIQQMAQsLQX8gAg0AGkEAIQIDfyACIAdGBH9BAAUgCCAJIAJBAnRqIgAtAAJBAXRqIgEgAS8BACIBQQFqOwEAIAAgAyABEBRrIgU6AAMgACABIAVB/wFxdCAHazsBACACQQFqIQIMAQsLCyEFIAhBgARqJAAgBQvjBgEIf0FsIQcCQCACQQNJDQACQAJAAkACQCABLQAAIgNBA3EiCUEBaw4DAwEAAgsgACgCiOEBDQBBYg8LIAJBBUkNAkEDIQYgASgAACEFAn8CQAJAIANBAnZBA3EiCEF+aiIEQQFNBEAgBEEBaw0BDAILIAVBDnZB/wdxIQQgBUEEdkH/B3EhAyAIRQwCCyAFQRJ2IQRBBCEGIAVBBHZB//8AcSEDQQAMAQsgBUEEdkH//w9xIgNBgIAISw0DIAEtAARBCnQgBUEWdnIhBEEFIQZBAAshBSAEIAZqIgogAksNAgJAIANBgQZJDQAgACgCnOIBRQ0AQQAhAgNAIAJBg4ABSw0BIAJBQGshAgwAAAsACwJ/IAlBA0YEQCABIAZqIQEgAEHw4gFqIQIgACgCDCEGIAUEQCACIAMgASAEIAYQXwwCCyACIAMgASAEIAYQXQwBCyAAQbjQAWohAiABIAZqIQEgAEHw4gFqIQYgAEGo0ABqIQggBQRAIAggBiADIAEgBCACEF4MAQsgCCAGIAMgASAEIAIQXAsQAw0CIAAgAzYCgOIBIABBATYCiOEBIAAgAEHw4gFqNgLw4QEgCUECRgRAIAAgAEGo0ABqNgIMCyAAIANqIgBBiOMBakIANwAAIABBgOMBakIANwAAIABB+OIBakIANwAAIABB8OIBakIANwAAIAoPCwJ/AkACQAJAIANBAnZBA3FBf2oiBEECSw0AIARBAWsOAgACAQtBASEEIANBA3YMAgtBAiEEIAEvAABBBHYMAQtBAyEEIAEQIUEEdgsiAyAEaiIFQSBqIAJLBEAgBSACSw0CIABB8OIBaiABIARqIAMQCyEBIAAgAzYCgOIBIAAgATYC8OEBIAEgA2oiAEIANwAYIABCADcAECAAQgA3AAggAEIANwAAIAUPCyAAIAM2AoDiASAAIAEgBGo2AvDhASAFDwsCfwJAAkACQCADQQJ2QQNxQX9qIgRBAksNACAEQQFrDgIAAgELQQEhByADQQN2DAILQQIhByABLwAAQQR2DAELIAJBBEkgARAhIgJBj4CAAUtyDQFBAyEHIAJBBHYLIQIgAEHw4gFqIAEgB2otAAAgAkEgahAQIQEgACACNgKA4gEgACABNgLw4QEgB0EBaiEHCyAHC0sAIABC+erQ0OfJoeThADcDICAAQgA3AxggAELP1tO+0ser2UI3AxAgAELW64Lu6v2J9eAANwMIIABCADcDACAAQShqQQBBKBAQGgviAgICfwV+IABBKGoiASAAKAJIaiECAn4gACkDACIDQiBaBEAgACkDECIEQgeJIAApAwgiBUIBiXwgACkDGCIGQgyJfCAAKQMgIgdCEol8IAUQGSAEEBkgBhAZIAcQGQwBCyAAKQMYQsXP2bLx5brqJ3wLIAN8IQMDQCABQQhqIgAgAk0EQEIAIAEpAAAQCSADhUIbiUKHla+vmLbem55/fkLj3MqV/M7y9YV/fCEDIAAhAQwBCwsCQCABQQRqIgAgAksEQCABIQAMAQsgASgAAK1Ch5Wvr5i23puef34gA4VCF4lCz9bTvtLHq9lCfkL5893xmfaZqxZ8IQMLA0AgACACSQRAIAAxAABCxc/ZsvHluuonfiADhUILiUKHla+vmLbem55/fiEDIABBAWohAAwBCwsgA0IhiCADhULP1tO+0ser2UJ+IgNCHYggA4VC+fPd8Zn2masWfiIDQiCIIAOFC+8CAgJ/BH4gACAAKQMAIAKtfDcDAAJAAkAgACgCSCIDIAJqIgRBH00EQCABRQ0BIAAgA2pBKGogASACECAgACgCSCACaiEEDAELIAEgAmohAgJ/IAMEQCAAQShqIgQgA2ogAUEgIANrECAgACAAKQMIIAQpAAAQCTcDCCAAIAApAxAgACkAMBAJNwMQIAAgACkDGCAAKQA4EAk3AxggACAAKQMgIABBQGspAAAQCTcDICAAKAJIIQMgAEEANgJIIAEgA2tBIGohAQsgAUEgaiACTQsEQCACQWBqIQMgACkDICEFIAApAxghBiAAKQMQIQcgACkDCCEIA0AgCCABKQAAEAkhCCAHIAEpAAgQCSEHIAYgASkAEBAJIQYgBSABKQAYEAkhBSABQSBqIgEgA00NAAsgACAFNwMgIAAgBjcDGCAAIAc3AxAgACAINwMICyABIAJPDQEgAEEoaiABIAIgAWsiBBAgCyAAIAQ2AkgLCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQEBogAwVBun8LCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQCxogAwVBun8LC6gCAQZ/IwBBEGsiByQAIABB2OABaikDAEKAgIAQViEIQbh/IQUCQCAEQf//B0sNACAAIAMgBBBCIgUQAyIGDQAgACgCnOIBIQkgACAHQQxqIAMgAyAFaiAGGyIKIARBACAFIAYbayIGEEAiAxADBEAgAyEFDAELIAcoAgwhBCABRQRAQbp/IQUgBEEASg0BCyAGIANrIQUgAyAKaiEDAkAgCQRAIABBADYCnOIBDAELAkACQAJAIARBBUgNACAAQdjgAWopAwBCgICACFgNAAwBCyAAQQA2ApziAQwBCyAAKAIIED8hBiAAQQA2ApziASAGQRRPDQELIAAgASACIAMgBSAEIAgQOSEFDAELIAAgASACIAMgBSAEIAgQOiEFCyAHQRBqJAAgBQtnACAAQdDgAWogASACIAAoAuzhARAuIgEQAwRAIAEPC0G4fyECAkAgAQ0AIABB7OABaigCACIBBEBBYCECIAAoApjiASABRw0BC0EAIQIgAEHw4AFqKAIARQ0AIABBkOEBahBDCyACCycBAX8QVyIERQRAQUAPCyAEIAAgASACIAMgBBBLEE8hACAEEFYgAAs/AQF/AkACQAJAIAAoAqDiAUEBaiIBQQJLDQAgAUEBaw4CAAECCyAAEDBBAA8LIABBADYCoOIBCyAAKAKU4gELvAMCB38BfiMAQRBrIgkkAEG4fyEGAkAgBCgCACIIQQVBCSAAKALs4QEiBRtJDQAgAygCACIHQQFBBSAFGyAFEC8iBRADBEAgBSEGDAELIAggBUEDakkNACAAIAcgBRBJIgYQAw0AIAEgAmohCiAAQZDhAWohCyAIIAVrIQIgBSAHaiEHIAEhBQNAIAcgAiAJECwiBhADDQEgAkF9aiICIAZJBEBBuH8hBgwCCyAJKAIAIghBAksEQEFsIQYMAgsgB0EDaiEHAn8CQAJAAkAgCEEBaw4CAgABCyAAIAUgCiAFayAHIAYQSAwCCyAFIAogBWsgByAGEEcMAQsgBSAKIAVrIActAAAgCSgCCBBGCyIIEAMEQCAIIQYMAgsgACgC8OABBEAgCyAFIAgQRQsgAiAGayECIAYgB2ohByAFIAhqIQUgCSgCBEUNAAsgACkD0OABIgxCf1IEQEFsIQYgDCAFIAFrrFINAQsgACgC8OABBEBBaiEGIAJBBEkNASALEEQhDCAHKAAAIAynRw0BIAdBBGohByACQXxqIQILIAMgBzYCACAEIAI2AgAgBSABayEGCyAJQRBqJAAgBgsuACAAECsCf0EAQQAQAw0AGiABRSACRXJFBEBBYiAAIAEgAhA9EAMNARoLQQALCzcAIAEEQCAAIAAoAsTgASABKAIEIAEoAghqRzYCnOIBCyAAECtBABADIAFFckUEQCAAIAEQWwsL0QIBB38jAEEQayIGJAAgBiAENgIIIAYgAzYCDCAFBEAgBSgCBCEKIAUoAgghCQsgASEIAkACQANAIAAoAuzhARAWIQsCQANAIAQgC0kNASADKAAAQXBxQdDUtMIBRgRAIAMgBBAiIgcQAw0EIAQgB2shBCADIAdqIQMMAQsLIAYgAzYCDCAGIAQ2AggCQCAFBEAgACAFEE5BACEHQQAQA0UNAQwFCyAAIAogCRBNIgcQAw0ECyAAIAgQUCAMQQFHQQAgACAIIAIgBkEMaiAGQQhqEEwiByIDa0EAIAMQAxtBCkdyRQRAQbh/IQcMBAsgBxADDQMgAiAHayECIAcgCGohCEEBIQwgBigCDCEDIAYoAgghBAwBCwsgBiADNgIMIAYgBDYCCEG4fyEHIAQNASAIIAFrIQcMAQsgBiADNgIMIAYgBDYCCAsgBkEQaiQAIAcLRgECfyABIAAoArjgASICRwRAIAAgAjYCxOABIAAgATYCuOABIAAoArzgASEDIAAgATYCvOABIAAgASADIAJrajYCwOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEEdCAAbiECCyAAQQh2IgEgAkEYbCIAQYwIaigCAGwgAEGICGooAgBqIgJBA3YgAmogAEGACGooAgAgAEGECGooAgAgAWxqSQs3ACAAIAMgBCAFQYAQEDMiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQMgVBuH8LC78DAQN/IwBBIGsiBSQAIAVBCGogAiADEAYiAhADRQRAIAAgAWoiB0F9aiEGIAUgBBAOIARBBGohAiAFLQACIQMDQEEAIAAgBkkgBUEIahAEGwRAIAAgAiAFQQhqIAMQAkECdGoiBC8BADsAACAFQQhqIAQtAAIQASAAIAQtAANqIgQgAiAFQQhqIAMQAkECdGoiAC8BADsAACAFQQhqIAAtAAIQASAEIAAtAANqIQAMAQUgB0F+aiEEA0AgBUEIahAEIAAgBEtyRQRAIAAgAiAFQQhqIAMQAkECdGoiBi8BADsAACAFQQhqIAYtAAIQASAAIAYtAANqIQAMAQsLA0AgACAES0UEQCAAIAIgBUEIaiADEAJBAnRqIgYvAQA7AAAgBUEIaiAGLQACEAEgACAGLQADaiEADAELCwJAIAAgB08NACAAIAIgBUEIaiADEAIiA0ECdGoiAC0AADoAACAALQADQQFGBEAgBUEIaiAALQACEAEMAQsgBSgCDEEfSw0AIAVBCGogAiADQQJ0ai0AAhABIAUoAgxBIUkNACAFQSA2AgwLIAFBbCAFQQhqEAobIQILCwsgBUEgaiQAIAILkgIBBH8jAEFAaiIJJAAgCSADQTQQCyEDAkAgBEECSA0AIAMgBEECdGooAgAhCSADQTxqIAgQIyADQQE6AD8gAyACOgA+QQAhBCADKAI8IQoDQCAEIAlGDQEgACAEQQJ0aiAKNgEAIARBAWohBAwAAAsAC0EAIQkDQCAGIAlGRQRAIAMgBSAJQQF0aiIKLQABIgtBAnRqIgwoAgAhBCADQTxqIAotAABBCHQgCGpB//8DcRAjIANBAjoAPyADIAcgC2siCiACajoAPiAEQQEgASAKa3RqIQogAygCPCELA0AgACAEQQJ0aiALNgEAIARBAWoiBCAKSQ0ACyAMIAo2AgAgCUEBaiEJDAELCyADQUBrJAALowIBCX8jAEHQAGsiCSQAIAlBEGogBUE0EAsaIAcgBmshDyAHIAFrIRADQAJAIAMgCkcEQEEBIAEgByACIApBAXRqIgYtAAEiDGsiCGsiC3QhDSAGLQAAIQ4gCUEQaiAMQQJ0aiIMKAIAIQYgCyAPTwRAIAAgBkECdGogCyAIIAUgCEE0bGogCCAQaiIIQQEgCEEBShsiCCACIAQgCEECdGooAgAiCEEBdGogAyAIayAHIA4QYyAGIA1qIQgMAgsgCUEMaiAOECMgCUEBOgAPIAkgCDoADiAGIA1qIQggCSgCDCELA0AgBiAITw0CIAAgBkECdGogCzYBACAGQQFqIQYMAAALAAsgCUHQAGokAA8LIAwgCDYCACAKQQFqIQoMAAALAAs0ACAAIAMgBCAFEDYiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQNAVBuH8LCyMAIAA/AEEQdGtB//8DakEQdkAAQX9GBEBBAA8LQQAQAEEBCzsBAX8gAgRAA0AgACABIAJBgCAgAkGAIEkbIgMQCyEAIAFBgCBqIQEgAEGAIGohACACIANrIgINAAsLCwYAIAAQAwsLqBUJAEGICAsNAQAAAAEAAAACAAAAAgBBoAgLswYBAAAAAQAAAAIAAAACAAAAJgAAAIIAAAAhBQAASgAAAGcIAAAmAAAAwAEAAIAAAABJBQAASgAAAL4IAAApAAAALAIAAIAAAABJBQAASgAAAL4IAAAvAAAAygIAAIAAAACKBQAASgAAAIQJAAA1AAAAcwMAAIAAAACdBQAASgAAAKAJAAA9AAAAgQMAAIAAAADrBQAASwAAAD4KAABEAAAAngMAAIAAAABNBgAASwAAAKoKAABLAAAAswMAAIAAAADBBgAATQAAAB8NAABNAAAAUwQAAIAAAAAjCAAAUQAAAKYPAABUAAAAmQQAAIAAAABLCQAAVwAAALESAABYAAAA2gQAAIAAAABvCQAAXQAAACMUAABUAAAARQUAAIAAAABUCgAAagAAAIwUAABqAAAArwUAAIAAAAB2CQAAfAAAAE4QAAB8AAAA0gIAAIAAAABjBwAAkQAAAJAHAACSAAAAAAAAAAEAAAABAAAABQAAAA0AAAAdAAAAPQAAAH0AAAD9AAAA/QEAAP0DAAD9BwAA/Q8AAP0fAAD9PwAA/X8AAP3/AAD9/wEA/f8DAP3/BwD9/w8A/f8fAP3/PwD9/38A/f//AP3//wH9//8D/f//B/3//w/9//8f/f//P/3//38AAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABEAAAASAAAAEwAAABQAAAAVAAAAFgAAABcAAAAYAAAAGQAAABoAAAAbAAAAHAAAAB0AAAAeAAAAHwAAAAMAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAAAAwAAAANAAAADgAAAA8AAAAQAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAZAAAAGgAAABsAAAAcAAAAHQAAAB4AAAAfAAAAIAAAACEAAAAiAAAAIwAAACUAAAAnAAAAKQAAACsAAAAvAAAAMwAAADsAAABDAAAAUwAAAGMAAACDAAAAAwEAAAMCAAADBAAAAwgAAAMQAAADIAAAA0AAAAOAAAADAAEAQeAPC1EBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAEAAAABQAAAAcAAAAIAAAACQAAAAoAAAALAAAADAAAAA0AAAAOAAAADwAAABAAQcQQC4sBAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABIAAAAUAAAAFgAAABgAAAAcAAAAIAAAACgAAAAwAAAAQAAAAIAAAAAAAQAAAAIAAAAEAAAACAAAABAAAAAgAAAAQAAAAIAAAAAAAQBBkBIL5gQBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAAAEAAAAEAAAACAAAAAAAAAABAAEBBgAAAAAAAAQAAAAAEAAABAAAAAAgAAAFAQAAAAAAAAUDAAAAAAAABQQAAAAAAAAFBgAAAAAAAAUHAAAAAAAABQkAAAAAAAAFCgAAAAAAAAUMAAAAAAAABg4AAAAAAAEFEAAAAAAAAQUUAAAAAAABBRYAAAAAAAIFHAAAAAAAAwUgAAAAAAAEBTAAAAAgAAYFQAAAAAAABwWAAAAAAAAIBgABAAAAAAoGAAQAAAAADAYAEAAAIAAABAAAAAAAAAAEAQAAAAAAAAUCAAAAIAAABQQAAAAAAAAFBQAAACAAAAUHAAAAAAAABQgAAAAgAAAFCgAAAAAAAAULAAAAAAAABg0AAAAgAAEFEAAAAAAAAQUSAAAAIAABBRYAAAAAAAIFGAAAACAAAwUgAAAAAAADBSgAAAAAAAYEQAAAABAABgRAAAAAIAAHBYAAAAAAAAkGAAIAAAAACwYACAAAMAAABAAAAAAQAAAEAQAAACAAAAUCAAAAIAAABQMAAAAgAAAFBQAAACAAAAUGAAAAIAAABQgAAAAgAAAFCQAAACAAAAULAAAAIAAABQwAAAAAAAAGDwAAACAAAQUSAAAAIAABBRQAAAAgAAIFGAAAACAAAgUcAAAAIAADBSgAAAAgAAQFMAAAAAAAEAYAAAEAAAAPBgCAAAAAAA4GAEAAAAAADQYAIABBgBcLhwIBAAEBBQAAAAAAAAUAAAAAAAAGBD0AAAAAAAkF/QEAAAAADwX9fwAAAAAVBf3/HwAAAAMFBQAAAAAABwR9AAAAAAAMBf0PAAAAABIF/f8DAAAAFwX9/38AAAAFBR0AAAAAAAgE/QAAAAAADgX9PwAAAAAUBf3/DwAAAAIFAQAAABAABwR9AAAAAAALBf0HAAAAABEF/f8BAAAAFgX9/z8AAAAEBQ0AAAAQAAgE/QAAAAAADQX9HwAAAAATBf3/BwAAAAEFAQAAABAABgQ9AAAAAAAKBf0DAAAAABAF/f8AAAAAHAX9//8PAAAbBf3//wcAABoF/f//AwAAGQX9//8BAAAYBf3//wBBkBkLhgQBAAEBBgAAAAAAAAYDAAAAAAAABAQAAAAgAAAFBQAAAAAAAAUGAAAAAAAABQgAAAAAAAAFCQAAAAAAAAULAAAAAAAABg0AAAAAAAAGEAAAAAAAAAYTAAAAAAAABhYAAAAAAAAGGQAAAAAAAAYcAAAAAAAABh8AAAAAAAAGIgAAAAAAAQYlAAAAAAABBikAAAAAAAIGLwAAAAAAAwY7AAAAAAAEBlMAAAAAAAcGgwAAAAAACQYDAgAAEAAABAQAAAAAAAAEBQAAACAAAAUGAAAAAAAABQcAAAAgAAAFCQAAAAAAAAUKAAAAAAAABgwAAAAAAAAGDwAAAAAAAAYSAAAAAAAABhUAAAAAAAAGGAAAAAAAAAYbAAAAAAAABh4AAAAAAAAGIQAAAAAAAQYjAAAAAAABBicAAAAAAAIGKwAAAAAAAwYzAAAAAAAEBkMAAAAAAAUGYwAAAAAACAYDAQAAIAAABAQAAAAwAAAEBAAAABAAAAQFAAAAIAAABQcAAAAgAAAFCAAAACAAAAUKAAAAIAAABQsAAAAAAAAGDgAAAAAAAAYRAAAAAAAABhQAAAAAAAAGFwAAAAAAAAYaAAAAAAAABh0AAAAAAAAGIAAAAAAAEAYDAAEAAAAPBgOAAAAAAA4GA0AAAAAADQYDIAAAAAAMBgMQAAAAAAsGAwgAAAAACgYDBABBpB0L2QEBAAAAAwAAAAcAAAAPAAAAHwAAAD8AAAB/AAAA/wAAAP8BAAD/AwAA/wcAAP8PAAD/HwAA/z8AAP9/AAD//wAA//8BAP//AwD//wcA//8PAP//HwD//z8A//9/AP///wD///8B////A////wf///8P////H////z////9/AAAAAAEAAAACAAAABAAAAAAAAAACAAAABAAAAAgAAAAAAAAAAQAAAAIAAAABAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAACAAAAAcAAAAIAAAACQAAAAoAAAALAEGgIAsDwBBQ",i_=new WeakMap;let r_,s_=0;class a_ extends Ah{constructor(t){super(t),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new Ry,this.workerSourceURL="",this.workerConfig=null,"undefined"!=typeof MSC_TRANSCODER&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(t){return this.transcoderPath=t,this}setWorkerLimit(t){return this.workerPool.setWorkerLimit(t),this}async detectSupportAsync(t){return this.workerConfig={astcSupported:await t.hasFeatureAsync("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:await t.hasFeatureAsync("texture-compression-etc1"),etc2Supported:await t.hasFeatureAsync("texture-compression-etc2"),dxtSupported:await t.hasFeatureAsync("texture-compression-bc"),bptcSupported:await t.hasFeatureAsync("texture-compression-bptc"),pvrtcSupported:await t.hasFeatureAsync("texture-compression-pvrtc")},this}detectSupport(t){return!0===t.isWebGPURenderer?this.workerConfig={astcSupported:t.hasFeature("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:t.hasFeature("texture-compression-etc1"),etc2Supported:t.hasFeature("texture-compression-etc2"),dxtSupported:t.hasFeature("texture-compression-bc"),bptcSupported:t.hasFeature("texture-compression-bptc"),pvrtcSupported:t.hasFeature("texture-compression-pvrtc")}:this.workerConfig={astcSupported:t.extensions.has("WEBGL_compressed_texture_astc"),astcHDRSupported:t.extensions.has("WEBGL_compressed_texture_astc")&&t.extensions.get("WEBGL_compressed_texture_astc").getSupportedProfiles().includes("hdr"),etc1Supported:t.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:t.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:t.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:t.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:t.extensions.has("WEBGL_compressed_texture_pvrtc")||t.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},this}init(){if(!this.transcoderPending){const t=new _h(this.manager);t.setPath(this.transcoderPath),t.setWithCredentials(this.withCredentials);const e=t.loadAsync("basis_transcoder.js"),n=new _h(this.manager);n.setPath(this.transcoderPath),n.setResponseType("arraybuffer"),n.setWithCredentials(this.withCredentials);const i=n.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([e,i]).then((([t,e])=>{const n=a_.BasisWorker.toString(),i=["/* constants */","let _EngineFormat = "+JSON.stringify(a_.EngineFormat),"let _EngineType = "+JSON.stringify(a_.EngineType),"let _TranscoderFormat = "+JSON.stringify(a_.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(a_.BasisFormat),"/* basis_transcoder.js */",t,"/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i])),this.transcoderBinary=e,this.workerPool.setWorkerCreator((()=>{const t=new Worker(this.workerSourceURL),e=this.transcoderBinary.slice(0);return t.postMessage({type:"init",config:this.workerConfig,transcoderBinary:e},[e]),t}))})),s_>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),s_++}return this.transcoderPending}load(t,e,n,i){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const r=new _h(this.manager);r.setResponseType("arraybuffer"),r.setWithCredentials(this.withCredentials),r.load(t,(t=>{this.parse(t,e,i)}),n,i)}parse(t,e,n){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if(i_.has(t))return i_.get(t).promise.then(e).catch(n);this._createTexture(t).then((t=>e?e(t):null)).catch(n)}_createTextureFrom(t,e){const{type:n,error:i,data:{faces:r,width:s,height:a,format:o,type:l,dfdFlags:c}}=t;if("error"===n)return Promise.reject(i);let h;if(6===e.faceCount)h=new hl(r,o,l);else{const t=r[0].mipmaps;h=e.layerCount>1?new cl(t,s,a,e.layerCount,o,l):new ll(t,s,a,o,l)}return h.minFilter=1===r[0].mipmaps.length?Lt:Ft,h.magFilter=Lt,h.generateMipmaps=!1,h.needsUpdate=!0,h.colorSpace=h_(e),h.premultiplyAlpha=!!(1&c),h}async _createTexture(t,e={}){const n=function(t){const e=new Uint8Array(t.buffer,t.byteOffset,Yy.length);if(e[0]!==Yy[0]||e[1]!==Yy[1]||e[2]!==Yy[2]||e[3]!==Yy[3]||e[4]!==Yy[4]||e[5]!==Yy[5]||e[6]!==Yy[6]||e[7]!==Yy[7]||e[8]!==Yy[8]||e[9]!==Yy[9]||e[10]!==Yy[10]||e[11]!==Yy[11])throw new Error("Missing KTX 2.0 identifier.");const n=new qy,i=17*Uint32Array.BYTES_PER_ELEMENT,r=new Xy(t,Yy.length,i,!0);n.vkFormat=r._nextUint32(),n.typeSize=r._nextUint32(),n.pixelWidth=r._nextUint32(),n.pixelHeight=r._nextUint32(),n.pixelDepth=r._nextUint32(),n.layerCount=r._nextUint32(),n.faceCount=r._nextUint32();const s=r._nextUint32();n.supercompressionScheme=r._nextUint32();const a=r._nextUint32(),o=r._nextUint32(),l=r._nextUint32(),c=r._nextUint32(),h=r._nextUint64(),u=r._nextUint64(),d=new Xy(t,Yy.length+i,3*s*8,!0);for(let e=0;e{const e=new e_;await e.init(),t(e)}))),n=await r_);const i=[];for(let r=0;r>r),a=Math.max(1,t.pixelHeight>>r),o=t.pixelDepth?Math.max(1,t.pixelDepth>>r):0,l=t.levels[r];let c,h;if(0===t.supercompressionScheme)c=l.levelData;else{if(2!==t.supercompressionScheme)throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");c=n.decode(l.levelData,l.uncompressedByteLength)}h=c_[e]===Wt?new Float32Array(c.buffer,c.byteOffset,c.byteLength/Float32Array.BYTES_PER_ELEMENT):c_[e]===jt?new Uint16Array(c.buffer,c.byteOffset,c.byteLength/Uint16Array.BYTES_PER_ELEMENT):c,i.push({data:h,width:s,height:a,depth:o})}let r;if(o_.has(l_[e]))r=0===t.pixelDepth?new $a(i[0].data,t.pixelWidth,t.pixelHeight):new Oi(i[0].data,t.pixelWidth,t.pixelHeight,t.pixelDepth);else{if(t.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");r=new ll(i,t.pixelWidth,t.pixelHeight),r.minFilter=1===i.length?Lt:Ft,r.magFilter=Lt}return r.mipmaps=i,r.type=c_[e],r.format=l_[e],r.colorSpace=h_(t),r.needsUpdate=!0,Promise.resolve(r)}(n);const r=e,s=this.init().then((()=>this.workerPool.postMessage({type:"transcode",buffer:t,taskConfig:r},[t]))).then((t=>this._createTextureFrom(t.data,n)));return i_.set(t,{promise:s}),s}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),s_--,this}}a_.BasisFormat={ETC1S:0,UASTC:1,UASTC_HDR:2},a_.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16,BC6H:22,RGB_HALF:24,RGBA_HALF:25},a_.EngineFormat={RGBAFormat:$t,RGBA_ASTC_4x4_Format:xe,RGB_BPTC_UNSIGNED_Format:Fe,RGBA_BPTC_Format:Ue,RGBA_ETC2_EAC_Format:_e,RGBA_PVRTC_4BPPV1_Format:ge,RGBA_S3TC_DXT5_Format:pe,RGB_ETC1_Format:ve,RGB_ETC2_Format:ye,RGB_PVRTC_4BPPV1_Format:fe,RGBA_S3TC_DXT1_Format:ue},a_.EngineType={UnsignedByteType:kt,HalfFloatType:jt,FloatType:Wt},a_.BasisWorker=function(){let t,e,n;const i=_EngineFormat,r=_EngineType,s=_TranscoderFormat,a=_BasisFormat;self.addEventListener("message",(function(i){const s=i.data;switch(s.type){case"init":t=s.config,o=s.transcoderBinary,e=new Promise((t=>{n={wasmBinary:o,onRuntimeInitialized:t},BASIS(n)})).then((()=>{n.initializeBasis(),void 0===n.KTX2File&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")}));break;case"transcode":e.then((()=>{try{const{faces:e,buffers:i,width:o,height:u,hasAlpha:d,format:p,type:f,dfdFlags:m}=function(e){const i=new n.KTX2File(new Uint8Array(e));function s(){i.close(),i.delete()}if(!i.isValid())throw s(),new Error("THREE.KTX2Loader:\tInvalid or unsupported .ktx2 file");let o;if(i.isUASTC())o=a.UASTC;else if(i.isETC1S())o=a.ETC1S;else{if(!i.isHDR())throw new Error("THREE.KTX2Loader: Unknown Basis encoding");o=a.UASTC_HDR}const u=i.getWidth(),d=i.getHeight(),p=i.getLayers()||1,f=i.getLevels(),m=i.getFaces(),g=i.getHasAlpha(),A=i.getDFDFlags(),{transcoderFormat:v,engineFormat:y,engineType:_}=function(e,n,i,r){const s=l[e];for(let a=0;a1?(o=c.origWidth,l=c.origHeight):(o=c.width,l=c.height);let h=new Uint8Array(i.getImageTranscodedSizeInBytes(n,e,0,v));const u=i.transcodeImage(h,n,e,t,v,0,-1,-1);if(_===r.HalfFloatType&&(h=new Uint16Array(h.buffer,h.byteOffset,h.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!u)throw s(),new Error("THREE.KTX2Loader: .transcodeImage failed.");a.push(h)}const c=h(a);e.push({data:c,width:o,height:l}),w.push(c.buffer)}x.push({mipmaps:e,width:u,height:d,format:y,type:_})}return s(),{faces:x,buffers:w,width:u,height:d,hasAlpha:g,dfdFlags:A,format:y,type:_}}(s.buffer);self.postMessage({type:"transcode",id:s.id,data:{faces:e,width:o,height:u,hasAlpha:d,format:p,type:f,dfdFlags:m}},i)}catch(t){console.error(t),self.postMessage({type:"error",id:s.id,error:t.message})}}))}var o}));const o=[{if:"astcSupported",basisFormat:[a.UASTC],transcoderFormat:[s.ASTC_4x4,s.ASTC_4x4],engineFormat:[i.RGBA_ASTC_4x4_Format,i.RGBA_ASTC_4x4_Format],engineType:[r.UnsignedByteType],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.BC7_M5,s.BC7_M5],engineFormat:[i.RGBA_BPTC_Format,i.RGBA_BPTC_Format],engineType:[r.UnsignedByteType],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.BC1,s.BC3],engineFormat:[i.RGBA_S3TC_DXT1_Format,i.RGBA_S3TC_DXT5_Format],engineType:[r.UnsignedByteType],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.ETC1,s.ETC2],engineFormat:[i.RGB_ETC2_Format,i.RGBA_ETC2_EAC_Format],engineType:[r.UnsignedByteType],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.ETC1],engineFormat:[i.RGB_ETC1_Format],engineType:[r.UnsignedByteType],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.PVRTC1_4_RGB,s.PVRTC1_4_RGBA],engineFormat:[i.RGB_PVRTC_4BPPV1_Format,i.RGBA_PVRTC_4BPPV1_Format],engineType:[r.UnsignedByteType],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0},{if:"bptcSupported",basisFormat:[a.UASTC_HDR],transcoderFormat:[s.BC6H],engineFormat:[i.RGB_BPTC_UNSIGNED_Format],engineType:[r.HalfFloatType],priorityHDR:1,needsPowerOfTwo:!1},{basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[s.RGBA32,s.RGBA32],engineFormat:[i.RGBAFormat,i.RGBAFormat],engineType:[r.UnsignedByteType,r.UnsignedByteType],priorityETC1S:100,priorityUASTC:100,needsPowerOfTwo:!1},{basisFormat:[a.UASTC_HDR],transcoderFormat:[s.RGBA_HALF],engineFormat:[i.RGBAFormat],engineType:[r.HalfFloatType],priorityHDR:100,needsPowerOfTwo:!1}],l={[a.ETC1S]:o.filter((t=>t.basisFormat.includes(a.ETC1S))).sort(((t,e)=>t.priorityUASTC-e.priorityUASTC)),[a.UASTC]:o.filter((t=>t.basisFormat.includes(a.UASTC))).sort(((t,e)=>t.priorityUASTC-e.priorityUASTC)),[a.UASTC_HDR]:o.filter((t=>t.basisFormat.includes(a.UASTC_HDR))).sort(((t,e)=>t.priorityHDR-e.priorityHDR))};function c(t){return t<=2||!(t&t-1)&&0!==t}function h(t){if(1===t.length)return t[0];let e=0;for(let n=0;nt&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Y"===i.name&&Math.abs(b_.copy(U_).applyQuaternion(e).dot(this.eye))>t&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Z"===i.name&&Math.abs(b_.copy(N_).applyQuaternion(e).dot(this.eye))>t&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"XY"===i.name&&Math.abs(b_.copy(N_).applyQuaternion(e).dot(this.eye)).9&&(i.visible=!1)),"Y"===this.axis&&(f_.setFromEuler(S_.set(0,0,Math.PI/2)),i.quaternion.copy(e).multiply(f_),Math.abs(b_.copy(U_).applyQuaternion(e).dot(this.eye))>.9&&(i.visible=!1)),"Z"===this.axis&&(f_.setFromEuler(S_.set(0,Math.PI/2,0)),i.quaternion.copy(e).multiply(f_),Math.abs(b_.copy(N_).applyQuaternion(e).dot(this.eye))>.9&&(i.visible=!1)),"XYZE"===this.axis&&(f_.setFromEuler(S_.set(0,Math.PI/2,0)),b_.copy(this.rotationAxis),i.quaternion.setFromRotationMatrix(T_.lookAt(I_,b_,U_)),i.quaternion.multiply(f_),i.visible=this.dragging),"E"===this.axis&&(i.visible=!1)):"START"===i.name?(i.position.copy(this.worldPositionStart),i.visible=this.dragging):"END"===i.name?(i.position.copy(this.worldPosition),i.visible=this.dragging):"DELTA"===i.name?(i.position.copy(this.worldPositionStart),i.quaternion.copy(this.worldQuaternionStart),d_.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),d_.applyQuaternion(this.worldQuaternionStart.clone().invert()),i.scale.copy(d_),i.visible=this.dragging):(i.quaternion.copy(e),this.dragging?i.position.copy(this.worldPositionStart):i.position.copy(this.worldPosition),this.axis&&(i.visible=-1!==this.axis.search(i.name)))}super.updateMatrixWorld(t)}}class G_ extends Ks{constructor(){super(new Mc(1e5,1e5,2,2),new ps({visible:!1,wireframe:!0,side:S,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(t){let e=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(e="local"),F_.copy(L_).applyQuaternion("local"===e?this.worldQuaternion:R_),O_.copy(U_).applyQuaternion("local"===e?this.worldQuaternion:R_),k_.copy(N_).applyQuaternion("local"===e?this.worldQuaternion:R_),b_.copy(O_),this.mode){case"translate":case"scale":switch(this.axis){case"X":b_.copy(this.eye).cross(F_),D_.copy(F_).cross(b_);break;case"Y":b_.copy(this.eye).cross(O_),D_.copy(O_).cross(b_);break;case"Z":b_.copy(this.eye).cross(k_),D_.copy(k_).cross(b_);break;case"XY":D_.copy(k_);break;case"YZ":D_.copy(F_);break;case"XZ":b_.copy(k_),D_.copy(O_);break;case"XYZ":case"E":D_.set(0,0,0)}break;default:D_.set(0,0,0)}0===D_.length()?this.quaternion.copy(this.cameraQuaternion):(P_.lookAt(d_.set(0,0,0),D_,b_),this.quaternion.setFromRotationMatrix(P_)),super.updateMatrixWorld(t)}}const H_="csm_DiffuseColor",V_="csm_Roughness",W_="csm_Metalness",j_="csm_Emissive",q_="csm_AO",X_="csm_Bump",Y_="csm_FragNormal",J_="csm_Clearcoat",K_="csm_ClearcoatRoughness",Z_="csm_ClearcoatNormal",$_="csm_Transmission",tx="csm_Thickness",ex="csm_Iridescence",nx="csm_PointSize",ix="csm_FragColor",rx="csm_DepthAlpha",sx="csm_UnlitFac",ax="csm_Position",ox="csm_PositionRaw",lx="csm_Normal",cx={[`${ax}`]:"*",[`${ox}`]:"*",[`${lx}`]:"*",[`${rx}`]:"*",[`${nx}`]:["PointsMaterial"],[`${H_}`]:"*",[`${ix}`]:"*",[`${Y_}`]:"*",[`${sx}`]:"*",[`${j_}`]:["MeshStandardMaterial","MeshPhysicalMaterial"],[`${V_}`]:["MeshStandardMaterial","MeshPhysicalMaterial"],[`${W_}`]:["MeshStandardMaterial","MeshPhysicalMaterial"],[`${ex}`]:["MeshStandardMaterial","MeshPhysicalMaterial"],[`${q_}`]:["MeshStandardMaterial","MeshPhysicalMaterial","MeshBasicMaterial","MeshLambertMaterial","MeshPhongMaterial","MeshToonMaterial"],[`${X_}`]:["MeshLambertMaterial","MeshMatcapMaterial","MeshNormalMaterial","MeshPhongMaterial","MeshPhysicalMaterial","MeshStandardMaterial","MeshToonMaterial","ShadowMaterial"],[`${J_}`]:["MeshPhysicalMaterial"],[`${K_}`]:["MeshPhysicalMaterial"],[`${Z_}`]:["MeshPhysicalMaterial"],[`${$_}`]:["MeshPhysicalMaterial"],[`${tx}`]:["MeshPhysicalMaterial"]},hx={"*":{"#include ":Od.lights_physical_fragment,"#include ":Od.transmission_fragment},[`${lx}`]:{"#include ":`\n vec3 objectNormal = ${lx};\n #ifdef USE_TANGENT\n\t vec3 objectTangent = vec3( tangent.xyz );\n #endif\n `},[`${ax}`]:{"#include ":`\n vec3 transformed = ${ax};\n `},[`${ox}`]:{"#include ":`\n vec4 csm_internal_positionUnprojected = ${ox};\n mat4x4 csm_internal_unprojectMatrix = projectionMatrix * modelViewMatrix;\n #ifdef USE_INSTANCING\n csm_internal_unprojectMatrix = csm_internal_unprojectMatrix * instanceMatrix;\n #endif\n csm_internal_positionUnprojected = inverse(csm_internal_unprojectMatrix) * csm_internal_positionUnprojected;\n vec3 transformed = csm_internal_positionUnprojected.xyz;\n `},[`${nx}`]:{"gl_PointSize = size;":`\n gl_PointSize = ${nx};\n `},[`${H_}`]:{"#include ":`\n #include \n diffuseColor = ${H_};\n `},[`${ix}`]:{"#include ":`\n #include \n gl_FragColor = mix(gl_FragColor, ${ix}, ${sx});\n `},[`${j_}`]:{"vec3 totalEmissiveRadiance = emissive;":`\n vec3 totalEmissiveRadiance = ${j_};\n `},[`${V_}`]:{"#include ":`\n #include \n roughnessFactor = ${V_};\n `},[`${W_}`]:{"#include ":`\n #include \n metalnessFactor = ${W_};\n `},[`${q_}`]:{"#include ":`\n #include \n reflectedLight.indirectDiffuse *= 1. - ${q_};\n `},[`${X_}`]:{"#include ":`\n #include \n\n vec3 csm_internal_orthogonal = ${X_} - (dot(${X_}, normal) * normal);\n vec3 csm_internal_projectedbump = mat3(csm_internal_vModelViewMatrix) * csm_internal_orthogonal;\n normal = normalize(normal - csm_internal_projectedbump);\n `},[`${Y_}`]:{"#include ":`\n #include \n normal = ${Y_};\n `},[`${rx}`]:{"gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );":`\n gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity * 1.0 - ${rx} );\n `,"gl_FragColor = packDepthToRGBA( fragCoordZ );":`\n if(${rx} < 1.0) discard;\n gl_FragColor = packDepthToRGBA( dist );\n `,"gl_FragColor = packDepthToRGBA( dist );":`\n if(${rx} < 1.0) discard;\n gl_FragColor = packDepthToRGBA( dist );\n `},[`${J_}`]:{"material.clearcoat = clearcoat;":`material.clearcoat = ${J_};`},[`${K_}`]:{"material.clearcoatRoughness = clearcoatRoughness;":`material.clearcoatRoughness = ${K_};`},[`${Z_}`]:{"#include ":"\n vec3 csm_coat_internal_orthogonal = csm_ClearcoatNormal - (dot(csm_ClearcoatNormal, nonPerturbedNormal) * nonPerturbedNormal);\n vec3 csm_coat_internal_projectedbump = mat3(csm_internal_vModelViewMatrix) * csm_coat_internal_orthogonal;\n vec3 clearcoatNormal = normalize(nonPerturbedNormal - csm_coat_internal_projectedbump);\n "},[`${$_}`]:{"material.transmission = transmission;":`\n material.transmission = ${$_};\n `},[`${tx}`]:{"material.thickness = thickness;":`\n material.thickness = ${tx};\n `},[`${ex}`]:{"material.iridescence = iridescence;":`\n material.iridescence = ${ex};\n `}},ux={clearcoat:[J_,Z_,K_],transmission:[$_],iridescence:[ex]};function dx(t){return t.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,"")}const px="row",fx="row-reverse",mx="column",gx="column-reverse";function Ax(t,e,n,i){let r=n,s="getWidth",a="x",o="y";0===e.indexOf(mx)&&(s="getHeight",a="y",o="x");for(let e=0;e{let o;switch(n){case _x:case"right":case"bottom":o=0===e.indexOf(px)?-s+a[i]()/2+(a.margin||0):s-a[i]()/2-(a.margin||0);break;case vx:case"left":case"top":o=0===e.indexOf(px)?s-a[i]()/2-(a.margin||0):-s+a[i]()/2+(a.margin||0)}t.childrenPos[a.id][r]=o||0}))}function Cx(t){-1!==Mx.indexOf(t)&&console.warn(`alignItems === '${t}' is deprecated and will be remove in 7.x.x. Fallback are 'start'|'end'`)}const Ex=[vx,yx,_x,xx,"top","right","bottom","left"],Mx=["top","right","bottom","left"],Sx="start",bx="center",Ix="end",Tx="space-around",Bx="space-between",Rx="space-evenly";function Dx(t,e,n,i){const r=t.getJustifyContent();-1===Px.indexOf(r)&&console.warn(`justifyContent === '${r}' is not supported`);const s=0===e.indexOf("row")?"width":"height",a=t.getChildrenSideSum(s),o=("width"===s?t.getInnerWidth():t.getInnerHeight())-a,l=function(t,e){switch(t){case Ix:return e;case bx:return e/2}return 0}(r,2*n-a*Math.sign(n)),c=function(t,e,n,i){const r=Array(t.length).fill(0);if(e>0)switch(n){case Bx:if(t.length>1){const n=e/(t.length-1)*i;r[0]=0;for(let e=1;e1){const n=e/(t.length+1)*i;for(let e=0;e1){const n=e/t.length*i,s=n/2;r[0]=s;for(let e=1;e{t.childrenPos[e.id][h]-=l-c[n]}))}const Px=[Sx,bx,Ix,Tx,Bx,Rx];function Lx(t){return class extends t{constructor(t){super(t),this.isBoxComponent=!0,this.childrenPos={}}getInnerWidth(){const t=this.getContentDirection();switch(t){case"row":case"row-reverse":return this.width-(2*this.padding||0)||this.getChildrenSideSum("width");case"column":case"column-reverse":return this.getHighestChildSizeOn("width");default:console.error(`Invalid contentDirection : ${t}`)}}getInnerHeight(){const t=this.getContentDirection();switch(t){case"row":case"row-reverse":return this.getHighestChildSizeOn("height");case"column":case"column-reverse":return this.height-(2*this.padding||0)||this.getChildrenSideSum("height");default:console.error(`Invalid contentDirection : ${t}`)}}getChildrenSideSum(t){return this.childrenBoxes.reduce(((e,n)=>{const i=2*n.margin||0;return e+("width"===t?n.getWidth()+i:n.getHeight()+i)}),0)}setPosFromParentRecords(){this.parentUI&&this.parentUI.childrenPos[this.id]&&(this.position.x=this.parentUI.childrenPos[this.id].x,this.position.y=this.parentUI.childrenPos[this.id].y)}computeChildrenPosition(){if(this.children.length>0){const t=this.getContentDirection();let e;switch(t){case px:e=-this.getInnerWidth()/2;break;case fx:e=this.getInnerWidth()/2;break;case mx:e=this.getInnerHeight()/2;break;case gx:e=-this.getInnerHeight()/2}const n=-Math.sign(e);Ax(this,t,e,n),Dx(this,t,e,n),wx(this,t)}}getHighestChildSizeOn(t){return this.childrenBoxes.reduce(((e,n)=>{const i=n.margin||0,r="width"===t?n.getWidth()+2*i:n.getHeight()+2*i;return Math.max(e,r)}),0)}getWidth(){return this.parentUI&&"stretch"===this.parentUI.getAlignItems()&&-1!==this.parentUI.getContentDirection().indexOf("column")?this.parentUI.getWidth()-(2*this.parentUI.padding||0):this.width||this.getInnerWidth()+(2*this.padding||0)}getHeight(){return this.parentUI&&"stretch"===this.parentUI.getAlignItems()&&-1!==this.parentUI.getContentDirection().indexOf("row")?this.parentUI.getHeight()-(2*this.parentUI.padding||0):this.height||this.getInnerHeight()+(2*this.padding||0)}}}const Ux={"\t":"\t","\n":"\n","\r":"\r"," ":" "},Nx="normal",Fx="nowrap",Ox="pre",kx="pre-line",Qx="pre-wrap",zx=function(t,e){switch(e){case Fx:case Nx:t=t.replace(/\n/g," ");case kx:t=t.replace(/[ ]{2,}/g," ")}return t},Gx=function(t){switch(t){case Ox:case Qx:case kx:return"mandatory"}},Hx=function(t,e,n,i){const r=t[e];switch(i.WHITESPACE){case Nx:case kx:case Qx:if("mandatory"===r.lineBreak)return!0;const s=r.kerning?r.kerning:0,a=r.xoffset?r.xoffset:0;if(n+(r.xadvance?r.xadvance:r.width)+a+s>i.INNER_WIDTH)return!0;const o=qx(t,e,i);return function(t,e,n,i){return!(!t||!t.glyph)&&!(e+n-1}(t[e-1],n,o,i);case Ox:return"mandatory"===r.lineBreak;default:return!1}},Vx=function(t,e){const n=t[0],i=t[t.length-1];switch(e){case Qx:n.glyph&&"\n"===n.glyph&&t.length>1&&jx([n],t[1]),i.glyph&&"\n"===i.glyph&&t.length>1&&Wx([i],t[t.length-2]);break;case kx:case Fx:case Nx:let r,s=[];for(let e=0;ee))break;s.push(n),r=t[e+1]}jx(s,r),s=[],r=null;for(let e=t.length-1;e>0;e--){const n=t[e];if(!(n.glyph&&Ux[n.glyph]&&e>0))break;s.push(n),r=t[e-1]}Wx(s,r);break;case Ox:break;default:return console.warn(`whiteSpace: '${e}' is not valid`),0}return n.offsetX};function Wx(t,e){if(e)for(let n=0;n{switch(e){case Zx:case Kx:case Xx:return-n/2;case $x:case Yx:return-t.width+n/2;case Jx:return-t.width/2;case tw:return i?-t.width/2:-n/2;default:console.warn(`textAlign: '${e}' is not valid`)}};function iw(t){return class extends t{computeInlinesPosition(){const t=this.getWidth()-(2*this.padding||0),e=this.getHeight()-(2*this.padding||0),n=this.getJustifyContent(),i=this.getTextAlign(),r=this.getInterLine(),s=this.computeLines();s.interLine=r;const a=Math.abs(s.height),o=(()=>{switch(n){case"start":return e/2;case"end":return a-e/2;case"center":return a/2;default:console.warn(`justifyContent: '${n}' is not valid`)}})();s.forEach((t=>{t.y+=o,t.forEach((t=>{t.offsetY+=o}))})),ew(s,i,t),this.lines=s}calculateBestFit(t){if(0!==this.childrenInlines.length)switch(t){case"grow":this.calculateGrowFit();break;case"shrink":this.calculateShrinkFit();break;case"auto":this.calculateAutoFit()}}calculateGrowFit(){const t=this.getHeight()-(2*this.padding||0);let e=1;const n=this.childrenInlines.find((t=>t.isText));let i,r=1,s=2,a=n._fitFontSize?n._fitFontSize/n.getFontSize():1;do{if(i=this.calculateHeight(a),i>t){if(a<=r){this.childrenInlines.forEach((t=>{t.isInlineBlock||(t._fitFontSize=t.getFontSize())}));break}s=a,a-=(s-r)/2}else{if(Math.abs(t-i)<.075)break;Math.abs(a-s)<5e-10&&(s*=2),r=a,a+=(s-r)/2}}while(++e<=10)}calculateShrinkFit(){const t=this.getHeight()-(2*this.padding||0);let e=1;const n=this.childrenInlines.find((t=>t.isText));let i,r=0,s=1,a=n._fitFontSize?n._fitFontSize/n.getFontSize():1;do{if(i=this.calculateHeight(a),i>t)s=a,a-=(s-r)/2;else{if(a>=s){this.childrenInlines.forEach((t=>{t.isInlineBlock||(t._fitFontSize=t.getFontSize())}));break}if(Math.abs(t-i)<.075)break;r=a,a+=(s-r)/2}}while(++e<=10)}calculateAutoFit(){const t=this.getHeight()-(2*this.padding||0);let e=1;const n=this.childrenInlines.find((t=>t.isText));let i,r=0,s=2,a=n._fitFontSize?n._fitFontSize/n.getFontSize():1;do{if(i=this.calculateHeight(a),i>t)s=a,a-=(s-r)/2;else{if(Math.abs(t-i)<.075)break;Math.abs(a-s)<5e-10&&(s*=2),r=a,a+=(s-r)/2}}while(++e<=10)}computeLines(){const t=this.getWidth()-(2*this.padding||0),e=[[]];e.height=0;const n=this.getInterLine();this.childrenInlines.reduce(((n,i)=>{if(!i.inlines)return;const r=i._fitFontSize||i.getFontSize(),s=i.isText?i.getLetterSpacing()*r:0,a=i.getWhiteSpace(),o=i.getBreakOn(),l={WHITESPACE:a,LETTERSPACING:s,BREAKON:o,INNER_WIDTH:t},c=i.inlines.reduce(((t,n,i,r)=>{const a=n.kerning?n.kerning:0,o=n.xoffset?n.xoffset:0,c=n.xadvance?n.xadvance:n.width;return Hx(r,i,t,l)?(e.push([n]),n.offsetX=o,0===n.width?0:c+s):(e[e.length-1].push(n),n.offsetX=t+o+a,t+c+a+s)}),n);return c}),0);let i=0,r=0,s=-n/2;return e.forEach((t=>{if(t.lineHeight=t.reduce(((t,e)=>{const n=void 0!==e.lineHeight?e.lineHeight:e.height;return Math.max(t,n)}),0),t.lineBase=t.reduce(((t,e)=>{const n=void 0!==e.lineBase?e.lineBase:e.height;return Math.max(t,n)}),0),t.width=0,t.height=t.lineHeight,t[0]){const e=this.getWhiteSpace(),a=Vx(t,e);t.forEach((t=>{t.offsetX-=a})),t.width=this.computeLineWidth(t),t.width>i&&(i=t.width),t.forEach((e=>{e.offsetY=s-e.height-e.anchor,e.lineHeight{e.isInlineBlock||(e._fitFontSize=e.getFontSize()*t,e.calculateInlines(e._fitFontSize))}));const e=this.computeLines();return Math.abs(e.height)}computeLineWidth(t){const e=t[0],n=t[t.length-1];return n.offsetX+n.width+e.offsetX}}}const rw=new _h,sw=[],aw={},ow=new Sh,lw=[],cw={},hw={};function uw(t){if(t._kernings)return;const e={};for(let n=0;n{const n=JSON.parse(t);uw(n),aw[e]=n;for(const t of Object.keys(hw))e===hw[t].jsonURL&&hw[t].component._updateFontFamily(n)}))),hw[t.id]||(hw[t.id]={component:t}),hw[t.id].jsonURL=e,aw[e]&&t._updateFontFamily(aw[e])}(t,e):(hw[t.id]||(hw[t.id]={component:t}),uw(e),hw[t.id].json=e,t._updateFontFamily(e))},setFontTexture:function(t,e){-1===lw.indexOf(e)&&(lw.push(e),ow.load(e,(t=>{t.generateMipmaps=!1,t.minFilter=Lt,t.magFilter=Lt,cw[e]=t;for(const n of Object.keys(hw))e===hw[n].textureURL&&hw[n].component._updateFontTexture(t)}))),hw[t.id]||(hw[t.id]={component:t}),hw[t.id].textureURL=e,cw[e]&&t._updateFontTexture(cw[e])},getFontOf:function t(e){const n=hw[e.id];return!n&&e.parentUI?t(e.parentUI):n},addFont:function(t,e,n){n.generateMipmaps=!1,n.minFilter=Lt,n.magFilter=Lt,sw.push(t),aw[t]=e,uw(e),n&&(lw.push(t),cw[t]=n)}};class pw{static requestUpdate(t,e,n,i){t.traverse((t=>{t.isUI&&(this.requestedUpdates[t.id]?(e&&(this.requestedUpdates[t.id].updateParsing=!0),n&&(this.requestedUpdates[t.id].updateLayout=!0),i&&(this.requestedUpdates[t.id].updateInner=!0)):this.requestedUpdates[t.id]={updateParsing:e,updateLayout:n,updateInner:i,needCallback:e||n||i})}))}static register(t){this.components.includes(t)||this.components.push(t)}static disposeOf(t){const e=this.components.indexOf(t);e>-1&&this.components.splice(e,1)}static update(){if(Object.keys(this.requestedUpdates).length>0){const t=this.components.filter((t=>!t.parentUI));t.forEach((t=>this.traverseParsing(t))),t.forEach((t=>this.traverseUpdates(t)))}}static traverseParsing(t){const e=this.requestedUpdates[t.id];e&&e.updateParsing&&(t.parseParams(),e.updateParsing=!1),t.childrenUIs.forEach((t=>this.traverseParsing(t)))}static traverseUpdates(t){const e=this.requestedUpdates[t.id];delete this.requestedUpdates[t.id],e&&e.updateLayout&&(e.updateLayout=!1,t.updateLayout()),e&&e.updateInner&&(e.updateInner=!1,t.updateInner()),t.childrenUIs.forEach((t=>{this.traverseUpdates(t)})),e&&e.needCallback&&t.onAfterUpdate()}}pw.components=[],pw.requestedUpdates={};const fw={container:null,fontFamily:null,fontSize:.05,fontKerning:"normal",bestFit:"none",offset:.01,interLine:.01,breakOn:"- ,.:?!\n",whiteSpace:kx,contentDirection:mx,alignItems:yx,justifyContent:Sx,textAlign:Jx,textType:"MSDF",fontColor:new cs(16777215),fontOpacity:1,fontPXRange:4,fontSupersampling:!0,borderRadius:.01,borderWidth:0,borderColor:new cs("black"),borderOpacity:1,backgroundSize:"cover",backgroundColor:new cs(2236962),backgroundWhiteColor:new cs(16777215),backgroundOpacity:.8,backgroundOpaqueOpacity:1,getDefaultTexture:function(){if(!mw){const t=document.createElement("canvas").getContext("2d");t.canvas.width=1,t.canvas.height=1,t.fillStyle="#ffffff",t.fillRect(0,0,1,1),mw=new ul(t.canvas),mw.isDefault=!0}return mw},hiddenOverflow:!1,letterSpacing:0};let mw;function gw(t){return class extends t{constructor(t){super(t),this.states={},this.currentState=void 0,this.isUI=!0,this.autoLayout=!0,this.childrenUIs=[],this.childrenBoxes=[],this.childrenTexts=[],this.childrenInlines=[],this.parentUI=null,this.addEventListener("added",this._rebuildParentUI),this.addEventListener("removed",this._rebuildParentUI)}getClippingPlanes(){const t=[];if(this.parentUI){if(this.isBlock&&this.parentUI.getHiddenOverflow()){const e=this.parentUI.getHeight()/2-(this.parentUI.padding||0),n=this.parentUI.getWidth()/2-(this.parentUI.padding||0),i=[new go(new zi(0,1,0),e),new go(new zi(0,-1,0),e),new go(new zi(1,0,0),n),new go(new zi(-1,0,0),n)];i.forEach((t=>{t.applyMatrix4(this.parent.matrixWorld)})),t.push(...i)}this.parentUI.parentUI&&t.push(...this.parentUI.getClippingPlanes())}return t}getHighestParent(){return this.parentUI?this.parent.getHighestParent():this}_getProperty(t){return void 0===this[t]&&this.parentUI?this.parent._getProperty(t):void 0!==this[t]?this[t]:fw[t]}getFontSize(){return this._getProperty("fontSize")}getFontKerning(){return this._getProperty("fontKerning")}getLetterSpacing(){return this._getProperty("letterSpacing")}getFontTexture(){return void 0===this.fontTexture&&this.parentUI?this.parent._getProperty("fontTexture"):void 0!==this.fontTexture?this.fontTexture:fw.getDefaultTexture()}getFontFamily(){return this._getProperty("fontFamily")}getBreakOn(){return this._getProperty("breakOn")}getWhiteSpace(){return this._getProperty("whiteSpace")}getTextAlign(){return this._getProperty("textAlign")}getTextType(){return this._getProperty("textType")}getFontColor(){return this._getProperty("fontColor")}getFontSupersampling(){return this._getProperty("fontSupersampling")}getFontOpacity(){return this._getProperty("fontOpacity")}getFontPXRange(){return this._getProperty("fontPXRange")}getBorderRadius(){return this._getProperty("borderRadius")}getBorderWidth(){return this._getProperty("borderWidth")}getBorderColor(){return this._getProperty("borderColor")}getBorderOpacity(){return this._getProperty("borderOpacity")}getContainer(){return!this.threeOBJ&&this.parent?this.parent.getContainer():this.threeOBJ?this:fw.container}getParentsNumber(t){return t=t||0,this.parentUI?this.parentUI.getParentsNumber(t+1):t}getBackgroundOpacity(){return this.backgroundOpacity||0===this.backgroundOpacity?this.backgroundOpacity:fw.backgroundOpacity}getBackgroundColor(){return this.backgroundColor||fw.backgroundColor}getBackgroundTexture(){return this.backgroundTexture||fw.getDefaultTexture()}getAlignContent(){return this.alignContent||fw.alignContent}getAlignItems(){return this.alignItems||fw.alignItems}getContentDirection(){return this.contentDirection||fw.contentDirection}getJustifyContent(){return this.justifyContent||fw.justifyContent}getInterLine(){return void 0===this.interLine?fw.interLine:this.interLine}getOffset(){return void 0===this.offset?fw.offset:this.offset}getBackgroundSize(){return void 0===this.backgroundSize?fw.backgroundSize:this.backgroundSize}getHiddenOverflow(){return void 0===this.hiddenOverflow?fw.hiddenOverflow:this.hiddenOverflow}getBestFit(){return void 0===this.bestFit?fw.bestFit:this.bestFit}_rebuildChildrenLists(){this.childrenUIs=this.children.filter((t=>t.isUI)),this.childrenBoxes=this.children.filter((t=>t.isBoxComponent)),this.childrenInlines=this.children.filter((t=>t.isInline)),this.childrenTexts=this.children.filter((t=>t.isText))}_rebuildParentUI=()=>{this.parent&&this.parent.isUI?this.parentUI=this.parent:this.parentUI=null};add(){for(const t of Object.keys(arguments))arguments[t].isInline&&this.update(null,!0);const t=super.add(...arguments);return this._rebuildChildrenLists(),t}remove(){for(const t of Object.keys(arguments))arguments[t].isInline&&this.update(null,!0);const t=super.remove(...arguments);return this._rebuildChildrenLists(),t}update(t,e,n){pw.requestUpdate(this,t,e,n)}onAfterUpdate(){}_updateFontFamily(t){this.fontFamily=t,this.traverse((t=>{t.isUI&&t.update(!0,!0,!1)})),this.getHighestParent().update(!1,!0,!1)}_updateFontTexture(t){this.fontTexture=t,this.getHighestParent().update(!1,!0,!1)}set(t){let e,n,i;if(pw.register(this),t&&JSON.stringify(t)!==JSON.stringify({})){t.alignContent&&(t.alignItems=t.alignContent,t.textAlign||(t.textAlign=t.alignContent),console.warn("`alignContent` property has been deprecated, please rely on `alignItems` and `textAlign` instead."),delete t.alignContent),t.alignItems&&Cx(t.alignItems);for(const r of Object.keys(t))if(this[r]!=t[r])switch(r){case"content":case"fontSize":case"fontKerning":case"breakOn":case"whiteSpace":this.isText&&(e=!0),n=!0,this[r]=t[r];break;case"bestFit":this.isBlock&&(e=!0,n=!0),this[r]=t[r];break;case"width":case"height":case"padding":(this.isInlineBlock||this.isBlock&&"none"!=this.getBestFit())&&(e=!0),n=!0,this[r]=t[r];break;case"letterSpacing":case"interLine":this.isBlock&&"none"!=this.getBestFit()&&(e=!0),n=!0,this[r]=t[r];break;case"margin":case"contentDirection":case"justifyContent":case"alignContent":case"alignItems":case"textAlign":case"textType":n=!0,this[r]=t[r];break;case"fontColor":case"fontOpacity":case"fontSupersampling":case"offset":case"backgroundColor":case"backgroundOpacity":case"backgroundTexture":case"backgroundSize":case"borderRadius":case"borderWidth":case"borderColor":case"borderOpacity":i=!0,this[r]=t[r];break;case"hiddenOverflow":this[r]=t[r]}t.fontFamily&&dw.setFontFamily(this,t.fontFamily),t.fontTexture&&dw.setFontTexture(this,t.fontTexture),this.parentUI&&"none"!=this.parentUI.getBestFit()&&this.parentUI.update(!0,!0,!1),this.update(e,n,i),n&&this.getHighestParent().update(!1,!0,!1)}}setupState(t){this.states[t.state]={attributes:t.attributes,onSet:t.onSet}}setState(t){const e=this.states[t];e?t!==this.currentState&&(this.currentState=t,e.onSet&&e.onSet(),e.attributes&&this.set(e.attributes)):console.warn(`state "${t}" does not exist within this component:`,this.name)}clear(){this.traverse((t=>{pw.disposeOf(t),t.material&&t.material.dispose(),t.geometry&&t.geometry.dispose()}))}}}function Aw(t){return class extends t{constructor(t){super(t),this.textUniforms={u_texture:{value:this.getFontTexture()},u_color:{value:this.getFontColor()},u_opacity:{value:this.getFontOpacity()},u_pxRange:{value:this.getFontPXRange()},u_useRGSS:{value:this.getFontSupersampling()}},this.backgroundUniforms={u_texture:{value:this.getBackgroundTexture()},u_color:{value:this.getBackgroundColor()},u_opacity:{value:this.getBackgroundOpacity()},u_backgroundMapping:{value:this.getBackgroundSize()},u_borderWidth:{value:this.getBorderWidth()},u_borderColor:{value:this.getBorderColor()},u_borderRadiusTopLeft:{value:this.getBorderRadius()},u_borderRadiusTopRight:{value:this.getBorderRadius()},u_borderRadiusBottomRight:{value:this.getBorderRadius()},u_borderRadiusBottomLeft:{value:this.getBorderRadius()},u_borderOpacity:{value:this.getBorderOpacity()},u_size:{value:new hi(1,1)},u_tSize:{value:new hi(1,1)}}}updateBackgroundMaterial(){this.backgroundUniforms.u_texture.value=this.getBackgroundTexture(),this.backgroundUniforms.u_tSize.value.set(this.backgroundUniforms.u_texture.value.image.width,this.backgroundUniforms.u_texture.value.image.height),this.size&&this.backgroundUniforms.u_size.value.copy(this.size),this.backgroundUniforms.u_texture.value.isDefault?(this.backgroundUniforms.u_color.value=this.getBackgroundColor(),this.backgroundUniforms.u_opacity.value=this.getBackgroundOpacity()):(this.backgroundUniforms.u_color.value=this.backgroundColor||fw.backgroundWhiteColor,this.backgroundUniforms.u_opacity.value=this.backgroundOpacity||0===this.backgroundOpacity?this.backgroundOpacity:fw.backgroundOpaqueOpacity),this.backgroundUniforms.u_backgroundMapping.value=(()=>{switch(this.getBackgroundSize()){case"stretch":return 0;case"contain":return 1;case"cover":return 2}})();const t=this.getBorderRadius();this.backgroundUniforms.u_borderWidth.value=this.getBorderWidth(),this.backgroundUniforms.u_borderColor.value=this.getBorderColor(),this.backgroundUniforms.u_borderOpacity.value=this.getBorderOpacity(),Array.isArray(t)?(this.backgroundUniforms.u_borderRadiusTopLeft.value=t[0],this.backgroundUniforms.u_borderRadiusTopRight.value=t[1],this.backgroundUniforms.u_borderRadiusBottomRight.value=t[2],this.backgroundUniforms.u_borderRadiusBottomLeft.value=t[3]):(this.backgroundUniforms.u_borderRadiusTopLeft.value=t,this.backgroundUniforms.u_borderRadiusTopRight.value=t,this.backgroundUniforms.u_borderRadiusBottomRight.value=t,this.backgroundUniforms.u_borderRadiusBottomLeft.value=t)}updateTextMaterial(){this.textUniforms.u_texture.value=this.getFontTexture(),this.textUniforms.u_color.value=this.getFontColor(),this.textUniforms.u_opacity.value=this.getFontOpacity(),this.textUniforms.u_pxRange.value=this.getFontPXRange(),this.textUniforms.u_useRGSS.value=this.getFontSupersampling()}getBackgroundMaterial(){return this.backgroundMaterial&&this.backgroundUniforms||(this.backgroundMaterial=this._makeBackgroundMaterial()),this.backgroundMaterial}getFontMaterial(){return this.fontMaterial&&this.textUniforms||(this.fontMaterial=this._makeTextMaterial()),this.fontMaterial}_makeTextMaterial(){return new ra({uniforms:this.textUniforms,transparent:!0,clipping:!0,vertexShader:vw,fragmentShader:yw,extensions:{derivatives:!0}})}_makeBackgroundMaterial(){return new ra({uniforms:this.backgroundUniforms,transparent:!0,clipping:!0,vertexShader:_w,fragmentShader:xw,extensions:{derivatives:!0}})}updateClippingPlanes(t){const e=void 0!==t?t:this.getClippingPlanes();JSON.stringify(e)!==JSON.stringify(this.clippingPlanes)&&(this.clippingPlanes=e,this.fontMaterial&&(this.fontMaterial.clippingPlanes=this.clippingPlanes),this.backgroundMaterial&&(this.backgroundMaterial.clippingPlanes=this.clippingPlanes))}}}const vw="\nvarying vec2 vUv;\n\n#include \n\nvoid main() {\n\n\tvUv = uv;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\tgl_Position.z -= 0.00001;\n\n\t#include \n\n}\n",yw="\n\nuniform sampler2D u_texture;\nuniform vec3 u_color;\nuniform float u_opacity;\nuniform float u_pxRange;\nuniform bool u_useRGSS;\n\nvarying vec2 vUv;\n\n#include \n\n// functions from the original msdf repo:\n// https://github.com/Chlumsky/msdfgen#using-a-multi-channel-distance-field\n\nfloat median(float r, float g, float b) {\n\treturn max(min(r, g), min(max(r, g), b));\n}\n\nfloat screenPxRange() {\n\tvec2 unitRange = vec2(u_pxRange)/vec2(textureSize(u_texture, 0));\n\tvec2 screenTexSize = vec2(1.0)/fwidth(vUv);\n\treturn max(0.5*dot(unitRange, screenTexSize), 1.0);\n}\n\nfloat tap(vec2 offsetUV) {\n\tvec3 msd = texture( u_texture, offsetUV ).rgb;\n\tfloat sd = median(msd.r, msd.g, msd.b);\n\tfloat screenPxDistance = screenPxRange() * (sd - 0.5);\n\tfloat alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\n\treturn alpha;\n}\n\nvoid main() {\n\n\tfloat alpha;\n\n\tif ( u_useRGSS ) {\n\n\t\t// shader-based supersampling based on https://bgolus.medium.com/sharper-mipmapping-using-shader-based-supersampling-ed7aadb47bec\n\t\t// per pixel partial derivatives\n\t\tvec2 dx = dFdx(vUv);\n\t\tvec2 dy = dFdy(vUv);\n\n\t\t// rotated grid uv offsets\n\t\tvec2 uvOffsets = vec2(0.125, 0.375);\n\t\tvec2 offsetUV = vec2(0.0, 0.0);\n\n\t\t// supersampled using 2x2 rotated grid\n\t\talpha = 0.0;\n\t\toffsetUV.xy = vUv + uvOffsets.x * dx + uvOffsets.y * dy;\n\t\talpha += tap(offsetUV);\n\t\toffsetUV.xy = vUv - uvOffsets.x * dx - uvOffsets.y * dy;\n\t\talpha += tap(offsetUV);\n\t\toffsetUV.xy = vUv + uvOffsets.y * dx - uvOffsets.x * dy;\n\t\talpha += tap(offsetUV);\n\t\toffsetUV.xy = vUv - uvOffsets.y * dx + uvOffsets.x * dy;\n\t\talpha += tap(offsetUV);\n\t\talpha *= 0.25;\n\n\t} else {\n\n\t\talpha = tap( vUv );\n\n\t}\n\n\n\t// apply the opacity\n\talpha *= u_opacity;\n\n\t// this is useful to avoid z-fighting when quads overlap because of kerning\n\tif ( alpha < 0.02) discard;\n\n\n\tgl_FragColor = vec4( u_color, alpha );\n\n\t#include \n\n}\n",_w="\nvarying vec2 vUv;\n\n#include \n\nvoid main() {\n\n\tvUv = uv;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\n\t#include \n\n}\n",xw="\n\nuniform sampler2D u_texture;\nuniform vec3 u_color;\nuniform float u_opacity;\n\nuniform float u_borderRadiusTopLeft;\nuniform float u_borderRadiusTopRight;\nuniform float u_borderRadiusBottomLeft;\nuniform float u_borderRadiusBottomRight;\nuniform float u_borderWidth;\nuniform vec3 u_borderColor;\nuniform float u_borderOpacity;\nuniform vec2 u_size;\nuniform vec2 u_tSize;\nuniform int u_backgroundMapping;\n\nvarying vec2 vUv;\n\n#include \n\nfloat getEdgeDist() {\n\tvec2 ndc = vec2( vUv.x * 2.0 - 1.0, vUv.y * 2.0 - 1.0 );\n\tvec2 planeSpaceCoord = vec2( u_size.x * 0.5 * ndc.x, u_size.y * 0.5 * ndc.y );\n\tvec2 corner = u_size * 0.5;\n\tvec2 offsetCorner = corner - abs( planeSpaceCoord );\n\tfloat innerRadDist = min( offsetCorner.x, offsetCorner.y ) * -1.0;\n\tif (vUv.x < 0.5 && vUv.y >= 0.5) {\n\t\tfloat roundedDist = length( max( abs( planeSpaceCoord ) - u_size * 0.5 + u_borderRadiusTopLeft, 0.0 ) ) - u_borderRadiusTopLeft;\n\t\tfloat s = step( innerRadDist * -1.0, u_borderRadiusTopLeft );\n\t\treturn mix( innerRadDist, roundedDist, s );\n\t}\n\tif (vUv.x >= 0.5 && vUv.y >= 0.5) {\n\t\tfloat roundedDist = length( max( abs( planeSpaceCoord ) - u_size * 0.5 + u_borderRadiusTopRight, 0.0 ) ) - u_borderRadiusTopRight;\n\t\tfloat s = step( innerRadDist * -1.0, u_borderRadiusTopRight );\n\t\treturn mix( innerRadDist, roundedDist, s );\n\t}\n\tif (vUv.x >= 0.5 && vUv.y < 0.5) {\n\t\tfloat roundedDist = length( max( abs( planeSpaceCoord ) - u_size * 0.5 + u_borderRadiusBottomRight, 0.0 ) ) - u_borderRadiusBottomRight;\n\t\tfloat s = step( innerRadDist * -1.0, u_borderRadiusBottomRight );\n\t\treturn mix( innerRadDist, roundedDist, s );\n\t}\n\tif (vUv.x < 0.5 && vUv.y < 0.5) {\n\t\tfloat roundedDist = length( max( abs( planeSpaceCoord ) - u_size * 0.5 + u_borderRadiusBottomLeft, 0.0 ) ) - u_borderRadiusBottomLeft;\n\t\tfloat s = step( innerRadDist * -1.0, u_borderRadiusBottomLeft );\n\t\treturn mix( innerRadDist, roundedDist, s );\n\t}\n}\n\nvec4 sampleTexture() {\n\tfloat textureRatio = u_tSize.x / u_tSize.y;\n\tfloat panelRatio = u_size.x / u_size.y;\n\tvec2 uv = vUv;\n\tif ( u_backgroundMapping == 1 ) { // contain\n\t\tif ( textureRatio < panelRatio ) { // repeat on X\n\t\t\tfloat newX = uv.x * ( panelRatio / textureRatio );\n\t\t\tnewX += 0.5 - 0.5 * ( panelRatio / textureRatio );\n\t\t\tuv.x = newX;\n\t\t} else { // repeat on Y\n\t\t\tfloat newY = uv.y * ( textureRatio / panelRatio );\n\t\t\tnewY += 0.5 - 0.5 * ( textureRatio / panelRatio );\n\t\t\tuv.y = newY;\n\t\t}\n\t} else if ( u_backgroundMapping == 2 ) { // cover\n\t\tif ( textureRatio < panelRatio ) { // stretch on Y\n\t\t\tfloat newY = uv.y * ( textureRatio / panelRatio );\n\t\t\tnewY += 0.5 - 0.5 * ( textureRatio / panelRatio );\n\t\t\tuv.y = newY;\n\t\t} else { // stretch on X\n\t\t\tfloat newX = uv.x * ( panelRatio / textureRatio );\n\t\t\tnewX += 0.5 - 0.5 * ( panelRatio / textureRatio );\n\t\t\tuv.x = newX;\n\t\t}\n\t}\n\treturn texture2D( u_texture, uv ).rgba;\n}\n\nvoid main() {\n\n\tfloat edgeDist = getEdgeDist();\n\tfloat change = fwidth( edgeDist );\n\n\tvec4 textureSample = sampleTexture();\n\tvec3 blendedColor = textureSample.rgb * u_color;\n\n\tfloat alpha = smoothstep( change, 0.0, edgeDist );\n\tfloat blendedOpacity = u_opacity * textureSample.a * alpha;\n\n\tvec4 frameColor = vec4( blendedColor, blendedOpacity );\n\n\tif ( u_borderWidth <= 0.0 ) {\n\t\tgl_FragColor = frameColor;\n\t} else {\n\t\tvec4 borderColor = vec4( u_borderColor, u_borderOpacity * alpha );\n\t\tfloat stp = smoothstep( edgeDist + change, edgeDist, u_borderWidth * -1.0 );\n\t\tgl_FragColor = mix( frameColor, borderColor, stp );\n\t}\n\n\t#include \n}\n";class ww extends Ks{constructor(t){super(new Mc,t),this.castShadow=!0,this.receiveShadow=!0,this.name="MeshUI-Frame"}}let Cw=null;function Ew(...t){if(!Cw)throw new Error("Cannot use mixins with Base null");let e=Cw;Cw=null;let n,i=t.length;for(;--i>=0;)n=t[i],e=n(e);return e}Ew.withBase=t=>(Cw=t,Ew);class Mw extends(Ew.withBase(Vr)(Lx,iw,Aw,gw)){constructor(t){super(t),this.isBlock=!0,this.size=new hi(1,1),this.frame=new ww(this.getBackgroundMaterial()),this.frame.onBeforeRender=()=>{this.updateClippingPlanes&&this.updateClippingPlanes()},this.add(this.frame),this.set(t)}parseParams(){const t=this.getBestFit();"none"!=t&&this.childrenTexts.length?this.calculateBestFit(t):this.childrenTexts.forEach((t=>{t._fitFontSize=void 0}))}updateLayout(){const t=this.getWidth(),e=this.getHeight();t&&e?(this.size.set(t,e),this.frame.scale.set(t,e,1),this.frame&&this.updateBackgroundMaterial(),this.frame.renderOrder=this.getParentsNumber(),this.autoLayout&&this.setPosFromParentRecords(),this.childrenInlines.length&&this.computeInlinesPosition(),this.computeChildrenPosition(),this.parentUI&&(this.position.z=this.getOffset())):console.warn("Block got no dimension from its parameters or from children parameters")}updateInner(){this.parentUI&&(this.position.z=this.getOffset()),this.frame&&this.updateBackgroundMaterial()}}function Sw(t){return class extends t{constructor(t){super(t),this.isInline=!0}}}class bw extends Mc{constructor(t,e){const n=t.glyph,i=t.fontSize;super(t.width,t.height),null===n.match(/\s/g)?(-1===e.info.charset.indexOf(n)&&console.error(`The character '${n}' is not included in the font characters set.`),this.mapUVs(e,n),this.transformGeometry(t)):(this.nullifyUVs(),this.scale(0,0,1),this.translate(0,i/2,0))}mapUVs(t,e){const n=t.chars.find((t=>t.char===e)),i=t.common,r=n.x/i.scaleW,s=(n.x+n.width)/i.scaleW,a=1-(n.y+n.height)/i.scaleH,o=1-n.y/i.scaleH,l=this.attributes.uv;for(let t=0;t{switch(t){case 0:return[r,o];case 1:return[s,o];case 2:return[r,a];case 3:return[s,a]}})(),l.setXY(t,e,n)}}nullifyUVs(){const t=this.attributes.uv;for(let e=0;et.char===i));let a=s?s.width*r:n/3,o=s?s.height*r:0;0===a&&(a=s?s.xadvance*r:n),0===o&&(o=.7*n),"\n"===i&&(a=0);const l=s?s.xadvance*r:a,c=s?s.xoffset*r:0;return{width:a,height:o,anchor:s?s.yoffset*r:0,xadvance:l,xoffset:c}},getGlyphPairKerning:function(t,e){const n=t._kernings;return n[e]?n[e]:0},buildText:function(){const t=[];this.inlines.forEach(((e,n)=>{t[n]=new bw(e,this.getFontFamily()),t[n].translate(e.offsetX,e.offsetY,0)}));const e=Dg(t);return new Ks(e,this.getFontMaterial())}};function Tw(t){return class extends t{createText(){const t=this,e=(()=>{if("MSDF"===this.getTextType())return Iw.buildText.call(this);console.warn(`'${this.getTextType()}' is not a supported text type.\nSee https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type`)})();return e.renderOrder=1/0,e.onBeforeRender=function(){t.updateClippingPlanes&&t.updateClippingPlanes()},e}getGlyphDimensions(t){if("MSDF"===t.textType)return Iw.getGlyphDimensions(t);console.warn(`'${t.textType}' is not a supported text type.\nSee https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type`)}getGlyphPairKerning(t,e,n){if("MSDF"===t)return Iw.getGlyphPairKerning(e,n);console.warn(`'${t}' is not a supported text type.\nSee https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type`)}}}const Bw=function t(e){e.children.forEach((n=>{n.children.length>0&&t(n),e.remove(n),pw.disposeOf(n),n.material&&n.material.dispose(),n.geometry&&n.geometry.dispose()})),e.children=[]};class Rw extends(Ew.withBase(Vr)(Sw,Tw,Aw,gw)){constructor(t){super(t),this.isText=!0,this.set(t)}parseParams(){this.calculateInlines(this._fitFontSize||this.getFontSize())}updateLayout(){Bw(this),this.inlines&&(this.textContent=this.createText(),this.updateTextMaterial(),this.add(this.textContent)),this.position.z=this.getOffset()}updateInner(){this.position.z=this.getOffset(),this.textContent&&this.updateTextMaterial()}calculateInlines(t){const e=this.content,n=this.getFontFamily(),i=this.getBreakOn(),r=this.getTextType(),s=this.getWhiteSpace();if(!n||"string"==typeof n)return void(dw.getFontOf(this)||console.warn("no font was found"));if(!this.content)return void(this.inlines=null);if(!r)return void console.error("You must provide a 'textType' attribute so three-mesh-ui knows how to render your text.\n See https://github.com/felixmariotto/three-mesh-ui/wiki/Using-a-custom-text-type");const a=zx(e,s),o=Array.from?Array.from(a):String(a).split(""),l=t/n.info.size,c=n.common.lineHeight*l,h=n.common.base*l,u=o.map((e=>{const a=this.getGlyphDimensions({textType:r,glyph:e,font:n,fontSize:t});let o=null;return s!==Fx&&(i.includes(e)||e.match(/\s/g))&&(o="possible"),e.match(/\n/g)&&(o=Gx(s)),{height:a.height,width:a.width,anchor:a.anchor,xadvance:a.xadvance,xoffset:a.xoffset,lineBreak:o,glyph:e,fontSize:t,lineHeight:c,lineBase:h}}));if("none"!==this.getFontKerning())for(let e=1;e{this.updateClippingPlanes&&this.updateClippingPlanes()},this.add(this.frame),this.set(t)}parseParams(){this.width||console.warn("inlineBlock has no width. Set to 0.3 by default"),this.height||console.warn("inlineBlock has no height. Set to 0.3 by default"),this.inlines=[{height:this.height||.3,width:this.width||.3,anchor:0,lineBreak:"possible"}]}updateLayout(){const t=this.getWidth(),e=this.getHeight();if(this.inlines){const t=this.inlines[0];this.position.set(t.width/2,t.height/2,0),this.position.x+=t.offsetX,this.position.y+=t.offsetY}this.size.set(t,e),this.frame.scale.set(t,e,1),this.frame&&this.updateBackgroundMaterial(),this.frame.renderOrder=this.getParentsNumber(),this.childrenInlines.length&&this.computeInlinesPosition(),this.computeChildrenPosition(),this.position.z=this.getOffset()}updateInner(){this.position.z=this.getOffset(),this.frame&&this.updateBackgroundMaterial()}}const Pw=[[[{width:.1,chars:[{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"l",upperCase:"L"}]},{width:.1,chars:[{lowerCase:"m",upperCase:"M"}]}],[{width:.2,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"n",upperCase:"N"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Lw=[[[{width:.1,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"l",upperCase:"L"}]}],[{width:.15,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"n",upperCase:"N"}]},{width:.1,chars:[{lowerCase:"m",upperCase:"M"}]},{width:.15,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Uw=[[[{width:1/12,chars:[{lowerCase:"й",upperCase:"Й"},{lowerCase:"q",upperCase:"Q"}]},{width:1/12,chars:[{lowerCase:"ц",upperCase:"Ц"},{lowerCase:"w",upperCase:"W"}]},{width:1/12,chars:[{lowerCase:"у",upperCase:"У"},{lowerCase:"e",upperCase:"E"}]},{width:1/12,chars:[{lowerCase:"к",upperCase:"К"},{lowerCase:"r",upperCase:"R"}]},{width:1/12,chars:[{lowerCase:"е",upperCase:"Е"},{lowerCase:"t",upperCase:"T"}]},{width:1/12,chars:[{lowerCase:"н",upperCase:"Н"},{lowerCase:"y",upperCase:"Y"}]},{width:1/12,chars:[{lowerCase:"г",upperCase:"Г"},{lowerCase:"u",upperCase:"U"}]},{width:1/12,chars:[{lowerCase:"ш",upperCase:"Ш"},{lowerCase:"i",upperCase:"I"}]},{width:1/12,chars:[{lowerCase:"щ",upperCase:"Щ"},{lowerCase:"o",upperCase:"O"}]},{width:1/12,chars:[{lowerCase:"з",upperCase:"З"},{lowerCase:"p",upperCase:"P"}]},{width:1/12,chars:[{lowerCase:"х",upperCase:"Х"},{lowerCase:"{",upperCase:"["}]},{width:1/12,chars:[{lowerCase:"ъ",upperCase:"Ъ"},{lowerCase:"}",upperCase:"]"}]}],[{width:1/12,chars:[{lowerCase:"ф",upperCase:"Ф"},{lowerCase:"a",upperCase:"A"}]},{width:1/12,chars:[{lowerCase:"ы",upperCase:"Ы"},{lowerCase:"s",upperCase:"S"}]},{width:1/12,chars:[{lowerCase:"в",upperCase:"В"},{lowerCase:"d",upperCase:"D"}]},{width:1/12,chars:[{lowerCase:"а",upperCase:"А"},{lowerCase:"f",upperCase:"F"}]},{width:1/12,chars:[{lowerCase:"п",upperCase:"П"},{lowerCase:"g",upperCase:"G"}]},{width:1/12,chars:[{lowerCase:"р",upperCase:"Р"},{lowerCase:"h",upperCase:"H"}]},{width:1/12,chars:[{lowerCase:"о",upperCase:"О"},{lowerCase:"j",upperCase:"J"}]},{width:1/12,chars:[{lowerCase:"л",upperCase:"Л"},{lowerCase:"k",upperCase:"K"}]},{width:1/12,chars:[{lowerCase:"д",upperCase:"Д"},{lowerCase:"l",upperCase:"L"}]},{width:1/12,chars:[{lowerCase:"ж",upperCase:"Ж"},{lowerCase:":",upperCase:";"}]},{width:1/12,chars:[{lowerCase:"э",upperCase:"Э"},{lowerCase:'"',upperCase:"'"}]},{width:1/12,chars:[{lowerCase:"ё",upperCase:"Ё"},{lowerCase:"|",upperCase:"\\"}]}],[{width:.125,command:"shift",chars:[{icon:"shift"}]},{width:1/12,chars:[{lowerCase:"я",upperCase:"Я"},{lowerCase:"z",upperCase:"Z"}]},{width:1/12,chars:[{lowerCase:"ч",upperCase:"Ч"},{lowerCase:"x",upperCase:"X"}]},{width:1/12,chars:[{lowerCase:"с",upperCase:"С"},{lowerCase:"c",upperCase:"C"}]},{width:1/12,chars:[{lowerCase:"м",upperCase:"М"},{lowerCase:"v",upperCase:"V"}]},{width:1/12,chars:[{lowerCase:"и",upperCase:"И"},{lowerCase:"b",upperCase:"B"}]},{width:1/12,chars:[{lowerCase:"т",upperCase:"Т"},{lowerCase:"n",upperCase:"N"}]},{width:1/12,chars:[{lowerCase:"ь",upperCase:"Ь"},{lowerCase:"m",upperCase:"M"}]},{width:1/12,chars:[{lowerCase:"б",upperCase:"Б"},{lowerCase:",",upperCase:""}]},{width:1/12,chars:[{lowerCase:"ю",upperCase:"Ю"},{lowerCase:".",upperCase:""}]},{width:.125,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.15,command:"switch-set",chars:[{lowerCase:"eng"}]},{width:.15,command:"switch",chars:[{lowerCase:".?12"}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.3,command:"switch",chars:[{lowerCase:"АБВ"}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Nw=[[[{width:1/11,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:1/11,chars:[{lowerCase:"w",upperCase:"W"}]},{width:1/11,chars:[{lowerCase:"e",upperCase:"E"}]},{width:1/11,chars:[{lowerCase:"r",upperCase:"R"}]},{width:1/11,chars:[{lowerCase:"t",upperCase:"T"}]},{width:1/11,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:1/11,chars:[{lowerCase:"u",upperCase:"U"}]},{width:1/11,chars:[{lowerCase:"i",upperCase:"I"}]},{width:1/11,chars:[{lowerCase:"o",upperCase:"O"}]},{width:1/11,chars:[{lowerCase:"p",upperCase:"P"}]},{width:1/11,chars:[{lowerCase:"ü",upperCase:"Ü"}]}],[{width:1/11,chars:[{lowerCase:"a",upperCase:"A"}]},{width:1/11,chars:[{lowerCase:"s",upperCase:"S"}]},{width:1/11,chars:[{lowerCase:"d",upperCase:"D"}]},{width:1/11,chars:[{lowerCase:"f",upperCase:"F"}]},{width:1/11,chars:[{lowerCase:"g",upperCase:"G"}]},{width:1/11,chars:[{lowerCase:"h",upperCase:"H"}]},{width:1/11,chars:[{lowerCase:"j",upperCase:"J"}]},{width:1/11,chars:[{lowerCase:"k",upperCase:"K"}]},{width:1/11,chars:[{lowerCase:"l",upperCase:"L"}]},{width:1/11,chars:[{lowerCase:"ö",upperCase:"Ö"}]},{width:1/11,chars:[{lowerCase:"ä",upperCase:"Ä"}]}],[{width:2/11,command:"shift",chars:[{icon:"shift"}]},{width:1/11,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:1/11,chars:[{lowerCase:"x",upperCase:"X"}]},{width:1/11,chars:[{lowerCase:"c",upperCase:"C"}]},{width:1/11,chars:[{lowerCase:"v",upperCase:"V"}]},{width:1/11,chars:[{lowerCase:"b",upperCase:"B"}]},{width:1/11,chars:[{lowerCase:"n",upperCase:"N"}]},{width:1/11,chars:[{lowerCase:"m",upperCase:"M"}]},{width:2/11,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Fw=[[[{width:.1,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"l",upperCase:"L"}]},{width:.1,chars:[{lowerCase:"ñ",upperCase:"Ñ"}]}],[{width:.15,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"n",upperCase:"N"}]},{width:.1,chars:[{lowerCase:"m",upperCase:"M"}]},{width:.15,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Ow=[[[{width:.1,chars:[{lowerCase:";",upperCase:":"},{lowerCase:"q",upperCase:"Q"}]},{width:.1,chars:[{lowerCase:"ς",upperCase:"ς"},{lowerCase:"w",upperCase:"W"}]},{width:.1,chars:[{lowerCase:"ε",upperCase:"Ε"},{lowerCase:"e",upperCase:"E"}]},{width:.1,chars:[{lowerCase:"ρ",upperCase:"Ρ"},{lowerCase:"r",upperCase:"R"}]},{width:.1,chars:[{lowerCase:"τ",upperCase:"Τ"},{lowerCase:"t",upperCase:"T"}]},{width:.1,chars:[{lowerCase:"υ",upperCase:"Υ"},{lowerCase:"y",upperCase:"Y"}]},{width:.1,chars:[{lowerCase:"θ",upperCase:"Θ"},{lowerCase:"u",upperCase:"U"}]},{width:.1,chars:[{lowerCase:"ι",upperCase:"Ι"},{lowerCase:"i",upperCase:"I"}]},{width:.1,chars:[{lowerCase:"ο",upperCase:"Ο"},{lowerCase:"o",upperCase:"O"}]},{width:.1,chars:[{lowerCase:"π",upperCase:"Π"},{lowerCase:"p",upperCase:"P"}]}],[{width:.1,chars:[{lowerCase:"α",upperCase:"Α"},{lowerCase:"a",upperCase:"A"}]},{width:.1,chars:[{lowerCase:"σ",upperCase:"Σ"},{lowerCase:"s",upperCase:"S"}]},{width:.1,chars:[{lowerCase:"δ",upperCase:"Δ"},{lowerCase:"d",upperCase:"D"}]},{width:.1,chars:[{lowerCase:"φ",upperCase:"Φ"},{lowerCase:"f",upperCase:"F"}]},{width:.1,chars:[{lowerCase:"γ",upperCase:"Γ"},{lowerCase:"g",upperCase:"G"}]},{width:.1,chars:[{lowerCase:"η",upperCase:"Η"},{lowerCase:"h",upperCase:"H"}]},{width:.1,chars:[{lowerCase:"ξ",upperCase:"Ξ"},{lowerCase:"j",upperCase:"J"}]},{width:.1,chars:[{lowerCase:"κ",upperCase:"Κ"},{lowerCase:"k",upperCase:"K"}]},{width:.1,chars:[{lowerCase:"λ",upperCase:"Λ"},{lowerCase:"l",upperCase:"L"}]}],[{width:.15,command:"shift",chars:[{icon:"shift"}]},{width:.1,chars:[{lowerCase:"ζ",upperCase:"Ζ"},{lowerCase:"z",upperCase:"Z"}]},{width:.1,chars:[{lowerCase:"χ",upperCase:"Χ"},{lowerCase:"x",upperCase:"X"}]},{width:.1,chars:[{lowerCase:"ψ",upperCase:"Ψ"},{lowerCase:"c",upperCase:"C"}]},{width:.1,chars:[{lowerCase:"ω",upperCase:"Ω"},{lowerCase:"v",upperCase:"V"}]},{width:.1,chars:[{lowerCase:"β",upperCase:"Β"},{lowerCase:"b",upperCase:"B"}]},{width:.1,chars:[{lowerCase:"ν",upperCase:"Ν"},{lowerCase:"n",upperCase:"N"}]},{width:.1,chars:[{lowerCase:"μ",upperCase:"Μ"},{lowerCase:"m",upperCase:"M"}]},{width:.15,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.15,command:"switch-set",chars:[{lowerCase:"eng"}]},{width:.15,command:"switch",chars:[{lowerCase:".?12"}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],kw=[[[{width:1/11,chars:[{lowerCase:"q",upperCase:"Q"}]},{width:1/11,chars:[{lowerCase:"w",upperCase:"W"}]},{width:1/11,chars:[{lowerCase:"e",upperCase:"E"}]},{width:1/11,chars:[{lowerCase:"r",upperCase:"R"}]},{width:1/11,chars:[{lowerCase:"t",upperCase:"T"}]},{width:1/11,chars:[{lowerCase:"y",upperCase:"Y"}]},{width:1/11,chars:[{lowerCase:"u",upperCase:"U"}]},{width:1/11,chars:[{lowerCase:"i",upperCase:"I"}]},{width:1/11,chars:[{lowerCase:"o",upperCase:"O"}]},{width:1/11,chars:[{lowerCase:"p",upperCase:"P"}]},{width:1/11,chars:[{lowerCase:"å",upperCase:"Å"}]}],[{width:1/11,chars:[{lowerCase:"a",upperCase:"A"}]},{width:1/11,chars:[{lowerCase:"s",upperCase:"S"}]},{width:1/11,chars:[{lowerCase:"d",upperCase:"D"}]},{width:1/11,chars:[{lowerCase:"f",upperCase:"F"}]},{width:1/11,chars:[{lowerCase:"g",upperCase:"G"}]},{width:1/11,chars:[{lowerCase:"h",upperCase:"H"}]},{width:1/11,chars:[{lowerCase:"j",upperCase:"J"}]},{width:1/11,chars:[{lowerCase:"k",upperCase:"K"}]},{width:1/11,chars:[{lowerCase:"l",upperCase:"L"}]},{width:1/11,chars:[{lowerCase:"æ",upperCase:"Æ"}]},{width:1/11,chars:[{lowerCase:"ø",upperCase:"Ø"}]}],[{width:2/11,command:"shift",chars:[{icon:"shift"}]},{width:1/11,chars:[{lowerCase:"z",upperCase:"Z"}]},{width:1/11,chars:[{lowerCase:"x",upperCase:"X"}]},{width:1/11,chars:[{lowerCase:"c",upperCase:"C"}]},{width:1/11,chars:[{lowerCase:"v",upperCase:"V"}]},{width:1/11,chars:[{lowerCase:"b",upperCase:"B"}]},{width:1/11,chars:[{lowerCase:"n",upperCase:"N"}]},{width:1/11,chars:[{lowerCase:"m",upperCase:"M"}]},{width:2/11,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]],[[{width:.1,chars:[{lowerCase:"1"}]},{width:.1,chars:[{lowerCase:"2"}]},{width:.1,chars:[{lowerCase:"3"}]},{width:.1,chars:[{lowerCase:"4"}]},{width:.1,chars:[{lowerCase:"5"}]},{width:.1,chars:[{lowerCase:"6"}]},{width:.1,chars:[{lowerCase:"7"}]},{width:.1,chars:[{lowerCase:"8"}]},{width:.1,chars:[{lowerCase:"9"}]},{width:.1,chars:[{lowerCase:"0"}]}],[{width:.1,chars:[{lowerCase:"@"}]},{width:.1,chars:[{lowerCase:"#"}]},{width:.1,chars:[{lowerCase:"|"}]},{width:.1,chars:[{lowerCase:"_"}]},{width:.1,chars:[{lowerCase:"&"}]},{width:.1,chars:[{lowerCase:"-"}]},{width:.1,chars:[{lowerCase:"+"}]},{width:.1,chars:[{lowerCase:"("}]},{width:.1,chars:[{lowerCase:")"}]},{width:.1,chars:[{lowerCase:"/"}]}],[{width:.1,chars:[{lowerCase:"="}]},{width:.1,chars:[{lowerCase:"*"}]},{width:.1,chars:[{lowerCase:'"'}]},{width:.1,chars:[{lowerCase:"'"}]},{width:.1,chars:[{lowerCase:":"}]},{width:.1,chars:[{lowerCase:";"}]},{width:.1,chars:[{lowerCase:"!"}]},{width:.1,chars:[{lowerCase:"?"}]},{width:.2,command:"backspace",chars:[{icon:"backspace"}]}],[{width:.2,command:"switch",chars:[{lowerCase:".?12"}]},{width:.1,chars:[{lowerCase:","}]},{width:.4,command:"space",chars:[{icon:"space"}]},{width:.1,chars:[{lowerCase:"."}]},{width:.2,command:"enter",chars:[{icon:"enter"}]}]]],Qw=new Sh;class zw extends(Ew.withBase(Vr)(Lx,gw)){constructor(t){let e;if(t||(t={}),t.width||(t.width=1),t.height||(t.height=.4),t.margin||(t.margin=.003),t.padding||(t.padding=.01),super(t),this.currentPanel=0,this.isLowerCase=!0,this.charsetCount=1,t.language||navigator.language)switch(t.language||navigator.language){case"fr":case"fr-CH":case"fr-CA":e=Pw;break;case"ru":this.charsetCount=2,e=Uw;break;case"de":case"de-DE":case"de-AT":case"de-LI":case"de-CH":e=Nw;break;case"es":case"es-419":case"es-AR":case"es-CL":case"es-CO":case"es-ES":case"es-CR":case"es-US":case"es-HN":case"es-MX":case"es-PE":case"es-UY":case"es-VE":e=Fw;break;case"el":this.charsetCount=2,e=Ow;break;case"nord":e=kw;break;default:e=Lw}else e=Lw;this.keys=[],this.panels=e.map((e=>{const n=t.height/e.length-2*t.margin,i=new Mw({width:t.width+2*t.padding,height:t.height+2*t.padding,offset:0,padding:t.padding,fontFamily:t.fontFamily,fontTexture:t.fontTexture,backgroundColor:t.backgroundColor,backgroundOpacity:t.backgroundOpacity});return i.charset=0,i.add(...e.map((e=>{const r=new Mw({width:t.width,height:n,margin:t.margin,contentDirection:"row",justifyContent:"center"});r.frame.visible=!1;const s=[];return e.forEach((e=>{const r=new Mw({width:t.width*e.width-2*t.margin,height:n,margin:t.margin,justifyContent:"center",offset:0}),a=e.chars[i.charset].lowerCase||e.chars[i.charset].icon||"undif";if("enter"===a&&t.enterTexture||"shift"===a&&t.shiftTexture||"backspace"===a&&t.backspaceTexture){const e=(()=>{switch(a){case"backspace":return t.backspaceTexture;case"enter":return t.enterTexture;case"shift":return t.shiftTexture;default:console.warn("There is no icon image for this key")}})();Qw.load(e,(t=>{r.add(new Dw({width:.65*r.width,height:.65*r.height,backgroundSize:"contain",backgroundTexture:t}))}))}else r.add(new Rw({content:a,offset:0}));r.type="Key",r.info=e,r.info.input=a,r.panel=i,s.push(r),this.keys.push(r)})),r.add(...s),r}))),i})),this.add(this.panels[0]),this.set(t)}setNextPanel(){this.panels.forEach((t=>{this.remove(t)})),this.currentPanel=(this.currentPanel+1)%this.panels.length,this.add(this.panels[this.currentPanel]),this.update(!0,!0,!0)}setNextCharset(){this.panels[this.currentPanel].charset=(this.panels[this.currentPanel].charset+1)%this.charsetCount,this.keys.forEach((t=>{if(!this.panels[this.currentPanel].getObjectById(t.id))return;const e=t.info.chars[t.panel.charset]||t.info.chars[0],n=this.isLowerCase||!e.upperCase?e.lowerCase:e.upperCase;if(!t.childrenTexts.length)return;const i=t.childrenTexts[0];t.info.input=n,i.set({content:n}),i.update(!0,!0,!0)}))}toggleCase(){this.isLowerCase=!this.isLowerCase,this.keys.forEach((t=>{const e=t.info.chars[t.panel.charset]||t.info.chars[0],n=this.isLowerCase||!e.upperCase?e.lowerCase:e.upperCase;if(!t.childrenTexts.length)return;const i=t.childrenTexts[0];t.info.input=n,i.set({content:n}),i.update(!0,!0,!0)}))}parseParams(){}updateLayout(){}updateInner(){}}const Gw={Block:Mw,Text:Rw,InlineBlock:Dw,Keyboard:zw,FontLibrary:dw,update:()=>pw.update(),TextAlign:l,Whitespace:o,JustifyContent:a,AlignItems:s,ContentDirection:r};void 0!==t.g&&(t.g.ThreeMeshUI=Gw);const Hw=Gw;function Vw(t,e,n){return null===t?null:(t.point.applyMatrix4(e.matrixWorld),t.distance=t.point.distanceTo(n.ray.origin),t.object=e,t)}const Ww=0,jw=1,qw=2,Xw=0,Yw=1,Jw=2,Kw=1.25,Zw=1,$w=32,tC=65535,eC=Math.pow(2,-24),nC=Symbol("SKIP_GENERATION");function iC(t){return t.index?t.index.count:t.attributes.position.count}function rC(t){return iC(t)/3}function sC(t,e=ArrayBuffer){return t>65535?new Uint32Array(new e(4*t)):new Uint16Array(new e(2*t))}function aC(t,e){const n=rC(t),i=e||t.drawRange,r=i.start/3,s=(i.start+i.count)/3,a=Math.max(0,r),o=Math.min(n,s)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function oC(t,e){if(!t.groups||!t.groups.length)return aC(t,e);const n=[],i=new Set,r=e||t.drawRange,s=r.start/3,a=(r.start+r.count)/3;for(const e of t.groups){const t=e.start/3,n=(e.start+e.count)/3;i.add(Math.max(s,t)),i.add(Math.min(a,n))}const o=Array.from(i.values()).sort(((t,e)=>t-e));for(let t=0;tl&&(l=A),ef&&(f=e);const v=t[i+2],y=t[i+3],_=v-y,x=v+y;_c&&(c=x),vm&&(m=v);const w=t[i+4],C=t[i+5],E=w-C,M=w+C;Eh&&(h=M),wg&&(g=w)}i[0]=s,i[1]=a,i[2]=o,i[3]=l,i[4]=c,i[5]=h,r[0]=u,r[1]=d,r[2]=p,r[3]=f,r[4]=m,r[5]=g}function cC(t,e,n){return n.min.x=e[t],n.min.y=e[t+1],n.min.z=e[t+2],n.max.x=e[t+3],n.max.y=e[t+4],n.max.z=e[t+5],n}function hC(t){let e=-1,n=-1/0;for(let i=0;i<3;i++){const r=t[i+3]-t[i];r>n&&(n=r,e=i)}return e}function uC(t,e){e.set(t)}function dC(t,e,n){let i,r;for(let s=0;s<3;s++){const a=s+3;i=t[s],r=e[s],n[s]=ir?i:r}}function pC(t,e,n){for(let i=0;i<3;i++){const r=e[t+2*i],s=e[t+2*i+1],a=r-s,o=r+s;an[i+3]&&(n[i+3]=o)}}function fC(t){const e=t[3]-t[0],n=t[4]-t[1],i=t[5]-t[2];return 2*(e*n+n*i+i*e)}const mC=(t,e)=>t.candidate-e.candidate,gC=new Array(32).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),AC=new Float32Array(6);class vC{constructor(){this.boundingData=new Float32Array(6)}}function yC(t,e,n,i,r,s){let a=i,o=i+r-1;const l=s.pos,c=2*s.axis;for(;;){for(;a<=o&&n[6*a+c]=l;)o--;if(!(a=l;)o--;if(!(aRC)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return IC[n+6]=a/4,a=LC(a,r),IC[n+7]=s,a}}function UC(t,e){const n=t.geometry;e.indirect&&(t._indirectBuffer=function(t,e){const n=(t.index?t.index.count:t.attributes.position.count)/3,i=n>65536,r=i?4:2,s=e?new SharedArrayBuffer(n*r):new ArrayBuffer(n*r),a=i?new Uint32Array(s):new Uint16Array(s);for(let t=0,e=a.length;tt.offset-e.offset)),r=i[i.length-1];r.count=Math.min(n-r.offset,r.count);let s=0;return i.forEach((({count:t})=>s+=t)),n!==s}(n,e.range)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),t._indirectBuffer||function(t,e){if(!t.index){const n=t.attributes.position.count,i=sC(n,e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);t.setIndex(new ws(i,1));for(let t=0;tf&&(f=s),h>f&&(f=h);const m=(f-u)/2,g=2*t;l[n+g+0]=u+m,l[n+g+1]=m+(Math.abs(u)+m)*eC}}return l}(n),s=e.indirect?aC(n,e.range):oC(n,e.range);t._roots=s.map((n=>{const s=function(t,e,n,i,r){const{maxDepth:s,verbose:a,maxLeafTris:o,strategy:l,onProgress:c,indirect:h}=r,u=t._indirectBuffer,d=t.geometry,p=d.index?d.index.array:null,f=h?_C:yC,m=rC(d),g=new Float32Array(6);let A=!1;const v=new vC;return lC(e,n,i,v.boundingData,g),function t(n,i,r,c=null,h=0){if(!A&&h>=s&&(A=!0,a&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(d))),r<=o||h>=s)return y(i+r),n.offset=i,n.count=r,n;const m=function(t,e,n,i,r,s){let a=-1,o=0;if(s===Ww)a=hC(e),-1!==a&&(o=(e[a]+e[a+3])/2);else if(s===jw)a=hC(t),-1!==a&&(o=function(t,e,n,i){let r=0;for(let s=e,a=e+n;s=s.candidate?pC(i,n,s.rightCacheBounds):(pC(i,n,s.leftCacheBounds),s.count++)}}for(let n=0;n=32&&(r=31);const s=gC[r];s.count++,pC(e,n,s.bounds)}const e=gC[31];uC(e.bounds,e.rightCacheBounds);for(let t=30;t>=0;t--){const e=gC[t],n=gC[t+1];dC(e.bounds,n.rightCacheBounds,e.rightCacheBounds)}let d=0;for(let e=0;e<31;e++){const n=gC[e],i=n.count,c=n.bounds,h=gC[e+1].rightCacheBounds;0!==i&&(0===d?uC(c,AC):dC(c,AC,AC)),d+=i;let u=0,p=0;0!==d&&(u=fC(AC)/s);const f=r-d;0!==f&&(p=fC(h)/s);const m=Zw+Kw*(u*d+p*f);mi?s:i}this.min=n,this.max=i}setFromPoints(t,e){let n=1/0,i=-1/0;for(let r=0,s=e.length;ri?a:i}this.min=n,this.max=i}isSeparated(t){return this.min>t.max||t.min>this.max}}NC.prototype.setFromBox=function(){const t=new zi;return function(e,n){const i=n.min,r=n.max;let s=1/0,a=-1/0;for(let n=0;n<=1;n++)for(let o=0;o<=1;o++)for(let l=0;l<=1;l++){t.x=i.x*n+r.x*(1-n),t.y=i.y*o+r.y*(1-o),t.z=i.z*l+r.z*(1-l);const c=e.dot(t);s=Math.min(c,s),a=Math.max(c,a)}this.min=s,this.max=a}}(),new NC;const FC=function(){const t=new zi,e=new zi,n=new zi;return function(i,r,s){const a=i.start,o=t,l=r.start,c=e;n.subVectors(a,l),t.subVectors(i.end,i.start),e.subVectors(r.end,r.start);const h=n.dot(c),u=c.dot(o),d=c.dot(c),p=n.dot(o),f=o.dot(o)*d-u*u;let m,g;m=0!==f?(h*u-p*d)/f:0,g=(h+m*u)/d,s.x=m,s.y=g}}(),OC=function(){const t=new hi,e=new zi,n=new zi;return function(i,r,s,a){FC(i,r,t);let o=t.x,l=t.y;if(o>=0&&o<=1&&l>=0&&l<=1)return i.at(o,s),void r.at(l,a);if(o>=0&&o<=1)return l<0?r.at(0,a):r.at(1,a),void i.closestPointToPoint(a,!0,s);if(l>=0&&l<=1)return o<0?i.at(0,s):i.at(1,s),void r.closestPointToPoint(s,!0,a);{let t,c;t=o<0?i.start:i.end,c=l<0?r.start:r.end;const h=e,u=n;return i.closestPointToPoint(c,!0,e),r.closestPointToPoint(t,!0,n),h.distanceToSquared(c)<=u.distanceToSquared(t)?(s.copy(h),void a.copy(c)):(s.copy(t),void a.copy(u))}}}(),kC=function(){const t=new zi,e=new zi,n=new go,i=new td;return function(r,s){const{radius:a,center:o}=r,{a:l,b:c,c:h}=s;if(i.start=l,i.end=c,i.closestPointToPoint(o,!0,t).distanceTo(o)<=a)return!0;if(i.start=l,i.end=h,i.closestPointToPoint(o,!0,t).distanceTo(o)<=a)return!0;if(i.start=c,i.end=h,i.closestPointToPoint(o,!0,t).distanceTo(o)<=a)return!0;const u=s.getPlane(n);if(Math.abs(u.distanceToPoint(o))<=a){const t=u.projectPoint(o,e);if(s.containsPoint(t))return!0}return!1}}();function QC(t){return Math.abs(t)<1e-15}class zC extends rs{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map((()=>new zi)),this.satBounds=new Array(4).fill().map((()=>new NC)),this.points=[this.a,this.b,this.c],this.sphere=new lr,this.plane=new go,this.needsUpdate=!0}intersectsSphere(t){return kC(t,this)}update(){const t=this.a,e=this.b,n=this.c,i=this.points,r=this.satAxes,s=this.satBounds,a=r[0],o=s[0];this.getNormal(a),o.setFromPoints(a,i);const l=r[1],c=s[1];l.subVectors(t,e),c.setFromPoints(l,i);const h=r[2],u=s[2];h.subVectors(e,n),u.setFromPoints(h,i);const d=r[3],p=s[3];d.subVectors(n,t),p.setFromPoints(d,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}}zC.prototype.closestPointToSegment=function(){const t=new zi,e=new zi,n=new td;return function(i,r=null,s=null){const{start:a,end:o}=i,l=this.points;let c,h=1/0;for(let a=0;a<3;a++){const o=(a+1)%3;n.start.copy(l[a]),n.end.copy(l[o]),OC(n,i,t,e),c=t.distanceToSquared(e),c=2){(1===s?n.start:n.end).copy(p),r=2;break}if(r++,2===r&&-1===s)break}}return r}return function(a,h=null,p=!1){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(t.copy(a),t.update(),a=t);const m=this.plane,g=a.plane;if(Math.abs(m.normal.dot(g.normal))>1-1e-10){const t=this.satBounds,o=this.satAxes;n[0]=a.a,n[1]=a.b,n[2]=a.c;for(let e=0;e<4;e++){const r=t[e],s=o[e];if(i.setFromPoints(s,n),r.isSeparated(i))return!1}const l=a.satBounds,c=a.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let t=0;t<4;t++){const n=l[t],r=c[t];if(i.setFromPoints(r,e),n.isSeparated(i))return!1}for(let t=0;t<4;t++){const a=o[t];for(let t=0;t<4;t++){const o=c[t];if(s.crossVectors(a,o),i.setFromPoints(s,e),r.setFromPoints(s,n),i.isSeparated(r))return!1}}return h&&(p||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),h.start.set(0,0,0),h.end.set(0,0,0)),!0}{const t=f(this,g,u);if(1===t&&a.containsPoint(u.end))return h&&(h.start.copy(u.end),h.end.copy(u.end)),!0;if(2!==t)return!1;const e=f(a,m,d);if(1===e&&this.containsPoint(d.end))return h&&(h.start.copy(d.end),h.end.copy(d.end)),!0;if(2!==e)return!1;if(u.delta(o),d.delta(l),o.dot(l)<0){let t=d.start;d.start=d.end,d.end=t}const n=u.start.dot(o),i=u.end.dot(o),r=d.start.dot(o),s=d.end.dot(o);return(n===s||r===i||i0?h.start.copy(u.start):h.start.copy(d.start),c.subVectors(u.end,d.end),c.dot(o)<0?h.end.copy(u.end):h.end.copy(d.end)),!0)}}}(),zC.prototype.distanceToPoint=function(){const t=new zi;return function(e){return this.closestPointToPoint(e,t),e.distanceTo(t)}}(),zC.prototype.distanceToTriangle=function(){const t=new zi,e=new zi,n=["a","b","c"],i=new td,r=new td;return function(s,a=null,o=null){const l=a||o?i:null;if(this.intersectsTriangle(s,l))return(a||o)&&(a&&l.getCenter(a),o&&l.getCenter(o)),0;let c=1/0;for(let e=0;e<3;e++){let i;const r=n[e],l=s[r];this.closestPointToPoint(l,t),i=l.distanceToSquared(t),inew zi)),this.satAxes=new Array(3).fill().map((()=>new zi)),this.satBounds=new Array(3).fill().map((()=>new NC)),this.alignedSatBounds=new Array(3).fill().map((()=>new NC)),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),n&&this.matrix.copy(n)}set(t,e,n){this.min.copy(t),this.max.copy(e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}}GC.prototype.update=function(){const t=this.matrix,e=this.min,n=this.max,i=this.points;for(let r=0;r<=1;r++)for(let s=0;s<=1;s++)for(let a=0;a<=1;a++){const o=i[1*r|2*s|4*a];o.x=r?n.x:e.x,o.y=s?n.y:e.y,o.z=a?n.z:e.z,o.applyMatrix4(t)}const r=this.satBounds,s=this.satAxes,a=i[0];for(let t=0;t<3;t++){const e=s[t],n=r[t],o=i[1<new td)),n=new Array(12).fill().map((()=>new td)),i=new zi,r=new zi;return function(s,a=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(s))return(o||l)&&(s.getCenter(r),this.closestPointToPoint(r,i),s.closestPointToPoint(i,r),o&&o.copy(i),l&&l.copy(r)),0;const c=a*a,h=s.min,u=s.max,d=this.points;let p=1/0;for(let t=0;t<8;t++){const e=d[t];r.copy(e).clamp(h,u);const n=e.distanceToSquared(r);if(nnew zC))}}const WC=new VC,jC=new class{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const t=[];let e=null;this.setBuffer=n=>{e&&t.push(e),e=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{e=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,0!==t.length&&this.setBuffer(t.pop())}}};let qC,XC;const YC=[],JC=new HC((()=>new Vi));function KC(t,e,n,i,r,s){qC=JC.getPrimitive(),XC=JC.getPrimitive(),YC.push(qC,XC),jC.setBuffer(t._roots[e]);const a=ZC(0,t.geometry,n,i,r,s);jC.clearBuffer(),JC.releasePrimitive(qC),JC.releasePrimitive(XC),YC.pop(),YC.pop();const o=YC.length;return o>0&&(XC=YC[o-1],qC=YC[o-2]),a}function ZC(t,e,n,i,r=null,s=0,a=0){const{float32Array:o,uint16Array:l,uint32Array:c}=jC;let h=2*t;if(xC(h,l)){const u=wC(t,c),d=CC(h,l);return cC(t,o,qC),i(u,d,!1,a,s+t,qC)}{const p=EC(t),f=MC(t,c);let m,g,A,v,y=p,_=f;if(r&&(A=qC,v=XC,cC(y,o,A),cC(_,o,v),m=r(A),g=r(v),g=169,nE=new zi,iE=new zi,rE=new zi,sE=new hi,aE=new hi,oE=new hi,lE=new zi,cE=new zi,hE=new zi,uE=new zi;function dE(t,e,n,i,r,s,a){const o=3*i;let l=o+0,c=o+1,h=o+2;const u=t.index;t.index&&(l=u.getX(l),c=u.getX(c),h=u.getX(h));const{position:d,normal:p,uv:f,uv1:m}=t.attributes,g=function(t,e,n,i,r,s,a,o,l,c,h){nE.fromBufferAttribute(e,s),iE.fromBufferAttribute(e,a),rE.fromBufferAttribute(e,o);const u=function(t,e,n,i,r,s,a,o){let l;if(l=s===M?t.intersectTriangle(i,n,e,!0,r):t.intersectTriangle(e,n,i,s!==S,r),null===l)return null;const c=t.origin.distanceTo(r);return co?null:{distance:c,point:r.clone()}}(t,nE,iE,rE,uE,l,c,h);if(u){const e=new zi;rs.getBarycoord(uE,nE,iE,rE,e),i&&(sE.fromBufferAttribute(i,s),aE.fromBufferAttribute(i,a),oE.fromBufferAttribute(i,o),u.uv=rs.getInterpolation(uE,nE,iE,rE,sE,aE,oE,new hi)),r&&(sE.fromBufferAttribute(r,s),aE.fromBufferAttribute(r,a),oE.fromBufferAttribute(r,o),u.uv1=rs.getInterpolation(uE,nE,iE,rE,sE,aE,oE,new hi)),n&&(lE.fromBufferAttribute(n,s),cE.fromBufferAttribute(n,a),hE.fromBufferAttribute(n,o),u.normal=rs.getInterpolation(uE,nE,iE,rE,lE,cE,hE,new zi),u.normal.dot(t.direction)>0&&u.normal.multiplyScalar(-1));const l={a:s,b:a,c:o,normal:new zi,materialIndex:0};rs.getNormal(nE,iE,rE,l.normal),u.face=l,u.faceIndex=s,eE&&(u.barycoord=e)}return u}(n,d,p,f,m,l,c,h,e,s,a);return g?(g.faceIndex=i,r&&r.push(g),g):null}function pE(t,e,n,i){const r=t.a,s=t.b,a=t.c;let o=e,l=e+1,c=e+2;n&&(o=n.getX(o),l=n.getX(l),c=n.getX(c)),r.x=i.getX(o),r.y=i.getY(o),r.z=i.getZ(o),s.x=i.getX(l),s.y=i.getY(l),s.z=i.getZ(l),a.x=i.getX(c),a.y=i.getY(c),a.z=i.getZ(c)}const fE=new zi,mE=new zi,gE=new zi,AE=new hi,vE=new hi,yE=new hi;function _E(t,e,n,i){const r=e.getIndex().array,s=e.getAttribute("position"),a=e.getAttribute("uv"),o=r[3*n],l=r[3*n+1],c=r[3*n+2];fE.fromBufferAttribute(s,o),mE.fromBufferAttribute(s,l),gE.fromBufferAttribute(s,c);let h=0;const u=e.groups,d=3*n;for(let t=0,e=u.length;t=n&&du&&(u=a),od&&(d=o),lp&&(p=l)}return(l[t+0]!==n||l[t+1]!==s||l[t+2]!==h||l[t+3]!==u||l[t+4]!==d||l[t+5]!==p)&&(l[t+0]=n,l[t+1]=s,l[t+2]=h,l[t+3]=u,l[t+4]=d,l[t+5]=p,!0)}{const i=t+8,r=a[t+6],o=i+n,c=r+n;let h=s,d=!1,p=!1;e?h||(d=e.has(o),p=e.has(c),h=!d&&!p):(d=!0,p=!0);const f=h||p;let m=!1;(h||d)&&(m=u(i,n,h));let g=!1;f&&(g=u(r,n,h));const A=m||g;if(A)for(let e=0;e<3;e++){const n=i+e,s=r+e,a=l[n],o=l[n+3],c=l[s],h=l[s+3];l[t+e]=ah?o:h}return A}}}function CE(t,e,n,i,r){let s,a,o,l,c,h;const u=1/n.direction.x,d=1/n.direction.y,p=1/n.direction.z,f=n.origin.x,m=n.origin.y,g=n.origin.z;let A=e[t],v=e[t+3],y=e[t+1],_=e[t+3+1],x=e[t+2],w=e[t+3+2];return u>=0?(s=(A-f)*u,a=(v-f)*u):(s=(v-f)*u,a=(A-f)*u),d>=0?(o=(y-m)*d,l=(_-m)*d):(o=(_-m)*d,l=(y-m)*d),!(s>l||o>a)&&((o>s||isNaN(s))&&(s=o),(l=0?(c=(x-g)*p,h=(w-g)*p):(c=(w-g)*p,h=(x-g)*p),!(s>h||c>a)&&((c>s||s!=s)&&(s=c),(h=i))}function EE(t,e,n,i,r,s,a){jC.setBuffer(t._roots[e]),ME(0,t,n,i,r,s,a),jC.clearBuffer()}function ME(t,e,n,i,r,s,a){const{float32Array:o,uint16Array:l,uint32Array:c}=jC,h=2*t;if(xC(h,l))!function(t,e,n,i,r,s,a,o){const{geometry:l,_indirectBuffer:c}=t;for(let t=i,c=i+r;t=0;let u,d;h?(u=EC(t),d=MC(t,l)):(u=MC(t,l),d=EC(t));const p=CE(u,a,i,r,s)?IE(u,e,n,i,r,s):null;if(p){const t=p.point[c];if(h?t<=a[d+o]:t>=a[d+o+3])return p}const f=CE(d,a,i,r,s)?IE(d,e,n,i,r,s):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}const TE=new Vi,BE=new zC,RE=new zC,DE=new Ar,PE=new GC,LE=new GC;function UE(t,e,n,i){jC.setBuffer(t._roots[e]);const r=NE(0,t,n,i);return jC.clearBuffer(),r}function NE(t,e,n,i,r=null){const{float32Array:s,uint16Array:a,uint32Array:o}=jC;let l=2*t;if(null===r&&(n.boundingBox||n.computeBoundingBox(),PE.set(n.boundingBox.min,n.boundingBox.max,i),r=PE),!xC(l,a)){const a=t+8,l=o[t+6];return cC(a,s,TE),r.intersectsBox(TE)&&NE(a,e,n,i,r)?!0:(cC(l,s,TE),!(!r.intersectsBox(TE)||!NE(l,e,n,i,r)))}{const r=e.geometry,c=r.index,h=r.attributes.position,u=n.index,d=n.attributes.position,p=wC(t,o),f=CC(l,a);if(DE.copy(i).invert(),n.boundsTree){cC(t,s,LE),LE.matrix.copy(DE),LE.needsUpdate=!0;const e=n.boundsTree.shapecast({intersectsBounds:t=>LE.intersectsBox(t),intersectsTriangle:t=>{t.a.applyMatrix4(i),t.b.applyMatrix4(i),t.c.applyMatrix4(i),t.needsUpdate=!0;for(let e=3*p,n=3*(f+p);eOE.distanceToBox(t),intersectsBounds:(t,e,n)=>n{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:t=>kE.distanceToBox(t),intersectsBounds:(t,e,n)=>n{for(let a=e,o=e+r;ad&&(d=a),op&&(p=o),lf&&(f=l)}}return(l[n+0]!==s||l[n+1]!==c||l[n+2]!==u||l[n+3]!==d||l[n+4]!==p||l[n+5]!==f)&&(l[n+0]=s,l[n+1]=c,l[n+2]=u,l[n+3]=d,l[n+4]=p,l[n+5]=f,!0)}{const t=n+8,i=a[n+6],r=t+s,o=i+s;let h=c,d=!1,p=!1;e?h||(d=e.has(r),p=e.has(o),h=!d&&!p):(d=!0,p=!0);const f=h||p;let m=!1;(h||d)&&(m=u(t,s,h));let g=!1;f&&(g=u(i,s,h));const A=m||g;if(A)for(let e=0;e<3;e++){const r=t+e,s=i+e,a=l[r],o=l[r+3],c=l[s],h=l[s+3];l[n+e]=ah?o:h}return A}}}function qE(t,e,n,i,r,s,a){jC.setBuffer(t._roots[e]),XE(0,t,n,i,r,s,a),jC.clearBuffer()}function XE(t,e,n,i,r,s,a){const{float32Array:o,uint16Array:l,uint32Array:c}=jC,h=2*t;if(xC(h,l))!function(t,e,n,i,r,s,a,o){const{geometry:l,_indirectBuffer:c}=t;for(let t=i,h=i+r;t=0;let u,d;h?(u=EC(t),d=MC(t,l)):(u=MC(t,l),d=EC(t));const p=CE(u,a,i,r,s)?KE(u,e,n,i,r,s):null;if(p){const t=p.point[c];if(h?t<=a[d+o]:t>=a[d+o+3])return p}const f=CE(d,a,i,r,s)?KE(d,e,n,i,r,s):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}const ZE=new Vi,$E=new zC,tM=new zC,eM=new Ar,nM=new GC,iM=new GC;function rM(t,e,n,i){jC.setBuffer(t._roots[e]);const r=sM(0,t,n,i);return jC.clearBuffer(),r}function sM(t,e,n,i,r=null){const{float32Array:s,uint16Array:a,uint32Array:o}=jC;let l=2*t;if(null===r&&(n.boundingBox||n.computeBoundingBox(),nM.set(n.boundingBox.min,n.boundingBox.max,i),r=nM),!xC(l,a)){const a=t+8,l=o[t+6];return cC(a,s,ZE),r.intersectsBox(ZE)&&sM(a,e,n,i,r)?!0:(cC(l,s,ZE),!(!r.intersectsBox(ZE)||!sM(l,e,n,i,r)))}{const r=e.geometry,c=r.index,h=r.attributes.position,u=n.index,d=n.attributes.position,p=wC(t,o),f=CC(l,a);if(eM.copy(i).invert(),n.boundsTree){cC(t,s,iM),iM.matrix.copy(eM),iM.needsUpdate=!0;const r=n.boundsTree.shapecast({intersectsBounds:t=>iM.intersectsBox(t),intersectsTriangle:t=>{t.a.applyMatrix4(i),t.b.applyMatrix4(i),t.c.applyMatrix4(i),t.needsUpdate=!0;for(let n=p,i=f+p;noM.distanceToBox(t),intersectsBounds:(t,e,n)=>n{if(e.boundsTree){const o=e.boundsTree;return o.shapecast({boundsTraverseOrder:t=>lM.distanceToBox(t),intersectsBounds:(t,e,n)=>n{for(let x=e,w=e+a;xnew Vi)),vM=new Vi,yM=new Vi,_M=new Vi,xM=new Vi;let wM=!1;function CM(t,e,n,i,r,s=0,a=0,o=0,l=0,c=null,h=!1){let u,d;h?(u=gM,d=mM):(u=mM,d=gM);const p=u.float32Array,f=u.uint32Array,m=u.uint16Array,g=d.float32Array,A=d.uint32Array,v=d.uint16Array,y=2*e,_=xC(2*t,m),x=xC(y,v);let w=!1;if(x&&_)w=h?r(wC(e,A),CC(2*e,v),wC(t,f),CC(2*t,m),l,a+e,o,s+t):r(wC(t,f),CC(2*t,m),wC(e,A),CC(2*e,v),o,s+t,l,a+e);else if(x){const c=AM.getPrimitive();cC(e,g,c),c.applyMatrix4(n);const u=EC(t),d=MC(t,f);cC(u,p,vM),cC(d,p,yM);const m=c.intersectsBox(vM),A=c.intersectsBox(yM);w=m&&CM(e,u,i,n,r,a,s,l,o+1,c,!h)||A&&CM(e,d,i,n,r,a,s,l,o+1,c,!h),AM.releasePrimitive(c)}else{const u=EC(e),d=MC(e,A);cC(u,g,_M),cC(d,g,xM);const m=c.intersectsBox(_M),v=c.intersectsBox(xM);if(m&&v)w=CM(t,u,n,i,r,s,a,o,l+1,c,h)||CM(t,d,n,i,r,s,a,o,l+1,c,h);else if(m)if(_)w=CM(t,u,n,i,r,s,a,o,l+1,c,h);else{const e=AM.getPrimitive();e.copy(_M).applyMatrix4(n);const c=EC(t),d=MC(t,f);cC(c,p,vM),cC(d,p,yM);const m=e.intersectsBox(vM),g=e.intersectsBox(yM);w=m&&CM(u,c,i,n,r,a,s,l,o+1,e,!h)||g&&CM(u,d,i,n,r,a,s,l,o+1,e,!h),AM.releasePrimitive(e)}else if(v)if(_)w=CM(t,d,n,i,r,s,a,o,l+1,c,h);else{const e=AM.getPrimitive();e.copy(xM).applyMatrix4(n);const c=EC(t),u=MC(t,f);cC(c,p,vM),cC(u,p,yM);const m=e.intersectsBox(vM),g=e.intersectsBox(yM);w=m&&CM(d,c,i,n,r,a,s,l,o+1,e,!h)||g&&CM(d,u,i,n,r,a,s,l,o+1,e,!h),AM.releasePrimitive(e)}}return w}const EM=new GC,MM=new Vi,SM={strategy:Ww,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class bM{static serialize(t,e={}){e={cloneBuffers:!0,...e};const n=t.geometry,i=t._roots,r=t._indirectBuffer,s=n.getIndex();let a;return a=e.cloneBuffers?{roots:i.map((t=>t.slice())),index:s?s.array.slice():null,indirectBuffer:r?r.slice():null}:{roots:i,index:s?s.array:null,indirectBuffer:r},a}static deserialize(t,e,n={}){n={setIndex:!0,indirect:Boolean(t.indirectBuffer),...n};const{index:i,roots:r,indirectBuffer:s}=t,a=new bM(e,{...n,[nC]:!0});if(a._roots=r,a._indirectBuffer=s||null,n.setIndex){const n=e.getIndex();if(null===n){const n=new ws(t.index,1,!1);e.setIndex(n)}else n.array!==i&&(n.array.set(i),n.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(t,e={}){if(!t.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");if((e=Object.assign({...SM,[nC]:!1},e)).useSharedArrayBuffer&&!fM())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=t,this._roots=null,this._indirectBuffer=null,e[nC]||(UC(this,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new Vi))),this.resolveTriangleIndex=e.indirect?t=>this._indirectBuffer[t]:t=>t}refit(t=null){return(this.indirect?jE:wE)(this,t)}traverse(t,e=0){const n=this._roots[e],i=new Uint32Array(n),r=new Uint16Array(n);!function e(s,a=0){const o=2*s,l=r[o+15]===tC;if(l){const e=i[s+6],c=r[o+14];t(a,l,new Float32Array(n,4*s,6),e,c)}else{const r=s+8,o=i[s+6],c=i[s+7];t(a,l,new Float32Array(n,4*s,6),c)||(e(r,a+1),e(o,a+1))}}(0)}raycast(t,e=E,n=0,i=1/0){const r=this._roots,s=this.geometry,a=[],o=e.isMaterial,l=Array.isArray(e),c=s.groups,h=o?e.side:e,u=this.indirect?qE:EE;for(let s=0,o=r.length;s!!t(i,r,s,o,l)||n(i,r,this,a,s,o,e)}else s||(s=a?(t,i,r,s)=>n(t,i,this,a,r,s,e):(t,e,n)=>n);let o=!1,l=0;const c=this._roots;for(let t=0,e=c.length;t{const e=this.resolveTriangleIndex(t);pE(s,3*e,a,o)}:t=>{pE(s,3*t,a,o)},c=WC.getPrimitive(),h=t.geometry.index,u=t.geometry.attributes.position,d=t.indirect?e=>{const n=t.resolveTriangleIndex(e);pE(c,3*n,h,u)}:t=>{pE(c,3*t,h,u)};if(r){const t=(t,n,i,a,o,h,u,p)=>{for(let f=i,m=i+a;fEM.intersectsBox(t),intersectsTriangle:t=>EM.intersectsTriangle(t)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n={},i={},r=0,s=1/0){return(this.indirect?pM:VE)(this,t,e,n,i,r,s)}closestPointToPoint(t,e={},n=0,i=1/0){return function(t,e,n={},i=0,r=1/0){const s=i*i,a=r*r;let o=1/0,l=null;if(t.shapecast({boundsTraverseOrder:t=>($C.copy(e).clamp(t.min,t.max),$C.distanceToSquared(e)),intersectsBounds:(t,e,n)=>n{t.closestPointToPoint(e,$C);const i=e.distanceToSquared($C);return i{cC(0,new Float32Array(e),MM),t.union(MM)})),t}}const IM=parseInt(p)>=166,TM=new gr,BM=new zi,RM=new Ar,DM=Ks.prototype.raycast,PM=Fo.prototype.raycast,LM=new zi,UM=new Ks,NM=[];function FM(t,e){this.isBatchedMesh?OM.call(this,t,e):kM.call(this,t,e)}function OM(t,e){if(this.boundsTrees){const n=this.boundsTrees,i=this._drawInfo||this._instanceInfo,r=this._drawRanges||this._geometryInfo,s=this.matrixWorld;UM.material=this.material,UM.geometry=this.geometry;const a=UM.geometry.boundsTree,o=UM.geometry.drawRange;null===UM.geometry.boundingSphere&&(UM.geometry.boundingSphere=new lr);for(let a=0,o=i.length;a{if(t>=i||e)return s++,!0;r&&s++}),n);let a=0;const o=new Float32Array(24*s);let l,c;e.traverse(((t,e,n)=>{const s=t>=i||e;if(s||r){cC(0,n,VM);const{min:t,max:e}=VM;for(let n=-1;n<=1;n+=2){const i=n<0?t.x:e.x;for(let n=-1;n<=1;n+=2){const r=n<0?t.y:e.y;for(let n=-1;n<=1;n+=2){const s=n<0?t.z:e.z;o[a+0]=i,o[a+1]=r,o[a+2]=s,a+=3}}}return s}}),n),c=this.displayEdges?new Uint8Array([0,4,1,5,2,6,3,7,0,2,1,3,4,6,5,7,0,1,2,3,4,5,6,7]):new Uint8Array([0,1,2,2,1,3,4,6,5,6,7,5,1,4,5,0,4,1,2,3,6,3,7,6,0,2,4,2,6,4,1,5,3,3,5,7]),l=o.length>65535?new Uint32Array(c.length*s):new Uint16Array(c.length*s);const h=c.length;for(let t=0;tn;){const t=this._roots.pop();t.geometry.dispose(),this.remove(t)}for(let t=0;t=this._roots.length){const r=new jM(e,i,n,t);this.add(r),this._roots.push(r)}const o=this._roots[t];o.bvh=e,o.depth=n,o.displayParents=s,o.displayEdges=a,o.material=a?i:r,o.update()}}updateMatrixWorld(...t){const e=this.mesh,n=this.parent;null!==e&&(e.updateWorldMatrix(!0,!1),n?this.matrix.copy(n.matrixWorld).invert().multiply(e.matrixWorld):this.matrix.copy(e.matrixWorld),(e.isInstancedMesh||e.isBatchedMesh)&&(e.getMatrixAt(this.objectIndex,WM),this.matrix.multiply(WM)),this.matrix.decompose(this.position,this.quaternion,this.scale)),super.updateMatrixWorld(...t)}copy(t){this.depth=t.depth,this.mesh=t.mesh,this.bvh=t.bvh,this.opacity=t.opacity,this.color.copy(t.color)}clone(){return new qM(this.mesh,this.bvh,this.depth)}dispose(){this.edgeMaterial.dispose(),this.meshMaterial.dispose();const t=this.children;for(let e=0,n=t.length;efunction(t,e){const n={nodeCount:0,leafNodeCount:0,depth:{min:1/0,max:-1/0},tris:{min:1/0,max:-1/0},splits:[0,0,0],surfaceAreaScore:0};return t.traverse(((t,e,i,r,s)=>{const a=i[3]-i[0],o=i[4]-i[1],l=i[5]-i[2],c=2*(a*o+o*l+l*a);n.nodeCount++,e?(n.leafNodeCount++,n.depth.min=Math.min(t,n.depth.min),n.depth.max=Math.max(t,n.depth.max),n.tris.min=Math.min(s,n.tris.min),n.tris.max=Math.max(s,n.tris.max),n.surfaceAreaScore+=c*Kw*s):(n.splits[r]++,n.surfaceAreaScore+=c*Zw)}),e),n.tris.min===1/0&&(n.tris.min=0,n.tris.max=0),n.depth.min===1/0&&(n.depth.min=0,n.depth.max=0),n}(t,n)))}function $M(t){const e=new Set,n=[t];let i=0;for(;n.length;){const t=n.pop();if(!e.has(t)){e.add(t);for(let e in t){if(!Object.hasOwn(t,e))continue;i+=KM(e);const r=t[e];!r||"object"!=typeof r&&"function"!=typeof r?i+=KM(r):/(Uint|Int|Float)(8|16|32)Array/.test(r.constructor.name)||fM()&&r instanceof SharedArrayBuffer||r instanceof ArrayBuffer?i+=r.byteLength:n.push(r)}}}return i}function tS(t){const e=t.geometry,n=[],i=e.index,r=e.getAttribute("position");let s=!0;return t.traverse(((e,a,o,l,c)=>{const h={depth:e,isLeaf:a,boundingData:o,offset:l,count:c};n[e]=h,cC(0,o,XM);const u=n[e-1];if(a)for(let e=l,n=l+c;e{const a={bounds:cC(0,i,new Vi)};n?(a.count=s,a.offset=r):(a.left=null,a.right=null),e[t]=a;const o=e[t-1];o&&(null===o.left?o.left=a:o.right=a)})),e[0]}function nS(t){switch(t){case 1:return se;case 2:return oe;case 3:case 4:return ce}}class iS extends $a{constructor(){super(),this.minFilter=Tt,this.magFilter=Tt,this.generateMipmaps=!1,this.overrideItemSize=null,this._forcedType=null}updateFrom(t){const e=this.overrideItemSize,n=t.itemSize,i=t.count;if(null!==e){if(n*i%e!=0)throw new Error("VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.");t.itemSize=e,t.count=i*n/e}const r=t.itemSize,s=t.count,a=t.normalized,o=t.array.constructor,l=o.BYTES_PER_ELEMENT;let c,h,u,d,p=this._forcedType,f=r;if(null===p)switch(o){case Float32Array:p=Wt;break;case Uint8Array:case Uint16Array:case Uint32Array:p=Vt;break;case Int8Array:case Int16Array:case Int32Array:p=Ht}let m=function(t){switch(t){case 1:return"R";case 2:return"RG";case 3:case 4:return"RGBA"}throw new Error}(r);switch(p){case Wt:u=1,h=function(t){switch(t){case 1:return re;case 2:return ae;case 3:case 4:return $t}}(r),a&&1===l?(d=o,m+="8",o===Uint8Array?c=kt:(c=Qt,m+="_SNORM")):(d=Float32Array,m+="32F",c=Wt);break;case Ht:m+=8*l+"I",u=a?Math.pow(2,8*o.BYTES_PER_ELEMENT-1):1,h=nS(r),1===l?(d=Int8Array,c=Qt):2===l?(d=Int16Array,c=zt):(d=Int32Array,c=Ht);break;case Vt:m+=8*l+"UI",u=a?Math.pow(2,8*o.BYTES_PER_ELEMENT-1):1,h=nS(r),1===l?(d=Uint8Array,c=kt):2===l?(d=Uint16Array,c=Gt):(d=Uint32Array,c=Vt)}3!==f||h!==$t&&h!==ce||(f=4);const g=Math.ceil(Math.sqrt(s))||1,A=new d(f*g*g),v=t.normalized;t.normalized=!1;for(let e=0;e=2&&(A[n+1]=t.getY(e)/u),r>=3&&(A[n+2]=t.getZ(e)/u,4===f&&(A[n+3]=1)),r>=4&&(A[n+3]=t.getW(e)/u)}t.normalized=v,this.internalFormat=m,this.format=h,this.type=c,this.image.width=g,this.image.height=g,this.image.data=A,this.needsUpdate=!0,this.dispose(),t.itemSize=n,t.count=i}}class rS extends iS{constructor(){super(),this._forcedType=Vt}}class sS extends iS{constructor(){super(),this._forcedType=Ht}}class aS extends iS{constructor(){super(),this._forcedType=Wt}}class oS{constructor(){this.index=new rS,this.position=new aS,this.bvhBounds=new $a,this.bvhContents=new $a,this._cachedIndexAttr=null,this.index.overrideItemSize=3}updateFrom(t){const{geometry:e}=t;if(function(t,e,n){const i=t._roots;if(1!==i.length)throw new Error("MeshBVHUniformStruct: Multi-root BVHs not supported.");const r=i[0],s=new Uint16Array(r),a=new Uint32Array(r),o=new Float32Array(r),l=r.byteLength/$w,c=2*Math.ceil(Math.sqrt(l/2)),h=new Float32Array(4*c*c),u=Math.ceil(Math.sqrt(l)),d=new Uint32Array(2*u*u);for(let t=0;t=2&&e.setY(s,t.getY(r)),i>=3&&e.setZ(s,t.getZ(r)),i>=4&&e.setW(s,t.getW(r))}}else{const i=e.array,r=i.constructor,s=i.BYTES_PER_ELEMENT*t.itemSize*n;new r(i.buffer,s,t.array.length).set(t.array)}}function xS(t,e,n){const i=t.elements,r=e.elements;for(let t=0,e=r.length;t{t.traverseVisible((t=>{t.isMesh&&e.push(t)}))})),this.meshes=e,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(e.length).fill().map((()=>new ks)),this._diffMap=new WeakMap}getMaterials(){const t=[];return this.meshes.forEach((e=>{Array.isArray(e.material)?t.push(...e.material):t.push(e.material)})),t}generate(t=new ks){let e=[];const{meshes:n,useGroups:i,_intermediateGeometry:r,_diffMap:s}=this;for(let t=0,i=n.length;t{const i=t(e),r=t(n);return ir?1:0}):this._unloadPriorityCallback=t}constructor(){this.minSize=6e3,this.maxSize=8e3,this.minBytesSize=322122547.2,this.maxBytesSize=429496729.6,this.unloadPercent=.05,this.autoMarkUnused=!0,this.itemSet=new Map,this.itemList=[],this.usedSet=new Set,this.callbacks=new Map,this.unloadingHandle=-1,this.cachedBytes=0,this.bytesMap=new Map,this.loadedSet=new Set,this._unloadPriorityCallback=null,this.computeMemoryUsageCallback=()=>null;const t=this.itemSet;this.defaultPriorityCallback=e=>t.get(e)}isFull(){return this.itemSet.size>=this.maxSize||this.cachedBytes>=this.maxBytesSize}getMemoryUsage(t){return this.bytesMap.get(t)??null}add(t,e){const n=this.itemSet;if(n.has(t))return!1;if(this.isFull())return!1;const i=this.usedSet,r=this.itemList,s=this.callbacks,a=this.bytesMap;r.push(t),i.add(t),n.set(t,Date.now()),s.set(t,e);const o=this.computeMemoryUsageCallback(t);return this.cachedBytes+=o||0,a.set(t,o),!0}has(t){return this.itemSet.has(t)}remove(t){const e=this.usedSet,n=this.itemSet,i=this.itemList,r=this.bytesMap,s=this.callbacks,a=this.loadedSet;if(n.has(t)){this.cachedBytes-=r.get(t)||0,r.delete(t),s.get(t)(t);const o=i.indexOf(t);return i.splice(o,1),e.delete(t),n.delete(t),s.delete(t),a.delete(t),!0}return!1}setLoaded(t,e){const{itemSet:n,loadedSet:i}=this;n.has(t)&&(!0===e?i.add(t):i.delete(t))}updateMemoryUsage(t){const e=this.itemSet,n=this.bytesMap;if(!e.has(t))return;this.cachedBytes-=n.get(t)||0;const i=this.computeMemoryUsageCallback(t);n.set(t,i),this.cachedBytes+=i}markUsed(t){const e=this.itemSet,n=this.usedSet;e.has(t)&&!n.has(t)&&(e.set(t,Date.now()),n.add(t))}markUnused(t){this.usedSet.delete(t)}markAllUnused(){this.usedSet.clear()}unloadUnusedContent(){const{unloadPercent:t,minSize:e,maxSize:n,itemList:i,itemSet:r,usedSet:s,loadedSet:a,callbacks:o,bytesMap:l,minBytesSize:c,maxBytesSize:h}=this,u=i.length-s.size,d=i.length-a.size,p=Math.max(Math.min(i.length-e,u),0),f=this.cachedBytes-c,m=this.unloadPriorityCallback||this.defaultPriorityCallback;let g=!1;const A=p>0&&u>0||d&&i.length>n;if(u&&this.cachedBytes>c||d&&this.cachedBytes>h||A){i.sort(((t,e)=>{const n=s.has(t);if(n===s.has(e)){const n=a.has(t);return n===a.has(e)?-m(t,e):n?1:-1}return n?1:-1}));const d=Math.max(e*t,p*t),A=Math.ceil(Math.min(d,u,p)),v=Math.max(t*f,t*c),y=Math.min(v,f);let _=0,x=0;for(;this.cachedBytes-x>h||i.length-_>n;){const t=i[_],e=l.get(t)||0;if(s.has(t)&&a.has(t)||this.cachedBytes-x-e=A)break;x+=e,_++}i.splice(0,_).forEach((t=>{this.cachedBytes-=l.get(t)||0,o.get(t)(t),l.delete(t),r.delete(t),o.delete(t),a.delete(t),s.delete(t)})),g=_0}g&&(this.unloadingHandle=requestAnimationFrame((()=>this.scheduleUnload())))}scheduleUnload(){cancelAnimationFrame(this.unloadingHandle),this.scheduled||(this.scheduled=!0,queueMicrotask((()=>{this.scheduled=!1,this.unloadUnusedContent()})))}}class US{constructor(){this.maxJobs=6,this.items=[],this.callbacks=new Map,this.currJobs=0,this.scheduled=!1,this.autoUpdate=!0,this.priorityCallback=()=>{throw new Error("PriorityQueue: PriorityCallback function not defined.")},this.schedulingCallback=t=>{requestAnimationFrame(t)},this._runjobs=()=>{this.tryRunJobs(),this.scheduled=!1}}sort(){const t=this.priorityCallback;this.items.sort(t)}add(t,e){return new Promise(((n,i)=>{const r=this.items,s=this.callbacks;r.push(t),s.set(t,((...t)=>e(...t).then(n).catch(i))),this.autoUpdate&&this.scheduleJobRun()}))}remove(t){const e=this.items,n=this.callbacks,i=e.indexOf(t);-1!==i&&(e.splice(i,1),n.delete(t))}tryRunJobs(){this.sort();const t=this.items,e=this.callbacks,n=this.maxJobs;let i=this.currJobs;for(;n>i&&t.length>0;){i++;const n=t.pop(),r=e.get(n);e.delete(n),r(n).then((()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()})).catch((()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()}))}this.currJobs=i}scheduleJobRun(){this.scheduled||(this.schedulingCallback(this._runjobs),this.scheduled=!0)}}const NS=-1,FS=0,OS=1,kS=2,QS=3,zS=6378137,GS=1/298.257223563,HS=-(GS*zS-zS);function VS(t){return t===QS||t===NS}function WS(t,e){return t.__lastFrameVisited===e&&t.__used}function jS(t,e){t.__lastFrameVisited!==e.frameCount&&(t.__lastFrameVisited=e.frameCount,t.__used=!1,t.__inFrustum=!1,t.__isLeaf=!1,t.__visible=!1,t.__active=!1,t.__error=1/0,t.__distanceFromCamera=1/0,t.__childrenWereVisible=!1,t.__allChildrenLoaded=!1,t.__inFrustum=e.tileInView(t),e.calculateError(t))}function qS(t,e){if(e.ensureChildrenArePreprocessed(t),jS(t,e),YS(t,e),!t.__hasRenderableContent){const n=t.children;for(let t=0,i=n.length;t0&&t.__depth+1>=e.maxDepth)}(t,e))return void YS(t,e);let n=!1,i=!1;const r=t.children;for(let t=0,s=r.length;te.setTileVisible&&e.setTileVisible(t,r)))),t.__wasSetActive=i,t.__wasSetVisible=r,t.__usedLastFrame=n;const s=t.children;for(let t=0,n=s.length;tt.__depthFromRenderedParent!==e.__depthFromRenderedParent?t.__depthFromRenderedParent>e.__depthFromRenderedParent?-1:1:t.__inFrustum!==e.__inFrustum?t.__inFrustum?1:-1:t.__used!==e.__used?t.__used?1:-1:t.__error!==e.__error?t.__error>e.__error?1:-1:t.__distanceFromCamera!==e.__distanceFromCamera?t.__distanceFromCamera>e.__distanceFromCamera?-1:1:0,nb=(t,e)=>t.__depthFromRenderedParent!==e.__depthFromRenderedParent?t.__depthFromRenderedParent>e.__depthFromRenderedParent?1:-1:t.__loadingState!==e.__loadingState?t.__loadingState>e.__loadingState?-1:1:t.__lastFrameVisited!==e.__lastFrameVisited?t.__lastFrameVisited>e.__lastFrameVisited?-1:1:t.__hasUnrenderableContent!==e.__hasUnrenderableContent?t.__hasUnrenderableContent?-1:1:t.__error!==e.__error?t.__error>e.__error?-1:1:0;class ib{get root(){const t=this.rootTileSet;return t?t.root:null}get loadProgress(){const t=this.stats,e=t.downloading+t.parsing,n=t.inCacheSinceLoad;return 0===n?1:1-e/n}constructor(t=null){this.rootLoadingState=FS,this.rootTileSet=null,this.rootURL=t,this.fetchOptions={},this.plugins=[],this.queuedTiles=[],this.cachedSinceLoadComplete=new Set;const e=new LS;e.unloadPriorityCallback=nb;const n=new US;n.maxJobs=10,n.priorityCallback=eb;const i=new US;i.maxJobs=1,i.priorityCallback=eb,this.visibleTiles=new Set,this.activeTiles=new Set,this.usedSet=new Set,this.lruCache=e,this.downloadQueue=n,this.parseQueue=i,this.stats={inCacheSinceLoad:0,inCache:0,parsing:0,downloading:0,failed:0,inFrustum:0,used:0,active:0,visible:0},this.frameCount=0,this.errorTarget=6,this.errorThreshold=1/0,this.displayActiveTiles=!1,this.maxDepth=1/0}registerPlugin(t){if(!0===t[tb])throw new Error("TilesRendererBase: A plugin can only be registered to a single tile set");const e=this.plugins,n=t.priority||0;let i=0;for(let t=0;tn));t++);e.splice(i,0,t),t[tb]=!0,t.init&&t.init(this)}unregisterPlugin(t){const e=this.plugins;if("string"==typeof t&&(t=this.getPluginByName(name)),e.includes(t)){const n=e.indexOf(t);return e.splice(n,1),t.dispose&&t.dispose(),!0}return!1}getPluginByName(t){return this.plugins.find((e=>e.name===t))||null}traverse(t,e){this.root&&function(t,e=null,n=null){const i=[];for(i.push(t),i.push(null),i.push(0);i.length>0;){const t=i.pop(),r=i.pop(),s=i.pop();if(e&&e(s,r,t))return void(n&&n(s,r,t));const a=s.children;if(a)for(let e=a.length-1;e>=0;e--)i.push(a[e]),i.push(s),i.push(t+1);n&&n(s,r,t)}}(this.root,((e,...n)=>(this.ensureChildrenArePreprocessed(e),!!t&&t(e,...n))),e)}queueTileForDownload(t){t.__loadingState===FS&&this.queuedTiles.push(t)}markTileUsed(t){this.usedSet.add(t),this.lruCache.markUsed(t)}update(){const{lruCache:t,usedSet:e,stats:n,root:i}=this;if(this.rootLoadingState===FS&&(this.rootLoadingState=OS,this.invokeOnePlugin((t=>t.loadRootTileSet&&t.loadRootTileSet())).then((()=>this.rootLoadingState=QS)).catch((t=>{this.rootLoadingState=NS,console.error(t)}))),!i)return;n.inFrustum=0,n.used=0,n.active=0,n.visible=0,this.frameCount++,e.forEach((e=>t.markUnused(e))),e.clear(),JS(i,this),KS(i,this),ZS(i,this),$S(i,this);const r=this.queuedTiles;r.sort(t.unloadPriorityCallback);for(let e=0,n=r.length;e{t.__loadingState===NS&&(t.__loadingState=FS)})),t.failed=0)}dispose(){this.invokeAllPlugins((t=>{t!==this&&t.dispose&&t.dispose()}));const t=this.lruCache,e=[];this.traverse((t=>(e.push(t),!1)));for(let n=0,i=e.length;ne.setTileVisible&&e.setTileVisible(t,!1))),t.__visible=!1),t.__active&&(this.setTileActive(t,!1),t.__active=!1)}preprocessNode(t,e,n=null){if(t.content&&(!("uri"in t.content)&&"url"in t.content&&(t.content.uri=t.content.url,delete t.content.url),t.content.boundingVolume&&!("box"in t.content.boundingVolume||"sphere"in t.content.boundingVolume||"region"in t.content.boundingVolume)&&delete t.content.boundingVolume),t.parent=n,t.children=t.children||[],t.content?.uri){const e=PS(t.content.uri);t.__hasContent=!0,t.__hasUnrenderableContent=Boolean(e&&/json$/.test(e)),t.__hasRenderableContent=!t.__hasUnrenderableContent}else t.__hasContent=!1,t.__hasUnrenderableContent=!1,t.__hasRenderableContent=!1;t.__distanceFromCamera=1/0,t.__error=1/0,t.__inFrustum=!1,t.__isLeaf=!1,t.__usedLastFrame=!1,t.__used=!1,t.__wasSetVisible=!1,t.__visible=!1,t.__childrenWereVisible=!1,t.__allChildrenLoaded=!1,t.__wasSetActive=!1,t.__active=!1,t.__loadingState=FS,null===n?(t.__depth=0,t.__depthFromRenderedParent=t.__hasRenderableContent?1:0,t.refine=t.refine||"REPLACE"):(t.__depth=n.__depth+1,t.__depthFromRenderedParent=n.__depthFromRenderedParent+(t.__hasRenderableContent?1:0),t.refine=t.refine||n.refine),t.__basePath=e,t.__lastFrameVisited=-1,this.invokeAllPlugins((i=>{i!==this&&i.preprocessNode&&i.preprocessNode(t,e,n)}))}setTileActive(t,e){e?this.activeTiles.add(t):this.activeTiles.delete(t)}setTileVisible(t,e){e?this.visibleTiles.add(t):this.visibleTiles.delete(t)}calculateError(t){return 0}tileInView(t){return!0}ensureChildrenArePreprocessed(t){const e=t.children;for(let n=0,i=e.length;nparseInt(t)));console.assert(r<=1,"TilesRenderer: asset.version is expected to be a 1.x or a compatible version."),1===r&&s>0&&console.warn("TilesRenderer: tiles versions at 1.1 or higher have limited support. Some new extensions and features may not be supported.");let a=e.replace(/\/[^/]*\/?$/,"");a=new URL(a,window.location.href).toString(),this.preprocessNode(t.root,a,n)}loadRootTileSet(){let t=this.rootURL;this.invokeAllPlugins((e=>t=e.preprocessURL?e.preprocessURL(t,null):t));const e=this.invokeOnePlugin((e=>e.fetchData&&e.fetchData(t,this.fetchOptions))).then((e=>{if(e.ok)return e.json();throw new Error(`TilesRenderer: Failed to load tileset "${t}" with status ${e.status} : ${e.statusText}`)})).then((e=>{this.preprocessTileSet(e,t),this.rootTileSet=e}));return e.catch((e=>{console.error(e),this.rootTileSet=null,this.dispatchEvent({type:"load-error",tile:null,error:e,uri:t})})),e}requestTileContents(t){if(t.__loadingState!==FS)return;let e=!1,n=new URL(t.content.uri,t.__basePath+"/").toString();this.invokeAllPlugins((e=>n=e.preprocessURL?e.preprocessURL(n,t):n));const i=this.stats,r=this.lruCache,s=this.downloadQueue,a=this.parseQueue,o=PS(n),l=new AbortController,c=l.signal;return r.add(t,(n=>{l.abort(),e?n.children.length=0:this.invokeAllPlugins((t=>{t.disposeTile&&t.disposeTile(n)})),i.inCache--,this.cachedSinceLoadComplete.has(t)&&(this.cachedSinceLoadComplete.delete(t),i.inCacheSinceLoad--),n.__loadingState===OS?i.downloading--:n.__loadingState===kS&&i.parsing--,n.__loadingState=FS,a.remove(n),s.remove(n)}))?(0===i.parsing&&0===i.downloading&&this.dispatchEvent({type:"tiles-load-start"}),this.cachedSinceLoadComplete.add(t),i.inCacheSinceLoad++,i.inCache++,i.downloading++,t.__loadingState=OS,s.add(t,(t=>c.aborted?Promise.resolve():this.invokeOnePlugin((t=>t.fetchData&&t.fetchData(n,{...this.fetchOptions,signal:c}))))).then((t=>{if(!c.aborted){if(t.ok)return"json"===o?t.json():t.arrayBuffer();throw new Error(`Failed to load model with error code ${t.status}`)}})).then((r=>{if(!c.aborted)return i.downloading--,i.parsing++,t.__loadingState=kS,a.add(t,(i=>c.aborted?Promise.resolve():"json"===o&&r.root?(this.preprocessTileSet(r,n,t),t.children.push(r.root),e=!0,Promise.resolve()):this.invokeOnePlugin((t=>t.parseTile&&t.parseTile(r,i,o,n,c)))))})).then((()=>{c.aborted||(i.parsing--,t.__loadingState=QS,r.setLoaded(t,!0),null===r.getMemoryUsage(t)&&(r.isFull()&&r.computeMemoryUsageCallback(t)>0?r.remove(t):r.updateMemoryUsage(t)),t.cached.scene&&this.dispatchEvent({type:"load-model",scene:t.cached.scene,tile:t}))})).catch((e=>{c.aborted||("AbortError"!==e.name?(a.remove(t),s.remove(t),t.__loadingState===kS?i.parsing--:t.__loadingState===OS&&i.downloading--,i.failed++,console.error(`TilesRenderer : Failed to load tile at url "${t.content.uri}".`),console.error(e),t.__loadingState=NS,r.setLoaded(t,!0),this.dispatchEvent({type:"load-error",tile:t,error:e,uri:n})):r.remove(t))})).finally((()=>{0===i.parsing&&0===i.downloading&&(this.cachedSinceLoadComplete.clear(),i.inCacheSinceLoad=0,this.dispatchEvent({type:"tiles-load-end"}))}))):void 0}getAttributions(t=[]){return this.invokeAllPlugins((e=>e!==this&&e.getAttributions&&e.getAttributions(t))),t}invokeOnePlugin(t){const e=[...this.plugins,this];for(let n=0;na+o)throw new Error("FeatureTable: Feature data read outside binary body length.");return d}}return s}getBuffer(t,e){const{buffer:n,binOffset:i}=this;return n.slice(i+t,i+t+e)}}class lb{constructor(t){this.batchTable=t;const e=t.header.extensions["3DTILES_batch_table_hierarchy"];this.classes=e.classes;for(const t of this.classes){const e=t.instances;for(const n in e)t.instances[n]=this._parseProperty(e[n],t.length,n)}if(this.instancesLength=e.instancesLength,this.classIds=this._parseProperty(e.classIds,this.instancesLength,"classIds"),e.parentCounts?this.parentCounts=this._parseProperty(e.parentCounts,this.instancesLength,"parentCounts"):this.parentCounts=new Array(this.instancesLength).fill(1),e.parentIds){const t=this.parentCounts.reduce(((t,e)=>t+e),0);this.parentIds=this._parseProperty(e.parentIds,t,"parentIds")}else this.parentIds=null;this.instancesIds=[];const n={};for(const t of this.classIds)n[t]=n[t]??0,this.instancesIds.push(n[t]),n[t]++}_parseProperty(t,e,n){if(Array.isArray(t))return t;{const{buffer:i,binOffset:r}=this.batchTable;return ab(i,r+t.byteOffset,e,"SCALAR",t.componentType||"UNSIGNED_SHORT",n)}}getDataFromId(t,e={}){const n=this.parentCounts[t];if(this.parentIds&&n>0){let i=0;for(let e=0;e=this.count)throw new Error(`BatchTable: id value "${t}" out of bounds for "${this.count}" features number.`);for(const n of this.getKeys())"extensions"!==n&&(e[n]=super.getData(n,this.count)[t]);for(const n in this.extensions){const i=this.extensions[n];i.getDataFromId instanceof Function&&(e[n]=e[n]||{},i.getDataFromId(t,e[n]))}return e}getPropertyArray(t){return super.getData(t,this.count)}}class hb{constructor(){this.fetchOptions={},this.workingPath=""}load(t){return console.warn('Loader: "load" function has been deprecated in favor of "loadAsync".'),this.loadAsync(t)}loadAsync(t){return fetch(t,this.fetchOptions).then((e=>{if(!e.ok)throw new Error(`Failed to load file "${t}" with status ${e.status} : ${e.statusText}`);return e.arrayBuffer()})).then((e=>(""===this.workingPath&&(this.workingPath=this.workingPathForURL(t)),this.parse(e))))}resolveExternalURL(t){return/^[^\\/]/.test(t)&&!/^http/.test(t)?this.workingPath+"/"+t:t}workingPathForURL(t){const e=t.split(/[\\/]/g);return e.pop(),e.join("/")+"/"}parse(t){throw new Error("LoaderBase: Parse not implemented.")}}function ub(t){let e;if(e=t instanceof DataView?t:new DataView(t),"{"===String.fromCharCode(e.getUint8(0)))return null;let n="";for(let t=0;t<4;t++)n+=String.fromCharCode(e.getUint8(t));return n}class db extends hb{parse(t){const e=new DataView(t),n=ub(e);console.assert("b3dm"===n);const i=e.getUint32(4,!0);console.assert(1===i);const r=e.getUint32(8,!0);console.assert(r===t.byteLength);const s=e.getUint32(12,!0),a=e.getUint32(16,!0),o=e.getUint32(20,!0),l=e.getUint32(24,!0),c=t.slice(28,28+s+a),h=new ob(c,0,s,a),u=28+s+a,d=t.slice(u,u+o+l),p=new cb(d,h.getData("BATCH_LENGTH"),0,o,l),f=u+o+l;return{version:i,featureTable:h,batchTable:p,glbBytes:new Uint8Array(t,f,r-f)}}}class pb extends db{constructor(t=gh){super(),this.manager=t,this.adjustmentTransform=new Ar}parse(t){const e=super.parse(t),n=e.glbBytes.slice().buffer;return new Promise(((t,i)=>{const r=this.manager,s=this.fetchOptions,a=r.getHandler("path.gltf")||new Ng(r);"include"===s.credentials&&"cors"===s.mode&&a.setCrossOrigin("use-credentials"),"credentials"in s&&a.setWithCredentials("include"===s.credentials),s.headers&&a.setRequestHeader(s.headers);let o=this.workingPath;!/[\\/]$/.test(o)&&o.length&&(o+="/");const l=this.adjustmentTransform;a.parse(n,o,(n=>{const{batchTable:i,featureTable:r}=e,{scene:s}=n,a=r.getData("RTC_CENTER");a&&(s.position.x+=a[0],s.position.y+=a[1],s.position.z+=a[2]),n.scene.updateMatrix(),n.scene.matrix.multiply(l),n.scene.matrix.decompose(n.scene.position,n.scene.quaternion,n.scene.scale),n.batchTable=i,n.featureTable=r,s.batchTable=i,s.featureTable=r,t(n)}),i)}))}}class fb extends hb{parse(t){const e=new DataView(t),n=ub(e);console.assert("pnts"===n);const i=e.getUint32(4,!0);console.assert(1===i);const r=e.getUint32(8,!0);console.assert(r===t.byteLength);const s=e.getUint32(12,!0),a=e.getUint32(16,!0),o=e.getUint32(20,!0),l=e.getUint32(24,!0),c=t.slice(28,28+s+a),h=new ob(c,0,s,a),u=28+s+a,d=t.slice(u,u+o+l),p=new cb(d,h.getData("BATCH_LENGTH")||h.getData("POINTS_LENGTH"),0,o,l);return Promise.resolve({version:i,featureTable:h,batchTable:p})}}function mb(t){const e=t>>11,n=t>>5&63,i=31&t;return[Math.round(e/31*255),Math.round(n/63*255),Math.round(i/31*255)]}const gb=new hi;function Ab(t,e,n=new zi){gb.set(t,e).divideScalar(256).multiplyScalar(2).subScalar(1),n.set(gb.x,gb.y,1-Math.abs(gb.x)-Math.abs(gb.y));const i=ci.clamp(-n.z,0,1);return n.x>=0?n.setX(n.x-i):n.setX(n.x+i),n.y>=0?n.setY(n.y-i):n.setY(n.y+i),n.normalize(),n}const vb={RGB:"color",POSITION:"position"};class yb extends fb{constructor(t=gh){super(),this.manager=t}parse(t){return super.parse(t).then((async t=>{const{featureTable:e,batchTable:n}=t,i=new Zo,r=e.header.extensions,s=new zi;let a;if(r&&r["3DTILES_draco_point_compression"]){const{byteOffset:t,byteLength:n,properties:s}=r["3DTILES_draco_point_compression"],o=this.manager.getHandler("draco.drc");if(null==o)throw new Error("PNTSLoader: dracoLoader not available.");const l={};for(const t in s)t in vb&&t in s&&(l[vb[t]]=s[t]);const c={attributeIDs:l,attributeTypes:{position:"Float32Array",color:"Uint8Array"},useUniqueIDs:!0},h=e.getBuffer(t,n);a=await o.decodeGeometry(h,c),a.attributes.color&&(i.vertexColors=!0)}else{const t=e.getData("POINTS_LENGTH"),n=e.getData("POSITION",t,"FLOAT","VEC3"),r=e.getData("NORMAL",t,"FLOAT","VEC3"),o=e.getData("NORMAL",t,"UNSIGNED_BYTE","VEC2"),l=e.getData("RGB",t,"UNSIGNED_BYTE","VEC3"),c=e.getData("RGBA",t,"UNSIGNED_BYTE","VEC4"),h=e.getData("RGB565",t,"UNSIGNED_SHORT","SCALAR"),u=e.getData("CONSTANT_RGBA",t,"UNSIGNED_BYTE","VEC4"),d=e.getData("POSITION_QUANTIZED",t,"UNSIGNED_SHORT","VEC3"),p=e.getData("QUANTIZED_VOLUME_SCALE",t,"FLOAT","VEC3"),f=e.getData("QUANTIZED_VOLUME_OFFSET",t,"FLOAT","VEC3");if(a=new ks,d){const e=new Float32Array(3*t);for(let n=0;n{if(!e.ok)throw new Error(`I3DMLoaderBase : Failed to load file "${t}" with status ${e.status} : ${e.statusText}`);return e.arrayBuffer()})).then((t=>{A=new Uint8Array(t)}))}return v.then((()=>({version:i,featureTable:u,batchTable:f,glbBytes:A,gltfWorkingPath:y})))}}const xb=new qu,wb=new zi,Cb={};function Eb(t){const{x:e,y:n,z:i}=t;t.x=i,t.y=e,t.z=n}function Mb(t){const{x:e,y:n,z:i}=t;t.z=e,t.x=n,t.y=i}function Sb(t){return-(t-Math.PI/2)}function bb(t){return-t+Math.PI/2}function Ib(t,e="E",n="W"){const i=t<0?n:e,r=~~(t=Math.abs(t)),s=60*(t-r),a=~~s;return`${r}° ${a}' ${~~(60*(s-a))}" ${i}`}function Tb(t,e,n=!1){const i=function(t,e,n={}){return xb.theta=e,xb.phi=bb(t),wb.setFromSpherical(xb),xb.setFromVector3(wb),n.lat=Sb(xb.phi),n.lon=xb.theta,n}(t,e,Cb);let r,s;return n?(r=`${(ci.RAD2DEG*i.lat).toFixed(4)}°`,s=`${(ci.RAD2DEG*i.lon).toFixed(4)}°`):(r=Ib(ci.RAD2DEG*i.lat,"N","S"),s=Ib(ci.RAD2DEG*i.lon,"E","W")),`${r} ${s}`}const Bb=new qu,Rb=new zi,Db=new zi,Pb=new zi,Lb=new Ar,Ub=new Ar,Nb=new lr,Fb=new br,Ob=new zi,kb=new zi,Qb=new zi,zb=new zi,Gb=new gr,Hb=0,Vb=1,Wb=2;class jb{constructor(t=1,e=1,n=1){this.name="",this.radius=new zi(t,e,n)}intersectRay(t,e){return Lb.makeScale(...this.radius).invert(),Nb.center.set(0,0,0),Nb.radius=1,Gb.copy(t).applyMatrix4(Lb),Gb.intersectSphere(Nb,e)?(Lb.makeScale(...this.radius),e.applyMatrix4(Lb),e):null}getEastNorthUpFrame(t,e,n){return this.getEastNorthUpAxes(t,e,Ob,kb,Qb,zb),n.makeBasis(Ob,kb,Qb).setPosition(zb)}getEastNorthUpAxes(t,e,n,i,r,s=zb){this.getCartographicToPosition(t,e,0,s),this.getCartographicToNormal(t,e,r),n.set(-s.y,s.x,0).normalize(),i.crossVectors(r,n).normalize()}getAzElRollFromRotationMatrix(t,e,n,i,r=Hb){return r===Vb?(Fb.set(-Math.PI/2,0,0,"XYZ"),Ub.makeRotationFromEuler(Fb).premultiply(n)):r===Wb?(Fb.set(-Math.PI/2,0,Math.PI,"XYZ"),Ub.makeRotationFromEuler(Fb).premultiply(n)):Ub.copy(n),this.getEastNorthUpFrame(t,e,Lb).invert(),Ub.premultiply(Lb),Fb.setFromRotationMatrix(Ub,"ZXY"),i.azimuth=-Fb.z,i.elevation=Fb.x,i.roll=Fb.y,i}getRotationMatrixFromAzElRoll(t,e,n,i,r,s,a=Hb){return this.getEastNorthUpFrame(t,e,Lb),Fb.set(i,r,-n,"ZXY"),s.makeRotationFromEuler(Fb).premultiply(Lb).setPosition(0,0,0),a===Vb?(Fb.set(Math.PI/2,0,0,"XYZ"),Ub.makeRotationFromEuler(Fb),s.multiply(Ub)):a===Wb&&(Fb.set(-Math.PI/2,0,Math.PI,"XYZ"),Ub.makeRotationFromEuler(Fb),s.multiply(Ub)),s}getFrame(t,e,n,i,r,s,a,o=Hb){return this.getRotationMatrixFromAzElRoll(t,e,n,i,r,a,o),this.getCartographicToPosition(t,e,s,zb),a.setPosition(zb),a}getCartographicToPosition(t,e,n,i){this.getCartographicToNormal(t,e,Rb);const r=this.radius;Db.copy(Rb),Db.x*=r.x**2,Db.y*=r.y**2,Db.z*=r.z**2;const s=Math.sqrt(Rb.dot(Db));return Db.divideScalar(s),i.copy(Db).addScaledVector(Rb,n)}getPositionToCartographic(t,e){this.getPositionToSurfacePoint(t,Db),this.getPositionToNormal(t,Rb);const n=Pb.subVectors(t,Db);return e.lon=Math.atan2(Rb.y,Rb.x),e.lat=Math.asin(Rb.z),e.height=Math.sign(n.dot(t))*n.length(),e}getCartographicToNormal(t,e,n){return Bb.set(1,bb(t),e),n.setFromSpherical(Bb).normalize(),Eb(n),n}getPositionToNormal(t,e){const n=this.radius;return e.copy(t),e.x/=n.x**2,e.y/=n.y**2,e.z/=n.z**2,e.normalize(),e}getPositionToSurfacePoint(t,e){const n=this.radius,i=1/n.x**2,r=1/n.y**2,s=1/n.z**2,a=t.x*t.x*i,o=t.y*t.y*r,l=t.z*t.z*s,c=a+o+l,h=Math.sqrt(1/c),u=Db.copy(t).multiplyScalar(h);if(c<.1)return isFinite(h)?e.copy(u):null;const d=Pb.set(u.x*i*2,u.y*r*2,u.z*s*2);let p,f,m,g,A,v,y,_,x,w,C,E=(1-h)*t.length()/(.5*d.length()),M=0;do{E-=M,m=1/(1+E*i),g=1/(1+E*r),A=1/(1+E*s),v=m*m,y=g*g,_=A*A,x=v*m,w=y*g,C=_*A,p=a*v+o*y+l*_-1,f=a*x*i+o*w*r+l*C*s,M=p/(-2*f)}while(Math.abs(p)>1e-12);return e.set(t.x*m,t.y*g,t.z*A)}calculateHorizonDistance(t,e){const n=this.calculateEffectiveRadius(t);return Math.sqrt(2*n*e+e**2)}calculateEffectiveRadius(t){const e=this.radius.x,n=1-this.radius.z**2/e**2,i=t*ci.DEG2RAD,r=Math.sin(i)**2;return e/Math.sqrt(1-n*r)}getPositionElevation(t){this.getPositionToSurfacePoint(t,Db);const e=Pb.subVectors(t,Db);return Math.sign(e.dot(t))*e.length()}copy(t){return this.radius.copy(t.radius),this}clone(){return(new this.constructor).copy(this)}}const qb=new jb(zS,zS,HS);qb.name="WGS84 Earth";const Xb=new zi,Yb=new zi,Jb=new zi,Kb=new zi,Zb=new Qi,$b=new zi,tI=new Ar,eI=new Ar,nI=new zi,iI=new Ar,rI=new Qi,sI={};class aI extends _b{constructor(t=gh){super(),this.manager=t,this.adjustmentTransform=new Ar,this.ellipsoid=qb.clone()}resolveExternalURL(t){return this.manager.resolveURL(super.resolveExternalURL(t))}parse(t){return super.parse(t).then((t=>{const{featureTable:e,batchTable:n}=t,i=t.glbBytes.slice().buffer;return new Promise(((r,s)=>{const a=this.fetchOptions,o=this.manager,l=o.getHandler("path.gltf")||new Ng(o);"include"===a.credentials&&"cors"===a.mode&&l.setCrossOrigin("use-credentials"),"credentials"in a&&l.setWithCredentials("include"===a.credentials),a.headers&&l.setRequestHeader(a.headers);let c=t.gltfWorkingPath??this.workingPath;/[\\/]$/.test(c)||(c+="/");const h=this.adjustmentTransform;l.parse(i,c,(t=>{const i=e.getData("INSTANCES_LENGTH"),s=e.getData("POSITION",i,"FLOAT","VEC3"),a=e.getData("NORMAL_UP",i,"FLOAT","VEC3"),o=e.getData("NORMAL_RIGHT",i,"FLOAT","VEC3"),l=e.getData("SCALE_NON_UNIFORM",i,"FLOAT","VEC3"),c=e.getData("SCALE",i,"FLOAT","SCALAR"),u=e.getData("RTC_CENTER"),d=e.getData("EAST_NORTH_UP");["QUANTIZED_VOLUME_OFFSET","QUANTIZED_VOLUME_SCALE","POSITION_QUANTIZED","NORMAL_UP_OCT32P","NORMAL_RIGHT_OCT32P"].forEach((t=>{t in e.header&&console.warn(`I3DMLoader: Unsupported FeatureTable feature "${t}" detected.`)}));const p=new zi;for(let t=0;t{if(t.isMesh){m.push(t);const{geometry:e,material:n}=t,r=new uo(e,n,i);r.position.copy(p),u&&(r.position.x+=u[0],r.position.y+=u[1],r.position.z+=u[2]),f.push(r)}}));for(let t=0;t{const e=new fa;return t.forEach((t=>{e.add(t.scene)})),{tiles:t,scene:e}}))}}const cI=new Ar;class hI extends fa{constructor(t){super(),this.name="TilesRenderer.TilesGroup",this.tilesRenderer=t}raycast(t,e){return!this.tilesRenderer.optimizeRaycast||(this.tilesRenderer.raycast(t,e),!1)}updateMatrixWorld(t){if(this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldNeedsUpdate||t){null===this.parent?cI.copy(this.matrix):cI.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1;const t=cI.elements,e=this.matrixWorld.elements;let n=!1;for(let i=0;i<16;i++){const r=t[i],s=e[i];if(Math.abs(r-s)>Number.EPSILON){n=!0;break}}if(n){this.matrixWorld.copy(cI);const t=this.children;for(let e=0,n=t.length;en.raycastTile&&n.raycastTile(t,r,e,i)))||e.intersectObject(r,!0,i)}function AI(t,e,n,i=null){const{group:r,activeTiles:s}=t;t.ensureChildrenArePreprocessed(e),null===i&&(i=dI,uI.copy(r.matrixWorld).invert(),i.copy(n.ray).applyMatrix4(uI));const a=[],o=e.children;for(let t=0,e=o.length;tc)break;const h=AI(t,o,n,i);if(h){const t=h.distance*h.distance;tnew zi)),this.planes=new Array(6).fill().map((()=>new go))}clampPoint(t,e){return e.copy(t).applyMatrix4(this.inverseTransform).clamp(this.box.min,this.box.max).applyMatrix4(this.transform)}distanceToPoint(t){return this.clampPoint(t,xI).distanceTo(t)}containsPoint(t){return xI.copy(t).applyMatrix4(this.inverseTransform),this.box.containsPoint(xI)}intersectsRay(t){return wI.copy(t).applyMatrix4(this.inverseTransform),wI.intersectsBox(this.box)}intersectRay(t,e){return wI.copy(t).applyMatrix4(this.inverseTransform),wI.intersectBox(this.box,e)?(e.applyMatrix4(this.transform),e):null}update(){const{points:t,inverseTransform:e,transform:n,box:i}=this;e.copy(n).invert();const{min:r,max:s}=i;let a=0;for(let e=-1;e<=1;e+=2)for(let i=-1;i<=1;i+=2)for(let o=-1;o<=1;o+=2)t[a].set(e<0?r.x:s.x,i<0?r.y:s.y,o<0?r.z:s.z).applyMatrix4(n),a++;this.updatePlanes()}updatePlanes(){yI.copy(this.box.min).applyMatrix4(this.transform),_I.copy(this.box.max).applyMatrix4(this.transform),xI.set(0,0,1).transformDirection(this.transform),this.planes[0].setFromNormalAndCoplanarPoint(xI,yI),this.planes[1].setFromNormalAndCoplanarPoint(xI,_I).negate(),xI.set(0,1,0).transformDirection(this.transform),this.planes[2].setFromNormalAndCoplanarPoint(xI,yI),this.planes[3].setFromNormalAndCoplanarPoint(xI,_I).negate(),xI.set(1,0,0).transformDirection(this.transform),this.planes[4].setFromNormalAndCoplanarPoint(xI,yI),this.planes[5].setFromNormalAndCoplanarPoint(xI,_I).negate()}intersectsFrustum(t){const{points:e}=this,{planes:n}=t;for(let t=0;t<6;t++){const i=n[t];let r=-1/0;for(let t=0;t<8;t++){const n=e[t],s=i.distanceToPoint(n);r=r=e&&a<=n&&o>=i&&o<=r){const e=DI(t);u.push(e),this.getCartographicToPosition(a,o,l,e)}}}return u}getBoundingBox(t,e){PI();const{latStart:n,latEnd:i,lonStart:r,lonEnd:s}=this;if(i-nr?i:r}intersectsFrustum(t){const e=this.obb||this.regionObb,n=this.sphere;return!(n&&!t.intersectsSphere(n))&&!(e&&!e.intersectsFrustum(t))&&Boolean(n||e)}getOBB(t,e){const n=this.obb||this.regionObb;n?(t.copy(n.box),e.copy(n.transform)):(this.getAABB(t),e.identity())}getAABB(t){if(this.sphere)this.sphere.getBoundingBox(t);else{const e=this.obb||this.regionObb;t.copy(e.box).applyMatrix4(e.transform)}}getSphere(t){if(this.sphere)t.copy(this.sphere);else if(this.region)this.region.getBoundingSphere(t);else{const e=this.obb||this.regionObb;e.box.getBoundingSphere(t),t.applyMatrix4(e.transform)}}setObbData(t,e){const n=new CI;UI.set(t[3],t[4],t[5]),NI.set(t[6],t[7],t[8]),FI.set(t[9],t[10],t[11]);const i=UI.length(),r=NI.length(),s=FI.length();UI.normalize(),NI.normalize(),FI.normalize(),0===i&&UI.crossVectors(NI,FI),0===r&&NI.crossVectors(UI,FI),0===s&&FI.crossVectors(UI,NI),n.transform.set(UI.x,NI.x,FI.x,t[0],UI.y,NI.y,FI.y,t[1],UI.z,NI.z,FI.z,t[2],0,0,0,1).premultiply(e),n.box.min.set(-i,-r,-s),n.box.max.set(i,r,s),n.update(),this.obb=n}setSphereData(t,e,n,i,r){const s=new lr;s.center.set(t,e,n),s.radius=i,s.applyMatrix4(r),this.sphere=s}setRegionData(t,e,n,i,r,s,a){const o=new LI(...t.radius,n,r,e,i,s,a),l=new CI;o.getBoundingBox(l.box,l.transform),l.update(),this.region=o,this.regionObb=l}}const zI=new ui;class GI extends yo{constructor(){super(),this.points=Array(8).fill().map((()=>new zi))}setFromProjectionMatrix(t,e){super.setFromProjectionMatrix(t,e),this.calculateFrustumPoints()}calculateFrustumPoints(){const{planes:t,points:e}=this;[[t[0],t[3],t[4]],[t[1],t[3],t[4]],[t[0],t[2],t[4]],[t[1],t[2],t[4]],[t[0],t[3],t[5]],[t[1],t[3],t[5]],[t[0],t[2],t[5]],[t[1],t[2],t[5]]].forEach(((t,n)=>{!function(t,e,n,i){const r=zI.set(t.normal.x,t.normal.y,t.normal.z,e.normal.x,e.normal.y,e.normal.z,n.normal.x,n.normal.y,n.normal.z);i.set(-t.constant,-e.constant,-n.constant),i.applyMatrix3(r.invert())}(t[0],t[1],t[2],e[n])}))}}const HI=new Ar,VI=new br,WI=Symbol("INITIAL_FRUSTUM_CULLED"),jI=new Ar,qI=new Ar,XI=new zi,YI=new hi,JI=new zi(1,0,0),KI=new zi(0,1,0);function ZI(t,e){t.traverse((t=>{t.frustumCulled=t[WI]&&e}))}class $I extends ib{get autoDisableRendererCulling(){return this._autoDisableRendererCulling}set autoDisableRendererCulling(t){this._autoDisableRendererCulling!==t&&(super._autoDisableRendererCulling=t,this.forEachLoadedModel((e=>{ZI(e,!t)})))}constructor(...t){super(...t),this.group=new hI(this),this.ellipsoid=qb.clone(),this.cameras=[],this.cameraMap=new Map,this.cameraInfo=[],this.optimizeRaycast=!0,this._upRotationMatrix=new Ar,this.lruCache.computeMemoryUsageCallback=t=>t.cached.bytesUsed??null,this._autoDisableRendererCulling=!0;const e=new mh;e.setURLModifier((t=>this.preprocessURL?this.preprocessURL(t):t)),this.manager=e,this._listeners={}}addEventListener(...t){Zn.prototype.addEventListener.call(this,...t)}hasEventListener(...t){Zn.prototype.hasEventListener.call(this,...t)}removeEventListener(...t){Zn.prototype.removeEventListener.call(this,...t)}dispatchEvent(...t){Zn.prototype.dispatchEvent.call(this,...t)}getBoundingBox(t){if(!this.root)return!1;const e=this.root.cached.boundingVolume;return!!e&&(e.getAABB(t),!0)}getOrientedBoundingBox(t,e){if(!this.root)return!1;const n=this.root.cached.boundingVolume;return!!n&&(n.getOBB(t,e),!0)}getBoundingSphere(t){if(!this.root)return!1;const e=this.root.cached.boundingVolume;return!!e&&(e.getSphere(t),!0)}forEachLoadedModel(t){this.traverse((e=>{const n=e.cached.scene;n&&t(n,e)}))}raycast(t,e){if(this.root)if(t.firstHitOnly){const n=AI(this,this.root,t);n&&e.push(n)}else vI(this,this.root,t,e)}hasCamera(t){return this.cameraMap.has(t)}setCamera(t){const e=this.cameras,n=this.cameraMap;return!n.has(t)&&(n.set(t,new hi),e.push(t),this.dispatchEvent({type:"add-camera",camera:t}),!0)}setResolution(t,e,n){const i=this.cameraMap;if(!i.has(t))return!1;const r=e.isVector2?e.x:e,s=e.isVector2?e.y:n,a=i.get(t);return a.width===r&&a.height===s||(a.set(r,s),this.dispatchEvent({type:"camera-resolution-change"})),!0}setResolutionFromRenderer(t,e){return e.getSize(YI).multiplyScalar(e.getPixelRatio()),this.setResolution(t,YI.x,YI.y)}deleteCamera(t){const e=this.cameras,n=this.cameraMap;if(n.has(t)){const i=e.indexOf(t);return e.splice(i,1),n.delete(t),this.dispatchEvent({type:"delete-camera",camera:t}),!0}return!1}preprocessTileSet(t,e,n){super.preprocessTileSet(t,e,n),queueMicrotask((()=>{this.dispatchEvent({type:"load-tile-set",tileSet:t,url:e})}))}loadRootTileSet(...t){return super.loadRootTileSet(...t).then((()=>{const{asset:t,extensions:e={}}=this.rootTileSet;switch((t&&t.gltfUpAxis||"y").toLowerCase()){case"x":this._upRotationMatrix.makeRotationAxis(KI,-Math.PI/2);break;case"y":this._upRotationMatrix.makeRotationAxis(JI,Math.PI/2)}if("3DTILES_ellipsoid"in e){const t=e["3DTILES_ellipsoid"],{ellipsoid:n}=this;n.name=t.body,t.radii?n.radius.set(...t.radii):n.radius.set(1,1,1)}this.dispatchEvent({type:"load-content"})}))}update(){let t=null;if(this.invokeAllPlugins((e=>{if(e.doTilesNeedUpdate){const n=e.doTilesNeedUpdate();t=null===t?n:t||n}})),!1===t)return this.dispatchEvent({type:"update-before"}),void this.dispatchEvent({type:"update-after"});this.dispatchEvent({type:"update-before"});const e=this.group,n=this.cameras,i=this.cameraMap,r=this.cameraInfo;if(0!==n.length){for(;r.length>n.length;)r.pop();for(;r.length1e-6&&console.warn("ThreeTilesRenderer : Non uniform scale used for tile which may cause issues when calculating screen space error.");for(let t=0,s=r.length;tt.scene));break}case"gltf":case"glb":{const e=h.getHandler("path.gltf")||h.getHandler("path.glb")||new Ng(h);e.setWithCredentials("include"===c.credentials),e.setRequestHeader(c.headers||{}),"include"===c.credentials&&"cors"===c.mode&&e.setCrossOrigin("use-credentials");let n=e.resourcePath||e.path||l;!/[\\/]$/.test(n)&&n.length&&(n+="/"),u=e.parseAsync(t,n).then((t=>{const{scene:e}=t;return e.updateMatrix(),e.matrix.multiply(p).decompose(e.position,e.quaternion,e.scale),t}));break}default:console.warn(`TilesRenderer: Content type "${f}" not supported.`),u=Promise.resolve(null)}const m=await u;let g,A;m.isObject3D?(g=m,A=null):(g=m.scene,A=m),await this.invokeAllPlugins((t=>t.processTileModel&&t.processTileModel(g,n))),g.updateMatrix(),g.matrix.premultiply(d),g.matrix.decompose(g.position,g.quaternion,g.scale),g.traverse((t=>{t[WI]=t.frustumCulled})),ZI(g,!this.autoDisableRendererCulling);const v=[],y=[],_=[];if(g.traverse((t=>{if(t.geometry&&y.push(t.geometry),t.material){const e=t.material;v.push(t.material);for(const t in e){const n=e[t];n&&n.isTexture&&_.push(n)}}})),s.aborted)for(let t=0,e=_.length;t{if(t.geometry&&!i.has(t.geometry)&&(r+=Lg(t.geometry),i.add(t.geometry)),t.material){const e=t.material;for(const t in e){const s=e[t];if(s&&s.isTexture&&!i.has(s)){const{format:t,type:e,image:a}=s,{width:o,height:l}=a,c=n.getByteLength(o,l,t,e);r+=s.generateMipmaps?4*c/3:c,i.add(s)}}}})),r}(g)}disposeTile(t){super.disposeTile(t);const e=t.cached;if(e.scene){const n=e.materials,i=e.geometry,r=e.textures,s=e.scene.parent;e.scene.traverse((t=>{t.userData.meshFeatures&&t.userData.meshFeatures.dispose(),t.userData.structuralMetadata&&t.userData.structuralMetadata.dispose()}));for(let t=0,e=i.length;t{},this.pivotMesh.scale.setScalar(.25),this.raycaster=new Vu,this.raycaster.firstHitOnly=!0,this.up=new zi(0,1,0),this.clock=new hu,this.fallbackPlane=new go(new zi(0,1,0),0),this.useFallbackPlane=!0,this._detachCallback=null,this._upInitialized=!1,this._lastUsedState=0,this._zoomPointWasSet=!1,this._tilesOnChangeCallback=()=>this.zoomPointSet=!1,n&&this.attach(n),e&&this.setCamera(e),t&&this.setScene(t),i&&this.setTilesRenderer(i)}setScene(t){this.scene=t}setCamera(t){this.camera=t,this._upInitialized=!1,this.zoomDirectionSet=!1,this.zoomPointSet=!1,this.needsUpdate=!0,this.raycaster.camera=t,this.resetState()}setTilesRenderer(t){this.tilesRenderer&&this.tilesRenderer.removeEventListener("tile-visibility-change",this._tilesOnChangeCallback),this.tilesRenderer=t,null!==this.tilesRenderer&&(this.tilesRenderer.addEventListener("tile-visibility-change",this._tilesOnChangeCallback),null===this.scene&&this.setScene(this.tilesRenderer.group))}attach(t){if(this.domElement)throw new Error("EnvironmentControls: Controls already attached to element");this.domElement=t,this.pointerTracker.domElement=t,t.style.touchAction="none";let e=!1;const n=t=>{t.preventDefault()},i=t=>{"Shift"===t.key&&(e=!0)},r=t=>{"Shift"===t.key&&(e=!1)},s=t=>{t.preventDefault();const{camera:n,raycaster:i,domElement:r,up:s,pivotMesh:a,pointerTracker:o}=this;if(o.addPointer(t),this.needsUpdate=!0,o.isPointerTouch())if(a.visible=!1,0===o.getPointerCount())r.setPointerCapture(t.pointerId);else if(o.getPointerCount()>2)return void this.resetState();o.getCenterPoint(bT),cT(bT.x,bT.y,r,bT),uT(i,bT,n);const l=Math.abs(i.ray.direction.dot(s));if(l{t.preventDefault(),this.zoomDirectionSet=!1,this.zoomPointSet=!1,0!==this.state&&(this.needsUpdate=!0);const{pointerTracker:e}=this;e.setHoverEvent(t),e.updatePointer(t)&&(e.isPointerTouch()&&2===e.getPointerCount()&&(a||(a=!0,queueMicrotask((()=>{a=!1,e.getCenterPoint(BT);const t=e.getStartTouchPointerDistance(),n=e.getTouchPointerDistance(),i=n-t;if(0===this.state||4===this.state){e.getCenterPoint(BT),e.getStartCenterPoint(RT);const t=2*window.devicePixelRatio,n=BT.distanceTo(RT);(Math.abs(i)>t||n>t)&&(Math.abs(i)>n?(this.setState(3),this.zoomDirectionSet=!1):this.setState(2))}if(3===this.state){const t=e.getPreviousTouchPointerDistance();this.zoomDelta+=n-t}else 2===this.state&&(this.pivotMesh.visible=this.enabled)})))),this.dispatchEvent(DT))},l=e=>{const{pointerTracker:n}=this;n.deletePointer(e),"touch"===n.getPointerType()&&0===n.getPointerCount()&&t.releasePointerCapture(e.pointerId),this.resetState(),this.needsUpdate=!0},c=t=>{t.preventDefault();const{pointerTracker:e}=this;let n;switch(e.setHoverEvent(t),e.updatePointer(t),this.dispatchEvent(PT),t.deltaMode){case 2:n=100*t.deltaY;break;case 1:n=16*t.deltaY;break;case 0:n=t.deltaY}const i=Math.sign(n),r=Math.log(Math.abs(n)+1);this.zoomDelta-=3*i*r,this.needsUpdate=!0,this._lastUsedState=3,this.dispatchEvent(LT)},h=t=>{const{pointerTracker:n}=this;e=!1,t.buttons!==n.getPointerButtons()&&(n.deletePointer(t),this.resetState())};t.addEventListener("contextmenu",n),t.addEventListener("keydown",i),t.addEventListener("keyup",r),t.addEventListener("pointerdown",s),t.addEventListener("pointermove",o),t.addEventListener("pointerup",l),t.addEventListener("wheel",c,{passive:!1}),t.addEventListener("pointerenter",h),this._detachCallback=()=>{t.removeEventListener("contextmenu",n),t.removeEventListener("keydown",i),t.removeEventListener("keyup",r),t.removeEventListener("pointerdown",s),t.removeEventListener("pointermove",o),t.removeEventListener("pointerup",l),t.removeEventListener("wheel",c),t.removeEventListener("pointerenter",h)}}getUpDirection(t,e){e.copy(this.up)}getCameraUpDirection(t){this.getUpDirection(this.camera.position,t)}getPivotPoint(t){let e=null;3===this._lastUsedState?this._zoomPointWasSet&&(e=t.copy(this.zoomPoint)):2!==this._lastUsedState&&1!==this._lastUsedState||(e=t.copy(this.pivotPoint));const{camera:n,raycaster:i}=this;null!==e&&(gT.copy(e).project(n),(gT.x<-1||gT.x>1||gT.y<-1||gT.y>1)&&(e=null)),uT(i,{x:0,y:0},n);const r=this._raycast(i);return r&&(null===e||r.distance0?1/Math.abs(e):e;i*=c,i>1?ln.zoom*i&&(i=1),n.zoom*=i,n.updateProjectionMatrix(),t&&(cT(bT.x,bT.y,a,ET),ET.unproject(n),n.position.sub(ET).add(CT),n.updateMatrixWorld())}else{this._updateZoomDirection();const s=gT.copy(e);if(this.zoomPointSet||this._updateZoomPoint()){const s=t.distanceTo(n.position);if(h<0){const t=Math.min(0,s-r);h=h*s*c*.0025,h=Math.max(h,t)}else{const t=Math.max(0,s-i);h=h*Math.max(s-i,0)*c*.0025,h=Math.min(h,t)}n.position.addScaledVector(e,h),n.updateMatrixWorld()}else{const t=this._getPointBelowCamera();if(t){const e=t.distance;s.set(0,0,-1).transformDirection(n.matrixWorld),n.position.addScaledVector(s,h*e*.01),n.updateMatrixWorld()}}}}_updateZoomDirection(){if(this.zoomDirectionSet)return;const{domElement:t,raycaster:e,camera:n,zoomDirection:i,pointerTracker:r}=this;r.getLatestPoint(bT),cT(bT.x,bT.y,t,CT),uT(e,CT,n),i.copy(e.ray.direction).normalize(),this.zoomDirectionSet=!0}_updateZoomPoint(){const{camera:t,zoomDirectionSet:e,zoomDirection:n,raycaster:i,zoomPoint:r,pointerTracker:s,domElement:a}=this;if(this._zoomPointWasSet=!1,!e)return!1;t.isOrthographicCamera&&s.getLatestPoint(ST)?(cT(ST.x,ST.y,a,ST),uT(i,ST,t)):(i.ray.origin.copy(t.position),i.ray.direction.copy(n),i.near=0,i.far=1/0);const o=this._raycast(i);return!!o&&(r.copy(o.point),this.zoomPointSet=!0,this._zoomPointWasSet=!0,!0)}_getPointBelowCamera(t=this.camera.position,e=this.up){const{raycaster:n}=this;n.ray.direction.copy(e).multiplyScalar(-1),n.ray.origin.copy(t).addScaledVector(e,1e5),n.near=0,n.far=1/0;const i=this._raycast(n);return i&&(i.distance-=1e5),i}_updatePosition(t){const{raycaster:e,camera:n,pivotPoint:i,up:r,pointerTracker:s,domElement:a,state:o,dragInertia:l,enableDamping:c}=this;if(1===o){if(s.getCenterPoint(bT),cT(bT.x,bT.y,a,bT),xT.setFromNormalAndCoplanarPoint(r,i),uT(e,bT,n),Math.abs(e.ray.direction.dot(r))0?(l=Math.min(c-r-.01,l),l=Math.max(0,l)):(l=Math.max(c-s,l),l=Math.min(0,l)),_T.setFromAxisAngle(wT,o),lT(n,_T,fT),i.matrixWorld.premultiply(fT),yT.set(-1,0,0).transformDirection(i.matrixWorld),_T.setFromAxisAngle(yT,l),lT(n,_T,fT),i.matrixWorld.premultiply(fT),i.matrixWorld.decompose(i.position,i.quaternion,gT)}_setFrame(t,e){const{up:n,camera:i,state:r,zoomPoint:s,zoomDirectionSet:a,zoomPointSet:o,reorientOnDrag:l,scaleZoomOrientationAtEdges:c}=this;i.updateMatrixWorld(),_T.setFromUnitVectors(n,t);const h=r;if(a&&(o||this._updateZoomPoint())){if(this.getUpDirection(s,gT),c){let t=Math.max(gT.dot(n)-.6,0)/.4;t=ci.mapLinear(t,0,.5,0,1),t=Math.min(t,1),i.isOrthographicCamera&&(t*=.1),_T.slerp(MT,1-t)}lT(s,_T,fT),i.matrixWorld.premultiply(fT),i.matrixWorld.decompose(i.position,i.quaternion,gT),this.zoomDirectionSet=!1,this._updateZoomDirection()}else 1===h&&l&&e&&(lT(e,_T,fT),i.matrixWorld.premultiply(fT),i.matrixWorld.decompose(i.position,i.quaternion,gT));n.copy(t),i.updateMatrixWorld()}_raycast(t){const{scene:e,useFallbackPlane:n,fallbackPlane:i}=this,r=t.intersectObject(e)[0]||null;if(r)return r;if(n){const e=i;if(t.ray.intersectPlane(e,gT))return{point:gT.clone(),distance:t.ray.origin.distanceTo(gT)}}return null}}const NT=new Ar,FT=new Ar,OT=new zi,kT=new zi,QT=new zi,zT=new zi,GT=new zi,HT=new zi,VT=new zi,WT=new Qi,jT=new zi,qT=new zi,XT={},YT=new gr,JT=new jb,KT=new hi;class ZT extends UT{get ellipsoid(){return this.tilesRenderer?this.tilesRenderer.ellipsoid:null}get tilesGroup(){return this.tilesRenderer?this.tilesRenderer.group:null}constructor(t=null,e=null,n=null,i=null){super(t,e,n),this.isGlobeControls=!0,this._dragMode=0,this._rotationMode=0,this.maxZoom=.01,this.nearMargin=.25,this.farMargin=0,this.useFallbackPlane=!1,this.reorientOnDrag=!1,this.dragQuaternion=new Qi,this.setTilesRenderer(i)}setScene(t){null===t&&null!==this.tilesRenderer?super.setScene(this.tilesRenderer.group):super.setScene(t)}getPivotPoint(t){const{camera:e,tilesGroup:n,ellipsoid:i}=this;return zT.set(0,0,-1).transformDirection(e.matrixWorld),NT.copy(n.matrixWorld).invert(),YT.origin.copy(e.position),YT.direction.copy(zT),YT.applyMatrix4(NT),hT(YT,i,kT),kT.applyMatrix4(n.matrixWorld),(null===super.getPivotPoint(t)||t.distanceTo(YT.origin)>kT.distanceTo(YT.origin))&&t.copy(kT),t}getVectorToCenter(t){const{tilesGroup:e,camera:n}=this;return t.setFromMatrixPosition(e.matrixWorld).sub(n.position)}getDistanceToCenter(){return this.getVectorToCenter(kT).length()}getUpDirection(t,e){const{tilesGroup:n,ellipsoid:i}=this;NT.copy(n.matrixWorld).invert(),kT.copy(t).applyMatrix4(NT),i.getPositionToNormal(kT,e),e.transformDirection(n.matrixWorld)}getCameraUpDirection(t){const{tilesGroup:e,ellipsoid:n,camera:i}=this;i.isOrthographicCamera?(this._getVirtualOrthoCameraPosition(kT),NT.copy(e.matrixWorld).invert(),kT.applyMatrix4(NT),n.getPositionToNormal(kT,t),t.transformDirection(e.matrixWorld)):this.getUpDirection(i.position,t)}update(t=Math.min(this.clock.getDelta(),.064)){if(!this.enabled||!this.tilesGroup||!this.camera||0===t)return;const{camera:e,pivotMesh:n}=this;this._isNearControls()?this.scaleZoomOrientationAtEdges=this.zoomDelta<0:(0!==this.state&&1!==this._dragMode&&1!==this._rotationMode&&(n.visible=!1),this.scaleZoomOrientationAtEdges=!1),super.update(t),this.adjustCamera(e)}adjustCamera(t){super.adjustCamera(t);const{tilesGroup:e,ellipsoid:n,nearMargin:i,farMargin:r}=this,s=Math.max(...n.radius);if(t.isPerspectiveCamera){const a=kT.setFromMatrixPosition(e.matrixWorld).sub(t.position).length(),o=i*s,l=ci.clamp((a-s)/o,0,1),c=ci.lerp(1,1e3,l);t.near=Math.max(c,a-s-o);const h=NT.copy(e.matrixWorld).invert();OT.copy(t.position).applyMatrix4(h),n.getPositionToCartographic(OT,XT);const u=Math.max(n.getPositionElevation(OT),400),d=n.calculateHorizonDistance(XT.lat,u);t.far=2.5*d+.1+s*r,t.updateProjectionMatrix()}else{this._getVirtualOrthoCameraPosition(t.position,t),t.updateMatrixWorld(),NT.copy(t.matrixWorld).invert(),kT.setFromMatrixPosition(e.matrixWorld).applyMatrix4(NT);const n=-kT.z;t.near=n-s*(1+i),t.far=n+.1+s*r,t.position.addScaledVector(zT,t.near),t.far-=t.near,t.near=0,t.updateProjectionMatrix(),t.updateMatrixWorld()}}resetState(){super.resetState(),this._dragMode=0,this._rotationMode=0}_updatePosition(t){if(1!==this.state){const{enableDamping:e,tilesGroup:n,dragQuaternion:i,dragInertia:r,camera:s}=this;e&&(1!==i.w||0===i.x&&0===i.y&&0===i.z||(i.w=Math.min(i.w,1-1e-9)),QT.setFromMatrixPosition(n.matrixWorld),WT.identity().slerp(i,r.x*t),lT(QT,WT,FT),s.matrixWorld.premultiply(FT),s.matrixWorld.decompose(s.position,s.quaternion,kT))}else{0===this._dragMode&&(this._dragMode=this._isNearControls()?1:-1);const{raycaster:e,camera:n,pivotPoint:i,pointerTracker:r,domElement:s,tilesGroup:a}=this,o=OT,l=HT;r.getCenterPoint(KT),cT(KT.x,KT.y,s,KT),uT(e,KT,n),NT.copy(a.matrixWorld).invert(),e.ray.applyMatrix4(NT);const c=kT.copy(i).applyMatrix4(NT).length();JT.radius.setScalar(c),n.isPerspectiveCamera?JT.intersectRay(e.ray,kT)||function(t,e,n){const i=t.origin.length(),r=Math.acos(e/i);n.copy(t.origin).multiplyScalar(-1).normalize();const s=oT.crossVectors(n,t.direction).normalize();n.multiplyScalar(-1).applyAxisAngle(s,-r).normalize().multiplyScalar(e)}(e.ray,c,kT):hT(e.ray,JT,kT),kT.applyMatrix4(a.matrixWorld),QT.setFromMatrixPosition(a.matrixWorld),o.subVectors(i,QT).normalize(),l.subVectors(kT,QT).normalize(),WT.setFromUnitVectors(l,o),lT(QT,WT,FT),n.matrixWorld.premultiply(FT),n.matrixWorld.decompose(n.position,n.quaternion,kT);const{dragInertia:h,dragQuaternion:u}=this;r.getMoveDistance()/t<2*window.devicePixelRatio?(u.slerp(WT,.5),h.set(1/t,0,0)):(u.copy(WT),h.set(1/t,0,0))}this._alignCameraUp(this.up)}_updateRotation(...t){1===this._rotationMode||this._isNearControls()?(this._rotationMode=1,super._updateRotation(...t)):(this.pivotMesh.visible=!1,this._rotationMode=-1),this._alignCameraUp(this.up)}_updateZoom(){const{zoomDelta:t,ellipsoid:e,zoomSpeed:n,zoomPoint:i,camera:r,maxZoom:s}=this,a=ci.clamp(ci.mapLinear(Math.abs(t),0,20,0,1),0,1);if(this._isNearControls()||t>0){if(this._updateZoomDirection(),t<0&&(this.zoomPointSet||this._updateZoomPoint())){zT.set(0,0,-1).transformDirection(r.matrixWorld).normalize(),qT.copy(this.up).multiplyScalar(-1),this.getUpDirection(i,jT);const t=ci.clamp(ci.mapLinear(-jT.dot(qT),1,.95,0,1),0,1),e=1-zT.dot(qT),n=r.isOrthographicCamera?.05:1,s=ci.clamp(3*a,0,1),o=Math.min(t*e*n*s,.1);qT.lerpVectors(zT,qT,o).normalize(),WT.setFromUnitVectors(zT,qT),lT(i,WT,FT),r.matrixWorld.premultiply(FT),r.matrixWorld.decompose(r.position,r.quaternion,qT),this.zoomDirection.subVectors(i,r.position).normalize()}super._updateZoom()}else if(r.isPerspectiveCamera){const i=this._getPerspectiveTransitionDistance(),r=this._getMaxPerspectiveDistance(),s=ci.mapLinear(this.getDistanceToCenter(),i,r,0,1);this._tiltTowardsCenter(ci.lerp(0,.4,s*a)),this._alignCameraUpToNorth(ci.lerp(0,.2,s*a));const o=t*(this.getDistanceToCenter()-e.radius.x)*n*.0025,l=Math.max(o,Math.min(this.getDistanceToCenter()-r,0));this.getVectorToCenter(kT).normalize(),this.camera.position.addScaledVector(kT,l),this.camera.updateMatrixWorld(),this.zoomDelta=0}else{const t=this._getOrthographicTransitionZoom(),e=this._getMinOrthographicZoom(),i=ci.mapLinear(r.zoom,t,e,0,1);this._tiltTowardsCenter(ci.lerp(0,.4,i*a)),this._alignCameraUpToNorth(ci.lerp(0,.2,i*a));const o=this.zoomDelta,l=Math.pow(.95,Math.abs(.05*o)),c=o>0?1/Math.abs(l):l,h=e/r.zoom,u=Math.max(c*n,Math.min(h,1));r.zoom=Math.min(s,r.zoom*u),r.updateProjectionMatrix(),this.zoomDelta=0,this.zoomDirectionSet=!1}}_alignCameraUpToNorth(t){const{tilesGroup:e}=this;VT.set(0,0,1).transformDirection(e.matrixWorld),this._alignCameraUp(VT,t)}_alignCameraUp(t,e=null){const{camera:n}=this;zT.set(0,0,-1).transformDirection(n.matrixWorld),GT.set(-1,0,0).transformDirection(n.matrixWorld),HT.crossVectors(t,zT),null===e&&(e=1-Math.abs(zT.dot(t)),e=ci.mapLinear(e,0,1,-.01,1),e=ci.clamp(e,0,1)**2),HT.lerp(GT,1-e).normalize(),WT.setFromUnitVectors(GT,HT),n.quaternion.premultiply(WT),n.updateMatrixWorld()}_tiltTowardsCenter(t){const{camera:e,tilesGroup:n}=this;zT.set(0,0,-1).transformDirection(e.matrixWorld).normalize(),kT.setFromMatrixPosition(n.matrixWorld).sub(e.position).normalize(),kT.lerp(zT,1-t).normalize(),WT.setFromUnitVectors(zT,kT),e.quaternion.premultiply(WT),e.updateMatrixWorld()}_getPerspectiveTransitionDistance(){const{camera:t,ellipsoid:e}=this;if(!t.isPerspectiveCamera)throw new Error;const n=Math.max(...e.radius),i=2*Math.atan(Math.tan(ci.DEG2RAD*t.fov*.5)*t.aspect),r=n/Math.tan(ci.DEG2RAD*t.fov*.5),s=n/Math.tan(.5*i);return Math.max(r,s)}_getMaxPerspectiveDistance(){const{camera:t,ellipsoid:e}=this;if(!t.isPerspectiveCamera)throw new Error;const n=Math.max(...e.radius),i=2*Math.atan(Math.tan(ci.DEG2RAD*t.fov*.5)*t.aspect),r=n/Math.tan(ci.DEG2RAD*t.fov*.5),s=n/Math.tan(.5*i);return 2*Math.max(r,s)}_getOrthographicTransitionZoom(){const{camera:t,ellipsoid:e}=this;if(!t.isOrthographicCamera)throw new Error;const n=t.top-t.bottom,i=t.right-t.left;return 2*Math.max(n,i)/(2*Math.max(...e.radius))}_getMinOrthographicZoom(){const{camera:t,ellipsoid:e}=this;if(!t.isOrthographicCamera)throw new Error;const n=t.top-t.bottom,i=t.right-t.left;return.7*Math.min(n,i)/(2*Math.max(...e.radius))}_getVirtualOrthoCameraPosition(t,e=this.camera){const{tilesGroup:n,ellipsoid:i}=this;if(!e.isOrthographicCamera)throw new Error;NT.copy(n.matrixWorld).invert(),YT.origin.copy(e.position),YT.direction.set(0,0,-1).transformDirection(e.matrixWorld),YT.applyMatrix4(NT),hT(YT,i,OT),OT.applyMatrix4(n.matrixWorld);const r=e.top-e.bottom,s=e.right-e.left,a=Math.max(r,s)/e.zoom;zT.set(0,0,-1).transformDirection(e.matrixWorld);const o=OT.sub(e.position).dot(zT);t.copy(e.position).addScaledVector(zT,o-4*a)}_isNearControls(){const{camera:t}=this;return t.isPerspectiveCamera?this.getDistanceToCenter()this._getOrthographicTransitionZoom()}}const $T=new zi,tB=new zi,eB=new Qh,nB=new zi,iB=new zi,rB=new zi,sB=new Qi,aB=new Qi;class oB extends Zn{get animating(){return 0!==this._alpha&&1!==this._alpha}get camera(){return 0===this._alpha?this.perspectiveCamera:1===this._alpha?this.orthographicCamera:this.transitionCamera}get mode(){return 0===this._target?"perspective":"orthographic"}set mode(t){if(t===this.mode)return;const e=this.camera;"perspective"===t?(this._target=0,this._alpha=0):(this._target=1,this._alpha=1),this.dispatchEvent({type:"camera-change",camera:this.camera,prevCamera:e})}constructor(t=new ca,e=new Qh){super(),this.perspectiveCamera=t,this.orthographicCamera=e,this.transitionCamera=new ca,this.orthographicPositionalZoom=!0,this.orthographicOffset=50,this.fixedPoint=new zi,this.duration=200,this.autoSync=!0,this.easeFunction=t=>t,this._target=0,this._alpha=0,this._clock=new hu}toggle(){this._target=1===this._target?0:1,this._clock.getDelta(),this.dispatchEvent({type:"toggle"})}update(t=Math.min(this._clock.getDelta(),.064)){this.autoSync&&this.syncCameras();const{perspectiveCamera:e,orthographicCamera:n,transitionCamera:i,camera:r}=this,s=1e3*t;if(this._alpha!==this._target){const t=Math.sign(this._target-this._alpha)*s/this.duration;this._alpha=ci.clamp(this._alpha+t,0,1),this.dispatchEvent({type:"change"})}const a=r;let o=null;0===this._alpha?o=e:1===this._alpha?o=n:(o=i,this._updateTransitionCamera()),a!==o&&(o===i&&this.dispatchEvent({type:"transition-start"}),this.dispatchEvent({type:"camera-change",camera:o,prevCamera:a}),a===i&&this.dispatchEvent({type:"transition-end"}))}syncCameras(){const t=this._getFromCamera(),{perspectiveCamera:e,orthographicCamera:n,transitionCamera:i,fixedPoint:r}=this;if($T.set(0,0,-1).transformDirection(t.matrixWorld).normalize(),t.isPerspectiveCamera){if(this.orthographicPositionalZoom)n.position.copy(e.position).addScaledVector($T,-this.orthographicOffset),n.rotation.copy(e.rotation),n.updateMatrixWorld();else{const t=tB.subVectors(r,n.position).dot($T),i=tB.subVectors(r,e.position).dot($T);tB.copy(e.position).addScaledVector($T,i),n.rotation.copy(e.rotation),n.position.copy(tB).addScaledVector($T,-t),n.updateMatrixWorld()}const t=Math.abs(tB.subVectors(e.position,r).dot($T)),i=2*Math.tan(ci.DEG2RAD*e.fov*.5)*t,s=n.top-n.bottom;n.zoom=s/i,n.updateProjectionMatrix()}else{const t=Math.abs(tB.subVectors(n.position,r).dot($T)),i=(n.top-n.bottom)/n.zoom*.5/Math.tan(ci.DEG2RAD*e.fov*.5);e.rotation.copy(n.rotation),e.position.copy(n.position).addScaledVector($T,t).addScaledVector($T,-i),e.updateMatrixWorld(),this.orthographicPositionalZoom&&(n.position.copy(e.position).addScaledVector($T,-this.orthographicOffset),n.updateMatrixWorld())}i.position.copy(e.position),i.rotation.copy(e.rotation)}_getTransitionDirection(){return Math.sign(this._target-this._alpha)}_getToCamera(){const t=this._getTransitionDirection();return 0===t?0===this._target?this.perspectiveCamera:this.orthographicCamera:t>0?this.orthographicCamera:this.perspectiveCamera}_getFromCamera(){const t=this._getTransitionDirection();return 0===t?0===this._target?this.perspectiveCamera:this.orthographicCamera:t>0?this.perspectiveCamera:this.orthographicCamera}_updateTransitionCamera(){const{perspectiveCamera:t,orthographicCamera:e,transitionCamera:n,fixedPoint:i}=this,r=this.easeFunction(this._alpha);$T.set(0,0,-1).transformDirection(e.matrixWorld).normalize(),eB.copy(e),eB.position.addScaledVector($T,e.near),e.far-=e.near,e.near=0,$T.set(0,0,-1).transformDirection(t.matrixWorld).normalize();const s=Math.abs(tB.subVectors(t.position,i).dot($T)),a=2*Math.tan(ci.DEG2RAD*t.fov*.5)*s,o=aB.slerpQuaternions(t.quaternion,eB.quaternion,r),l=ci.lerp(t.fov,1,r),c=.5*a/Math.tan(ci.DEG2RAD*l*.5),h=rB.copy(eB.position).sub(i).applyQuaternion(sB.copy(eB.quaternion).invert()),u=iB.copy(t.position).sub(i).applyQuaternion(sB.copy(t.quaternion).invert()),d=nB.lerpVectors(u,h,r);d.z-=Math.abs(d.z)-c;const p=-(u.z-d.z),f=-(h.z-d.z),m=ci.lerp(p+t.near,f+eB.near,r),g=ci.lerp(p+t.far,f+eB.far,r),A=Math.max(g,0)-Math.max(m,0);n.aspect=t.aspect,n.fov=l,n.near=Math.max(m,1e-5*A),n.far=g,n.position.copy(d).applyQuaternion(o).add(i),n.quaternion.copy(o),n.updateProjectionMatrix(),n.updateMatrixWorld()}}const{clamp:lB}=ci;class cB{constructor(){this.duration=250,this.fadeCount=0,this._lastTick=-1,this._fadeState=new Map,this.onFadeComplete=null,this.onFadeStart=null,this.onFadeSetComplete=null,this.onFadeSetStart=null}deleteObject(t){t&&this.completeFade(t)}guaranteeState(t){const e=this._fadeState;return!e.has(t)&&(e.set(t,{fadeInTarget:0,fadeOutTarget:0,fadeIn:0,fadeOut:0}),!0)}completeFade(t){const e=this._fadeState;if(!e.has(t))return;const n=0===e.get(t).fadeOutTarget;e.delete(t),this.fadeCount--,this.onFadeComplete&&this.onFadeComplete(t,n),0===this.fadeCount&&this.onFadeSetComplete&&this.onFadeSetComplete()}completeAllFades(){this._fadeState.forEach(((t,e)=>{this.completeFade(e)}))}forEachObject(t){this._fadeState.forEach(((e,n)=>{t(n,e)}))}fadeIn(t){const e=this.guaranteeState(t),n=this._fadeState.get(t);n.fadeInTarget=1,n.fadeOutTarget=0,n.fadeOut=0,e&&(this.fadeCount++,1===this.fadeCount&&this.onFadeSetStart&&this.onFadeSetStart(),this.onFadeStart&&this.onFadeStart(t))}fadeOut(t){const e=this.guaranteeState(t),n=this._fadeState.get(t);n.fadeOutTarget=1,e&&(n.fadeInTarget=1,n.fadeIn=1,this.fadeCount++,1===this.fadeCount&&this.onFadeSetStart&&this.onFadeSetStart(),this.onFadeStart&&this.onFadeStart(t))}isFading(t){return this._fadeState.has(t)}isFadingOut(t){const e=this._fadeState.get(t);return e&&1===e.fadeOutTarget}update(){const t=window.performance.now();-1===this._lastTick&&(this._lastTick=t);const e=lB((t-this._lastTick)/this.duration,0,1);this._lastTick=t,this._fadeState.forEach(((t,n)=>{const{fadeOutTarget:i,fadeInTarget:r}=t;let{fadeOut:s,fadeIn:a}=t;const o=Math.sign(r-a);a=lB(a+o*e,0,1);const l=Math.sign(i-s);s=lB(s+l*e,0,1),t.fadeIn=a,t.fadeOut=s,((1===s||0===s)&&(1===a||0===a)||s>=a)&&this.completeFade(n)}))}}function hB(t,e){const n={fadeIn:{value:0},fadeOut:{value:0},fadeTexture:{value:null}};return t.defines={...t.defines||{},FEATURE_FADE:0},t.onBeforeCompile=t=>{e&&e(t),t.uniforms={...t.uniforms,...n},t.vertexShader=t.vertexShader.replace(/void\s+main\(\)\s+{/,(t=>`\n\t\t\t\t\t#ifdef USE_BATCHING_FRAG\n\n\t\t\t\t\tvarying float vBatchId;\n\n\t\t\t\t\t#endif\n\n\t\t\t\t\t${t}\n\n\t\t\t\t\t\t#ifdef USE_BATCHING_FRAG\n\n\t\t\t\t\t\t// add 0.5 to the value to avoid floating error that may cause flickering\n\t\t\t\t\t\tvBatchId = getIndirectIndex( gl_DrawID ) + 0.5;\n\n\t\t\t\t\t\t#endif\n\t\t\t\t`)),t.fragmentShader=t.fragmentShader.replace(/void main\(/,(t=>`\n\t\t\t\t#if FEATURE_FADE\n\n\t\t\t\t// adapted from https://www.shadertoy.com/view/Mlt3z8\n\t\t\t\tfloat bayerDither2x2( vec2 v ) {\n\n\t\t\t\t\treturn mod( 3.0 * v.y + 2.0 * v.x, 4.0 );\n\n\t\t\t\t}\n\n\t\t\t\tfloat bayerDither4x4( vec2 v ) {\n\n\t\t\t\t\tvec2 P1 = mod( v, 2.0 );\n\t\t\t\t\tvec2 P2 = floor( 0.5 * mod( v, 4.0 ) );\n\t\t\t\t\treturn 4.0 * bayerDither2x2( P1 ) + bayerDither2x2( P2 );\n\n\t\t\t\t}\n\n\t\t\t\t// the USE_BATCHING define is not available in fragment shaders\n\t\t\t\t#ifdef USE_BATCHING_FRAG\n\n\t\t\t\t// functions for reading the fade state of a given batch id\n\t\t\t\tuniform sampler2D fadeTexture;\n\t\t\t\tvarying float vBatchId;\n\t\t\t\tvec2 getFadeValues( const in float i ) {\n\n\t\t\t\t\tint size = textureSize( fadeTexture, 0 ).x;\n\t\t\t\t\tint j = int( i );\n\t\t\t\t\tint x = j % size;\n\t\t\t\t\tint y = j / size;\n\t\t\t\t\treturn texelFetch( fadeTexture, ivec2( x, y ), 0 ).rg;\n\n\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\tuniform float fadeIn;\n\t\t\t\tuniform float fadeOut;\n\n\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t\t${t}\n\t\t\t`)).replace(/#include /,(t=>`\n\n\t\t\t\t${t}\n\n\t\t\t\t#if FEATURE_FADE\n\n\t\t\t\t#ifdef USE_BATCHING_FRAG\n\n\t\t\t\tvec2 fadeValues = getFadeValues( vBatchId );\n\t\t\t\tfloat fadeIn = fadeValues.r;\n\t\t\t\tfloat fadeOut = fadeValues.g;\n\n\t\t\t\t#endif\n\n\t\t\t\tfloat bayerValue = bayerDither4x4( floor( mod( gl_FragCoord.xy, 4.0 ) ) );\n\t\t\t\tfloat bayerBins = 16.0;\n\t\t\t\tfloat dither = ( 0.5 + bayerValue ) / bayerBins;\n\t\t\t\tif ( dither >= fadeIn ) {\n\n\t\t\t\t\tdiscard;\n\n\t\t\t\t}\n\n\t\t\t\tif ( dither < fadeOut ) {\n\n\t\t\t\t\tdiscard;\n\n\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t`))},n}class uB{constructor(){this._fadeParams=new WeakMap,this.fading=0}setFade(t,e,n){if(!t)return;const i=this._fadeParams;t.traverse((t=>{const r=t.material;if(r){const t=i.get(r);t.fadeIn.value=e,t.fadeOut.value=n;const s=Number(!(0===e||1===e)||!(0===n||1===n));r.defines.FEATURE_FADE!==s&&(this.fading+=1===s?1:-1,r.defines.FEATURE_FADE=s,r.needsUpdate=!0)}}))}prepareScene(t){t.traverse((t=>{t.material&&this.prepareMaterial(t.material)}))}deleteScene(t){if(!t)return;const e=this._fadeParams;t.traverse((t=>{const n=t.material;n&&(e.delete(n),n.onBeforeCompile=()=>{},n.needsUpdate=!0)}))}prepareMaterial(t){const e=this._fadeParams;e.has(t)||e.set(t,hB(t))}}class dB{constructor(t,e=new ps){this.other=t,this.material=e,this.visible=!0,this.parent=null,this._instanceInfo=[],this._visibilityChanged=!0;const n=new Proxy(this,{get(e,i){if(i in e)return e[i];{const r=t[i];return r instanceof Function?(...t)=>(e.syncInstances(),r.call(n,...t)):t[i]}},set:(e,n,i)=>(n in e?e[n]=i:t[n]=i,!0),deleteProperty:(e,n)=>n in e?delete e[n]:delete t[n]});return n}syncInstances(){const t=this._instanceInfo,e=this.other._instanceInfo;for(;e.length>t.length;){const n=t.length;t.push(new Proxy({visible:!1},{get:(t,i)=>i in t?t[i]:e[n][i],set:(t,i,r)=>(i in t?t[i]=r:e[n][i]=r,!0)}))}}}class pB extends dB{constructor(...t){super(...t);const e=this.material,n=hB(e,e.onBeforeCompile);e.defines.FEATURE_FADE=1,e.defines.USE_BATCHING_FRAG=1,e.needsUpdate=!0,this.fadeTexture=null,this._fadeParams=n}setFadeAt(t,e,n){this._initFadeTexture(),this.fadeTexture.setValueAt(t,255*e,255*n)}_initFadeTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=t*t*2,n=this.fadeTexture;if(!n||n.image.data.length!==e){const i=new Uint8Array(e),r=new fB(i,t,t,ae,kt);if(n){n.dispose();const t=n.image.data,e=this.fadeTexture.image.data,i=Math.min(t.length,e.length);e.set(new t.constructor(t.buffer,0,i))}this.fadeTexture=r,this._fadeParams.fadeTexture.value=r,r.needsUpdate=!0}}dispose(){this.fadeTexture&&this.fadeTexture.dispose()}}class fB extends $a{setValueAt(t,...e){const{data:n,width:i,height:r}=this.image,s=Math.floor(n.length/(i*r));let a=!1;for(let i=0;i{const e=t.cached.scene;e&&(e.visible=t.__inFrustum),this.forEachBatchIds(t,((e,n,i)=>{n.setVisibleAt(e,t.__inFrustum),i.batchedMesh.setVisibleAt(e,t.__inFrustum)}))})),a{if(!r.has(t))return;const n=t.matrixWorld,i=r.get(t);n.decompose(AB,yB,_B),i.decompose(gB,vB,_B);const s=yB.angleTo(vB),a=AB.distanceTo(gB);e=e&&(s>.25||a>.1)})),e&&t.completeAllFades()}if(l.forEach((t=>{r.get(t).copy(t.matrixWorld)})),t.forEachObject(((n,{fadeIn:i,fadeOut:r})=>{const a=n.cached.scene,o=t.isFadingOut(n);s.markTileUsed(n),a&&(e.setFade(a,i,r),o&&(a.visible=!0)),this.forEachBatchIds(n,((t,e,n)=>{e.setFadeAt(t,i,r),e.setVisibleAt(t,!0),n.batchedMesh.setVisibleAt(t,!1)}))})),o){const t=s.getPluginByName("BATCHED_TILES_PLUGIN").batchedMesh.material;o.material.map=t.map}}function CB(t){return"OCTREE"===t.__implicitRoot.implicitTiling.subdivisionScheme}function EB(t){return CB(t)?8:4}class MB{constructor(t,e){this.parent=t,this.children=[],this.__level=t.__level+1,this.__implicitRoot=t.__implicitRoot,this.__subtreeIdx=e,[this.__x,this.__y,this.__z]=function(t,e){return e?[2*e.__x+t.__subtreeIdx%2,2*e.__y+Math.floor(t.__subtreeIdx/2)%2,CB(t)?2*e.__z+Math.floor(t.__subtreeIdx/4)%2:0]:[0,0,0]}(this,t)}static copy(t){const e={children:[]};return e.__level=t.__level,e.__implicitRoot=t.__implicitRoot,e.__subtreeIdx=t.__subtreeIdx,[e.__x,e.__y,e.__z]=[t.__x,t.__y,t.__z],e.boundingVolume=t.boundingVolume,e.geometricError=t.geometricError,e}}class SB extends hb{constructor(t){super(),this.tile=t,this.rootTile=t.__implicitRoot}parseBuffer(t){const e=new DataView(t);let n=0;const i=ub(e);console.assert("subt"===i,'SUBTREELoader: The magic bytes equal "subt".'),n+=4;const r=e.getUint32(n,!0);console.assert(1===r,'SUBTREELoader: The version listed in the header is "1".'),n+=4;const s=e.getUint32(n,!0);n+=8;const a=e.getUint32(n,!0);n+=8;const o=JSON.parse(sb(new Uint8Array(t,n,s)));return n+=s,{version:r,subtreeJson:o,subtreeByte:t.slice(n,n+a)}}parse(t){const e=this.parseBuffer(t),n=e.subtreeJson;n.contentAvailabilityHeaders=[].concat(n.contentAvailability);const i=this.preprocessBuffers(n.buffers),r=this.preprocessBufferViews(n.bufferViews,i);this.markActiveBufferViews(n,r);const s=this.requestActiveBuffers(i,e.subtreeByte),a=this.parseActiveBufferViews(r,s);this.parseAvailability(e,n,a),this.expandSubtree(this.tile,e)}markActiveBufferViews(t,e){let n;const i=t.tileAvailability;isNaN(i.bitstream)?isNaN(i.bufferView)||(n=e[i.bufferView]):n=e[i.bitstream],n&&(n.isActive=!0,n.bufferHeader.isActive=!0);const r=t.contentAvailabilityHeaders;for(let t=0;t>Math.log2(r)];if(!this.getBit(e._tileAvailability,a)){i.push(void 0);continue}const l=this.deriveChildTile(e,o,a,t);o.children.push(l),i.push(l)}n=i,i=[]}return n}deriveChildTile(t,e,n,i){const r=new MB(e,i);r.boundingVolume=this.getTileBoundingVolume(r),r.geometricError=this.getGeometricError(r);for(let e=0;t&&e=t.lengthBits)throw new Error("Bit index out of bounds.");if(void 0!==t.constant)return t.constant;const n=e>>3,i=e%8;return 1==(new Uint8Array(t.bitstream)[n]>>i&1)}getTileBoundingVolume(t){const e={};if(this.rootTile.boundingVolume.region){const n=[...this.rootTile.boundingVolume.region],i=n[0],r=n[2],s=n[1],a=n[3],o=(r-i)/Math.pow(2,t.__level),l=(a-s)/Math.pow(2,t.__level);n[0]=i+o*t.__x,n[2]=i+o*(t.__x+1),n[1]=s+l*t.__y,n[3]=s+l*(t.__y+1);for(let t=0;t<4;t++){const e=n[t];e<-Math.PI?n[t]+=2*Math.PI:e>Math.PI&&(n[t]-=2*Math.PI)}if(CB(t)){const e=n[4],i=(n[5]-e)/Math.pow(2,t.__level);n[4]=e+i*t.__z,n[5]=e+i*(t.__z+1)}e.region=n}if(this.rootTile.boundingVolume.box){const n=[...this.rootTile.boundingVolume.box],i=2**t.__level-1,r=Math.pow(2,-t.__level),s=CB(t)?3:2;for(let e=0;eMath.PI&&(n-=Ag),i<-Math.PI?i+=Ag:i>Math.PI&&(i-=Ag),this._spherical.theta=n<=i?Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),!0===this.enableDamping?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const t=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=t!=this._spherical.radius}if(gg.setFromSpherical(this._spherical),gg.applyQuaternion(this._quatInverse),e.copy(this.target).add(gg),this.object.lookAt(this.target),!0===this.enableDamping?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let t=null;if(this.object.isPerspectiveCamera){const e=gg.length();t=this._clampDistance(e*this._scale);const n=e-t;this.object.position.addScaledVector(this._dollyDirection,n),this.object.updateMatrixWorld(),r=!!n}else if(this.object.isOrthographicCamera){const e=new zi(this._mouse.x,this._mouse.y,0);e.unproject(this.object);const n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=n!==this.object.zoom;const i=new zi(this._mouse.x,this._mouse.y,0);i.unproject(this.object),this.object.position.sub(i).add(e),this.object.updateMatrixWorld(),t=gg.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;null!==t&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(t).add(this.object.position):(pg.origin.copy(this.object.position),pg.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(pg.direction))yg||8*(1-this._lastQuaternion.dot(this.object.quaternion))>yg||this._lastTargetPosition.distanceToSquared(this.target)>yg)&&(this.dispatchEvent(hg),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0)}_getAutoRotationAngle(t){return null!==t?Ag/60*this.autoRotateSpeed*t:Ag/60/60*this.autoRotateSpeed}_getZoomScale(t){const e=Math.abs(.01*t);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){gg.setFromMatrixColumn(e,0),gg.multiplyScalar(-t),this._panOffset.add(gg)}_panUp(t,e){!0===this.screenSpacePanning?gg.setFromMatrixColumn(e,1):(gg.setFromMatrixColumn(e,0),gg.crossVectors(this.object.up,gg)),gg.multiplyScalar(t),this._panOffset.add(gg)}_pan(t,e){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;gg.copy(i).sub(this.target);let r=gg.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*r/n.clientHeight,this.object.matrix),this._panUp(2*e*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),i=t-n.left,r=e-n.top,s=n.width,a=n.height;this._mouse.x=i/s*2-1,this._mouse.y=-r/a*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(Ag*this._rotateDelta.x/e.clientHeight),this._rotateUp(Ag*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(Ag*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(-Ag*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(Ag*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(-Ag*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(1===this._pointers.length)this._rotateStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(t){if(1===this._pointers.length)this._panStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._panStart.set(n,i)}}_handleTouchStartDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,i=t.pageY-e.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(1==this._pointers.length)this._rotateEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._rotateEnd.set(n,i)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(Ag*this._rotateDelta.x/e.clientHeight),this._rotateUp(Ag*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(1===this._pointers.length)this._panEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),i=.5*(t.pageY+e.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,i=t.pageY-e.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const s=.5*(t.pageX+e.x),a=.5*(t.pageY+e.y);this._updateZoomParameters(s,a)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;es.distanceTo(i[2])?r[2]:i[2];let o=s.distanceTo(a);if(this.fade){const t=this.camera,e=Math.max(t.far,this.maxFar),i=n.vertices.far[0].z/(e-t.near);o+=.25*Math.pow(i,2)*(e-t.near)}t.left=-o/2,t.right=o/2,t.top=o/2,t.bottom=-o/2,t.updateProjectionMatrix()}}getBreaks(){const t=this.camera,e=Math.min(t.far,this.maxFar);switch(this.breaks.length=0,this.mode){case"uniform":n(this.cascades,t.near,e,this.breaks);break;case"logarithmic":i(this.cascades,t.near,e,this.breaks);break;case"practical":!function(t,e,r,s,a){sg.length=0,ag.length=0,i(t,e,r,ag),n(t,e,r,sg);for(let e=1;e{this.parse(t,e,i)}),n,i)}parse(t,e,n=()=>{}){this.decodeDracoFile(t,e,null,null,hn,n).catch(n)}decodeDracoFile(t,e,n,i,r=un,s=()=>{}){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:r};return this.decodeGeometry(t,a).then(e).catch(s)}decodeGeometry(t,e){const n=JSON.stringify(e);if(sv.has(t)){const e=sv.get(t);if(e.key===n)return e.promise;if(0===t.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const r=this.workerNextTaskID++,s=t.byteLength,a=this._getWorker(r,s).then((n=>(i=n,new Promise(((n,s)=>{i._callbacks[r]={resolve:n,reject:s},i.postMessage({type:"decode",id:r,taskConfig:e,buffer:t},[t])}))))).then((t=>this._createGeometry(t.geometry)));return a.catch((()=>!0)).then((()=>{i&&r&&this._releaseTask(i,r)})),sv.set(t,{key:n,promise:a}),a}_createGeometry(t){const e=new ks;t.index&&e.setIndex(new ws(t.index.array,1));for(let n=0;n{n.load(t,e,void 0,i)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const t="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then((e=>{const n=e[0];t||(this.decoderConfig.wasmBinary=e[1]);const i=av.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),this.decoderPending}_getWorker(t,e){return this._initDecoder().then((()=>{if(this.workerPool.lengthe._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[t]=e,n._taskLoad+=e,n}))}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map((t=>t._taskLoad)))}dispose(){for(let t=0;t{if(t.isMesh){const e=t.geometry,i=t.material;if(i.isMeshStandardMaterial){const a="geometries/Geometry_"+e.id+".usda";if(!(a in n)){const t=function(t){const e=function(t){const e=t.attributes,n=e.position.count;return`\n\tdef Mesh "Geometry"\n\t{\n\t\tint[] faceVertexCounts = [${function(t){const e=null!==t.index?t.index.count:t.attributes.position.count;return Array(e/3).fill(3).join(", ")}(t)}]\n\t\tint[] faceVertexIndices = [${function(t){const e=t.index,n=[];if(null!==e)for(let t=0;t0?n:"",r=t["uv"+i];void 0!==r&&(e+=`\n\t\ttexCoord2f[] primvars:st${i} = [${hy(r)}] (\n\t\t\tinterpolation = "vertex"\n\t\t)`)}const n=t.color;return void 0!==n&&(e+=`\n\tcolor3f[] primvars:displayColor = [${cy(n,n.count)}] (\n\t\tinterpolation = "vertex"\n\t\t)`),e}(e)}\n\t\tuniform token subdivisionScheme = "none"\n\t}\n`}(t);return`\ndef "Geometry"\n{\n${e}\n}\n`}(e);n[a]=function(t){let e='#usda 1.0\n(\n\tcustomLayerData = {\n\t\tstring creator = "Three.js USDZExporter"\n\t}\n\tdefaultPrim = "Root"\n\tmetersPerUnit = 1\n\tupAxis = "Y"\n)\n\n';return e+=t,iy(e)}(t)}i.uuid in s||(s[i.uuid]=i),r+=function(t,e,n){const i="Object_"+t.id,r=oy(t.matrixWorld);return t.matrixWorld.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",t),`def Xform "${i}" (\n\tprepend references = @./geometries/Geometry_${e.id}.usda@\n\tprepend apiSchemas = ["MaterialBindingAPI"]\n)\n{\n\tmatrix4d xformOp:transform = ${r}\n\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\trel material:binding = \n}\n\n`}(t,e,i)}else console.warn("THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)",t)}else t.isCamera&&(r+=function(t){const e=t.name?t.name:"Camera_"+t.id,n=oy(t.matrixWorld);return t.matrixWorld.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",t),t.isOrthographicCamera?`def Camera "${e}"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ${n}\n\t\t\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\t\t\tfloat2 clippingRange = (${t.near.toPrecision(7)}, ${t.far.toPrecision(7)})\n\t\t\tfloat horizontalAperture = ${(10*(Math.abs(t.left)+Math.abs(t.right))).toPrecision(7)}\n\t\t\tfloat verticalAperture = ${(10*(Math.abs(t.top)+Math.abs(t.bottom))).toPrecision(7)}\n\t\t\ttoken projection = "orthographic"\n\t\t}\n\t\n\t`:`def Camera "${e}"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ${n}\n\t\t\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\t\t\tfloat2 clippingRange = (${t.near.toPrecision(7)}, ${t.far.toPrecision(7)})\n\t\t\tfloat focalLength = ${t.getFocalLength().toPrecision(7)}\n\t\t\tfloat focusDistance = ${t.focus.toPrecision(7)}\n\t\t\tfloat horizontalAperture = ${t.getFilmWidth().toPrecision(7)}\n\t\t\ttoken projection = "perspective"\n\t\t\tfloat verticalAperture = ${t.getFilmHeight().toPrecision(7)}\n\t\t}\n\t\n\t`}(t))})),r+="\n\t\t}\n\t}\n}\n\n",r+=function(t,e,n=!1){const i=[];for(const r in t){const s=t[r];i.push(uy(s,e,n))}return`def "Materials"\n{\n${i.join("")}\n}\n\n`}(s,a,e.quickLookCompatible),n[i]=iy(r),r=null;for(const t in a){let i=a[t];if(!0===i.isCompressedTexture){if(null===this.textureUtils)throw new Error("THREE.USDZExporter: setTextureUtils() must be called to process compressed textures.");i=await this.textureUtils.decompress(i)}const r=ay(i.image,i.flipY,e.maxTextureSize),s=await new Promise((t=>r.toBlob(t,"image/png",1)));n[`textures/Texture_${t}.png`]=new Uint8Array(await s.arrayBuffer())}let o=0;for(const t in n){const e=n[t];o+=34+t.length;const i=63&o;if(4!==i){const r=new Uint8Array(64-i);n[t]=[e,{extra:{12345:r}}]}o=e.length}return function(t,e){e||(e={});var n={},i=[];ty(t,"",n,e);var r=0,s=0;for(var a in n){var o=n[a],l=o[0],c=o[1],h=0==c.level?0:8,u=(C=iy(a)).length,d=c.comment,p=d&&iy(d),f=p&&p.length,m=ry(c.extra);u>65535&&Nv(11);var g=h?Zv(l,c):l,A=g.length,v=Xv();v.p(l),i.push(Jv(c,{size:l.length,crc:v.d(),c:g,f:C,m:p,u:u!=a.length||p&&d.length!=f,o:r,compression:h})),r+=30+u+m+A,s+=76+2*(u+m)+(f||0)+A}for(var y=new ov(s+22),_=r,x=s-r,w=0;w(r=o.indexOf("\n"))&&s=t.byteLength||!(l=n(t)))&&e(1,"no header found"),(c=l.match(/^#\?(\S+)/))||e(3,"bad initial token"),o.valid|=1,o.programtype=c[1],o.string+=l+"\n";l=n(t),!1!==l;)if(o.string+=l+"\n","#"!==l.charAt(0)){if((c=l.match(i))&&(o.gamma=parseFloat(c[1])),(c=l.match(r))&&(o.exposure=parseFloat(c[1])),(c=l.match(s))&&(o.valid|=2,o.format=c[1]),(c=l.match(a))&&(o.valid|=4,o.height=parseInt(c[1],10),o.width=parseInt(c[2],10)),2&o.valid&&4&o.valid)break}else o.comments+=l+"\n";return 2&o.valid||e(3,"missing format specifier"),4&o.valid||e(3,"missing image size specifier"),o}(s),o=a.width,l=a.height,c=function(t,n,i){const r=n;if(r<8||r>32767||2!==t[0]||2!==t[1]||128&t[2])return new Uint8Array(t);r!==(t[2]<<8|t[3])&&e(3,"wrong scanline width");const s=new Uint8Array(4*n*i);s.length||e(4,"unable to allocate buffer space");let a=0,o=0;const l=4*r,c=new Uint8Array(4),h=new Uint8Array(l);let u=i;for(;u>0&&ot.byteLength&&e(1),c[0]=t[o++],c[1]=t[o++],c[2]=t[o++],c[3]=t[o++],2==c[0]&&2==c[1]&&(c[2]<<8|c[3])==r||e(3,"bad rgbe scanline format");let n,i=0;for(;i128;if(r&&(n-=128),(0===n||i+n>l)&&e(3,"bad scanline data"),r){const e=t[o++];for(let t=0;t>n&(1<>6}const h={c:0,lc:0};function u(t,e,n,i){t=t<<8|F(n,i),e+=8,h.c=t,h.lc=e}const d={c:0,lc:0};function p(t,e,n,i,r,s,a,o,l){if(t==e){i<8&&(u(n,i,r,s),n=h.c,i=h.lc);let t=n>>(i-=8);if(t=new Uint8Array([t])[0],o.value+t>l)return!1;const e=a[o.value-1];for(;t-- >0;)a[o.value++]=e}else{if(!(o.value32767?e-65536:e}const g={a:0,b:0};function A(t,e){const n=m(t),i=m(e),r=n+(1&i)+(i>>1),s=r,a=r-i;g.a=s,g.b=a}function v(t,e){const n=f(t),i=f(e),r=n-(i>>1)&65535,s=i+r-32768&65535;g.a=s,g.b=r}function y(t,e,n,i,r,s,a){const o=a<16384,l=n>r?r:n;let c,h,u=1;for(;u<=l;)u<<=1;for(u>>=1,c=u,u>>=1;u>=1;){h=0;const a=h+s*(r-c),l=s*u,d=s*c,p=i*u,f=i*c;let m,y,_,x;for(;h<=a;h+=d){let r=h;const s=h+i*(n-c);for(;r<=s;r+=f){const n=r+p,i=r+l,s=i+p;o?(A(t[r+e],t[i+e]),m=g.a,_=g.b,A(t[n+e],t[s+e]),y=g.a,x=g.b,A(m,y),t[r+e]=g.a,t[n+e]=g.b,A(_,x),t[i+e]=g.a,t[s+e]=g.b):(v(t[r+e],t[i+e]),m=g.a,_=g.b,v(t[n+e],t[s+e]),y=g.a,x=g.b,v(m,y),t[r+e]=g.a,t[n+e]=g.b,v(_,x),t[i+e]=g.a,t[s+e]=g.b)}if(n&u){const n=r+l;o?A(t[r+e],t[n+e]):v(t[r+e],t[n+e]),m=g.a,t[n+e]=g.b,t[r+e]=m}}if(r&u){let r=h;const s=h+i*(n-c);for(;r<=s;r+=f){const n=r+p;o?A(t[r+e],t[n+e]):v(t[r+e],t[n+e]),m=g.a,t[n+e]=g.b,t[r+e]=m}}c=u,u>>=1}return h}function _(t,e,r,f,m,g){const A=r.value,v=N(e,r),y=N(e,r);r.value+=4;const _=N(e,r);if(r.value+=4,v<0||v>=i||y<0||y>=i)throw new Error("Something wrong with HUF_ENCSIZE");const x=new Array(i),w=new Array(16384);if(function(t){for(let e=0;e<16384;e++)t[e]={},t[e].len=0,t[e].lit=0,t[e].p=null}(w),function(t,e,n,r,l,c){const h=e;let u=0,d=0;for(;r<=l;r++){if(h.value-e.value>n)return!1;a(6,u,d,t,h);const i=s.l;if(u=s.c,d=s.lc,c[r]=i,63==i){if(h.value-e.value>n)throw new Error("Something wrong with hufUnpackEncTable");a(8,u,d,t,h);let i=s.l+6;if(u=s.c,d=s.lc,r+i>l+1)throw new Error("Something wrong with hufUnpackEncTable");for(;i--;)c[r++]=0;r--}else if(i>=59){let t=i-59+2;if(r+t>l+1)throw new Error("Something wrong with hufUnpackEncTable");for(;t--;)c[r++]=0;r--}}!function(t){for(let t=0;t<=58;++t)o[t]=0;for(let e=0;e0;--t){const n=e+o[t]>>1;o[t]=e,e=n}for(let e=0;e0&&(t[e]=n|o[n]++<<6)}}(c)}(t,r,f-(r.value-A),v,y,x),_>8*(f-(r.value-A)))throw new Error("Something wrong with hufUncompress");!function(t,e,i,r){for(;e<=i;e++){const i=c(t[e]),s=l(t[e]);if(i>>s)throw new Error("Invalid table entry");if(s>n){const t=r[i>>s-n];if(t.len)throw new Error("Invalid table entry");if(t.lit++,t.p){const e=t.p;t.p=new Array(t.lit);for(let n=0;n0;a--){const a=r[(i<=n;){const s=e[g>>A-n&16383];if(s.len)A-=s.len,p(s.lit,a,g,A,i,r,f,m,v),g=d.c,A=d.lc;else{if(!s.p)throw new Error("hufDecode issues");let e;for(e=0;e=n&&c(t[s.p[e]])==(g>>A-n&(1<>=_,A-=_;A>0;){const t=e[g<s||(e[r++]=t[n++],r>s));)e[r++]=t[i++]}function C(t){let e=t.byteLength;const n=new Array;let i=0;const r=new DataView(t);for(;e>0;){const t=r.getInt8(i++);if(t<0){const s=-t;e-=s+1;for(let t=0;t>8==255?r+=255&i:(n[r]=i,r++),t.value++}function M(t){const e=.5*Math.cos(.7853975),n=.5*Math.cos(3.14159/16),i=.5*Math.cos(3.14159/8),r=.5*Math.cos(3*3.14159/16),s=.5*Math.cos(.981746875),a=.5*Math.cos(3*3.14159/8),o=.5*Math.cos(1.374445625),l=new Array(4),c=new Array(4),h=new Array(4),u=new Array(4);for(let d=0;d<8;++d){const p=8*d;l[0]=i*t[p+2],l[1]=a*t[p+2],l[2]=i*t[p+6],l[3]=a*t[p+6],c[0]=n*t[p+1]+r*t[p+3]+s*t[p+5]+o*t[p+7],c[1]=r*t[p+1]-o*t[p+3]-n*t[p+5]-s*t[p+7],c[2]=s*t[p+1]-n*t[p+3]+o*t[p+5]+r*t[p+7],c[3]=o*t[p+1]-s*t[p+3]+r*t[p+5]-n*t[p+7],h[0]=e*(t[p+0]+t[p+4]),h[3]=e*(t[p+0]-t[p+4]),h[1]=l[0]+l[3],h[2]=l[1]-l[2],u[0]=h[0]+h[1],u[1]=h[3]+h[2],u[2]=h[3]-h[2],u[3]=h[0]-h[1],t[p+0]=u[0]+c[0],t[p+1]=u[1]+c[1],t[p+2]=u[2]+c[2],t[p+3]=u[3]+c[3],t[p+4]=u[3]-c[3],t[p+5]=u[2]-c[2],t[p+6]=u[1]-c[1],t[p+7]=u[0]-c[0]}for(let d=0;d<8;++d)l[0]=i*t[16+d],l[1]=a*t[16+d],l[2]=i*t[48+d],l[3]=a*t[48+d],c[0]=n*t[8+d]+r*t[24+d]+s*t[40+d]+o*t[56+d],c[1]=r*t[8+d]-o*t[24+d]-n*t[40+d]-s*t[56+d],c[2]=s*t[8+d]-n*t[24+d]+o*t[40+d]+r*t[56+d],c[3]=o*t[8+d]-s*t[24+d]+r*t[40+d]-n*t[56+d],h[0]=e*(t[d]+t[32+d]),h[3]=e*(t[d]-t[32+d]),h[1]=l[0]+l[3],h[2]=l[1]-l[2],u[0]=h[0]+h[1],u[1]=h[3]+h[2],u[2]=h[3]-h[2],u[3]=h[0]-h[1],t[0+d]=u[0]+c[0],t[8+d]=u[1]+c[1],t[16+d]=u[2]+c[2],t[24+d]=u[3]+c[3],t[32+d]=u[3]-c[3],t[40+d]=u[2]-c[2],t[48+d]=u[1]-c[1],t[56+d]=u[0]-c[0]}function S(t){for(let e=0;e<64;++e){const n=t[0][e],i=t[1][e],r=t[2][e];t[0][e]=n+1.5747*r,t[1][e]=n-.1873*i-.4682*r,t[2][e]=n+1.8556*i}}function b(t,e,n){for(let s=0;s<64;++s)e[n+s]=vs.toHalfFloat((i=t[s])<=1?Math.sign(i)*Math.pow(Math.abs(i),2.2):Math.sign(i)*Math.pow(r,Math.abs(i)-1));var i}function I(t){return new DataView(t.array.buffer,t.offset.value,t.size)}function T(t){const e=t.viewer.buffer.slice(t.offset.value,t.offset.value+t.size),n=new Uint8Array(C(e)),i=new Uint8Array(n.length);return x(n),w(n,i),new DataView(i.buffer)}function B(t){const e=$v(t.array.slice(t.offset.value,t.offset.value+t.size)),n=new Uint8Array(e.length);return x(e),w(e,n),new DataView(n.buffer)}function R(t){const n=t.viewer,i={value:t.offset.value},r=new Uint16Array(t.columns*t.lines*(t.inputChannels.length*t.type)),s=new Uint8Array(8192);let a=0;const o=new Array(t.inputChannels.length);for(let e=0,n=t.inputChannels.length;e=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(l<=c)for(let t=0;t>3]&1<<(7&r))&&(n[i++]=r);const r=i-1;for(;i0;){const t=L(e.buffer,n),i=O(e,n),r=i>>2&3,o=new Int8Array([(i>>4)-1])[0],l=O(e,n);s.push({name:t,index:o,type:l,compression:r}),a-=t.length+3}const o=Z.channels,l=new Array(t.inputChannels.length);for(let e=0;e=0&&(c.idx[i.index]=e),t.offset=e)}}let h,u,d;if(r.acCompressedSize>0)switch(r.acCompression){case 0:h=new Uint16Array(r.totalAcUncompressedCount),_(t.array,e,n,r.acCompressedSize,h,r.totalAcUncompressedCount);break;case 1:const i=$v(t.array.slice(n.value,n.value+r.totalAcUncompressedCount));h=new Uint16Array(i.buffer),n.value+=r.totalAcUncompressedCount}if(r.dcCompressedSize>0){const e={array:t.array,offset:n,size:r.dcCompressedSize};u=new Uint16Array(B(e).buffer),n.value+=r.dcCompressedSize}r.rleRawSize>0&&(d=C($v(t.array.slice(n.value,n.value+r.rleCompressedSize)).buffer),n.value+=r.rleCompressedSize);let p=0;const f=new Array(l.length);for(let t=0;t>10,n=1023&t;return(t>>15?-1:1)*(e?31===e?n?NaN:1/0:Math.pow(2,e-15)*(1+n/1024):n/1024*6103515625e-14)}function H(t,e){const n=t.getUint16(e.value,!0);return e.value+=2,n}function V(t,e){return G(H(t,e))}function W(t,e,n,i,r){return"string"===i||"stringvector"===i||"iccProfile"===i?function(t,e,n){const i=(new TextDecoder).decode(new Uint8Array(t).slice(e.value,e.value+n));return e.value=e.value+n,i}(e,n,r):"chlist"===i?function(t,e,n,i){const r=n.value,s=[];for(;n.value>4]}}(t,n):"lineOrder"===i?function(t,e){return["INCREASING_Y","DECREASING_Y","RANDOM_Y"][O(t,e)]}(t,n):"float"===i?Q(t,n):"v2f"===i?function(t,e){return[Q(t,e),Q(t,e)]}(t,n):"v3f"===i?function(t,e){return[Q(t,e),Q(t,e),Q(t,e)]}(t,n):"int"===i?U(t,n):"rational"===i?function(t,e){return[U(t,e),N(t,e)]}(t,n):"timecode"===i?function(t,e){return[N(t,e),N(t,e)]}(t,n):"preview"===i?(n.value+=r,"skipped"):void(n.value+=r)}function j(t,e,n,i){const r=new Array(t);for(let s=0;st.width?t.width-s:t.blockWidth,t.lines=a+t.blockHeight>t.height?t.height-a:t.blockHeight;const o=t.columns*t.totalBytes,l=t.sizet.height?t.height-r:t.blockHeight;const s=t.columns*t.totalBytes,a=t.size=t.height)continue;const l=e*s,c=(t.height-1-o)*t.outLineWidth;for(let e=0;et:s.scanOrder=t=>s.height-1-t,4==s.outputChannels?(s.format=$t,s.colorSpace=un):(s.format=re,s.colorSpace=cn),t.spec.singleTile){s.blockHeight=t.tiles.ySize,s.blockWidth=t.tiles.xSize;const n=function(t,e,n){let i=0;switch(t.levelMode){case"ONE_LEVEL":i=1;break;case"MIPMAP_LEVELS":i=function(t,e){const n=Math.log2(t);return"ROUND_DOWN"==e?Math.floor(n):Math.ceil(n)}(Math.max(e,n),t.roundingMode)+1;break;case"RIPMAP_LEVELS":throw new Error("THREE.EXRLoader: RIPMAP_LEVELS tiles currently unsupported.")}return i}(t.tiles,s.width,s.height),r=j(n,s.width,t.tiles.xSize,t.tiles.roundingMode),a=j(n,s.height,t.tiles.ySize,t.tiles.roundingMode);s.tileCount=r[0]*a[0];for(let t=0;t{const r=t.xr.getSession();"requestLightProbe"in r&&r.requestLightProbe({reflectionFormat:r.preferredReflectionFormat}).then((r=>{n=new By(this,t,r,e,(()=>{i=!0,this.dispatchEvent({type:"estimationstart"})}))}))})),t.xr.addEventListener("sessionend",(()=>{n&&(n.dispose(),n=null),i&&this.dispatchEvent({type:"estimationend"})})),this.dispose=()=>{n&&(n.dispose(),n=null),this.remove(this.lightProbe),this.lightProbe=null,this.remove(this.directionalLight),this.directionalLight=null,this.environment=null}}},e.TransformControls=class extends Pd{constructor(t,e=null){super(void 0,e);const n=new Q_(this);this._root=n;const i=new z_;this._gizmo=i,n.add(i);const r=new G_;this._plane=r,n.add(r);const s=this;function a(t,e){let n=e;Object.defineProperty(s,t,{get:function(){return void 0!==n?n:e},set:function(e){n!==e&&(n=e,r[t]=e,i[t]=e,s.dispatchEvent({type:t+"-changed",value:e}),s.dispatchEvent(g_))}}),s[t]=e,r[t]=e,i[t]=e}a("camera",t),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const o=new zi,l=new zi,c=new Qi,h=new Qi,u=new zi,d=new Qi,p=new zi,f=new zi,m=new zi,g=new zi;a("worldPosition",o),a("worldPositionStart",l),a("worldQuaternion",c),a("worldQuaternionStart",h),a("cameraPosition",u),a("cameraQuaternion",d),a("pointStart",p),a("pointEnd",f),a("rotationAxis",m),a("rotationAngle",0),a("eye",g),this._offset=new zi,this._startNorm=new zi,this._endNorm=new zi,this._cameraScale=new zi,this._parentPosition=new zi,this._parentQuaternion=new Qi,this._parentQuaternionInv=new Qi,this._parentScale=new zi,this._worldScaleStart=new zi,this._worldQuaternionInv=new Qi,this._worldScale=new zi,this._positionStart=new zi,this._quaternionStart=new Qi,this._scaleStart=new zi,this._getPointer=__.bind(this),this._onPointerDown=w_.bind(this),this._onPointerHover=x_.bind(this),this._onPointerMove=C_.bind(this),this._onPointerUp=E_.bind(this),null!==e&&this.connect()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(t){if(void 0===this.object||!0===this.dragging)return;null!==t&&u_.setFromCamera(t,this.camera);const e=M_(this._gizmo.picker[this.mode],u_);this.axis=e?e.object.name:null}pointerDown(t){if(void 0!==this.object&&!0!==this.dragging&&(null==t||0===t.button)&&null!==this.axis){null!==t&&u_.setFromCamera(t,this.camera);const e=M_(this._plane,u_,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,A_.mode=this.mode,this.dispatchEvent(A_)}}pointerMove(t){const e=this.axis,n=this.mode,i=this.object;let r=this.space;if("scale"===n?r="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(r="world"),void 0===i||null===e||!1===this.dragging||null!==t&&-1!==t.button)return;null!==t&&u_.setFromCamera(t,this.camera);const s=M_(this._plane,u_,!0);if(s){if(this.pointEnd.copy(s.point).sub(this.worldPositionStart),"translate"===n)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===r&&"XYZ"!==e&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===e.indexOf("X")&&(this._offset.x=0),-1===e.indexOf("Y")&&(this._offset.y=0),-1===e.indexOf("Z")&&(this._offset.z=0),"local"===r&&"XYZ"!==e?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===r&&(i.position.applyQuaternion(f_.copy(this._quaternionStart).invert()),-1!==e.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),"world"===r&&(i.parent&&i.position.add(d_.setFromMatrixPosition(i.parent.matrixWorld)),-1!==e.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(d_.setFromMatrixPosition(i.parent.matrixWorld)))),i.position.x=Math.max(this.minX,Math.min(this.maxX,i.position.x)),i.position.y=Math.max(this.minY,Math.min(this.maxY,i.position.y)),i.position.z=Math.max(this.minZ,Math.min(this.maxZ,i.position.z));else if("scale"===n){if(-1!==e.search("XYZ")){let t=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(t*=-1),p_.set(t,t,t)}else d_.copy(this.pointStart),p_.copy(this.pointEnd),d_.applyQuaternion(this._worldQuaternionInv),p_.applyQuaternion(this._worldQuaternionInv),p_.divide(d_),-1===e.search("X")&&(p_.x=1),-1===e.search("Y")&&(p_.y=1),-1===e.search("Z")&&(p_.z=1);i.scale.copy(this._scaleStart).multiply(p_),this.scaleSnap&&(-1!==e.search("X")&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Z")&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===n){this._offset.copy(this.pointEnd).sub(this.pointStart);const t=20/this.worldPosition.distanceTo(d_.setFromMatrixPosition(this.camera.matrixWorld));let n=!1;"XYZE"===e?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(d_.copy(this.rotationAxis).cross(this.eye))*t):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(m_[e]),d_.copy(m_[e]),"local"===r&&d_.applyQuaternion(this.worldQuaternion),d_.cross(this.eye),0===d_.length()?n=!0:this.rotationAngle=this._offset.dot(d_.normalize())*t),("E"===e||n)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===r&&"E"!==e&&"XYZE"!==e?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(f_.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(f_.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(g_),this.dispatchEvent(y_)}}pointerUp(t){null!==t&&0!==t.button||(this.dragging&&null!==this.axis&&(v_.mode=this.mode,this.dispatchEvent(v_)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(t){return this.object=t,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(g_),this.dispatchEvent(y_),this.pointStart.copy(this.pointEnd))}getRaycaster(){return u_}getMode(){return this.mode}setMode(t){this.mode=t}setTranslationSnap(t){this.translationSnap=t}setRotationSnap(t){this.rotationSnap=t}setScaleSnap(t){this.scaleSnap=t}setSize(t){this.size=t}setSpace(t){this.space=t}},e.CSS3DRenderer=class{constructor(t={}){const e=this;let n,i,r,s;const a={camera:{style:""},objects:new WeakMap},o=void 0!==t.element?t.element:document.createElement("div");o.style.overflow="hidden",this.domElement=o;const l=document.createElement("div");l.style.transformOrigin="0 0",l.style.pointerEvents="none",o.appendChild(l);const c=document.createElement("div");function h(t){return Math.abs(t)<1e-10?0:t}function u(t){const e=t.elements;return"matrix3d("+h(e[0])+","+h(-e[1])+","+h(e[2])+","+h(e[3])+","+h(e[4])+","+h(-e[5])+","+h(e[6])+","+h(e[7])+","+h(e[8])+","+h(-e[9])+","+h(e[10])+","+h(e[11])+","+h(e[12])+","+h(-e[13])+","+h(e[14])+","+h(e[15])+")"}function d(t){const e=t.elements;return"translate(-50%,-50%)matrix3d("+h(e[0])+","+h(e[1])+","+h(e[2])+","+h(e[3])+","+h(-e[4])+","+h(-e[5])+","+h(-e[6])+","+h(-e[7])+","+h(e[8])+","+h(e[9])+","+h(e[10])+","+h(e[11])+","+h(e[12])+","+h(e[13])+","+h(e[14])+","+h(e[15])+")"}function p(t){t.isCSS3DObject&&(t.element.style.display="none");for(let e=0,n=t.children.length;e{this._fadeMaterialManager.prepareScene(t)},this._onDisposeModel=({tile:t,scene:e})=>{this._fadeManager.deleteObject(t),this._fadeMaterialManager.deleteScene(e)},this._onAddCamera=({camera:t})=>{this._prevCameraTransforms.set(t,new Ar)},this._onDeleteCamera=({camera:t})=>{this._prevCameraTransforms.delete(t)},this._onTileVisibilityChange=({tile:t,visible:e})=>{const n=t.cached.scene;n&&(n.visible=!0),this.forEachBatchIds(t,((t,e,n)=>{e.setFadeAt(t,0,0),e.setVisibleAt(t,!1),n.batchedMesh.setVisibleAt(t,!1)}))},this._onUpdateBefore=()=>{xB.call(this)},this._onUpdateAfter=()=>{wB.call(this)},t.addEventListener("load-model",this._onLoadModel),t.addEventListener("dispose-model",this._onDisposeModel),t.addEventListener("add-camera",this._onAddCamera),t.addEventListener("delete-camera",this._onDeleteCamera),t.addEventListener("update-before",this._onUpdateBefore),t.addEventListener("update-after",this._onUpdateAfter),t.addEventListener("tile-visibility-change",this._onTileVisibilityChange);const e=this._fadeManager;e.onFadeSetStart=()=>{t.dispatchEvent({type:"fade-start"}),t.dispatchEvent({type:"force-rerender"})},e.onFadeSetComplete=()=>{t.dispatchEvent({type:"fade-end"}),t.dispatchEvent({type:"force-rerender"})},e.onFadeComplete=(e,n)=>{this._fadeMaterialManager.setFade(e.cached.scene,0,0),this.forEachBatchIds(e,((t,e,i)=>{e.setFadeAt(t,0,0),e.setVisibleAt(t,!1),i.batchedMesh.setVisibleAt(t,n)})),n||(t.invokeOnePlugin((t=>t!==this&&t.setTileVisible&&t.setTileVisible(e,!1))),this._fadingOutCount--)};const n=new Map;t.cameras.forEach((t=>{n.set(t,new Ar)})),t.forEachLoadedModel(((t,e)=>{this._onLoadModel({scene:t})})),this.tiles=t,this._fadeManager=e,this._prevCameraTransforms=n}initBatchedMesh(){const t=this.tiles.getPluginByName("BATCHED_TILES_PLUGIN")?.batchedMesh;if(t){if(null===this.batchedMesh){this._onBatchedMeshDispose=()=>{this.batchedMesh.dispose(),this.batchedMesh.removeFromParent(),this.batchedMesh=null,t.removeEventListener("dispose",this._onBatchedMeshDispose)};const e=t.material.clone();e.onBeforeCompile=t.material.onBeforeCompile,this.batchedMesh=new pB(t,e),this.tiles.group.add(this.batchedMesh)}}else null!==this.batchedMesh&&(this._onBatchedMeshDispose(),this._onBatchedMeshDispose=null)}setTileVisible(t,e){const n=this._fadeManager,i=n.isFading(t);if(n.isFadingOut(t)&&this._fadingOutCount--,e?1===t.__depthFromRenderedParent?((t[mB]||this.fadeRootTiles)&&this._fadeManager.fadeIn(t),t[mB]=!0):this._fadeManager.fadeIn(t):(this._fadingOutCount++,n.fadeOut(t)),i)return!0;const r=this._fadeManager.isFading(t);return!(e||!r)}dispose(){const t=this.tiles;this._fadeManager.completeAllFades(),null!==this.batchedMesh&&this._onBatchedMeshDispose(),t.removeEventListener("load-model",this._onLoadModel),t.removeEventListener("dispose-model",this._onDisposeModel),t.removeEventListener("add-camera",this._onAddCamera),t.removeEventListener("delete-camera",this._onDeleteCamera),t.removeEventListener("update-before",this._onUpdateBefore),t.removeEventListener("update-after",this._onUpdateAfter),t.removeEventListener("tile-visibility-change",this._onTileVisibilityChange),t.forEachLoadedModel(((t,e)=>{this._fadeManager.deleteObject(e),t&&(t.visible=!0)}))}forEachBatchIds(t,e){if(this.initBatchedMesh(),this.batchedMesh){const n=this.tiles.getPluginByName("BATCHED_TILES_PLUGIN"),i=n.getTileBatchIds(t);i&&i.forEach((t=>{e(t,this.batchedMesh,n)}))}}},d.ImplicitTilingPlugin=class{constructor(){this.name="IMPLICIT_TILING_PLUGIN"}init(t){this.tiles=t}preprocessNode(t,e,n){t.implicitTiling?(t.__hasUnrenderableContent=!0,t.__hasRenderableContent=!1,t.__subtreeIdx=0,t.__implicitRoot=t,t.__x=0,t.__y=0,t.__z=0,t.__level=0):/.subtree$/i.test(t.content?.uri)&&(t.__hasUnrenderableContent=!0,t.__hasRenderableContent=!1)}parseTile(t,e,n){if(/^subtree$/i.test(n))return new SB(e).parse(t),Promise.resolve()}preprocessURL(t,e){if(e&&e.implicitTiling){const t=e.implicitTiling.subtrees.uri.replace("{level}",e.__level).replace("{x}",e.__x).replace("{y}",e.__y).replace("{z}",e.__z);return new URL(t,e.__basePath+"/").toString()}return t}disposeTile(t){/.subtree$/i.test(t.content?.uri)&&(t.children.length=0)}},window.THREE=e,window.ThreeMeshUI=Hw,window.ThreeMeshBVH=h,window.TILES=d,window.CustomShaderMaterial=class extends ds{constructor({baseMaterial:t,vertexShader:e,fragmentShader:n,uniforms:i,patchMap:r,cacheKey:s,...a}){if(!t)throw new Error("CustomShaderMaterial: baseMaterial is required.");let o;if(function(t){try{new t}catch(t){if(t.message.indexOf("is not a constructor")>=0)return!1}return!0}(t)){const e=0===Object.keys(a).length;o=new t(e?void 0:a)}else o=t,Object.assign(o,a);if(["ShaderMaterial","RawShaderMaterial"].includes(o.type))throw new Error(`CustomShaderMaterial does not support ${o.type} as a base material.`);super(),this.uniforms={},this.vertexShader="",this.fragmentShader="";const l=o;l.name=`CustomShaderMaterial<${o.name||o.type}>`,l.update=this.update.bind(l),l.__csm={prevOnBeforeCompile:o.onBeforeCompile,baseMaterial:o,vertexShader:e,fragmentShader:n,uniforms:i,patchMap:r,cacheKey:s};const c={...l.uniforms||{},...i||{}};l.uniforms=this.uniforms=c,l.vertexShader=this.vertexShader=e||"",l.fragmentShader=this.fragmentShader=n||"",l.update({fragmentShader:l.fragmentShader,vertexShader:l.vertexShader,uniforms:l.uniforms,patchMap:r,cacheKey:s}),Object.assign(this,l);const h=Object.getOwnPropertyDescriptors(Object.getPrototypeOf(l));for(const t in h){const e=h[t];(e.get||e.set)&&Object.defineProperty(this,t,e)}return Object.defineProperty(this,"type",{get:()=>o.type,set(t){o.type=t}}),this}update({fragmentShader:t,vertexShader:e,uniforms:n,cacheKey:i,patchMap:r}){const s=dx(e||""),a=dx(t||""),o=this;n&&(o.uniforms=n),e&&(o.vertexShader=e),t&&(o.fragmentShader=t),Object.entries(ux).forEach((([t,e])=>{for(const n in e){const i=e[n];(a&&a.includes(i)||s&&s.includes(i))&&(o[t]||(o[t]=1))}}));const l=o.__csm.prevOnBeforeCompile,c=(t,e,n)=>{let i,r="";if(e){const t=e.search(/void\s+main\s*\(\s*\)\s*{/);if(-1!==t){r=e.slice(0,t);let n=0,s=-1;for(let i=t;i{null==l||l(t,e);const i=r||{},h=o.type,u=h?`#define IS_${h.toUpperCase()};\n`:"#define IS_UNKNOWN;\n";t.vertexShader=u+"#define IS_VERTEX\n"+t.vertexShader,t.fragmentShader=u+"#define IS_FRAGMENT\n"+t.fragmentShader;const d=e=>{for(const n in e){const i="*"===n||s&&s.includes(n);if("*"===n||a&&a.includes(n)||i){const i=cx[n];if(i&&"*"!==i&&(Array.isArray(i)?!i.includes(h):i!==h))return void console.error(`CustomShaderMaterial: ${n} is not available in ${h}. Shader cannot compile.`);const r=e[n];for(const e in r){const n=r[e];if("object"==typeof n){const i=n.type,r=n.value;"fs"===i?t.fragmentShader=t.fragmentShader.replace(e,r):"vs"===i&&(t.vertexShader=t.vertexShader.replace(e,r))}else n&&(t.vertexShader=t.vertexShader.replace(e,n),t.fragmentShader=t.fragmentShader.replace(e,n))}}}};d(hx),d(i),t.vertexShader=c(t.vertexShader,s,!1),t.fragmentShader=c(t.fragmentShader,a,!0),n&&(t.uniforms={...t.uniforms,...o.uniforms}),o.uniforms=t.uniforms};const h=o.customProgramCacheKey;o.customProgramCacheKey=()=>((null==i?void 0:i())||function(t){let e=0;for(let n=0;n>>0)}((s||"")+(a||"")))+(null==h?void 0:h.call(o)),o.needsUpdate=!0}clone(){const t=this;return new t.constructor({baseMaterial:t.__csm.baseMaterial.clone(),vertexShader:t.__csm.vertexShader,fragmentShader:t.__csm.fragmentShader,uniforms:t.__csm.uniforms,patchMap:t.__csm.patchMap,cacheKey:t.__csm.cacheKey})}}})(); \ No newline at end of file diff --git a/public/dist/THREE.bundle.js.LICENSE.txt b/public/dist/THREE.bundle.js.LICENSE.txt index c303454e..da1e3975 100644 --- a/public/dist/THREE.bundle.js.LICENSE.txt +++ b/public/dist/THREE.bundle.js.LICENSE.txt @@ -17,6 +17,6 @@ version 0.8.2 /** * @license - * Copyright 2010-2024 Three.js Authors + * Copyright 2010-2025 Three.js Authors * SPDX-License-Identifier: MIT */ diff --git a/public/res/css/main.css b/public/res/css/main.css index a58760b6..84b7f092 100644 --- a/public/res/css/main.css +++ b/public/res/css/main.css @@ -277,11 +277,11 @@ canvas:active { height: 16px; } -/* + .aton-btn { - background-color: var(--bs-secondary-bg); + /*background-color: var(--bs-body-bg) !important;*/ + white-space: nowrap; } -*/ .aton-btn img { width: 1.5em; @@ -306,6 +306,17 @@ canvas:active { display: inline-block; } +.aton-dropdown-item img { + margin-right: 8px; + height: 20px; + width: 20px; +} +.aton-dropdown-item .bi { + margin-right: 8px; + height: 16px; + width: 16px; +} + .aton-dropdown-item:hover { background-color: var(--bs-secondary-bg); } diff --git a/public/src/ATON.ui.js b/public/src/ATON.ui.js index c6cf3398..2a655b94 100644 --- a/public/src/ATON.ui.js +++ b/public/src/ATON.ui.js @@ -355,7 +355,9 @@ UI.createButton = (options)=>{ /** Create a dropdown -- options.items: an array of objects with "title" (string) and "url" (string) properties. +- options.title: the dropdown button title +- options.icon: icon for dropdown button +- options.items: an array of objects with "title" (string) and "url" (string) properties. An optional icon can be provided @param {object} options - UI options object @returns {HTMLElement} @@ -365,7 +367,7 @@ UI.createDropdown = (options)=>{ el.classList.add("btn-group"); let elBtn = UI.createElementFromHTMLString(` - + `); if (options.icon) UI.prependIcon(elBtn, options.icon); @@ -375,8 +377,8 @@ UI.createDropdown = (options)=>{ if (options.items){ let elList = document.createElement("ul"); - elList.classList.add("dropdown-menu", "aton-dropdown-menu"); - if (options.align) elList.classList.add(options.align); + elList.classList.add("dropdown-menu", "dropdown-menu-sm-end", "aton-dropdown-menu"); + //if (options.align) elList.classList.add(options.align); for (let i=0; i{ elInGroup.append(UI.createElementFromHTMLString("")); elInGroup.append(elInput); - elInput.oninput = ()=> { + if (options.oninput) elInput.oninput = options.oninput; + else elInput.oninput = ()=> { if (!options.filterclass) return; let v = elInput.value.trim().toLowerCase(); @@ -836,7 +840,9 @@ UI.createLiveFilter = (options)=>{ } for (let item of filterItems) { - if (item.getAttribute('data-search-term').includes(v) || v.length < 1) { + let attr = item.getAttribute('data-search-term'); + + if (attr && (attr.includes(v) || v.length < 1)) { item.classList.remove('d-none'); } else { diff --git a/services/views/v2/home.ejs b/services/views/v2/home.ejs index 5285aef9..ca0c58e2 100644 --- a/services/views/v2/home.ejs +++ b/services/views/v2/home.ejs @@ -56,7 +56,7 @@ window.addEventListener( 'load', ()=>{ let elNavCont = document.getElementById("navbarSupportedContent"); let elNavItems = document.getElementById("navbarItems"); - elNavCont.append(ATON.UI.createLiveFilter({ + let elSearch = ATON.UI.createLiveFilter({ filterclass: "aton-scene-card", onfocus: ()=>{ elHero.style.display = "none"; @@ -68,7 +68,9 @@ window.addEventListener( 'load', ()=>{ if (elApps) elApps.style.display = "block"; //elStaffPick.style.display = "block"; } - })); + }) + + elNavCont.append(elSearch); let btnLogin = ATON.UI.createButton({ icon: "bi-person", @@ -112,12 +114,12 @@ window.addEventListener( 'load', ()=>{ elNavCont.append( ATON.UI.createDropdown({ icon: "bi-person", - align: "dropdown-menu-end", + //align: "dropdown-menu-end", title: u.username, items: [ { title: "My Scenes", url: "#", icon:"scene" }, { title: "My Collection", url: "#", icon:"collection" }, - { title: "Logout", url: "/v2/logout" } + { title: "Logout", url: "/v2/logout", xicon: "bi-box-arrow-left" } ] }));