From 498bf51af4bab9bdb5cf6b7d652f4c0bb08fe624 Mon Sep 17 00:00:00 2001 From: diarmidmackenzie Date: Thu, 22 Dec 2022 10:32:12 +0000 Subject: [PATCH 1/6] Moving to webpack --- package.json | 22 +++++++-------- src/drivers/worker-driver.js | 2 +- webpack.config.js | 53 ++++++++++++++++++++++++++++++++++++ webpack.prod.config.js | 12 ++++++++ 4 files changed, 76 insertions(+), 13 deletions(-) create mode 100644 webpack.config.js create mode 100644 webpack.prod.config.js diff --git a/package.json b/package.json index 12ec5331..380e6390 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,10 @@ "description": "Physics system for A-Frame VR, built on Cannon.js & Ammo.js", "main": "index.js", "scripts": { - "dev": "budo index.js:dist/aframe-physics-system.js -d examples --port 8000 -- -g browserify-shim", - "dist": "browserify -g browserify-shim index.js -o dist/aframe-physics-system.js && uglifyjs -c -o dist/aframe-physics-system.min.js -- dist/aframe-physics-system.js", + "dev": "npx webpack serve", + "dist": "npm run dist:dev && npm run dist:prod", + "dist:dev": "webpack --config webpack.config.js", + "dist:prod": "webpack --config webpack.prod.config.js", "test": "karma start ./tests/karma.conf.js", "test:once": "karma start ./tests/karma.conf.js --single-run", "test:firefox": "karma start ./tests/karma.conf.js --browsers Firefox", @@ -16,9 +18,6 @@ "version": "npm run preversion:readme && npm run dist && git add -A dist README.md", "postversion": "git push && git push --tags && npm publish" }, - "browserify-shim": { - "three": "global:THREE" - }, "repository": { "type": "git", "url": "git+https://github.com/c-frame/aframe-physics-system.git" @@ -46,19 +45,17 @@ "aframe-stats-panel": "^0.2.1", "ammo-debug-drawer": "^0.1.0", "cannon-es": "^0.9.1", - "three-to-ammo": "^0.1.0", + "three-to-ammo": "0.1.0", "three-to-cannon": "^4.0.0", - "webworkify": "^1.4.0" + "webpack": "^5.75.0", + "webpack-dev-server": "^4.11.1", + "webworkify-webpack": "^2.1.5" }, "peerDependencies": { "aframe": ">=0.5.0" }, "devDependencies": { "aframe": "~1.1.0", - "browserify": "^16.5.1", - "browserify-css": "^0.15.0", - "browserify-shim": "^3.8.14", - "budo": "^11.6.3", "chai": "^3.5.0", "chai-shallow-deep-equal": "^1.4.6", "envify": "^4.1.0", @@ -76,7 +73,8 @@ "sinon": "^2.4.1", "sinon-chai": "^2.14.0", "three": ">=0.125.0", - "uglify-es": "^3.3.9" + "uglify-es": "^3.3.9", + "webpack-cli": "^5.0.1" }, "directories": { "doc": "docs", diff --git a/src/drivers/worker-driver.js b/src/drivers/worker-driver.js index 98d91ee8..4c19d7bd 100644 --- a/src/drivers/worker-driver.js +++ b/src/drivers/worker-driver.js @@ -1,6 +1,6 @@ /* global performance */ -var webworkify = require('webworkify'), +var webworkify = require('webworkify-webpack'), webworkifyDebug = require('./webworkify-debug'), Driver = require('./driver'), Event = require('./event'), diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 00000000..a7032215 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,53 @@ +// Webpack uses this to work with directories +const path = require('path'); + +// This is the main configuration object. +// Here, you write different options and tell Webpack what to do +module.exports = { + + // Path to your entry point. From this file Webpack will begin its work + entry: './index.js', + + // Path and filename of your result bundle. + // Webpack will bundle all JavaScript into this file + output: { + path: path.resolve(__dirname, 'dist'), + publicPath: '', + filename: 'aframe-physics-system.js' + }, + + resolve: { + fallback: { + "fs": false, + "path": false + }, + }, + + devServer: { + static: { + directory: path.join(__dirname, ''), + }, + + onListening: function (devServer) { + if (!devServer) { + throw new Error('webpack-dev-server is not defined'); + } + const brightYellow = "\x1b[1m\x1b[33m" + const underscoreCyan = "\x1b[4m\x1b[36m" + const reset = "\x1b[0m" + + const port = devServer.server.address().port; + console.log(brightYellow) + console.log("***********************************************************************"); + console.log(`* View examples at ${underscoreCyan}http://localhost:${port}/examples${reset}${brightYellow} *`); + console.log("***********************************************************************"); + console.log(reset) + }, + }, + + // Default mode for Webpack is production. + // Depending on mode Webpack will apply different things + // on the final bundle. For now, we don't need production's JavaScript + // minifying and other things, so let's set mode to development + mode: 'development' +}; \ No newline at end of file diff --git a/webpack.prod.config.js b/webpack.prod.config.js new file mode 100644 index 00000000..485ce2c8 --- /dev/null +++ b/webpack.prod.config.js @@ -0,0 +1,12 @@ +var path = require('path'); +var merge = require('webpack-merge').merge; +var commonConfiguration = require('./webpack.config.js'); + +module.exports = merge(commonConfiguration, { + output: { + path: path.resolve(__dirname, 'dist'), + publicPath: '', + filename: 'aframe-physics-system.min.js' + }, + mode: 'production' +}); \ No newline at end of file From 2abbc57a8bd598c5d19b2aac80475b0fbee8b218 Mon Sep 17 00:00:00 2001 From: diarmidmackenzie Date: Thu, 22 Dec 2022 11:04:09 +0000 Subject: [PATCH 2/6] Undo three-to-ammo version change (was unintended) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 380e6390..540b7f92 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "aframe-stats-panel": "^0.2.1", "ammo-debug-drawer": "^0.1.0", "cannon-es": "^0.9.1", - "three-to-ammo": "0.1.0", + "three-to-ammo": "^0.1.0", "three-to-cannon": "^4.0.0", "webpack": "^5.75.0", "webpack-dev-server": "^4.11.1", From 1c577c62f8c9e6b627aa8a564c4365e8a90e09f4 Mon Sep 17 00:00:00 2001 From: diarmidmackenzie Date: Thu, 22 Dec 2022 11:04:26 +0000 Subject: [PATCH 3/6] publicPath not needed --- webpack.config.js | 1 - webpack.prod.config.js | 1 - 2 files changed, 2 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index a7032215..ec3d13f0 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -12,7 +12,6 @@ module.exports = { // Webpack will bundle all JavaScript into this file output: { path: path.resolve(__dirname, 'dist'), - publicPath: '', filename: 'aframe-physics-system.js' }, diff --git a/webpack.prod.config.js b/webpack.prod.config.js index 485ce2c8..b562d783 100644 --- a/webpack.prod.config.js +++ b/webpack.prod.config.js @@ -5,7 +5,6 @@ var commonConfiguration = require('./webpack.config.js'); module.exports = merge(commonConfiguration, { output: { path: path.resolve(__dirname, 'dist'), - publicPath: '', filename: 'aframe-physics-system.min.js' }, mode: 'production' From 4328caa5ef35710341809cb8c313be2fa2038573 Mon Sep 17 00:00:00 2001 From: diarmidmackenzie Date: Thu, 22 Dec 2022 11:04:39 +0000 Subject: [PATCH 4/6] Updated package-lock.json --- package-lock.json | 8128 +++++++++++++++++++++++++++++---------------- 1 file changed, 5246 insertions(+), 2882 deletions(-) diff --git a/package-lock.json b/package-lock.json index 36c8902c..b173ef00 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,14 +14,12 @@ "cannon-es": "^0.9.1", "three-to-ammo": "^0.1.0", "three-to-cannon": "^4.0.0", - "webworkify": "^1.4.0" + "webpack": "^5.75.0", + "webpack-dev-server": "^4.11.1", + "webworkify-webpack": "^2.1.5" }, "devDependencies": { "aframe": "~1.1.0", - "browserify": "^16.5.1", - "browserify-css": "^0.15.0", - "browserify-shim": "^3.8.14", - "budo": "^11.6.3", "chai": "^3.5.0", "chai-shallow-deep-equal": "^1.4.6", "envify": "^4.1.0", @@ -39,7 +37,8 @@ "sinon": "^2.4.1", "sinon-chai": "^2.14.0", "three": ">=0.125.0", - "uglify-es": "^3.3.9" + "uglify-es": "^3.3.9", + "webpack-cli": "^5.0.1" }, "engines": { "npm": ">=7" @@ -48,12 +47,219 @@ "aframe": ">=0.5.0" } }, + "node_modules/@discoveryjs/json-ext": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz", + "integrity": "sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==", + "dev": true, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", + "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", + "dependencies": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/source-map": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.2.tgz", + "integrity": "sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.17", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.17.tgz", + "integrity": "sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g==", + "dependencies": { + "@jridgewell/resolve-uri": "3.1.0", + "@jridgewell/sourcemap-codec": "1.4.14" + } + }, + "node_modules/@leichtgewicht/ip-codec": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz", + "integrity": "sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A==" + }, + "node_modules/@types/body-parser": { + "version": "1.19.2", + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz", + "integrity": "sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==", + "dependencies": { + "@types/connect": "*", + "@types/node": "*" + } + }, + "node_modules/@types/bonjour": { + "version": "3.5.10", + "resolved": "https://registry.npmjs.org/@types/bonjour/-/bonjour-3.5.10.tgz", + "integrity": "sha512-p7ienRMiS41Nu2/igbJxxLDWrSZ0WxM8UQgCeO9KhoVF7cOVFkrKsiDr1EsJIla8vV3oEEjGcz11jc5yimhzZw==", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/color-name": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", "dev": true }, + "node_modules/@types/connect": { + "version": "3.4.35", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz", + "integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/connect-history-api-fallback": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@types/connect-history-api-fallback/-/connect-history-api-fallback-1.3.5.tgz", + "integrity": "sha512-h8QJa8xSb1WD4fpKBDcATDNGXghFj6/3GRWG6dhmRcu0RX1Ubasur2Uvx5aeEwlf0MwblEC2bMzzMQntxnw/Cw==", + "dependencies": { + "@types/express-serve-static-core": "*", + "@types/node": "*" + } + }, + "node_modules/@types/eslint": { + "version": "8.4.10", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.10.tgz", + "integrity": "sha512-Sl/HOqN8NKPmhWo2VBEPm0nvHnu2LL3v9vKo8MEq0EtbJ4eVzGPl41VNPvn5E1i5poMk4/XD8UriLHpJvEP/Nw==", + "dependencies": { + "@types/estree": "*", + "@types/json-schema": "*" + } + }, + "node_modules/@types/eslint-scope": { + "version": "3.7.4", + "resolved": "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.4.tgz", + "integrity": "sha512-9K4zoImiZc3HlIp6AVUDE4CWYx22a+lhSZMYNpbjW04+YF0KWj4pJXnEMjdnFTiQibFFmElcsasJXDbdI/EPhA==", + "dependencies": { + "@types/eslint": "*", + "@types/estree": "*" + } + }, + "node_modules/@types/estree": { + "version": "0.0.51", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.51.tgz", + "integrity": "sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==" + }, + "node_modules/@types/express": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.15.tgz", + "integrity": "sha512-Yv0k4bXGOH+8a+7bELd2PqHQsuiANB+A8a4gnQrkRWzrkKlb6KHaVvyXhqs04sVW/OWlbPyYxRgYlIXLfrufMQ==", + "dependencies": { + "@types/body-parser": "*", + "@types/express-serve-static-core": "^4.17.31", + "@types/qs": "*", + "@types/serve-static": "*" + } + }, + "node_modules/@types/express-serve-static-core": { + "version": "4.17.31", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.31.tgz", + "integrity": "sha512-DxMhY+NAsTwMMFHBTtJFNp5qiHKJ7TeqOo23zVEM9alT1Ml27Q3xcTH0xwxn7Q0BbMcVEJOs/7aQtUWupUQN3Q==", + "dependencies": { + "@types/node": "*", + "@types/qs": "*", + "@types/range-parser": "*" + } + }, + "node_modules/@types/http-proxy": { + "version": "1.17.9", + "resolved": "https://registry.npmjs.org/@types/http-proxy/-/http-proxy-1.17.9.tgz", + "integrity": "sha512-QsbSjA/fSk7xB+UXlCT3wHBy5ai9wOcNDWwZAtud+jXhwOM3l+EYZh8Lng4+/6n8uar0J7xILzqftJdJ/Wdfkw==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/json-schema": { + "version": "7.0.11", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", + "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==" + }, + "node_modules/@types/mime": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz", + "integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==" + }, + "node_modules/@types/node": { + "version": "18.11.17", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.17.tgz", + "integrity": "sha512-HJSUJmni4BeDHhfzn6nF0sVmd1SMezP7/4F0Lq+aXzmp2xm9O7WXrUtHW/CHlYVtZUbByEvWidHqRtcJXGF2Ng==" + }, + "node_modules/@types/qs": { + "version": "6.9.7", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", + "integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==" + }, + "node_modules/@types/range-parser": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz", + "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==" + }, + "node_modules/@types/retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz", + "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==" + }, + "node_modules/@types/serve-index": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/@types/serve-index/-/serve-index-1.9.1.tgz", + "integrity": "sha512-d/Hs3nWDxNL2xAczmOVZNj92YZCS6RGxfBPjKzuu/XirCgXdpKEb88dYNbrYGint6IVWLNP+yonwVAuRC0T2Dg==", + "dependencies": { + "@types/express": "*" + } + }, + "node_modules/@types/serve-static": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.0.tgz", + "integrity": "sha512-z5xyF6uh8CbjAu9760KDKsH2FcDxZ2tFCsA4HIMWE6IkiYMXfVoa+4f9KX+FN0ZLsaMw1WNG2ETLA6N+/YA+cg==", + "dependencies": { + "@types/mime": "*", + "@types/node": "*" + } + }, + "node_modules/@types/sockjs": { + "version": "0.3.33", + "resolved": "https://registry.npmjs.org/@types/sockjs/-/sockjs-0.3.33.tgz", + "integrity": "sha512-f0KEEe05NvUnat+boPTZ0dgaLZ4SfSouXUgv5noUiefG2ajgKjmETo9ZJyuqsl7dfl2aHlLJUiki6B4ZYldiiw==", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/three": { "version": "0.144.0", "resolved": "https://registry.npmjs.org/@types/three/-/three-0.144.0.tgz", @@ -67,41 +273,217 @@ "resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.0.tgz", "integrity": "sha512-IUMDPSXnYIbEO2IereEFcgcqfDREOgmbGqtrMpVPpACTU6pltYLwHgVkrnYv0XhWEcjio9sYEfIEzgn3c7nDqA==" }, - "node_modules/accepts": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", - "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", - "dev": true, + "node_modules/@types/ws": { + "version": "8.5.3", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.3.tgz", + "integrity": "sha512-6YOoWjruKj1uLf3INHH7D3qTXwFfEsg1kf3c0uDdSBJwfa/llkwIjrAGV7j7mVgGNbzTQ3HiHKKDXl6bJPD97w==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@webassemblyjs/ast": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz", + "integrity": "sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw==", + "dependencies": { + "@webassemblyjs/helper-numbers": "1.11.1", + "@webassemblyjs/helper-wasm-bytecode": "1.11.1" + } + }, + "node_modules/@webassemblyjs/floating-point-hex-parser": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.1.tgz", + "integrity": "sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ==" + }, + "node_modules/@webassemblyjs/helper-api-error": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.1.tgz", + "integrity": "sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg==" + }, + "node_modules/@webassemblyjs/helper-buffer": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.1.tgz", + "integrity": "sha512-gwikF65aDNeeXa8JxXa2BAk+REjSyhrNC9ZwdT0f8jc4dQQeDQ7G4m0f2QCLPJiMTTO6wfDmRmj/pW0PsUvIcA==" + }, + "node_modules/@webassemblyjs/helper-numbers": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.1.tgz", + "integrity": "sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ==", + "dependencies": { + "@webassemblyjs/floating-point-hex-parser": "1.11.1", + "@webassemblyjs/helper-api-error": "1.11.1", + "@xtuc/long": "4.2.2" + } + }, + "node_modules/@webassemblyjs/helper-wasm-bytecode": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.1.tgz", + "integrity": "sha512-PvpoOGiJwXeTrSf/qfudJhwlvDQxFgelbMqtq52WWiXC6Xgg1IREdngmPN3bs4RoO83PnL/nFrxucXj1+BX62Q==" + }, + "node_modules/@webassemblyjs/helper-wasm-section": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.1.tgz", + "integrity": "sha512-10P9No29rYX1j7F3EVPX3JvGPQPae+AomuSTPiF9eBQeChHI6iqjMIwR9JmOJXwpnn/oVGDk7I5IlskuMwU/pg==", + "dependencies": { + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/helper-buffer": "1.11.1", + "@webassemblyjs/helper-wasm-bytecode": "1.11.1", + "@webassemblyjs/wasm-gen": "1.11.1" + } + }, + "node_modules/@webassemblyjs/ieee754": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.11.1.tgz", + "integrity": "sha512-hJ87QIPtAMKbFq6CGTkZYJivEwZDbQUgYd3qKSadTNOhVY7p+gfP6Sr0lLRVTaG1JjFj+r3YchoqRYxNH3M0GQ==", + "dependencies": { + "@xtuc/ieee754": "^1.2.0" + } + }, + "node_modules/@webassemblyjs/leb128": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.11.1.tgz", + "integrity": "sha512-BJ2P0hNZ0u+Th1YZXJpzW6miwqQUGcIHT1G/sf72gLVD9DZ5AdYTqPNbHZh6K1M5VmKvFXwGSWZADz+qBWxeRw==", + "dependencies": { + "@xtuc/long": "4.2.2" + } + }, + "node_modules/@webassemblyjs/utf8": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.11.1.tgz", + "integrity": "sha512-9kqcxAEdMhiwQkHpkNiorZzqpGrodQQ2IGrHHxCy+Ozng0ofyMA0lTqiLkVs1uzTRejX+/O0EOT7KxqVPuXosQ==" + }, + "node_modules/@webassemblyjs/wasm-edit": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.1.tgz", + "integrity": "sha512-g+RsupUC1aTHfR8CDgnsVRVZFJqdkFHpsHMfJuWQzWU3tvnLC07UqHICfP+4XyL2tnr1amvl1Sdp06TnYCmVkA==", + "dependencies": { + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/helper-buffer": "1.11.1", + "@webassemblyjs/helper-wasm-bytecode": "1.11.1", + "@webassemblyjs/helper-wasm-section": "1.11.1", + "@webassemblyjs/wasm-gen": "1.11.1", + "@webassemblyjs/wasm-opt": "1.11.1", + "@webassemblyjs/wasm-parser": "1.11.1", + "@webassemblyjs/wast-printer": "1.11.1" + } + }, + "node_modules/@webassemblyjs/wasm-gen": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.1.tgz", + "integrity": "sha512-F7QqKXwwNlMmsulj6+O7r4mmtAlCWfO/0HdgOxSklZfQcDu0TpLiD1mRt/zF25Bk59FIjEuGAIyn5ei4yMfLhA==", + "dependencies": { + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/helper-wasm-bytecode": "1.11.1", + "@webassemblyjs/ieee754": "1.11.1", + "@webassemblyjs/leb128": "1.11.1", + "@webassemblyjs/utf8": "1.11.1" + } + }, + "node_modules/@webassemblyjs/wasm-opt": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.1.tgz", + "integrity": "sha512-VqnkNqnZlU5EB64pp1l7hdm3hmQw7Vgqa0KF/KCNO9sIpI6Fk6brDEiX+iCOYrvMuBWDws0NkTOxYEb85XQHHw==", + "dependencies": { + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/helper-buffer": "1.11.1", + "@webassemblyjs/wasm-gen": "1.11.1", + "@webassemblyjs/wasm-parser": "1.11.1" + } + }, + "node_modules/@webassemblyjs/wasm-parser": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.1.tgz", + "integrity": "sha512-rrBujw+dJu32gYB7/Lup6UhdkPx9S9SnobZzRVL7VcBH9Bt9bCBLEuX/YXOOtBsOZ4NQrRykKhffRWHvigQvOA==", + "dependencies": { + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/helper-api-error": "1.11.1", + "@webassemblyjs/helper-wasm-bytecode": "1.11.1", + "@webassemblyjs/ieee754": "1.11.1", + "@webassemblyjs/leb128": "1.11.1", + "@webassemblyjs/utf8": "1.11.1" + } + }, + "node_modules/@webassemblyjs/wast-printer": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.11.1.tgz", + "integrity": "sha512-IQboUWM4eKzWW+N/jij2sRatKMh99QEelo3Eb2q0qXkvPRISAj8Qxtmw5itwqK+TTkBuUIE45AxYPToqPtL5gg==", "dependencies": { - "mime-types": "~2.1.24", - "negotiator": "0.6.2" + "@webassemblyjs/ast": "1.11.1", + "@xtuc/long": "4.2.2" + } + }, + "node_modules/@webpack-cli/configtest": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-2.0.1.tgz", + "integrity": "sha512-njsdJXJSiS2iNbQVS0eT8A/KPnmyH4pv1APj2K0d1wrZcBLw+yppxOy4CGqa0OxDJkzfL/XELDhD8rocnIwB5A==", + "dev": true, + "engines": { + "node": ">=14.15.0" }, + "peerDependencies": { + "webpack": "5.x.x", + "webpack-cli": "5.x.x" + } + }, + "node_modules/@webpack-cli/info": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@webpack-cli/info/-/info-2.0.1.tgz", + "integrity": "sha512-fE1UEWTwsAxRhrJNikE7v4EotYflkEhBL7EbajfkPlf6E37/2QshOy/D48Mw8G5XMFlQtS6YV42vtbG9zBpIQA==", + "dev": true, "engines": { - "node": ">= 0.6" + "node": ">=14.15.0" + }, + "peerDependencies": { + "webpack": "5.x.x", + "webpack-cli": "5.x.x" } }, - "node_modules/accessory": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/accessory/-/accessory-1.1.0.tgz", - "integrity": "sha1-eDPpg5oy3tdtJgIfNqQXB6Ug9ZM=", + "node_modules/@webpack-cli/serve": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-2.0.1.tgz", + "integrity": "sha512-0G7tNyS+yW8TdgHwZKlDWYXFA6OJQnoLCQvYKkQP0Q2X205PSQ6RNUj0M+1OB/9gRQaUZ/ccYfaxd0nhaWKfjw==", "dev": true, - "dependencies": { - "ap": "~0.2.0", - "balanced-match": "~0.2.0", - "dot-parts": "~1.0.0" + "engines": { + "node": ">=14.15.0" + }, + "peerDependencies": { + "webpack": "5.x.x", + "webpack-cli": "5.x.x" + }, + "peerDependenciesMeta": { + "webpack-dev-server": { + "optional": true + } } }, - "node_modules/accessory/node_modules/balanced-match": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.2.1.tgz", - "integrity": "sha1-e8ZYtL7WHu5CStdPdfXD4sTfPMc=", - "dev": true + "node_modules/@xtuc/ieee754": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz", + "integrity": "sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==" + }, + "node_modules/@xtuc/long": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz", + "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==" + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } }, "node_modules/acorn": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.2.0.tgz", "integrity": "sha512-apwXVmYVpQ34m/i71vrApRrRKCWQnZZF1+npOD0WV5xZFfwWOmKGQ2RWlfdy9vWITsenisM8M0Qeq8agcFHNiQ==", "dev": true, + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -114,6 +496,7 @@ "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.8.2.tgz", "integrity": "sha512-8mt+fslDufLYntIoPAaIMUe/lrbrehIiwmR3t2k9LljIzoigEPF27eLk2hy8zSGzmR/ogr7zbRKINMo1u0yh5A==", "dev": true, + "peer": true, "dependencies": { "acorn": "^7.0.0", "acorn-walk": "^7.0.0", @@ -125,6 +508,7 @@ "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", "dev": true, + "peer": true, "engines": { "node": ">=0.4" } @@ -134,6 +518,7 @@ "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.1.1.tgz", "integrity": "sha512-wdlPY2tm/9XBr7QkKlq0WQVgiuGTX6YWPyRyBviSoScBuLfTVQhvwg6wJ369GJ/1nPfTLMfnrFIfjqVg6d+jQQ==", "dev": true, + "peer": true, "engines": { "node": ">=0.4.0" } @@ -180,14 +565,63 @@ "integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=", "dev": true }, - "node_modules/amdefine": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", - "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", - "dev": true, - "optional": true, - "engines": { - "node": ">=0.4.2" + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ajv-formats": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz", + "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", + "dependencies": { + "ajv": "^8.0.0" + }, + "peerDependencies": { + "ajv": "^8.0.0" + }, + "peerDependenciesMeta": { + "ajv": { + "optional": true + } + } + }, + "node_modules/ajv-formats/node_modules/ajv": { + "version": "8.11.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.2.tgz", + "integrity": "sha512-E4bfmKAhGiSTvMfL1Myyycaub+cUEU2/IvpylXkUu7CHBkBj1f/ikdzbD7YQ6FKUbixDxeYvB/xY4fvyroDlQg==", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ajv-formats/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" + }, + "node_modules/ajv-keywords": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", + "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", + "peerDependencies": { + "ajv": "^6.9.1" } }, "node_modules/ammo-debug-drawer": { @@ -210,22 +644,15 @@ "node": ">=6" } }, - "node_modules/ansi-regex": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz", - "integrity": "sha1-DY6UaWej2BQ/k+JOKYUl/BsiNfk=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/ansi-styles": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.1.0.tgz", - "integrity": "sha1-6uy/Zs1waIJ2Cy9GkVgrj1XXp94=", - "dev": true, - "engines": { - "node": ">=0.10.0" + "node_modules/ansi-html-community": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/ansi-html-community/-/ansi-html-community-0.0.8.tgz", + "integrity": "sha512-1APHAyr3+PCamwNw3bXCPp4HFLONZt/yIH0sZp0/469KWNTEy+qN5jQ3GVX6DMZ1UXAi34yVwtTeaG/HpBuuzw==", + "engines": [ + "node >= 0.8.0" + ], + "bin": { + "ansi-html": "bin/ansi-html" } }, "node_modules/anymatch": { @@ -233,6 +660,7 @@ "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", "dev": true, + "peer": true, "dependencies": { "micromatch": "^3.1.4", "normalize-path": "^2.1.1" @@ -243,6 +671,7 @@ "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", "dev": true, + "peer": true, "dependencies": { "remove-trailing-separator": "^1.0.1" }, @@ -250,12 +679,6 @@ "node": ">=0.10.0" } }, - "node_modules/ap": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/ap/-/ap-0.2.0.tgz", - "integrity": "sha1-rglCYAspkS8NKxTsYMRejzMLYRA=", - "dev": true - }, "node_modules/argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -270,6 +693,7 @@ "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -279,6 +703,7 @@ "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -288,10 +713,16 @@ "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } }, + "node_modules/array-flatten": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-2.1.2.tgz", + "integrity": "sha512-hNfzcOV8W4NdualtqBFPyVO+54DSJuZGY9qT4pRroB6S9e3iiido2ISIC5h9R2sPJ8H3FHCIiEnsv1lPXO3KtQ==" + }, "node_modules/array-shuffle": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/array-shuffle/-/array-shuffle-1.0.1.tgz", @@ -306,6 +737,7 @@ "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -327,6 +759,7 @@ "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", "dev": true, + "peer": true, "dependencies": { "bn.js": "^4.0.0", "inherits": "^2.0.1", @@ -337,13 +770,15 @@ "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true + "dev": true, + "peer": true }, "node_modules/assert": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/assert/-/assert-1.5.0.tgz", "integrity": "sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA==", "dev": true, + "peer": true, "dependencies": { "object-assign": "^4.1.1", "util": "0.10.3" @@ -353,13 +788,15 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", - "dev": true + "dev": true, + "peer": true }, "node_modules/assert/node_modules/util": { "version": "0.10.3", "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", "dev": true, + "peer": true, "dependencies": { "inherits": "2.0.1" } @@ -378,6 +815,7 @@ "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -395,7 +833,8 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==", - "dev": true + "dev": true, + "peer": true }, "node_modules/async-limiter": { "version": "1.0.1", @@ -408,6 +847,7 @@ "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", "dev": true, + "peer": true, "bin": { "atob": "bin/atob.js" }, @@ -424,14 +864,14 @@ "node_modules/balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, "node_modules/base": { "version": "0.11.2", "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", "dev": true, + "peer": true, "dependencies": { "cache-base": "^1.0.1", "class-utils": "^0.3.5", @@ -450,6 +890,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, + "peer": true, "dependencies": { "is-descriptor": "^1.0.0" }, @@ -462,6 +903,7 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, + "peer": true, "dependencies": { "kind-of": "^6.0.0" }, @@ -474,6 +916,7 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, + "peer": true, "dependencies": { "kind-of": "^6.0.0" }, @@ -486,6 +929,7 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, + "peer": true, "dependencies": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -508,7 +952,8 @@ "version": "1.3.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==", - "dev": true + "dev": true, + "peer": true }, "node_modules/base64id": { "version": "1.0.0", @@ -519,6 +964,11 @@ "node": ">= 0.4.0" } }, + "node_modules/batch": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz", + "integrity": "sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw==" + }, "node_modules/better-assert": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz", @@ -536,10 +986,22 @@ "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } }, + "node_modules/bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "dev": true, + "optional": true, + "peer": true, + "dependencies": { + "file-uri-to-path": "1.0.0" + } + }, "node_modules/blob": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz", @@ -556,61 +1018,58 @@ "version": "5.1.1", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.1.1.tgz", "integrity": "sha512-IUTD/REb78Z2eodka1QZyyEk66pciRcP6Sroka0aI3tG/iwIdYLrBD62RsubR7vqdt3WyX8p4jxeatzmRSphtA==", - "dev": true + "dev": true, + "peer": true }, "node_modules/body-parser": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", - "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", - "dev": true, + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", + "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", "dependencies": { - "bytes": "3.1.0", + "bytes": "3.1.2", "content-type": "~1.0.4", "debug": "2.6.9", - "depd": "~1.1.2", - "http-errors": "1.7.2", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", "iconv-lite": "0.4.24", - "on-finished": "~2.3.0", - "qs": "6.7.0", - "raw-body": "2.4.0", - "type-is": "~1.6.17" + "on-finished": "2.4.1", + "qs": "6.11.0", + "raw-body": "2.5.1", + "type-is": "~1.6.18", + "unpipe": "1.0.0" }, "engines": { - "node": ">= 0.8" + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" } }, - "node_modules/body-parser/node_modules/http-errors": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", - "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", - "dev": true, + "node_modules/body-parser/node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", "dependencies": { - "depd": "~1.1.2", - "inherits": "2.0.3", - "setprototypeof": "1.1.1", - "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.0" + "ee-first": "1.1.1" }, "engines": { - "node": ">= 0.6" + "node": ">= 0.8" } }, - "node_modules/bole": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/bole/-/bole-2.0.0.tgz", - "integrity": "sha1-2KocaQRnv7T+Ebh0rLLoOH44JhU=", - "dev": true, + "node_modules/bonjour-service": { + "version": "1.0.14", + "resolved": "https://registry.npmjs.org/bonjour-service/-/bonjour-service-1.0.14.tgz", + "integrity": "sha512-HIMbgLnk1Vqvs6B4Wq5ep7mxvj9sGz5d1JJyDNSGNIdA/w2MCz6GTjWTdjqOJV1bEPj+6IkxDvWNFKEBxNt4kQ==", "dependencies": { - "core-util-is": ">=1.0.1 <1.1.0-0", - "individual": ">=3.0.0 <3.1.0-0", - "json-stringify-safe": ">=5.0.0 <5.1.0-0" + "array-flatten": "^2.1.2", + "dns-equal": "^1.0.0", + "fast-deep-equal": "^3.1.3", + "multicast-dns": "^7.2.5" } }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -621,6 +1080,7 @@ "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", "dev": true, + "peer": true, "dependencies": { "arr-flatten": "^1.1.0", "array-unique": "^0.3.2", @@ -642,6 +1102,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, + "peer": true, "dependencies": { "is-extendable": "^0.1.0" }, @@ -653,13 +1114,15 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", - "dev": true + "dev": true, + "peer": true }, "node_modules/browser-pack": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.1.0.tgz", "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==", "dev": true, + "peer": true, "dependencies": { "combine-source-map": "~0.8.0", "defined": "^1.0.0", @@ -677,6 +1140,7 @@ "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.3.tgz", "integrity": "sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ==", "dev": true, + "peer": true, "dependencies": { "resolve": "1.1.7" } @@ -685,7 +1149,8 @@ "version": "1.1.7", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", - "dev": true + "dev": true, + "peer": true }, "node_modules/browser-stdout": { "version": "1.3.1", @@ -698,6 +1163,7 @@ "resolved": "https://registry.npmjs.org/browserify/-/browserify-16.5.1.tgz", "integrity": "sha512-EQX0h59Pp+0GtSRb5rL6OTfrttlzv+uyaUVlK6GX3w11SQ0jKPKyjC/54RhPR2ib2KmfcELM06e8FxcI5XNU2A==", "dev": true, + "peer": true, "dependencies": { "assert": "^1.4.0", "browser-pack": "^6.0.1", @@ -760,6 +1226,7 @@ "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "dev": true, + "peer": true, "dependencies": { "buffer-xor": "^1.0.3", "cipher-base": "^1.0.0", @@ -774,33 +1241,19 @@ "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", "dev": true, + "peer": true, "dependencies": { "browserify-aes": "^1.0.4", "browserify-des": "^1.0.0", "evp_bytestokey": "^1.0.0" } }, - "node_modules/browserify-css": { - "version": "0.15.0", - "resolved": "https://registry.npmjs.org/browserify-css/-/browserify-css-0.15.0.tgz", - "integrity": "sha512-ZgLHyZ16PH6P25JlBE+5xNtdobpkc5Egh+ctc8ha3GDtuZqSSQu0ovOxOQvXt0xAmaXixth/DY9iT56HlDOxyg==", - "dev": true, - "dependencies": { - "clean-css": "^4.1.5", - "concat-stream": "^1.6.0", - "css": "^2.2.1", - "find-node-modules": "^2.0.0", - "lodash": "^4.17.11", - "mime": "^1.3.6", - "strip-css-comments": "^3.0.0", - "through2": "2.0.x" - } - }, "node_modules/browserify-des": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", "dev": true, + "peer": true, "dependencies": { "cipher-base": "^1.0.1", "des.js": "^1.0.0", @@ -813,6 +1266,7 @@ "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", "dev": true, + "peer": true, "dependencies": { "bn.js": "^4.1.0", "randombytes": "^2.0.1" @@ -822,35 +1276,15 @@ "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true - }, - "node_modules/browserify-shim": { - "version": "3.8.14", - "resolved": "https://registry.npmjs.org/browserify-shim/-/browserify-shim-3.8.14.tgz", - "integrity": "sha1-vxBXAmky0yU8de991xTzuHft7Gs=", "dev": true, - "dependencies": { - "exposify": "~0.5.0", - "mothership": "~0.2.0", - "rename-function-calls": "~0.1.0", - "resolve": "~0.6.1", - "through": "~2.3.4" - }, - "peerDependencies": { - "browserify": ">= 2.3" - } - }, - "node_modules/browserify-shim/node_modules/resolve": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-0.6.3.tgz", - "integrity": "sha1-3ZV5gufnNt699TtYpN2RdUV13UY=", - "dev": true + "peer": true }, "node_modules/browserify-sign": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.1.0.tgz", "integrity": "sha512-VYxo7cDCeYUoBZ0ZCy4UyEUCP3smyBd4DRQM5nrFS1jJjPJjX7rP3oLRpPoWfkhQfyJ0I9ZbHbKafrFD/SGlrg==", "dev": true, + "peer": true, "dependencies": { "bn.js": "^5.1.1", "browserify-rsa": "^4.0.1", @@ -866,13 +1300,15 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "dev": true, + "peer": true }, "node_modules/browserify-sign/node_modules/readable-stream": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", "dev": true, + "peer": true, "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -887,6 +1323,7 @@ "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", "dev": true, + "peer": true, "dependencies": { "pako": "~1.0.5" } @@ -896,58 +1333,36 @@ "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", "dev": true, + "peer": true, "engines": { "node": ">= 0.6.0" } }, - "node_modules/budo": { - "version": "11.6.3", - "resolved": "https://registry.npmjs.org/budo/-/budo-11.6.3.tgz", - "integrity": "sha512-U9pV6SoSxGduY/wnoIlDwEEUhxtTFqYqoyWvi3B5nJ/abSxuNmolfAfzgOQIEXqtHhPEA4FlM+VNzdEDOjpIjw==", - "dev": true, + "node_modules/browserslist": { + "version": "4.21.4", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.4.tgz", + "integrity": "sha512-CBHJJdDmgjl3daYjN5Cp5kbTf1mUhZoS+beLklHIvkOWscs83YAhLlF3Wsh/lciQYAcbBJgTOD44VtG31ZM4Hw==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + } + ], "dependencies": { - "bole": "^2.0.0", - "browserify": "^16.2.3", - "chokidar": "^2.0.4", - "connect-pushstate": "^1.1.0", - "escape-html": "^1.0.3", - "events": "^1.0.2", - "garnish": "^5.0.0", - "get-ports": "^1.0.2", - "inject-lr-script": "^2.1.0", - "internal-ip": "^3.0.1", - "micromatch": "^3.1.10", - "on-finished": "^2.3.0", - "on-headers": "^1.0.1", - "once": "^1.3.2", - "opn": "^3.0.2", - "path-is-absolute": "^1.0.1", - "pem": "^1.13.2", - "reload-css": "^1.0.0", - "resolve": "^1.1.6", - "serve-static": "^1.10.0", - "simple-html-index": "^1.4.0", - "stacked": "^1.1.1", - "stdout-stream": "^1.4.0", - "strip-ansi": "^3.0.0", - "subarg": "^1.0.0", - "term-color": "^1.0.1", - "url-trim": "^1.0.0", - "watchify-middleware": "^1.8.2", - "ws": "^6.2.1", - "xtend": "^4.0.0" + "caniuse-lite": "^1.0.30001400", + "electron-to-chromium": "^1.4.251", + "node-releases": "^2.0.6", + "update-browserslist-db": "^1.0.9" }, "bin": { - "budo": "bin/cmd.js" - } - }, - "node_modules/budo/node_modules/events": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", - "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", - "dev": true, + "browserslist": "cli.js" + }, "engines": { - "node": ">=0.4.x" + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, "node_modules/buffer": { @@ -955,6 +1370,7 @@ "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", "integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==", "dev": true, + "peer": true, "dependencies": { "base64-js": "^1.0.2", "ieee754": "^1.1.4" @@ -994,8 +1410,7 @@ "node_modules/buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", - "dev": true + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" }, "node_modules/buffer-to-arraybuffer": { "version": "0.0.5", @@ -1007,19 +1422,20 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", - "dev": true + "dev": true, + "peer": true }, "node_modules/builtin-status-codes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", - "dev": true + "dev": true, + "peer": true }, "node_modules/bytes": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", - "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==", - "dev": true, + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", "engines": { "node": ">= 0.8" } @@ -1029,6 +1445,7 @@ "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", "dev": true, + "peer": true, "dependencies": { "collection-visit": "^1.0.0", "component-emitter": "^1.2.1", @@ -1048,7 +1465,20 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.0.2.tgz", "integrity": "sha512-5r2GqsoEb4qMTTN9J+WzXfjov+hjxT+j3u5K+kIVNIwAd99DLCJE9pBIMP1qVeybV6JiijL385Oz0DcYxfbOIg==", - "dev": true + "dev": true, + "peer": true + }, + "node_modules/call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dependencies": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, "node_modules/callsite": { "version": "1.0.0", @@ -1068,6 +1498,21 @@ "node": ">=6" } }, + "node_modules/caniuse-lite": { + "version": "1.0.30001441", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001441.tgz", + "integrity": "sha512-OyxRR4Vof59I3yGWXws6i908EtGbMzVUi3ganaZQHmydk1iwDhRnvaPG2WaR0KcqrDFKrxVZHULT396LEPhXfg==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + } + ] + }, "node_modules/cannon-es": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/cannon-es/-/cannon-es-0.9.1.tgz", @@ -1110,52 +1555,13 @@ "chai": ">= 1.9.0" } }, - "node_modules/chalk": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz", - "integrity": "sha1-Zjs6ZItotV0EaQ1JFnqoN4WPIXQ=", - "dev": true, - "dependencies": { - "ansi-styles": "^1.1.0", - "escape-string-regexp": "^1.0.0", - "has-ansi": "^0.1.0", - "strip-ansi": "^0.3.0", - "supports-color": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/chalk/node_modules/strip-ansi": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz", - "integrity": "sha1-JfSOoiynkYfzF0pNuHWTR7sSYiA=", - "dev": true, - "dependencies": { - "ansi-regex": "^0.2.1" - }, - "bin": { - "strip-ansi": "cli.js" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/charenc": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", - "integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc=", - "dev": true, - "engines": { - "node": "*" - } - }, "node_modules/chokidar": { "version": "2.1.8", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", "integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==", "deprecated": "Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies", "dev": true, + "peer": true, "dependencies": { "anymatch": "^2.0.0", "async-each": "^1.0.1", @@ -1173,11 +1579,40 @@ "fsevents": "^1.2.7" } }, + "node_modules/chokidar/node_modules/fsevents": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", + "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", + "deprecated": "fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "peer": true, + "dependencies": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + }, + "engines": { + "node": ">= 4.0" + } + }, + "node_modules/chrome-trace-event": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz", + "integrity": "sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==", + "engines": { + "node": ">=6.0" + } + }, "node_modules/cipher-base": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", "dev": true, + "peer": true, "dependencies": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" @@ -1188,6 +1623,7 @@ "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", "dev": true, + "peer": true, "dependencies": { "arr-union": "^3.1.0", "define-property": "^0.2.5", @@ -1203,6 +1639,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, + "peer": true, "dependencies": { "is-descriptor": "^0.1.0" }, @@ -1210,27 +1647,6 @@ "node": ">=0.10.0" } }, - "node_modules/clean-css": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.3.tgz", - "integrity": "sha512-VcMWDN54ZN/DS+g58HYL5/n4Zrqe8vHJpGA8KdgUXFU4fuP/aHNw8eld9SyEIyabIMJX/0RaY/fplOo5hYLSFA==", - "dev": true, - "dependencies": { - "source-map": "~0.6.0" - }, - "engines": { - "node": ">= 4.0" - } - }, - "node_modules/clean-css/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/cliui": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", @@ -1277,11 +1693,26 @@ "node": ">=6" } }, + "node_modules/clone-deep": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-4.0.1.tgz", + "integrity": "sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==", + "dev": true, + "dependencies": { + "is-plain-object": "^2.0.4", + "kind-of": "^6.0.2", + "shallow-clone": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/collection-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", "dev": true, + "peer": true, "dependencies": { "map-visit": "^1.0.0", "object-visit": "^1.0.0" @@ -1305,6 +1736,11 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, + "node_modules/colorette": { + "version": "2.0.19", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.19.tgz", + "integrity": "sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ==" + }, "node_modules/colors": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", @@ -1319,6 +1755,7 @@ "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.8.0.tgz", "integrity": "sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos=", "dev": true, + "peer": true, "dependencies": { "convert-source-map": "~1.1.0", "inline-source-map": "~0.6.0", @@ -1342,7 +1779,8 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", - "dev": true + "dev": true, + "peer": true }, "node_modules/component-inherit": { "version": "0.0.3", @@ -1350,11 +1788,51 @@ "integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM=", "dev": true }, + "node_modules/compressible": { + "version": "2.0.18", + "resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.18.tgz", + "integrity": "sha512-AF3r7P5dWxL8MxyITRMlORQNaOA2IkAFaTr4k7BUumjPtRpGDTZpl0Pb1XCO6JeDCBdp126Cgs9sMxqSjgYyRg==", + "dependencies": { + "mime-db": ">= 1.43.0 < 2" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/compression": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/compression/-/compression-1.7.4.tgz", + "integrity": "sha512-jaSIDzP9pZVS4ZfQ+TzvtiWhdpFhE2RDHz8QJkpX9SIpLq88VueF5jJw6t+6CUQcAoA6t+x89MLrWAqpfDE8iQ==", + "dependencies": { + "accepts": "~1.3.5", + "bytes": "3.0.0", + "compressible": "~2.0.16", + "debug": "2.6.9", + "on-headers": "~1.0.2", + "safe-buffer": "5.1.2", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/compression/node_modules/bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha512-pMhOfFDPiv9t5jjIXkHosWmkSyQbvsgEVNkz0ERHbuLh2T/7j4Mqqpz523Fe8MVY89KC6Sh/QfS2sM+SjgFDcw==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/compression/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, "node_modules/concat-stream": { "version": "1.6.2", @@ -1364,6 +1842,7 @@ "engines": [ "node >= 0.8" ], + "peer": true, "dependencies": { "buffer-from": "^1.0.0", "inherits": "^2.0.3", @@ -1386,29 +1865,43 @@ "node": ">= 0.10.0" } }, - "node_modules/connect-pushstate": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/connect-pushstate/-/connect-pushstate-1.1.0.tgz", - "integrity": "sha1-vKsiQnHEOWBKD7D2FMCl9WPojiQ=", - "dev": true + "node_modules/connect-history-api-fallback": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-2.0.0.tgz", + "integrity": "sha512-U73+6lQFmfiNPrYbXqr6kZ1i1wiRqXnp2nhMsINseWXO8lDau0LGEffJ8kQi4EjLZympVgRdvqjAgiZ1tgzDDA==", + "engines": { + "node": ">=0.8" + } }, "node_modules/console-browserify": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.2.0.tgz", "integrity": "sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA==", - "dev": true + "dev": true, + "peer": true }, "node_modules/constants-browserify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=", - "dev": true + "dev": true, + "peer": true + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } }, "node_modules/content-type": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", - "dev": true, "engines": { "node": ">= 0.6" } @@ -1428,11 +1921,17 @@ "node": ">= 0.6" } }, + "node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" + }, "node_modules/copy-descriptor": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -1440,14 +1939,14 @@ "node_modules/core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, "node_modules/create-ecdh": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", "dev": true, + "peer": true, "dependencies": { "bn.js": "^4.1.0", "elliptic": "^6.0.0" @@ -1457,13 +1956,15 @@ "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true + "dev": true, + "peer": true }, "node_modules/create-hash": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "dev": true, + "peer": true, "dependencies": { "cipher-base": "^1.0.1", "inherits": "^2.0.1", @@ -1477,6 +1978,7 @@ "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "dev": true, + "peer": true, "dependencies": { "cipher-base": "^1.0.3", "create-hash": "^1.1.0", @@ -1486,36 +1988,12 @@ "sha.js": "^2.4.8" } }, - "node_modules/cross-spawn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", - "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", - "dev": true, - "dependencies": { - "nice-try": "^1.0.4", - "path-key": "^2.0.1", - "semver": "^5.5.0", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - }, - "engines": { - "node": ">=4.8" - } - }, - "node_modules/crypt": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", - "integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs=", - "dev": true, - "engines": { - "node": "*" - } - }, "node_modules/crypto-browserify": { "version": "3.12.0", "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", "dev": true, + "peer": true, "dependencies": { "browserify-cipher": "^1.0.0", "browserify-sign": "^4.0.0", @@ -1533,27 +2011,6 @@ "node": "*" } }, - "node_modules/css": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/css/-/css-2.2.4.tgz", - "integrity": "sha512-oUnjmWpy0niI3x/mPL8dVEI1l7MnG3+HHyRPHf+YFSbK+svOhXpmSOcDURUh2aOCgl2grzrOPt1nHLuCVFULLw==", - "dev": true, - "dependencies": { - "inherits": "^2.0.3", - "source-map": "^0.6.1", - "source-map-resolve": "^0.5.2", - "urix": "^0.1.0" - } - }, - "node_modules/css/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/custom-event": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz", @@ -1570,7 +2027,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/dash-ast/-/dash-ast-1.0.0.tgz", "integrity": "sha512-Vy4dx7gquTeMcQR/hDkYLGUnwVil6vk4FOOct+djUnHOUWt+zJPJAaRIXaAFkPXtJjvlY7o3rfRu0/3hpnwoUA==", - "dev": true + "dev": true, + "peer": true }, "node_modules/date-format": { "version": "2.1.0", @@ -1582,17 +2040,10 @@ "node": ">=4.0" } }, - "node_modules/debounce": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/debounce/-/debounce-1.2.0.tgz", - "integrity": "sha512-mYtLl1xfZLi1m4RtQYlZgJUNQjl4ZxVnHzIR8nLLgi4q1YT8o/WM+MK/f8yfcc9s5Ir5zRaPZyZU6xs1Syoocg==", - "dev": true - }, "node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, "dependencies": { "ms": "2.0.0" } @@ -1660,26 +2111,12 @@ "node": "*" } }, - "node_modules/default-gateway": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/default-gateway/-/default-gateway-2.7.2.tgz", - "integrity": "sha512-lAc4i9QJR0YHSDFdzeBQKfZ1SRDG3hsJNEkrpcZa8QhBfidLAilT60BDEIVUUGqosFp425KOgB3uYqcnQrWafQ==", - "dev": true, - "os": [ - "android", - "darwin", - "freebsd", - "linux", - "openbsd", - "sunos", - "win32" - ], - "dependencies": { - "execa": "^0.10.0", - "ip-regex": "^2.1.0" - }, + "node_modules/define-lazy-prop": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", + "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==", "engines": { - "node": ">=4" + "node": ">=8" } }, "node_modules/define-properties": { @@ -1699,6 +2136,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", "dev": true, + "peer": true, "dependencies": { "is-descriptor": "^1.0.2", "isobject": "^3.0.1" @@ -1712,6 +2150,7 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, + "peer": true, "dependencies": { "kind-of": "^6.0.0" }, @@ -1724,6 +2163,7 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, + "peer": true, "dependencies": { "kind-of": "^6.0.0" }, @@ -1736,6 +2176,7 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, + "peer": true, "dependencies": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -1749,15 +2190,15 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", - "dev": true + "dev": true, + "peer": true }, "node_modules/depd": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", - "dev": true, + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", "engines": { - "node": ">= 0.6" + "node": ">= 0.8" } }, "node_modules/deps-sort": { @@ -1765,6 +2206,7 @@ "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-2.0.1.tgz", "integrity": "sha512-1orqXQr5po+3KI6kQb9A4jnXT1PBwggGl2d7Sq2xsnOeI9GPcE/tGcF9UiSZtZBM7MukY4cAh7MemS6tZYipfw==", "dev": true, + "peer": true, "dependencies": { "JSONStream": "^1.0.3", "shasum-object": "^1.0.0", @@ -1780,31 +2222,32 @@ "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz", "integrity": "sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA==", "dev": true, + "peer": true, "dependencies": { "inherits": "^2.0.1", "minimalistic-assert": "^1.0.0" } }, "node_modules/destroy": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", - "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=", - "dev": true - }, - "node_modules/detect-file": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", - "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", - "dev": true, + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", "engines": { - "node": ">=0.10.0" + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/detect-node": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.1.0.tgz", + "integrity": "sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==" + }, "node_modules/detective": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/detective/-/detective-5.2.0.tgz", "integrity": "sha512-6SsIx+nUUbuK0EthKjv0zrdnajCCXVYGmbYYiYjFVpzcjwEs/JMDZ8tPRG29J/HhN56t3GJp2cGSWDRjjot8Pg==", "dev": true, + "peer": true, "dependencies": { "acorn-node": "^1.6.1", "defined": "^1.0.0", @@ -1837,6 +2280,7 @@ "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", "dev": true, + "peer": true, "dependencies": { "bn.js": "^4.1.0", "miller-rabin": "^4.0.0", @@ -1847,7 +2291,24 @@ "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true + "dev": true, + "peer": true + }, + "node_modules/dns-equal": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/dns-equal/-/dns-equal-1.0.0.tgz", + "integrity": "sha512-z+paD6YUQsk+AbGCEM4PrOXSss5gd66QfcVBFTKR/HpFL9jCqikS94HYwKww6fQyO7IxrIIyUu+g0Ka9tUS2Cg==" + }, + "node_modules/dns-packet": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-5.4.0.tgz", + "integrity": "sha512-EgqGeaBB8hLiHLZtp/IbaDQTL8pZ0+IvwzSHA6d7VyMDM+B9hgddEMa9xjK5oYnw0ci0JQ6g2XCD7/f6cafU6g==", + "dependencies": { + "@leichtgewicht/ip-codec": "^2.0.1" + }, + "engines": { + "node": ">=6" + } }, "node_modules/document-register-element": { "version": "0.5.4", @@ -1879,17 +2340,12 @@ "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", "integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==", "dev": true, + "peer": true, "engines": { "node": ">=0.4", "npm": ">=1.2" } }, - "node_modules/dot-parts": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/dot-parts/-/dot-parts-1.0.1.tgz", - "integrity": "sha1-iEvXvPwwgv+tL+XbU+SU2PPgdD8=", - "dev": true - }, "node_modules/dtype": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/dtype/-/dtype-2.0.0.tgz", @@ -1904,6 +2360,7 @@ "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", "dev": true, + "peer": true, "dependencies": { "readable-stream": "^2.0.2" } @@ -1911,14 +2368,19 @@ "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", - "dev": true + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "node_modules/electron-to-chromium": { + "version": "1.4.284", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.284.tgz", + "integrity": "sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA==" }, "node_modules/elliptic": { "version": "6.5.3", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz", "integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==", "dev": true, + "peer": true, "dependencies": { "bn.js": "^4.4.0", "brorand": "^1.0.1", @@ -1933,7 +2395,8 @@ "version": "4.11.9", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz", "integrity": "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==", - "dev": true + "dev": true, + "peer": true }, "node_modules/emoji-regex": { "version": "7.0.3", @@ -1945,7 +2408,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", - "dev": true, "engines": { "node": ">= 0.8" } @@ -2054,6 +2516,18 @@ "ultron": "~1.1.0" } }, + "node_modules/enhanced-resolve": { + "version": "5.12.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.12.0.tgz", + "integrity": "sha512-QHTXI/sZQmko1cbDoNAa3mJ5qhWUUNAq3vR0/YiD379fWQrcfuoX1+HW2S0MTt7XmoPLapdaDKUtelUSPic7hQ==", + "dependencies": { + "graceful-fs": "^4.2.4", + "tapable": "^2.2.0" + }, + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/ent": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz", @@ -2073,6 +2547,18 @@ "envify": "bin/envify" } }, + "node_modules/envinfo": { + "version": "7.8.1", + "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.8.1.tgz", + "integrity": "sha512-/o+BXHmB7ocbHEAs6F2EnG0ogybVVUdkRunTT2glZU9XAaGmhqskrvKwqXuDfNjEO0LZKWdejEEpnq8aM0tOaw==", + "dev": true, + "bin": { + "envinfo": "dist/cli.js" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/es-abstract": { "version": "1.17.5", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.5.tgz", @@ -2098,6 +2584,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/es-module-lexer": { + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.9.3.tgz", + "integrity": "sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==" + }, "node_modules/es-to-primitive": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", @@ -2115,17 +2606,18 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/es6-promisify": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-6.1.1.tgz", - "integrity": "sha512-HBL8I3mIki5C1Cc9QjKUenHtnG0A5/xA8Q/AllRcfiwl2CZFXGK7ddBiCoRwAix4i2KxcQfjtIVcrVbB3vbmwg==", - "dev": true + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "engines": { + "node": ">=6" + } }, "node_modules/escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", - "dev": true + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" }, "node_modules/escape-string-regexp": { "version": "1.0.5", @@ -2136,51 +2628,24 @@ "node": ">=0.8.0" } }, - "node_modules/escodegen": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.1.0.tgz", - "integrity": "sha1-xmOSP24gqtSNDA+knzHG1PSTYM8=", - "dev": true, + "node_modules/eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", "dependencies": { - "esprima": "~1.0.4", - "estraverse": "~1.5.0", - "esutils": "~1.0.0" - }, - "bin": { - "escodegen": "bin/escodegen.js", - "esgenerate": "bin/esgenerate.js" - }, - "engines": { - "node": ">=0.4.0" - }, - "optionalDependencies": { - "source-map": "~0.1.30" - } - }, - "node_modules/escodegen/node_modules/esprima": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz", - "integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0=", - "dev": true, - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" }, "engines": { - "node": ">=0.4.0" + "node": ">=8.0.0" } }, - "node_modules/escodegen/node_modules/source-map": { - "version": "0.1.43", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz", - "integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=", - "dev": true, - "optional": true, - "dependencies": { - "amdefine": ">=0.0.4" - }, + "node_modules/eslint-scope/node_modules/estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", "engines": { - "node": ">=0.8.0" + "node": ">=4.0" } }, "node_modules/esprima": { @@ -2196,29 +2661,29 @@ "node": ">=4" } }, - "node_modules/estraverse": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.5.1.tgz", - "integrity": "sha1-hno+jlip+EYYr7bC3bzZFrfLr3E=", - "dev": true, - "engines": { - "node": ">=0.4.0" + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" } }, - "node_modules/esutils": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-1.0.0.tgz", - "integrity": "sha1-gVHTWOIMisx/t0XnRywAJf5JZXA=", - "dev": true, + "node_modules/esrecurse/node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "engines": { - "node": ">=0.10.0" + "node": ">=4.0" } }, "node_modules/etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", - "dev": true, "engines": { "node": ">= 0.6" } @@ -2226,14 +2691,14 @@ "node_modules/eventemitter3": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.0.tgz", - "integrity": "sha512-qerSRB0p+UDEssxTtm6EDKcE7W4OaoisfIMl4CngyEhjpYglocpNg6UEqCvemdGhosAsg4sO2dXJOdyBifPGCg==", - "dev": true + "integrity": "sha512-qerSRB0p+UDEssxTtm6EDKcE7W4OaoisfIMl4CngyEhjpYglocpNg6UEqCvemdGhosAsg4sO2dXJOdyBifPGCg==" }, "node_modules/events": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/events/-/events-2.1.0.tgz", "integrity": "sha512-3Zmiobend8P9DjmKAty0Era4jV8oJ0yGYe2nJJAxgymF9+N8F2m0hhZiMoWtcfepExzNKZumFU3ksdQbInGWCg==", "dev": true, + "peer": true, "engines": { "node": ">=0.4.x" } @@ -2243,34 +2708,18 @@ "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", "dev": true, + "peer": true, "dependencies": { "md5.js": "^1.3.4", "safe-buffer": "^5.1.1" } }, - "node_modules/execa": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-0.10.0.tgz", - "integrity": "sha512-7XOMnz8Ynx1gGo/3hyV9loYNPWM94jG3+3T3Y8tsfSstFmETmENCMU/A/zj8Lyaj1lkgEepKepvd6240tBRvlw==", - "dev": true, - "dependencies": { - "cross-spawn": "^6.0.0", - "get-stream": "^3.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/expand-brackets": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", "dev": true, + "peer": true, "dependencies": { "debug": "^2.3.3", "define-property": "^0.2.5", @@ -2289,6 +2738,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, + "peer": true, "dependencies": { "is-descriptor": "^0.1.0" }, @@ -2301,6 +2751,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, + "peer": true, "dependencies": { "is-extendable": "^0.1.0" }, @@ -2308,81 +2759,99 @@ "node": ">=0.10.0" } }, - "node_modules/expand-tilde": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", - "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", - "dev": true, + "node_modules/express": { + "version": "4.18.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", + "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", "dependencies": { - "homedir-polyfill": "^1.0.1" + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "1.20.1", + "content-disposition": "0.5.4", + "content-type": "~1.0.4", + "cookie": "0.5.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.2.0", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.7", + "qs": "6.11.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "0.18.0", + "serve-static": "1.15.0", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" }, "engines": { - "node": ">=0.10.0" + "node": ">= 0.10.0" } }, - "node_modules/exposify": { + "node_modules/express/node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" + }, + "node_modules/express/node_modules/cookie": { "version": "0.5.0", - "resolved": "https://registry.npmjs.org/exposify/-/exposify-0.5.0.tgz", - "integrity": "sha1-+S0AlMJls/VT4fpFagOhiD0QWcw=", - "dev": true, - "dependencies": { - "globo": "~1.1.0", - "map-obj": "~1.0.1", - "replace-requires": "~1.0.3", - "through2": "~0.4.0", - "transformify": "~0.1.1" + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", + "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "engines": { + "node": ">= 0.6" } }, - "node_modules/exposify/node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "node_modules/exposify/node_modules/object-keys": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz", - "integrity": "sha1-KKaq50KN0sOpLz2V8hM13SBOAzY=", - "dev": true - }, - "node_modules/exposify/node_modules/readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, + "node_modules/express/node_modules/finalhandler": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", + "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "statuses": "2.0.1", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" } }, - "node_modules/exposify/node_modules/string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, - "node_modules/exposify/node_modules/through2": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.4.2.tgz", - "integrity": "sha1-2/WGYDEVHsg1K7bE22SiKSqEC5s=", - "dev": true, + "node_modules/express/node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", "dependencies": { - "readable-stream": "~1.0.17", - "xtend": "~2.1.1" + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" } }, - "node_modules/exposify/node_modules/xtend": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-2.1.2.tgz", - "integrity": "sha1-bv7MKk2tjmlixJAbM3znuoe10os=", - "dev": true, - "dependencies": { - "object-keys": "~0.4.0" - }, + "node_modules/express/node_modules/path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" + }, + "node_modules/express/node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", "engines": { - "node": ">=0.4" + "node": ">= 0.8" } }, "node_modules/extend": { @@ -2396,6 +2865,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", "dev": true, + "peer": true, "dependencies": { "assign-symbols": "^1.0.0", "is-extendable": "^1.0.1" @@ -2409,6 +2879,7 @@ "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, + "peer": true, "dependencies": { "is-plain-object": "^2.0.4" }, @@ -2421,6 +2892,7 @@ "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", "dev": true, + "peer": true, "dependencies": { "array-unique": "^0.3.2", "define-property": "^1.0.0", @@ -2440,6 +2912,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, + "peer": true, "dependencies": { "is-descriptor": "^1.0.0" }, @@ -2452,6 +2925,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, + "peer": true, "dependencies": { "is-extendable": "^0.1.0" }, @@ -2464,6 +2938,7 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, + "peer": true, "dependencies": { "kind-of": "^6.0.0" }, @@ -2476,6 +2951,7 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, + "peer": true, "dependencies": { "kind-of": "^6.0.0" }, @@ -2488,6 +2964,7 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, + "peer": true, "dependencies": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -2497,17 +2974,57 @@ "node": ">=0.10.0" } }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" + }, "node_modules/fast-safe-stringify": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz", "integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==", - "dev": true + "dev": true, + "peer": true + }, + "node_modules/fastest-levenshtein": { + "version": "1.0.16", + "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz", + "integrity": "sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg==", + "dev": true, + "engines": { + "node": ">= 4.9.1" + } + }, + "node_modules/faye-websocket": { + "version": "0.11.4", + "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.11.4.tgz", + "integrity": "sha512-CzbClwlXAuiRQAlUyfqPgvPoNKTckTPGfwZV4ZdAhVcP2lh9KUxJg2b5GkE7XbjKQ3YJnQ9z6D9ntLAlB+tP8g==", + "dependencies": { + "websocket-driver": ">=0.5.1" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "dev": true, + "optional": true, + "peer": true }, "node_modules/fill-range": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", "dev": true, + "peer": true, "dependencies": { "extend-shallow": "^2.0.1", "is-number": "^3.0.0", @@ -2523,6 +3040,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, + "peer": true, "dependencies": { "is-extendable": "^0.1.0" }, @@ -2548,22 +3066,6 @@ "node": ">= 0.8" } }, - "node_modules/find-node-modules": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/find-node-modules/-/find-node-modules-2.0.0.tgz", - "integrity": "sha512-8MWIBRgJi/WpjjfVXumjPKCtmQ10B+fjx6zmSA+770GMJirLhWIzg8l763rhjl9xaeaHbnxPNRQKq2mgMhr+aw==", - "dev": true, - "dependencies": { - "findup-sync": "^3.0.0", - "merge": "^1.2.1" - } - }, - "node_modules/find-parent-dir": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/find-parent-dir/-/find-parent-dir-0.3.0.tgz", - "integrity": "sha1-M8RLQpqysvBkYpnF+fcY83b/jVQ=", - "dev": true - }, "node_modules/find-up": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", @@ -2576,21 +3078,6 @@ "node": ">=6" } }, - "node_modules/findup-sync": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-3.0.0.tgz", - "integrity": "sha512-YbffarhcicEhOrm4CtrwdKBdCuz576RLdhJDsIfvNtxUuhdRet1qZcsMjqbePtAseKdAnDyM/IyXbu7PRPRLYg==", - "dev": true, - "dependencies": { - "detect-file": "^1.0.0", - "is-glob": "^4.0.0", - "micromatch": "^3.0.4", - "resolve-dir": "^1.0.1" - }, - "engines": { - "node": ">= 0.10" - } - }, "node_modules/flat": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", @@ -2632,7 +3119,6 @@ "version": "1.11.0", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.11.0.tgz", "integrity": "sha512-KZm0V+ll8PfBrKwMzdo5D13b1bur9Iq9Zd/RMmAoQQcl2PxxFml8cxXPaaPYVbV0RjNjq1CU7zIzAOqtUPudmA==", - "dev": true, "dependencies": { "debug": "^3.0.0" }, @@ -2645,7 +3131,6 @@ "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", "deprecated": "Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)", - "dev": true, "dependencies": { "ms": "^2.1.1" } @@ -2653,14 +3138,14 @@ "node_modules/follow-redirects/node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -2675,11 +3160,20 @@ "samsam": "1.x" } }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/fragment-cache": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", "dev": true, + "peer": true, "dependencies": { "map-cache": "^0.2.2" }, @@ -2691,30 +3185,10 @@ "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", - "dev": true, "engines": { "node": ">= 0.6" } }, - "node_modules/from2": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", - "integrity": "sha1-i/tVAr3kpNNs/e6gB/zKIdfjgq8=", - "dev": true, - "dependencies": { - "inherits": "^2.0.1", - "readable-stream": "^2.0.0" - } - }, - "node_modules/from2-string": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/from2-string/-/from2-string-1.1.0.tgz", - "integrity": "sha1-GCgrJ9CKJnyzAwzSuLSw8hKvdSo=", - "dev": true, - "dependencies": { - "from2": "^2.0.3" - } - }, "node_modules/fs-access": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/fs-access/-/fs-access-1.0.1.tgz", @@ -2741,44 +3215,40 @@ "node": ">=6 <7 || >=8" } }, + "node_modules/fs-monkey": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/fs-monkey/-/fs-monkey-1.0.3.tgz", + "integrity": "sha512-cybjIfiiE+pTWicSCLFHSrXZ6EilF30oh91FDP9S2B051prEa7QWfrVTQm10/dDpswBDXZugPa1Ogu8Yh+HV0Q==" + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } }, "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - }, - "node_modules/garnish": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/garnish/-/garnish-5.2.0.tgz", - "integrity": "sha1-vtQ2WTguSxmOM8eTiXvnxwHmVXc=", - "dev": true, - "dependencies": { - "chalk": "^0.5.1", - "minimist": "^1.1.0", - "pad-left": "^2.0.0", - "pad-right": "^0.2.2", - "prettier-bytes": "^1.0.3", - "pretty-ms": "^2.1.0", - "right-now": "^1.0.0", - "split2": "^0.2.1", - "stdout-stream": "^1.4.0", - "url-trim": "^1.0.0" - }, - "bin": { - "garnish": "bin/cmd.js" - } + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, "node_modules/get-assigned-identifiers": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz", "integrity": "sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ==", - "dev": true + "dev": true, + "peer": true }, "node_modules/get-caller-file": { "version": "2.0.5", @@ -2789,22 +3259,17 @@ "node": "6.* || 8.* || >= 10.*" } }, - "node_modules/get-ports": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/get-ports/-/get-ports-1.0.3.tgz", - "integrity": "sha1-9AvVgKyn7A77e5bL/L6wPviUteg=", - "dev": true, + "node_modules/get-intrinsic": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.3.tgz", + "integrity": "sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==", "dependencies": { - "map-limit": "0.0.1" - } - }, - "node_modules/get-stream": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", - "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", - "dev": true, - "engines": { - "node": ">=4" + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/get-value": { @@ -2812,6 +3277,7 @@ "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -2826,7 +3292,6 @@ "version": "7.1.6", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", - "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -2847,6 +3312,7 @@ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", "dev": true, + "peer": true, "dependencies": { "is-glob": "^3.1.0", "path-dirname": "^1.0.0" @@ -2857,6 +3323,7 @@ "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", "dev": true, + "peer": true, "dependencies": { "is-extglob": "^2.1.0" }, @@ -2864,6 +3331,11 @@ "node": ">=0.10.0" } }, + "node_modules/glob-to-regexp": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", + "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==" + }, "node_modules/global": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/global/-/global-4.4.0.tgz", @@ -2874,55 +3346,10 @@ "process": "^0.11.10" } }, - "node_modules/global-modules": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", - "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", - "dev": true, - "dependencies": { - "global-prefix": "^1.0.1", - "is-windows": "^1.0.1", - "resolve-dir": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/global-prefix": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz", - "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", - "dev": true, - "dependencies": { - "expand-tilde": "^2.0.2", - "homedir-polyfill": "^1.0.1", - "ini": "^1.3.4", - "is-windows": "^1.0.1", - "which": "^1.2.14" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/globo": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/globo/-/globo-1.1.0.tgz", - "integrity": "sha1-DSYJiVXepCLrIAGxBImLChAcqvM=", - "dev": true, - "dependencies": { - "accessory": "~1.1.0", - "is-defined": "~1.0.0", - "ternary": "~1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/graceful-fs": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", - "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", - "dev": true + "version": "4.2.10", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==" }, "node_modules/growl": { "version": "1.10.5", @@ -2933,11 +3360,15 @@ "node": ">=4.x" } }, + "node_modules/handle-thing": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/handle-thing/-/handle-thing-2.0.1.tgz", + "integrity": "sha512-9Qn4yBxelxoh2Ow62nP+Ka/kMnOXRi8BXnRaUwezLNhqelnN49xKz4F/dPP8OYLxLxq6JDtZb2i9XznUQbNPTg==" + }, "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, "dependencies": { "function-bind": "^1.1.1" }, @@ -2945,21 +3376,6 @@ "node": ">= 0.4.0" } }, - "node_modules/has-ansi": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-0.1.0.tgz", - "integrity": "sha1-hPJlqujA5qiKEtcCKJS3VoiUxi4=", - "dev": true, - "dependencies": { - "ansi-regex": "^0.2.0" - }, - "bin": { - "has-ansi": "cli.js" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/has-binary2": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.3.tgz", @@ -2990,20 +3406,10 @@ "node": ">=4" } }, - "node_modules/has-require": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/has-require/-/has-require-1.2.2.tgz", - "integrity": "sha1-khZ1qxMNvZdo/I2o8ajiQt+kF3Q=", - "dev": true, - "dependencies": { - "escape-string-regexp": "^1.0.3" - } - }, "node_modules/has-symbols": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", - "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", - "dev": true, + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", "engines": { "node": ">= 0.4" }, @@ -3016,6 +3422,7 @@ "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", "dev": true, + "peer": true, "dependencies": { "get-value": "^2.0.6", "has-values": "^1.0.0", @@ -3030,6 +3437,7 @@ "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", "dev": true, + "peer": true, "dependencies": { "is-number": "^3.0.0", "kind-of": "^4.0.0" @@ -3043,6 +3451,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", "dev": true, + "peer": true, "dependencies": { "is-buffer": "^1.1.5" }, @@ -3055,6 +3464,7 @@ "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz", "integrity": "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==", "dev": true, + "peer": true, "dependencies": { "inherits": "^2.0.4", "readable-stream": "^3.6.0", @@ -3068,13 +3478,15 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "dev": true, + "peer": true }, "node_modules/hash-base/node_modules/readable-stream": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", "dev": true, + "peer": true, "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -3089,6 +3501,7 @@ "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", "dev": true, + "peer": true, "dependencies": { "inherits": "^2.0.3", "minimalistic-assert": "^1.0.1" @@ -3117,60 +3530,81 @@ "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", "dev": true, + "peer": true, "dependencies": { "hash.js": "^1.0.3", "minimalistic-assert": "^1.0.0", "minimalistic-crypto-utils": "^1.0.1" } }, - "node_modules/homedir-polyfill": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", - "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", - "dev": true, + "node_modules/hpack.js": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/hpack.js/-/hpack.js-2.1.6.tgz", + "integrity": "sha512-zJxVehUdMGIKsRaNt7apO2Gqp0BdqW5yaiGHXXmbpvxgBYVZnAql+BJb4RO5ad2MgpbZKn5G6nMnegrH1FcNYQ==", "dependencies": { - "parse-passwd": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" + "inherits": "^2.0.1", + "obuf": "^1.0.0", + "readable-stream": "^2.0.1", + "wbuf": "^1.1.0" } }, + "node_modules/html-entities": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.3.3.tgz", + "integrity": "sha512-DV5Ln36z34NNTDgnz0EWGBLZENelNAtkiFA4kyNOG2tDI6Mz1uSWiq1wAKdyjnJwyDiDO7Fa2SO1CTxPXL8VxA==" + }, "node_modules/htmlescape": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz", "integrity": "sha1-OgPtwiFLyjtmQko+eVk0lQnLA1E=", "dev": true, + "peer": true, "engines": { "node": ">=0.10" } }, + "node_modules/http-deceiver": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/http-deceiver/-/http-deceiver-1.2.7.tgz", + "integrity": "sha512-LmpOGxTfbpgtGVxJrj5k7asXHCgNZp5nLfp+hWc8QQRqtb7fUy6kRY3BO1h9ddF6yIPYUARgxGOwB42DnxIaNw==" + }, "node_modules/http-errors": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.3.tgz", - "integrity": "sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw==", - "dev": true, + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", "dependencies": { - "depd": "~1.1.2", + "depd": "2.0.0", "inherits": "2.0.4", - "setprototypeof": "1.1.1", - "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.0" + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" }, "engines": { - "node": ">= 0.6" + "node": ">= 0.8" } }, "node_modules/http-errors/node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/http-errors/node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/http-parser-js": { + "version": "0.5.8", + "resolved": "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.5.8.tgz", + "integrity": "sha512-SGeBX54F94Wgu5RH3X5jsDtf4eHyRogWX1XGT3b4HuW3tQPM4AaBzoUji/4AAJNXCEOWZ5O0DgZmJw1947gD5Q==" }, "node_modules/http-proxy": { "version": "1.18.1", "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz", "integrity": "sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==", - "dev": true, "dependencies": { "eventemitter3": "^4.0.0", "follow-redirects": "^1.0.0", @@ -3180,29 +3614,133 @@ "node": ">=8.0.0" } }, - "node_modules/https-browserify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", - "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", - "dev": true - }, - "node_modules/iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "dev": true, + "node_modules/http-proxy-middleware": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz", + "integrity": "sha512-ya/UeJ6HVBYxrgYotAZo1KvPWlgB48kUJLDePFeneHsVujFaW5WNj2NgWCAE//B1Dl02BIfYlpNgBy8Kf8Rjmw==", "dependencies": { - "safer-buffer": ">= 2.1.2 < 3" + "@types/http-proxy": "^1.17.8", + "http-proxy": "^1.18.1", + "is-glob": "^4.0.1", + "is-plain-obj": "^3.0.0", + "micromatch": "^4.0.2" }, "engines": { - "node": ">=0.10.0" + "node": ">=12.0.0" + }, + "peerDependencies": { + "@types/express": "^4.17.13" + }, + "peerDependenciesMeta": { + "@types/express": { + "optional": true + } } }, - "node_modules/ieee754": { - "version": "1.1.13", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", + "node_modules/http-proxy-middleware/node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/http-proxy-middleware/node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/http-proxy-middleware/node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/http-proxy-middleware/node_modules/micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dependencies": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/http-proxy-middleware/node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/https-browserify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", + "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", + "dev": true, + "peer": true + }, + "node_modules/human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "engines": { + "node": ">=10.17.0" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ieee754": { + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==", - "dev": true + "dev": true, + "peer": true + }, + "node_modules/import-local": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", + "integrity": "sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==", + "dev": true, + "dependencies": { + "pkg-dir": "^4.2.0", + "resolve-cwd": "^3.0.0" + }, + "bin": { + "import-local-fixture": "fixtures/cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, "node_modules/indexof": { "version": "0.0.1", @@ -3210,17 +3748,10 @@ "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=", "dev": true }, - "node_modules/individual": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/individual/-/individual-3.0.0.tgz", - "integrity": "sha1-58pPhfiVewGHNPKFdQ3CLsL5hi0=", - "dev": true - }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, "dependencies": { "once": "^1.3.0", "wrappy": "1" @@ -3229,33 +3760,14 @@ "node_modules/inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "node_modules/ini": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", - "deprecated": "Please update to ini >=1.3.6 to avoid a prototype pollution issue", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/inject-lr-script": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/inject-lr-script/-/inject-lr-script-2.2.0.tgz", - "integrity": "sha512-lFLjCOg2XP8233AiET5vFePo910vhNIkKHDzUptNhc+4Y7dsp/TNBiusUUpaxzaGd6UDHy0Lozfl9AwmteK6DQ==", - "dev": true, - "dependencies": { - "resp-modifier": "^6.0.0" - } + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, "node_modules/inline-source-map": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.6.2.tgz", "integrity": "sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU=", "dev": true, + "peer": true, "dependencies": { "source-map": "~0.5.3" } @@ -3265,6 +3777,7 @@ "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.2.0.tgz", "integrity": "sha512-VE6NlW+WGn2/AeOMd496AHFYmE7eLKkUY6Ty31k4og5vmA3Fjuwe9v6ifH6Xx/Hz27QvdoMoviw1/pqWRB09Sw==", "dev": true, + "peer": true, "dependencies": { "acorn-node": "^1.5.2", "combine-source-map": "^0.8.0", @@ -3286,46 +3799,24 @@ "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", "dev": true, + "peer": true, "engines": { "node": ">= 0.6.0" } }, - "node_modules/internal-ip": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/internal-ip/-/internal-ip-3.0.1.tgz", - "integrity": "sha512-NXXgESC2nNVtU+pqmC9e6R8B1GpKxzsAQhffvh5AL79qKnodd+L7tnEQmTiUAVngqLalPbSqRA7XGIEL5nCd0Q==", - "dev": true, - "os": [ - "android", - "darwin", - "freebsd", - "linux", - "openbsd", - "sunos", - "win32" - ], - "dependencies": { - "default-gateway": "^2.6.0", - "ipaddr.js": "^1.5.2" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/ip-regex": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-2.1.0.tgz", - "integrity": "sha1-+ni/XS5pE8kRzp+BnuUUa7bYROk=", + "node_modules/interpret": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-3.1.1.tgz", + "integrity": "sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ==", "dev": true, "engines": { - "node": ">=4" + "node": ">=10.13.0" } }, "node_modules/ipaddr.js": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", - "dev": true, "engines": { "node": ">= 0.10" } @@ -3335,6 +3826,7 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, + "peer": true, "dependencies": { "kind-of": "^3.0.2" }, @@ -3347,6 +3839,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, + "peer": true, "dependencies": { "is-buffer": "^1.1.5" }, @@ -3359,6 +3852,7 @@ "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", "dev": true, + "peer": true, "dependencies": { "binary-extensions": "^1.0.0" }, @@ -3385,11 +3879,24 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-core-module": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz", + "integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==", + "dev": true, + "dependencies": { + "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, + "peer": true, "dependencies": { "kind-of": "^3.0.2" }, @@ -3402,6 +3909,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, + "peer": true, "dependencies": { "is-buffer": "^1.1.5" }, @@ -3421,17 +3929,12 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-defined": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-defined/-/is-defined-1.0.0.tgz", - "integrity": "sha1-HwfKZ9Vx9ZTEsUQVpF9774j5K/U=", - "dev": true - }, "node_modules/is-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", "dev": true, + "peer": true, "dependencies": { "is-accessor-descriptor": "^0.1.6", "is-data-descriptor": "^0.1.4", @@ -3446,17 +3949,23 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } }, "node_modules/is-docker": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.0.0.tgz", - "integrity": "sha512-pJEdRugimx4fBMra5z2/5iRdZ63OhYV0vr0Dwm5+xtW4D1FvRkB8hamMIhnWfyJeDdyr/aa7BDyNbtG38VxgoQ==", - "dev": true, + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "bin": { + "is-docker": "cli.js" + }, "engines": { "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/is-extendable": { @@ -3464,6 +3973,7 @@ "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -3472,21 +3982,8 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-finite": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.1.0.tgz", - "integrity": "sha512-cdyMtqX/BOqqNBBiKlIVkytNHm49MtMlYyn1zxzvJKWmFMlGzm+ry5BBfYyeY9YmNKbRSo/o7OX9w9ale0wg3w==", - "dev": true, "engines": { "node": ">=0.10.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/is-fullwidth-code-point": { @@ -3508,7 +4005,6 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", - "dev": true, "dependencies": { "is-extglob": "^2.1.1" }, @@ -3521,6 +4017,7 @@ "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, + "peer": true, "dependencies": { "kind-of": "^3.0.2" }, @@ -3533,6 +4030,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, + "peer": true, "dependencies": { "is-buffer": "^1.1.5" }, @@ -3549,6 +4047,17 @@ "node": ">=0.10.0" } }, + "node_modules/is-plain-obj": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-3.0.0.tgz", + "integrity": "sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -3576,24 +4085,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-regexp": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-regexp/-/is-regexp-1.0.0.tgz", - "integrity": "sha1-/S2INUXEa6xaYz57mgnof6LLUGk=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-symbol": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", @@ -3614,6 +4105,7 @@ "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -3622,7 +4114,6 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", - "dev": true, "dependencies": { "is-docker": "^2.0.0" }, @@ -3633,8 +4124,7 @@ "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" }, "node_modules/isbinaryfile": { "version": "3.0.3", @@ -3651,8 +4141,7 @@ "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" }, "node_modules/isobject": { "version": "3.0.1", @@ -3663,6 +4152,41 @@ "node": ">=0.10.0" } }, + "node_modules/jest-worker": { + "version": "27.5.1", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-27.5.1.tgz", + "integrity": "sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==", + "dependencies": { + "@types/node": "*", + "merge-stream": "^2.0.0", + "supports-color": "^8.0.0" + }, + "engines": { + "node": ">= 10.13.0" + } + }, + "node_modules/jest-worker/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/jest-worker/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, "node_modules/js-string-escape": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/js-string-escape/-/js-string-escape-1.0.1.tgz", @@ -3685,21 +4209,26 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==" + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" + }, "node_modules/json-stable-stringify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz", "integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=", "dev": true, + "peer": true, "dependencies": { "jsonify": "~0.0.0" } }, - "node_modules/json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", - "dev": true - }, "node_modules/jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", @@ -3714,6 +4243,7 @@ "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", "dev": true, + "peer": true, "engines": { "node": "*" } @@ -3725,13 +4255,15 @@ "dev": true, "engines": [ "node >= 0.2.0" - ] + ], + "peer": true }, "node_modules/JSONStream": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", "dev": true, + "peer": true, "dependencies": { "jsonparse": "^1.2.0", "through": ">=2.2.7 <3" @@ -4014,6 +4546,21 @@ "node": ">=8" } }, + "node_modules/karma/node_modules/fsevents": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz", + "integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==", + "deprecated": "\"Please update to latest v2.3 or v2.2\"", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/karma/node_modules/glob-parent": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", @@ -4106,6 +4653,7 @@ "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.2.tgz", "integrity": "sha512-Ca4LSXFFZUjPScRaqOcFxneA0VpKZr4MMYCljyQr4LIewTLb3Y0IUTIsnBBsVubIeEfxeSZpSjSsRM8APEQaAw==", "dev": true, + "peer": true, "dependencies": { "inherits": "^2.0.1", "stream-splicer": "^2.0.0" @@ -4138,6 +4686,14 @@ "xtend": "^4.0.0" } }, + "node_modules/loader-runner": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz", + "integrity": "sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==", + "engines": { + "node": ">=6.11.5" + } + }, "node_modules/locate-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", @@ -4161,7 +4717,8 @@ "version": "3.0.4", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz", "integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=", - "dev": true + "dev": true, + "peer": true }, "node_modules/log-symbols": { "version": "2.2.0", @@ -4267,6 +4824,7 @@ "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -4289,20 +4847,12 @@ "wrappy": "1" } }, - "node_modules/map-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", - "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/map-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", "dev": true, + "peer": true, "dependencies": { "object-visit": "^1.0.0" }, @@ -4310,22 +4860,12 @@ "node": ">=0.10.0" } }, - "node_modules/md5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/md5/-/md5-2.2.1.tgz", - "integrity": "sha1-U6s41f48iJG6RlMp6iP6wFQBJvk=", - "dev": true, - "dependencies": { - "charenc": "~0.0.1", - "crypt": "~0.0.1", - "is-buffer": "~1.1.1" - } - }, "node_modules/md5.js": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", "dev": true, + "peer": true, "dependencies": { "hash-base": "^3.0.0", "inherits": "^2.0.1", @@ -4336,22 +4876,45 @@ "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", - "dev": true, "engines": { "node": ">= 0.6" } }, - "node_modules/merge": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/merge/-/merge-1.2.1.tgz", - "integrity": "sha512-VjFo4P5Whtj4vsLzsYBu5ayHhoHJ0UqNm7ibvShmbmoz7tGi0vXaoJbGdB+GmDMLUdg8DpQXEIeVDAe8MaABvQ==", - "dev": true + "node_modules/memfs": { + "version": "3.4.12", + "resolved": "https://registry.npmjs.org/memfs/-/memfs-3.4.12.tgz", + "integrity": "sha512-BcjuQn6vfqP+k100e0E9m61Hyqa//Brp+I3f0OBmN0ATHlFA8vx3Lt8z57R3u2bPqe3WGDBC+nF72fTH7isyEw==", + "dependencies": { + "fs-monkey": "^1.0.3" + }, + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" + }, + "node_modules/merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "engines": { + "node": ">= 0.6" + } }, "node_modules/micromatch": { "version": "3.1.10", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", "dev": true, + "peer": true, "dependencies": { "arr-diff": "^4.0.0", "array-unique": "^0.3.2", @@ -4376,6 +4939,7 @@ "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", "dev": true, + "peer": true, "dependencies": { "bn.js": "^4.0.0", "brorand": "^1.0.1" @@ -4388,13 +4952,13 @@ "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true + "dev": true, + "peer": true }, "node_modules/mime": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", - "dev": true, "bin": { "mime": "cli.js" }, @@ -4403,26 +4967,32 @@ } }, "node_modules/mime-db": { - "version": "1.44.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", - "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==", - "dev": true, + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", "engines": { "node": ">= 0.6" } }, "node_modules/mime-types": { - "version": "2.1.27", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", - "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", - "dev": true, + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", "dependencies": { - "mime-db": "1.44.0" + "mime-db": "1.52.0" }, "engines": { "node": ">= 0.6" } }, + "node_modules/mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "engines": { + "node": ">=6" + } + }, "node_modules/mimic-response": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", @@ -4444,20 +5014,19 @@ "node_modules/minimalistic-assert": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", - "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", - "dev": true + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" }, "node_modules/minimalistic-crypto-utils": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=", - "dev": true + "dev": true, + "peer": true }, "node_modules/minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", - "dev": true, "dependencies": { "brace-expansion": "^1.1.7" }, @@ -4476,6 +5045,7 @@ "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", "dev": true, + "peer": true, "dependencies": { "for-in": "^1.0.2", "is-extendable": "^1.0.1" @@ -4489,6 +5059,7 @@ "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, + "peer": true, "dependencies": { "is-plain-object": "^2.0.4" }, @@ -4513,7 +5084,8 @@ "version": "0.5.3", "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", - "dev": true + "dev": true, + "peer": true }, "node_modules/mocha": { "version": "6.2.3", @@ -4603,6 +5175,7 @@ "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-6.2.2.tgz", "integrity": "sha512-a9y6yDv5u5I4A+IPHTnqFxcaKr4p50/zxTjcQJaX2ws9tN/W6J6YXnEKhqRyPhl494dkcxx951onSKVezmI+3w==", "dev": true, + "peer": true, "dependencies": { "browser-resolve": "^1.7.0", "cached-path-relative": "^1.0.2", @@ -4627,26 +5200,37 @@ "node": ">= 0.8.0" } }, - "node_modules/mothership": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/mothership/-/mothership-0.2.0.tgz", - "integrity": "sha1-k9SKL7w+UOKl/I7VhvW8RMZfmpk=", - "dev": true, - "dependencies": { - "find-parent-dir": "~0.3.0" - } - }, "node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, - "node_modules/nanomatch": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", - "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", + "node_modules/multicast-dns": { + "version": "7.2.5", + "resolved": "https://registry.npmjs.org/multicast-dns/-/multicast-dns-7.2.5.tgz", + "integrity": "sha512-2eznPJP8z2BFLX50tf0LuODrpINqP1RVIm/CObbTcBRITQgmC/TjcREF1NeTBzIcR5XO/ukWo+YHOjBbFwIupg==", + "dependencies": { + "dns-packet": "^5.2.2", + "thunky": "^1.0.2" + }, + "bin": { + "multicast-dns": "cli.js" + } + }, + "node_modules/nan": { + "version": "2.17.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz", + "integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==", + "dev": true, + "optional": true, + "peer": true + }, + "node_modules/nanomatch": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", + "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", "dev": true, + "peer": true, "dependencies": { "arr-diff": "^4.0.0", "array-unique": "^0.3.2", @@ -4671,14 +5255,18 @@ "dev": true }, "node_modules/negotiator": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", - "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==", - "dev": true, + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", "engines": { "node": ">= 0.6" } }, + "node_modules/neo-async": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", + "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" + }, "node_modules/new-array": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/new-array/-/new-array-1.0.0.tgz", @@ -4700,12 +5288,6 @@ "nice-color-palettes": "bin/index.js" } }, - "node_modules/nice-try": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", - "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", - "dev": true - }, "node_modules/node-environment-flags": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.5.tgz", @@ -4716,11 +5298,23 @@ "semver": "^5.7.0" } }, + "node_modules/node-forge": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", + "integrity": "sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==", + "engines": { + "node": ">= 6.13.0" + } + }, + "node_modules/node-releases": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.8.tgz", + "integrity": "sha512-dFSmB8fFHEH/s81Xi+Y/15DQY6VHW81nXRj86EMSL3lmuTmK1e+aT4wrFCkTbm+gSwkw4KpX+rT/pMM2c1mF+A==" + }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -4731,18 +5325,6 @@ "integrity": "sha1-z9kZwlUjyg0PSmn7MwXAg62u4ok=", "dev": true }, - "node_modules/npm-run-path": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", - "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", - "dev": true, - "dependencies": { - "path-key": "^2.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/null-check": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/null-check/-/null-check-1.0.0.tgz", @@ -4772,6 +5354,7 @@ "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", "dev": true, + "peer": true, "dependencies": { "copy-descriptor": "^0.1.0", "define-property": "^0.2.5", @@ -4786,6 +5369,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, + "peer": true, "dependencies": { "is-descriptor": "^0.1.0" }, @@ -4798,6 +5382,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, + "peer": true, "dependencies": { "is-buffer": "^1.1.5" }, @@ -4806,10 +5391,9 @@ } }, "node_modules/object-inspect": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", - "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", - "dev": true, + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz", + "integrity": "sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==", "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -4828,6 +5412,7 @@ "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", "dev": true, + "peer": true, "dependencies": { "isobject": "^3.0.0" }, @@ -4871,6 +5456,7 @@ "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", "dev": true, + "peer": true, "dependencies": { "isobject": "^3.0.1" }, @@ -4878,6 +5464,11 @@ "node": ">=0.10.0" } }, + "node_modules/obuf": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/obuf/-/obuf-1.1.2.tgz", + "integrity": "sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==" + }, "node_modules/on-finished": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", @@ -4894,7 +5485,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==", - "dev": true, "engines": { "node": ">= 0.8" } @@ -4903,21 +5493,38 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, "dependencies": { "wrappy": "1" } }, - "node_modules/opn": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/opn/-/opn-3.0.3.tgz", - "integrity": "sha1-ttmec5n3jWXDuq/+8fsojpuFJDo=", - "dev": true, + "node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", "dependencies": { - "object-assign": "^4.0.1" + "mimic-fn": "^2.1.0" }, "engines": { - "node": ">=0.10.0" + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/open": { + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/open/-/open-8.4.0.tgz", + "integrity": "sha512-XgFPPM+B28FtCCgSb9I+s9szOC1vZRSwgWsRUA5ylIxRTgKozqjOCrVOqGsYABPYK5qnfqClxZTFBa8PKt2v6Q==", + "dependencies": { + "define-lazy-prop": "^2.0.0", + "is-docker": "^2.1.1", + "is-wsl": "^2.2.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/optimist": { @@ -4940,7 +5547,8 @@ "version": "0.3.0", "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=", - "dev": true + "dev": true, + "peer": true }, "node_modules/os-shim": { "version": "0.1.3", @@ -4965,19 +5573,11 @@ "resolved": "https://registry.npmjs.org/outpipe/-/outpipe-1.1.1.tgz", "integrity": "sha1-UM+GFjZeh+Ax4ppeyTOaPaRyX6I=", "dev": true, + "peer": true, "dependencies": { "shell-quote": "^1.4.2" } }, - "node_modules/p-finally": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/p-limit": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", @@ -5005,50 +5605,40 @@ "node": ">=6" } }, - "node_modules/p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/pad-left": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/pad-left/-/pad-left-2.1.0.tgz", - "integrity": "sha1-FuajstRKjhOMsIOMx8tAOk/J6ZQ=", - "dev": true, + "node_modules/p-retry": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-4.6.2.tgz", + "integrity": "sha512-312Id396EbJdvRONlngUx0NydfrIQ5lsYu0znKVUzVvArzEIt08V1qhtyESbGVd1FGX7UKtiFp5uwKZdM8wIuQ==", "dependencies": { - "repeat-string": "^1.5.4" + "@types/retry": "0.12.0", + "retry": "^0.13.1" }, "engines": { - "node": ">=0.10.0" + "node": ">=8" } }, - "node_modules/pad-right": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/pad-right/-/pad-right-0.2.2.tgz", - "integrity": "sha1-b7ySQEXSRPKiokRQMGDTv8YAl3Q=", + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true, - "dependencies": { - "repeat-string": "^1.5.2" - }, "engines": { - "node": ">=0.10.0" + "node": ">=6" } }, "node_modules/pako": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", - "dev": true + "dev": true, + "peer": true }, "node_modules/parents": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz", "integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=", "dev": true, + "peer": true, "dependencies": { "path-platform": "~0.11.15" } @@ -5058,6 +5648,7 @@ "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.5.tgz", "integrity": "sha512-jkMYn1dcJqF6d5CpU689bq7w/b5ALS9ROVSpQDPrZsqqesUJii9qutvoT5ltGedNXMO2e16YUWIghG9KxaViTQ==", "dev": true, + "peer": true, "dependencies": { "asn1.js": "^4.0.0", "browserify-aes": "^1.0.0", @@ -5095,24 +5686,6 @@ "integrity": "sha512-QhhZ+DCCit2Coi2vmAKbq5RGTRcQUOE2+REgv8vdyu7MnYx2eZztegqtTx99TZ86GTIwqiy3+4nQTWZ2tgmdCA==", "dev": true }, - "node_modules/parse-ms": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-1.0.1.tgz", - "integrity": "sha1-VjRtR0nXjyNDDKDHE4UK75GqNh0=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/parse-passwd": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", - "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/parseqs": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", @@ -5135,7 +5708,6 @@ "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", - "dev": true, "engines": { "node": ">= 0.8" } @@ -5145,15 +5717,7 @@ "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/patch-text": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/patch-text/-/patch-text-1.0.2.tgz", - "integrity": "sha1-S/NuZeUXM9bpjwz2LgkDTaoDSKw=", - "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -5162,13 +5726,15 @@ "version": "0.0.1", "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", "integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==", - "dev": true + "dev": true, + "peer": true }, "node_modules/path-dirname": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", - "dev": true + "dev": true, + "peer": true }, "node_modules/path-exists": { "version": "3.0.0", @@ -5183,24 +5749,14 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true, "engines": { "node": ">=0.10.0" } }, - "node_modules/path-key": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, "node_modules/path-platform": { @@ -5208,6 +5764,7 @@ "resolved": "https://registry.npmjs.org/path-platform/-/path-platform-0.11.15.tgz", "integrity": "sha1-6GQhf3TDaFDwhSt43Hv31KVyG/I=", "dev": true, + "peer": true, "engines": { "node": ">= 0.8.0" } @@ -5232,6 +5789,7 @@ "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", "dev": true, + "peer": true, "dependencies": { "create-hash": "^1.1.2", "create-hmac": "^1.1.4", @@ -5243,61 +5801,84 @@ "node": ">=0.12" } }, - "node_modules/pem": { - "version": "1.14.4", - "resolved": "https://registry.npmjs.org/pem/-/pem-1.14.4.tgz", - "integrity": "sha512-v8lH3NpirgiEmbOqhx0vwQTxwi0ExsiWBGYh0jYNq7K6mQuO4gI6UEFlr6fLAdv9TPXRt6GqiwE37puQdIDS8g==", + "node_modules/phin": { + "version": "2.9.3", + "resolved": "https://registry.npmjs.org/phin/-/phin-2.9.3.tgz", + "integrity": "sha512-CzFr90qM24ju5f88quFC/6qohjC144rehe5n6DH900lgXmUe86+xCKc10ev56gRKC4/BkHUoG4uSiQgBiIXwDA==", + "dev": true + }, + "node_modules/picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", "dev": true, "dependencies": { - "es6-promisify": "^6.0.0", - "md5": "^2.2.1", - "os-tmpdir": "^1.0.1", - "which": "^2.0.2" + "find-up": "^4.0.0" }, "engines": { - "node": ">=6.0.0" + "node": ">=8" } }, - "node_modules/pem/node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "node_modules/pkg-dir/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", "dev": true, "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" }, "engines": { - "node": ">= 8" + "node": ">=8" } }, - "node_modules/phin": { - "version": "2.9.3", - "resolved": "https://registry.npmjs.org/phin/-/phin-2.9.3.tgz", - "integrity": "sha512-CzFr90qM24ju5f88quFC/6qohjC144rehe5n6DH900lgXmUe86+xCKc10ev56gRKC4/BkHUoG4uSiQgBiIXwDA==", - "dev": true - }, - "node_modules/picomatch": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", - "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", + "node_modules/pkg-dir/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", "dev": true, + "dependencies": { + "p-locate": "^4.1.0" + }, "engines": { - "node": ">=8.6" + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "dependencies": { + "p-limit": "^2.2.0" }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" + "engines": { + "node": ">=8" } }, - "node_modules/plur": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/plur/-/plur-1.0.0.tgz", - "integrity": "sha1-24XGgU9eXlo7Se/CjWBP7GKXUVY=", + "node_modules/pkg-dir/node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", "dev": true, "engines": { - "node": ">=0.10.0" + "node": ">=8" } }, "node_modules/posix-character-classes": { @@ -5305,6 +5886,7 @@ "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -5315,26 +5897,6 @@ "integrity": "sha1-nu/3ANqp6ZhhM1Lkf3rCMk1PrwI=", "dev": true }, - "node_modules/prettier-bytes": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/prettier-bytes/-/prettier-bytes-1.0.4.tgz", - "integrity": "sha1-mUsCqkb2mcULYle1+qp/4lV+YtY=", - "dev": true - }, - "node_modules/pretty-ms": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-2.1.0.tgz", - "integrity": "sha1-QlfCVt8/sLRR1q/6qwIYhBJpgdw=", - "dev": true, - "dependencies": { - "is-finite": "^1.0.1", - "parse-ms": "^1.0.0", - "plur": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", @@ -5347,8 +5909,7 @@ "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "dev": true + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" }, "node_modules/promise-polyfill": { "version": "3.1.0", @@ -5356,6 +5917,18 @@ "integrity": "sha1-YpUrAdBZsRW0MnY7fvRhuA9t9H0=", "dev": true }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/pseudomap": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", @@ -5367,6 +5940,7 @@ "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", "dev": true, + "peer": true, "dependencies": { "bn.js": "^4.1.0", "browserify-rsa": "^4.0.0", @@ -5380,13 +5954,15 @@ "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true + "dev": true, + "peer": true }, "node_modules/punycode": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", - "dev": true + "dev": true, + "peer": true }, "node_modules/qjobs": { "version": "1.2.0", @@ -5398,12 +5974,17 @@ } }, "node_modules/qs": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", - "dev": true, + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "dependencies": { + "side-channel": "^1.0.4" + }, "engines": { "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/quad-indices": { @@ -5437,6 +6018,7 @@ "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", "deprecated": "The querystring API is considered Legacy. new code should use the URLSearchParams API instead.", "dev": true, + "peer": true, "engines": { "node": ">=0.4.x" } @@ -5446,6 +6028,7 @@ "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", "dev": true, + "peer": true, "engines": { "node": ">=0.4.x" } @@ -5454,7 +6037,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", - "dev": true, "dependencies": { "safe-buffer": "^5.1.0" } @@ -5464,6 +6046,7 @@ "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", "dev": true, + "peer": true, "dependencies": { "randombytes": "^2.0.5", "safe-buffer": "^5.1.0" @@ -5473,19 +6056,17 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", - "dev": true, "engines": { "node": ">= 0.6" } }, "node_modules/raw-body": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", - "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", - "dev": true, + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", + "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", "dependencies": { - "bytes": "3.1.0", - "http-errors": "1.7.2", + "bytes": "3.1.2", + "http-errors": "2.0.0", "iconv-lite": "0.4.24", "unpipe": "1.0.0" }, @@ -5493,27 +6074,12 @@ "node": ">= 0.8" } }, - "node_modules/raw-body/node_modules/http-errors": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", - "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", - "dev": true, - "dependencies": { - "depd": "~1.1.2", - "inherits": "2.0.3", - "setprototypeof": "1.1.1", - "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.0" - }, - "engines": { - "node": ">= 0.6" - } - }, "node_modules/read-only-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-2.0.0.tgz", "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=", "dev": true, + "peer": true, "dependencies": { "readable-stream": "^2.0.2" } @@ -5522,7 +6088,6 @@ "version": "2.3.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, "dependencies": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -5536,14 +6101,12 @@ "node_modules/readable-stream/node_modules/safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "node_modules/readable-stream/node_modules/string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, "dependencies": { "safe-buffer": "~5.1.0" } @@ -5553,6 +6116,7 @@ "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", "dev": true, + "peer": true, "dependencies": { "graceful-fs": "^4.1.11", "micromatch": "^3.1.10", @@ -5562,36 +6126,27 @@ "node": ">=0.10" } }, - "node_modules/regex-not": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", - "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", + "node_modules/rechoir": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.8.0.tgz", + "integrity": "sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==", "dev": true, "dependencies": { - "extend-shallow": "^3.0.2", - "safe-regex": "^1.1.0" + "resolve": "^1.20.0" }, "engines": { - "node": ">=0.10.0" + "node": ">= 10.13.0" } }, - "node_modules/reload-css": { + "node_modules/regex-not": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/reload-css/-/reload-css-1.0.2.tgz", - "integrity": "sha1-avsRFi4jFP7M2tbcX96CH9cxgzE=", - "dev": true, - "dependencies": { - "query-string": "^4.2.3" - } - }, - "node_modules/reload-css/node_modules/query-string": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-4.3.4.tgz", - "integrity": "sha1-u7aTucqRXCMlFbIosaArYJBD2+s=", + "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", + "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", "dev": true, + "peer": true, "dependencies": { - "object-assign": "^4.1.0", - "strict-uri-encode": "^1.0.0" + "extend-shallow": "^3.0.2", + "safe-regex": "^1.1.0" }, "engines": { "node": ">=0.10.0" @@ -5601,45 +6156,15 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", - "dev": true - }, - "node_modules/rename-function-calls": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/rename-function-calls/-/rename-function-calls-0.1.1.tgz", - "integrity": "sha1-f4M2nAB6MAf2q+MDPM+BaGoQjgE=", "dev": true, - "dependencies": { - "detective": "~3.1.0" - } - }, - "node_modules/rename-function-calls/node_modules/detective": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/detective/-/detective-3.1.0.tgz", - "integrity": "sha1-d3gkRKt1K4jKG+Lp0KA5Xx2iXu0=", - "dev": true, - "dependencies": { - "escodegen": "~1.1.0", - "esprima-fb": "3001.1.0-dev-harmony-fb" - } - }, - "node_modules/rename-function-calls/node_modules/esprima-fb": { - "version": "3001.1.0-dev-harmony-fb", - "resolved": "https://registry.npmjs.org/esprima-fb/-/esprima-fb-3001.0001.0000-dev-harmony-fb.tgz", - "integrity": "sha1-t303q8046gt3Qmu4vCkizmtCZBE=", - "dev": true, - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" - }, - "engines": { - "node": ">=0.4.0" - } + "peer": true }, "node_modules/repeat-element": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -5649,6 +6174,7 @@ "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", "dev": true, + "peer": true, "engines": { "node": ">=0.10" } @@ -5671,43 +6197,6 @@ "node": ">= 6" } }, - "node_modules/replace-requires": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/replace-requires/-/replace-requires-1.0.4.tgz", - "integrity": "sha1-AUtzMLa54lV7cQQ7ZvsCZgw79mc=", - "dev": true, - "dependencies": { - "detective": "^4.5.0", - "has-require": "~1.2.1", - "patch-text": "~1.0.2", - "xtend": "~4.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/replace-requires/node_modules/acorn": { - "version": "5.7.4", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz", - "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==", - "dev": true, - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/replace-requires/node_modules/detective": { - "version": "4.7.1", - "resolved": "https://registry.npmjs.org/detective/-/detective-4.7.1.tgz", - "integrity": "sha512-H6PmeeUcZloWtdt4DAkFyzFL94arpHr3NOwwmVILFiy+9Qd4JTxxXrzfyGk/lmct2qVGBwTSwSXagqu2BxmWig==", - "dev": true, - "dependencies": { - "acorn": "^5.2.1", - "defined": "^1.0.0" - } - }, "node_modules/replace/node_modules/ansi-regex": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", @@ -5945,6 +6434,14 @@ "node": ">=0.10.0" } }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/require-main-filename": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", @@ -5954,32 +6451,44 @@ "node_modules/requires-port": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=", - "dev": true + "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" }, "node_modules/resolve": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", - "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", + "version": "1.22.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", + "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", "dev": true, "dependencies": { - "path-parse": "^1.0.6" + "is-core-module": "^2.9.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" }, "funding": { "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/resolve-dir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", - "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", + "node_modules/resolve-cwd": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", + "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", "dev": true, "dependencies": { - "expand-tilde": "^2.0.0", - "global-modules": "^1.0.0" + "resolve-from": "^5.0.0" }, "engines": { - "node": ">=0.10.0" + "node": ">=8" + } + }, + "node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "engines": { + "node": ">=8" } }, "node_modules/resolve-url": { @@ -5987,42 +6496,33 @@ "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", "deprecated": "https://github.com/lydell/resolve-url#deprecated", - "dev": true - }, - "node_modules/resp-modifier": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/resp-modifier/-/resp-modifier-6.0.2.tgz", - "integrity": "sha1-sSTeXE+6/LpUH0j/pzlw9KpFa08=", "dev": true, - "dependencies": { - "debug": "^2.2.0", - "minimatch": "^3.0.2" - }, - "engines": { - "node": ">= 0.8.0" - } + "peer": true }, "node_modules/ret": { "version": "0.1.15", "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", "dev": true, + "peer": true, "engines": { "node": ">=0.12" } }, + "node_modules/retry": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.13.1.tgz", + "integrity": "sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg==", + "engines": { + "node": ">= 4" + } + }, "node_modules/rfdc": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.1.4.tgz", "integrity": "sha512-5C9HXdzK8EAqN7JDif30jqsBzavB7wLpaubisuQIGHWf2gUXSpzy6ArX/+Da8RjFpagWsCn+pIgxTMAmKw9Zug==", "dev": true }, - "node_modules/right-now": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/right-now/-/right-now-1.0.0.tgz", - "integrity": "sha1-bolgne69fc2vja7Mmuo5z1haCRg=", - "dev": true - }, "node_modules/rimraf": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", @@ -6040,22 +6540,37 @@ "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", "dev": true, + "peer": true, "dependencies": { "hash-base": "^3.0.0", "inherits": "^2.0.1" } }, "node_modules/safe-buffer": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", - "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", - "dev": true + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] }, "node_modules/safe-regex": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "dev": true, + "peer": true, "dependencies": { "ret": "~0.1.10" } @@ -6063,8 +6578,7 @@ "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "node_modules/samsam": { "version": "1.3.0", @@ -6079,6 +6593,39 @@ "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", "dev": true }, + "node_modules/schema-utils": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.1.1.tgz", + "integrity": "sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw==", + "dependencies": { + "@types/json-schema": "^7.0.8", + "ajv": "^6.12.5", + "ajv-keywords": "^3.5.2" + }, + "engines": { + "node": ">= 10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, + "node_modules/select-hose": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz", + "integrity": "sha512-mEugaLK+YfkijB4fx0e6kImuJdCIt2LxCRcbEYPqRGCs4F2ogyfZU5IAZRdjCP8JPq2AtdNoC/Dux63d9Kiryg==" + }, + "node_modules/selfsigned": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/selfsigned/-/selfsigned-2.1.1.tgz", + "integrity": "sha512-GSL3aowiF7wa/WtSFwnUrludWFoNhftq8bUkH9pkzjpN2XSPOAYEgg6e0sS9s0rZwgJzJiQRPU18A6clnoW5wQ==", + "dependencies": { + "node-forge": "^1" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/semver": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", @@ -6089,45 +6636,113 @@ } }, "node_modules/send": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", - "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", - "dev": true, + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", + "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", "dependencies": { "debug": "2.6.9", - "depd": "~1.1.2", - "destroy": "~1.0.4", + "depd": "2.0.0", + "destroy": "1.2.0", "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "etag": "~1.8.1", "fresh": "0.5.2", - "http-errors": "~1.7.2", + "http-errors": "2.0.0", "mime": "1.6.0", - "ms": "2.1.1", - "on-finished": "~2.3.0", + "ms": "2.1.3", + "on-finished": "2.4.1", "range-parser": "~1.2.1", - "statuses": "~1.5.0" + "statuses": "2.0.1" }, "engines": { "node": ">= 0.8.0" } }, "node_modules/send/node_modules/ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", - "dev": true + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/send/node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/send/node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "node_modules/serve-index": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz", + "integrity": "sha512-pXHfKNP4qujrtteMrSBb0rc8HJ9Ms/GrXwcUtUtD5s4ewDJI8bT3Cz2zTVRMKtri49pLx2e0Ya8ziP5Ya2pZZw==", + "dependencies": { + "accepts": "~1.3.4", + "batch": "0.6.1", + "debug": "2.6.9", + "escape-html": "~1.0.3", + "http-errors": "~1.6.2", + "mime-types": "~2.1.17", + "parseurl": "~1.3.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/serve-index/node_modules/depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/serve-index/node_modules/http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A==", + "dependencies": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/serve-index/node_modules/setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" }, "node_modules/serve-static": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", - "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", - "dev": true, + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", + "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", "dependencies": { "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "parseurl": "~1.3.3", - "send": "0.17.1" + "send": "0.18.0" }, "engines": { "node": ">= 0.8.0" @@ -6144,6 +6759,7 @@ "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", "dev": true, + "peer": true, "dependencies": { "extend-shallow": "^2.0.1", "is-extendable": "^0.1.1", @@ -6159,6 +6775,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, + "peer": true, "dependencies": { "is-extendable": "^0.1.0" }, @@ -6167,16 +6784,16 @@ } }, "node_modules/setprototypeof": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", - "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==", - "dev": true + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, "node_modules/sha.js": { "version": "2.4.11", "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "dev": true, + "peer": true, "dependencies": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" @@ -6185,11 +6802,24 @@ "sha.js": "bin.js" } }, + "node_modules/shallow-clone": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz", + "integrity": "sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==", + "dev": true, + "dependencies": { + "kind-of": "^6.0.2" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/shasum": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/shasum/-/shasum-1.0.2.tgz", "integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=", "dev": true, + "peer": true, "dependencies": { "json-stable-stringify": "~0.0.0", "sha.js": "~2.4.4" @@ -6200,42 +6830,35 @@ "resolved": "https://registry.npmjs.org/shasum-object/-/shasum-object-1.0.0.tgz", "integrity": "sha512-Iqo5rp/3xVi6M4YheapzZhhGPVs0yZwHj7wvwQ1B9z8H6zk+FEnI7y3Teq7qwnekfEhu8WmG2z0z4iWZaxLWVg==", "dev": true, + "peer": true, "dependencies": { "fast-safe-stringify": "^2.0.7" } }, - "node_modules/shebang-command": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", - "dev": true, - "dependencies": { - "shebang-regex": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/shebang-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/shell-quote": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.2.tgz", "integrity": "sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==", - "dev": true + "dev": true, + "peer": true + }, + "node_modules/side-channel": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", + "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "dependencies": { + "call-bind": "^1.0.0", + "get-intrinsic": "^1.0.2", + "object-inspect": "^1.9.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, "node_modules/signal-exit": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", - "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==", - "dev": true + "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==" }, "node_modules/simple-concat": { "version": "1.0.0", @@ -6254,15 +6877,6 @@ "simple-concat": "^1.0.0" } }, - "node_modules/simple-html-index": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/simple-html-index/-/simple-html-index-1.5.0.tgz", - "integrity": "sha1-LJPurrrAAdihNfwAIr1K3o9YmW8=", - "dev": true, - "dependencies": { - "from2-string": "^1.1.0" - } - }, "node_modules/sinon": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/sinon/-/sinon-2.4.1.tgz", @@ -6306,6 +6920,7 @@ "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", "dev": true, + "peer": true, "dependencies": { "base": "^0.11.1", "debug": "^2.2.0", @@ -6325,6 +6940,7 @@ "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", "dev": true, + "peer": true, "dependencies": { "define-property": "^1.0.0", "isobject": "^3.0.0", @@ -6339,6 +6955,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, + "peer": true, "dependencies": { "is-descriptor": "^1.0.0" }, @@ -6351,6 +6968,7 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, + "peer": true, "dependencies": { "kind-of": "^6.0.0" }, @@ -6363,6 +6981,7 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, + "peer": true, "dependencies": { "kind-of": "^6.0.0" }, @@ -6375,6 +6994,7 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, + "peer": true, "dependencies": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -6389,6 +7009,7 @@ "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", "dev": true, + "peer": true, "dependencies": { "kind-of": "^3.2.0" }, @@ -6401,6 +7022,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, + "peer": true, "dependencies": { "is-buffer": "^1.1.5" }, @@ -6413,6 +7035,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, + "peer": true, "dependencies": { "is-descriptor": "^0.1.0" }, @@ -6425,6 +7048,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, + "peer": true, "dependencies": { "is-extendable": "^0.1.0" }, @@ -6530,11 +7154,22 @@ "ms": "2.0.0" } }, + "node_modules/sockjs": { + "version": "0.3.24", + "resolved": "https://registry.npmjs.org/sockjs/-/sockjs-0.3.24.tgz", + "integrity": "sha512-GJgLTZ7vYb/JtPSSZ10hsOYIvEYsjbNU+zPdIHcUaWVNUEPivzxku31865sSSud0Da0W4lEeOPlmw93zLQchuQ==", + "dependencies": { + "faye-websocket": "^0.11.3", + "uuid": "^8.3.2", + "websocket-driver": "^0.7.4" + } + }, "node_modules/source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -6545,6 +7180,7 @@ "integrity": "sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==", "deprecated": "See https://github.com/lydell/source-map-resolve#deprecated", "dev": true, + "peer": true, "dependencies": { "atob": "^2.1.2", "decode-uri-component": "^0.2.0", @@ -6553,87 +7189,141 @@ "urix": "^0.1.0" } }, + "node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/source-map-support/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/source-map-url": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", "deprecated": "See https://github.com/lydell/source-map-url#deprecated", - "dev": true - }, - "node_modules/split-string": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", - "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", "dev": true, + "peer": true + }, + "node_modules/spdy": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/spdy/-/spdy-4.0.2.tgz", + "integrity": "sha512-r46gZQZQV+Kl9oItvl1JZZqJKGr+oEkB08A6BzkiR7593/7IbtuncXHd2YoYeTsG4157ZssMu9KYvUHLcjcDoA==", "dependencies": { - "extend-shallow": "^3.0.0" + "debug": "^4.1.0", + "handle-thing": "^2.0.0", + "http-deceiver": "^1.2.7", + "select-hose": "^2.0.0", + "spdy-transport": "^3.0.0" }, "engines": { - "node": ">=0.10.0" + "node": ">=6.0.0" } }, - "node_modules/split2": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/split2/-/split2-0.2.1.tgz", - "integrity": "sha1-At2smtwD7Au3jBKC7Aecpuha6QA=", - "dev": true, + "node_modules/spdy-transport": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdy-transport/-/spdy-transport-3.0.0.tgz", + "integrity": "sha512-hsLVFE5SjA6TCisWeJXFKniGGOpBgMLmerfO2aCyCU5s7nJ/rpAepqmFifv/GCbSbueEeAJJnmSQ2rKC/g8Fcw==", "dependencies": { - "through2": "~0.6.1" + "debug": "^4.1.0", + "detect-node": "^2.0.4", + "hpack.js": "^2.1.6", + "obuf": "^1.1.2", + "readable-stream": "^3.0.6", + "wbuf": "^1.7.3" } }, - "node_modules/split2/node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "node_modules/split2/node_modules/readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, + "node_modules/spdy-transport/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, - "node_modules/split2/node_modules/string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true + "node_modules/spdy-transport/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, - "node_modules/split2/node_modules/through2": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", - "dev": true, + "node_modules/spdy-transport/node_modules/readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", "dependencies": { - "readable-stream": ">=1.0.33-1 <1.1.0-0", - "xtend": ">=4.0.0 <4.1.0-0" + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" } }, - "node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - }, - "node_modules/stacked": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/stacked/-/stacked-1.1.1.tgz", - "integrity": "sha1-LH+jjMfjejQRp3zY55LeRI+faXU=", - "dev": true - }, - "node_modules/static-extend": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", - "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", - "dev": true, + "node_modules/spdy/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dependencies": { - "define-property": "^0.2.5", + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/spdy/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/split-string": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", + "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", + "dev": true, + "peer": true, + "dependencies": { + "extend-shallow": "^3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "node_modules/static-extend": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", + "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", + "dev": true, + "peer": true, + "dependencies": { + "define-property": "^0.2.5", "object-copy": "^0.1.0" }, "engines": { @@ -6645,6 +7335,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, + "peer": true, "dependencies": { "is-descriptor": "^0.1.0" }, @@ -6656,25 +7347,16 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", - "dev": true, "engines": { "node": ">= 0.6" } }, - "node_modules/stdout-stream": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/stdout-stream/-/stdout-stream-1.4.1.tgz", - "integrity": "sha512-j4emi03KXqJWcIeF8eIXkjMFN1Cmb8gUlDYGeBALLPo5qdyTfA9bOtl8m33lRoC+vFMkP3gl0WsDr6+gzxbbTA==", - "dev": true, - "dependencies": { - "readable-stream": "^2.0.1" - } - }, "node_modules/stream-browserify": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.2.tgz", "integrity": "sha512-nX6hmklHs/gr2FuxYDltq8fJA1GDlxKQCz8O/IM4atRqBH8OORmBNgfvW5gG10GT/qQ9u0CzIvr2X5Pkt6ntqg==", "dev": true, + "peer": true, "dependencies": { "inherits": "~2.0.1", "readable-stream": "^2.0.2" @@ -6685,6 +7367,7 @@ "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", "dev": true, + "peer": true, "dependencies": { "duplexer2": "~0.1.0", "readable-stream": "^2.0.2" @@ -6695,6 +7378,7 @@ "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-3.1.1.tgz", "integrity": "sha512-S7OqaYu0EkFpgeGFb/NPOoPLxFko7TPqtEeFg5DXPB4v/KETHG0Ln6fRFrNezoelpaDKmycEmmZ81cC9DAwgYg==", "dev": true, + "peer": true, "dependencies": { "builtin-status-codes": "^3.0.0", "inherits": "^2.0.4", @@ -6706,13 +7390,15 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "dev": true, + "peer": true }, "node_modules/stream-http/node_modules/readable-stream": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", "dev": true, + "peer": true, "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -6727,6 +7413,7 @@ "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", "dev": true, + "peer": true, "engines": { "node": ">=0.4" } @@ -6736,6 +7423,7 @@ "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.1.tgz", "integrity": "sha512-Xizh4/NPuYSyAXyT7g8IvdJ9HJpxIGL9PjyhtywCZvvP0OPIdqyrr4dMikeuvY8xahpdKEBlBTySe583totajg==", "dev": true, + "peer": true, "dependencies": { "inherits": "^2.0.1", "readable-stream": "^2.0.2" @@ -6787,7 +7475,6 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "dev": true, "dependencies": { "safe-buffer": "~5.2.0" } @@ -6886,46 +7573,12 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "dependencies": { - "ansi-regex": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/strip-ansi/node_modules/ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/strip-css-comments": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-css-comments/-/strip-css-comments-3.0.0.tgz", - "integrity": "sha1-elYl7/iisibPiUehElTaluE9rok=", - "dev": true, - "dependencies": { - "is-regexp": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/strip-eof": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", - "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", - "dev": true, + "node_modules/strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", "engines": { - "node": ">=0.10.0" + "node": ">=6" } }, "node_modules/strip-json-comments": { @@ -6942,6 +7595,7 @@ "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz", "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=", "dev": true, + "peer": true, "dependencies": { "minimist": "^1.1.0" } @@ -6958,16 +7612,16 @@ "integrity": "sha512-5P71owlReO9HmKG5OxSSb1qKBuEWVhvGIb59gZkIoqRX5WgmBfZPo7x0OZOYEd7r9nG87cRv+OyeHJCO1Qh0CA==", "dev": true }, - "node_modules/supports-color": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz", - "integrity": "sha1-2S3iaU6z9nMjlz1649i1W0wiGQo=", + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "dev": true, - "bin": { - "supports-color": "cli.js" - }, "engines": { - "node": ">=0.10.0" + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/syntax-error": { @@ -6975,46 +7629,84 @@ "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz", "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==", "dev": true, + "peer": true, "dependencies": { "acorn-node": "^1.2.0" } }, - "node_modules/term-color": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/term-color/-/term-color-1.0.1.tgz", - "integrity": "sha1-OOGSVTpHPjXkFgT/UZmEa/gRejo=", - "dev": true, + "node_modules/tapable": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", + "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", + "engines": { + "node": ">=6" + } + }, + "node_modules/terser": { + "version": "5.16.1", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.16.1.tgz", + "integrity": "sha512-xvQfyfA1ayT0qdK47zskQgRZeWLoOQ8JQ6mIgRGVNwZKdQMU+5FkCBjmv4QjcrTzyZquRw2FVtlJSRUmMKQslw==", "dependencies": { - "ansi-styles": "2.0.1", - "supports-color": "1.3.1" + "@jridgewell/source-map": "^0.3.2", + "acorn": "^8.5.0", + "commander": "^2.20.0", + "source-map-support": "~0.5.20" + }, + "bin": { + "terser": "bin/terser" + }, + "engines": { + "node": ">=10" } }, - "node_modules/term-color/node_modules/ansi-styles": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.0.1.tgz", - "integrity": "sha1-sDP1f5Pi0oreuLwRE4+hPaD9IKM=", - "dev": true, + "node_modules/terser-webpack-plugin": { + "version": "5.3.6", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.6.tgz", + "integrity": "sha512-kfLFk+PoLUQIbLmB1+PZDMRSZS99Mp+/MHqDNmMA6tOItzRt+Npe3E+fsMs5mfcM0wCtrrdU387UnV+vnSffXQ==", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.14", + "jest-worker": "^27.4.5", + "schema-utils": "^3.1.1", + "serialize-javascript": "^6.0.0", + "terser": "^5.14.1" + }, "engines": { - "node": ">=0.10.0" + "node": ">= 10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "^5.1.0" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "uglify-js": { + "optional": true + } } }, - "node_modules/term-color/node_modules/supports-color": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-1.3.1.tgz", - "integrity": "sha1-FXWN8J2P87SswwdTn6vicJXhBC0=", - "dev": true, + "node_modules/terser/node_modules/acorn": { + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", + "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", "bin": { - "supports-color": "cli.js" + "acorn": "bin/acorn" }, "engines": { - "node": ">=0.8.0" + "node": ">=0.4.0" } }, - "node_modules/ternary": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/ternary/-/ternary-1.0.0.tgz", - "integrity": "sha1-RXAnJWCMlJnUapYQ6bDkn/JveJ4=", - "dev": true + "node_modules/terser/node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" }, "node_modules/text-encoding": { "version": "0.6.4", @@ -7082,11 +7774,17 @@ "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", "dev": true, + "peer": true, "dependencies": { "readable-stream": "~2.3.6", "xtend": "~4.0.1" } }, + "node_modules/thunky": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz", + "integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==" + }, "node_modules/timed-out": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", @@ -7101,6 +7799,7 @@ "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz", "integrity": "sha1-ycWLV1voQHN1y14kYtrO50NZ9B0=", "dev": true, + "peer": true, "dependencies": { "process": "~0.11.0" }, @@ -7113,6 +7812,7 @@ "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", "dev": true, + "peer": true, "engines": { "node": ">= 0.6.0" } @@ -7140,6 +7840,7 @@ "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", "dev": true, + "peer": true, "dependencies": { "kind-of": "^3.0.2" }, @@ -7152,6 +7853,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, + "peer": true, "dependencies": { "is-buffer": "^1.1.5" }, @@ -7164,6 +7866,7 @@ "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", "dev": true, + "peer": true, "dependencies": { "define-property": "^2.0.2", "extend-shallow": "^3.0.2", @@ -7179,6 +7882,7 @@ "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", "dev": true, + "peer": true, "dependencies": { "is-number": "^3.0.0", "repeat-string": "^1.6.1" @@ -7188,52 +7892,19 @@ } }, "node_modules/toidentifier": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", - "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", - "dev": true, + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", "engines": { "node": ">=0.6" } }, - "node_modules/transformify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/transformify/-/transformify-0.1.2.tgz", - "integrity": "sha1-mk9CoVRDPdcnuAV1Qoo8nlSJ6/E=", - "dev": true, - "dependencies": { - "readable-stream": "~1.1.9" - } - }, - "node_modules/transformify/node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "node_modules/transformify/node_modules/readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "node_modules/transformify/node_modules/string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, "node_modules/tty-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==", - "dev": true + "dev": true, + "peer": true }, "node_modules/type-detect": { "version": "1.0.0", @@ -7248,7 +7919,6 @@ "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", - "dev": true, "dependencies": { "media-typer": "0.3.0", "mime-types": "~2.1.24" @@ -7261,7 +7931,8 @@ "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", - "dev": true + "dev": true, + "peer": true }, "node_modules/uglify-es": { "version": "3.3.9", @@ -7300,6 +7971,7 @@ "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz", "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==", "dev": true, + "peer": true, "bin": { "umd": "bin/cli.js" } @@ -7309,6 +7981,7 @@ "resolved": "https://registry.npmjs.org/undeclared-identifiers/-/undeclared-identifiers-1.1.3.tgz", "integrity": "sha512-pJOW4nxjlmfwKApE4zvxLScM/njmwj/DiUBv7EabwE4O8kRUy+HIwxQtZLBPll/jx1LJyBcqNfB3/cpv9EZwOw==", "dev": true, + "peer": true, "dependencies": { "acorn-node": "^1.3.0", "dash-ast": "^1.0.0", @@ -7325,6 +7998,7 @@ "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", "dev": true, + "peer": true, "dependencies": { "arr-union": "^3.1.0", "get-value": "^2.0.6", @@ -7348,7 +8022,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", - "dev": true, "engines": { "node": ">= 0.8" } @@ -7358,6 +8031,7 @@ "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", "dev": true, + "peer": true, "dependencies": { "has-value": "^0.3.1", "isobject": "^3.0.0" @@ -7371,6 +8045,7 @@ "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", "dev": true, + "peer": true, "dependencies": { "get-value": "^2.0.3", "has-values": "^0.1.4", @@ -7385,6 +8060,7 @@ "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", "dev": true, + "peer": true, "dependencies": { "isarray": "1.0.0" }, @@ -7397,6 +8073,7 @@ "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -7406,23 +8083,67 @@ "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz", "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==", "dev": true, + "peer": true, "engines": { "node": ">=4", "yarn": "*" } }, + "node_modules/update-browserslist-db": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz", + "integrity": "sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + } + ], + "dependencies": { + "escalade": "^3.1.1", + "picocolors": "^1.0.0" + }, + "bin": { + "browserslist-lint": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/uri-js/node_modules/punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "engines": { + "node": ">=6" + } + }, "node_modules/urix": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", "deprecated": "Please see https://github.com/lydell/urix#deprecated", - "dev": true + "dev": true, + "peer": true }, "node_modules/url": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", "dev": true, + "peer": true, "dependencies": { "punycode": "1.3.2", "querystring": "0.2.0" @@ -7434,23 +8155,19 @@ "integrity": "sha512-3AChu4NiXquPfeckE5R5cGdiHCMWJx1dwCWOmWIL4KHAziJNOFIYJlpGFeKDvwLPHovZRCxK3cYlwzqI9Vp+Gg==", "dev": true }, - "node_modules/url-trim": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/url-trim/-/url-trim-1.0.0.tgz", - "integrity": "sha1-QAV+LxZLiOXaynJp2kfm0d2Detw=", - "dev": true - }, "node_modules/url/node_modules/punycode": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", - "dev": true + "dev": true, + "peer": true }, "node_modules/use": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -7470,6 +8187,7 @@ "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", "dev": true, + "peer": true, "dependencies": { "inherits": "2.0.3" } @@ -7477,23 +8195,38 @@ "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "node_modules/utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", - "dev": true, "engines": { "node": ">= 0.4.0" } }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/vm-browserify": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz", "integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==", - "dev": true + "dev": true, + "peer": true }, "node_modules/void-elements": { "version": "2.0.1", @@ -7509,6 +8242,7 @@ "resolved": "https://registry.npmjs.org/watchify/-/watchify-3.11.1.tgz", "integrity": "sha512-WwnUClyFNRMB2NIiHgJU9RQPQNqVeFk7OmZaWf5dC5EnNa0Mgr7imBydbaJ7tGTuPM2hz1Cb4uiBvK9NVxMfog==", "dev": true, + "peer": true, "dependencies": { "anymatch": "^2.0.0", "browserify": "^16.1.0", @@ -7522,82 +8256,769 @@ "watchify": "bin/cmd.js" } }, - "node_modules/watchify-middleware": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/watchify-middleware/-/watchify-middleware-1.8.2.tgz", - "integrity": "sha512-A+x5K0mHVEK2WSLOEbazcXDFnSlralMZzk364Ea39F4xFl2jGl4VQLLN5HwrnRzpF5/Ggf1Q2he0HpJtflUiHg==", - "dev": true, + "node_modules/watchpack": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", + "integrity": "sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==", "dependencies": { - "concat-stream": "^1.5.0", - "debounce": "^1.0.0", - "events": "^1.0.2", - "object-assign": "^4.0.1", - "strip-ansi": "^3.0.0", - "watchify": "^3.11.1" - } - }, - "node_modules/watchify-middleware/node_modules/events": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", - "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", - "dev": true, + "glob-to-regexp": "^0.4.1", + "graceful-fs": "^4.1.2" + }, "engines": { - "node": ">=0.4.x" + "node": ">=10.13.0" } }, - "node_modules/webvr-polyfill": { - "version": "0.10.12", - "resolved": "https://registry.npmjs.org/webvr-polyfill/-/webvr-polyfill-0.10.12.tgz", - "integrity": "sha512-trDJEVUQnRIVAnmImjEQ0BlL1NfuWl8+eaEdu+bs4g59c7OtETi/5tFkgEFDRaWEYwHntXs/uFF3OXZuutNGGA==", - "dev": true, + "node_modules/wbuf": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/wbuf/-/wbuf-1.7.3.tgz", + "integrity": "sha512-O84QOnr0icsbFGLS0O3bI5FswxzRr8/gHwWkDlQFskhSPryQXvrTMxjxGP4+iWYoauLoBvfDpkrOauZ+0iZpDA==", "dependencies": { - "cardboard-vr-display": "^1.0.19" + "minimalistic-assert": "^1.0.0" } }, - "node_modules/webvr-polyfill-dpdb": { - "version": "1.0.18", - "resolved": "https://registry.npmjs.org/webvr-polyfill-dpdb/-/webvr-polyfill-dpdb-1.0.18.tgz", - "integrity": "sha512-O0S1ZGEWyPvyZEkS2VbyV7mtir/NM9MNK3EuhbHPoJ8EHTky2pTXehjIl+IiDPr+Lldgx129QGt3NGly7rwRPw==", - "dev": true - }, - "node_modules/webworkify": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/webworkify/-/webworkify-1.4.0.tgz", - "integrity": "sha1-cSRdHjTKz1TkJr2VX4zG7hLQJMI=" + "node_modules/webpack": { + "version": "5.75.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.75.0.tgz", + "integrity": "sha512-piaIaoVJlqMsPtX/+3KTTO6jfvrSYgauFVdt8cr9LTHKmcq/AMd4mhzsiP7ZF/PGRNPGA8336jldh9l2Kt2ogQ==", + "dependencies": { + "@types/eslint-scope": "^3.7.3", + "@types/estree": "^0.0.51", + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/wasm-edit": "1.11.1", + "@webassemblyjs/wasm-parser": "1.11.1", + "acorn": "^8.7.1", + "acorn-import-assertions": "^1.7.6", + "browserslist": "^4.14.5", + "chrome-trace-event": "^1.0.2", + "enhanced-resolve": "^5.10.0", + "es-module-lexer": "^0.9.0", + "eslint-scope": "5.1.1", + "events": "^3.2.0", + "glob-to-regexp": "^0.4.1", + "graceful-fs": "^4.2.9", + "json-parse-even-better-errors": "^2.3.1", + "loader-runner": "^4.2.0", + "mime-types": "^2.1.27", + "neo-async": "^2.6.2", + "schema-utils": "^3.1.0", + "tapable": "^2.1.1", + "terser-webpack-plugin": "^5.1.3", + "watchpack": "^2.4.0", + "webpack-sources": "^3.2.3" + }, + "bin": { + "webpack": "bin/webpack.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependenciesMeta": { + "webpack-cli": { + "optional": true + } + } }, - "node_modules/which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "dev": true, - "dependencies": { - "isexe": "^2.0.0" + "node_modules/webpack-cli": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-5.0.1.tgz", + "integrity": "sha512-S3KVAyfwUqr0Mo/ur3NzIp6jnerNpo7GUO6so51mxLi1spqsA17YcMXy0WOIJtBSnj748lthxC6XLbNKh/ZC+A==", + "dev": true, + "dependencies": { + "@discoveryjs/json-ext": "^0.5.0", + "@webpack-cli/configtest": "^2.0.1", + "@webpack-cli/info": "^2.0.1", + "@webpack-cli/serve": "^2.0.1", + "colorette": "^2.0.14", + "commander": "^9.4.1", + "cross-spawn": "^7.0.3", + "envinfo": "^7.7.3", + "fastest-levenshtein": "^1.0.12", + "import-local": "^3.0.2", + "interpret": "^3.1.1", + "rechoir": "^0.8.0", + "webpack-merge": "^5.7.3" }, "bin": { - "which": "bin/which" + "webpack-cli": "bin/cli.js" + }, + "engines": { + "node": ">=14.15.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "5.x.x" + }, + "peerDependenciesMeta": { + "@webpack-cli/generators": { + "optional": true + }, + "webpack-bundle-analyzer": { + "optional": true + }, + "webpack-dev-server": { + "optional": true + } } }, - "node_modules/which-module": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", - "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", - "dev": true + "node_modules/webpack-cli/node_modules/commander": { + "version": "9.4.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.4.1.tgz", + "integrity": "sha512-5EEkTNyHNGFPD2H+c/dXXfQZYa/scCKasxWcXJaWnNJ99pnQN9Vnmqow+p+PlFPE63Q6mThaZws1T+HxfpgtPw==", + "dev": true, + "engines": { + "node": "^12.20.0 || >=14" + } }, - "node_modules/wide-align": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", - "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "node_modules/webpack-cli/node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, "dependencies": { - "string-width": "^1.0.2 || 2" + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" } }, - "node_modules/word-wrapper": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/word-wrapper/-/word-wrapper-1.0.7.tgz", - "integrity": "sha512-VOPBFCm9b6FyYKQYfn9AVn2dQvdR/YOVFV6IBRA1TBMJWKffvhEX1af6FMGrttILs2Q9ikCRhLqkbY2weW6dOQ==", - "dev": true - }, + "node_modules/webpack-cli/node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/webpack-cli/node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/webpack-cli/node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/webpack-cli/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/webpack-dev-middleware": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-5.3.3.tgz", + "integrity": "sha512-hj5CYrY0bZLB+eTO+x/j67Pkrquiy7kWepMHmUMoPsmcUaeEnQJqFzHJOyxgWlq746/wUuA64p9ta34Kyb01pA==", + "dependencies": { + "colorette": "^2.0.10", + "memfs": "^3.4.3", + "mime-types": "^2.1.31", + "range-parser": "^1.2.1", + "schema-utils": "^4.0.0" + }, + "engines": { + "node": ">= 12.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "^4.0.0 || ^5.0.0" + } + }, + "node_modules/webpack-dev-middleware/node_modules/ajv": { + "version": "8.11.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.2.tgz", + "integrity": "sha512-E4bfmKAhGiSTvMfL1Myyycaub+cUEU2/IvpylXkUu7CHBkBj1f/ikdzbD7YQ6FKUbixDxeYvB/xY4fvyroDlQg==", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/webpack-dev-middleware/node_modules/ajv-keywords": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", + "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", + "dependencies": { + "fast-deep-equal": "^3.1.3" + }, + "peerDependencies": { + "ajv": "^8.8.2" + } + }, + "node_modules/webpack-dev-middleware/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" + }, + "node_modules/webpack-dev-middleware/node_modules/schema-utils": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.0.tgz", + "integrity": "sha512-1edyXKgh6XnJsJSQ8mKWXnN/BVaIbFMLpouRUrXgVq7WYne5kw3MW7UPhO44uRXQSIpTSXoJbmrR2X0w9kUTyg==", + "dependencies": { + "@types/json-schema": "^7.0.9", + "ajv": "^8.8.0", + "ajv-formats": "^2.1.1", + "ajv-keywords": "^5.0.0" + }, + "engines": { + "node": ">= 12.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, + "node_modules/webpack-dev-server": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/webpack-dev-server/-/webpack-dev-server-4.11.1.tgz", + "integrity": "sha512-lILVz9tAUy1zGFwieuaQtYiadImb5M3d+H+L1zDYalYoDl0cksAB1UNyuE5MMWJrG6zR1tXkCP2fitl7yoUJiw==", + "dependencies": { + "@types/bonjour": "^3.5.9", + "@types/connect-history-api-fallback": "^1.3.5", + "@types/express": "^4.17.13", + "@types/serve-index": "^1.9.1", + "@types/serve-static": "^1.13.10", + "@types/sockjs": "^0.3.33", + "@types/ws": "^8.5.1", + "ansi-html-community": "^0.0.8", + "bonjour-service": "^1.0.11", + "chokidar": "^3.5.3", + "colorette": "^2.0.10", + "compression": "^1.7.4", + "connect-history-api-fallback": "^2.0.0", + "default-gateway": "^6.0.3", + "express": "^4.17.3", + "graceful-fs": "^4.2.6", + "html-entities": "^2.3.2", + "http-proxy-middleware": "^2.0.3", + "ipaddr.js": "^2.0.1", + "open": "^8.0.9", + "p-retry": "^4.5.0", + "rimraf": "^3.0.2", + "schema-utils": "^4.0.0", + "selfsigned": "^2.1.1", + "serve-index": "^1.9.1", + "sockjs": "^0.3.24", + "spdy": "^4.0.2", + "webpack-dev-middleware": "^5.3.1", + "ws": "^8.4.2" + }, + "bin": { + "webpack-dev-server": "bin/webpack-dev-server.js" + }, + "engines": { + "node": ">= 12.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "^4.37.0 || ^5.0.0" + }, + "peerDependenciesMeta": { + "webpack-cli": { + "optional": true + } + } + }, + "node_modules/webpack-dev-server/node_modules/ajv": { + "version": "8.11.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.2.tgz", + "integrity": "sha512-E4bfmKAhGiSTvMfL1Myyycaub+cUEU2/IvpylXkUu7CHBkBj1f/ikdzbD7YQ6FKUbixDxeYvB/xY4fvyroDlQg==", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/webpack-dev-server/node_modules/ajv-keywords": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", + "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", + "dependencies": { + "fast-deep-equal": "^3.1.3" + }, + "peerDependencies": { + "ajv": "^8.8.2" + } + }, + "node_modules/webpack-dev-server/node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/webpack-dev-server/node_modules/binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/webpack-dev-server/node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/webpack-dev-server/node_modules/chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/webpack-dev-server/node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/webpack-dev-server/node_modules/default-gateway": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/default-gateway/-/default-gateway-6.0.3.tgz", + "integrity": "sha512-fwSOJsbbNzZ/CUFpqFBqYfYNLj1NbMPm8MMCIzHjC83iSJRBEGmDUxU+WP661BaBQImeC2yHwXtz+P/O9o+XEg==", + "dependencies": { + "execa": "^5.0.0" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/webpack-dev-server/node_modules/execa": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/webpack-dev-server/node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/webpack-dev-server/node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/webpack-dev-server/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/webpack-dev-server/node_modules/ipaddr.js": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.0.1.tgz", + "integrity": "sha512-1qTgH9NG+IIJ4yfKs2e6Pp1bZg8wbDbKHT21HrLIeYBTRLgMYKnMTPAuI3Lcs61nfx5h1xlXnbJtH1kX5/d/ng==", + "engines": { + "node": ">= 10" + } + }, + "node_modules/webpack-dev-server/node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/webpack-dev-server/node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/webpack-dev-server/node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/webpack-dev-server/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" + }, + "node_modules/webpack-dev-server/node_modules/npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dependencies": { + "path-key": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/webpack-dev-server/node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "engines": { + "node": ">=8" + } + }, + "node_modules/webpack-dev-server/node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/webpack-dev-server/node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/webpack-dev-server/node_modules/schema-utils": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.0.tgz", + "integrity": "sha512-1edyXKgh6XnJsJSQ8mKWXnN/BVaIbFMLpouRUrXgVq7WYne5kw3MW7UPhO44uRXQSIpTSXoJbmrR2X0w9kUTyg==", + "dependencies": { + "@types/json-schema": "^7.0.9", + "ajv": "^8.8.0", + "ajv-formats": "^2.1.1", + "ajv-keywords": "^5.0.0" + }, + "engines": { + "node": ">= 12.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, + "node_modules/webpack-dev-server/node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/webpack-dev-server/node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "engines": { + "node": ">=8" + } + }, + "node_modules/webpack-dev-server/node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/webpack-dev-server/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/webpack-dev-server/node_modules/ws": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/webpack-merge": { + "version": "5.8.0", + "resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-5.8.0.tgz", + "integrity": "sha512-/SaI7xY0831XwP6kzuwhKWVKDP9t1QY1h65lAFLbZqMPIuYcD9QAW4u9STIbU9kaJbPBB/geU/gLr1wDjOhQ+Q==", + "dev": true, + "dependencies": { + "clone-deep": "^4.0.1", + "wildcard": "^2.0.0" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/webpack-sources": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz", + "integrity": "sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==", + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/webpack/node_modules/acorn": { + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", + "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/webpack/node_modules/acorn-import-assertions": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz", + "integrity": "sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw==", + "peerDependencies": { + "acorn": "^8" + } + }, + "node_modules/webpack/node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "engines": { + "node": ">=0.8.x" + } + }, + "node_modules/websocket-driver": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.7.4.tgz", + "integrity": "sha512-b17KeDIQVjvb0ssuSDF2cYXSg2iztliJ4B9WdsuB6J952qCPKmnVq4DyW5motImXHDC1cBT/1UezrJVsKw5zjg==", + "dependencies": { + "http-parser-js": ">=0.5.1", + "safe-buffer": ">=5.1.0", + "websocket-extensions": ">=0.1.1" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/websocket-extensions": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.4.tgz", + "integrity": "sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg==", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/webvr-polyfill": { + "version": "0.10.12", + "resolved": "https://registry.npmjs.org/webvr-polyfill/-/webvr-polyfill-0.10.12.tgz", + "integrity": "sha512-trDJEVUQnRIVAnmImjEQ0BlL1NfuWl8+eaEdu+bs4g59c7OtETi/5tFkgEFDRaWEYwHntXs/uFF3OXZuutNGGA==", + "dev": true, + "dependencies": { + "cardboard-vr-display": "^1.0.19" + } + }, + "node_modules/webvr-polyfill-dpdb": { + "version": "1.0.18", + "resolved": "https://registry.npmjs.org/webvr-polyfill-dpdb/-/webvr-polyfill-dpdb-1.0.18.tgz", + "integrity": "sha512-O0S1ZGEWyPvyZEkS2VbyV7mtir/NM9MNK3EuhbHPoJ8EHTky2pTXehjIl+IiDPr+Lldgx129QGt3NGly7rwRPw==", + "dev": true + }, + "node_modules/webworkify-webpack": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/webworkify-webpack/-/webworkify-webpack-2.1.5.tgz", + "integrity": "sha512-2akF8FIyUvbiBBdD+RoHpoTbHMQF2HwjcxfDvgztAX5YwbZNyrtfUMgvfgFVsgDhDPVTlkbb5vyasqDHfIDPQw==" + }, + "node_modules/which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "which": "bin/which" + } + }, + "node_modules/which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true + }, + "node_modules/wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "dev": true, + "dependencies": { + "string-width": "^1.0.2 || 2" + } + }, + "node_modules/wildcard": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/wildcard/-/wildcard-2.0.0.tgz", + "integrity": "sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw==", + "dev": true + }, + "node_modules/word-wrapper": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/word-wrapper/-/word-wrapper-1.0.7.tgz", + "integrity": "sha512-VOPBFCm9b6FyYKQYfn9AVn2dQvdR/YOVFV6IBRA1TBMJWKffvhEX1af6FMGrttILs2Q9ikCRhLqkbY2weW6dOQ==", + "dev": true + }, "node_modules/wordwrap": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", @@ -7671,17 +9092,7 @@ "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "node_modules/ws": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", - "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", - "dev": true, - "dependencies": { - "async-limiter": "~1.0.0" - } + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "node_modules/xhr": { "version": "2.6.0", @@ -7853,12 +9264,207 @@ } }, "dependencies": { + "@discoveryjs/json-ext": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz", + "integrity": "sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==", + "dev": true + }, + "@jridgewell/gen-mapping": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", + "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", + "requires": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + } + }, + "@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==" + }, + "@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==" + }, + "@jridgewell/source-map": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.2.tgz", + "integrity": "sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==", + "requires": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + } + }, + "@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==" + }, + "@jridgewell/trace-mapping": { + "version": "0.3.17", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.17.tgz", + "integrity": "sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g==", + "requires": { + "@jridgewell/resolve-uri": "3.1.0", + "@jridgewell/sourcemap-codec": "1.4.14" + } + }, + "@leichtgewicht/ip-codec": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz", + "integrity": "sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A==" + }, + "@types/body-parser": { + "version": "1.19.2", + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz", + "integrity": "sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==", + "requires": { + "@types/connect": "*", + "@types/node": "*" + } + }, + "@types/bonjour": { + "version": "3.5.10", + "resolved": "https://registry.npmjs.org/@types/bonjour/-/bonjour-3.5.10.tgz", + "integrity": "sha512-p7ienRMiS41Nu2/igbJxxLDWrSZ0WxM8UQgCeO9KhoVF7cOVFkrKsiDr1EsJIla8vV3oEEjGcz11jc5yimhzZw==", + "requires": { + "@types/node": "*" + } + }, "@types/color-name": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", "dev": true }, + "@types/connect": { + "version": "3.4.35", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz", + "integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==", + "requires": { + "@types/node": "*" + } + }, + "@types/connect-history-api-fallback": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@types/connect-history-api-fallback/-/connect-history-api-fallback-1.3.5.tgz", + "integrity": "sha512-h8QJa8xSb1WD4fpKBDcATDNGXghFj6/3GRWG6dhmRcu0RX1Ubasur2Uvx5aeEwlf0MwblEC2bMzzMQntxnw/Cw==", + "requires": { + "@types/express-serve-static-core": "*", + "@types/node": "*" + } + }, + "@types/eslint": { + "version": "8.4.10", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.10.tgz", + "integrity": "sha512-Sl/HOqN8NKPmhWo2VBEPm0nvHnu2LL3v9vKo8MEq0EtbJ4eVzGPl41VNPvn5E1i5poMk4/XD8UriLHpJvEP/Nw==", + "requires": { + "@types/estree": "*", + "@types/json-schema": "*" + } + }, + "@types/eslint-scope": { + "version": "3.7.4", + "resolved": "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.4.tgz", + "integrity": "sha512-9K4zoImiZc3HlIp6AVUDE4CWYx22a+lhSZMYNpbjW04+YF0KWj4pJXnEMjdnFTiQibFFmElcsasJXDbdI/EPhA==", + "requires": { + "@types/eslint": "*", + "@types/estree": "*" + } + }, + "@types/estree": { + "version": "0.0.51", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.51.tgz", + "integrity": "sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==" + }, + "@types/express": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.15.tgz", + "integrity": "sha512-Yv0k4bXGOH+8a+7bELd2PqHQsuiANB+A8a4gnQrkRWzrkKlb6KHaVvyXhqs04sVW/OWlbPyYxRgYlIXLfrufMQ==", + "requires": { + "@types/body-parser": "*", + "@types/express-serve-static-core": "^4.17.31", + "@types/qs": "*", + "@types/serve-static": "*" + } + }, + "@types/express-serve-static-core": { + "version": "4.17.31", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.31.tgz", + "integrity": "sha512-DxMhY+NAsTwMMFHBTtJFNp5qiHKJ7TeqOo23zVEM9alT1Ml27Q3xcTH0xwxn7Q0BbMcVEJOs/7aQtUWupUQN3Q==", + "requires": { + "@types/node": "*", + "@types/qs": "*", + "@types/range-parser": "*" + } + }, + "@types/http-proxy": { + "version": "1.17.9", + "resolved": "https://registry.npmjs.org/@types/http-proxy/-/http-proxy-1.17.9.tgz", + "integrity": "sha512-QsbSjA/fSk7xB+UXlCT3wHBy5ai9wOcNDWwZAtud+jXhwOM3l+EYZh8Lng4+/6n8uar0J7xILzqftJdJ/Wdfkw==", + "requires": { + "@types/node": "*" + } + }, + "@types/json-schema": { + "version": "7.0.11", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", + "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==" + }, + "@types/mime": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz", + "integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==" + }, + "@types/node": { + "version": "18.11.17", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.17.tgz", + "integrity": "sha512-HJSUJmni4BeDHhfzn6nF0sVmd1SMezP7/4F0Lq+aXzmp2xm9O7WXrUtHW/CHlYVtZUbByEvWidHqRtcJXGF2Ng==" + }, + "@types/qs": { + "version": "6.9.7", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", + "integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==" + }, + "@types/range-parser": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz", + "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==" + }, + "@types/retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz", + "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==" + }, + "@types/serve-index": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/@types/serve-index/-/serve-index-1.9.1.tgz", + "integrity": "sha512-d/Hs3nWDxNL2xAczmOVZNj92YZCS6RGxfBPjKzuu/XirCgXdpKEb88dYNbrYGint6IVWLNP+yonwVAuRC0T2Dg==", + "requires": { + "@types/express": "*" + } + }, + "@types/serve-static": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.0.tgz", + "integrity": "sha512-z5xyF6uh8CbjAu9760KDKsH2FcDxZ2tFCsA4HIMWE6IkiYMXfVoa+4f9KX+FN0ZLsaMw1WNG2ETLA6N+/YA+cg==", + "requires": { + "@types/mime": "*", + "@types/node": "*" + } + }, + "@types/sockjs": { + "version": "0.3.33", + "resolved": "https://registry.npmjs.org/@types/sockjs/-/sockjs-0.3.33.tgz", + "integrity": "sha512-f0KEEe05NvUnat+boPTZ0dgaLZ4SfSouXUgv5noUiefG2ajgKjmETo9ZJyuqsl7dfl2aHlLJUiki6B4ZYldiiw==", + "requires": { + "@types/node": "*" + } + }, "@types/three": { "version": "0.144.0", "resolved": "https://registry.npmjs.org/@types/three/-/three-0.144.0.tgz", @@ -7872,46 +9478,198 @@ "resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.0.tgz", "integrity": "sha512-IUMDPSXnYIbEO2IereEFcgcqfDREOgmbGqtrMpVPpACTU6pltYLwHgVkrnYv0XhWEcjio9sYEfIEzgn3c7nDqA==" }, - "accepts": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", - "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", - "dev": true, + "@types/ws": { + "version": "8.5.3", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.3.tgz", + "integrity": "sha512-6YOoWjruKj1uLf3INHH7D3qTXwFfEsg1kf3c0uDdSBJwfa/llkwIjrAGV7j7mVgGNbzTQ3HiHKKDXl6bJPD97w==", "requires": { - "mime-types": "~2.1.24", - "negotiator": "0.6.2" + "@types/node": "*" } }, - "accessory": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/accessory/-/accessory-1.1.0.tgz", - "integrity": "sha1-eDPpg5oy3tdtJgIfNqQXB6Ug9ZM=", + "@webassemblyjs/ast": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz", + "integrity": "sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw==", + "requires": { + "@webassemblyjs/helper-numbers": "1.11.1", + "@webassemblyjs/helper-wasm-bytecode": "1.11.1" + } + }, + "@webassemblyjs/floating-point-hex-parser": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.1.tgz", + "integrity": "sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ==" + }, + "@webassemblyjs/helper-api-error": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.1.tgz", + "integrity": "sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg==" + }, + "@webassemblyjs/helper-buffer": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.1.tgz", + "integrity": "sha512-gwikF65aDNeeXa8JxXa2BAk+REjSyhrNC9ZwdT0f8jc4dQQeDQ7G4m0f2QCLPJiMTTO6wfDmRmj/pW0PsUvIcA==" + }, + "@webassemblyjs/helper-numbers": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.1.tgz", + "integrity": "sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ==", + "requires": { + "@webassemblyjs/floating-point-hex-parser": "1.11.1", + "@webassemblyjs/helper-api-error": "1.11.1", + "@xtuc/long": "4.2.2" + } + }, + "@webassemblyjs/helper-wasm-bytecode": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.1.tgz", + "integrity": "sha512-PvpoOGiJwXeTrSf/qfudJhwlvDQxFgelbMqtq52WWiXC6Xgg1IREdngmPN3bs4RoO83PnL/nFrxucXj1+BX62Q==" + }, + "@webassemblyjs/helper-wasm-section": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.1.tgz", + "integrity": "sha512-10P9No29rYX1j7F3EVPX3JvGPQPae+AomuSTPiF9eBQeChHI6iqjMIwR9JmOJXwpnn/oVGDk7I5IlskuMwU/pg==", + "requires": { + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/helper-buffer": "1.11.1", + "@webassemblyjs/helper-wasm-bytecode": "1.11.1", + "@webassemblyjs/wasm-gen": "1.11.1" + } + }, + "@webassemblyjs/ieee754": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.11.1.tgz", + "integrity": "sha512-hJ87QIPtAMKbFq6CGTkZYJivEwZDbQUgYd3qKSadTNOhVY7p+gfP6Sr0lLRVTaG1JjFj+r3YchoqRYxNH3M0GQ==", + "requires": { + "@xtuc/ieee754": "^1.2.0" + } + }, + "@webassemblyjs/leb128": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.11.1.tgz", + "integrity": "sha512-BJ2P0hNZ0u+Th1YZXJpzW6miwqQUGcIHT1G/sf72gLVD9DZ5AdYTqPNbHZh6K1M5VmKvFXwGSWZADz+qBWxeRw==", + "requires": { + "@xtuc/long": "4.2.2" + } + }, + "@webassemblyjs/utf8": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.11.1.tgz", + "integrity": "sha512-9kqcxAEdMhiwQkHpkNiorZzqpGrodQQ2IGrHHxCy+Ozng0ofyMA0lTqiLkVs1uzTRejX+/O0EOT7KxqVPuXosQ==" + }, + "@webassemblyjs/wasm-edit": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.1.tgz", + "integrity": "sha512-g+RsupUC1aTHfR8CDgnsVRVZFJqdkFHpsHMfJuWQzWU3tvnLC07UqHICfP+4XyL2tnr1amvl1Sdp06TnYCmVkA==", + "requires": { + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/helper-buffer": "1.11.1", + "@webassemblyjs/helper-wasm-bytecode": "1.11.1", + "@webassemblyjs/helper-wasm-section": "1.11.1", + "@webassemblyjs/wasm-gen": "1.11.1", + "@webassemblyjs/wasm-opt": "1.11.1", + "@webassemblyjs/wasm-parser": "1.11.1", + "@webassemblyjs/wast-printer": "1.11.1" + } + }, + "@webassemblyjs/wasm-gen": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.1.tgz", + "integrity": "sha512-F7QqKXwwNlMmsulj6+O7r4mmtAlCWfO/0HdgOxSklZfQcDu0TpLiD1mRt/zF25Bk59FIjEuGAIyn5ei4yMfLhA==", + "requires": { + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/helper-wasm-bytecode": "1.11.1", + "@webassemblyjs/ieee754": "1.11.1", + "@webassemblyjs/leb128": "1.11.1", + "@webassemblyjs/utf8": "1.11.1" + } + }, + "@webassemblyjs/wasm-opt": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.1.tgz", + "integrity": "sha512-VqnkNqnZlU5EB64pp1l7hdm3hmQw7Vgqa0KF/KCNO9sIpI6Fk6brDEiX+iCOYrvMuBWDws0NkTOxYEb85XQHHw==", + "requires": { + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/helper-buffer": "1.11.1", + "@webassemblyjs/wasm-gen": "1.11.1", + "@webassemblyjs/wasm-parser": "1.11.1" + } + }, + "@webassemblyjs/wasm-parser": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.1.tgz", + "integrity": "sha512-rrBujw+dJu32gYB7/Lup6UhdkPx9S9SnobZzRVL7VcBH9Bt9bCBLEuX/YXOOtBsOZ4NQrRykKhffRWHvigQvOA==", + "requires": { + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/helper-api-error": "1.11.1", + "@webassemblyjs/helper-wasm-bytecode": "1.11.1", + "@webassemblyjs/ieee754": "1.11.1", + "@webassemblyjs/leb128": "1.11.1", + "@webassemblyjs/utf8": "1.11.1" + } + }, + "@webassemblyjs/wast-printer": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.11.1.tgz", + "integrity": "sha512-IQboUWM4eKzWW+N/jij2sRatKMh99QEelo3Eb2q0qXkvPRISAj8Qxtmw5itwqK+TTkBuUIE45AxYPToqPtL5gg==", + "requires": { + "@webassemblyjs/ast": "1.11.1", + "@xtuc/long": "4.2.2" + } + }, + "@webpack-cli/configtest": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-2.0.1.tgz", + "integrity": "sha512-njsdJXJSiS2iNbQVS0eT8A/KPnmyH4pv1APj2K0d1wrZcBLw+yppxOy4CGqa0OxDJkzfL/XELDhD8rocnIwB5A==", + "dev": true, + "requires": {} + }, + "@webpack-cli/info": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@webpack-cli/info/-/info-2.0.1.tgz", + "integrity": "sha512-fE1UEWTwsAxRhrJNikE7v4EotYflkEhBL7EbajfkPlf6E37/2QshOy/D48Mw8G5XMFlQtS6YV42vtbG9zBpIQA==", + "dev": true, + "requires": {} + }, + "@webpack-cli/serve": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-2.0.1.tgz", + "integrity": "sha512-0G7tNyS+yW8TdgHwZKlDWYXFA6OJQnoLCQvYKkQP0Q2X205PSQ6RNUj0M+1OB/9gRQaUZ/ccYfaxd0nhaWKfjw==", "dev": true, + "requires": {} + }, + "@xtuc/ieee754": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz", + "integrity": "sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==" + }, + "@xtuc/long": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz", + "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==" + }, + "accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", "requires": { - "ap": "~0.2.0", - "balanced-match": "~0.2.0", - "dot-parts": "~1.0.0" - }, - "dependencies": { - "balanced-match": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.2.1.tgz", - "integrity": "sha1-e8ZYtL7WHu5CStdPdfXD4sTfPMc=", - "dev": true - } + "mime-types": "~2.1.34", + "negotiator": "0.6.3" } }, "acorn": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.2.0.tgz", "integrity": "sha512-apwXVmYVpQ34m/i71vrApRrRKCWQnZZF1+npOD0WV5xZFfwWOmKGQ2RWlfdy9vWITsenisM8M0Qeq8agcFHNiQ==", - "dev": true + "dev": true, + "peer": true }, "acorn-node": { "version": "1.8.2", "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.8.2.tgz", "integrity": "sha512-8mt+fslDufLYntIoPAaIMUe/lrbrehIiwmR3t2k9LljIzoigEPF27eLk2hy8zSGzmR/ogr7zbRKINMo1u0yh5A==", "dev": true, + "peer": true, "requires": { "acorn": "^7.0.0", "acorn-walk": "^7.0.0", @@ -7922,7 +9680,8 @@ "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", - "dev": true + "dev": true, + "peer": true } } }, @@ -7930,7 +9689,8 @@ "version": "7.1.1", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.1.1.tgz", "integrity": "sha512-wdlPY2tm/9XBr7QkKlq0WQVgiuGTX6YWPyRyBviSoScBuLfTVQhvwg6wJ369GJ/1nPfTLMfnrFIfjqVg6d+jQQ==", - "dev": true + "dev": true, + "peer": true }, "aframe": { "version": "1.1.0", @@ -7971,12 +9731,48 @@ "integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=", "dev": true }, - "amdefine": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", - "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", - "dev": true, - "optional": true + "ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ajv-formats": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz", + "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", + "requires": { + "ajv": "^8.0.0" + }, + "dependencies": { + "ajv": { + "version": "8.11.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.2.tgz", + "integrity": "sha512-E4bfmKAhGiSTvMfL1Myyycaub+cUEU2/IvpylXkUu7CHBkBj1f/ikdzbD7YQ6FKUbixDxeYvB/xY4fvyroDlQg==", + "requires": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + } + }, + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" + } + } + }, + "ajv-keywords": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", + "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", + "requires": {} }, "ammo-debug-drawer": { "version": "0.1.0", @@ -7995,23 +9791,17 @@ "integrity": "sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==", "dev": true }, - "ansi-regex": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz", - "integrity": "sha1-DY6UaWej2BQ/k+JOKYUl/BsiNfk=", - "dev": true - }, - "ansi-styles": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.1.0.tgz", - "integrity": "sha1-6uy/Zs1waIJ2Cy9GkVgrj1XXp94=", - "dev": true + "ansi-html-community": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/ansi-html-community/-/ansi-html-community-0.0.8.tgz", + "integrity": "sha512-1APHAyr3+PCamwNw3bXCPp4HFLONZt/yIH0sZp0/469KWNTEy+qN5jQ3GVX6DMZ1UXAi34yVwtTeaG/HpBuuzw==" }, "anymatch": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", "dev": true, + "peer": true, "requires": { "micromatch": "^3.1.4", "normalize-path": "^2.1.1" @@ -8022,18 +9812,13 @@ "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", "dev": true, + "peer": true, "requires": { "remove-trailing-separator": "^1.0.1" } } } }, - "ap": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/ap/-/ap-0.2.0.tgz", - "integrity": "sha1-rglCYAspkS8NKxTsYMRejzMLYRA=", - "dev": true - }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -8047,19 +9832,27 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true + "dev": true, + "peer": true }, "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", - "dev": true + "dev": true, + "peer": true }, "arr-union": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", - "dev": true + "dev": true, + "peer": true + }, + "array-flatten": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-2.1.2.tgz", + "integrity": "sha512-hNfzcOV8W4NdualtqBFPyVO+54DSJuZGY9qT4pRroB6S9e3iiido2ISIC5h9R2sPJ8H3FHCIiEnsv1lPXO3KtQ==" }, "array-shuffle": { "version": "1.0.1", @@ -8071,7 +9864,8 @@ "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true + "dev": true, + "peer": true }, "arraybuffer.slice": { "version": "0.0.7", @@ -8090,6 +9884,7 @@ "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", "dev": true, + "peer": true, "requires": { "bn.js": "^4.0.0", "inherits": "^2.0.1", @@ -8100,7 +9895,8 @@ "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true + "dev": true, + "peer": true } } }, @@ -8109,6 +9905,7 @@ "resolved": "https://registry.npmjs.org/assert/-/assert-1.5.0.tgz", "integrity": "sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA==", "dev": true, + "peer": true, "requires": { "object-assign": "^4.1.1", "util": "0.10.3" @@ -8118,13 +9915,15 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", - "dev": true + "dev": true, + "peer": true }, "util": { "version": "0.10.3", "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", "dev": true, + "peer": true, "requires": { "inherits": "2.0.1" } @@ -8141,7 +9940,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", - "dev": true + "dev": true, + "peer": true }, "async": { "version": "2.6.3", @@ -8156,7 +9956,8 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==", - "dev": true + "dev": true, + "peer": true }, "async-limiter": { "version": "1.0.1", @@ -8168,7 +9969,8 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", - "dev": true + "dev": true, + "peer": true }, "backo2": { "version": "1.0.2", @@ -8179,14 +9981,14 @@ "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, "base": { "version": "0.11.2", "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", "dev": true, + "peer": true, "requires": { "cache-base": "^1.0.1", "class-utils": "^0.3.5", @@ -8202,6 +10004,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, + "peer": true, "requires": { "is-descriptor": "^1.0.0" } @@ -8211,6 +10014,7 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, + "peer": true, "requires": { "kind-of": "^6.0.0" } @@ -8220,6 +10024,7 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, + "peer": true, "requires": { "kind-of": "^6.0.0" } @@ -8229,6 +10034,7 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, + "peer": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -8247,7 +10053,8 @@ "version": "1.3.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==", - "dev": true + "dev": true, + "peer": true }, "base64id": { "version": "1.0.0", @@ -8255,6 +10062,11 @@ "integrity": "sha1-R2iMuZu2gE8OBtPnY7HDLlfY5rY=", "dev": true }, + "batch": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz", + "integrity": "sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw==" + }, "better-assert": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz", @@ -8268,7 +10080,19 @@ "version": "1.13.1", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", - "dev": true + "dev": true, + "peer": true + }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "dev": true, + "optional": true, + "peer": true, + "requires": { + "file-uri-to-path": "1.0.0" + } }, "blob": { "version": "0.0.5", @@ -8286,57 +10110,53 @@ "version": "5.1.1", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.1.1.tgz", "integrity": "sha512-IUTD/REb78Z2eodka1QZyyEk66pciRcP6Sroka0aI3tG/iwIdYLrBD62RsubR7vqdt3WyX8p4jxeatzmRSphtA==", - "dev": true + "dev": true, + "peer": true }, "body-parser": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", - "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", - "dev": true, + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", + "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", "requires": { - "bytes": "3.1.0", + "bytes": "3.1.2", "content-type": "~1.0.4", "debug": "2.6.9", - "depd": "~1.1.2", - "http-errors": "1.7.2", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", "iconv-lite": "0.4.24", - "on-finished": "~2.3.0", - "qs": "6.7.0", - "raw-body": "2.4.0", - "type-is": "~1.6.17" + "on-finished": "2.4.1", + "qs": "6.11.0", + "raw-body": "2.5.1", + "type-is": "~1.6.18", + "unpipe": "1.0.0" }, "dependencies": { - "http-errors": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", - "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", - "dev": true, + "on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", "requires": { - "depd": "~1.1.2", - "inherits": "2.0.3", - "setprototypeof": "1.1.1", - "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.0" + "ee-first": "1.1.1" } } } }, - "bole": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/bole/-/bole-2.0.0.tgz", - "integrity": "sha1-2KocaQRnv7T+Ebh0rLLoOH44JhU=", - "dev": true, + "bonjour-service": { + "version": "1.0.14", + "resolved": "https://registry.npmjs.org/bonjour-service/-/bonjour-service-1.0.14.tgz", + "integrity": "sha512-HIMbgLnk1Vqvs6B4Wq5ep7mxvj9sGz5d1JJyDNSGNIdA/w2MCz6GTjWTdjqOJV1bEPj+6IkxDvWNFKEBxNt4kQ==", "requires": { - "core-util-is": ">=1.0.1 <1.1.0-0", - "individual": ">=3.0.0 <3.1.0-0", - "json-stringify-safe": ">=5.0.0 <5.1.0-0" + "array-flatten": "^2.1.2", + "dns-equal": "^1.0.0", + "fast-deep-equal": "^3.1.3", + "multicast-dns": "^7.2.5" } }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -8347,6 +10167,7 @@ "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", "dev": true, + "peer": true, "requires": { "arr-flatten": "^1.1.0", "array-unique": "^0.3.2", @@ -8365,6 +10186,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, + "peer": true, "requires": { "is-extendable": "^0.1.0" } @@ -8375,13 +10197,15 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", - "dev": true + "dev": true, + "peer": true }, "browser-pack": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.1.0.tgz", "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==", "dev": true, + "peer": true, "requires": { "combine-source-map": "~0.8.0", "defined": "^1.0.0", @@ -8396,6 +10220,7 @@ "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.3.tgz", "integrity": "sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ==", "dev": true, + "peer": true, "requires": { "resolve": "1.1.7" }, @@ -8404,7 +10229,8 @@ "version": "1.1.7", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", - "dev": true + "dev": true, + "peer": true } } }, @@ -8419,6 +10245,7 @@ "resolved": "https://registry.npmjs.org/browserify/-/browserify-16.5.1.tgz", "integrity": "sha512-EQX0h59Pp+0GtSRb5rL6OTfrttlzv+uyaUVlK6GX3w11SQ0jKPKyjC/54RhPR2ib2KmfcELM06e8FxcI5XNU2A==", "dev": true, + "peer": true, "requires": { "assert": "^1.4.0", "browser-pack": "^6.0.1", @@ -8474,7 +10301,8 @@ "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", - "dev": true + "dev": true, + "peer": true } } }, @@ -8483,6 +10311,7 @@ "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "dev": true, + "peer": true, "requires": { "buffer-xor": "^1.0.3", "cipher-base": "^1.0.0", @@ -8497,33 +10326,19 @@ "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", "dev": true, + "peer": true, "requires": { "browserify-aes": "^1.0.4", "browserify-des": "^1.0.0", "evp_bytestokey": "^1.0.0" } }, - "browserify-css": { - "version": "0.15.0", - "resolved": "https://registry.npmjs.org/browserify-css/-/browserify-css-0.15.0.tgz", - "integrity": "sha512-ZgLHyZ16PH6P25JlBE+5xNtdobpkc5Egh+ctc8ha3GDtuZqSSQu0ovOxOQvXt0xAmaXixth/DY9iT56HlDOxyg==", - "dev": true, - "requires": { - "clean-css": "^4.1.5", - "concat-stream": "^1.6.0", - "css": "^2.2.1", - "find-node-modules": "^2.0.0", - "lodash": "^4.17.11", - "mime": "^1.3.6", - "strip-css-comments": "^3.0.0", - "through2": "2.0.x" - } - }, "browserify-des": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", "dev": true, + "peer": true, "requires": { "cipher-base": "^1.0.1", "des.js": "^1.0.0", @@ -8536,6 +10351,7 @@ "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", "dev": true, + "peer": true, "requires": { "bn.js": "^4.1.0", "randombytes": "^2.0.1" @@ -8545,28 +10361,8 @@ "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true - } - } - }, - "browserify-shim": { - "version": "3.8.14", - "resolved": "https://registry.npmjs.org/browserify-shim/-/browserify-shim-3.8.14.tgz", - "integrity": "sha1-vxBXAmky0yU8de991xTzuHft7Gs=", - "dev": true, - "requires": { - "exposify": "~0.5.0", - "mothership": "~0.2.0", - "rename-function-calls": "~0.1.0", - "resolve": "~0.6.1", - "through": "~2.3.4" - }, - "dependencies": { - "resolve": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-0.6.3.tgz", - "integrity": "sha1-3ZV5gufnNt699TtYpN2RdUV13UY=", - "dev": true + "dev": true, + "peer": true } } }, @@ -8575,6 +10371,7 @@ "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.1.0.tgz", "integrity": "sha512-VYxo7cDCeYUoBZ0ZCy4UyEUCP3smyBd4DRQM5nrFS1jJjPJjX7rP3oLRpPoWfkhQfyJ0I9ZbHbKafrFD/SGlrg==", "dev": true, + "peer": true, "requires": { "bn.js": "^5.1.1", "browserify-rsa": "^4.0.1", @@ -8590,13 +10387,15 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "dev": true, + "peer": true }, "readable-stream": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", "dev": true, + "peer": true, "requires": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -8610,54 +10409,20 @@ "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", "dev": true, + "peer": true, "requires": { "pako": "~1.0.5" } }, - "budo": { - "version": "11.6.3", - "resolved": "https://registry.npmjs.org/budo/-/budo-11.6.3.tgz", - "integrity": "sha512-U9pV6SoSxGduY/wnoIlDwEEUhxtTFqYqoyWvi3B5nJ/abSxuNmolfAfzgOQIEXqtHhPEA4FlM+VNzdEDOjpIjw==", - "dev": true, + "browserslist": { + "version": "4.21.4", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.4.tgz", + "integrity": "sha512-CBHJJdDmgjl3daYjN5Cp5kbTf1mUhZoS+beLklHIvkOWscs83YAhLlF3Wsh/lciQYAcbBJgTOD44VtG31ZM4Hw==", "requires": { - "bole": "^2.0.0", - "browserify": "^16.2.3", - "chokidar": "^2.0.4", - "connect-pushstate": "^1.1.0", - "escape-html": "^1.0.3", - "events": "^1.0.2", - "garnish": "^5.0.0", - "get-ports": "^1.0.2", - "inject-lr-script": "^2.1.0", - "internal-ip": "^3.0.1", - "micromatch": "^3.1.10", - "on-finished": "^2.3.0", - "on-headers": "^1.0.1", - "once": "^1.3.2", - "opn": "^3.0.2", - "path-is-absolute": "^1.0.1", - "pem": "^1.13.2", - "reload-css": "^1.0.0", - "resolve": "^1.1.6", - "serve-static": "^1.10.0", - "simple-html-index": "^1.4.0", - "stacked": "^1.1.1", - "stdout-stream": "^1.4.0", - "strip-ansi": "^3.0.0", - "subarg": "^1.0.0", - "term-color": "^1.0.1", - "url-trim": "^1.0.0", - "watchify-middleware": "^1.8.2", - "ws": "^6.2.1", - "xtend": "^4.0.0" - }, - "dependencies": { - "events": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", - "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", - "dev": true - } + "caniuse-lite": "^1.0.30001400", + "electron-to-chromium": "^1.4.251", + "node-releases": "^2.0.6", + "update-browserslist-db": "^1.0.9" } }, "buffer": { @@ -8665,6 +10430,7 @@ "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", "integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==", "dev": true, + "peer": true, "requires": { "base64-js": "^1.0.2", "ieee754": "^1.1.4" @@ -8701,8 +10467,7 @@ "buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", - "dev": true + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" }, "buffer-to-arraybuffer": { "version": "0.0.5", @@ -8714,25 +10479,27 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", - "dev": true + "dev": true, + "peer": true }, "builtin-status-codes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", - "dev": true + "dev": true, + "peer": true }, "bytes": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", - "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==", - "dev": true + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==" }, "cache-base": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", "dev": true, + "peer": true, "requires": { "collection-visit": "^1.0.0", "component-emitter": "^1.2.1", @@ -8749,7 +10516,17 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.0.2.tgz", "integrity": "sha512-5r2GqsoEb4qMTTN9J+WzXfjov+hjxT+j3u5K+kIVNIwAd99DLCJE9pBIMP1qVeybV6JiijL385Oz0DcYxfbOIg==", - "dev": true + "dev": true, + "peer": true + }, + "call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } }, "callsite": { "version": "1.0.0", @@ -8763,6 +10540,11 @@ "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", "dev": true }, + "caniuse-lite": { + "version": "1.0.30001441", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001441.tgz", + "integrity": "sha512-OyxRR4Vof59I3yGWXws6i908EtGbMzVUi3ganaZQHmydk1iwDhRnvaPG2WaR0KcqrDFKrxVZHULT396LEPhXfg==" + }, "cannon-es": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/cannon-es/-/cannon-es-0.9.1.tgz", @@ -8797,41 +10579,12 @@ "dev": true, "requires": {} }, - "chalk": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz", - "integrity": "sha1-Zjs6ZItotV0EaQ1JFnqoN4WPIXQ=", - "dev": true, - "requires": { - "ansi-styles": "^1.1.0", - "escape-string-regexp": "^1.0.0", - "has-ansi": "^0.1.0", - "strip-ansi": "^0.3.0", - "supports-color": "^0.2.0" - }, - "dependencies": { - "strip-ansi": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz", - "integrity": "sha1-JfSOoiynkYfzF0pNuHWTR7sSYiA=", - "dev": true, - "requires": { - "ansi-regex": "^0.2.1" - } - } - } - }, - "charenc": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", - "integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc=", - "dev": true - }, "chokidar": { "version": "2.1.8", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", "integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==", "dev": true, + "peer": true, "requires": { "anymatch": "^2.0.0", "async-each": "^1.0.1", @@ -8845,13 +10598,33 @@ "path-is-absolute": "^1.0.0", "readdirp": "^2.2.1", "upath": "^1.1.1" + }, + "dependencies": { + "fsevents": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", + "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", + "dev": true, + "optional": true, + "peer": true, + "requires": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + } + } } }, + "chrome-trace-event": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz", + "integrity": "sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==" + }, "cipher-base": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", "dev": true, + "peer": true, "requires": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" @@ -8862,6 +10635,7 @@ "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", "dev": true, + "peer": true, "requires": { "arr-union": "^3.1.0", "define-property": "^0.2.5", @@ -8874,29 +10648,13 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, + "peer": true, "requires": { "is-descriptor": "^0.1.0" } } } }, - "clean-css": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.3.tgz", - "integrity": "sha512-VcMWDN54ZN/DS+g58HYL5/n4Zrqe8vHJpGA8KdgUXFU4fuP/aHNw8eld9SyEIyabIMJX/0RaY/fplOo5hYLSFA==", - "dev": true, - "requires": { - "source-map": "~0.6.0" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } - } - }, "cliui": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", @@ -8936,11 +10694,23 @@ } } }, + "clone-deep": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-4.0.1.tgz", + "integrity": "sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4", + "kind-of": "^6.0.2", + "shallow-clone": "^3.0.0" + } + }, "collection-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", "dev": true, + "peer": true, "requires": { "map-visit": "^1.0.0", "object-visit": "^1.0.0" @@ -8961,6 +10731,11 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, + "colorette": { + "version": "2.0.19", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.19.tgz", + "integrity": "sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ==" + }, "colors": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", @@ -8972,6 +10747,7 @@ "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.8.0.tgz", "integrity": "sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos=", "dev": true, + "peer": true, "requires": { "convert-source-map": "~1.1.0", "inline-source-map": "~0.6.0", @@ -8995,7 +10771,8 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", - "dev": true + "dev": true, + "peer": true }, "component-inherit": { "version": "0.0.3", @@ -9003,17 +10780,51 @@ "integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM=", "dev": true }, + "compressible": { + "version": "2.0.18", + "resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.18.tgz", + "integrity": "sha512-AF3r7P5dWxL8MxyITRMlORQNaOA2IkAFaTr4k7BUumjPtRpGDTZpl0Pb1XCO6JeDCBdp126Cgs9sMxqSjgYyRg==", + "requires": { + "mime-db": ">= 1.43.0 < 2" + } + }, + "compression": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/compression/-/compression-1.7.4.tgz", + "integrity": "sha512-jaSIDzP9pZVS4ZfQ+TzvtiWhdpFhE2RDHz8QJkpX9SIpLq88VueF5jJw6t+6CUQcAoA6t+x89MLrWAqpfDE8iQ==", + "requires": { + "accepts": "~1.3.5", + "bytes": "3.0.0", + "compressible": "~2.0.16", + "debug": "2.6.9", + "on-headers": "~1.0.2", + "safe-buffer": "5.1.2", + "vary": "~1.1.2" + }, + "dependencies": { + "bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha512-pMhOfFDPiv9t5jjIXkHosWmkSyQbvsgEVNkz0ERHbuLh2T/7j4Mqqpz523Fe8MVY89KC6Sh/QfS2sM+SjgFDcw==" + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + } + } + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, "concat-stream": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", "dev": true, + "peer": true, "requires": { "buffer-from": "^1.0.0", "inherits": "^2.0.3", @@ -9033,29 +10844,37 @@ "utils-merge": "1.0.1" } }, - "connect-pushstate": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/connect-pushstate/-/connect-pushstate-1.1.0.tgz", - "integrity": "sha1-vKsiQnHEOWBKD7D2FMCl9WPojiQ=", - "dev": true + "connect-history-api-fallback": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-2.0.0.tgz", + "integrity": "sha512-U73+6lQFmfiNPrYbXqr6kZ1i1wiRqXnp2nhMsINseWXO8lDau0LGEffJ8kQi4EjLZympVgRdvqjAgiZ1tgzDDA==" }, "console-browserify": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.2.0.tgz", "integrity": "sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA==", - "dev": true + "dev": true, + "peer": true }, "constants-browserify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=", - "dev": true + "dev": true, + "peer": true + }, + "content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "requires": { + "safe-buffer": "5.2.1" + } }, "content-type": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", - "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", - "dev": true + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" }, "convert-source-map": { "version": "1.1.3", @@ -9069,23 +10888,29 @@ "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=", "dev": true }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" + }, "copy-descriptor": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", - "dev": true + "dev": true, + "peer": true }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, "create-ecdh": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", "dev": true, + "peer": true, "requires": { "bn.js": "^4.1.0", "elliptic": "^6.0.0" @@ -9095,7 +10920,8 @@ "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true + "dev": true, + "peer": true } } }, @@ -9104,6 +10930,7 @@ "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "dev": true, + "peer": true, "requires": { "cipher-base": "^1.0.1", "inherits": "^2.0.1", @@ -9117,6 +10944,7 @@ "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "dev": true, + "peer": true, "requires": { "cipher-base": "^1.0.3", "create-hash": "^1.1.0", @@ -9126,30 +10954,12 @@ "sha.js": "^2.4.8" } }, - "cross-spawn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", - "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", - "dev": true, - "requires": { - "nice-try": "^1.0.4", - "path-key": "^2.0.1", - "semver": "^5.5.0", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - } - }, - "crypt": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", - "integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs=", - "dev": true - }, "crypto-browserify": { "version": "3.12.0", "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", "dev": true, + "peer": true, "requires": { "browserify-cipher": "^1.0.0", "browserify-sign": "^4.0.0", @@ -9164,26 +10974,6 @@ "randomfill": "^1.0.3" } }, - "css": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/css/-/css-2.2.4.tgz", - "integrity": "sha512-oUnjmWpy0niI3x/mPL8dVEI1l7MnG3+HHyRPHf+YFSbK+svOhXpmSOcDURUh2aOCgl2grzrOPt1nHLuCVFULLw==", - "dev": true, - "requires": { - "inherits": "^2.0.3", - "source-map": "^0.6.1", - "source-map-resolve": "^0.5.2", - "urix": "^0.1.0" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } - } - }, "custom-event": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz", @@ -9200,7 +10990,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/dash-ast/-/dash-ast-1.0.0.tgz", "integrity": "sha512-Vy4dx7gquTeMcQR/hDkYLGUnwVil6vk4FOOct+djUnHOUWt+zJPJAaRIXaAFkPXtJjvlY7o3rfRu0/3hpnwoUA==", - "dev": true + "dev": true, + "peer": true }, "date-format": { "version": "2.1.0", @@ -9208,17 +10999,10 @@ "integrity": "sha512-bYQuGLeFxhkxNOF3rcMtiZxvCBAquGzZm6oWA1oZ0g2THUzivaRhv8uOhdr19LmoobSOLoIAxeUK2RdbM8IFTA==", "dev": true }, - "debounce": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/debounce/-/debounce-1.2.0.tgz", - "integrity": "sha512-mYtLl1xfZLi1m4RtQYlZgJUNQjl4ZxVnHzIR8nLLgi4q1YT8o/WM+MK/f8yfcc9s5Ir5zRaPZyZU6xs1Syoocg==", - "dev": true - }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, "requires": { "ms": "2.0.0" } @@ -9270,15 +11054,10 @@ } } }, - "default-gateway": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/default-gateway/-/default-gateway-2.7.2.tgz", - "integrity": "sha512-lAc4i9QJR0YHSDFdzeBQKfZ1SRDG3hsJNEkrpcZa8QhBfidLAilT60BDEIVUUGqosFp425KOgB3uYqcnQrWafQ==", - "dev": true, - "requires": { - "execa": "^0.10.0", - "ip-regex": "^2.1.0" - } + "define-lazy-prop": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", + "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==" }, "define-properties": { "version": "1.1.3", @@ -9294,6 +11073,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", "dev": true, + "peer": true, "requires": { "is-descriptor": "^1.0.2", "isobject": "^3.0.1" @@ -9304,6 +11084,7 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, + "peer": true, "requires": { "kind-of": "^6.0.0" } @@ -9313,6 +11094,7 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, + "peer": true, "requires": { "kind-of": "^6.0.0" } @@ -9322,6 +11104,7 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, + "peer": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -9334,19 +11117,20 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", - "dev": true + "dev": true, + "peer": true }, "depd": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", - "dev": true + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==" }, "deps-sort": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-2.0.1.tgz", "integrity": "sha512-1orqXQr5po+3KI6kQb9A4jnXT1PBwggGl2d7Sq2xsnOeI9GPcE/tGcF9UiSZtZBM7MukY4cAh7MemS6tZYipfw==", "dev": true, + "peer": true, "requires": { "JSONStream": "^1.0.3", "shasum-object": "^1.0.0", @@ -9359,28 +11143,28 @@ "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz", "integrity": "sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA==", "dev": true, + "peer": true, "requires": { "inherits": "^2.0.1", "minimalistic-assert": "^1.0.0" } }, "destroy": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", - "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=", - "dev": true + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==" }, - "detect-file": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", - "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", - "dev": true + "detect-node": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.1.0.tgz", + "integrity": "sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==" }, "detective": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/detective/-/detective-5.2.0.tgz", "integrity": "sha512-6SsIx+nUUbuK0EthKjv0zrdnajCCXVYGmbYYiYjFVpzcjwEs/JMDZ8tPRG29J/HhN56t3GJp2cGSWDRjjot8Pg==", "dev": true, + "peer": true, "requires": { "acorn-node": "^1.6.1", "defined": "^1.0.0", @@ -9404,6 +11188,7 @@ "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", "dev": true, + "peer": true, "requires": { "bn.js": "^4.1.0", "miller-rabin": "^4.0.0", @@ -9414,10 +11199,24 @@ "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true + "dev": true, + "peer": true } } }, + "dns-equal": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/dns-equal/-/dns-equal-1.0.0.tgz", + "integrity": "sha512-z+paD6YUQsk+AbGCEM4PrOXSss5gd66QfcVBFTKR/HpFL9jCqikS94HYwKww6fQyO7IxrIIyUu+g0Ka9tUS2Cg==" + }, + "dns-packet": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-5.4.0.tgz", + "integrity": "sha512-EgqGeaBB8hLiHLZtp/IbaDQTL8pZ0+IvwzSHA6d7VyMDM+B9hgddEMa9xjK5oYnw0ci0JQ6g2XCD7/f6cafU6g==", + "requires": { + "@leichtgewicht/ip-codec": "^2.0.1" + } + }, "document-register-element": { "version": "git+ssh://git@github.com/dmarcos/document-register-element.git#8ccc532b7f3744be954574caf3072a5fd260ca90", "integrity": "sha512-dwvGei9I/m1pYQ/9aNODyVmvSWBtlncfIROn5Sbi4MVnIcZKre5QaWx+AGLI/j6VH9sp8jwLyeuWP1micANT0g==", @@ -9446,13 +11245,8 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", "integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==", - "dev": true - }, - "dot-parts": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/dot-parts/-/dot-parts-1.0.1.tgz", - "integrity": "sha1-iEvXvPwwgv+tL+XbU+SU2PPgdD8=", - "dev": true + "dev": true, + "peer": true }, "dtype": { "version": "2.0.0", @@ -9465,6 +11259,7 @@ "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", "dev": true, + "peer": true, "requires": { "readable-stream": "^2.0.2" } @@ -9472,14 +11267,19 @@ "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", - "dev": true + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "electron-to-chromium": { + "version": "1.4.284", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.284.tgz", + "integrity": "sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA==" }, "elliptic": { "version": "6.5.3", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz", "integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==", "dev": true, + "peer": true, "requires": { "bn.js": "^4.4.0", "brorand": "^1.0.1", @@ -9494,7 +11294,8 @@ "version": "4.11.9", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz", "integrity": "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==", - "dev": true + "dev": true, + "peer": true } } }, @@ -9507,8 +11308,7 @@ "encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", - "dev": true + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" }, "engine.io": { "version": "3.2.1", @@ -9618,6 +11418,15 @@ "has-binary2": "~1.0.2" } }, + "enhanced-resolve": { + "version": "5.12.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.12.0.tgz", + "integrity": "sha512-QHTXI/sZQmko1cbDoNAa3mJ5qhWUUNAq3vR0/YiD379fWQrcfuoX1+HW2S0MTt7XmoPLapdaDKUtelUSPic7hQ==", + "requires": { + "graceful-fs": "^4.2.4", + "tapable": "^2.2.0" + } + }, "ent": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz", @@ -9634,6 +11443,12 @@ "through": "~2.3.4" } }, + "envinfo": { + "version": "7.8.1", + "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.8.1.tgz", + "integrity": "sha512-/o+BXHmB7ocbHEAs6F2EnG0ogybVVUdkRunTT2glZU9XAaGmhqskrvKwqXuDfNjEO0LZKWdejEEpnq8aM0tOaw==", + "dev": true + }, "es-abstract": { "version": "1.17.5", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.5.tgz", @@ -9653,6 +11468,11 @@ "string.prototype.trimright": "^2.1.1" } }, + "es-module-lexer": { + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.9.3.tgz", + "integrity": "sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==" + }, "es-to-primitive": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", @@ -9664,17 +11484,15 @@ "is-symbol": "^1.0.2" } }, - "es6-promisify": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-6.1.1.tgz", - "integrity": "sha512-HBL8I3mIki5C1Cc9QjKUenHtnG0A5/xA8Q/AllRcfiwl2CZFXGK7ddBiCoRwAix4i2KxcQfjtIVcrVbB3vbmwg==", - "dev": true + "escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==" }, "escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", - "dev": true + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" }, "escape-string-regexp": { "version": "1.0.5", @@ -9682,33 +11500,19 @@ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, - "escodegen": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.1.0.tgz", - "integrity": "sha1-xmOSP24gqtSNDA+knzHG1PSTYM8=", - "dev": true, + "eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", "requires": { - "esprima": "~1.0.4", - "estraverse": "~1.5.0", - "esutils": "~1.0.0", - "source-map": "~0.1.30" + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" }, "dependencies": { - "esprima": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz", - "integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0=", - "dev": true - }, - "source-map": { - "version": "0.1.43", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz", - "integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=", - "dev": true, - "optional": true, - "requires": { - "amdefine": ">=0.0.4" - } + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==" } } }, @@ -9718,66 +11522,55 @@ "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true }, - "estraverse": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.5.1.tgz", - "integrity": "sha1-hno+jlip+EYYr7bC3bzZFrfLr3E=", - "dev": true - }, - "esutils": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-1.0.0.tgz", - "integrity": "sha1-gVHTWOIMisx/t0XnRywAJf5JZXA=", - "dev": true + "esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "requires": { + "estraverse": "^5.2.0" + }, + "dependencies": { + "estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==" + } + } }, "etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", - "dev": true + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" }, "eventemitter3": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.0.tgz", - "integrity": "sha512-qerSRB0p+UDEssxTtm6EDKcE7W4OaoisfIMl4CngyEhjpYglocpNg6UEqCvemdGhosAsg4sO2dXJOdyBifPGCg==", - "dev": true + "integrity": "sha512-qerSRB0p+UDEssxTtm6EDKcE7W4OaoisfIMl4CngyEhjpYglocpNg6UEqCvemdGhosAsg4sO2dXJOdyBifPGCg==" }, "events": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/events/-/events-2.1.0.tgz", "integrity": "sha512-3Zmiobend8P9DjmKAty0Era4jV8oJ0yGYe2nJJAxgymF9+N8F2m0hhZiMoWtcfepExzNKZumFU3ksdQbInGWCg==", - "dev": true + "dev": true, + "peer": true }, "evp_bytestokey": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", "dev": true, + "peer": true, "requires": { "md5.js": "^1.3.4", "safe-buffer": "^5.1.1" } }, - "execa": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-0.10.0.tgz", - "integrity": "sha512-7XOMnz8Ynx1gGo/3hyV9loYNPWM94jG3+3T3Y8tsfSstFmETmENCMU/A/zj8Lyaj1lkgEepKepvd6240tBRvlw==", - "dev": true, - "requires": { - "cross-spawn": "^6.0.0", - "get-stream": "^3.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" - } - }, "expand-brackets": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", "dev": true, + "peer": true, "requires": { "debug": "^2.3.3", "define-property": "^0.2.5", @@ -9793,6 +11586,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, + "peer": true, "requires": { "is-descriptor": "^0.1.0" } @@ -9802,82 +11596,92 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, + "peer": true, "requires": { "is-extendable": "^0.1.0" } } } }, - "expand-tilde": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", - "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", - "dev": true, - "requires": { - "homedir-polyfill": "^1.0.1" - } - }, - "exposify": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/exposify/-/exposify-0.5.0.tgz", - "integrity": "sha1-+S0AlMJls/VT4fpFagOhiD0QWcw=", - "dev": true, + "express": { + "version": "4.18.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", + "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", "requires": { - "globo": "~1.1.0", - "map-obj": "~1.0.1", - "replace-requires": "~1.0.3", - "through2": "~0.4.0", - "transformify": "~0.1.1" + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "1.20.1", + "content-disposition": "0.5.4", + "content-type": "~1.0.4", + "cookie": "0.5.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.2.0", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.7", + "qs": "6.11.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "0.18.0", + "serve-static": "1.15.0", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" }, "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" }, - "object-keys": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz", - "integrity": "sha1-KKaq50KN0sOpLz2V8hM13SBOAzY=", - "dev": true + "cookie": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", + "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==" }, - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, + "finalhandler": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", + "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "statuses": "2.0.1", + "unpipe": "~1.0.0" } }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, - "through2": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.4.2.tgz", - "integrity": "sha1-2/WGYDEVHsg1K7bE22SiKSqEC5s=", - "dev": true, + "on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", "requires": { - "readable-stream": "~1.0.17", - "xtend": "~2.1.1" + "ee-first": "1.1.1" } }, - "xtend": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-2.1.2.tgz", - "integrity": "sha1-bv7MKk2tjmlixJAbM3znuoe10os=", - "dev": true, - "requires": { - "object-keys": "~0.4.0" - } + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" + }, + "statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==" } } }, @@ -9892,6 +11696,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", "dev": true, + "peer": true, "requires": { "assign-symbols": "^1.0.0", "is-extendable": "^1.0.1" @@ -9902,6 +11707,7 @@ "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, + "peer": true, "requires": { "is-plain-object": "^2.0.4" } @@ -9913,6 +11719,7 @@ "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", "dev": true, + "peer": true, "requires": { "array-unique": "^0.3.2", "define-property": "^1.0.0", @@ -9929,6 +11736,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, + "peer": true, "requires": { "is-descriptor": "^1.0.0" } @@ -9938,6 +11746,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, + "peer": true, "requires": { "is-extendable": "^0.1.0" } @@ -9947,6 +11756,7 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, + "peer": true, "requires": { "kind-of": "^6.0.0" } @@ -9956,6 +11766,7 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, + "peer": true, "requires": { "kind-of": "^6.0.0" } @@ -9965,6 +11776,7 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, + "peer": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -9973,17 +11785,51 @@ } } }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + }, + "fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" + }, "fast-safe-stringify": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz", "integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==", + "dev": true, + "peer": true + }, + "fastest-levenshtein": { + "version": "1.0.16", + "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz", + "integrity": "sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg==", "dev": true }, + "faye-websocket": { + "version": "0.11.4", + "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.11.4.tgz", + "integrity": "sha512-CzbClwlXAuiRQAlUyfqPgvPoNKTckTPGfwZV4ZdAhVcP2lh9KUxJg2b5GkE7XbjKQ3YJnQ9z6D9ntLAlB+tP8g==", + "requires": { + "websocket-driver": ">=0.5.1" + } + }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "dev": true, + "optional": true, + "peer": true + }, "fill-range": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", "dev": true, + "peer": true, "requires": { "extend-shallow": "^2.0.1", "is-number": "^3.0.0", @@ -9996,6 +11842,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, + "peer": true, "requires": { "is-extendable": "^0.1.0" } @@ -10017,22 +11864,6 @@ "unpipe": "~1.0.0" } }, - "find-node-modules": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/find-node-modules/-/find-node-modules-2.0.0.tgz", - "integrity": "sha512-8MWIBRgJi/WpjjfVXumjPKCtmQ10B+fjx6zmSA+770GMJirLhWIzg8l763rhjl9xaeaHbnxPNRQKq2mgMhr+aw==", - "dev": true, - "requires": { - "findup-sync": "^3.0.0", - "merge": "^1.2.1" - } - }, - "find-parent-dir": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/find-parent-dir/-/find-parent-dir-0.3.0.tgz", - "integrity": "sha1-M8RLQpqysvBkYpnF+fcY83b/jVQ=", - "dev": true - }, "find-up": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", @@ -10042,18 +11873,6 @@ "locate-path": "^3.0.0" } }, - "findup-sync": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-3.0.0.tgz", - "integrity": "sha512-YbffarhcicEhOrm4CtrwdKBdCuz576RLdhJDsIfvNtxUuhdRet1qZcsMjqbePtAseKdAnDyM/IyXbu7PRPRLYg==", - "dev": true, - "requires": { - "detect-file": "^1.0.0", - "is-glob": "^4.0.0", - "micromatch": "^3.0.4", - "resolve-dir": "^1.0.1" - } - }, "flat": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", @@ -10090,7 +11909,6 @@ "version": "1.11.0", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.11.0.tgz", "integrity": "sha512-KZm0V+ll8PfBrKwMzdo5D13b1bur9Iq9Zd/RMmAoQQcl2PxxFml8cxXPaaPYVbV0RjNjq1CU7zIzAOqtUPudmA==", - "dev": true, "requires": { "debug": "^3.0.0" }, @@ -10099,7 +11917,6 @@ "version": "3.2.6", "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", - "dev": true, "requires": { "ms": "^2.1.1" } @@ -10107,8 +11924,7 @@ "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" } } }, @@ -10116,7 +11932,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true + "dev": true, + "peer": true }, "formatio": { "version": "1.2.0", @@ -10127,11 +11944,17 @@ "samsam": "1.x" } }, + "forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==" + }, "fragment-cache": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", "dev": true, + "peer": true, "requires": { "map-cache": "^0.2.2" } @@ -10139,27 +11962,7 @@ "fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", - "dev": true - }, - "from2": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", - "integrity": "sha1-i/tVAr3kpNNs/e6gB/zKIdfjgq8=", - "dev": true, - "requires": { - "inherits": "^2.0.1", - "readable-stream": "^2.0.0" - } - }, - "from2-string": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/from2-string/-/from2-string-1.1.0.tgz", - "integrity": "sha1-GCgrJ9CKJnyzAwzSuLSw8hKvdSo=", - "dev": true, - "requires": { - "from2": "^2.0.3" - } + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" }, "fs-access": { "version": "1.0.1", @@ -10181,41 +11984,33 @@ "universalify": "^0.1.0" } }, + "fs-monkey": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/fs-monkey/-/fs-monkey-1.0.3.tgz", + "integrity": "sha512-cybjIfiiE+pTWicSCLFHSrXZ6EilF30oh91FDP9S2B051prEa7QWfrVTQm10/dDpswBDXZugPa1Ogu8Yh+HV0Q==" + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "optional": true }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - }, - "garnish": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/garnish/-/garnish-5.2.0.tgz", - "integrity": "sha1-vtQ2WTguSxmOM8eTiXvnxwHmVXc=", - "dev": true, - "requires": { - "chalk": "^0.5.1", - "minimist": "^1.1.0", - "pad-left": "^2.0.0", - "pad-right": "^0.2.2", - "prettier-bytes": "^1.0.3", - "pretty-ms": "^2.1.0", - "right-now": "^1.0.0", - "split2": "^0.2.1", - "stdout-stream": "^1.4.0", - "url-trim": "^1.0.0" - } + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, "get-assigned-identifiers": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz", "integrity": "sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ==", - "dev": true + "dev": true, + "peer": true }, "get-caller-file": { "version": "2.0.5", @@ -10223,26 +12018,22 @@ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, - "get-ports": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/get-ports/-/get-ports-1.0.3.tgz", - "integrity": "sha1-9AvVgKyn7A77e5bL/L6wPviUteg=", - "dev": true, + "get-intrinsic": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.3.tgz", + "integrity": "sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==", "requires": { - "map-limit": "0.0.1" + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.3" } }, - "get-stream": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", - "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", - "dev": true - }, "get-value": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", - "dev": true + "dev": true, + "peer": true }, "gl-preserve-state": { "version": "1.0.0", @@ -10254,7 +12045,6 @@ "version": "7.1.6", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", - "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -10269,6 +12059,7 @@ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", "dev": true, + "peer": true, "requires": { "is-glob": "^3.1.0", "path-dirname": "^1.0.0" @@ -10279,12 +12070,18 @@ "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", "dev": true, + "peer": true, "requires": { "is-extglob": "^2.1.0" } } } }, + "glob-to-regexp": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", + "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==" + }, "global": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/global/-/global-4.4.0.tgz", @@ -10295,46 +12092,10 @@ "process": "^0.11.10" } }, - "global-modules": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", - "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", - "dev": true, - "requires": { - "global-prefix": "^1.0.1", - "is-windows": "^1.0.1", - "resolve-dir": "^1.0.0" - } - }, - "global-prefix": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz", - "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", - "dev": true, - "requires": { - "expand-tilde": "^2.0.2", - "homedir-polyfill": "^1.0.1", - "ini": "^1.3.4", - "is-windows": "^1.0.1", - "which": "^1.2.14" - } - }, - "globo": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/globo/-/globo-1.1.0.tgz", - "integrity": "sha1-DSYJiVXepCLrIAGxBImLChAcqvM=", - "dev": true, - "requires": { - "accessory": "~1.1.0", - "is-defined": "~1.0.0", - "ternary": "~1.0.0" - } - }, "graceful-fs": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", - "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", - "dev": true + "version": "4.2.10", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==" }, "growl": { "version": "1.10.5", @@ -10342,24 +12103,19 @@ "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", "dev": true }, + "handle-thing": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/handle-thing/-/handle-thing-2.0.1.tgz", + "integrity": "sha512-9Qn4yBxelxoh2Ow62nP+Ka/kMnOXRi8BXnRaUwezLNhqelnN49xKz4F/dPP8OYLxLxq6JDtZb2i9XznUQbNPTg==" + }, "has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, "requires": { "function-bind": "^1.1.1" } }, - "has-ansi": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-0.1.0.tgz", - "integrity": "sha1-hPJlqujA5qiKEtcCKJS3VoiUxi4=", - "dev": true, - "requires": { - "ansi-regex": "^0.2.0" - } - }, "has-binary2": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.3.tgz", @@ -10389,26 +12145,17 @@ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, - "has-require": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/has-require/-/has-require-1.2.2.tgz", - "integrity": "sha1-khZ1qxMNvZdo/I2o8ajiQt+kF3Q=", - "dev": true, - "requires": { - "escape-string-regexp": "^1.0.3" - } - }, "has-symbols": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", - "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", - "dev": true + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==" }, "has-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", "dev": true, + "peer": true, "requires": { "get-value": "^2.0.6", "has-values": "^1.0.0", @@ -10420,6 +12167,7 @@ "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", "dev": true, + "peer": true, "requires": { "is-number": "^3.0.0", "kind-of": "^4.0.0" @@ -10430,6 +12178,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", "dev": true, + "peer": true, "requires": { "is-buffer": "^1.1.5" } @@ -10441,6 +12190,7 @@ "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz", "integrity": "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==", "dev": true, + "peer": true, "requires": { "inherits": "^2.0.4", "readable-stream": "^3.6.0", @@ -10451,13 +12201,15 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "dev": true, + "peer": true }, "readable-stream": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", "dev": true, + "peer": true, "requires": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -10471,6 +12223,7 @@ "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", "dev": true, + "peer": true, "requires": { "inherits": "^2.0.3", "minimalistic-assert": "^1.0.1" @@ -10493,70 +12246,148 @@ "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", "dev": true, + "peer": true, "requires": { "hash.js": "^1.0.3", "minimalistic-assert": "^1.0.0", "minimalistic-crypto-utils": "^1.0.1" } }, - "homedir-polyfill": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", - "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", - "dev": true, + "hpack.js": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/hpack.js/-/hpack.js-2.1.6.tgz", + "integrity": "sha512-zJxVehUdMGIKsRaNt7apO2Gqp0BdqW5yaiGHXXmbpvxgBYVZnAql+BJb4RO5ad2MgpbZKn5G6nMnegrH1FcNYQ==", "requires": { - "parse-passwd": "^1.0.0" + "inherits": "^2.0.1", + "obuf": "^1.0.0", + "readable-stream": "^2.0.1", + "wbuf": "^1.1.0" } }, + "html-entities": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.3.3.tgz", + "integrity": "sha512-DV5Ln36z34NNTDgnz0EWGBLZENelNAtkiFA4kyNOG2tDI6Mz1uSWiq1wAKdyjnJwyDiDO7Fa2SO1CTxPXL8VxA==" + }, "htmlescape": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz", "integrity": "sha1-OgPtwiFLyjtmQko+eVk0lQnLA1E=", - "dev": true + "dev": true, + "peer": true + }, + "http-deceiver": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/http-deceiver/-/http-deceiver-1.2.7.tgz", + "integrity": "sha512-LmpOGxTfbpgtGVxJrj5k7asXHCgNZp5nLfp+hWc8QQRqtb7fUy6kRY3BO1h9ddF6yIPYUARgxGOwB42DnxIaNw==" }, "http-errors": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.3.tgz", - "integrity": "sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw==", - "dev": true, + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", "requires": { - "depd": "~1.1.2", + "depd": "2.0.0", "inherits": "2.0.4", - "setprototypeof": "1.1.1", - "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.0" + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" }, "dependencies": { "inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==" } } }, + "http-parser-js": { + "version": "0.5.8", + "resolved": "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.5.8.tgz", + "integrity": "sha512-SGeBX54F94Wgu5RH3X5jsDtf4eHyRogWX1XGT3b4HuW3tQPM4AaBzoUji/4AAJNXCEOWZ5O0DgZmJw1947gD5Q==" + }, "http-proxy": { "version": "1.18.1", "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz", "integrity": "sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==", - "dev": true, "requires": { "eventemitter3": "^4.0.0", "follow-redirects": "^1.0.0", "requires-port": "^1.0.0" } }, + "http-proxy-middleware": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz", + "integrity": "sha512-ya/UeJ6HVBYxrgYotAZo1KvPWlgB48kUJLDePFeneHsVujFaW5WNj2NgWCAE//B1Dl02BIfYlpNgBy8Kf8Rjmw==", + "requires": { + "@types/http-proxy": "^1.17.8", + "http-proxy": "^1.18.1", + "is-glob": "^4.0.1", + "is-plain-obj": "^3.0.0", + "micromatch": "^4.0.2" + }, + "dependencies": { + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "requires": { + "fill-range": "^7.0.1" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" + }, + "micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "requires": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "requires": { + "is-number": "^7.0.0" + } + } + } + }, "https-browserify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", - "dev": true + "dev": true, + "peer": true + }, + "human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==" }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "dev": true, "requires": { "safer-buffer": ">= 2.1.2 < 3" } @@ -10565,7 +12396,18 @@ "version": "1.1.13", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==", - "dev": true + "dev": true, + "peer": true + }, + "import-local": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", + "integrity": "sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==", + "dev": true, + "requires": { + "pkg-dir": "^4.2.0", + "resolve-cwd": "^3.0.0" + } }, "indexof": { "version": "0.0.1", @@ -10573,17 +12415,10 @@ "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=", "dev": true }, - "individual": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/individual/-/individual-3.0.0.tgz", - "integrity": "sha1-58pPhfiVewGHNPKFdQ3CLsL5hi0=", - "dev": true - }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, "requires": { "once": "^1.3.0", "wrappy": "1" @@ -10592,29 +12427,14 @@ "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "ini": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", - "dev": true - }, - "inject-lr-script": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/inject-lr-script/-/inject-lr-script-2.2.0.tgz", - "integrity": "sha512-lFLjCOg2XP8233AiET5vFePo910vhNIkKHDzUptNhc+4Y7dsp/TNBiusUUpaxzaGd6UDHy0Lozfl9AwmteK6DQ==", - "dev": true, - "requires": { - "resp-modifier": "^6.0.0" - } + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, "inline-source-map": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.6.2.tgz", "integrity": "sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU=", "dev": true, + "peer": true, "requires": { "source-map": "~0.5.3" } @@ -10624,6 +12444,7 @@ "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.2.0.tgz", "integrity": "sha512-VE6NlW+WGn2/AeOMd496AHFYmE7eLKkUY6Ty31k4og5vmA3Fjuwe9v6ifH6Xx/Hz27QvdoMoviw1/pqWRB09Sw==", "dev": true, + "peer": true, "requires": { "acorn-node": "^1.5.2", "combine-source-map": "^0.8.0", @@ -10641,37 +12462,28 @@ "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", - "dev": true + "dev": true, + "peer": true } } }, - "internal-ip": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/internal-ip/-/internal-ip-3.0.1.tgz", - "integrity": "sha512-NXXgESC2nNVtU+pqmC9e6R8B1GpKxzsAQhffvh5AL79qKnodd+L7tnEQmTiUAVngqLalPbSqRA7XGIEL5nCd0Q==", - "dev": true, - "requires": { - "default-gateway": "^2.6.0", - "ipaddr.js": "^1.5.2" - } - }, - "ip-regex": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-2.1.0.tgz", - "integrity": "sha1-+ni/XS5pE8kRzp+BnuUUa7bYROk=", + "interpret": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-3.1.1.tgz", + "integrity": "sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ==", "dev": true }, "ipaddr.js": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", - "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", - "dev": true + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==" }, "is-accessor-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, + "peer": true, "requires": { "kind-of": "^3.0.2" }, @@ -10681,6 +12493,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, + "peer": true, "requires": { "is-buffer": "^1.1.5" } @@ -10692,6 +12505,7 @@ "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", "dev": true, + "peer": true, "requires": { "binary-extensions": "^1.0.0" } @@ -10708,11 +12522,21 @@ "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==", "dev": true }, + "is-core-module": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz", + "integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, "is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, + "peer": true, "requires": { "kind-of": "^3.0.2" }, @@ -10722,6 +12546,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, + "peer": true, "requires": { "is-buffer": "^1.1.5" } @@ -10734,17 +12559,12 @@ "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", "dev": true }, - "is-defined": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-defined/-/is-defined-1.0.0.tgz", - "integrity": "sha1-HwfKZ9Vx9ZTEsUQVpF9774j5K/U=", - "dev": true - }, "is-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", "dev": true, + "peer": true, "requires": { "is-accessor-descriptor": "^0.1.6", "is-data-descriptor": "^0.1.4", @@ -10755,33 +12575,27 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true + "dev": true, + "peer": true } } }, "is-docker": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.0.0.tgz", - "integrity": "sha512-pJEdRugimx4fBMra5z2/5iRdZ63OhYV0vr0Dwm5+xtW4D1FvRkB8hamMIhnWfyJeDdyr/aa7BDyNbtG38VxgoQ==", - "dev": true + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==" }, "is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "dev": true + "dev": true, + "peer": true }, "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true - }, - "is-finite": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.1.0.tgz", - "integrity": "sha512-cdyMtqX/BOqqNBBiKlIVkytNHm49MtMlYyn1zxzvJKWmFMlGzm+ry5BBfYyeY9YmNKbRSo/o7OX9w9ale0wg3w==", - "dev": true + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" }, "is-fullwidth-code-point": { "version": "2.0.0", @@ -10799,7 +12613,6 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", - "dev": true, "requires": { "is-extglob": "^2.1.1" } @@ -10809,6 +12622,7 @@ "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, + "peer": true, "requires": { "kind-of": "^3.0.2" }, @@ -10818,6 +12632,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, + "peer": true, "requires": { "is-buffer": "^1.1.5" } @@ -10830,6 +12645,11 @@ "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", "dev": true }, + "is-plain-obj": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-3.0.0.tgz", + "integrity": "sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA==" + }, "is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -10848,18 +12668,6 @@ "has": "^1.0.3" } }, - "is-regexp": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-regexp/-/is-regexp-1.0.0.tgz", - "integrity": "sha1-/S2INUXEa6xaYz57mgnof6LLUGk=", - "dev": true - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", - "dev": true - }, "is-symbol": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", @@ -10873,13 +12681,13 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", - "dev": true + "dev": true, + "peer": true }, "is-wsl": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", - "dev": true, "requires": { "is-docker": "^2.0.0" } @@ -10887,8 +12695,7 @@ "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" }, "isbinaryfile": { "version": "3.0.3", @@ -10902,8 +12709,7 @@ "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" }, "isobject": { "version": "3.0.1", @@ -10911,6 +12717,31 @@ "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", "dev": true }, + "jest-worker": { + "version": "27.5.1", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-27.5.1.tgz", + "integrity": "sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==", + "requires": { + "@types/node": "*", + "merge-stream": "^2.0.0", + "supports-color": "^8.0.0" + }, + "dependencies": { + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" + }, + "supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, "js-string-escape": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/js-string-escape/-/js-string-escape-1.0.1.tgz", @@ -10927,21 +12758,26 @@ "esprima": "^4.0.0" } }, + "json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==" + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" + }, "json-stable-stringify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz", "integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=", "dev": true, + "peer": true, "requires": { "jsonify": "~0.0.0" } }, - "json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", - "dev": true - }, "jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", @@ -10955,19 +12791,22 @@ "version": "0.0.0", "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", - "dev": true + "dev": true, + "peer": true }, "jsonparse": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", - "dev": true + "dev": true, + "peer": true }, "JSONStream": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", "dev": true, + "peer": true, "requires": { "jsonparse": "^1.2.0", "through": ">=2.2.7 <3" @@ -11057,6 +12896,13 @@ "to-regex-range": "^5.0.1" } }, + "fsevents": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz", + "integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==", + "dev": true, + "optional": true + }, "glob-parent": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", @@ -11253,6 +13099,7 @@ "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.2.tgz", "integrity": "sha512-Ca4LSXFFZUjPScRaqOcFxneA0VpKZr4MMYCljyQr4LIewTLb3Y0IUTIsnBBsVubIeEfxeSZpSjSsRM8APEQaAw==", "dev": true, + "peer": true, "requires": { "inherits": "^2.0.1", "stream-splicer": "^2.0.0" @@ -11285,6 +13132,11 @@ "xtend": "^4.0.0" } }, + "loader-runner": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz", + "integrity": "sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==" + }, "locate-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", @@ -11305,7 +13157,8 @@ "version": "3.0.4", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz", "integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=", - "dev": true + "dev": true, + "peer": true }, "log-symbols": { "version": "2.2.0", @@ -11397,7 +13250,8 @@ "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "dev": true + "dev": true, + "peer": true }, "map-limit": { "version": "0.0.1", @@ -11419,37 +13273,22 @@ } } }, - "map-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", - "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", - "dev": true - }, "map-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", "dev": true, + "peer": true, "requires": { "object-visit": "^1.0.0" } }, - "md5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/md5/-/md5-2.2.1.tgz", - "integrity": "sha1-U6s41f48iJG6RlMp6iP6wFQBJvk=", - "dev": true, - "requires": { - "charenc": "~0.0.1", - "crypt": "~0.0.1", - "is-buffer": "~1.1.1" - } - }, "md5.js": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", "dev": true, + "peer": true, "requires": { "hash-base": "^3.0.0", "inherits": "^2.0.1", @@ -11459,20 +13298,37 @@ "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", - "dev": true + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "memfs": { + "version": "3.4.12", + "resolved": "https://registry.npmjs.org/memfs/-/memfs-3.4.12.tgz", + "integrity": "sha512-BcjuQn6vfqP+k100e0E9m61Hyqa//Brp+I3f0OBmN0ATHlFA8vx3Lt8z57R3u2bPqe3WGDBC+nF72fTH7isyEw==", + "requires": { + "fs-monkey": "^1.0.3" + } + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" + }, + "merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" }, - "merge": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/merge/-/merge-1.2.1.tgz", - "integrity": "sha512-VjFo4P5Whtj4vsLzsYBu5ayHhoHJ0UqNm7ibvShmbmoz7tGi0vXaoJbGdB+GmDMLUdg8DpQXEIeVDAe8MaABvQ==", - "dev": true + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==" }, "micromatch": { "version": "3.1.10", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", "dev": true, + "peer": true, "requires": { "arr-diff": "^4.0.0", "array-unique": "^0.3.2", @@ -11494,6 +13350,7 @@ "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", "dev": true, + "peer": true, "requires": { "bn.js": "^4.0.0", "brorand": "^1.0.1" @@ -11503,31 +13360,34 @@ "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true + "dev": true, + "peer": true } } }, "mime": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", - "dev": true + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" }, "mime-db": { - "version": "1.44.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", - "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==", - "dev": true + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==" }, "mime-types": { - "version": "2.1.27", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", - "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", - "dev": true, + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", "requires": { - "mime-db": "1.44.0" + "mime-db": "1.52.0" } }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" + }, "mimic-response": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", @@ -11546,20 +13406,19 @@ "minimalistic-assert": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", - "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", - "dev": true + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" }, "minimalistic-crypto-utils": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=", - "dev": true + "dev": true, + "peer": true }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", - "dev": true, "requires": { "brace-expansion": "^1.1.7" } @@ -11575,6 +13434,7 @@ "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", "dev": true, + "peer": true, "requires": { "for-in": "^1.0.2", "is-extendable": "^1.0.1" @@ -11585,6 +13445,7 @@ "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, + "peer": true, "requires": { "is-plain-object": "^2.0.4" } @@ -11604,7 +13465,8 @@ "version": "0.5.3", "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", - "dev": true + "dev": true, + "peer": true }, "mocha": { "version": "6.2.3", @@ -11682,6 +13544,7 @@ "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-6.2.2.tgz", "integrity": "sha512-a9y6yDv5u5I4A+IPHTnqFxcaKr4p50/zxTjcQJaX2ws9tN/W6J6YXnEKhqRyPhl494dkcxx951onSKVezmI+3w==", "dev": true, + "peer": true, "requires": { "browser-resolve": "^1.7.0", "cached-path-relative": "^1.0.2", @@ -11700,26 +13563,34 @@ "xtend": "^4.0.0" } }, - "mothership": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/mothership/-/mothership-0.2.0.tgz", - "integrity": "sha1-k9SKL7w+UOKl/I7VhvW8RMZfmpk=", - "dev": true, - "requires": { - "find-parent-dir": "~0.3.0" - } - }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "multicast-dns": { + "version": "7.2.5", + "resolved": "https://registry.npmjs.org/multicast-dns/-/multicast-dns-7.2.5.tgz", + "integrity": "sha512-2eznPJP8z2BFLX50tf0LuODrpINqP1RVIm/CObbTcBRITQgmC/TjcREF1NeTBzIcR5XO/ukWo+YHOjBbFwIupg==", + "requires": { + "dns-packet": "^5.2.2", + "thunky": "^1.0.2" + } + }, + "nan": { + "version": "2.17.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz", + "integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==", + "dev": true, + "optional": true, + "peer": true }, "nanomatch": { "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", "dev": true, + "peer": true, "requires": { "arr-diff": "^4.0.0", "array-unique": "^0.3.2", @@ -11741,10 +13612,14 @@ "dev": true }, "negotiator": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", - "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==", - "dev": true + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==" + }, + "neo-async": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", + "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" }, "new-array": { "version": "1.0.0", @@ -11764,12 +13639,6 @@ "xhr-request": "^1.0.1" } }, - "nice-try": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", - "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", - "dev": true - }, "node-environment-flags": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.5.tgz", @@ -11780,11 +13649,20 @@ "semver": "^5.7.0" } }, + "node-forge": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", + "integrity": "sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==" + }, + "node-releases": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.8.tgz", + "integrity": "sha512-dFSmB8fFHEH/s81Xi+Y/15DQY6VHW81nXRj86EMSL3lmuTmK1e+aT4wrFCkTbm+gSwkw4KpX+rT/pMM2c1mF+A==" + }, "normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" }, "nosleep.js": { "version": "0.7.0", @@ -11792,15 +13670,6 @@ "integrity": "sha1-z9kZwlUjyg0PSmn7MwXAg62u4ok=", "dev": true }, - "npm-run-path": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", - "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", - "dev": true, - "requires": { - "path-key": "^2.0.0" - } - }, "null-check": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/null-check/-/null-check-1.0.0.tgz", @@ -11824,6 +13693,7 @@ "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", "dev": true, + "peer": true, "requires": { "copy-descriptor": "^0.1.0", "define-property": "^0.2.5", @@ -11835,6 +13705,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, + "peer": true, "requires": { "is-descriptor": "^0.1.0" } @@ -11844,6 +13715,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, + "peer": true, "requires": { "is-buffer": "^1.1.5" } @@ -11851,10 +13723,9 @@ } }, "object-inspect": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", - "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", - "dev": true + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz", + "integrity": "sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==" }, "object-keys": { "version": "1.1.1", @@ -11867,6 +13738,7 @@ "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", "dev": true, + "peer": true, "requires": { "isobject": "^3.0.0" } @@ -11898,10 +13770,16 @@ "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", "dev": true, + "peer": true, "requires": { "isobject": "^3.0.1" } }, + "obuf": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/obuf/-/obuf-1.1.2.tgz", + "integrity": "sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==" + }, "on-finished": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", @@ -11914,25 +13792,32 @@ "on-headers": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", - "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==", - "dev": true + "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==" }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, "requires": { "wrappy": "1" } }, - "opn": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/opn/-/opn-3.0.3.tgz", - "integrity": "sha1-ttmec5n3jWXDuq/+8fsojpuFJDo=", - "dev": true, + "onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", "requires": { - "object-assign": "^4.0.1" + "mimic-fn": "^2.1.0" + } + }, + "open": { + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/open/-/open-8.4.0.tgz", + "integrity": "sha512-XgFPPM+B28FtCCgSb9I+s9szOC1vZRSwgWsRUA5ylIxRTgKozqjOCrVOqGsYABPYK5qnfqClxZTFBa8PKt2v6Q==", + "requires": { + "define-lazy-prop": "^2.0.0", + "is-docker": "^2.1.1", + "is-wsl": "^2.2.0" } }, "optimist": { @@ -11957,7 +13842,8 @@ "version": "0.3.0", "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=", - "dev": true + "dev": true, + "peer": true }, "os-shim": { "version": "0.1.3", @@ -11976,16 +13862,11 @@ "resolved": "https://registry.npmjs.org/outpipe/-/outpipe-1.1.1.tgz", "integrity": "sha1-UM+GFjZeh+Ax4ppeyTOaPaRyX6I=", "dev": true, + "peer": true, "requires": { "shell-quote": "^1.4.2" } }, - "p-finally": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", - "dev": true - }, "p-limit": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", @@ -12004,41 +13885,34 @@ "p-limit": "^2.0.0" } }, + "p-retry": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-4.6.2.tgz", + "integrity": "sha512-312Id396EbJdvRONlngUx0NydfrIQ5lsYu0znKVUzVvArzEIt08V1qhtyESbGVd1FGX7UKtiFp5uwKZdM8wIuQ==", + "requires": { + "@types/retry": "0.12.0", + "retry": "^0.13.1" + } + }, "p-try": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, - "pad-left": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/pad-left/-/pad-left-2.1.0.tgz", - "integrity": "sha1-FuajstRKjhOMsIOMx8tAOk/J6ZQ=", - "dev": true, - "requires": { - "repeat-string": "^1.5.4" - } - }, - "pad-right": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/pad-right/-/pad-right-0.2.2.tgz", - "integrity": "sha1-b7ySQEXSRPKiokRQMGDTv8YAl3Q=", - "dev": true, - "requires": { - "repeat-string": "^1.5.2" - } - }, "pako": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", - "dev": true + "dev": true, + "peer": true }, "parents": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz", "integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=", "dev": true, + "peer": true, "requires": { "path-platform": "~0.11.15" } @@ -12048,6 +13922,7 @@ "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.5.tgz", "integrity": "sha512-jkMYn1dcJqF6d5CpU689bq7w/b5ALS9ROVSpQDPrZsqqesUJii9qutvoT5ltGedNXMO2e16YUWIghG9KxaViTQ==", "dev": true, + "peer": true, "requires": { "asn1.js": "^4.0.0", "browserify-aes": "^1.0.0", @@ -12085,18 +13960,6 @@ "integrity": "sha512-QhhZ+DCCit2Coi2vmAKbq5RGTRcQUOE2+REgv8vdyu7MnYx2eZztegqtTx99TZ86GTIwqiy3+4nQTWZ2tgmdCA==", "dev": true }, - "parse-ms": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-1.0.1.tgz", - "integrity": "sha1-VjRtR0nXjyNDDKDHE4UK75GqNh0=", - "dev": true - }, - "parse-passwd": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", - "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", - "dev": true - }, "parseqs": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", @@ -12118,32 +13981,28 @@ "parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", - "dev": true + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" }, "pascalcase": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", - "dev": true - }, - "patch-text": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/patch-text/-/patch-text-1.0.2.tgz", - "integrity": "sha1-S/NuZeUXM9bpjwz2LgkDTaoDSKw=", - "dev": true + "dev": true, + "peer": true }, "path-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", "integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==", - "dev": true + "dev": true, + "peer": true }, "path-dirname": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", - "dev": true + "dev": true, + "peer": true }, "path-exists": { "version": "3.0.0", @@ -12154,26 +14013,20 @@ "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "path-key": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", - "dev": true + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, "path-platform": { "version": "0.11.15", "resolved": "https://registry.npmjs.org/path-platform/-/path-platform-0.11.15.tgz", "integrity": "sha1-6GQhf3TDaFDwhSt43Hv31KVyG/I=", - "dev": true + "dev": true, + "peer": true }, "path-to-regexp": { "version": "1.8.0", @@ -12197,6 +14050,7 @@ "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", "dev": true, + "peer": true, "requires": { "create-hash": "^1.1.2", "create-hmac": "^1.1.4", @@ -12205,52 +14059,73 @@ "sha.js": "^2.4.8" } }, - "pem": { - "version": "1.14.4", - "resolved": "https://registry.npmjs.org/pem/-/pem-1.14.4.tgz", - "integrity": "sha512-v8lH3NpirgiEmbOqhx0vwQTxwi0ExsiWBGYh0jYNq7K6mQuO4gI6UEFlr6fLAdv9TPXRt6GqiwE37puQdIDS8g==", + "phin": { + "version": "2.9.3", + "resolved": "https://registry.npmjs.org/phin/-/phin-2.9.3.tgz", + "integrity": "sha512-CzFr90qM24ju5f88quFC/6qohjC144rehe5n6DH900lgXmUe86+xCKc10ev56gRKC4/BkHUoG4uSiQgBiIXwDA==", + "dev": true + }, + "picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" + }, + "pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", "dev": true, "requires": { - "es6-promisify": "^6.0.0", - "md5": "^2.2.1", - "os-tmpdir": "^1.0.1", - "which": "^2.0.2" + "find-up": "^4.0.0" }, "dependencies": { - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", "dev": true, "requires": { - "isexe": "^2.0.0" + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true } } }, - "phin": { - "version": "2.9.3", - "resolved": "https://registry.npmjs.org/phin/-/phin-2.9.3.tgz", - "integrity": "sha512-CzFr90qM24ju5f88quFC/6qohjC144rehe5n6DH900lgXmUe86+xCKc10ev56gRKC4/BkHUoG4uSiQgBiIXwDA==", - "dev": true - }, - "picomatch": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", - "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", - "dev": true - }, - "plur": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/plur/-/plur-1.0.0.tgz", - "integrity": "sha1-24XGgU9eXlo7Se/CjWBP7GKXUVY=", - "dev": true - }, "posix-character-classes": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", - "dev": true + "dev": true, + "peer": true }, "present": { "version": "0.0.6", @@ -12258,23 +14133,6 @@ "integrity": "sha1-nu/3ANqp6ZhhM1Lkf3rCMk1PrwI=", "dev": true }, - "prettier-bytes": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/prettier-bytes/-/prettier-bytes-1.0.4.tgz", - "integrity": "sha1-mUsCqkb2mcULYle1+qp/4lV+YtY=", - "dev": true - }, - "pretty-ms": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-2.1.0.tgz", - "integrity": "sha1-QlfCVt8/sLRR1q/6qwIYhBJpgdw=", - "dev": true, - "requires": { - "is-finite": "^1.0.1", - "parse-ms": "^1.0.0", - "plur": "^1.0.0" - } - }, "process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", @@ -12284,8 +14142,7 @@ "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "dev": true + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" }, "promise-polyfill": { "version": "3.1.0", @@ -12293,6 +14150,15 @@ "integrity": "sha1-YpUrAdBZsRW0MnY7fvRhuA9t9H0=", "dev": true }, + "proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "requires": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + } + }, "pseudomap": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", @@ -12304,6 +14170,7 @@ "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", "dev": true, + "peer": true, "requires": { "bn.js": "^4.1.0", "browserify-rsa": "^4.0.0", @@ -12317,7 +14184,8 @@ "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true + "dev": true, + "peer": true } } }, @@ -12325,7 +14193,8 @@ "version": "1.4.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", - "dev": true + "dev": true, + "peer": true }, "qjobs": { "version": "1.2.0", @@ -12334,10 +14203,12 @@ "dev": true }, "qs": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", - "dev": true + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "requires": { + "side-channel": "^1.0.4" + } }, "quad-indices": { "version": "2.0.1", @@ -12365,19 +14236,20 @@ "version": "0.2.0", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", - "dev": true + "dev": true, + "peer": true }, "querystring-es3": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", - "dev": true + "dev": true, + "peer": true }, "randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", - "dev": true, "requires": { "safe-buffer": "^5.1.0" } @@ -12387,6 +14259,7 @@ "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", "dev": true, + "peer": true, "requires": { "randombytes": "^2.0.5", "safe-buffer": "^5.1.0" @@ -12395,34 +14268,17 @@ "range-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", - "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", - "dev": true + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" }, "raw-body": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", - "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", - "dev": true, + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", + "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", "requires": { - "bytes": "3.1.0", - "http-errors": "1.7.2", + "bytes": "3.1.2", + "http-errors": "2.0.0", "iconv-lite": "0.4.24", "unpipe": "1.0.0" - }, - "dependencies": { - "http-errors": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", - "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", - "dev": true, - "requires": { - "depd": "~1.1.2", - "inherits": "2.0.3", - "setprototypeof": "1.1.1", - "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.0" - } - } } }, "read-only-stream": { @@ -12430,6 +14286,7 @@ "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-2.0.0.tgz", "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=", "dev": true, + "peer": true, "requires": { "readable-stream": "^2.0.2" } @@ -12438,7 +14295,6 @@ "version": "2.3.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -12452,14 +14308,12 @@ "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, "requires": { "safe-buffer": "~5.1.0" } @@ -12471,87 +14325,53 @@ "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", "dev": true, + "peer": true, "requires": { "graceful-fs": "^4.1.11", "micromatch": "^3.1.10", "readable-stream": "^2.0.2" } }, + "rechoir": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.8.0.tgz", + "integrity": "sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==", + "dev": true, + "requires": { + "resolve": "^1.20.0" + } + }, "regex-not": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", "dev": true, + "peer": true, "requires": { "extend-shallow": "^3.0.2", "safe-regex": "^1.1.0" } }, - "reload-css": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/reload-css/-/reload-css-1.0.2.tgz", - "integrity": "sha1-avsRFi4jFP7M2tbcX96CH9cxgzE=", - "dev": true, - "requires": { - "query-string": "^4.2.3" - }, - "dependencies": { - "query-string": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-4.3.4.tgz", - "integrity": "sha1-u7aTucqRXCMlFbIosaArYJBD2+s=", - "dev": true, - "requires": { - "object-assign": "^4.1.0", - "strict-uri-encode": "^1.0.0" - } - } - } - }, "remove-trailing-separator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", - "dev": true - }, - "rename-function-calls": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/rename-function-calls/-/rename-function-calls-0.1.1.tgz", - "integrity": "sha1-f4M2nAB6MAf2q+MDPM+BaGoQjgE=", "dev": true, - "requires": { - "detective": "~3.1.0" - }, - "dependencies": { - "detective": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/detective/-/detective-3.1.0.tgz", - "integrity": "sha1-d3gkRKt1K4jKG+Lp0KA5Xx2iXu0=", - "dev": true, - "requires": { - "escodegen": "~1.1.0", - "esprima-fb": "3001.1.0-dev-harmony-fb" - } - }, - "esprima-fb": { - "version": "3001.1.0-dev-harmony-fb", - "resolved": "https://registry.npmjs.org/esprima-fb/-/esprima-fb-3001.0001.0000-dev-harmony-fb.tgz", - "integrity": "sha1-t303q8046gt3Qmu4vCkizmtCZBE=", - "dev": true - } - } + "peer": true }, "repeat-element": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", - "dev": true + "dev": true, + "peer": true }, "repeat-string": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true + "dev": true, + "peer": true }, "replace": { "version": "1.2.0", @@ -12745,42 +14565,17 @@ } } }, - "replace-requires": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/replace-requires/-/replace-requires-1.0.4.tgz", - "integrity": "sha1-AUtzMLa54lV7cQQ7ZvsCZgw79mc=", - "dev": true, - "requires": { - "detective": "^4.5.0", - "has-require": "~1.2.1", - "patch-text": "~1.0.2", - "xtend": "~4.0.0" - }, - "dependencies": { - "acorn": { - "version": "5.7.4", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz", - "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==", - "dev": true - }, - "detective": { - "version": "4.7.1", - "resolved": "https://registry.npmjs.org/detective/-/detective-4.7.1.tgz", - "integrity": "sha512-H6PmeeUcZloWtdt4DAkFyzFL94arpHr3NOwwmVILFiy+9Qd4JTxxXrzfyGk/lmct2qVGBwTSwSXagqu2BxmWig==", - "dev": true, - "requires": { - "acorn": "^5.2.1", - "defined": "^1.0.0" - } - } - } - }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", "dev": true }, + "require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==" + }, "require-main-filename": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", @@ -12790,49 +14585,52 @@ "requires-port": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=", - "dev": true + "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" }, "resolve": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", - "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", + "version": "1.22.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", + "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", "dev": true, "requires": { - "path-parse": "^1.0.6" + "is-core-module": "^2.9.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" } }, - "resolve-dir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", - "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", + "resolve-cwd": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", + "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", "dev": true, "requires": { - "expand-tilde": "^2.0.0", - "global-modules": "^1.0.0" + "resolve-from": "^5.0.0" } }, + "resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true + }, "resolve-url": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", - "dev": true - }, - "resp-modifier": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/resp-modifier/-/resp-modifier-6.0.2.tgz", - "integrity": "sha1-sSTeXE+6/LpUH0j/pzlw9KpFa08=", "dev": true, - "requires": { - "debug": "^2.2.0", - "minimatch": "^3.0.2" - } + "peer": true }, "ret": { "version": "0.1.15", "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", - "dev": true + "dev": true, + "peer": true + }, + "retry": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.13.1.tgz", + "integrity": "sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg==" }, "rfdc": { "version": "1.1.4", @@ -12840,12 +14638,6 @@ "integrity": "sha512-5C9HXdzK8EAqN7JDif30jqsBzavB7wLpaubisuQIGHWf2gUXSpzy6ArX/+Da8RjFpagWsCn+pIgxTMAmKw9Zug==", "dev": true }, - "right-now": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/right-now/-/right-now-1.0.0.tgz", - "integrity": "sha1-bolgne69fc2vja7Mmuo5z1haCRg=", - "dev": true - }, "rimraf": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", @@ -12860,22 +14652,23 @@ "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", "dev": true, + "peer": true, "requires": { "hash-base": "^3.0.0", "inherits": "^2.0.1" } }, "safe-buffer": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", - "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", - "dev": true + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" }, "safe-regex": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "dev": true, + "peer": true, "requires": { "ret": "~0.1.10" } @@ -12883,8 +14676,7 @@ "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "samsam": { "version": "1.3.0", @@ -12898,6 +14690,29 @@ "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", "dev": true }, + "schema-utils": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.1.1.tgz", + "integrity": "sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw==", + "requires": { + "@types/json-schema": "^7.0.8", + "ajv": "^6.12.5", + "ajv-keywords": "^3.5.2" + } + }, + "select-hose": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz", + "integrity": "sha512-mEugaLK+YfkijB4fx0e6kImuJdCIt2LxCRcbEYPqRGCs4F2ogyfZU5IAZRdjCP8JPq2AtdNoC/Dux63d9Kiryg==" + }, + "selfsigned": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/selfsigned/-/selfsigned-2.1.1.tgz", + "integrity": "sha512-GSL3aowiF7wa/WtSFwnUrludWFoNhftq8bUkH9pkzjpN2XSPOAYEgg6e0sS9s0rZwgJzJiQRPU18A6clnoW5wQ==", + "requires": { + "node-forge": "^1" + } + }, "semver": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", @@ -12905,44 +14720,99 @@ "dev": true }, "send": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", - "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", - "dev": true, + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", + "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", "requires": { "debug": "2.6.9", - "depd": "~1.1.2", - "destroy": "~1.0.4", + "depd": "2.0.0", + "destroy": "1.2.0", "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "etag": "~1.8.1", "fresh": "0.5.2", - "http-errors": "~1.7.2", + "http-errors": "2.0.0", "mime": "1.6.0", - "ms": "2.1.1", - "on-finished": "~2.3.0", + "ms": "2.1.3", + "on-finished": "2.4.1", "range-parser": "~1.2.1", - "statuses": "~1.5.0" + "statuses": "2.0.1" }, "dependencies": { "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", - "dev": true + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "requires": { + "ee-first": "1.1.1" + } + }, + "statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==" + } + } + }, + "serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "requires": { + "randombytes": "^2.1.0" + } + }, + "serve-index": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz", + "integrity": "sha512-pXHfKNP4qujrtteMrSBb0rc8HJ9Ms/GrXwcUtUtD5s4ewDJI8bT3Cz2zTVRMKtri49pLx2e0Ya8ziP5Ya2pZZw==", + "requires": { + "accepts": "~1.3.4", + "batch": "0.6.1", + "debug": "2.6.9", + "escape-html": "~1.0.3", + "http-errors": "~1.6.2", + "mime-types": "~2.1.17", + "parseurl": "~1.3.2" + }, + "dependencies": { + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==" + }, + "http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A==", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + } + }, + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" } } }, "serve-static": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", - "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", - "dev": true, + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", + "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", "requires": { "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "parseurl": "~1.3.3", - "send": "0.17.1" + "send": "0.18.0" } }, "set-blocking": { @@ -12956,6 +14826,7 @@ "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", "dev": true, + "peer": true, "requires": { "extend-shallow": "^2.0.1", "is-extendable": "^0.1.1", @@ -12968,6 +14839,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, + "peer": true, "requires": { "is-extendable": "^0.1.0" } @@ -12975,26 +14847,36 @@ } }, "setprototypeof": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", - "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==", - "dev": true + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, "sha.js": { "version": "2.4.11", "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "dev": true, + "peer": true, "requires": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" } }, + "shallow-clone": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz", + "integrity": "sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==", + "dev": true, + "requires": { + "kind-of": "^6.0.2" + } + }, "shasum": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/shasum/-/shasum-1.0.2.tgz", "integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=", "dev": true, + "peer": true, "requires": { "json-stable-stringify": "~0.0.0", "sha.js": "~2.4.4" @@ -13005,36 +14887,32 @@ "resolved": "https://registry.npmjs.org/shasum-object/-/shasum-object-1.0.0.tgz", "integrity": "sha512-Iqo5rp/3xVi6M4YheapzZhhGPVs0yZwHj7wvwQ1B9z8H6zk+FEnI7y3Teq7qwnekfEhu8WmG2z0z4iWZaxLWVg==", "dev": true, + "peer": true, "requires": { "fast-safe-stringify": "^2.0.7" } }, - "shebang-command": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", - "dev": true, - "requires": { - "shebang-regex": "^1.0.0" - } - }, - "shebang-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", - "dev": true - }, "shell-quote": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.2.tgz", "integrity": "sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==", - "dev": true + "dev": true, + "peer": true + }, + "side-channel": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", + "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "requires": { + "call-bind": "^1.0.0", + "get-intrinsic": "^1.0.2", + "object-inspect": "^1.9.0" + } }, "signal-exit": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", - "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==", - "dev": true + "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==" }, "simple-concat": { "version": "1.0.0", @@ -13053,15 +14931,6 @@ "simple-concat": "^1.0.0" } }, - "simple-html-index": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/simple-html-index/-/simple-html-index-1.5.0.tgz", - "integrity": "sha1-LJPurrrAAdihNfwAIr1K3o9YmW8=", - "dev": true, - "requires": { - "from2-string": "^1.1.0" - } - }, "sinon": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/sinon/-/sinon-2.4.1.tgz", @@ -13098,6 +14967,7 @@ "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", "dev": true, + "peer": true, "requires": { "base": "^0.11.1", "debug": "^2.2.0", @@ -13114,6 +14984,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, + "peer": true, "requires": { "is-descriptor": "^0.1.0" } @@ -13123,6 +14994,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, + "peer": true, "requires": { "is-extendable": "^0.1.0" } @@ -13134,6 +15006,7 @@ "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", "dev": true, + "peer": true, "requires": { "define-property": "^1.0.0", "isobject": "^3.0.0", @@ -13145,6 +15018,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, + "peer": true, "requires": { "is-descriptor": "^1.0.0" } @@ -13154,6 +15028,7 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, + "peer": true, "requires": { "kind-of": "^6.0.0" } @@ -13163,6 +15038,7 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, + "peer": true, "requires": { "kind-of": "^6.0.0" } @@ -13172,6 +15048,7 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, + "peer": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -13185,6 +15062,7 @@ "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", "dev": true, + "peer": true, "requires": { "kind-of": "^3.2.0" }, @@ -13194,6 +15072,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, + "peer": true, "requires": { "is-buffer": "^1.1.5" } @@ -13304,17 +15183,29 @@ } } }, + "sockjs": { + "version": "0.3.24", + "resolved": "https://registry.npmjs.org/sockjs/-/sockjs-0.3.24.tgz", + "integrity": "sha512-GJgLTZ7vYb/JtPSSZ10hsOYIvEYsjbNU+zPdIHcUaWVNUEPivzxku31865sSSud0Da0W4lEeOPlmw93zLQchuQ==", + "requires": { + "faye-websocket": "^0.11.3", + "uuid": "^8.3.2", + "websocket-driver": "^0.7.4" + } + }, "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true + "dev": true, + "peer": true }, "source-map-resolve": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz", "integrity": "sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==", "dev": true, + "peer": true, "requires": { "atob": "^2.1.2", "decode-uri-component": "^0.2.0", @@ -13323,83 +15214,116 @@ "urix": "^0.1.0" } }, + "source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + } + } + }, "source-map-url": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", - "dev": true - }, - "split-string": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", - "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", "dev": true, + "peer": true + }, + "spdy": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/spdy/-/spdy-4.0.2.tgz", + "integrity": "sha512-r46gZQZQV+Kl9oItvl1JZZqJKGr+oEkB08A6BzkiR7593/7IbtuncXHd2YoYeTsG4157ZssMu9KYvUHLcjcDoA==", "requires": { - "extend-shallow": "^3.0.0" + "debug": "^4.1.0", + "handle-thing": "^2.0.0", + "http-deceiver": "^1.2.7", + "select-hose": "^2.0.0", + "spdy-transport": "^3.0.0" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } } }, - "split2": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/split2/-/split2-0.2.1.tgz", - "integrity": "sha1-At2smtwD7Au3jBKC7Aecpuha6QA=", - "dev": true, + "spdy-transport": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdy-transport/-/spdy-transport-3.0.0.tgz", + "integrity": "sha512-hsLVFE5SjA6TCisWeJXFKniGGOpBgMLmerfO2aCyCU5s7nJ/rpAepqmFifv/GCbSbueEeAJJnmSQ2rKC/g8Fcw==", "requires": { - "through2": "~0.6.1" + "debug": "^4.1.0", + "detect-node": "^2.0.4", + "hpack.js": "^2.1.6", + "obuf": "^1.1.2", + "readable-stream": "^3.0.6", + "wbuf": "^1.7.3" }, "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" + "ms": "2.1.2" } }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, - "through2": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", - "dev": true, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", "requires": { - "readable-stream": ">=1.0.33-1 <1.1.0-0", - "xtend": ">=4.0.0 <4.1.0-0" + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" } } } }, + "split-string": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", + "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", + "dev": true, + "peer": true, + "requires": { + "extend-shallow": "^3.0.0" + } + }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, - "stacked": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/stacked/-/stacked-1.1.1.tgz", - "integrity": "sha1-LH+jjMfjejQRp3zY55LeRI+faXU=", - "dev": true - }, "static-extend": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", "dev": true, + "peer": true, "requires": { "define-property": "^0.2.5", "object-copy": "^0.1.0" @@ -13410,6 +15334,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, + "peer": true, "requires": { "is-descriptor": "^0.1.0" } @@ -13419,23 +15344,14 @@ "statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", - "dev": true - }, - "stdout-stream": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/stdout-stream/-/stdout-stream-1.4.1.tgz", - "integrity": "sha512-j4emi03KXqJWcIeF8eIXkjMFN1Cmb8gUlDYGeBALLPo5qdyTfA9bOtl8m33lRoC+vFMkP3gl0WsDr6+gzxbbTA==", - "dev": true, - "requires": { - "readable-stream": "^2.0.1" - } + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" }, "stream-browserify": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.2.tgz", "integrity": "sha512-nX6hmklHs/gr2FuxYDltq8fJA1GDlxKQCz8O/IM4atRqBH8OORmBNgfvW5gG10GT/qQ9u0CzIvr2X5Pkt6ntqg==", "dev": true, + "peer": true, "requires": { "inherits": "~2.0.1", "readable-stream": "^2.0.2" @@ -13446,6 +15362,7 @@ "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", "dev": true, + "peer": true, "requires": { "duplexer2": "~0.1.0", "readable-stream": "^2.0.2" @@ -13456,6 +15373,7 @@ "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-3.1.1.tgz", "integrity": "sha512-S7OqaYu0EkFpgeGFb/NPOoPLxFko7TPqtEeFg5DXPB4v/KETHG0Ln6fRFrNezoelpaDKmycEmmZ81cC9DAwgYg==", "dev": true, + "peer": true, "requires": { "builtin-status-codes": "^3.0.0", "inherits": "^2.0.4", @@ -13467,13 +15385,15 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "dev": true, + "peer": true }, "readable-stream": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", "dev": true, + "peer": true, "requires": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -13484,7 +15404,8 @@ "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", - "dev": true + "dev": true, + "peer": true } } }, @@ -13493,6 +15414,7 @@ "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.1.tgz", "integrity": "sha512-Xizh4/NPuYSyAXyT7g8IvdJ9HJpxIGL9PjyhtywCZvvP0OPIdqyrr4dMikeuvY8xahpdKEBlBTySe583totajg==", "dev": true, + "peer": true, "requires": { "inherits": "^2.0.1", "readable-stream": "^2.0.2" @@ -13538,7 +15460,6 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "dev": true, "requires": { "safe-buffer": "~5.2.0" } @@ -13612,37 +15533,10 @@ "es-abstract": "^1.17.5" } }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - } - } - }, - "strip-css-comments": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-css-comments/-/strip-css-comments-3.0.0.tgz", - "integrity": "sha1-elYl7/iisibPiUehElTaluE9rok=", - "dev": true, - "requires": { - "is-regexp": "^1.0.0" - } - }, - "strip-eof": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", - "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", - "dev": true + "strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==" }, "strip-json-comments": { "version": "2.0.1", @@ -13655,6 +15549,7 @@ "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz", "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=", "dev": true, + "peer": true, "requires": { "minimist": "^1.1.0" } @@ -13671,10 +15566,10 @@ "integrity": "sha512-5P71owlReO9HmKG5OxSSb1qKBuEWVhvGIb59gZkIoqRX5WgmBfZPo7x0OZOYEd7r9nG87cRv+OyeHJCO1Qh0CA==", "dev": true }, - "supports-color": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz", - "integrity": "sha1-2S3iaU6z9nMjlz1649i1W0wiGQo=", + "supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "dev": true }, "syntax-error": { @@ -13682,39 +15577,50 @@ "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz", "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==", "dev": true, + "peer": true, "requires": { "acorn-node": "^1.2.0" } }, - "term-color": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/term-color/-/term-color-1.0.1.tgz", - "integrity": "sha1-OOGSVTpHPjXkFgT/UZmEa/gRejo=", - "dev": true, + "tapable": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", + "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==" + }, + "terser": { + "version": "5.16.1", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.16.1.tgz", + "integrity": "sha512-xvQfyfA1ayT0qdK47zskQgRZeWLoOQ8JQ6mIgRGVNwZKdQMU+5FkCBjmv4QjcrTzyZquRw2FVtlJSRUmMKQslw==", "requires": { - "ansi-styles": "2.0.1", - "supports-color": "1.3.1" + "@jridgewell/source-map": "^0.3.2", + "acorn": "^8.5.0", + "commander": "^2.20.0", + "source-map-support": "~0.5.20" }, "dependencies": { - "ansi-styles": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.0.1.tgz", - "integrity": "sha1-sDP1f5Pi0oreuLwRE4+hPaD9IKM=", - "dev": true + "acorn": { + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", + "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==" }, - "supports-color": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-1.3.1.tgz", - "integrity": "sha1-FXWN8J2P87SswwdTn6vicJXhBC0=", - "dev": true + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" } } }, - "ternary": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/ternary/-/ternary-1.0.0.tgz", - "integrity": "sha1-RXAnJWCMlJnUapYQ6bDkn/JveJ4=", - "dev": true + "terser-webpack-plugin": { + "version": "5.3.6", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.6.tgz", + "integrity": "sha512-kfLFk+PoLUQIbLmB1+PZDMRSZS99Mp+/MHqDNmMA6tOItzRt+Npe3E+fsMs5mfcM0wCtrrdU387UnV+vnSffXQ==", + "requires": { + "@jridgewell/trace-mapping": "^0.3.14", + "jest-worker": "^27.4.5", + "schema-utils": "^3.1.1", + "serialize-javascript": "^6.0.0", + "terser": "^5.14.1" + } }, "text-encoding": { "version": "0.6.4", @@ -13775,11 +15681,17 @@ "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", "dev": true, + "peer": true, "requires": { "readable-stream": "~2.3.6", "xtend": "~4.0.1" } }, + "thunky": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz", + "integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==" + }, "timed-out": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", @@ -13791,6 +15703,7 @@ "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz", "integrity": "sha1-ycWLV1voQHN1y14kYtrO50NZ9B0=", "dev": true, + "peer": true, "requires": { "process": "~0.11.0" }, @@ -13799,7 +15712,8 @@ "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", - "dev": true + "dev": true, + "peer": true } } }, @@ -13823,6 +15737,7 @@ "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", "dev": true, + "peer": true, "requires": { "kind-of": "^3.0.2" }, @@ -13832,6 +15747,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, + "peer": true, "requires": { "is-buffer": "^1.1.5" } @@ -13843,6 +15759,7 @@ "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", "dev": true, + "peer": true, "requires": { "define-property": "^2.0.2", "extend-shallow": "^3.0.2", @@ -13850,62 +15767,28 @@ "safe-regex": "^1.1.0" } }, - "to-regex-range": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", - "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", - "dev": true, - "requires": { - "is-number": "^3.0.0", - "repeat-string": "^1.6.1" - } - }, - "toidentifier": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", - "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", - "dev": true - }, - "transformify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/transformify/-/transformify-0.1.2.tgz", - "integrity": "sha1-mk9CoVRDPdcnuAV1Qoo8nlSJ6/E=", - "dev": true, - "requires": { - "readable-stream": "~1.1.9" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - } - } - }, + "to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", + "dev": true, + "peer": true, + "requires": { + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" + } + }, + "toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==" + }, "tty-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==", - "dev": true + "dev": true, + "peer": true }, "type-detect": { "version": "1.0.0", @@ -13917,7 +15800,6 @@ "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", - "dev": true, "requires": { "media-typer": "0.3.0", "mime-types": "~2.1.24" @@ -13927,7 +15809,8 @@ "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", - "dev": true + "dev": true, + "peer": true }, "uglify-es": { "version": "3.3.9", @@ -13957,13 +15840,15 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz", "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==", - "dev": true + "dev": true, + "peer": true }, "undeclared-identifiers": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/undeclared-identifiers/-/undeclared-identifiers-1.1.3.tgz", "integrity": "sha512-pJOW4nxjlmfwKApE4zvxLScM/njmwj/DiUBv7EabwE4O8kRUy+HIwxQtZLBPll/jx1LJyBcqNfB3/cpv9EZwOw==", "dev": true, + "peer": true, "requires": { "acorn-node": "^1.3.0", "dash-ast": "^1.0.0", @@ -13977,6 +15862,7 @@ "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", "dev": true, + "peer": true, "requires": { "arr-union": "^3.1.0", "get-value": "^2.0.6", @@ -13993,14 +15879,14 @@ "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", - "dev": true + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" }, "unset-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", "dev": true, + "peer": true, "requires": { "has-value": "^0.3.1", "isobject": "^3.0.0" @@ -14011,6 +15897,7 @@ "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", "dev": true, + "peer": true, "requires": { "get-value": "^2.0.3", "has-values": "^0.1.4", @@ -14022,6 +15909,7 @@ "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", "dev": true, + "peer": true, "requires": { "isarray": "1.0.0" } @@ -14032,7 +15920,8 @@ "version": "0.1.4", "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", - "dev": true + "dev": true, + "peer": true } } }, @@ -14040,19 +15929,46 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz", "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==", - "dev": true + "dev": true, + "peer": true + }, + "update-browserslist-db": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz", + "integrity": "sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ==", + "requires": { + "escalade": "^3.1.1", + "picocolors": "^1.0.0" + } + }, + "uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "requires": { + "punycode": "^2.1.0" + }, + "dependencies": { + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + } + } }, "urix": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", - "dev": true + "dev": true, + "peer": true }, "url": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", "dev": true, + "peer": true, "requires": { "punycode": "1.3.2", "querystring": "0.2.0" @@ -14062,7 +15978,8 @@ "version": "1.3.2", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", - "dev": true + "dev": true, + "peer": true } } }, @@ -14072,17 +15989,12 @@ "integrity": "sha512-3AChu4NiXquPfeckE5R5cGdiHCMWJx1dwCWOmWIL4KHAziJNOFIYJlpGFeKDvwLPHovZRCxK3cYlwzqI9Vp+Gg==", "dev": true }, - "url-trim": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/url-trim/-/url-trim-1.0.0.tgz", - "integrity": "sha1-QAV+LxZLiOXaynJp2kfm0d2Detw=", - "dev": true - }, "use": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", - "dev": true + "dev": true, + "peer": true }, "useragent": { "version": "2.3.0", @@ -14099,6 +16011,7 @@ "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", "dev": true, + "peer": true, "requires": { "inherits": "2.0.3" } @@ -14106,20 +16019,29 @@ "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", - "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", - "dev": true + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==" }, "vm-browserify": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz", "integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==", - "dev": true + "dev": true, + "peer": true }, "void-elements": { "version": "2.0.1", @@ -14132,6 +16054,7 @@ "resolved": "https://registry.npmjs.org/watchify/-/watchify-3.11.1.tgz", "integrity": "sha512-WwnUClyFNRMB2NIiHgJU9RQPQNqVeFk7OmZaWf5dC5EnNa0Mgr7imBydbaJ7tGTuPM2hz1Cb4uiBvK9NVxMfog==", "dev": true, + "peer": true, "requires": { "anymatch": "^2.0.0", "browserify": "^16.1.0", @@ -14142,28 +16065,473 @@ "xtend": "^4.0.0" } }, - "watchify-middleware": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/watchify-middleware/-/watchify-middleware-1.8.2.tgz", - "integrity": "sha512-A+x5K0mHVEK2WSLOEbazcXDFnSlralMZzk364Ea39F4xFl2jGl4VQLLN5HwrnRzpF5/Ggf1Q2he0HpJtflUiHg==", - "dev": true, + "watchpack": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", + "integrity": "sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==", "requires": { - "concat-stream": "^1.5.0", - "debounce": "^1.0.0", - "events": "^1.0.2", - "object-assign": "^4.0.1", - "strip-ansi": "^3.0.0", - "watchify": "^3.11.1" + "glob-to-regexp": "^0.4.1", + "graceful-fs": "^4.1.2" + } + }, + "wbuf": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/wbuf/-/wbuf-1.7.3.tgz", + "integrity": "sha512-O84QOnr0icsbFGLS0O3bI5FswxzRr8/gHwWkDlQFskhSPryQXvrTMxjxGP4+iWYoauLoBvfDpkrOauZ+0iZpDA==", + "requires": { + "minimalistic-assert": "^1.0.0" + } + }, + "webpack": { + "version": "5.75.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.75.0.tgz", + "integrity": "sha512-piaIaoVJlqMsPtX/+3KTTO6jfvrSYgauFVdt8cr9LTHKmcq/AMd4mhzsiP7ZF/PGRNPGA8336jldh9l2Kt2ogQ==", + "requires": { + "@types/eslint-scope": "^3.7.3", + "@types/estree": "^0.0.51", + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/wasm-edit": "1.11.1", + "@webassemblyjs/wasm-parser": "1.11.1", + "acorn": "^8.7.1", + "acorn-import-assertions": "^1.7.6", + "browserslist": "^4.14.5", + "chrome-trace-event": "^1.0.2", + "enhanced-resolve": "^5.10.0", + "es-module-lexer": "^0.9.0", + "eslint-scope": "5.1.1", + "events": "^3.2.0", + "glob-to-regexp": "^0.4.1", + "graceful-fs": "^4.2.9", + "json-parse-even-better-errors": "^2.3.1", + "loader-runner": "^4.2.0", + "mime-types": "^2.1.27", + "neo-async": "^2.6.2", + "schema-utils": "^3.1.0", + "tapable": "^2.1.1", + "terser-webpack-plugin": "^5.1.3", + "watchpack": "^2.4.0", + "webpack-sources": "^3.2.3" }, "dependencies": { + "acorn": { + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", + "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==" + }, + "acorn-import-assertions": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz", + "integrity": "sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw==", + "requires": {} + }, "events": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", - "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==" + } + } + }, + "webpack-cli": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-5.0.1.tgz", + "integrity": "sha512-S3KVAyfwUqr0Mo/ur3NzIp6jnerNpo7GUO6so51mxLi1spqsA17YcMXy0WOIJtBSnj748lthxC6XLbNKh/ZC+A==", + "dev": true, + "requires": { + "@discoveryjs/json-ext": "^0.5.0", + "@webpack-cli/configtest": "^2.0.1", + "@webpack-cli/info": "^2.0.1", + "@webpack-cli/serve": "^2.0.1", + "colorette": "^2.0.14", + "commander": "^9.4.1", + "cross-spawn": "^7.0.3", + "envinfo": "^7.7.3", + "fastest-levenshtein": "^1.0.12", + "import-local": "^3.0.2", + "interpret": "^3.1.1", + "rechoir": "^0.8.0", + "webpack-merge": "^5.7.3" + }, + "dependencies": { + "commander": { + "version": "9.4.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.4.1.tgz", + "integrity": "sha512-5EEkTNyHNGFPD2H+c/dXXfQZYa/scCKasxWcXJaWnNJ99pnQN9Vnmqow+p+PlFPE63Q6mThaZws1T+HxfpgtPw==", + "dev": true + }, + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } + }, + "webpack-dev-middleware": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-5.3.3.tgz", + "integrity": "sha512-hj5CYrY0bZLB+eTO+x/j67Pkrquiy7kWepMHmUMoPsmcUaeEnQJqFzHJOyxgWlq746/wUuA64p9ta34Kyb01pA==", + "requires": { + "colorette": "^2.0.10", + "memfs": "^3.4.3", + "mime-types": "^2.1.31", + "range-parser": "^1.2.1", + "schema-utils": "^4.0.0" + }, + "dependencies": { + "ajv": { + "version": "8.11.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.2.tgz", + "integrity": "sha512-E4bfmKAhGiSTvMfL1Myyycaub+cUEU2/IvpylXkUu7CHBkBj1f/ikdzbD7YQ6FKUbixDxeYvB/xY4fvyroDlQg==", + "requires": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + } + }, + "ajv-keywords": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", + "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", + "requires": { + "fast-deep-equal": "^3.1.3" + } + }, + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" + }, + "schema-utils": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.0.tgz", + "integrity": "sha512-1edyXKgh6XnJsJSQ8mKWXnN/BVaIbFMLpouRUrXgVq7WYne5kw3MW7UPhO44uRXQSIpTSXoJbmrR2X0w9kUTyg==", + "requires": { + "@types/json-schema": "^7.0.9", + "ajv": "^8.8.0", + "ajv-formats": "^2.1.1", + "ajv-keywords": "^5.0.0" + } + } + } + }, + "webpack-dev-server": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/webpack-dev-server/-/webpack-dev-server-4.11.1.tgz", + "integrity": "sha512-lILVz9tAUy1zGFwieuaQtYiadImb5M3d+H+L1zDYalYoDl0cksAB1UNyuE5MMWJrG6zR1tXkCP2fitl7yoUJiw==", + "requires": { + "@types/bonjour": "^3.5.9", + "@types/connect-history-api-fallback": "^1.3.5", + "@types/express": "^4.17.13", + "@types/serve-index": "^1.9.1", + "@types/serve-static": "^1.13.10", + "@types/sockjs": "^0.3.33", + "@types/ws": "^8.5.1", + "ansi-html-community": "^0.0.8", + "bonjour-service": "^1.0.11", + "chokidar": "^3.5.3", + "colorette": "^2.0.10", + "compression": "^1.7.4", + "connect-history-api-fallback": "^2.0.0", + "default-gateway": "^6.0.3", + "express": "^4.17.3", + "graceful-fs": "^4.2.6", + "html-entities": "^2.3.2", + "http-proxy-middleware": "^2.0.3", + "ipaddr.js": "^2.0.1", + "open": "^8.0.9", + "p-retry": "^4.5.0", + "rimraf": "^3.0.2", + "schema-utils": "^4.0.0", + "selfsigned": "^2.1.1", + "serve-index": "^1.9.1", + "sockjs": "^0.3.24", + "spdy": "^4.0.2", + "webpack-dev-middleware": "^5.3.1", + "ws": "^8.4.2" + }, + "dependencies": { + "ajv": { + "version": "8.11.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.2.tgz", + "integrity": "sha512-E4bfmKAhGiSTvMfL1Myyycaub+cUEU2/IvpylXkUu7CHBkBj1f/ikdzbD7YQ6FKUbixDxeYvB/xY4fvyroDlQg==", + "requires": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + } + }, + "ajv-keywords": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", + "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", + "requires": { + "fast-deep-equal": "^3.1.3" + } + }, + "anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==" + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "requires": { + "fill-range": "^7.0.1" + } + }, + "chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "requires": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "fsevents": "~2.3.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + } + }, + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "default-gateway": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/default-gateway/-/default-gateway-6.0.3.tgz", + "integrity": "sha512-fwSOJsbbNzZ/CUFpqFBqYfYNLj1NbMPm8MMCIzHjC83iSJRBEGmDUxU+WP661BaBQImeC2yHwXtz+P/O9o+XEg==", + "requires": { + "execa": "^5.0.0" + } + }, + "execa": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "requires": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==" + }, + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "requires": { + "is-glob": "^4.0.1" + } + }, + "ipaddr.js": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.0.1.tgz", + "integrity": "sha512-1qTgH9NG+IIJ4yfKs2e6Pp1bZg8wbDbKHT21HrLIeYBTRLgMYKnMTPAuI3Lcs61nfx5h1xlXnbJtH1kX5/d/ng==" + }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" + }, + "is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==" + }, + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" + }, + "npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "requires": { + "path-key": "^3.0.0" + } + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==" + }, + "readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "requires": { + "picomatch": "^2.2.1" + } + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "requires": { + "glob": "^7.1.3" + } + }, + "schema-utils": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.0.0.tgz", + "integrity": "sha512-1edyXKgh6XnJsJSQ8mKWXnN/BVaIbFMLpouRUrXgVq7WYne5kw3MW7UPhO44uRXQSIpTSXoJbmrR2X0w9kUTyg==", + "requires": { + "@types/json-schema": "^7.0.9", + "ajv": "^8.8.0", + "ajv-formats": "^2.1.1", + "ajv-keywords": "^5.0.0" + } + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==" + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "requires": { + "is-number": "^7.0.0" + } + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "requires": { + "isexe": "^2.0.0" + } + }, + "ws": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", + "requires": {} } } }, + "webpack-merge": { + "version": "5.8.0", + "resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-5.8.0.tgz", + "integrity": "sha512-/SaI7xY0831XwP6kzuwhKWVKDP9t1QY1h65lAFLbZqMPIuYcD9QAW4u9STIbU9kaJbPBB/geU/gLr1wDjOhQ+Q==", + "dev": true, + "requires": { + "clone-deep": "^4.0.1", + "wildcard": "^2.0.0" + } + }, + "webpack-sources": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz", + "integrity": "sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==" + }, + "websocket-driver": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.7.4.tgz", + "integrity": "sha512-b17KeDIQVjvb0ssuSDF2cYXSg2iztliJ4B9WdsuB6J952qCPKmnVq4DyW5motImXHDC1cBT/1UezrJVsKw5zjg==", + "requires": { + "http-parser-js": ">=0.5.1", + "safe-buffer": ">=5.1.0", + "websocket-extensions": ">=0.1.1" + } + }, + "websocket-extensions": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.4.tgz", + "integrity": "sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg==" + }, "webvr-polyfill": { "version": "0.10.12", "resolved": "https://registry.npmjs.org/webvr-polyfill/-/webvr-polyfill-0.10.12.tgz", @@ -14179,10 +16547,10 @@ "integrity": "sha512-O0S1ZGEWyPvyZEkS2VbyV7mtir/NM9MNK3EuhbHPoJ8EHTky2pTXehjIl+IiDPr+Lldgx129QGt3NGly7rwRPw==", "dev": true }, - "webworkify": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/webworkify/-/webworkify-1.4.0.tgz", - "integrity": "sha1-cSRdHjTKz1TkJr2VX4zG7hLQJMI=" + "webworkify-webpack": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/webworkify-webpack/-/webworkify-webpack-2.1.5.tgz", + "integrity": "sha512-2akF8FIyUvbiBBdD+RoHpoTbHMQF2HwjcxfDvgztAX5YwbZNyrtfUMgvfgFVsgDhDPVTlkbb5vyasqDHfIDPQw==" }, "which": { "version": "1.3.1", @@ -14208,6 +16576,12 @@ "string-width": "^1.0.2 || 2" } }, + "wildcard": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/wildcard/-/wildcard-2.0.0.tgz", + "integrity": "sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw==", + "dev": true + }, "word-wrapper": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/word-wrapper/-/word-wrapper-1.0.7.tgz", @@ -14271,17 +16645,7 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "ws": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", - "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", - "dev": true, - "requires": { - "async-limiter": "~1.0.0" - } + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "xhr": { "version": "2.6.0", From ab142816bc74b0102b1659979a002e5d23a977d8 Mon Sep 17 00:00:00 2001 From: diarmidmackenzie Date: Thu, 22 Dec 2022 11:08:35 +0000 Subject: [PATCH 5/6] Updated builds --- dist/aframe-physics-system.js | 19608 +--------------- dist/aframe-physics-system.min.js | 3 +- dist/aframe-physics-system.min.js.LICENSE.txt | 5 + 3 files changed, 312 insertions(+), 19304 deletions(-) create mode 100644 dist/aframe-physics-system.min.js.LICENSE.txt diff --git a/dist/aframe-physics-system.js b/dist/aframe-physics-system.js index b51493ab..077b1d04 100644 --- a/dist/aframe-physics-system.js +++ b/dist/aframe-physics-system.js @@ -1,19399 +1,401 @@ -(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i { - const counterValue = document.createElement('div') - counterValue.classList.add('rs-counter-value') - counterValue.innerHTML = "..." - this.counter.appendChild(counterValue) - this.counterValues[property] = counterValue - }) - - this.updateData = this.updateData.bind(this) - this.el.addEventListener(this.data.event, this.updateData) - - this.splitCache = {} - }, - - updateData(e) { - - this.data.properties.forEach((property) => { - const split = this.splitDot(property); - let value = e.detail; - for (i = 0; i < split.length; i++) { - value = value[split[i]]; - } - this.counterValues[property].innerHTML = value - }) - }, - - splitDot (path) { - if (path in this.splitCache) { return this.splitCache[path]; } - this.splitCache[path] = path.split('.'); - return this.splitCache[path]; - } - -}); - -AFRAME.registerComponent('stats-collector', { - multiple: true, - - schema: { - // name of an event to listen for - inEvent: {type: 'string'}, - - // property from event to output in stats panel - properties: {type: 'array'}, - - // frequency of output in terms of events received. - outputFrequency: {type: 'number', default: 100}, - - // name of event to emit - outEvent: {type: 'string'}, - - // outputs (generated for each property) - // Combination of: mean, max, percentile__XX.X (where XX.X is a number) - outputs: {type: 'array'}, - - // Whether to output to console as well as generating events - // If a string is specified, this is output to console, together with the event data - // If no string is specified, nothing is output to console. - outputToConsole: {type: 'string'} - }, - - init() { - - this.statsData = {} - this.resetData() - this.outputDetail = {} - this.data.properties.forEach((property) => { - this.outputDetail[property] = {} - }) - - this.statsReceived = this.statsReceived.bind(this) - this.el.addEventListener(this.data.inEvent, this.statsReceived) - }, - - resetData() { - - this.counter = 0 - this.data.properties.forEach((property) => { - - // For calculating percentiles like 0.01 and 99.9% we'll want to store - // additional data - something like this... - // Store off outliers, and discard data. - // const min = Math.min(...this.statsData[property]) - // this.lowOutliers[property].push(min) - // const max = Math.max(...this.statsData[property]) - // this.highOutliers[property].push(max) - - this.statsData[property] = [] - }) - }, - - statsReceived(e) { - - this.updateData(e.detail) - - this.counter++ - if (this.counter === this.data.outputFrequency) { - this.outputData() - this.resetData() - } - }, - - updateData(detail) { - - this.data.properties.forEach((property) => { - let value = detail; - value = value[property]; - this.statsData[property].push(value) - }) - }, - - outputData() { - this.data.properties.forEach((property) => { - this.data.outputs.forEach((output) => { - this.outputDetail[property][output] = this.computeOutput(output, this.statsData[property]) - }) - }) - - if (this.data.outEvent) { - this.el.emit(this.data.outEvent, this.outputDetail) - } - - if (this.data.outputToConsole) { - console.log(this.data.outputToConsole, this.outputDetail) - } - }, - - computeOutput(outputInstruction, data) { - - const outputInstructions = outputInstruction.split("__") - const outputType = outputInstructions[0] - let output - - switch (outputType) { - case "mean": - output = data.reduce((a, b) => a + b, 0) / data.length; - break; - - case "max": - output = Math.max(...data) - break; - - case "min": - output = Math.min(...data) - break; - - case "percentile": - const sorted = data.sort((a, b) => a - b) - // decimal percentiles encoded like 99+9 rather than 99.9 due to "." being used as a - // separator for nested properties. - const percentileString = outputInstructions[1].replace("_", ".") - const proportion = +percentileString / 100 - - // Note that this calculation of the percentile is inaccurate when there is insufficient data - // e.g. for 0.1th or 99.9th percentile when only 100 data points. - // Greater accuracy would require storing off more data (specifically outliers) and folding these - // into the computation. - const position = (data.length - 1) * proportion - const base = Math.floor(position) - const delta = position - base; - if (sorted[base + 1] !== undefined) { - output = sorted[base] + delta * (sorted[base + 1] - sorted[base]); - } else { - output = sorted[base]; - } - break; - } - return output.toFixed(2) - } -}); - -},{}],4:[function(require,module,exports){ -/* global Ammo,THREE */ - -THREE.AmmoDebugConstants = { - NoDebug: 0, - DrawWireframe: 1, - DrawAabb: 2, - DrawFeaturesText: 4, - DrawContactPoints: 8, - NoDeactivation: 16, - NoHelpText: 32, - DrawText: 64, - ProfileTimings: 128, - EnableSatComparison: 256, - DisableBulletLCP: 512, - EnableCCD: 1024, - DrawConstraints: 1 << 11, //2048 - DrawConstraintLimits: 1 << 12, //4096 - FastWireframe: 1 << 13, //8192 - DrawNormals: 1 << 14, //16384 - DrawOnTop: 1 << 15, //32768 - MAX_DEBUG_DRAW_MODE: 0xffffffff -}; - -/** - * An implementation of the btIDebugDraw interface in Ammo.js, for debug rendering of Ammo shapes - * @class AmmoDebugDrawer - * @param {THREE.Scene} scene - * @param {Ammo.btCollisionWorld} world - * @param {object} [options] - */ -THREE.AmmoDebugDrawer = function(scene, world, options) { - this.scene = scene; - this.world = world; - options = options || {}; - - this.debugDrawMode = options.debugDrawMode || THREE.AmmoDebugConstants.DrawWireframe; - var drawOnTop = this.debugDrawMode & THREE.AmmoDebugConstants.DrawOnTop || false; - var maxBufferSize = options.maxBufferSize || 1000000; - - this.geometry = new THREE.BufferGeometry(); - var vertices = new Float32Array(maxBufferSize * 3); - var colors = new Float32Array(maxBufferSize * 3); - - this.geometry.addAttribute("position", new THREE.BufferAttribute(vertices, 3).setDynamic(true)); - this.geometry.addAttribute("color", new THREE.BufferAttribute(colors, 3).setDynamic(true)); - - this.index = 0; - - var material = new THREE.LineBasicMaterial({ - vertexColors: THREE.VertexColors, - depthTest: !drawOnTop - }); - - this.mesh = new THREE.LineSegments(this.geometry, material); - if (drawOnTop) this.mesh.renderOrder = 999; - this.mesh.frustumCulled = false; - - this.enabled = false; - - this.debugDrawer = new Ammo.DebugDrawer(); - this.debugDrawer.drawLine = this.drawLine.bind(this); - this.debugDrawer.drawContactPoint = this.drawContactPoint.bind(this); - this.debugDrawer.reportErrorWarning = this.reportErrorWarning.bind(this); - this.debugDrawer.draw3dText = this.draw3dText.bind(this); - this.debugDrawer.setDebugMode = this.setDebugMode.bind(this); - this.debugDrawer.getDebugMode = this.getDebugMode.bind(this); - this.debugDrawer.enable = this.enable.bind(this); - this.debugDrawer.disable = this.disable.bind(this); - this.debugDrawer.update = this.update.bind(this); - - this.world.setDebugDrawer(this.debugDrawer); -}; - -THREE.AmmoDebugDrawer.prototype = function() { - return this.debugDrawer; -}; - -THREE.AmmoDebugDrawer.prototype.enable = function() { - this.enabled = true; - this.scene.add(this.mesh); -}; - -THREE.AmmoDebugDrawer.prototype.disable = function() { - this.enabled = false; - this.scene.remove(this.mesh); -}; - -THREE.AmmoDebugDrawer.prototype.update = function() { - if (!this.enabled) { - return; - } - - if (this.index != 0) { - this.geometry.attributes.position.needsUpdate = true; - this.geometry.attributes.color.needsUpdate = true; - } - - this.index = 0; - - this.world.debugDrawWorld(); - - this.geometry.setDrawRange(0, this.index); -}; - -THREE.AmmoDebugDrawer.prototype.drawLine = function(from, to, color) { - const heap = Ammo.HEAPF32; - const r = heap[(color + 0) / 4]; - const g = heap[(color + 4) / 4]; - const b = heap[(color + 8) / 4]; - - const fromX = heap[(from + 0) / 4]; - const fromY = heap[(from + 4) / 4]; - const fromZ = heap[(from + 8) / 4]; - this.geometry.attributes.position.setXYZ(this.index, fromX, fromY, fromZ); - this.geometry.attributes.color.setXYZ(this.index++, r, g, b); - - const toX = heap[(to + 0) / 4]; - const toY = heap[(to + 4) / 4]; - const toZ = heap[(to + 8) / 4]; - this.geometry.attributes.position.setXYZ(this.index, toX, toY, toZ); - this.geometry.attributes.color.setXYZ(this.index++, r, g, b); -}; - -//TODO: figure out how to make lifeTime work -THREE.AmmoDebugDrawer.prototype.drawContactPoint = function(pointOnB, normalOnB, distance, lifeTime, color) { - const heap = Ammo.HEAPF32; - const r = heap[(color + 0) / 4]; - const g = heap[(color + 4) / 4]; - const b = heap[(color + 8) / 4]; - - const x = heap[(pointOnB + 0) / 4]; - const y = heap[(pointOnB + 4) / 4]; - const z = heap[(pointOnB + 8) / 4]; - this.geometry.attributes.position.setXYZ(this.index, x, y, z); - this.geometry.attributes.color.setXYZ(this.index++, r, g, b); - - const dx = heap[(normalOnB + 0) / 4] * distance; - const dy = heap[(normalOnB + 4) / 4] * distance; - const dz = heap[(normalOnB + 8) / 4] * distance; - this.geometry.attributes.position.setXYZ(this.index, x + dx, y + dy, z + dz); - this.geometry.attributes.color.setXYZ(this.index++, r, g, b); -}; - -THREE.AmmoDebugDrawer.prototype.reportErrorWarning = function(warningString) { - if (Ammo.hasOwnProperty("Pointer_stringify")) { - console.warn(Ammo.Pointer_stringify(warningString)); - } else if (!this.warnedOnce) { - this.warnedOnce = true; - console.warn("Cannot print warningString, please rebuild Ammo.js using 'debug' flag"); - } -}; - -THREE.AmmoDebugDrawer.prototype.draw3dText = function(location, textString) { - //TODO - console.warn("TODO: draw3dText"); -}; - -THREE.AmmoDebugDrawer.prototype.setDebugMode = function(debugMode) { - this.debugDrawMode = debugMode; -}; - -THREE.AmmoDebugDrawer.prototype.getDebugMode = function() { - return this.debugDrawMode; -}; - -},{}],5:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -/** - * Records what objects are colliding with each other - * @class ObjectCollisionMatrix - * @constructor - */ -var ObjectCollisionMatrix = /*#__PURE__*/function () { - // The matrix storage. - function ObjectCollisionMatrix() { - this.matrix = {}; - } - /** - * @method get - * @param {Body} i - * @param {Body} j - * @return {boolean} - */ - - - var _proto = ObjectCollisionMatrix.prototype; - - _proto.get = function get(bi, bj) { - var i = bi.id; - var j = bj.id; - - if (j > i) { - var temp = j; - j = i; - i = temp; - } - - return i + "-" + j in this.matrix; - } - /** - * @method set - * @param {Body} i - * @param {Body} j - * @param {boolean} value - */ - ; - - _proto.set = function set(bi, bj, value) { - var i = bi.id; - var j = bj.id; - - if (j > i) { - var temp = j; - j = i; - i = temp; - } - - if (value) { - this.matrix[i + "-" + j] = true; - } else { - delete this.matrix[i + "-" + j]; - } - } - /** - * Empty the matrix - * @method reset - */ - ; - - _proto.reset = function reset() { - this.matrix = {}; - } - /** - * Set max number of objects - * @method setNumObjects - * @param {Number} n - */ - ; - - _proto.setNumObjects = function setNumObjects(n) {}; - - return ObjectCollisionMatrix; -}(); - -/** - * A 3x3 matrix. - * @class Mat3 - * @constructor - * @param {Array} elements A vector of length 9, containing all matrix elements. Optional. - * @author schteppe / http://github.com/schteppe - */ -var Mat3 = /*#__PURE__*/function () { - function Mat3(elements) { - if (elements === void 0) { - elements = [0, 0, 0, 0, 0, 0, 0, 0, 0]; - } - - this.elements = elements; - } - /** - * Sets the matrix to identity - * @method identity - * @todo Should perhaps be renamed to setIdentity() to be more clear. - * @todo Create another function that immediately creates an identity matrix eg. eye() - */ - - - var _proto = Mat3.prototype; - - _proto.identity = function identity() { - var e = this.elements; - e[0] = 1; - e[1] = 0; - e[2] = 0; - e[3] = 0; - e[4] = 1; - e[5] = 0; - e[6] = 0; - e[7] = 0; - e[8] = 1; - } - /** - * Set all elements to zero - * @method setZero - */ - ; - - _proto.setZero = function setZero() { - var e = this.elements; - e[0] = 0; - e[1] = 0; - e[2] = 0; - e[3] = 0; - e[4] = 0; - e[5] = 0; - e[6] = 0; - e[7] = 0; - e[8] = 0; - } - /** - * Sets the matrix diagonal elements from a Vec3 - * @method setTrace - * @param {Vec3} vec3 - */ - ; - - _proto.setTrace = function setTrace(vector) { - var e = this.elements; - e[0] = vector.x; - e[4] = vector.y; - e[8] = vector.z; - } - /** - * Gets the matrix diagonal elements - * @method getTrace - * @return {Vec3} - */ - ; - - _proto.getTrace = function getTrace(target) { - if (target === void 0) { - target = new Vec3(); - } - - var e = this.elements; - target.x = e[0]; - target.y = e[4]; - target.z = e[8]; - } - /** - * Matrix-Vector multiplication - * @method vmult - * @param {Vec3} v The vector to multiply with - * @param {Vec3} target Optional, target to save the result in. - */ - ; - - _proto.vmult = function vmult(v, target) { - if (target === void 0) { - target = new Vec3(); - } - - var e = this.elements; - var x = v.x; - var y = v.y; - var z = v.z; - target.x = e[0] * x + e[1] * y + e[2] * z; - target.y = e[3] * x + e[4] * y + e[5] * z; - target.z = e[6] * x + e[7] * y + e[8] * z; - return target; - } - /** - * Matrix-scalar multiplication - * @method smult - * @param {Number} s - */ - ; - - _proto.smult = function smult(s) { - for (var i = 0; i < this.elements.length; i++) { - this.elements[i] *= s; - } - } - /** - * Matrix multiplication - * @method mmult - * @param {Mat3} matrix Matrix to multiply with from left side. - * @return {Mat3} The result. - */ - ; - - _proto.mmult = function mmult(matrix, target) { - if (target === void 0) { - target = new Mat3(); - } - - var elements = matrix.elements; - - for (var i = 0; i < 3; i++) { - for (var j = 0; j < 3; j++) { - var sum = 0.0; - - for (var k = 0; k < 3; k++) { - sum += elements[i + k * 3] * this.elements[k + j * 3]; - } - - target.elements[i + j * 3] = sum; - } - } - - return target; - } - /** - * Scale each column of the matrix - * @method scale - * @param {Vec3} v - * @return {Mat3} The result. - */ - ; - - _proto.scale = function scale(vector, target) { - if (target === void 0) { - target = new Mat3(); - } - - var e = this.elements; - var t = target.elements; - - for (var i = 0; i !== 3; i++) { - t[3 * i + 0] = vector.x * e[3 * i + 0]; - t[3 * i + 1] = vector.y * e[3 * i + 1]; - t[3 * i + 2] = vector.z * e[3 * i + 2]; - } - - return target; - } - /** - * Solve Ax=b - * @method solve - * @param {Vec3} b The right hand side - * @param {Vec3} target Optional. Target vector to save in. - * @return {Vec3} The solution x - * @todo should reuse arrays - */ - ; - - _proto.solve = function solve(b, target) { - if (target === void 0) { - target = new Vec3(); - } - - // Construct equations - var nr = 3; // num rows - - var nc = 4; // num cols - - var eqns = []; - var i; - var j; - - for (i = 0; i < nr * nc; i++) { - eqns.push(0); - } - - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { - eqns[i + nc * j] = this.elements[i + 3 * j]; - } - } - - eqns[3 + 4 * 0] = b.x; - eqns[3 + 4 * 1] = b.y; - eqns[3 + 4 * 2] = b.z; // Compute right upper triangular version of the matrix - Gauss elimination - - var n = 3; - var k = n; - var np; - var kp = 4; // num rows - - var p; - - do { - i = k - n; - - if (eqns[i + nc * i] === 0) { - // the pivot is null, swap lines - for (j = i + 1; j < k; j++) { - if (eqns[i + nc * j] !== 0) { - np = kp; - - do { - // do ligne( i ) = ligne( i ) + ligne( k ) - p = kp - np; - eqns[p + nc * i] += eqns[p + nc * j]; - } while (--np); - - break; - } - } - } - - if (eqns[i + nc * i] !== 0) { - for (j = i + 1; j < k; j++) { - var multiplier = eqns[i + nc * j] / eqns[i + nc * i]; - np = kp; - - do { - // do ligne( k ) = ligne( k ) - multiplier * ligne( i ) - p = kp - np; - eqns[p + nc * j] = p <= i ? 0 : eqns[p + nc * j] - eqns[p + nc * i] * multiplier; - } while (--np); - } - } - } while (--n); // Get the solution - - - target.z = eqns[2 * nc + 3] / eqns[2 * nc + 2]; - target.y = (eqns[1 * nc + 3] - eqns[1 * nc + 2] * target.z) / eqns[1 * nc + 1]; - target.x = (eqns[0 * nc + 3] - eqns[0 * nc + 2] * target.z - eqns[0 * nc + 1] * target.y) / eqns[0 * nc + 0]; - - if (isNaN(target.x) || isNaN(target.y) || isNaN(target.z) || target.x === Infinity || target.y === Infinity || target.z === Infinity) { - throw "Could not solve equation! Got x=[" + target.toString() + "], b=[" + b.toString() + "], A=[" + this.toString() + "]"; - } - - return target; - } - /** - * Get an element in the matrix by index. Index starts at 0, not 1!!! - * @method e - * @param {Number} row - * @param {Number} column - * @param {Number} value Optional. If provided, the matrix element will be set to this value. - * @return {Number} - */ - ; - - _proto.e = function e(row, column, value) { - if (value === undefined) { - return this.elements[column + 3 * row]; - } else { - // Set value - this.elements[column + 3 * row] = value; - } - } - /** - * Copy another matrix into this matrix object. - * @method copy - * @param {Mat3} source - * @return {Mat3} this - */ - ; - - _proto.copy = function copy(matrix) { - for (var i = 0; i < matrix.elements.length; i++) { - this.elements[i] = matrix.elements[i]; - } - - return this; - } - /** - * Returns a string representation of the matrix. - * @method toString - * @return string - */ - ; - - _proto.toString = function toString() { - var r = ''; - var sep = ','; - - for (var i = 0; i < 9; i++) { - r += this.elements[i] + sep; - } - - return r; - } - /** - * reverse the matrix - * @method reverse - * @param {Mat3} target Optional. Target matrix to save in. - * @return {Mat3} The solution x - */ - ; - - _proto.reverse = function reverse(target) { - if (target === void 0) { - target = new Mat3(); - } - - // Construct equations - var nr = 3; // num rows - - var nc = 6; // num cols - - var eqns = []; - var i; - var j; - - for (i = 0; i < nr * nc; i++) { - eqns.push(0); - } - - for (i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) { - eqns[i + nc * j] = this.elements[i + 3 * j]; - } - } - - eqns[3 + 6 * 0] = 1; - eqns[3 + 6 * 1] = 0; - eqns[3 + 6 * 2] = 0; - eqns[4 + 6 * 0] = 0; - eqns[4 + 6 * 1] = 1; - eqns[4 + 6 * 2] = 0; - eqns[5 + 6 * 0] = 0; - eqns[5 + 6 * 1] = 0; - eqns[5 + 6 * 2] = 1; // Compute right upper triangular version of the matrix - Gauss elimination - - var n = 3; - var k = n; - var np; - var kp = nc; // num rows - - var p; - - do { - i = k - n; - - if (eqns[i + nc * i] === 0) { - // the pivot is null, swap lines - for (j = i + 1; j < k; j++) { - if (eqns[i + nc * j] !== 0) { - np = kp; - - do { - // do line( i ) = line( i ) + line( k ) - p = kp - np; - eqns[p + nc * i] += eqns[p + nc * j]; - } while (--np); - - break; - } - } - } - - if (eqns[i + nc * i] !== 0) { - for (j = i + 1; j < k; j++) { - var multiplier = eqns[i + nc * j] / eqns[i + nc * i]; - np = kp; - - do { - // do line( k ) = line( k ) - multiplier * line( i ) - p = kp - np; - eqns[p + nc * j] = p <= i ? 0 : eqns[p + nc * j] - eqns[p + nc * i] * multiplier; - } while (--np); - } - } - } while (--n); // eliminate the upper left triangle of the matrix - - - i = 2; - - do { - j = i - 1; - - do { - var _multiplier = eqns[i + nc * j] / eqns[i + nc * i]; - - np = nc; - - do { - p = nc - np; - eqns[p + nc * j] = eqns[p + nc * j] - eqns[p + nc * i] * _multiplier; - } while (--np); - } while (j--); - } while (--i); // operations on the diagonal - - - i = 2; - - do { - var _multiplier2 = 1 / eqns[i + nc * i]; - - np = nc; - - do { - p = nc - np; - eqns[p + nc * i] = eqns[p + nc * i] * _multiplier2; - } while (--np); - } while (i--); - - i = 2; - - do { - j = 2; - - do { - p = eqns[nr + j + nc * i]; - - if (isNaN(p) || p === Infinity) { - throw "Could not reverse! A=[" + this.toString() + "]"; - } - - target.e(i, j, p); - } while (j--); - } while (i--); - - return target; - } - /** - * Set the matrix from a quaterion - * @method setRotationFromQuaternion - * @param {Quaternion} q - */ - ; - - _proto.setRotationFromQuaternion = function setRotationFromQuaternion(q) { - var x = q.x; - var y = q.y; - var z = q.z; - var w = q.w; - var x2 = x + x; - var y2 = y + y; - var z2 = z + z; - var xx = x * x2; - var xy = x * y2; - var xz = x * z2; - var yy = y * y2; - var yz = y * z2; - var zz = z * z2; - var wx = w * x2; - var wy = w * y2; - var wz = w * z2; - var e = this.elements; - e[3 * 0 + 0] = 1 - (yy + zz); - e[3 * 0 + 1] = xy - wz; - e[3 * 0 + 2] = xz + wy; - e[3 * 1 + 0] = xy + wz; - e[3 * 1 + 1] = 1 - (xx + zz); - e[3 * 1 + 2] = yz - wx; - e[3 * 2 + 0] = xz - wy; - e[3 * 2 + 1] = yz + wx; - e[3 * 2 + 2] = 1 - (xx + yy); - return this; - } - /** - * Transpose the matrix - * @method transpose - * @param {Mat3} target Optional. Where to store the result. - * @return {Mat3} The target Mat3, or a new Mat3 if target was omitted. - */ - ; - - _proto.transpose = function transpose(target) { - if (target === void 0) { - target = new Mat3(); - } - - var Mt = target.elements; - var M = this.elements; - - for (var i = 0; i !== 3; i++) { - for (var j = 0; j !== 3; j++) { - Mt[3 * i + j] = M[3 * j + i]; - } - } - - return target; - }; - - return Mat3; -}(); - -/** - * 3-dimensional vector - * @class Vec3 - * @constructor - * @param {Number} x - * @param {Number} y - * @param {Number} z - * @author schteppe - * @example - * const v = new Vec3(1, 2, 3); - * console.log('x=' + v.x); // x=1 - */ - -var Vec3 = /*#__PURE__*/function () { - function Vec3(x, y, z) { - if (x === void 0) { - x = 0.0; - } - - if (y === void 0) { - y = 0.0; - } - - if (z === void 0) { - z = 0.0; - } - - this.x = x; - this.y = y; - this.z = z; - } - /** - * Vector cross product - * @method cross - * @param {Vec3} v - * @param {Vec3} target Optional. Target to save in. - * @return {Vec3} - */ - - - var _proto = Vec3.prototype; - - _proto.cross = function cross(vector, target) { - if (target === void 0) { - target = new Vec3(); - } - - var vx = vector.x; - var vy = vector.y; - var vz = vector.z; - var x = this.x; - var y = this.y; - var z = this.z; - target.x = y * vz - z * vy; - target.y = z * vx - x * vz; - target.z = x * vy - y * vx; - return target; - } - /** - * Set the vectors' 3 elements - * @method set - * @param {Number} x - * @param {Number} y - * @param {Number} z - * @return Vec3 - */ - ; - - _proto.set = function set(x, y, z) { - this.x = x; - this.y = y; - this.z = z; - return this; - } - /** - * Set all components of the vector to zero. - * @method setZero - */ - ; - - _proto.setZero = function setZero() { - this.x = this.y = this.z = 0; - } - /** - * Vector addition - * @method vadd - * @param {Vec3} v - * @param {Vec3} target Optional. - * @return {Vec3} - */ - ; - - _proto.vadd = function vadd(vector, target) { - if (target) { - target.x = vector.x + this.x; - target.y = vector.y + this.y; - target.z = vector.z + this.z; - } else { - return new Vec3(this.x + vector.x, this.y + vector.y, this.z + vector.z); - } - } - /** - * Vector subtraction - * @method vsub - * @param {Vec3} v - * @param {Vec3} target Optional. Target to save in. - * @return {Vec3} - */ - ; - - _proto.vsub = function vsub(vector, target) { - if (target) { - target.x = this.x - vector.x; - target.y = this.y - vector.y; - target.z = this.z - vector.z; - } else { - return new Vec3(this.x - vector.x, this.y - vector.y, this.z - vector.z); - } - } - /** - * Get the cross product matrix a_cross from a vector, such that a x b = a_cross * b = c - * @method crossmat - * @see http://www8.cs.umu.se/kurser/TDBD24/VT06/lectures/Lecture6.pdf - * @return {Mat3} - */ - ; - - _proto.crossmat = function crossmat() { - return new Mat3([0, -this.z, this.y, this.z, 0, -this.x, -this.y, this.x, 0]); - } - /** - * Normalize the vector. Note that this changes the values in the vector. - * @method normalize - * @return {Number} Returns the norm of the vector - */ - ; - - _proto.normalize = function normalize() { - var x = this.x; - var y = this.y; - var z = this.z; - var n = Math.sqrt(x * x + y * y + z * z); - - if (n > 0.0) { - var invN = 1 / n; - this.x *= invN; - this.y *= invN; - this.z *= invN; - } else { - // Make something up - this.x = 0; - this.y = 0; - this.z = 0; - } - - return n; - } - /** - * Get the version of this vector that is of length 1. - * @method unit - * @param {Vec3} target Optional target to save in - * @return {Vec3} Returns the unit vector - */ - ; - - _proto.unit = function unit(target) { - if (target === void 0) { - target = new Vec3(); - } - - var x = this.x; - var y = this.y; - var z = this.z; - var ninv = Math.sqrt(x * x + y * y + z * z); - - if (ninv > 0.0) { - ninv = 1.0 / ninv; - target.x = x * ninv; - target.y = y * ninv; - target.z = z * ninv; - } else { - target.x = 1; - target.y = 0; - target.z = 0; - } - - return target; - } - /** - * Get the length of the vector - * @method length - * @return {Number} - */ - ; - - _proto.length = function length() { - var x = this.x; - var y = this.y; - var z = this.z; - return Math.sqrt(x * x + y * y + z * z); - } - /** - * Get the squared length of the vector. - * @method lengthSquared - * @return {Number} - */ - ; - - _proto.lengthSquared = function lengthSquared() { - return this.dot(this); - } - /** - * Get distance from this point to another point - * @method distanceTo - * @param {Vec3} p - * @return {Number} - */ - ; - - _proto.distanceTo = function distanceTo(p) { - var x = this.x; - var y = this.y; - var z = this.z; - var px = p.x; - var py = p.y; - var pz = p.z; - return Math.sqrt((px - x) * (px - x) + (py - y) * (py - y) + (pz - z) * (pz - z)); - } - /** - * Get squared distance from this point to another point - * @method distanceSquared - * @param {Vec3} p - * @return {Number} - */ - ; - - _proto.distanceSquared = function distanceSquared(p) { - var x = this.x; - var y = this.y; - var z = this.z; - var px = p.x; - var py = p.y; - var pz = p.z; - return (px - x) * (px - x) + (py - y) * (py - y) + (pz - z) * (pz - z); - } - /** - * Multiply all the components of the vector with a scalar. - * @method scale - * @param {Number} scalar - * @param {Vec3} target The vector to save the result in. - * @return {Vec3} - */ - ; - - _proto.scale = function scale(scalar, target) { - if (target === void 0) { - target = new Vec3(); - } - - var x = this.x; - var y = this.y; - var z = this.z; - target.x = scalar * x; - target.y = scalar * y; - target.z = scalar * z; - return target; - } - /** - * Multiply the vector with an other vector, component-wise. - * @method vmult - * @param {Number} vector - * @param {Vec3} target The vector to save the result in. - * @return {Vec3} - */ - ; - - _proto.vmul = function vmul(vector, target) { - if (target === void 0) { - target = new Vec3(); - } - - target.x = vector.x * this.x; - target.y = vector.y * this.y; - target.z = vector.z * this.z; - return target; - } - /** - * Scale a vector and add it to this vector. Save the result in "target". (target = this + vector * scalar) - * @method addScaledVector - * @param {Number} scalar - * @param {Vec3} vector - * @param {Vec3} target The vector to save the result in. - * @return {Vec3} - */ - ; - - _proto.addScaledVector = function addScaledVector(scalar, vector, target) { - if (target === void 0) { - target = new Vec3(); - } - - target.x = this.x + scalar * vector.x; - target.y = this.y + scalar * vector.y; - target.z = this.z + scalar * vector.z; - return target; - } - /** - * Calculate dot product - * @method dot - * @param {Vec3} v - * @return {Number} - */ - ; - - _proto.dot = function dot(vector) { - return this.x * vector.x + this.y * vector.y + this.z * vector.z; - } - /** - * @method isZero - * @return bool - */ - ; - - _proto.isZero = function isZero() { - return this.x === 0 && this.y === 0 && this.z === 0; - } - /** - * Make the vector point in the opposite direction. - * @method negate - * @param {Vec3} target Optional target to save in - * @return {Vec3} - */ - ; - - _proto.negate = function negate(target) { - if (target === void 0) { - target = new Vec3(); - } - - target.x = -this.x; - target.y = -this.y; - target.z = -this.z; - return target; - } - /** - * Compute two artificial tangents to the vector - * @method tangents - * @param {Vec3} t1 Vector object to save the first tangent in - * @param {Vec3} t2 Vector object to save the second tangent in - */ - ; - - _proto.tangents = function tangents(t1, t2) { - var norm = this.length(); - - if (norm > 0.0) { - var n = Vec3_tangents_n; - var inorm = 1 / norm; - n.set(this.x * inorm, this.y * inorm, this.z * inorm); - var randVec = Vec3_tangents_randVec; - - if (Math.abs(n.x) < 0.9) { - randVec.set(1, 0, 0); - n.cross(randVec, t1); - } else { - randVec.set(0, 1, 0); - n.cross(randVec, t1); - } - - n.cross(t1, t2); - } else { - // The normal length is zero, make something up - t1.set(1, 0, 0); - t2.set(0, 1, 0); - } - } - /** - * Converts to a more readable format - * @method toString - * @return string - */ - ; - - _proto.toString = function toString() { - return this.x + "," + this.y + "," + this.z; - } - /** - * Converts to an array - * @method toArray - * @return Array - */ - ; - - _proto.toArray = function toArray() { - return [this.x, this.y, this.z]; - } - /** - * Copies value of source to this vector. - * @method copy - * @param {Vec3} source - * @return {Vec3} this - */ - ; - - _proto.copy = function copy(vector) { - this.x = vector.x; - this.y = vector.y; - this.z = vector.z; - return this; - } - /** - * Do a linear interpolation between two vectors - * @method lerp - * @param {Vec3} v - * @param {Number} t A number between 0 and 1. 0 will make this function return u, and 1 will make it return v. Numbers in between will generate a vector in between them. - * @param {Vec3} target - */ - ; - - _proto.lerp = function lerp(vector, t, target) { - var x = this.x; - var y = this.y; - var z = this.z; - target.x = x + (vector.x - x) * t; - target.y = y + (vector.y - y) * t; - target.z = z + (vector.z - z) * t; - } - /** - * Check if a vector equals is almost equal to another one. - * @method almostEquals - * @param {Vec3} v - * @param {Number} precision - * @return bool - */ - ; - - _proto.almostEquals = function almostEquals(vector, precision) { - if (precision === void 0) { - precision = 1e-6; - } - - if (Math.abs(this.x - vector.x) > precision || Math.abs(this.y - vector.y) > precision || Math.abs(this.z - vector.z) > precision) { - return false; - } - - return true; - } - /** - * Check if a vector is almost zero - * @method almostZero - * @param {Number} precision - */ - ; - - _proto.almostZero = function almostZero(precision) { - if (precision === void 0) { - precision = 1e-6; - } - - if (Math.abs(this.x) > precision || Math.abs(this.y) > precision || Math.abs(this.z) > precision) { - return false; - } - - return true; - } - /** - * Check if the vector is anti-parallel to another vector. - * @method isAntiparallelTo - * @param {Vec3} v - * @param {Number} precision Set to zero for exact comparisons - * @return {Boolean} - */ - ; - - _proto.isAntiparallelTo = function isAntiparallelTo(vector, precision) { - this.negate(antip_neg); - return antip_neg.almostEquals(vector, precision); - } - /** - * Clone the vector - * @method clone - * @return {Vec3} - */ - ; - - _proto.clone = function clone() { - return new Vec3(this.x, this.y, this.z); - }; - - return Vec3; -}(); -Vec3.ZERO = new Vec3(0, 0, 0); -Vec3.UNIT_X = new Vec3(1, 0, 0); -Vec3.UNIT_Y = new Vec3(0, 1, 0); -Vec3.UNIT_Z = new Vec3(0, 0, 1); -/** - * Compute two artificial tangents to the vector - * @method tangents - * @param {Vec3} t1 Vector object to save the first tangent in - * @param {Vec3} t2 Vector object to save the second tangent in - */ - -var Vec3_tangents_n = new Vec3(); -var Vec3_tangents_randVec = new Vec3(); -var antip_neg = new Vec3(); - -/** - * Axis aligned bounding box class. - * @class AABB - * @constructor - * @param {Object} [options] - * @param {Vec3} [options.upperBound] The upper bound of the bounding box. - * @param {Vec3} [options.lowerBound] The lower bound of the bounding box - */ -var AABB = /*#__PURE__*/function () { - // The lower bound of the bounding box - // The upper bound of the bounding box - function AABB(options) { - if (options === void 0) { - options = {}; - } - - this.lowerBound = new Vec3(); - this.upperBound = new Vec3(); - - if (options.lowerBound) { - this.lowerBound.copy(options.lowerBound); - } - - if (options.upperBound) { - this.upperBound.copy(options.upperBound); - } - } - /** - * Set the AABB bounds from a set of points. - * @method setFromPoints - * @param {Array} points An array of Vec3's. - * @param {Vec3} position Optional. - * @param {Quaternion} quaternion Optional. - * @param {number} skinSize Optional. - * @return {AABB} The self object - */ - - - var _proto = AABB.prototype; - - _proto.setFromPoints = function setFromPoints(points, position, quaternion, skinSize) { - var l = this.lowerBound; - var u = this.upperBound; - var q = quaternion; // Set to the first point - - l.copy(points[0]); - - if (q) { - q.vmult(l, l); - } - - u.copy(l); - - for (var i = 1; i < points.length; i++) { - var p = points[i]; - - if (q) { - q.vmult(p, tmp); - p = tmp; - } - - if (p.x > u.x) { - u.x = p.x; - } - - if (p.x < l.x) { - l.x = p.x; - } - - if (p.y > u.y) { - u.y = p.y; - } - - if (p.y < l.y) { - l.y = p.y; - } - - if (p.z > u.z) { - u.z = p.z; - } - - if (p.z < l.z) { - l.z = p.z; - } - } // Add offset - - - if (position) { - position.vadd(l, l); - position.vadd(u, u); - } - - if (skinSize) { - l.x -= skinSize; - l.y -= skinSize; - l.z -= skinSize; - u.x += skinSize; - u.y += skinSize; - u.z += skinSize; - } - - return this; - } - /** - * Copy bounds from an AABB to this AABB - * @method copy - * @param {AABB} aabb Source to copy from - * @return {AABB} The this object, for chainability - */ - ; - - _proto.copy = function copy(aabb) { - this.lowerBound.copy(aabb.lowerBound); - this.upperBound.copy(aabb.upperBound); - return this; - } - /** - * Clone an AABB - * @method clone - */ - ; - - _proto.clone = function clone() { - return new AABB().copy(this); - } - /** - * Extend this AABB so that it covers the given AABB too. - * @method extend - * @param {AABB} aabb - */ - ; - - _proto.extend = function extend(aabb) { - this.lowerBound.x = Math.min(this.lowerBound.x, aabb.lowerBound.x); - this.upperBound.x = Math.max(this.upperBound.x, aabb.upperBound.x); - this.lowerBound.y = Math.min(this.lowerBound.y, aabb.lowerBound.y); - this.upperBound.y = Math.max(this.upperBound.y, aabb.upperBound.y); - this.lowerBound.z = Math.min(this.lowerBound.z, aabb.lowerBound.z); - this.upperBound.z = Math.max(this.upperBound.z, aabb.upperBound.z); - } - /** - * Returns true if the given AABB overlaps this AABB. - * @method overlaps - * @param {AABB} aabb - * @return {Boolean} - */ - ; - - _proto.overlaps = function overlaps(aabb) { - var l1 = this.lowerBound; - var u1 = this.upperBound; - var l2 = aabb.lowerBound; - var u2 = aabb.upperBound; // l2 u2 - // |---------| - // |--------| - // l1 u1 - - var overlapsX = l2.x <= u1.x && u1.x <= u2.x || l1.x <= u2.x && u2.x <= u1.x; - var overlapsY = l2.y <= u1.y && u1.y <= u2.y || l1.y <= u2.y && u2.y <= u1.y; - var overlapsZ = l2.z <= u1.z && u1.z <= u2.z || l1.z <= u2.z && u2.z <= u1.z; - return overlapsX && overlapsY && overlapsZ; - } // Mostly for debugging - ; - - _proto.volume = function volume() { - var l = this.lowerBound; - var u = this.upperBound; - return (u.x - l.x) * (u.y - l.y) * (u.z - l.z); - } - /** - * Returns true if the given AABB is fully contained in this AABB. - * @method contains - * @param {AABB} aabb - * @return {Boolean} - */ - ; - - _proto.contains = function contains(aabb) { - var l1 = this.lowerBound; - var u1 = this.upperBound; - var l2 = aabb.lowerBound; - var u2 = aabb.upperBound; // l2 u2 - // |---------| - // |---------------| - // l1 u1 - - return l1.x <= l2.x && u1.x >= u2.x && l1.y <= l2.y && u1.y >= u2.y && l1.z <= l2.z && u1.z >= u2.z; - } - /** - * @method getCorners - * @param {Vec3} a - * @param {Vec3} b - * @param {Vec3} c - * @param {Vec3} d - * @param {Vec3} e - * @param {Vec3} f - * @param {Vec3} g - * @param {Vec3} h - */ - ; - - _proto.getCorners = function getCorners(a, b, c, d, e, f, g, h) { - var l = this.lowerBound; - var u = this.upperBound; - a.copy(l); - b.set(u.x, l.y, l.z); - c.set(u.x, u.y, l.z); - d.set(l.x, u.y, u.z); - e.set(u.x, l.y, u.z); - f.set(l.x, u.y, l.z); - g.set(l.x, l.y, u.z); - h.copy(u); - } - /** - * Get the representation of an AABB in another frame. - * @method toLocalFrame - * @param {Transform} frame - * @param {AABB} target - * @return {AABB} The "target" AABB object. - */ - ; - - _proto.toLocalFrame = function toLocalFrame(frame, target) { - var corners = transformIntoFrame_corners; - var a = corners[0]; - var b = corners[1]; - var c = corners[2]; - var d = corners[3]; - var e = corners[4]; - var f = corners[5]; - var g = corners[6]; - var h = corners[7]; // Get corners in current frame - - this.getCorners(a, b, c, d, e, f, g, h); // Transform them to new local frame - - for (var i = 0; i !== 8; i++) { - var corner = corners[i]; - frame.pointToLocal(corner, corner); - } - - return target.setFromPoints(corners); - } - /** - * Get the representation of an AABB in the global frame. - * @method toWorldFrame - * @param {Transform} frame - * @param {AABB} target - * @return {AABB} The "target" AABB object. - */ - ; - - _proto.toWorldFrame = function toWorldFrame(frame, target) { - var corners = transformIntoFrame_corners; - var a = corners[0]; - var b = corners[1]; - var c = corners[2]; - var d = corners[3]; - var e = corners[4]; - var f = corners[5]; - var g = corners[6]; - var h = corners[7]; // Get corners in current frame - - this.getCorners(a, b, c, d, e, f, g, h); // Transform them to new local frame - - for (var i = 0; i !== 8; i++) { - var corner = corners[i]; - frame.pointToWorld(corner, corner); - } - - return target.setFromPoints(corners); - } - /** - * Check if the AABB is hit by a ray. - * @param {Ray} ray - * @return {Boolean} - */ - ; - - _proto.overlapsRay = function overlapsRay(ray) { - var direction = ray.direction, - from = ray.from; - - var dirFracX = 1 / direction.x; - var dirFracY = 1 / direction.y; - var dirFracZ = 1 / direction.z; // this.lowerBound is the corner of AABB with minimal coordinates - left bottom, rt is maximal corner - - var t1 = (this.lowerBound.x - from.x) * dirFracX; - var t2 = (this.upperBound.x - from.x) * dirFracX; - var t3 = (this.lowerBound.y - from.y) * dirFracY; - var t4 = (this.upperBound.y - from.y) * dirFracY; - var t5 = (this.lowerBound.z - from.z) * dirFracZ; - var t6 = (this.upperBound.z - from.z) * dirFracZ; // const tmin = Math.max(Math.max(Math.min(t1, t2), Math.min(t3, t4))); - // const tmax = Math.min(Math.min(Math.max(t1, t2), Math.max(t3, t4))); - - var tmin = Math.max(Math.max(Math.min(t1, t2), Math.min(t3, t4)), Math.min(t5, t6)); - var tmax = Math.min(Math.min(Math.max(t1, t2), Math.max(t3, t4)), Math.max(t5, t6)); // if tmax < 0, ray (line) is intersecting AABB, but whole AABB is behing us - - if (tmax < 0) { - //t = tmax; - return false; - } // if tmin > tmax, ray doesn't intersect AABB - - - if (tmin > tmax) { - //t = tmax; - return false; - } - - return true; - }; - - return AABB; -}(); -var tmp = new Vec3(); -var transformIntoFrame_corners = [new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3()]; - -/** - * Collision "matrix". It's actually a triangular-shaped array of whether two bodies are touching this step, for reference next step - * @class ArrayCollisionMatrix - * @constructor - */ -var ArrayCollisionMatrix = /*#__PURE__*/function () { - // The matrix storage. - function ArrayCollisionMatrix() { - this.matrix = []; - } - /** - * Get an element - * @method get - * @param {Body} i - * @param {Body} j - * @return {Number} - */ - - - var _proto = ArrayCollisionMatrix.prototype; - - _proto.get = function get(bi, bj) { - var i = bi.index; - var j = bj.index; - - if (j > i) { - var temp = j; - j = i; - i = temp; - } - - return this.matrix[(i * (i + 1) >> 1) + j - 1]; - } - /** - * Set an element - * @method set - * @param {Body} i - * @param {Body} j - * @param {boolean} value - */ - ; - - _proto.set = function set(bi, bj, value) { - var i = bi.index; - var j = bj.index; - - if (j > i) { - var temp = j; - j = i; - i = temp; - } - - this.matrix[(i * (i + 1) >> 1) + j - 1] = value ? 1 : 0; - } - /** - * Sets all elements to zero - * @method reset - */ - ; - - _proto.reset = function reset() { - for (var i = 0, l = this.matrix.length; i !== l; i++) { - this.matrix[i] = 0; - } - } - /** - * Sets the max number of objects - * @method setNumObjects - * @param {Number} n - */ - ; - - _proto.setNumObjects = function setNumObjects(n) { - this.matrix.length = n * (n - 1) >> 1; - }; - - return ArrayCollisionMatrix; -}(); - -function _inheritsLoose(subClass, superClass) { - subClass.prototype = Object.create(superClass.prototype); - subClass.prototype.constructor = subClass; - subClass.__proto__ = superClass; -} - -function _assertThisInitialized(self) { - if (self === void 0) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - - return self; -} - -/** - * Base class for objects that dispatches events. - * @class EventTarget - * @constructor - */ -var EventTarget = /*#__PURE__*/function () { - function EventTarget() {} - /** - * Add an event listener - * @method addEventListener - * @param {String} type - * @param {Function} listener - * @return {EventTarget} The self object, for chainability. - */ - - - var _proto = EventTarget.prototype; - - _proto.addEventListener = function addEventListener(type, listener) { - if (this._listeners === undefined) { - this._listeners = {}; - } - - var listeners = this._listeners; - - if (listeners[type] === undefined) { - listeners[type] = []; - } - - if (!listeners[type].includes(listener)) { - listeners[type].push(listener); - } - - return this; - } - /** - * Check if an event listener is added - * @method hasEventListener - * @param {String} type - * @param {Function} listener - * @return {Boolean} - */ - ; - - _proto.hasEventListener = function hasEventListener(type, listener) { - if (this._listeners === undefined) { - return false; - } - - var listeners = this._listeners; - - if (listeners[type] !== undefined && listeners[type].includes(listener)) { - return true; - } - - return false; - } - /** - * Check if any event listener of the given type is added - * @method hasAnyEventListener - * @param {String} type - * @return {Boolean} - */ - ; - - _proto.hasAnyEventListener = function hasAnyEventListener(type) { - if (this._listeners === undefined) { - return false; - } - - var listeners = this._listeners; - return listeners[type] !== undefined; - } - /** - * Remove an event listener - * @method removeEventListener - * @param {String} type - * @param {Function} listener - * @return {EventTarget} The self object, for chainability. - */ - ; - - _proto.removeEventListener = function removeEventListener(type, listener) { - if (this._listeners === undefined) { - return this; - } - - var listeners = this._listeners; - - if (listeners[type] === undefined) { - return this; - } - - var index = listeners[type].indexOf(listener); - - if (index !== -1) { - listeners[type].splice(index, 1); - } - - return this; - } - /** - * Emit an event. - * @method dispatchEvent - * @param {Object} event - * @param {String} event.type - * @return {EventTarget} The self object, for chainability. - */ - ; - - _proto.dispatchEvent = function dispatchEvent(event) { - if (this._listeners === undefined) { - return this; - } - - var listeners = this._listeners; - var listenerArray = listeners[event.type]; - - if (listenerArray !== undefined) { - event.target = this; - - for (var i = 0, l = listenerArray.length; i < l; i++) { - listenerArray[i].call(this, event); - } - } - - return this; - }; - - return EventTarget; -}(); - -/** - * A Quaternion describes a rotation in 3D space. The Quaternion is mathematically defined as Q = x*i + y*j + z*k + w, where (i,j,k) are imaginary basis vectors. (x,y,z) can be seen as a vector related to the axis of rotation, while the real multiplier, w, is related to the amount of rotation. - * @param {Number} x Multiplier of the imaginary basis vector i. - * @param {Number} y Multiplier of the imaginary basis vector j. - * @param {Number} z Multiplier of the imaginary basis vector k. - * @param {Number} w Multiplier of the real part. - * @see http://en.wikipedia.org/wiki/Quaternion - */ - -var Quaternion = /*#__PURE__*/function () { - function Quaternion(x, y, z, w) { - if (x === void 0) { - x = 0; - } - - if (y === void 0) { - y = 0; - } - - if (z === void 0) { - z = 0; - } - - if (w === void 0) { - w = 1; - } - - this.x = x; - this.y = y; - this.z = z; - this.w = w; - } - /** - * Set the value of the quaternion. - */ - - - var _proto = Quaternion.prototype; - - _proto.set = function set(x, y, z, w) { - this.x = x; - this.y = y; - this.z = z; - this.w = w; - return this; - } - /** - * Convert to a readable format - * @return {String} "x,y,z,w" - */ - ; - - _proto.toString = function toString() { - return this.x + "," + this.y + "," + this.z + "," + this.w; - } - /** - * Convert to an Array - * @return {Array} [x, y, z, w] - */ - ; - - _proto.toArray = function toArray() { - return [this.x, this.y, this.z, this.w]; - } - /** - * Set the quaternion components given an axis and an angle in radians. - */ - ; - - _proto.setFromAxisAngle = function setFromAxisAngle(vector, angle) { - var s = Math.sin(angle * 0.5); - this.x = vector.x * s; - this.y = vector.y * s; - this.z = vector.z * s; - this.w = Math.cos(angle * 0.5); - return this; - } - /** - * Converts the quaternion to [ axis, angle ] representation. - * @param {Vec3} [targetAxis] A vector object to reuse for storing the axis. - * @return {Array} An array, first element is the axis and the second is the angle in radians. - */ - ; - - _proto.toAxisAngle = function toAxisAngle(targetAxis) { - if (targetAxis === void 0) { - targetAxis = new Vec3(); - } - - this.normalize(); // if w>1 acos and sqrt will produce errors, this cant happen if quaternion is normalised - - var angle = 2 * Math.acos(this.w); - var s = Math.sqrt(1 - this.w * this.w); // assuming quaternion normalised then w is less than 1, so term always positive. - - if (s < 0.001) { - // test to avoid divide by zero, s is always positive due to sqrt - // if s close to zero then direction of axis not important - targetAxis.x = this.x; // if it is important that axis is normalised then replace with x=1; y=z=0; - - targetAxis.y = this.y; - targetAxis.z = this.z; - } else { - targetAxis.x = this.x / s; // normalise axis - - targetAxis.y = this.y / s; - targetAxis.z = this.z / s; - } - - return [targetAxis, angle]; - } - /** - * Set the quaternion value given two vectors. The resulting rotation will be the needed rotation to rotate u to v. - */ - ; - - _proto.setFromVectors = function setFromVectors(u, v) { - if (u.isAntiparallelTo(v)) { - var t1 = sfv_t1; - var t2 = sfv_t2; - u.tangents(t1, t2); - this.setFromAxisAngle(t1, Math.PI); - } else { - var a = u.cross(v); - this.x = a.x; - this.y = a.y; - this.z = a.z; - this.w = Math.sqrt(Math.pow(u.length(), 2) * Math.pow(v.length(), 2)) + u.dot(v); - this.normalize(); - } - - return this; - } - /** - * Multiply the quaternion with an other quaternion. - */ - ; - - _proto.mult = function mult(quat, target) { - if (target === void 0) { - target = new Quaternion(); - } - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - var bx = quat.x; - var by = quat.y; - var bz = quat.z; - var bw = quat.w; - target.x = ax * bw + aw * bx + ay * bz - az * by; - target.y = ay * bw + aw * by + az * bx - ax * bz; - target.z = az * bw + aw * bz + ax * by - ay * bx; - target.w = aw * bw - ax * bx - ay * by - az * bz; - return target; - } - /** - * Get the inverse quaternion rotation. - */ - ; - - _proto.inverse = function inverse(target) { - if (target === void 0) { - target = new Quaternion(); - } - - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - this.conjugate(target); - var inorm2 = 1 / (x * x + y * y + z * z + w * w); - target.x *= inorm2; - target.y *= inorm2; - target.z *= inorm2; - target.w *= inorm2; - return target; - } - /** - * Get the quaternion conjugate - */ - ; - - _proto.conjugate = function conjugate(target) { - if (target === void 0) { - target = new Quaternion(); - } - - target.x = -this.x; - target.y = -this.y; - target.z = -this.z; - target.w = this.w; - return target; - } - /** - * Normalize the quaternion. Note that this changes the values of the quaternion. - * @method normalize - */ - ; - - _proto.normalize = function normalize() { - var l = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w); - - if (l === 0) { - this.x = 0; - this.y = 0; - this.z = 0; - this.w = 0; - } else { - l = 1 / l; - this.x *= l; - this.y *= l; - this.z *= l; - this.w *= l; - } - - return this; - } - /** - * Approximation of quaternion normalization. Works best when quat is already almost-normalized. - * @see http://jsperf.com/fast-quaternion-normalization - * @author unphased, https://github.com/unphased - */ - ; - - _proto.normalizeFast = function normalizeFast() { - var f = (3.0 - (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w)) / 2.0; - - if (f === 0) { - this.x = 0; - this.y = 0; - this.z = 0; - this.w = 0; - } else { - this.x *= f; - this.y *= f; - this.z *= f; - this.w *= f; - } - - return this; - } - /** - * Multiply the quaternion by a vector - */ - ; - - _proto.vmult = function vmult(v, target) { - if (target === void 0) { - target = new Vec3(); - } - - var x = v.x; - var y = v.y; - var z = v.z; - var qx = this.x; - var qy = this.y; - var qz = this.z; - var qw = this.w; // q*v - - var ix = qw * x + qy * z - qz * y; - var iy = qw * y + qz * x - qx * z; - var iz = qw * z + qx * y - qy * x; - var iw = -qx * x - qy * y - qz * z; - target.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; - target.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; - target.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; - return target; - } - /** - * Copies value of source to this quaternion. - * @method copy - * @param {Quaternion} source - * @return {Quaternion} this - */ - ; - - _proto.copy = function copy(quat) { - this.x = quat.x; - this.y = quat.y; - this.z = quat.z; - this.w = quat.w; - return this; - } - /** - * Convert the quaternion to euler angle representation. Order: YZX, as this page describes: http://www.euclideanspace.com/maths/standards/index.htm - * @method toEuler - * @param {Vec3} target - * @param {String} order Three-character string, defaults to "YZX" - */ - ; - - _proto.toEuler = function toEuler(target, order) { - if (order === void 0) { - order = 'YZX'; - } - - var heading; - var attitude; - var bank; - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - - switch (order) { - case 'YZX': - var test = x * y + z * w; - - if (test > 0.499) { - // singularity at north pole - heading = 2 * Math.atan2(x, w); - attitude = Math.PI / 2; - bank = 0; - } - - if (test < -0.499) { - // singularity at south pole - heading = -2 * Math.atan2(x, w); - attitude = -Math.PI / 2; - bank = 0; - } - - if (heading === undefined) { - var sqx = x * x; - var sqy = y * y; - var sqz = z * z; - heading = Math.atan2(2 * y * w - 2 * x * z, 1 - 2 * sqy - 2 * sqz); // Heading - - attitude = Math.asin(2 * test); // attitude - - bank = Math.atan2(2 * x * w - 2 * y * z, 1 - 2 * sqx - 2 * sqz); // bank - } - - break; - - default: - throw new Error("Euler order " + order + " not supported yet."); - } - - target.y = heading; - target.z = attitude; - target.x = bank; - } - /** - * @param {Number} x - * @param {Number} y - * @param {Number} z - * @param {String} order The order to apply angles: 'XYZ' or 'YXZ' or any other combination - * @see http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/content/SpinCalc.m - */ - ; - - _proto.setFromEuler = function setFromEuler(x, y, z, order) { - if (order === void 0) { - order = 'XYZ'; - } - - var c1 = Math.cos(x / 2); - var c2 = Math.cos(y / 2); - var c3 = Math.cos(z / 2); - var s1 = Math.sin(x / 2); - var s2 = Math.sin(y / 2); - var s3 = Math.sin(z / 2); - - if (order === 'XYZ') { - this.x = s1 * c2 * c3 + c1 * s2 * s3; - this.y = c1 * s2 * c3 - s1 * c2 * s3; - this.z = c1 * c2 * s3 + s1 * s2 * c3; - this.w = c1 * c2 * c3 - s1 * s2 * s3; - } else if (order === 'YXZ') { - this.x = s1 * c2 * c3 + c1 * s2 * s3; - this.y = c1 * s2 * c3 - s1 * c2 * s3; - this.z = c1 * c2 * s3 - s1 * s2 * c3; - this.w = c1 * c2 * c3 + s1 * s2 * s3; - } else if (order === 'ZXY') { - this.x = s1 * c2 * c3 - c1 * s2 * s3; - this.y = c1 * s2 * c3 + s1 * c2 * s3; - this.z = c1 * c2 * s3 + s1 * s2 * c3; - this.w = c1 * c2 * c3 - s1 * s2 * s3; - } else if (order === 'ZYX') { - this.x = s1 * c2 * c3 - c1 * s2 * s3; - this.y = c1 * s2 * c3 + s1 * c2 * s3; - this.z = c1 * c2 * s3 - s1 * s2 * c3; - this.w = c1 * c2 * c3 + s1 * s2 * s3; - } else if (order === 'YZX') { - this.x = s1 * c2 * c3 + c1 * s2 * s3; - this.y = c1 * s2 * c3 + s1 * c2 * s3; - this.z = c1 * c2 * s3 - s1 * s2 * c3; - this.w = c1 * c2 * c3 - s1 * s2 * s3; - } else if (order === 'XZY') { - this.x = s1 * c2 * c3 - c1 * s2 * s3; - this.y = c1 * s2 * c3 - s1 * c2 * s3; - this.z = c1 * c2 * s3 + s1 * s2 * c3; - this.w = c1 * c2 * c3 + s1 * s2 * s3; - } - - return this; - } - /** - * @method clone - * @return {Quaternion} - */ - ; - - _proto.clone = function clone() { - return new Quaternion(this.x, this.y, this.z, this.w); - } - /** - * Performs a spherical linear interpolation between two quat - * - * @param {Quaternion} toQuat second operand - * @param {Number} t interpolation amount between the self quaternion and toQuat - * @param {Quaternion} [target] A quaternion to store the result in. If not provided, a new one will be created. - * @returns {Quaternion} The "target" object - */ - ; - - _proto.slerp = function slerp(toQuat, t, target) { - if (target === void 0) { - target = new Quaternion(); - } - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - var bx = toQuat.x; - var by = toQuat.y; - var bz = toQuat.z; - var bw = toQuat.w; - var omega; - var cosom; - var sinom; - var scale0; - var scale1; // calc cosine - - cosom = ax * bx + ay * by + az * bz + aw * bw; // adjust signs (if necessary) - - if (cosom < 0.0) { - cosom = -cosom; - bx = -bx; - by = -by; - bz = -bz; - bw = -bw; - } // calculate coefficients - - - if (1.0 - cosom > 0.000001) { - // standard case (slerp) - omega = Math.acos(cosom); - sinom = Math.sin(omega); - scale0 = Math.sin((1.0 - t) * omega) / sinom; - scale1 = Math.sin(t * omega) / sinom; - } else { - // "from" and "to" quaternions are very close - // ... so we can do a linear interpolation - scale0 = 1.0 - t; - scale1 = t; - } // calculate final values - - - target.x = scale0 * ax + scale1 * bx; - target.y = scale0 * ay + scale1 * by; - target.z = scale0 * az + scale1 * bz; - target.w = scale0 * aw + scale1 * bw; - return target; - } - /** - * Rotate an absolute orientation quaternion given an angular velocity and a time step. - */ - ; - - _proto.integrate = function integrate(angularVelocity, dt, angularFactor, target) { - if (target === void 0) { - target = new Quaternion(); - } - - var ax = angularVelocity.x * angularFactor.x, - ay = angularVelocity.y * angularFactor.y, - az = angularVelocity.z * angularFactor.z, - bx = this.x, - by = this.y, - bz = this.z, - bw = this.w; - var half_dt = dt * 0.5; - target.x += half_dt * (ax * bw + ay * bz - az * by); - target.y += half_dt * (ay * bw + az * bx - ax * bz); - target.z += half_dt * (az * bw + ax * by - ay * bx); - target.w += half_dt * (-ax * bx - ay * by - az * bz); - return target; - }; - - return Quaternion; -}(); -var sfv_t1 = new Vec3(); -var sfv_t2 = new Vec3(); - -var SHAPE_TYPES = { - SPHERE: 1, - PLANE: 2, - BOX: 4, - COMPOUND: 8, - CONVEXPOLYHEDRON: 16, - HEIGHTFIELD: 32, - PARTICLE: 64, - CYLINDER: 128, - TRIMESH: 256 -}; - -/** - * Base class for shapes - * @class Shape - * @constructor - * @param {object} [options] - * @param {number} [options.collisionFilterGroup=1] - * @param {number} [options.collisionFilterMask=-1] - * @param {number} [options.collisionResponse=true] - * @param {number} [options.material=null] - * @author schteppe - */ -var Shape = /*#__PURE__*/function () { - // Identifyer of the Shape. - // The type of this shape. Must be set to an int > 0 by subclasses. - // The local bounding sphere radius of this shape. - // Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled. - function Shape(options) { - if (options === void 0) { - options = {}; - } - - this.id = Shape.idCounter++; - this.type = options.type || 0; - this.boundingSphereRadius = 0; - this.collisionResponse = options.collisionResponse ? options.collisionResponse : true; - this.collisionFilterGroup = options.collisionFilterGroup !== undefined ? options.collisionFilterGroup : 1; - this.collisionFilterMask = options.collisionFilterMask !== undefined ? options.collisionFilterMask : -1; - this.material = options.material ? options.material : null; - this.body = null; - } - /** - * Computes the bounding sphere radius. The result is stored in the property .boundingSphereRadius - * @method updateBoundingSphereRadius - */ - - - var _proto = Shape.prototype; - - _proto.updateBoundingSphereRadius = function updateBoundingSphereRadius() { - throw "computeBoundingSphereRadius() not implemented for shape type " + this.type; - } - /** - * Get the volume of this shape - * @method volume - * @return {Number} - */ - ; - - _proto.volume = function volume() { - throw "volume() not implemented for shape type " + this.type; - } - /** - * Calculates the inertia in the local frame for this shape. - * @method calculateLocalInertia - * @param {Number} mass - * @param {Vec3} target - * @see http://en.wikipedia.org/wiki/List_of_moments_of_inertia - */ - ; - - _proto.calculateLocalInertia = function calculateLocalInertia(mass, target) { - throw "calculateLocalInertia() not implemented for shape type " + this.type; - }; - - _proto.calculateWorldAABB = function calculateWorldAABB(pos, quat, min, max) { - throw "calculateWorldAABB() not implemented for shape type " + this.type; - }; - - return Shape; -}(); -Shape.idCounter = 0; -/** - * The available shape types. - * @static - * @property types - * @type {Object} - */ - -Shape.types = SHAPE_TYPES; - -var Transform = /*#__PURE__*/function () { - function Transform(options) { - if (options === void 0) { - options = {}; - } - - this.position = new Vec3(); - this.quaternion = new Quaternion(); - - if (options.position) { - this.position.copy(options.position); - } - - if (options.quaternion) { - this.quaternion.copy(options.quaternion); - } - } - /** - * Get a global point in local transform coordinates. - */ - - - var _proto = Transform.prototype; - - _proto.pointToLocal = function pointToLocal(worldPoint, result) { - return Transform.pointToLocalFrame(this.position, this.quaternion, worldPoint, result); - } - /** - * Get a local point in global transform coordinates. - */ - ; - - _proto.pointToWorld = function pointToWorld(localPoint, result) { - return Transform.pointToWorldFrame(this.position, this.quaternion, localPoint, result); - }; - - _proto.vectorToWorldFrame = function vectorToWorldFrame(localVector, result) { - if (result === void 0) { - result = new Vec3(); - } - - this.quaternion.vmult(localVector, result); - return result; - }; - - Transform.pointToLocalFrame = function pointToLocalFrame(position, quaternion, worldPoint, result) { - if (result === void 0) { - result = new Vec3(); - } - - worldPoint.vsub(position, result); - quaternion.conjugate(tmpQuat); - tmpQuat.vmult(result, result); - return result; - }; - - Transform.pointToWorldFrame = function pointToWorldFrame(position, quaternion, localPoint, result) { - if (result === void 0) { - result = new Vec3(); - } - - quaternion.vmult(localPoint, result); - result.vadd(position, result); - return result; - }; - - Transform.vectorToWorldFrame = function vectorToWorldFrame(quaternion, localVector, result) { - if (result === void 0) { - result = new Vec3(); - } - - quaternion.vmult(localVector, result); - return result; - }; - - Transform.vectorToLocalFrame = function vectorToLocalFrame(position, quaternion, worldVector, result) { - if (result === void 0) { - result = new Vec3(); - } - - quaternion.w *= -1; - quaternion.vmult(worldVector, result); - quaternion.w *= -1; - return result; - }; - - return Transform; -}(); -var tmpQuat = new Quaternion(); - -/** - * A set of polygons describing a convex shape. - * @class ConvexPolyhedron - * @constructor - * @extends Shape - * @description The shape MUST be convex for the code to work properly. No polygons may be coplanar (contained - * in the same 3D plane), instead these should be merged into one polygon. - * - * @param {array} points An array of Vec3's - * @param {array} faces Array of integer arrays, describing which vertices that is included in each face. - * - * @author qiao / https://github.com/qiao (original author, see https://github.com/qiao/three.js/commit/85026f0c769e4000148a67d45a9e9b9c5108836f) - * @author schteppe / https://github.com/schteppe - * @see http://www.altdevblogaday.com/2011/05/13/contact-generation-between-3d-convex-meshes/ - * - * @todo Move the clipping functions to ContactGenerator? - * @todo Automatically merge coplanar polygons in constructor. - */ -var ConvexPolyhedron = /*#__PURE__*/function (_Shape) { - _inheritsLoose(ConvexPolyhedron, _Shape); - - // Array of integer arrays, indicating which vertices each face consists of - // If given, these locally defined, normalized axes are the only ones being checked when doing separating axis check. - function ConvexPolyhedron(props) { - var _this; - - if (props === void 0) { - props = {}; - } - - var _props = props, - _props$vertices = _props.vertices, - vertices = _props$vertices === void 0 ? [] : _props$vertices, - _props$faces = _props.faces, - faces = _props$faces === void 0 ? [] : _props$faces, - _props$normals = _props.normals, - normals = _props$normals === void 0 ? [] : _props$normals, - axes = _props.axes, - boundingSphereRadius = _props.boundingSphereRadius; - _this = _Shape.call(this, { - type: Shape.types.CONVEXPOLYHEDRON - }) || this; - _this.vertices = vertices; - _this.faces = faces; - _this.faceNormals = normals; - - if (_this.faceNormals.length === 0) { - _this.computeNormals(); - } - - if (!boundingSphereRadius) { - _this.updateBoundingSphereRadius(); - } else { - _this.boundingSphereRadius = boundingSphereRadius; - } - - _this.worldVertices = []; // World transformed version of .vertices - - _this.worldVerticesNeedsUpdate = true; - _this.worldFaceNormals = []; // World transformed version of .faceNormals - - _this.worldFaceNormalsNeedsUpdate = true; - _this.uniqueAxes = axes ? axes.slice() : null; - _this.uniqueEdges = []; - - _this.computeEdges(); - - return _this; - } - /** - * Computes uniqueEdges - * @method computeEdges - */ - - - var _proto = ConvexPolyhedron.prototype; - - _proto.computeEdges = function computeEdges() { - var faces = this.faces; - var vertices = this.vertices; - var edges = this.uniqueEdges; - edges.length = 0; - var edge = new Vec3(); - - for (var i = 0; i !== faces.length; i++) { - var face = faces[i]; - var numVertices = face.length; - - for (var j = 0; j !== numVertices; j++) { - var k = (j + 1) % numVertices; - vertices[face[j]].vsub(vertices[face[k]], edge); - edge.normalize(); - var found = false; - - for (var p = 0; p !== edges.length; p++) { - if (edges[p].almostEquals(edge) || edges[p].almostEquals(edge)) { - found = true; - break; - } - } - - if (!found) { - edges.push(edge.clone()); - } - } - } - } - /** - * Compute the normals of the faces. Will reuse existing Vec3 objects in the .faceNormals array if they exist. - * @method computeNormals - */ - ; - - _proto.computeNormals = function computeNormals() { - this.faceNormals.length = this.faces.length; // Generate normals - - for (var i = 0; i < this.faces.length; i++) { - // Check so all vertices exists for this face - for (var j = 0; j < this.faces[i].length; j++) { - if (!this.vertices[this.faces[i][j]]) { - throw new Error("Vertex " + this.faces[i][j] + " not found!"); - } - } - - var n = this.faceNormals[i] || new Vec3(); - this.getFaceNormal(i, n); - n.negate(n); - this.faceNormals[i] = n; - var vertex = this.vertices[this.faces[i][0]]; - - if (n.dot(vertex) < 0) { - console.error(".faceNormals[" + i + "] = Vec3(" + n.toString() + ") looks like it points into the shape? The vertices follow. Make sure they are ordered CCW around the normal, using the right hand rule."); - - for (var _j = 0; _j < this.faces[i].length; _j++) { - console.warn(".vertices[" + this.faces[i][_j] + "] = Vec3(" + this.vertices[this.faces[i][_j]].toString() + ")"); - } - } - } - } - /** - * Compute the normal of a face from its vertices - * @method getFaceNormal - * @param {Number} i - * @param {Vec3} target - */ - ; - - _proto.getFaceNormal = function getFaceNormal(i, target) { - var f = this.faces[i]; - var va = this.vertices[f[0]]; - var vb = this.vertices[f[1]]; - var vc = this.vertices[f[2]]; - ConvexPolyhedron.computeNormal(va, vb, vc, target); - } - /** - * @method clipAgainstHull - * @param {Vec3} posA - * @param {Quaternion} quatA - * @param {ConvexPolyhedron} hullB - * @param {Vec3} posB - * @param {Quaternion} quatB - * @param {Vec3} separatingNormal - * @param {Number} minDist Clamp distance - * @param {Number} maxDist - * @param {array} result The an array of contact point objects, see clipFaceAgainstHull - */ - ; - - _proto.clipAgainstHull = function clipAgainstHull(posA, quatA, hullB, posB, quatB, separatingNormal, minDist, maxDist, result) { - var WorldNormal = new Vec3(); - var closestFaceB = -1; - var dmax = -Number.MAX_VALUE; - - for (var face = 0; face < hullB.faces.length; face++) { - WorldNormal.copy(hullB.faceNormals[face]); - quatB.vmult(WorldNormal, WorldNormal); - var d = WorldNormal.dot(separatingNormal); - - if (d > dmax) { - dmax = d; - closestFaceB = face; - } - } - - var worldVertsB1 = []; - - for (var i = 0; i < hullB.faces[closestFaceB].length; i++) { - var b = hullB.vertices[hullB.faces[closestFaceB][i]]; - var worldb = new Vec3(); - worldb.copy(b); - quatB.vmult(worldb, worldb); - posB.vadd(worldb, worldb); - worldVertsB1.push(worldb); - } - - if (closestFaceB >= 0) { - this.clipFaceAgainstHull(separatingNormal, posA, quatA, worldVertsB1, minDist, maxDist, result); - } - } - /** - * Find the separating axis between this hull and another - * @method findSeparatingAxis - * @param {ConvexPolyhedron} hullB - * @param {Vec3} posA - * @param {Quaternion} quatA - * @param {Vec3} posB - * @param {Quaternion} quatB - * @param {Vec3} target The target vector to save the axis in - * @return {bool} Returns false if a separation is found, else true - */ - ; - - _proto.findSeparatingAxis = function findSeparatingAxis(hullB, posA, quatA, posB, quatB, target, faceListA, faceListB) { - var faceANormalWS3 = new Vec3(); - var Worldnormal1 = new Vec3(); - var deltaC = new Vec3(); - var worldEdge0 = new Vec3(); - var worldEdge1 = new Vec3(); - var Cross = new Vec3(); - var dmin = Number.MAX_VALUE; - var hullA = this; - - if (!hullA.uniqueAxes) { - var numFacesA = faceListA ? faceListA.length : hullA.faces.length; // Test face normals from hullA - - for (var i = 0; i < numFacesA; i++) { - var fi = faceListA ? faceListA[i] : i; // Get world face normal - - faceANormalWS3.copy(hullA.faceNormals[fi]); - quatA.vmult(faceANormalWS3, faceANormalWS3); - var d = hullA.testSepAxis(faceANormalWS3, hullB, posA, quatA, posB, quatB); - - if (d === false) { - return false; - } - - if (d < dmin) { - dmin = d; - target.copy(faceANormalWS3); - } - } - } else { - // Test unique axes - for (var _i = 0; _i !== hullA.uniqueAxes.length; _i++) { - // Get world axis - quatA.vmult(hullA.uniqueAxes[_i], faceANormalWS3); - - var _d = hullA.testSepAxis(faceANormalWS3, hullB, posA, quatA, posB, quatB); - - if (_d === false) { - return false; - } - - if (_d < dmin) { - dmin = _d; - target.copy(faceANormalWS3); - } - } - } - - if (!hullB.uniqueAxes) { - // Test face normals from hullB - var numFacesB = faceListB ? faceListB.length : hullB.faces.length; - - for (var _i2 = 0; _i2 < numFacesB; _i2++) { - var _fi = faceListB ? faceListB[_i2] : _i2; - - Worldnormal1.copy(hullB.faceNormals[_fi]); - quatB.vmult(Worldnormal1, Worldnormal1); - - var _d2 = hullA.testSepAxis(Worldnormal1, hullB, posA, quatA, posB, quatB); - - if (_d2 === false) { - return false; - } - - if (_d2 < dmin) { - dmin = _d2; - target.copy(Worldnormal1); - } - } - } else { - // Test unique axes in B - for (var _i3 = 0; _i3 !== hullB.uniqueAxes.length; _i3++) { - quatB.vmult(hullB.uniqueAxes[_i3], Worldnormal1); - - var _d3 = hullA.testSepAxis(Worldnormal1, hullB, posA, quatA, posB, quatB); - - if (_d3 === false) { - return false; - } - - if (_d3 < dmin) { - dmin = _d3; - target.copy(Worldnormal1); - } - } - } // Test edges - - - for (var e0 = 0; e0 !== hullA.uniqueEdges.length; e0++) { - // Get world edge - quatA.vmult(hullA.uniqueEdges[e0], worldEdge0); - - for (var e1 = 0; e1 !== hullB.uniqueEdges.length; e1++) { - // Get world edge 2 - quatB.vmult(hullB.uniqueEdges[e1], worldEdge1); - worldEdge0.cross(worldEdge1, Cross); - - if (!Cross.almostZero()) { - Cross.normalize(); - var dist = hullA.testSepAxis(Cross, hullB, posA, quatA, posB, quatB); - - if (dist === false) { - return false; - } - - if (dist < dmin) { - dmin = dist; - target.copy(Cross); - } - } - } - } - - posB.vsub(posA, deltaC); - - if (deltaC.dot(target) > 0.0) { - target.negate(target); - } - - return true; - } - /** - * Test separating axis against two hulls. Both hulls are projected onto the axis and the overlap size is returned if there is one. - * @method testSepAxis - * @param {Vec3} axis - * @param {ConvexPolyhedron} hullB - * @param {Vec3} posA - * @param {Quaternion} quatA - * @param {Vec3} posB - * @param {Quaternion} quatB - * @return {number} The overlap depth, or FALSE if no penetration. - */ - ; - - _proto.testSepAxis = function testSepAxis(axis, hullB, posA, quatA, posB, quatB) { - var hullA = this; - ConvexPolyhedron.project(hullA, axis, posA, quatA, maxminA); - ConvexPolyhedron.project(hullB, axis, posB, quatB, maxminB); - var maxA = maxminA[0]; - var minA = maxminA[1]; - var maxB = maxminB[0]; - var minB = maxminB[1]; - - if (maxA < minB || maxB < minA) { - return false; // Separated - } - - var d0 = maxA - minB; - var d1 = maxB - minA; - var depth = d0 < d1 ? d0 : d1; - return depth; - } - /** - * @method calculateLocalInertia - * @param {Number} mass - * @param {Vec3} target - */ - ; - - _proto.calculateLocalInertia = function calculateLocalInertia(mass, target) { - // Approximate with box inertia - // Exact inertia calculation is overkill, but see http://geometrictools.com/Documentation/PolyhedralMassProperties.pdf for the correct way to do it - var aabbmax = new Vec3(); - var aabbmin = new Vec3(); - this.computeLocalAABB(aabbmin, aabbmax); - var x = aabbmax.x - aabbmin.x; - var y = aabbmax.y - aabbmin.y; - var z = aabbmax.z - aabbmin.z; - target.x = 1.0 / 12.0 * mass * (2 * y * 2 * y + 2 * z * 2 * z); - target.y = 1.0 / 12.0 * mass * (2 * x * 2 * x + 2 * z * 2 * z); - target.z = 1.0 / 12.0 * mass * (2 * y * 2 * y + 2 * x * 2 * x); - } - /** - * @method getPlaneConstantOfFace - * @param {Number} face_i Index of the face - * @return {Number} - */ - ; - - _proto.getPlaneConstantOfFace = function getPlaneConstantOfFace(face_i) { - var f = this.faces[face_i]; - var n = this.faceNormals[face_i]; - var v = this.vertices[f[0]]; - var c = -n.dot(v); - return c; - } - /** - * Clip a face against a hull. - * @method clipFaceAgainstHull - * @param {Vec3} separatingNormal - * @param {Vec3} posA - * @param {Quaternion} quatA - * @param {Array} worldVertsB1 An array of Vec3 with vertices in the world frame. - * @param {Number} minDist Distance clamping - * @param {Number} maxDist - * @param Array result Array to store resulting contact points in. Will be objects with properties: point, depth, normal. These are represented in world coordinates. - */ - ; - - _proto.clipFaceAgainstHull = function clipFaceAgainstHull(separatingNormal, posA, quatA, worldVertsB1, minDist, maxDist, result) { - var faceANormalWS = new Vec3(); - var edge0 = new Vec3(); - var WorldEdge0 = new Vec3(); - var worldPlaneAnormal1 = new Vec3(); - var planeNormalWS1 = new Vec3(); - var worldA1 = new Vec3(); - var localPlaneNormal = new Vec3(); - var planeNormalWS = new Vec3(); - var hullA = this; - var worldVertsB2 = []; - var pVtxIn = worldVertsB1; - var pVtxOut = worldVertsB2; - var closestFaceA = -1; - var dmin = Number.MAX_VALUE; // Find the face with normal closest to the separating axis - - for (var face = 0; face < hullA.faces.length; face++) { - faceANormalWS.copy(hullA.faceNormals[face]); - quatA.vmult(faceANormalWS, faceANormalWS); - var d = faceANormalWS.dot(separatingNormal); - - if (d < dmin) { - dmin = d; - closestFaceA = face; - } - } - - if (closestFaceA < 0) { - return; - } // Get the face and construct connected faces - - - var polyA = hullA.faces[closestFaceA]; - polyA.connectedFaces = []; - - for (var i = 0; i < hullA.faces.length; i++) { - for (var j = 0; j < hullA.faces[i].length; j++) { - if ( - /* Sharing a vertex*/ - polyA.indexOf(hullA.faces[i][j]) !== -1 && - /* Not the one we are looking for connections from */ - i !== closestFaceA && - /* Not already added */ - polyA.connectedFaces.indexOf(i) === -1) { - polyA.connectedFaces.push(i); - } - } - } // Clip the polygon to the back of the planes of all faces of hull A, - // that are adjacent to the witness face - - - var numVerticesA = polyA.length; - - for (var _i4 = 0; _i4 < numVerticesA; _i4++) { - var a = hullA.vertices[polyA[_i4]]; - var b = hullA.vertices[polyA[(_i4 + 1) % numVerticesA]]; - a.vsub(b, edge0); - WorldEdge0.copy(edge0); - quatA.vmult(WorldEdge0, WorldEdge0); - posA.vadd(WorldEdge0, WorldEdge0); - worldPlaneAnormal1.copy(this.faceNormals[closestFaceA]); - quatA.vmult(worldPlaneAnormal1, worldPlaneAnormal1); - posA.vadd(worldPlaneAnormal1, worldPlaneAnormal1); - WorldEdge0.cross(worldPlaneAnormal1, planeNormalWS1); - planeNormalWS1.negate(planeNormalWS1); - worldA1.copy(a); - quatA.vmult(worldA1, worldA1); - posA.vadd(worldA1, worldA1); - var otherFace = polyA.connectedFaces[_i4]; - localPlaneNormal.copy(this.faceNormals[otherFace]); - - var _localPlaneEq = this.getPlaneConstantOfFace(otherFace); - - planeNormalWS.copy(localPlaneNormal); - quatA.vmult(planeNormalWS, planeNormalWS); - - var _planeEqWS = _localPlaneEq - planeNormalWS.dot(posA); // Clip face against our constructed plane - - - this.clipFaceAgainstPlane(pVtxIn, pVtxOut, planeNormalWS, _planeEqWS); // Throw away all clipped points, but save the remaining until next clip - - while (pVtxIn.length) { - pVtxIn.shift(); - } - - while (pVtxOut.length) { - pVtxIn.push(pVtxOut.shift()); - } - } // only keep contact points that are behind the witness face - - - localPlaneNormal.copy(this.faceNormals[closestFaceA]); - var localPlaneEq = this.getPlaneConstantOfFace(closestFaceA); - planeNormalWS.copy(localPlaneNormal); - quatA.vmult(planeNormalWS, planeNormalWS); - var planeEqWS = localPlaneEq - planeNormalWS.dot(posA); - - for (var _i5 = 0; _i5 < pVtxIn.length; _i5++) { - var depth = planeNormalWS.dot(pVtxIn[_i5]) + planeEqWS; // ??? - - if (depth <= minDist) { - console.log("clamped: depth=" + depth + " to minDist=" + minDist); - depth = minDist; - } - - if (depth <= maxDist) { - var point = pVtxIn[_i5]; - - if (depth <= 1e-6) { - var p = { - point: point, - normal: planeNormalWS, - depth: depth - }; - result.push(p); - } - } - } - } - /** - * Clip a face in a hull against the back of a plane. - * @method clipFaceAgainstPlane - * @param {Array} inVertices - * @param {Array} outVertices - * @param {Vec3} planeNormal - * @param {Number} planeConstant The constant in the mathematical plane equation - */ - ; - - _proto.clipFaceAgainstPlane = function clipFaceAgainstPlane(inVertices, outVertices, planeNormal, planeConstant) { - var n_dot_first; - var n_dot_last; - var numVerts = inVertices.length; - - if (numVerts < 2) { - return outVertices; - } - - var firstVertex = inVertices[inVertices.length - 1]; - var lastVertex = inVertices[0]; - n_dot_first = planeNormal.dot(firstVertex) + planeConstant; - - for (var vi = 0; vi < numVerts; vi++) { - lastVertex = inVertices[vi]; - n_dot_last = planeNormal.dot(lastVertex) + planeConstant; - - if (n_dot_first < 0) { - if (n_dot_last < 0) { - // Start < 0, end < 0, so output lastVertex - var newv = new Vec3(); - newv.copy(lastVertex); - outVertices.push(newv); - } else { - // Start < 0, end >= 0, so output intersection - var _newv = new Vec3(); - - firstVertex.lerp(lastVertex, n_dot_first / (n_dot_first - n_dot_last), _newv); - outVertices.push(_newv); - } - } else { - if (n_dot_last < 0) { - // Start >= 0, end < 0 so output intersection and end - var _newv2 = new Vec3(); - - firstVertex.lerp(lastVertex, n_dot_first / (n_dot_first - n_dot_last), _newv2); - outVertices.push(_newv2); - outVertices.push(lastVertex); - } - } - - firstVertex = lastVertex; - n_dot_first = n_dot_last; - } - - return outVertices; - } // Updates .worldVertices and sets .worldVerticesNeedsUpdate to false. - ; - - _proto.computeWorldVertices = function computeWorldVertices(position, quat) { - while (this.worldVertices.length < this.vertices.length) { - this.worldVertices.push(new Vec3()); - } - - var verts = this.vertices; - var worldVerts = this.worldVertices; - - for (var i = 0; i !== this.vertices.length; i++) { - quat.vmult(verts[i], worldVerts[i]); - position.vadd(worldVerts[i], worldVerts[i]); - } - - this.worldVerticesNeedsUpdate = false; - }; - - _proto.computeLocalAABB = function computeLocalAABB(aabbmin, aabbmax) { - var vertices = this.vertices; - aabbmin.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE); - aabbmax.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE); - - for (var i = 0; i < this.vertices.length; i++) { - var v = vertices[i]; - - if (v.x < aabbmin.x) { - aabbmin.x = v.x; - } else if (v.x > aabbmax.x) { - aabbmax.x = v.x; - } - - if (v.y < aabbmin.y) { - aabbmin.y = v.y; - } else if (v.y > aabbmax.y) { - aabbmax.y = v.y; - } - - if (v.z < aabbmin.z) { - aabbmin.z = v.z; - } else if (v.z > aabbmax.z) { - aabbmax.z = v.z; - } - } - } - /** - * Updates .worldVertices and sets .worldVerticesNeedsUpdate to false. - * @method computeWorldFaceNormals - * @param {Quaternion} quat - */ - ; - - _proto.computeWorldFaceNormals = function computeWorldFaceNormals(quat) { - var N = this.faceNormals.length; - - while (this.worldFaceNormals.length < N) { - this.worldFaceNormals.push(new Vec3()); - } - - var normals = this.faceNormals; - var worldNormals = this.worldFaceNormals; - - for (var i = 0; i !== N; i++) { - quat.vmult(normals[i], worldNormals[i]); - } - - this.worldFaceNormalsNeedsUpdate = false; - } - /** - * @method updateBoundingSphereRadius - */ - ; - - _proto.updateBoundingSphereRadius = function updateBoundingSphereRadius() { - // Assume points are distributed with local (0,0,0) as center - var max2 = 0; - var verts = this.vertices; - - for (var i = 0; i !== verts.length; i++) { - var norm2 = verts[i].lengthSquared(); - - if (norm2 > max2) { - max2 = norm2; - } - } - - this.boundingSphereRadius = Math.sqrt(max2); - } - /** - * @method calculateWorldAABB - * @param {Vec3} pos - * @param {Quaternion} quat - * @param {Vec3} min - * @param {Vec3} max - */ - ; - - _proto.calculateWorldAABB = function calculateWorldAABB(pos, quat, min, max) { - var verts = this.vertices; - var minx; - var miny; - var minz; - var maxx; - var maxy; - var maxz; - var tempWorldVertex = new Vec3(); - - for (var i = 0; i < verts.length; i++) { - tempWorldVertex.copy(verts[i]); - quat.vmult(tempWorldVertex, tempWorldVertex); - pos.vadd(tempWorldVertex, tempWorldVertex); - var v = tempWorldVertex; - - if (minx === undefined || v.x < minx) { - minx = v.x; - } - - if (maxx === undefined || v.x > maxx) { - maxx = v.x; - } - - if (miny === undefined || v.y < miny) { - miny = v.y; - } - - if (maxy === undefined || v.y > maxy) { - maxy = v.y; - } - - if (minz === undefined || v.z < minz) { - minz = v.z; - } - - if (maxz === undefined || v.z > maxz) { - maxz = v.z; - } - } - - min.set(minx, miny, minz); - max.set(maxx, maxy, maxz); - } - /** - * Get approximate convex volume - * @method volume - * @return {Number} - */ - ; - - _proto.volume = function volume() { - return 4.0 * Math.PI * this.boundingSphereRadius / 3.0; - } - /** - * Get an average of all the vertices positions - * @method getAveragePointLocal - * @param {Vec3} target - * @return {Vec3} - */ - ; - - _proto.getAveragePointLocal = function getAveragePointLocal(target) { - if (target === void 0) { - target = new Vec3(); - } - - var verts = this.vertices; - - for (var i = 0; i < verts.length; i++) { - target.vadd(verts[i], target); - } - - target.scale(1 / verts.length, target); - return target; - } - /** - * Transform all local points. Will change the .vertices - * @method transformAllPoints - * @param {Vec3} offset - * @param {Quaternion} quat - */ - ; - - _proto.transformAllPoints = function transformAllPoints(offset, quat) { - var n = this.vertices.length; - var verts = this.vertices; // Apply rotation - - if (quat) { - // Rotate vertices - for (var i = 0; i < n; i++) { - var v = verts[i]; - quat.vmult(v, v); - } // Rotate face normals - - - for (var _i6 = 0; _i6 < this.faceNormals.length; _i6++) { - var _v = this.faceNormals[_i6]; - quat.vmult(_v, _v); - } - /* - // Rotate edges - for(let i=0; i 0 || r1 > 0 && r2 < 0) { - return false; // Encountered some other sign. Exit. - } - } // If we got here, all dot products were of the same sign. - - - return -1; - }; - - return ConvexPolyhedron; -}(Shape); -/** - * Get face normal given 3 vertices - * @static - * @method computeNormal - * @param {Vec3} va - * @param {Vec3} vb - * @param {Vec3} vc - * @param {Vec3} target - */ - -ConvexPolyhedron.computeNormal = function (va, vb, vc, target) { - var cb = new Vec3(); - var ab = new Vec3(); - vb.vsub(va, ab); - vc.vsub(vb, cb); - cb.cross(ab, target); - - if (!target.isZero()) { - target.normalize(); - } -}; - -var maxminA = []; -var maxminB = []; -/** - * Get max and min dot product of a convex hull at position (pos,quat) projected onto an axis. - * Results are saved in the array maxmin. - * @static - * @method project - * @param {ConvexPolyhedron} hull - * @param {Vec3} axis - * @param {Vec3} pos - * @param {Quaternion} quat - * @param {array} result result[0] and result[1] will be set to maximum and minimum, respectively. - */ - -ConvexPolyhedron.project = function (shape, axis, pos, quat, result) { - var n = shape.vertices.length; - var localAxis = new Vec3(); - var max = 0; - var min = 0; - var localOrigin = new Vec3(); - var vs = shape.vertices; - localOrigin.setZero(); // Transform the axis to local - - Transform.vectorToLocalFrame(pos, quat, axis, localAxis); - Transform.pointToLocalFrame(pos, quat, localOrigin, localOrigin); - var add = localOrigin.dot(localAxis); - min = max = vs[0].dot(localAxis); - - for (var i = 1; i < n; i++) { - var val = vs[i].dot(localAxis); - - if (val > max) { - max = val; - } - - if (val < min) { - min = val; - } - } - - min -= add; - max -= add; - - if (min > max) { - // Inconsistent - swap - var temp = min; - min = max; - max = temp; - } // Output - - - result[0] = max; - result[1] = min; -}; - -/** - * A 3d box shape. - * @class Box - * @constructor - * @param {Vec3} halfExtents - * @author schteppe - * @extends Shape - */ -var Box = /*#__PURE__*/function (_Shape) { - _inheritsLoose(Box, _Shape); - - // Used by the contact generator to make contacts with other convex polyhedra for example. - function Box(halfExtents) { - var _this; - - _this = _Shape.call(this, { - type: Shape.types.BOX - }) || this; - _this.halfExtents = halfExtents; - _this.convexPolyhedronRepresentation = null; - - _this.updateConvexPolyhedronRepresentation(); - - _this.updateBoundingSphereRadius(); - - return _this; - } - /** - * Updates the local convex polyhedron representation used for some collisions. - * @method updateConvexPolyhedronRepresentation - */ - - - var _proto = Box.prototype; - - _proto.updateConvexPolyhedronRepresentation = function updateConvexPolyhedronRepresentation() { - var sx = this.halfExtents.x; - var sy = this.halfExtents.y; - var sz = this.halfExtents.z; - var V = Vec3; - var vertices = [new V(-sx, -sy, -sz), new V(sx, -sy, -sz), new V(sx, sy, -sz), new V(-sx, sy, -sz), new V(-sx, -sy, sz), new V(sx, -sy, sz), new V(sx, sy, sz), new V(-sx, sy, sz)]; - var faces = [[3, 2, 1, 0], // -z - [4, 5, 6, 7], // +z - [5, 4, 0, 1], // -y - [2, 3, 7, 6], // +y - [0, 4, 7, 3], // -x - [1, 2, 6, 5] // +x - ]; - var axes = [new V(0, 0, 1), new V(0, 1, 0), new V(1, 0, 0)]; - var h = new ConvexPolyhedron({ - vertices: vertices, - faces: faces, - axes: axes - }); - this.convexPolyhedronRepresentation = h; - h.material = this.material; - } - /** - * @method calculateLocalInertia - * @param {Number} mass - * @param {Vec3} target - * @return {Vec3} - */ - ; - - _proto.calculateLocalInertia = function calculateLocalInertia(mass, target) { - if (target === void 0) { - target = new Vec3(); - } - - Box.calculateInertia(this.halfExtents, mass, target); - return target; - } - /** - * Get the box 6 side normals - * @method getSideNormals - * @param {array} sixTargetVectors An array of 6 vectors, to store the resulting side normals in. - * @param {Quaternion} quat Orientation to apply to the normal vectors. If not provided, the vectors will be in respect to the local frame. - * @return {array} - */ - ; - - _proto.getSideNormals = function getSideNormals(sixTargetVectors, quat) { - var sides = sixTargetVectors; - var ex = this.halfExtents; - sides[0].set(ex.x, 0, 0); - sides[1].set(0, ex.y, 0); - sides[2].set(0, 0, ex.z); - sides[3].set(-ex.x, 0, 0); - sides[4].set(0, -ex.y, 0); - sides[5].set(0, 0, -ex.z); - - if (quat !== undefined) { - for (var i = 0; i !== sides.length; i++) { - quat.vmult(sides[i], sides[i]); - } - } - - return sides; - }; - - _proto.volume = function volume() { - return 8.0 * this.halfExtents.x * this.halfExtents.y * this.halfExtents.z; - }; - - _proto.updateBoundingSphereRadius = function updateBoundingSphereRadius() { - this.boundingSphereRadius = this.halfExtents.length(); - }; - - _proto.forEachWorldCorner = function forEachWorldCorner(pos, quat, callback) { - var e = this.halfExtents; - var corners = [[e.x, e.y, e.z], [-e.x, e.y, e.z], [-e.x, -e.y, e.z], [-e.x, -e.y, -e.z], [e.x, -e.y, -e.z], [e.x, e.y, -e.z], [-e.x, e.y, -e.z], [e.x, -e.y, e.z]]; - - for (var i = 0; i < corners.length; i++) { - worldCornerTempPos.set(corners[i][0], corners[i][1], corners[i][2]); - quat.vmult(worldCornerTempPos, worldCornerTempPos); - pos.vadd(worldCornerTempPos, worldCornerTempPos); - callback(worldCornerTempPos.x, worldCornerTempPos.y, worldCornerTempPos.z); - } - }; - - _proto.calculateWorldAABB = function calculateWorldAABB(pos, quat, min, max) { - var e = this.halfExtents; - worldCornersTemp[0].set(e.x, e.y, e.z); - worldCornersTemp[1].set(-e.x, e.y, e.z); - worldCornersTemp[2].set(-e.x, -e.y, e.z); - worldCornersTemp[3].set(-e.x, -e.y, -e.z); - worldCornersTemp[4].set(e.x, -e.y, -e.z); - worldCornersTemp[5].set(e.x, e.y, -e.z); - worldCornersTemp[6].set(-e.x, e.y, -e.z); - worldCornersTemp[7].set(e.x, -e.y, e.z); - var wc = worldCornersTemp[0]; - quat.vmult(wc, wc); - pos.vadd(wc, wc); - max.copy(wc); - min.copy(wc); - - for (var i = 1; i < 8; i++) { - var _wc = worldCornersTemp[i]; - quat.vmult(_wc, _wc); - pos.vadd(_wc, _wc); - var _x = _wc.x; - var _y = _wc.y; - var _z = _wc.z; - - if (_x > max.x) { - max.x = _x; - } - - if (_y > max.y) { - max.y = _y; - } - - if (_z > max.z) { - max.z = _z; - } - - if (_x < min.x) { - min.x = _x; - } - - if (_y < min.y) { - min.y = _y; - } - - if (_z < min.z) { - min.z = _z; - } - } // Get each axis max - // min.set(Infinity,Infinity,Infinity); - // max.set(-Infinity,-Infinity,-Infinity); - // this.forEachWorldCorner(pos,quat,function(x,y,z){ - // if(x > max.x){ - // max.x = x; - // } - // if(y > max.y){ - // max.y = y; - // } - // if(z > max.z){ - // max.z = z; - // } - // if(x < min.x){ - // min.x = x; - // } - // if(y < min.y){ - // min.y = y; - // } - // if(z < min.z){ - // min.z = z; - // } - // }); - - }; - - return Box; -}(Shape); - -Box.calculateInertia = function (halfExtents, mass, target) { - var e = halfExtents; - target.x = 1.0 / 12.0 * mass * (2 * e.y * 2 * e.y + 2 * e.z * 2 * e.z); - target.y = 1.0 / 12.0 * mass * (2 * e.x * 2 * e.x + 2 * e.z * 2 * e.z); - target.z = 1.0 / 12.0 * mass * (2 * e.y * 2 * e.y + 2 * e.x * 2 * e.x); -}; - -var worldCornerTempPos = new Vec3(); -var worldCornersTemp = [new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3()]; - -var BODY_TYPES = { - DYNAMIC: 1, - STATIC: 2, - KINEMATIC: 4 -}; -var BODY_SLEEP_STATES = { - AWAKE: 0, - SLEEPY: 1, - SLEEPING: 2 -}; - -/** - * Base class for all body types. - * @class Body - * @constructor - * @extends EventTarget - * @param {object} [options] - * @param {Vec3} [options.position] - * @param {Vec3} [options.velocity] - * @param {Vec3} [options.angularVelocity] - * @param {Quaternion} [options.quaternion] - * @param {number} [options.mass] - * @param {Material} [options.material] - * @param {number} [options.type] - * @param {number} [options.linearDamping=0.01] - * @param {number} [options.angularDamping=0.01] - * @param {boolean} [options.allowSleep=true] - * @param {number} [options.sleepSpeedLimit=0.1] - * @param {number} [options.sleepTimeLimit=1] - * @param {number} [options.collisionFilterGroup=1] - * @param {number} [options.collisionFilterMask=-1] - * @param {boolean} [options.fixedRotation=false] - * @param {Vec3} [options.linearFactor] - * @param {Vec3} [options.angularFactor] - * @param {Shape} [options.shape] - * @example - * const body = new Body({ - * mass: 1 - * }); - * const shape = new Sphere(1); - * body.addShape(shape); - * world.addBody(body); - */ -var Body = /*#__PURE__*/function (_EventTarget) { - _inheritsLoose(Body, _EventTarget); - - // Position of body in World.bodies. Updated by World and used in ArrayCollisionMatrix. - // Reference to the world the body is living in. - // Callback function that is used BEFORE stepping the system. Use it to apply forces, for example. Inside the function, "this" will refer to this Body object. Deprecated - use World events instead. - // Callback function that is used AFTER stepping the system. Inside the function, "this" will refer to this Body object. Deprecated - use World events instead. - // Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled - i.e. "collide" events will be raised, but forces will not be altered. - // World space position of the body. - // Interpolated position of the body. - // Initial position of the body. - // World space velocity of the body. - // Linear force on the body in world space. - // One of: Body.DYNAMIC, Body.STATIC and Body.KINEMATIC. - // If true, the body will automatically fall to sleep. - // Current sleep state. - // If the speed (the norm of the velocity) is smaller than this value, the body is considered sleepy. - // If the body has been sleepy for this sleepTimeLimit seconds, it is considered sleeping. - // World space rotational force on the body, around center of mass. - // World space orientation of the body. - // Interpolated orientation of the body. - // Angular velocity of the body, in world space. Think of the angular velocity as a vector, which the body rotates around. The length of this vector determines how fast (in radians per second) the body rotates. - // Position of each Shape in the body, given in local Body space. - // Orientation of each Shape, given in local Body space. - // Set to true if you don't want the body to rotate. Make sure to run .updateMassProperties() after changing this. - // Use this property to limit the motion along any world axis. (1,1,1) will allow motion along all axes while (0,0,0) allows none. - // Use this property to limit the rotational motion along any world axis. (1,1,1) will allow rotation along all axes while (0,0,0) allows none. - // World space bounding box of the body and its shapes. - // Indicates if the AABB needs to be updated before use. - // Total bounding radius of the Body including its shapes, relative to body.position. - function Body(options) { - var _this; - - if (options === void 0) { - options = {}; - } - - _this = _EventTarget.call(this) || this; - _this.id = Body.idCounter++; - _this.index = -1; - _this.world = null; - _this.preStep = null; - _this.postStep = null; - _this.vlambda = new Vec3(); - _this.collisionFilterGroup = typeof options.collisionFilterGroup === 'number' ? options.collisionFilterGroup : 1; - _this.collisionFilterMask = typeof options.collisionFilterMask === 'number' ? options.collisionFilterMask : -1; - _this.collisionResponse = typeof options.collisionResponse === 'boolean' ? options.collisionResponse : true; - _this.position = new Vec3(); - _this.previousPosition = new Vec3(); - _this.interpolatedPosition = new Vec3(); - _this.initPosition = new Vec3(); - - if (options.position) { - _this.position.copy(options.position); - - _this.previousPosition.copy(options.position); - - _this.interpolatedPosition.copy(options.position); - - _this.initPosition.copy(options.position); - } - - _this.velocity = new Vec3(); - - if (options.velocity) { - _this.velocity.copy(options.velocity); - } - - _this.initVelocity = new Vec3(); - _this.force = new Vec3(); - var mass = typeof options.mass === 'number' ? options.mass : 0; - _this.mass = mass; - _this.invMass = mass > 0 ? 1.0 / mass : 0; - _this.material = options.material || null; - _this.linearDamping = typeof options.linearDamping === 'number' ? options.linearDamping : 0.01; - _this.type = mass <= 0.0 ? Body.STATIC : Body.DYNAMIC; - - if (typeof options.type === typeof Body.STATIC) { - _this.type = options.type; - } - - _this.allowSleep = typeof options.allowSleep !== 'undefined' ? options.allowSleep : true; - _this.sleepState = 0; - _this.sleepSpeedLimit = typeof options.sleepSpeedLimit !== 'undefined' ? options.sleepSpeedLimit : 0.1; - _this.sleepTimeLimit = typeof options.sleepTimeLimit !== 'undefined' ? options.sleepTimeLimit : 1; - _this.timeLastSleepy = 0; - _this.wakeUpAfterNarrowphase = false; - _this.torque = new Vec3(); - _this.quaternion = new Quaternion(); - _this.initQuaternion = new Quaternion(); - _this.previousQuaternion = new Quaternion(); - _this.interpolatedQuaternion = new Quaternion(); - - if (options.quaternion) { - _this.quaternion.copy(options.quaternion); - - _this.initQuaternion.copy(options.quaternion); - - _this.previousQuaternion.copy(options.quaternion); - - _this.interpolatedQuaternion.copy(options.quaternion); - } - - _this.angularVelocity = new Vec3(); - - if (options.angularVelocity) { - _this.angularVelocity.copy(options.angularVelocity); - } - - _this.initAngularVelocity = new Vec3(); - _this.shapes = []; - _this.shapeOffsets = []; - _this.shapeOrientations = []; - _this.inertia = new Vec3(); - _this.invInertia = new Vec3(); - _this.invInertiaWorld = new Mat3(); - _this.invMassSolve = 0; - _this.invInertiaSolve = new Vec3(); - _this.invInertiaWorldSolve = new Mat3(); - _this.fixedRotation = typeof options.fixedRotation !== 'undefined' ? options.fixedRotation : false; - _this.angularDamping = typeof options.angularDamping !== 'undefined' ? options.angularDamping : 0.01; - _this.linearFactor = new Vec3(1, 1, 1); - - if (options.linearFactor) { - _this.linearFactor.copy(options.linearFactor); - } - - _this.angularFactor = new Vec3(1, 1, 1); - - if (options.angularFactor) { - _this.angularFactor.copy(options.angularFactor); - } - - _this.aabb = new AABB(); - _this.aabbNeedsUpdate = true; - _this.boundingRadius = 0; - _this.wlambda = new Vec3(); - - if (options.shape) { - _this.addShape(options.shape); - } - - _this.updateMassProperties(); - - return _this; - } - /** - * Wake the body up. - * @method wakeUp - */ - - - var _proto = Body.prototype; - - _proto.wakeUp = function wakeUp() { - var prevState = this.sleepState; - this.sleepState = 0; - this.wakeUpAfterNarrowphase = false; - - if (prevState === Body.SLEEPING) { - this.dispatchEvent(Body.wakeupEvent); - } - } - /** - * Force body sleep - * @method sleep - */ - ; - - _proto.sleep = function sleep() { - this.sleepState = Body.SLEEPING; - this.velocity.set(0, 0, 0); - this.angularVelocity.set(0, 0, 0); - this.wakeUpAfterNarrowphase = false; - } - /** - * Called every timestep to update internal sleep timer and change sleep state if needed. - * @method sleepTick - * @param {Number} time The world time in seconds - */ - ; - - _proto.sleepTick = function sleepTick(time) { - if (this.allowSleep) { - var sleepState = this.sleepState; - var speedSquared = this.velocity.lengthSquared() + this.angularVelocity.lengthSquared(); - var speedLimitSquared = Math.pow(this.sleepSpeedLimit, 2); - - if (sleepState === Body.AWAKE && speedSquared < speedLimitSquared) { - this.sleepState = Body.SLEEPY; // Sleepy - - this.timeLastSleepy = time; - this.dispatchEvent(Body.sleepyEvent); - } else if (sleepState === Body.SLEEPY && speedSquared > speedLimitSquared) { - this.wakeUp(); // Wake up - } else if (sleepState === Body.SLEEPY && time - this.timeLastSleepy > this.sleepTimeLimit) { - this.sleep(); // Sleeping - - this.dispatchEvent(Body.sleepEvent); - } - } - } - /** - * If the body is sleeping, it should be immovable / have infinite mass during solve. We solve it by having a separate "solve mass". - * @method updateSolveMassProperties - */ - ; - - _proto.updateSolveMassProperties = function updateSolveMassProperties() { - if (this.sleepState === Body.SLEEPING || this.type === Body.KINEMATIC) { - this.invMassSolve = 0; - this.invInertiaSolve.setZero(); - this.invInertiaWorldSolve.setZero(); - } else { - this.invMassSolve = this.invMass; - this.invInertiaSolve.copy(this.invInertia); - this.invInertiaWorldSolve.copy(this.invInertiaWorld); - } - } - /** - * Convert a world point to local body frame. - * @method pointToLocalFrame - * @param {Vec3} worldPoint - * @param {Vec3} result - * @return {Vec3} - */ - ; - - _proto.pointToLocalFrame = function pointToLocalFrame(worldPoint, result) { - if (result === void 0) { - result = new Vec3(); - } - - worldPoint.vsub(this.position, result); - this.quaternion.conjugate().vmult(result, result); - return result; - } - /** - * Convert a world vector to local body frame. - * @method vectorToLocalFrame - * @param {Vec3} worldPoint - * @param {Vec3} result - * @return {Vec3} - */ - ; - - _proto.vectorToLocalFrame = function vectorToLocalFrame(worldVector, result) { - if (result === void 0) { - result = new Vec3(); - } - - this.quaternion.conjugate().vmult(worldVector, result); - return result; - } - /** - * Convert a local body point to world frame. - * @method pointToWorldFrame - * @param {Vec3} localPoint - * @param {Vec3} result - * @return {Vec3} - */ - ; - - _proto.pointToWorldFrame = function pointToWorldFrame(localPoint, result) { - if (result === void 0) { - result = new Vec3(); - } - - this.quaternion.vmult(localPoint, result); - result.vadd(this.position, result); - return result; - } - /** - * Convert a local body point to world frame. - * @method vectorToWorldFrame - * @param {Vec3} localVector - * @param {Vec3} result - * @return {Vec3} - */ - ; - - _proto.vectorToWorldFrame = function vectorToWorldFrame(localVector, result) { - if (result === void 0) { - result = new Vec3(); - } - - this.quaternion.vmult(localVector, result); - return result; - } - /** - * Add a shape to the body with a local offset and orientation. - * @method addShape - * @param {Shape} shape - * @param {Vec3} [_offset] - * @param {Quaternion} [_orientation] - * @return {Body} The body object, for chainability. - */ - ; - - _proto.addShape = function addShape(shape, _offset, _orientation) { - var offset = new Vec3(); - var orientation = new Quaternion(); - - if (_offset) { - offset.copy(_offset); - } - - if (_orientation) { - orientation.copy(_orientation); - } - - this.shapes.push(shape); - this.shapeOffsets.push(offset); - this.shapeOrientations.push(orientation); - this.updateMassProperties(); - this.updateBoundingRadius(); - this.aabbNeedsUpdate = true; - shape.body = this; - return this; - } - /** - * Update the bounding radius of the body. Should be done if any of the shapes are changed. - * @method updateBoundingRadius - */ - ; - - _proto.updateBoundingRadius = function updateBoundingRadius() { - var shapes = this.shapes; - var shapeOffsets = this.shapeOffsets; - var N = shapes.length; - var radius = 0; - - for (var i = 0; i !== N; i++) { - var shape = shapes[i]; - shape.updateBoundingSphereRadius(); - var offset = shapeOffsets[i].length(); - var r = shape.boundingSphereRadius; - - if (offset + r > radius) { - radius = offset + r; - } - } - - this.boundingRadius = radius; - } - /** - * Updates the .aabb - * @method computeAABB - * @todo rename to updateAABB() - */ - ; - - _proto.computeAABB = function computeAABB() { - var shapes = this.shapes; - var shapeOffsets = this.shapeOffsets; - var shapeOrientations = this.shapeOrientations; - var N = shapes.length; - var offset = tmpVec; - var orientation = tmpQuat$1; - var bodyQuat = this.quaternion; - var aabb = this.aabb; - var shapeAABB = computeAABB_shapeAABB; - - for (var i = 0; i !== N; i++) { - var shape = shapes[i]; // Get shape world position - - bodyQuat.vmult(shapeOffsets[i], offset); - offset.vadd(this.position, offset); // Get shape world quaternion - - bodyQuat.mult(shapeOrientations[i], orientation); // Get shape AABB - - shape.calculateWorldAABB(offset, orientation, shapeAABB.lowerBound, shapeAABB.upperBound); - - if (i === 0) { - aabb.copy(shapeAABB); - } else { - aabb.extend(shapeAABB); - } - } - - this.aabbNeedsUpdate = false; - } - /** - * Update .inertiaWorld and .invInertiaWorld - * @method updateInertiaWorld - */ - ; - - _proto.updateInertiaWorld = function updateInertiaWorld(force) { - var I = this.invInertia; - - if (I.x === I.y && I.y === I.z && !force) ; else { - var m1 = uiw_m1; - var m2 = uiw_m2; - m1.setRotationFromQuaternion(this.quaternion); - m1.transpose(m2); - m1.scale(I, m1); - m1.mmult(m2, this.invInertiaWorld); - } - }; - - _proto.applyForce = function applyForce(force, relativePoint) { - if (this.type !== Body.DYNAMIC) { - // Needed? - return; - } // Compute produced rotational force - - - var rotForce = Body_applyForce_rotForce; - relativePoint.cross(force, rotForce); // Add linear force - - this.force.vadd(force, this.force); // Add rotational force - - this.torque.vadd(rotForce, this.torque); - }; - - _proto.applyLocalForce = function applyLocalForce(localForce, localPoint) { - if (this.type !== Body.DYNAMIC) { - return; - } - - var worldForce = Body_applyLocalForce_worldForce; - var relativePointWorld = Body_applyLocalForce_relativePointWorld; // Transform the force vector to world space - - this.vectorToWorldFrame(localForce, worldForce); - this.vectorToWorldFrame(localPoint, relativePointWorld); - this.applyForce(worldForce, relativePointWorld); - }; - - _proto.applyImpulse = function applyImpulse(impulse, relativePoint) { - if (this.type !== Body.DYNAMIC) { - return; - } // Compute point position relative to the body center - - - var r = relativePoint; // Compute produced central impulse velocity - - var velo = Body_applyImpulse_velo; - velo.copy(impulse); - velo.scale(this.invMass, velo); // Add linear impulse - - this.velocity.vadd(velo, this.velocity); // Compute produced rotational impulse velocity - - var rotVelo = Body_applyImpulse_rotVelo; - r.cross(impulse, rotVelo); - /* - rotVelo.x *= this.invInertia.x; - rotVelo.y *= this.invInertia.y; - rotVelo.z *= this.invInertia.z; - */ - - this.invInertiaWorld.vmult(rotVelo, rotVelo); // Add rotational Impulse - - this.angularVelocity.vadd(rotVelo, this.angularVelocity); - }; - - _proto.applyLocalImpulse = function applyLocalImpulse(localImpulse, localPoint) { - if (this.type !== Body.DYNAMIC) { - return; - } - - var worldImpulse = Body_applyLocalImpulse_worldImpulse; - var relativePointWorld = Body_applyLocalImpulse_relativePoint; // Transform the force vector to world space - - this.vectorToWorldFrame(localImpulse, worldImpulse); - this.vectorToWorldFrame(localPoint, relativePointWorld); - this.applyImpulse(worldImpulse, relativePointWorld); - } - /** - * Should be called whenever you change the body shape or mass. - * @method updateMassProperties - */ - ; - - _proto.updateMassProperties = function updateMassProperties() { - var halfExtents = Body_updateMassProperties_halfExtents; - this.invMass = this.mass > 0 ? 1.0 / this.mass : 0; - var I = this.inertia; - var fixed = this.fixedRotation; // Approximate with AABB box - - this.computeAABB(); - halfExtents.set((this.aabb.upperBound.x - this.aabb.lowerBound.x) / 2, (this.aabb.upperBound.y - this.aabb.lowerBound.y) / 2, (this.aabb.upperBound.z - this.aabb.lowerBound.z) / 2); - Box.calculateInertia(halfExtents, this.mass, I); - this.invInertia.set(I.x > 0 && !fixed ? 1.0 / I.x : 0, I.y > 0 && !fixed ? 1.0 / I.y : 0, I.z > 0 && !fixed ? 1.0 / I.z : 0); - this.updateInertiaWorld(true); - } - /** - * Get world velocity of a point in the body. - * @method getVelocityAtWorldPoint - * @param {Vec3} worldPoint - * @param {Vec3} result - * @return {Vec3} The result vector. - */ - ; - - _proto.getVelocityAtWorldPoint = function getVelocityAtWorldPoint(worldPoint, result) { - var r = new Vec3(); - worldPoint.vsub(this.position, r); - this.angularVelocity.cross(r, result); - this.velocity.vadd(result, result); - return result; - } - /** - * Move the body forward in time. - * @param {number} dt Time step - * @param {boolean} quatNormalize Set to true to normalize the body quaternion - * @param {boolean} quatNormalizeFast If the quaternion should be normalized using "fast" quaternion normalization - */ - ; - - _proto.integrate = function integrate(dt, quatNormalize, quatNormalizeFast) { - // Save previous position - this.previousPosition.copy(this.position); - this.previousQuaternion.copy(this.quaternion); - - if (!(this.type === Body.DYNAMIC || this.type === Body.KINEMATIC) || this.sleepState === Body.SLEEPING) { - // Only for dynamic - return; - } - - var velo = this.velocity; - var angularVelo = this.angularVelocity; - var pos = this.position; - var force = this.force; - var torque = this.torque; - var quat = this.quaternion; - var invMass = this.invMass; - var invInertia = this.invInertiaWorld; - var linearFactor = this.linearFactor; - var iMdt = invMass * dt; - velo.x += force.x * iMdt * linearFactor.x; - velo.y += force.y * iMdt * linearFactor.y; - velo.z += force.z * iMdt * linearFactor.z; - var e = invInertia.elements; - var angularFactor = this.angularFactor; - var tx = torque.x * angularFactor.x; - var ty = torque.y * angularFactor.y; - var tz = torque.z * angularFactor.z; - angularVelo.x += dt * (e[0] * tx + e[1] * ty + e[2] * tz); - angularVelo.y += dt * (e[3] * tx + e[4] * ty + e[5] * tz); - angularVelo.z += dt * (e[6] * tx + e[7] * ty + e[8] * tz); // Use new velocity - leap frog - - pos.x += velo.x * dt; - pos.y += velo.y * dt; - pos.z += velo.z * dt; - quat.integrate(this.angularVelocity, dt, this.angularFactor, quat); - - if (quatNormalize) { - if (quatNormalizeFast) { - quat.normalizeFast(); - } else { - quat.normalize(); - } - } - - this.aabbNeedsUpdate = true; // Update world inertia - - this.updateInertiaWorld(); - }; - - return Body; -}(EventTarget); -/** - * Dispatched after two bodies collide. This event is dispatched on each - * of the two bodies involved in the collision. - * @event collide - * @param {Body} body The body that was involved in the collision. - * @param {ContactEquation} contact The details of the collision. - */ - -Body.COLLIDE_EVENT_NAME = 'collide'; -/** - * A dynamic body is fully simulated. Can be moved manually by the user, but normally they move according to forces. A dynamic body can collide with all body types. A dynamic body always has finite, non-zero mass. - * @static - * @property DYNAMIC - * @type {Number} - */ - -Body.DYNAMIC = 1; -/** - * A static body does not move during simulation and behaves as if it has infinite mass. Static bodies can be moved manually by setting the position of the body. The velocity of a static body is always zero. Static bodies do not collide with other static or kinematic bodies. - * @static - * @property STATIC - * @type {Number} - */ - -Body.STATIC = 2; -/** - * A kinematic body moves under simulation according to its velocity. They do not respond to forces. They can be moved manually, but normally a kinematic body is moved by setting its velocity. A kinematic body behaves as if it has infinite mass. Kinematic bodies do not collide with other static or kinematic bodies. - * @static - * @property KINEMATIC - * @type {Number} - */ - -Body.KINEMATIC = 4; -/** - * @static - * @property AWAKE - * @type {number} - */ - -Body.AWAKE = BODY_SLEEP_STATES.AWAKE; -Body.SLEEPY = BODY_SLEEP_STATES.SLEEPY; -Body.SLEEPING = BODY_SLEEP_STATES.SLEEPING; -Body.idCounter = 0; -/** - * Dispatched after a sleeping body has woken up. - * @event wakeup - */ - -Body.wakeupEvent = { - type: 'wakeup' -}; -/** - * Dispatched after a body has gone in to the sleepy state. - * @event sleepy - */ - -Body.sleepyEvent = { - type: 'sleepy' -}; -/** - * Dispatched after a body has fallen asleep. - * @event sleep - */ - -Body.sleepEvent = { - type: 'sleep' -}; -var tmpVec = new Vec3(); -var tmpQuat$1 = new Quaternion(); -var computeAABB_shapeAABB = new AABB(); -var uiw_m1 = new Mat3(); -var uiw_m2 = new Mat3(); -var uiw_m3 = new Mat3(); -/** - * Apply force to a world point. This could for example be a point on the Body surface. Applying force this way will add to Body.force and Body.torque. - * @method applyForce - * @param {Vec3} force The amount of force to add. - * @param {Vec3} relativePoint A point relative to the center of mass to apply the force on. - */ - -var Body_applyForce_rotForce = new Vec3(); -/** - * Apply force to a local point in the body. - * @method applyLocalForce - * @param {Vec3} force The force vector to apply, defined locally in the body frame. - * @param {Vec3} localPoint A local point in the body to apply the force on. - */ - -var Body_applyLocalForce_worldForce = new Vec3(); -var Body_applyLocalForce_relativePointWorld = new Vec3(); -/** - * Apply impulse to a world point. This could for example be a point on the Body surface. An impulse is a force added to a body during a short period of time (impulse = force * time). Impulses will be added to Body.velocity and Body.angularVelocity. - * @method applyImpulse - * @param {Vec3} impulse The amount of impulse to add. - * @param {Vec3} relativePoint A point relative to the center of mass to apply the force on. - */ - -var Body_applyImpulse_velo = new Vec3(); -var Body_applyImpulse_rotVelo = new Vec3(); -/** - * Apply locally-defined impulse to a local point in the body. - * @method applyLocalImpulse - * @param {Vec3} force The force vector to apply, defined locally in the body frame. - * @param {Vec3} localPoint A local point in the body to apply the force on. - */ - -var Body_applyLocalImpulse_worldImpulse = new Vec3(); -var Body_applyLocalImpulse_relativePoint = new Vec3(); -var Body_updateMassProperties_halfExtents = new Vec3(); - -/** - * Base class for broadphase implementations - * @class Broadphase - * @constructor - * @author schteppe - */ -var Broadphase = /*#__PURE__*/function () { - // The world to search for collisions in. - // If set to true, the broadphase uses bounding boxes for intersection test, else it uses bounding spheres. - // Set to true if the objects in the world moved. - function Broadphase() { - this.world = null; - this.useBoundingBoxes = false; - this.dirty = true; - } - /** - * Get the collision pairs from the world - * @method collisionPairs - * @param {World} world The world to search in - * @param {Array} p1 Empty array to be filled with body objects - * @param {Array} p2 Empty array to be filled with body objects - */ - - - var _proto = Broadphase.prototype; - - _proto.collisionPairs = function collisionPairs(world, p1, p2) { - throw new Error('collisionPairs not implemented for this BroadPhase class!'); - } - /** - * Check if a body pair needs to be intersection tested at all. - * @method needBroadphaseCollision - * @param {Body} bodyA - * @param {Body} bodyB - * @return {bool} - */ - ; - - _proto.needBroadphaseCollision = function needBroadphaseCollision(bodyA, bodyB) { - // Check collision filter masks - if ((bodyA.collisionFilterGroup & bodyB.collisionFilterMask) === 0 || (bodyB.collisionFilterGroup & bodyA.collisionFilterMask) === 0) { - return false; - } // Check types - - - if (((bodyA.type & Body.STATIC) !== 0 || bodyA.sleepState === Body.SLEEPING) && ((bodyB.type & Body.STATIC) !== 0 || bodyB.sleepState === Body.SLEEPING)) { - // Both bodies are static or sleeping. Skip. - return false; - } - - return true; - } - /** - * Check if the bounding volumes of two bodies intersect. - * @method intersectionTest - * @param {Body} bodyA - * @param {Body} bodyB - * @param {array} pairs1 - * @param {array} pairs2 - */ - ; - - _proto.intersectionTest = function intersectionTest(bodyA, bodyB, pairs1, pairs2) { - if (this.useBoundingBoxes) { - this.doBoundingBoxBroadphase(bodyA, bodyB, pairs1, pairs2); - } else { - this.doBoundingSphereBroadphase(bodyA, bodyB, pairs1, pairs2); - } - }; - - _proto.doBoundingSphereBroadphase = function doBoundingSphereBroadphase(bodyA, bodyB, pairs1, pairs2) { - var r = Broadphase_collisionPairs_r; - bodyB.position.vsub(bodyA.position, r); - var boundingRadiusSum2 = Math.pow(bodyA.boundingRadius + bodyB.boundingRadius, 2); - var norm2 = r.lengthSquared(); - - if (norm2 < boundingRadiusSum2) { - pairs1.push(bodyA); - pairs2.push(bodyB); - } - } - /** - * Check if the bounding boxes of two bodies are intersecting. - * @method doBoundingBoxBroadphase - * @param {Body} bodyA - * @param {Body} bodyB - * @param {Array} pairs1 - * @param {Array} pairs2 - */ - ; - - _proto.doBoundingBoxBroadphase = function doBoundingBoxBroadphase(bodyA, bodyB, pairs1, pairs2) { - if (bodyA.aabbNeedsUpdate) { - bodyA.computeAABB(); - } - - if (bodyB.aabbNeedsUpdate) { - bodyB.computeAABB(); - } // Check AABB / AABB - - - if (bodyA.aabb.overlaps(bodyB.aabb)) { - pairs1.push(bodyA); - pairs2.push(bodyB); - } - }; - - _proto.makePairsUnique = function makePairsUnique(pairs1, pairs2) { - var t = Broadphase_makePairsUnique_temp; - var p1 = Broadphase_makePairsUnique_p1; - var p2 = Broadphase_makePairsUnique_p2; - var N = pairs1.length; - - for (var i = 0; i !== N; i++) { - p1[i] = pairs1[i]; - p2[i] = pairs2[i]; - } - - pairs1.length = 0; - pairs2.length = 0; - - for (var _i = 0; _i !== N; _i++) { - var id1 = p1[_i].id; - var id2 = p2[_i].id; - var key = id1 < id2 ? id1 + "," + id2 : id2 + "," + id1; - t[key] = _i; - t.keys.push(key); - } - - for (var _i2 = 0; _i2 !== t.keys.length; _i2++) { - var _key = t.keys.pop(); - - var pairIndex = t[_key]; - pairs1.push(p1[pairIndex]); - pairs2.push(p2[pairIndex]); - delete t[_key]; - } - } - /** - * To be implemented by subcasses - * @method setWorld - * @param {World} world - */ - ; - - _proto.setWorld = function setWorld(world) {} - /** - * Returns all the bodies within the AABB. - * @method aabbQuery - * @param {World} world - * @param {AABB} aabb - * @param {array} result An array to store resulting bodies in. - * @return {array} - */ - ; - - _proto.aabbQuery = function aabbQuery(world, aabb, result) { - console.warn('.aabbQuery is not implemented in this Broadphase subclass.'); - return []; - }; - - return Broadphase; -}(); -/** - * Check if the bounding spheres of two bodies are intersecting. - * @method doBoundingSphereBroadphase - * @param {Body} bodyA - * @param {Body} bodyB - * @param {Array} pairs1 bodyA is appended to this array if intersection - * @param {Array} pairs2 bodyB is appended to this array if intersection - */ - -var // Temp objects -Broadphase_collisionPairs_r = new Vec3(); -var Broadphase_collisionPairs_normal = new Vec3(); -var Broadphase_collisionPairs_quat = new Quaternion(); -var Broadphase_collisionPairs_relpos = new Vec3(); -/** - * Removes duplicate pairs from the pair arrays. - * @method makePairsUnique - * @param {Array} pairs1 - * @param {Array} pairs2 - */ - -var Broadphase_makePairsUnique_temp = { - keys: [] -}; -var Broadphase_makePairsUnique_p1 = []; -var Broadphase_makePairsUnique_p2 = []; -/** - * Check if the bounding spheres of two bodies overlap. - * @method boundingSphereCheck - * @param {Body} bodyA - * @param {Body} bodyB - * @return {boolean} - */ - -var bsc_dist = new Vec3(); - -Broadphase.boundingSphereCheck = function (bodyA, bodyB) { - var dist = new Vec3(); // bsc_dist; - - bodyA.position.vsub(bodyB.position, dist); - var sa = bodyA.shapes[0]; - var sb = bodyB.shapes[0]; - return Math.pow(sa.boundingSphereRadius + sb.boundingSphereRadius, 2) > dist.lengthSquared(); -}; - -/** - * Axis aligned uniform grid broadphase. - * @class GridBroadphase - * @constructor - * @extends Broadphase - * @todo Needs support for more than just planes and spheres. - * @param {Vec3} aabbMin - * @param {Vec3} aabbMax - * @param {Number} nx Number of boxes along x - * @param {Number} ny Number of boxes along y - * @param {Number} nz Number of boxes along z - */ -var GridBroadphase = /*#__PURE__*/function (_Broadphase) { - _inheritsLoose(GridBroadphase, _Broadphase); - - function GridBroadphase(aabbMin, aabbMax, nx, ny, nz) { - var _this; - - if (aabbMin === void 0) { - aabbMin = new Vec3(100, 100, 100); - } - - if (aabbMax === void 0) { - aabbMax = new Vec3(-100, -100, -100); - } - - if (nx === void 0) { - nx = 10; - } - - if (ny === void 0) { - ny = 10; - } - - if (nz === void 0) { - nz = 10; - } - - _this = _Broadphase.call(this) || this; - _this.nx = nx; - _this.ny = ny; - _this.nz = nz; - _this.aabbMin = aabbMin; - _this.aabbMax = aabbMax; - var nbins = _this.nx * _this.ny * _this.nz; - - if (nbins <= 0) { - throw "GridBroadphase: Each dimension's n must be >0"; - } - - _this.bins = []; - _this.binLengths = []; //Rather than continually resizing arrays (thrashing the memory), just record length and allow them to grow - - _this.bins.length = nbins; - _this.binLengths.length = nbins; - - for (var i = 0; i < nbins; i++) { - _this.bins[i] = []; - _this.binLengths[i] = 0; - } - - return _this; - } - - var _proto = GridBroadphase.prototype; - - _proto.collisionPairs = function collisionPairs(world, pairs1, pairs2) { - var N = world.numObjects(); - var bodies = world.bodies; - var max = this.aabbMax; - var min = this.aabbMin; - var nx = this.nx; - var ny = this.ny; - var nz = this.nz; - var xstep = ny * nz; - var ystep = nz; - var zstep = 1; - var xmax = max.x; - var ymax = max.y; - var zmax = max.z; - var xmin = min.x; - var ymin = min.y; - var zmin = min.z; - var xmult = nx / (xmax - xmin); - var ymult = ny / (ymax - ymin); - var zmult = nz / (zmax - zmin); - var binsizeX = (xmax - xmin) / nx; - var binsizeY = (ymax - ymin) / ny; - var binsizeZ = (zmax - zmin) / nz; - var binRadius = Math.sqrt(binsizeX * binsizeX + binsizeY * binsizeY + binsizeZ * binsizeZ) * 0.5; - var types = Shape.types; - var SPHERE = types.SPHERE; - var PLANE = types.PLANE; - var BOX = types.BOX; - var COMPOUND = types.COMPOUND; - var CONVEXPOLYHEDRON = types.CONVEXPOLYHEDRON; - var bins = this.bins; - var binLengths = this.binLengths; - var Nbins = this.bins.length; // Reset bins - - for (var i = 0; i !== Nbins; i++) { - binLengths[i] = 0; - } - - var ceil = Math.ceil; - - function addBoxToBins(x0, y0, z0, x1, y1, z1, bi) { - var xoff0 = (x0 - xmin) * xmult | 0; - var yoff0 = (y0 - ymin) * ymult | 0; - var zoff0 = (z0 - zmin) * zmult | 0; - var xoff1 = ceil((x1 - xmin) * xmult); - var yoff1 = ceil((y1 - ymin) * ymult); - var zoff1 = ceil((z1 - zmin) * zmult); - - if (xoff0 < 0) { - xoff0 = 0; - } else if (xoff0 >= nx) { - xoff0 = nx - 1; - } - - if (yoff0 < 0) { - yoff0 = 0; - } else if (yoff0 >= ny) { - yoff0 = ny - 1; - } - - if (zoff0 < 0) { - zoff0 = 0; - } else if (zoff0 >= nz) { - zoff0 = nz - 1; - } - - if (xoff1 < 0) { - xoff1 = 0; - } else if (xoff1 >= nx) { - xoff1 = nx - 1; - } - - if (yoff1 < 0) { - yoff1 = 0; - } else if (yoff1 >= ny) { - yoff1 = ny - 1; - } - - if (zoff1 < 0) { - zoff1 = 0; - } else if (zoff1 >= nz) { - zoff1 = nz - 1; - } - - xoff0 *= xstep; - yoff0 *= ystep; - zoff0 *= zstep; - xoff1 *= xstep; - yoff1 *= ystep; - zoff1 *= zstep; - - for (var xoff = xoff0; xoff <= xoff1; xoff += xstep) { - for (var yoff = yoff0; yoff <= yoff1; yoff += ystep) { - for (var zoff = zoff0; zoff <= zoff1; zoff += zstep) { - var idx = xoff + yoff + zoff; - bins[idx][binLengths[idx]++] = bi; - } - } - } - } // Put all bodies into the bins - - - for (var _i = 0; _i !== N; _i++) { - var bi = bodies[_i]; - var si = bi.shapes[0]; - - switch (si.type) { - case SPHERE: - { - var shape = si; // Put in bin - // check if overlap with other bins - - var x = bi.position.x; - var y = bi.position.y; - var z = bi.position.z; - var r = shape.radius; - addBoxToBins(x - r, y - r, z - r, x + r, y + r, z + r, bi); - break; - } - - case PLANE: - { - var _shape = si; - - if (_shape.worldNormalNeedsUpdate) { - _shape.computeWorldNormal(bi.quaternion); - } - - var planeNormal = _shape.worldNormal; //Relative position from origin of plane object to the first bin - //Incremented as we iterate through the bins - - var xreset = xmin + binsizeX * 0.5 - bi.position.x; - var yreset = ymin + binsizeY * 0.5 - bi.position.y; - var zreset = zmin + binsizeZ * 0.5 - bi.position.z; - var d = GridBroadphase_collisionPairs_d; - d.set(xreset, yreset, zreset); - - for (var xi = 0, xoff = 0; xi !== nx; xi++, xoff += xstep, d.y = yreset, d.x += binsizeX) { - for (var yi = 0, yoff = 0; yi !== ny; yi++, yoff += ystep, d.z = zreset, d.y += binsizeY) { - for (var zi = 0, zoff = 0; zi !== nz; zi++, zoff += zstep, d.z += binsizeZ) { - if (d.dot(planeNormal) < binRadius) { - var idx = xoff + yoff + zoff; - bins[idx][binLengths[idx]++] = bi; - } - } - } - } - - break; - } - - default: - { - if (bi.aabbNeedsUpdate) { - bi.computeAABB(); - } - - addBoxToBins(bi.aabb.lowerBound.x, bi.aabb.lowerBound.y, bi.aabb.lowerBound.z, bi.aabb.upperBound.x, bi.aabb.upperBound.y, bi.aabb.upperBound.z, bi); - break; - } - } - } // Check each bin - - - for (var _i2 = 0; _i2 !== Nbins; _i2++) { - var binLength = binLengths[_i2]; //Skip bins with no potential collisions - - if (binLength > 1) { - var bin = bins[_i2]; // Do N^2 broadphase inside - - for (var _xi = 0; _xi !== binLength; _xi++) { - var _bi = bin[_xi]; - - for (var _yi = 0; _yi !== _xi; _yi++) { - var bj = bin[_yi]; - - if (this.needBroadphaseCollision(_bi, bj)) { - this.intersectionTest(_bi, bj, pairs1, pairs2); - } - } - } - } - } // for (let zi = 0, zoff=0; zi < nz; zi++, zoff+= zstep) { - // console.log("layer "+zi); - // for (let yi = 0, yoff=0; yi < ny; yi++, yoff += ystep) { - // const row = ''; - // for (let xi = 0, xoff=0; xi < nx; xi++, xoff += xstep) { - // const idx = xoff + yoff + zoff; - // row += ' ' + binLengths[idx]; - // } - // console.log(row); - // } - // } - - - this.makePairsUnique(pairs1, pairs2); - }; - - return GridBroadphase; -}(Broadphase); -/** - * Get all the collision pairs in the physics world - * @method collisionPairs - * @param {World} world - * @param {Array} pairs1 - * @param {Array} pairs2 - */ - -var GridBroadphase_collisionPairs_d = new Vec3(); -var GridBroadphase_collisionPairs_binPos = new Vec3(); - -/** - * Naive broadphase implementation, used in lack of better ones. - * @class NaiveBroadphase - * @constructor - * @description The naive broadphase looks at all possible pairs without restriction, therefore it has complexity N^2 (which is bad) - * @extends Broadphase - */ -var NaiveBroadphase = /*#__PURE__*/function (_Broadphase) { - _inheritsLoose(NaiveBroadphase, _Broadphase); - - function NaiveBroadphase() { - return _Broadphase.call(this) || this; - } - /** - * Get all the collision pairs in the physics world - * @method collisionPairs - * @param {World} world - * @param {Array} pairs1 - * @param {Array} pairs2 - */ - - - var _proto = NaiveBroadphase.prototype; - - _proto.collisionPairs = function collisionPairs(world, pairs1, pairs2) { - var bodies = world.bodies; - var n = bodies.length; - var bi; - var bj; // Naive N^2 ftw! - - for (var i = 0; i !== n; i++) { - for (var j = 0; j !== i; j++) { - bi = bodies[i]; - bj = bodies[j]; - - if (!this.needBroadphaseCollision(bi, bj)) { - continue; - } - - this.intersectionTest(bi, bj, pairs1, pairs2); - } - } - } - /** - * Returns all the bodies within an AABB. - * @method aabbQuery - * @param {World} world - * @param {AABB} aabb - * @param {array} result An array to store resulting bodies in. - * @return {array} - */ - ; - - _proto.aabbQuery = function aabbQuery(world, aabb, result) { - if (result === void 0) { - result = []; - } - - for (var i = 0; i < world.bodies.length; i++) { - var b = world.bodies[i]; - - if (b.aabbNeedsUpdate) { - b.computeAABB(); - } // Ugly hack until Body gets aabb - - - if (b.aabb.overlaps(aabb)) { - result.push(b); - } - } - - return result; - }; - - return NaiveBroadphase; -}(Broadphase); - -/** - * Storage for Ray casting data. - * @class RaycastResult - * @constructor - */ -var RaycastResult = /*#__PURE__*/function () { - // The index of the hit triangle, if the hit shape was a trimesh. - // Distance to the hit. Will be set to -1 if there was no hit. - // If the ray should stop traversing the bodies. - function RaycastResult() { - this.rayFromWorld = new Vec3(); - this.rayToWorld = new Vec3(); - this.hitNormalWorld = new Vec3(); - this.hitPointWorld = new Vec3(); - this.hasHit = false; - this.shape = null; - this.body = null; - this.hitFaceIndex = -1; - this.distance = -1; - this.shouldStop = false; - } - /** - * Reset all result data. - * @method reset - */ - - - var _proto = RaycastResult.prototype; - - _proto.reset = function reset() { - this.rayFromWorld.setZero(); - this.rayToWorld.setZero(); - this.hitNormalWorld.setZero(); - this.hitPointWorld.setZero(); - this.hasHit = false; - this.shape = null; - this.body = null; - this.hitFaceIndex = -1; - this.distance = -1; - this.shouldStop = false; - } - /** - * @method abort - */ - ; - - _proto.abort = function abort() { - this.shouldStop = true; - } - /** - * @method set - * @param {Vec3} rayFromWorld - * @param {Vec3} rayToWorld - * @param {Vec3} hitNormalWorld - * @param {Vec3} hitPointWorld - * @param {Shape} shape - * @param {Body} body - * @param {number} distance - */ - ; - - _proto.set = function set(rayFromWorld, rayToWorld, hitNormalWorld, hitPointWorld, shape, body, distance) { - this.rayFromWorld.copy(rayFromWorld); - this.rayToWorld.copy(rayToWorld); - this.hitNormalWorld.copy(hitNormalWorld); - this.hitPointWorld.copy(hitPointWorld); - this.shape = shape; - this.body = body; - this.distance = distance; - }; - - return RaycastResult; -}(); - -var RAY_MODES = { - CLOSEST: 1, - ANY: 2, - ALL: 4 -}; - -/** - * A line in 3D space that intersects bodies and return points. - * @class Ray - * @constructor - * @param {Vec3} from - * @param {Vec3} to - */ -var Ray = /*#__PURE__*/function () { - // The precision of the ray. Used when checking parallelity etc. - // Set to true if you want the Ray to take .collisionResponse flags into account on bodies and shapes. - // If set to true, the ray skips any hits with normal.dot(rayDirection) < 0. - // The intersection mode. Should be Ray.ANY, Ray.ALL or Ray.CLOSEST. - // Current result object. - // Will be set to true during intersectWorld() if the ray hit anything. - // User-provided result callback. Will be used if mode is Ray.ALL. - function Ray(from, to) { - if (from === void 0) { - from = new Vec3(); - } - - if (to === void 0) { - to = new Vec3(); - } - - this.from = from.clone(); - this.to = to.clone(); - this.direction = new Vec3(); - this.precision = 0.0001; - this.checkCollisionResponse = true; - this.skipBackfaces = false; - this.collisionFilterMask = -1; - this.collisionFilterGroup = -1; - this.mode = Ray.ANY; - this.result = new RaycastResult(); - this.hasHit = false; - - this.callback = function (result) {}; - } - /** - * Do itersection against all bodies in the given World. - * @method intersectWorld - * @param {World} world - * @param {object} options - * @return {Boolean} True if the ray hit anything, otherwise false. - */ - - - var _proto = Ray.prototype; - - _proto.intersectWorld = function intersectWorld(world, options) { - this.mode = options.mode || Ray.ANY; - this.result = options.result || new RaycastResult(); - this.skipBackfaces = !!options.skipBackfaces; - this.collisionFilterMask = typeof options.collisionFilterMask !== 'undefined' ? options.collisionFilterMask : -1; - this.collisionFilterGroup = typeof options.collisionFilterGroup !== 'undefined' ? options.collisionFilterGroup : -1; - this.checkCollisionResponse = typeof options.checkCollisionResponse !== 'undefined' ? options.checkCollisionResponse : true; - - if (options.from) { - this.from.copy(options.from); - } - - if (options.to) { - this.to.copy(options.to); - } - - this.callback = options.callback || function () {}; - - this.hasHit = false; - this.result.reset(); - this.updateDirection(); - this.getAABB(tmpAABB); - tmpArray.length = 0; - world.broadphase.aabbQuery(world, tmpAABB, tmpArray); - this.intersectBodies(tmpArray); - return this.hasHit; - } - /** - * Shoot a ray at a body, get back information about the hit. - * @param {Body} body - * @param {RaycastResult} [result] Deprecated - set the result property of the Ray instead. - */ - ; - - _proto.intersectBody = function intersectBody(body, result) { - if (result) { - this.result = result; - this.updateDirection(); - } - - var checkCollisionResponse = this.checkCollisionResponse; - - if (checkCollisionResponse && !body.collisionResponse) { - return; - } - - if ((this.collisionFilterGroup & body.collisionFilterMask) === 0 || (body.collisionFilterGroup & this.collisionFilterMask) === 0) { - return; - } - - var xi = intersectBody_xi; - var qi = intersectBody_qi; - - for (var i = 0, N = body.shapes.length; i < N; i++) { - var shape = body.shapes[i]; - - if (checkCollisionResponse && !shape.collisionResponse) { - continue; // Skip - } - - body.quaternion.mult(body.shapeOrientations[i], qi); - body.quaternion.vmult(body.shapeOffsets[i], xi); - xi.vadd(body.position, xi); - this.intersectShape(shape, qi, xi, body); - - if (this.result.shouldStop) { - break; - } - } - } - /** - * @method intersectBodies - * @param {Array} bodies An array of Body objects. - * @param {RaycastResult} [result] Deprecated - */ - ; - - _proto.intersectBodies = function intersectBodies(bodies, result) { - if (result) { - this.result = result; - this.updateDirection(); - } - - for (var i = 0, l = bodies.length; !this.result.shouldStop && i < l; i++) { - this.intersectBody(bodies[i]); - } - } - /** - * Updates the direction vector. - */ - ; - - _proto.updateDirection = function updateDirection() { - this.to.vsub(this.from, this.direction); - this.direction.normalize(); - }; - - _proto.intersectShape = function intersectShape(shape, quat, position, body) { - var from = this.from; // Checking boundingSphere - - var distance = distanceFromIntersection(from, this.direction, position); - - if (distance > shape.boundingSphereRadius) { - return; - } - - var intersectMethod = this[shape.type]; - - if (intersectMethod) { - intersectMethod.call(this, shape, quat, position, body, shape); - } - }; - - _proto._intersectBox = function _intersectBox(box, quat, position, body, reportedShape) { - return this._intersectConvex(box.convexPolyhedronRepresentation, quat, position, body, reportedShape); - }; - - _proto._intersectPlane = function _intersectPlane(shape, quat, position, body, reportedShape) { - var from = this.from; - var to = this.to; - var direction = this.direction; // Get plane normal - - var worldNormal = new Vec3(0, 0, 1); - quat.vmult(worldNormal, worldNormal); - var len = new Vec3(); - from.vsub(position, len); - var planeToFrom = len.dot(worldNormal); - to.vsub(position, len); - var planeToTo = len.dot(worldNormal); - - if (planeToFrom * planeToTo > 0) { - // "from" and "to" are on the same side of the plane... bail out - return; - } - - if (from.distanceTo(to) < planeToFrom) { - return; - } - - var n_dot_dir = worldNormal.dot(direction); - - if (Math.abs(n_dot_dir) < this.precision) { - // No intersection - return; - } - - var planePointToFrom = new Vec3(); - var dir_scaled_with_t = new Vec3(); - var hitPointWorld = new Vec3(); - from.vsub(position, planePointToFrom); - var t = -worldNormal.dot(planePointToFrom) / n_dot_dir; - direction.scale(t, dir_scaled_with_t); - from.vadd(dir_scaled_with_t, hitPointWorld); - this.reportIntersection(worldNormal, hitPointWorld, reportedShape, body, -1); - } - /** - * Get the world AABB of the ray. - */ - ; - - _proto.getAABB = function getAABB(aabb) { - var lowerBound = aabb.lowerBound, - upperBound = aabb.upperBound; - var to = this.to; - var from = this.from; - lowerBound.x = Math.min(to.x, from.x); - lowerBound.y = Math.min(to.y, from.y); - lowerBound.z = Math.min(to.z, from.z); - upperBound.x = Math.max(to.x, from.x); - upperBound.y = Math.max(to.y, from.y); - upperBound.z = Math.max(to.z, from.z); - }; - - _proto._intersectHeightfield = function _intersectHeightfield(shape, quat, position, body, reportedShape) { - var data = shape.data; - var w = shape.elementSize; // Convert the ray to local heightfield coordinates - - var localRay = intersectHeightfield_localRay; //new Ray(this.from, this.to); - - localRay.from.copy(this.from); - localRay.to.copy(this.to); - Transform.pointToLocalFrame(position, quat, localRay.from, localRay.from); - Transform.pointToLocalFrame(position, quat, localRay.to, localRay.to); - localRay.updateDirection(); // Get the index of the data points to test against - - var index = intersectHeightfield_index; - var iMinX; - var iMinY; - var iMaxX; - var iMaxY; // Set to max - - iMinX = iMinY = 0; - iMaxX = iMaxY = shape.data.length - 1; - var aabb = new AABB(); - localRay.getAABB(aabb); - shape.getIndexOfPosition(aabb.lowerBound.x, aabb.lowerBound.y, index, true); - iMinX = Math.max(iMinX, index[0]); - iMinY = Math.max(iMinY, index[1]); - shape.getIndexOfPosition(aabb.upperBound.x, aabb.upperBound.y, index, true); - iMaxX = Math.min(iMaxX, index[0] + 1); - iMaxY = Math.min(iMaxY, index[1] + 1); - - for (var i = iMinX; i < iMaxX; i++) { - for (var j = iMinY; j < iMaxY; j++) { - if (this.result.shouldStop) { - return; - } - - shape.getAabbAtIndex(i, j, aabb); - - if (!aabb.overlapsRay(localRay)) { - continue; - } // Lower triangle - - - shape.getConvexTrianglePillar(i, j, false); - Transform.pointToWorldFrame(position, quat, shape.pillarOffset, worldPillarOffset); - - this._intersectConvex(shape.pillarConvex, quat, worldPillarOffset, body, reportedShape, intersectConvexOptions); - - if (this.result.shouldStop) { - return; - } // Upper triangle - - - shape.getConvexTrianglePillar(i, j, true); - Transform.pointToWorldFrame(position, quat, shape.pillarOffset, worldPillarOffset); - - this._intersectConvex(shape.pillarConvex, quat, worldPillarOffset, body, reportedShape, intersectConvexOptions); - } - } - }; - - _proto._intersectSphere = function _intersectSphere(sphere, quat, position, body, reportedShape) { - var from = this.from; - var to = this.to; - var r = sphere.radius; - var a = Math.pow(to.x - from.x, 2) + Math.pow(to.y - from.y, 2) + Math.pow(to.z - from.z, 2); - var b = 2 * ((to.x - from.x) * (from.x - position.x) + (to.y - from.y) * (from.y - position.y) + (to.z - from.z) * (from.z - position.z)); - var c = Math.pow(from.x - position.x, 2) + Math.pow(from.y - position.y, 2) + Math.pow(from.z - position.z, 2) - Math.pow(r, 2); - var delta = Math.pow(b, 2) - 4 * a * c; - var intersectionPoint = Ray_intersectSphere_intersectionPoint; - var normal = Ray_intersectSphere_normal; - - if (delta < 0) { - // No intersection - return; - } else if (delta === 0) { - // single intersection point - from.lerp(to, delta, intersectionPoint); - intersectionPoint.vsub(position, normal); - normal.normalize(); - this.reportIntersection(normal, intersectionPoint, reportedShape, body, -1); - } else { - var d1 = (-b - Math.sqrt(delta)) / (2 * a); - var d2 = (-b + Math.sqrt(delta)) / (2 * a); - - if (d1 >= 0 && d1 <= 1) { - from.lerp(to, d1, intersectionPoint); - intersectionPoint.vsub(position, normal); - normal.normalize(); - this.reportIntersection(normal, intersectionPoint, reportedShape, body, -1); - } - - if (this.result.shouldStop) { - return; - } - - if (d2 >= 0 && d2 <= 1) { - from.lerp(to, d2, intersectionPoint); - intersectionPoint.vsub(position, normal); - normal.normalize(); - this.reportIntersection(normal, intersectionPoint, reportedShape, body, -1); - } - } - }; - - _proto._intersectConvex = function _intersectConvex(shape, quat, position, body, reportedShape, options) { - var normal = intersectConvex_normal; - var vector = intersectConvex_vector; - var faceList = options && options.faceList || null; // Checking faces - - var faces = shape.faces; - var vertices = shape.vertices; - var normals = shape.faceNormals; - var direction = this.direction; - var from = this.from; - var to = this.to; - var fromToDistance = from.distanceTo(to); - var Nfaces = faceList ? faceList.length : faces.length; - var result = this.result; - - for (var j = 0; !result.shouldStop && j < Nfaces; j++) { - var fi = faceList ? faceList[j] : j; - var face = faces[fi]; - var faceNormal = normals[fi]; - var q = quat; - var x = position; // determine if ray intersects the plane of the face - // note: this works regardless of the direction of the face normal - // Get plane point in world coordinates... - - vector.copy(vertices[face[0]]); - q.vmult(vector, vector); - vector.vadd(x, vector); // ...but make it relative to the ray from. We'll fix this later. - - vector.vsub(from, vector); // Get plane normal - - q.vmult(faceNormal, normal); // If this dot product is negative, we have something interesting - - var dot = direction.dot(normal); // Bail out if ray and plane are parallel - - if (Math.abs(dot) < this.precision) { - continue; - } // calc distance to plane - - - var scalar = normal.dot(vector) / dot; // if negative distance, then plane is behind ray - - if (scalar < 0) { - continue; - } // if (dot < 0) { - // Intersection point is from + direction * scalar - - - direction.scale(scalar, intersectPoint); - intersectPoint.vadd(from, intersectPoint); // a is the point we compare points b and c with. - - a.copy(vertices[face[0]]); - q.vmult(a, a); - x.vadd(a, a); - - for (var i = 1; !result.shouldStop && i < face.length - 1; i++) { - // Transform 3 vertices to world coords - b.copy(vertices[face[i]]); - c.copy(vertices[face[i + 1]]); - q.vmult(b, b); - q.vmult(c, c); - x.vadd(b, b); - x.vadd(c, c); - var distance = intersectPoint.distanceTo(from); - - if (!(pointInTriangle(intersectPoint, a, b, c) || pointInTriangle(intersectPoint, b, a, c)) || distance > fromToDistance) { - continue; - } - - this.reportIntersection(normal, intersectPoint, reportedShape, body, fi); - } // } - - } - } - /** - * @todo Optimize by transforming the world to local space first. - * @todo Use Octree lookup - */ - ; - - _proto._intersectTrimesh = function _intersectTrimesh(mesh, quat, position, body, reportedShape, options) { - var normal = intersectTrimesh_normal; - var triangles = intersectTrimesh_triangles; - var treeTransform = intersectTrimesh_treeTransform; - var vector = intersectConvex_vector; - var localDirection = intersectTrimesh_localDirection; - var localFrom = intersectTrimesh_localFrom; - var localTo = intersectTrimesh_localTo; - var worldIntersectPoint = intersectTrimesh_worldIntersectPoint; - var worldNormal = intersectTrimesh_worldNormal; - var faceList = options && options.faceList || null; // Checking faces - - var indices = mesh.indices; - var vertices = mesh.vertices; // const normals = mesh.faceNormals - - var from = this.from; - var to = this.to; - var direction = this.direction; - treeTransform.position.copy(position); - treeTransform.quaternion.copy(quat); // Transform ray to local space! - - Transform.vectorToLocalFrame(position, quat, direction, localDirection); - Transform.pointToLocalFrame(position, quat, from, localFrom); - Transform.pointToLocalFrame(position, quat, to, localTo); - localTo.x *= mesh.scale.x; - localTo.y *= mesh.scale.y; - localTo.z *= mesh.scale.z; - localFrom.x *= mesh.scale.x; - localFrom.y *= mesh.scale.y; - localFrom.z *= mesh.scale.z; - localTo.vsub(localFrom, localDirection); - localDirection.normalize(); - var fromToDistanceSquared = localFrom.distanceSquared(localTo); - mesh.tree.rayQuery(this, treeTransform, triangles); - - for (var i = 0, N = triangles.length; !this.result.shouldStop && i !== N; i++) { - var trianglesIndex = triangles[i]; - mesh.getNormal(trianglesIndex, normal); // determine if ray intersects the plane of the face - // note: this works regardless of the direction of the face normal - // Get plane point in world coordinates... - - mesh.getVertex(indices[trianglesIndex * 3], a); // ...but make it relative to the ray from. We'll fix this later. - - a.vsub(localFrom, vector); // If this dot product is negative, we have something interesting - - var dot = localDirection.dot(normal); // Bail out if ray and plane are parallel - // if (Math.abs( dot ) < this.precision){ - // continue; - // } - // calc distance to plane - - var scalar = normal.dot(vector) / dot; // if negative distance, then plane is behind ray - - if (scalar < 0) { - continue; - } // Intersection point is from + direction * scalar - - - localDirection.scale(scalar, intersectPoint); - intersectPoint.vadd(localFrom, intersectPoint); // Get triangle vertices - - mesh.getVertex(indices[trianglesIndex * 3 + 1], b); - mesh.getVertex(indices[trianglesIndex * 3 + 2], c); - var squaredDistance = intersectPoint.distanceSquared(localFrom); - - if (!(pointInTriangle(intersectPoint, b, a, c) || pointInTriangle(intersectPoint, a, b, c)) || squaredDistance > fromToDistanceSquared) { - continue; - } // transform intersectpoint and normal to world - - - Transform.vectorToWorldFrame(quat, normal, worldNormal); - Transform.pointToWorldFrame(position, quat, intersectPoint, worldIntersectPoint); - this.reportIntersection(worldNormal, worldIntersectPoint, reportedShape, body, trianglesIndex); - } - - triangles.length = 0; - } - /** - * @return {boolean} True if the intersections should continue - */ - ; - - _proto.reportIntersection = function reportIntersection(normal, hitPointWorld, shape, body, hitFaceIndex) { - var from = this.from; - var to = this.to; - var distance = from.distanceTo(hitPointWorld); - var result = this.result; // Skip back faces? - - if (this.skipBackfaces && normal.dot(this.direction) > 0) { - return; - } - - result.hitFaceIndex = typeof hitFaceIndex !== 'undefined' ? hitFaceIndex : -1; - - switch (this.mode) { - case Ray.ALL: - this.hasHit = true; - result.set(from, to, normal, hitPointWorld, shape, body, distance); - result.hasHit = true; - this.callback(result); - break; - - case Ray.CLOSEST: - // Store if closer than current closest - if (distance < result.distance || !result.hasHit) { - this.hasHit = true; - result.hasHit = true; - result.set(from, to, normal, hitPointWorld, shape, body, distance); - } - - break; - - case Ray.ANY: - // Report and stop. - this.hasHit = true; - result.hasHit = true; - result.set(from, to, normal, hitPointWorld, shape, body, distance); - result.shouldStop = true; - break; - } - }; - - return Ray; -}(); -Ray.CLOSEST = 1; -Ray.ANY = 2; -Ray.ALL = 4; -var tmpAABB = new AABB(); -var tmpArray = []; -var v1 = new Vec3(); -var v2 = new Vec3(); -/* - * As per "Barycentric Technique" as named here http://www.blackpawn.com/texts/pointinpoly/default.html But without the division - */ - -Ray.pointInTriangle = pointInTriangle; - -function pointInTriangle(p, a, b, c) { - c.vsub(a, v0); - b.vsub(a, v1); - p.vsub(a, v2); - var dot00 = v0.dot(v0); - var dot01 = v0.dot(v1); - var dot02 = v0.dot(v2); - var dot11 = v1.dot(v1); - var dot12 = v1.dot(v2); - var u; - var v; - return (u = dot11 * dot02 - dot01 * dot12) >= 0 && (v = dot00 * dot12 - dot01 * dot02) >= 0 && u + v < dot00 * dot11 - dot01 * dot01; -} - -var intersectBody_xi = new Vec3(); -var intersectBody_qi = new Quaternion(); -var vector = new Vec3(); -var normal = new Vec3(); -var intersectPoint = new Vec3(); -var a = new Vec3(); -var b = new Vec3(); -var c = new Vec3(); -var d = new Vec3(); -var tmpRaycastResult = new RaycastResult(); -Ray.prototype[Shape.types.BOX] = Ray.prototype._intersectBox; -Ray.prototype[Shape.types.PLANE] = Ray.prototype._intersectPlane; -var intersectConvexOptions = { - faceList: [0] -}; -var worldPillarOffset = new Vec3(); -var intersectHeightfield_localRay = new Ray(); -var intersectHeightfield_index = []; -Ray.prototype[Shape.types.HEIGHTFIELD] = Ray.prototype._intersectHeightfield; -var Ray_intersectSphere_intersectionPoint = new Vec3(); -var Ray_intersectSphere_normal = new Vec3(); -Ray.prototype[Shape.types.SPHERE] = Ray.prototype._intersectSphere; -var intersectConvex_normal = new Vec3(); -var intersectConvex_minDistNormal = new Vec3(); -var intersectConvex_minDistIntersect = new Vec3(); -var intersectConvex_vector = new Vec3(); -Ray.prototype[Shape.types.CONVEXPOLYHEDRON] = Ray.prototype._intersectConvex; -var intersectTrimesh_normal = new Vec3(); -var intersectTrimesh_localDirection = new Vec3(); -var intersectTrimesh_localFrom = new Vec3(); -var intersectTrimesh_localTo = new Vec3(); -var intersectTrimesh_worldNormal = new Vec3(); -var intersectTrimesh_worldIntersectPoint = new Vec3(); -var intersectTrimesh_localAABB = new AABB(); -var intersectTrimesh_triangles = []; -var intersectTrimesh_treeTransform = new Transform(); -Ray.prototype[Shape.types.TRIMESH] = Ray.prototype._intersectTrimesh; -var v0 = new Vec3(); -var intersect = new Vec3(); - -function distanceFromIntersection(from, direction, position) { - // v0 is vector from from to position - position.vsub(from, v0); - var dot = v0.dot(direction); // intersect = direction*dot + from - - direction.scale(dot, intersect); - intersect.vadd(from, intersect); - var distance = position.distanceTo(intersect); - return distance; -} - -/** - * Sweep and prune broadphase along one axis. - * - * @class SAPBroadphase - * @constructor - * @param {World} [world] - * @extends Broadphase - */ -var SAPBroadphase = /*#__PURE__*/function (_Broadphase) { - _inheritsLoose(SAPBroadphase, _Broadphase); - - // List of bodies currently in the broadphase. - // The world to search in. - // Axis to sort the bodies along. Set to 0 for x axis, and 1 for y axis. For best performance, choose an axis that the bodies are spread out more on. - function SAPBroadphase(world) { - var _this; - - _this = _Broadphase.call(this) || this; - _this.axisList = []; - _this.world = null; - _this.axisIndex = 0; - var axisList = _this.axisList; - - _this._addBodyHandler = function (event) { - axisList.push(event.body); - }; - - _this._removeBodyHandler = function (event) { - var idx = axisList.indexOf(event.body); - - if (idx !== -1) { - axisList.splice(idx, 1); - } - }; - - if (world) { - _this.setWorld(world); - } - - return _this; - } - /** - * Change the world - * @method setWorld - * @param {World} world - */ - - - var _proto = SAPBroadphase.prototype; - - _proto.setWorld = function setWorld(world) { - // Clear the old axis array - this.axisList.length = 0; // Add all bodies from the new world - - for (var i = 0; i < world.bodies.length; i++) { - this.axisList.push(world.bodies[i]); - } // Remove old handlers, if any - - - world.removeEventListener('addBody', this._addBodyHandler); - world.removeEventListener('removeBody', this._removeBodyHandler); // Add handlers to update the list of bodies. - - world.addEventListener('addBody', this._addBodyHandler); - world.addEventListener('removeBody', this._removeBodyHandler); - this.world = world; - this.dirty = true; - } - /** - * Collect all collision pairs - * @method collisionPairs - * @param {World} world - * @param {Array} p1 - * @param {Array} p2 - */ - ; - - _proto.collisionPairs = function collisionPairs(world, p1, p2) { - var bodies = this.axisList; - var N = bodies.length; - var axisIndex = this.axisIndex; - var i; - var j; - - if (this.dirty) { - this.sortList(); - this.dirty = false; - } // Look through the list - - - for (i = 0; i !== N; i++) { - var _bi = bodies[i]; - - for (j = i + 1; j < N; j++) { - var _bj = bodies[j]; - - if (!this.needBroadphaseCollision(_bi, _bj)) { - continue; - } - - if (!SAPBroadphase.checkBounds(_bi, _bj, axisIndex)) { - break; - } - - this.intersectionTest(_bi, _bj, p1, p2); - } - } - }; - - _proto.sortList = function sortList() { - var axisList = this.axisList; - var axisIndex = this.axisIndex; - var N = axisList.length; // Update AABBs - - for (var i = 0; i !== N; i++) { - var _bi2 = axisList[i]; - - if (_bi2.aabbNeedsUpdate) { - _bi2.computeAABB(); - } - } // Sort the list - - - if (axisIndex === 0) { - SAPBroadphase.insertionSortX(axisList); - } else if (axisIndex === 1) { - SAPBroadphase.insertionSortY(axisList); - } else if (axisIndex === 2) { - SAPBroadphase.insertionSortZ(axisList); - } - } - /** - * Computes the variance of the body positions and estimates the best - * axis to use. Will automatically set property .axisIndex. - * @method autoDetectAxis - */ - ; - - _proto.autoDetectAxis = function autoDetectAxis() { - var sumX = 0; - var sumX2 = 0; - var sumY = 0; - var sumY2 = 0; - var sumZ = 0; - var sumZ2 = 0; - var bodies = this.axisList; - var N = bodies.length; - var invN = 1 / N; - - for (var i = 0; i !== N; i++) { - var b = bodies[i]; - var centerX = b.position.x; - sumX += centerX; - sumX2 += centerX * centerX; - var centerY = b.position.y; - sumY += centerY; - sumY2 += centerY * centerY; - var centerZ = b.position.z; - sumZ += centerZ; - sumZ2 += centerZ * centerZ; - } - - var varianceX = sumX2 - sumX * sumX * invN; - var varianceY = sumY2 - sumY * sumY * invN; - var varianceZ = sumZ2 - sumZ * sumZ * invN; - - if (varianceX > varianceY) { - if (varianceX > varianceZ) { - this.axisIndex = 0; - } else { - this.axisIndex = 2; - } - } else if (varianceY > varianceZ) { - this.axisIndex = 1; - } else { - this.axisIndex = 2; - } - } - /** - * Returns all the bodies within an AABB. - * @method aabbQuery - * @param {World} world - * @param {AABB} aabb - * @param {array} result An array to store resulting bodies in. - * @return {array} - */ - ; - - _proto.aabbQuery = function aabbQuery(world, aabb, result) { - if (result === void 0) { - result = []; - } - - if (this.dirty) { - this.sortList(); - this.dirty = false; - } - - var axisIndex = this.axisIndex; - var axis = 'x'; - - if (axisIndex === 1) { - axis = 'y'; - } - - if (axisIndex === 2) { - axis = 'z'; - } - - var axisList = this.axisList; - var lower = aabb.lowerBound[axis]; - var upper = aabb.upperBound[axis]; - - for (var i = 0; i < axisList.length; i++) { - var b = axisList[i]; - - if (b.aabbNeedsUpdate) { - b.computeAABB(); - } - - if (b.aabb.overlaps(aabb)) { - result.push(b); - } - } - - return result; - }; - - return SAPBroadphase; -}(Broadphase); -/** - * @static - * @method insertionSortX - * @param {Array} a - * @return {Array} - */ - -SAPBroadphase.insertionSortX = function (a) { - for (var i = 1, l = a.length; i < l; i++) { - var v = a[i]; - var j = void 0; - - for (j = i - 1; j >= 0; j--) { - if (a[j].aabb.lowerBound.x <= v.aabb.lowerBound.x) { - break; - } - - a[j + 1] = a[j]; - } - - a[j + 1] = v; - } - - return a; -}; -/** - * @static - * @method insertionSortY - * @param {Array} a - * @return {Array} - */ - - -SAPBroadphase.insertionSortY = function (a) { - for (var i = 1, l = a.length; i < l; i++) { - var v = a[i]; - var j = void 0; - - for (j = i - 1; j >= 0; j--) { - if (a[j].aabb.lowerBound.y <= v.aabb.lowerBound.y) { - break; - } - - a[j + 1] = a[j]; - } - - a[j + 1] = v; - } - - return a; -}; -/** - * @static - * @method insertionSortZ - * @param {Array} a - * @return {Array} - */ - - -SAPBroadphase.insertionSortZ = function (a) { - for (var i = 1, l = a.length; i < l; i++) { - var v = a[i]; - var j = void 0; - - for (j = i - 1; j >= 0; j--) { - if (a[j].aabb.lowerBound.z <= v.aabb.lowerBound.z) { - break; - } - - a[j + 1] = a[j]; - } - - a[j + 1] = v; - } - - return a; -}; -/** - * Check if the bounds of two bodies overlap, along the given SAP axis. - * @static - * @method checkBounds - * @param {Body} bi - * @param {Body} bj - * @param {Number} axisIndex - * @return {Boolean} - */ - - -SAPBroadphase.checkBounds = function (bi, bj, axisIndex) { - var biPos; - var bjPos; - - if (axisIndex === 0) { - biPos = bi.position.x; - bjPos = bj.position.x; - } else if (axisIndex === 1) { - biPos = bi.position.y; - bjPos = bj.position.y; - } else if (axisIndex === 2) { - biPos = bi.position.z; - bjPos = bj.position.z; - } - - var ri = bi.boundingRadius, - rj = bj.boundingRadius, - // boundA1 = biPos - ri, - boundA2 = biPos + ri, - boundB1 = bjPos - rj; // boundB2 = bjPos + rj; - - return boundB1 < boundA2; -}; - -function Utils() {} -/** - * Extend an options object with default values. - * @static - * @method defaults - * @param {object} options The options object. May be falsy: in this case, a new object is created and returned. - * @param {object} defaults An object containing default values. - * @return {object} The modified options object. - */ - -Utils.defaults = function (options, defaults) { - if (options === void 0) { - options = {}; - } - - for (var key in defaults) { - if (!(key in options)) { - options[key] = defaults[key]; - } - } - - return options; -}; - -/** - * Constraint base class - * @class Constraint - * @author schteppe - * @constructor - * @param {Body} bodyA - * @param {Body} bodyB - * @param {object} [options] - * @param {boolean} [options.collideConnected=true] - * @param {boolean} [options.wakeUpBodies=true] - */ -var Constraint = /*#__PURE__*/function () { - // Equations to be solved in this constraint. - // Set to true if you want the bodies to collide when they are connected. - function Constraint(bodyA, bodyB, options) { - if (options === void 0) { - options = {}; - } - - options = Utils.defaults(options, { - collideConnected: true, - wakeUpBodies: true - }); - this.equations = []; - this.bodyA = bodyA; - this.bodyB = bodyB; - this.id = Constraint.idCounter++; - this.collideConnected = options.collideConnected; - - if (options.wakeUpBodies) { - if (bodyA) { - bodyA.wakeUp(); - } - - if (bodyB) { - bodyB.wakeUp(); - } - } - } - /** - * Update all the equations with data. - * @method update - */ - - - var _proto = Constraint.prototype; - - _proto.update = function update() { - throw new Error('method update() not implmemented in this Constraint subclass!'); - } - /** - * Enables all equations in the constraint. - * @method enable - */ - ; - - _proto.enable = function enable() { - var eqs = this.equations; - - for (var i = 0; i < eqs.length; i++) { - eqs[i].enabled = true; - } - } - /** - * Disables all equations in the constraint. - * @method disable - */ - ; - - _proto.disable = function disable() { - var eqs = this.equations; - - for (var i = 0; i < eqs.length; i++) { - eqs[i].enabled = false; - } - }; - - return Constraint; -}(); -Constraint.idCounter = 0; - -/** - * An element containing 6 entries, 3 spatial and 3 rotational degrees of freedom. - */ - -var JacobianElement = /*#__PURE__*/function () { - function JacobianElement() { - this.spatial = new Vec3(); - this.rotational = new Vec3(); - } - /** - * Multiply with other JacobianElement - */ - - - var _proto = JacobianElement.prototype; - - _proto.multiplyElement = function multiplyElement(element) { - return element.spatial.dot(this.spatial) + element.rotational.dot(this.rotational); - } - /** - * Multiply with two vectors - */ - ; - - _proto.multiplyVectors = function multiplyVectors(spatial, rotational) { - return spatial.dot(this.spatial) + rotational.dot(this.rotational); - }; - - return JacobianElement; -}(); - -/** - * Equation base class - * @class Equation - * @constructor - * @author schteppe - * @param {Body} bi - * @param {Body} bj - * @param {Number} minForce Minimum (read: negative max) force to be applied by the constraint. - * @param {Number} maxForce Maximum (read: positive max) force to be applied by the constraint. - */ -var Equation = /*#__PURE__*/function () { - // SPOOK parameter - // SPOOK parameter - // SPOOK parameter - // A number, proportional to the force added to the bodies. - function Equation(bi, bj, minForce, maxForce) { - if (minForce === void 0) { - minForce = -1e6; - } - - if (maxForce === void 0) { - maxForce = 1e6; - } - - this.id = Equation.id++; - this.minForce = minForce; - this.maxForce = maxForce; - this.bi = bi; - this.bj = bj; - this.a = 0.0; // SPOOK parameter - - this.b = 0.0; // SPOOK parameter - - this.eps = 0.0; // SPOOK parameter - - this.jacobianElementA = new JacobianElement(); - this.jacobianElementB = new JacobianElement(); - this.enabled = true; - this.multiplier = 0; - this.setSpookParams(1e7, 4, 1 / 60); // Set typical spook params - } - /** - * Recalculates a,b,eps. - * @method setSpookParams - */ - - - var _proto = Equation.prototype; - - _proto.setSpookParams = function setSpookParams(stiffness, relaxation, timeStep) { - var d = relaxation; - var k = stiffness; - var h = timeStep; - this.a = 4.0 / (h * (1 + 4 * d)); - this.b = 4.0 * d / (1 + 4 * d); - this.eps = 4.0 / (h * h * k * (1 + 4 * d)); - } - /** - * Computes the right hand side of the SPOOK equation - * @method computeB - * @return {Number} - */ - ; - - _proto.computeB = function computeB(a, b, h) { - var GW = this.computeGW(); - var Gq = this.computeGq(); - var GiMf = this.computeGiMf(); - return -Gq * a - GW * b - GiMf * h; - } - /** - * Computes G*q, where q are the generalized body coordinates - * @method computeGq - * @return {Number} - */ - ; - - _proto.computeGq = function computeGq() { - var GA = this.jacobianElementA; - var GB = this.jacobianElementB; - var bi = this.bi; - var bj = this.bj; - var xi = bi.position; - var xj = bj.position; - return GA.spatial.dot(xi) + GB.spatial.dot(xj); - } - /** - * Computes G*W, where W are the body velocities - * @method computeGW - * @return {Number} - */ - ; - - _proto.computeGW = function computeGW() { - var GA = this.jacobianElementA; - var GB = this.jacobianElementB; - var bi = this.bi; - var bj = this.bj; - var vi = bi.velocity; - var vj = bj.velocity; - var wi = bi.angularVelocity; - var wj = bj.angularVelocity; - return GA.multiplyVectors(vi, wi) + GB.multiplyVectors(vj, wj); - } - /** - * Computes G*Wlambda, where W are the body velocities - * @method computeGWlambda - * @return {Number} - */ - ; - - _proto.computeGWlambda = function computeGWlambda() { - var GA = this.jacobianElementA; - var GB = this.jacobianElementB; - var bi = this.bi; - var bj = this.bj; - var vi = bi.vlambda; - var vj = bj.vlambda; - var wi = bi.wlambda; - var wj = bj.wlambda; - return GA.multiplyVectors(vi, wi) + GB.multiplyVectors(vj, wj); - }; - - _proto.computeGiMf = function computeGiMf() { - var GA = this.jacobianElementA; - var GB = this.jacobianElementB; - var bi = this.bi; - var bj = this.bj; - var fi = bi.force; - var ti = bi.torque; - var fj = bj.force; - var tj = bj.torque; - var invMassi = bi.invMassSolve; - var invMassj = bj.invMassSolve; - fi.scale(invMassi, iMfi); - fj.scale(invMassj, iMfj); - bi.invInertiaWorldSolve.vmult(ti, invIi_vmult_taui); - bj.invInertiaWorldSolve.vmult(tj, invIj_vmult_tauj); - return GA.multiplyVectors(iMfi, invIi_vmult_taui) + GB.multiplyVectors(iMfj, invIj_vmult_tauj); - }; - - _proto.computeGiMGt = function computeGiMGt() { - var GA = this.jacobianElementA; - var GB = this.jacobianElementB; - var bi = this.bi; - var bj = this.bj; - var invMassi = bi.invMassSolve; - var invMassj = bj.invMassSolve; - var invIi = bi.invInertiaWorldSolve; - var invIj = bj.invInertiaWorldSolve; - var result = invMassi + invMassj; - invIi.vmult(GA.rotational, tmp$1); - result += tmp$1.dot(GA.rotational); - invIj.vmult(GB.rotational, tmp$1); - result += tmp$1.dot(GB.rotational); - return result; - } - /** - * Add constraint velocity to the bodies. - * @method addToWlambda - * @param {Number} deltalambda - */ - ; - - _proto.addToWlambda = function addToWlambda(deltalambda) { - var GA = this.jacobianElementA; - var GB = this.jacobianElementB; - var bi = this.bi; - var bj = this.bj; - var temp = addToWlambda_temp; // Add to linear velocity - // v_lambda += inv(M) * delta_lamba * G - - bi.vlambda.addScaledVector(bi.invMassSolve * deltalambda, GA.spatial, bi.vlambda); - bj.vlambda.addScaledVector(bj.invMassSolve * deltalambda, GB.spatial, bj.vlambda); // Add to angular velocity - - bi.invInertiaWorldSolve.vmult(GA.rotational, temp); - bi.wlambda.addScaledVector(deltalambda, temp, bi.wlambda); - bj.invInertiaWorldSolve.vmult(GB.rotational, temp); - bj.wlambda.addScaledVector(deltalambda, temp, bj.wlambda); - } - /** - * Compute the denominator part of the SPOOK equation: C = G*inv(M)*G' + eps - * @method computeInvC - * @param {Number} eps - * @return {Number} - */ - ; - - _proto.computeC = function computeC() { - return this.computeGiMGt() + this.eps; - }; - - return Equation; -}(); -Equation.id = 0; -/** - * Computes G*inv(M)*f, where M is the mass matrix with diagonal blocks for each body, and f are the forces on the bodies. - * @method computeGiMf - * @return {Number} - */ - -var iMfi = new Vec3(); -var iMfj = new Vec3(); -var invIi_vmult_taui = new Vec3(); -var invIj_vmult_tauj = new Vec3(); -/** - * Computes G*inv(M)*G' - * @method computeGiMGt - * @return {Number} - */ - -var tmp$1 = new Vec3(); -var addToWlambda_temp = new Vec3(); - -/** - * Contact/non-penetration constraint equation - * @class ContactEquation - * @constructor - * @author schteppe - * @param {Body} bodyA - * @param {Body} bodyB - * @extends Equation - */ -var ContactEquation = /*#__PURE__*/function (_Equation) { - _inheritsLoose(ContactEquation, _Equation); - - // "bounciness": u1 = -e*u0 - // World-oriented vector that goes from the center of bi to the contact point. - // World-oriented vector that starts in body j position and goes to the contact point. - // Contact normal, pointing out of body i. - function ContactEquation(bodyA, bodyB, maxForce) { - var _this; - - if (maxForce === void 0) { - maxForce = 1e6; - } - - _this = _Equation.call(this, bodyA, bodyB, 0, maxForce) || this; - _this.restitution = 0.0; - _this.ri = new Vec3(); - _this.rj = new Vec3(); - _this.ni = new Vec3(); - return _this; - } - - var _proto = ContactEquation.prototype; - - _proto.computeB = function computeB(h) { - var a = this.a; - var b = this.b; - var bi = this.bi; - var bj = this.bj; - var ri = this.ri; - var rj = this.rj; - var rixn = ContactEquation_computeB_temp1; - var rjxn = ContactEquation_computeB_temp2; - var vi = bi.velocity; - var wi = bi.angularVelocity; - var fi = bi.force; - var taui = bi.torque; - var vj = bj.velocity; - var wj = bj.angularVelocity; - var fj = bj.force; - var tauj = bj.torque; - var penetrationVec = ContactEquation_computeB_temp3; - var GA = this.jacobianElementA; - var GB = this.jacobianElementB; - var n = this.ni; // Caluclate cross products - - ri.cross(n, rixn); - rj.cross(n, rjxn); // g = xj+rj -(xi+ri) - // G = [ -ni -rixn ni rjxn ] - - n.negate(GA.spatial); - rixn.negate(GA.rotational); - GB.spatial.copy(n); - GB.rotational.copy(rjxn); // Calculate the penetration vector - - penetrationVec.copy(bj.position); - penetrationVec.vadd(rj, penetrationVec); - penetrationVec.vsub(bi.position, penetrationVec); - penetrationVec.vsub(ri, penetrationVec); - var g = n.dot(penetrationVec); // Compute iteration - - var ePlusOne = this.restitution + 1; - var GW = ePlusOne * vj.dot(n) - ePlusOne * vi.dot(n) + wj.dot(rjxn) - wi.dot(rixn); - var GiMf = this.computeGiMf(); - var B = -g * a - GW * b - h * GiMf; - return B; - } - /** - * Get the current relative velocity in the contact point. - * @method getImpactVelocityAlongNormal - * @return {number} - */ - ; - - _proto.getImpactVelocityAlongNormal = function getImpactVelocityAlongNormal() { - var vi = ContactEquation_getImpactVelocityAlongNormal_vi; - var vj = ContactEquation_getImpactVelocityAlongNormal_vj; - var xi = ContactEquation_getImpactVelocityAlongNormal_xi; - var xj = ContactEquation_getImpactVelocityAlongNormal_xj; - var relVel = ContactEquation_getImpactVelocityAlongNormal_relVel; - this.bi.position.vadd(this.ri, xi); - this.bj.position.vadd(this.rj, xj); - this.bi.getVelocityAtWorldPoint(xi, vi); - this.bj.getVelocityAtWorldPoint(xj, vj); - vi.vsub(vj, relVel); - return this.ni.dot(relVel); - }; - - return ContactEquation; -}(Equation); -var ContactEquation_computeB_temp1 = new Vec3(); // Temp vectors - -var ContactEquation_computeB_temp2 = new Vec3(); -var ContactEquation_computeB_temp3 = new Vec3(); -var ContactEquation_getImpactVelocityAlongNormal_vi = new Vec3(); -var ContactEquation_getImpactVelocityAlongNormal_vj = new Vec3(); -var ContactEquation_getImpactVelocityAlongNormal_xi = new Vec3(); -var ContactEquation_getImpactVelocityAlongNormal_xj = new Vec3(); -var ContactEquation_getImpactVelocityAlongNormal_relVel = new Vec3(); - -/** - * Connects two bodies at given offset points. - * @class PointToPointConstraint - * @extends Constraint - * @constructor - * @param {Body} bodyA - * @param {Vec3} pivotA The point relative to the center of mass of bodyA which bodyA is constrained to. - * @param {Body} bodyB Body that will be constrained in a similar way to the same point as bodyA. We will therefore get a link between bodyA and bodyB. If not specified, bodyA will be constrained to a static point. - * @param {Vec3} pivotB See pivotA. - * @param {Number} maxForce The maximum force that should be applied to constrain the bodies. - * - * @example - * const bodyA = new Body({ mass: 1 }); - * const bodyB = new Body({ mass: 1 }); - * bodyA.position.set(-1, 0, 0); - * bodyB.position.set(1, 0, 0); - * bodyA.addShape(shapeA); - * bodyB.addShape(shapeB); - * world.addBody(bodyA); - * world.addBody(bodyB); - * const localPivotA = new Vec3(1, 0, 0); - * const localPivotB = new Vec3(-1, 0, 0); - * const constraint = new PointToPointConstraint(bodyA, localPivotA, bodyB, localPivotB); - * world.addConstraint(constraint); - */ -var PointToPointConstraint = /*#__PURE__*/function (_Constraint) { - _inheritsLoose(PointToPointConstraint, _Constraint); - - // Pivot, defined locally in bodyA. - // Pivot, defined locally in bodyB. - function PointToPointConstraint(bodyA, pivotA, bodyB, pivotB, maxForce) { - var _this; - - if (pivotA === void 0) { - pivotA = new Vec3(); - } - - if (pivotB === void 0) { - pivotB = new Vec3(); - } - - if (maxForce === void 0) { - maxForce = 1e6; - } - - _this = _Constraint.call(this, bodyA, bodyB) || this; - _this.pivotA = pivotA.clone(); - _this.pivotB = pivotB.clone(); - var x = _this.equationX = new ContactEquation(bodyA, bodyB); - var y = _this.equationY = new ContactEquation(bodyA, bodyB); - var z = _this.equationZ = new ContactEquation(bodyA, bodyB); // Equations to be fed to the solver - - _this.equations.push(x, y, z); // Make the equations bidirectional - - - x.minForce = y.minForce = z.minForce = -maxForce; - x.maxForce = y.maxForce = z.maxForce = maxForce; - x.ni.set(1, 0, 0); - y.ni.set(0, 1, 0); - z.ni.set(0, 0, 1); - return _this; - } - - var _proto = PointToPointConstraint.prototype; - - _proto.update = function update() { - var bodyA = this.bodyA; - var bodyB = this.bodyB; - var x = this.equationX; - var y = this.equationY; - var z = this.equationZ; // Rotate the pivots to world space - - bodyA.quaternion.vmult(this.pivotA, x.ri); - bodyB.quaternion.vmult(this.pivotB, x.rj); - y.ri.copy(x.ri); - y.rj.copy(x.rj); - z.ri.copy(x.ri); - z.rj.copy(x.rj); - }; - - return PointToPointConstraint; -}(Constraint); - -/** - * Cone equation. Works to keep the given body world vectors aligned, or tilted within a given angle from each other. - * @class ConeEquation - * @constructor - * @author schteppe - * @param {Body} bodyA - * @param {Body} bodyB - * @param {Vec3} [options.axisA] Local axis in A - * @param {Vec3} [options.axisB] Local axis in B - * @param {Vec3} [options.angle] The "cone angle" to keep - * @param {number} [options.maxForce=1e6] - * @extends Equation - */ -var ConeEquation = /*#__PURE__*/function (_Equation) { - _inheritsLoose(ConeEquation, _Equation); - - // The cone angle to keep. - function ConeEquation(bodyA, bodyB, options) { - var _this; - - if (options === void 0) { - options = {}; - } - - var maxForce = typeof options.maxForce !== 'undefined' ? options.maxForce : 1e6; - _this = _Equation.call(this, bodyA, bodyB, -maxForce, maxForce) || this; - _this.axisA = options.axisA ? options.axisA.clone() : new Vec3(1, 0, 0); - _this.axisB = options.axisB ? options.axisB.clone() : new Vec3(0, 1, 0); - _this.angle = typeof options.angle !== 'undefined' ? options.angle : 0; - return _this; - } - - var _proto = ConeEquation.prototype; - - _proto.computeB = function computeB(h) { - var a = this.a; - var b = this.b; - var ni = this.axisA; - var nj = this.axisB; - var nixnj = tmpVec1; - var njxni = tmpVec2; - var GA = this.jacobianElementA; - var GB = this.jacobianElementB; // Caluclate cross products - - ni.cross(nj, nixnj); - nj.cross(ni, njxni); // The angle between two vector is: - // cos(theta) = a * b / (length(a) * length(b) = { len(a) = len(b) = 1 } = a * b - // g = a * b - // gdot = (b x a) * wi + (a x b) * wj - // G = [0 bxa 0 axb] - // W = [vi wi vj wj] - - GA.rotational.copy(njxni); - GB.rotational.copy(nixnj); - var g = Math.cos(this.angle) - ni.dot(nj); - var GW = this.computeGW(); - var GiMf = this.computeGiMf(); - var B = -g * a - GW * b - h * GiMf; - return B; - }; - - return ConeEquation; -}(Equation); -var tmpVec1 = new Vec3(); -var tmpVec2 = new Vec3(); - -/** - * Rotational constraint. Works to keep the local vectors orthogonal to each other in world space. - * @class RotationalEquation - * @constructor - * @author schteppe - * @param {Body} bodyA - * @param {Body} bodyB - * @param {Vec3} [options.axisA] - * @param {Vec3} [options.axisB] - * @param {number} [options.maxForce] - * @extends Equation - */ -var RotationalEquation = /*#__PURE__*/function (_Equation) { - _inheritsLoose(RotationalEquation, _Equation); - - function RotationalEquation(bodyA, bodyB, options) { - var _this; - - if (options === void 0) { - options = {}; - } - - var maxForce = typeof options.maxForce !== 'undefined' ? options.maxForce : 1e6; - _this = _Equation.call(this, bodyA, bodyB, -maxForce, maxForce) || this; - _this.axisA = options.axisA ? options.axisA.clone() : new Vec3(1, 0, 0); - _this.axisB = options.axisB ? options.axisB.clone() : new Vec3(0, 1, 0); - _this.maxAngle = Math.PI / 2; - return _this; - } - - var _proto = RotationalEquation.prototype; - - _proto.computeB = function computeB(h) { - var a = this.a; - var b = this.b; - var ni = this.axisA; - var nj = this.axisB; - var nixnj = tmpVec1$1; - var njxni = tmpVec2$1; - var GA = this.jacobianElementA; - var GB = this.jacobianElementB; // Caluclate cross products - - ni.cross(nj, nixnj); - nj.cross(ni, njxni); // g = ni * nj - // gdot = (nj x ni) * wi + (ni x nj) * wj - // G = [0 njxni 0 nixnj] - // W = [vi wi vj wj] - - GA.rotational.copy(njxni); - GB.rotational.copy(nixnj); - var g = Math.cos(this.maxAngle) - ni.dot(nj); - var GW = this.computeGW(); - var GiMf = this.computeGiMf(); - var B = -g * a - GW * b - h * GiMf; - return B; - }; - - return RotationalEquation; -}(Equation); -var tmpVec1$1 = new Vec3(); -var tmpVec2$1 = new Vec3(); - -/** - * @class ConeTwistConstraint - * @constructor - * @author schteppe - * @param {Body} bodyA - * @param {Body} bodyB - * @param {object} [options] - * @param {Vec3} [options.pivotA] - * @param {Vec3} [options.pivotB] - * @param {Vec3} [options.axisA] - * @param {Vec3} [options.axisB] - * @param {Number} [options.maxForce=1e6] - * @extends PointToPointConstraint - */ -var ConeTwistConstraint = /*#__PURE__*/function (_PointToPointConstrai) { - _inheritsLoose(ConeTwistConstraint, _PointToPointConstrai); - - function ConeTwistConstraint(bodyA, bodyB, options) { - var _this; - - if (options === void 0) { - options = {}; - } - - var maxForce = typeof options.maxForce !== 'undefined' ? options.maxForce : 1e6; // Set pivot point in between - - var pivotA = options.pivotA ? options.pivotA.clone() : new Vec3(); - var pivotB = options.pivotB ? options.pivotB.clone() : new Vec3(); - _this = _PointToPointConstrai.call(this, bodyA, pivotA, bodyB, pivotB, maxForce) || this; - _this.axisA = options.axisA ? options.axisA.clone() : new Vec3(); - _this.axisB = options.axisB ? options.axisB.clone() : new Vec3(); - _this.collideConnected = !!options.collideConnected; - _this.angle = typeof options.angle !== 'undefined' ? options.angle : 0; - var c = _this.coneEquation = new ConeEquation(bodyA, bodyB, options); - var t = _this.twistEquation = new RotationalEquation(bodyA, bodyB, options); - _this.twistAngle = typeof options.twistAngle !== 'undefined' ? options.twistAngle : 0; // Make the cone equation push the bodies toward the cone axis, not outward - - c.maxForce = 0; - c.minForce = -maxForce; // Make the twist equation add torque toward the initial position - - t.maxForce = 0; - t.minForce = -maxForce; - - _this.equations.push(c, t); - - return _this; - } - - var _proto = ConeTwistConstraint.prototype; - - _proto.update = function update() { - var bodyA = this.bodyA; - var bodyB = this.bodyB; - var cone = this.coneEquation; - var twist = this.twistEquation; - - _PointToPointConstrai.prototype.update.call(this); // Update the axes to the cone constraint - - - bodyA.vectorToWorldFrame(this.axisA, cone.axisA); - bodyB.vectorToWorldFrame(this.axisB, cone.axisB); // Update the world axes in the twist constraint - - this.axisA.tangents(twist.axisA, twist.axisA); - bodyA.vectorToWorldFrame(twist.axisA, twist.axisA); - this.axisB.tangents(twist.axisB, twist.axisB); - bodyB.vectorToWorldFrame(twist.axisB, twist.axisB); - cone.angle = this.angle; - twist.maxAngle = this.twistAngle; - }; - - return ConeTwistConstraint; -}(PointToPointConstraint); -var ConeTwistConstraint_update_tmpVec1 = new Vec3(); -var ConeTwistConstraint_update_tmpVec2 = new Vec3(); - -/** - * Constrains two bodies to be at a constant distance from each others center of mass. - * @class DistanceConstraint - * @constructor - * @author schteppe - * @param {Body} bodyA - * @param {Body} bodyB - * @param {Number} [distance] The distance to keep. If undefined, it will be set to the current distance between bodyA and bodyB - * @param {Number} [maxForce=1e6] - * @extends Constraint - */ -var DistanceConstraint = /*#__PURE__*/function (_Constraint) { - _inheritsLoose(DistanceConstraint, _Constraint); - - function DistanceConstraint(bodyA, bodyB, distance, maxForce) { - var _this; - - if (maxForce === void 0) { - maxForce = 1e6; - } - - _this = _Constraint.call(this, bodyA, bodyB) || this; - - if (typeof distance === 'undefined') { - distance = bodyA.position.distanceTo(bodyB.position); - } - - _this.distance = distance; - var eq = _this.distanceEquation = new ContactEquation(bodyA, bodyB); - - _this.equations.push(eq); // Make it bidirectional - - - eq.minForce = -maxForce; - eq.maxForce = maxForce; - return _this; - } - - var _proto = DistanceConstraint.prototype; - - _proto.update = function update() { - var bodyA = this.bodyA; - var bodyB = this.bodyB; - var eq = this.distanceEquation; - var halfDist = this.distance * 0.5; - var normal = eq.ni; - bodyB.position.vsub(bodyA.position, normal); - normal.normalize(); - normal.scale(halfDist, eq.ri); - normal.scale(-halfDist, eq.rj); - }; - - return DistanceConstraint; -}(Constraint); - -/** - * Lock constraint. Will remove all degrees of freedom between the bodies. - * @class LockConstraint - * @constructor - * @author schteppe - * @param {Body} bodyA - * @param {Body} bodyB - * @param {object} [options] - * @param {Number} [options.maxForce=1e6] - * @extends PointToPointConstraint - */ -var LockConstraint = /*#__PURE__*/function (_PointToPointConstrai) { - _inheritsLoose(LockConstraint, _PointToPointConstrai); - - function LockConstraint(bodyA, bodyB, options) { - var _this; - - if (options === void 0) { - options = {}; - } - - var maxForce = typeof options.maxForce !== 'undefined' ? options.maxForce : 1e6; // Set pivot point in between - - var pivotA = new Vec3(); - var pivotB = new Vec3(); - var halfWay = new Vec3(); - bodyA.position.vadd(bodyB.position, halfWay); - halfWay.scale(0.5, halfWay); - bodyB.pointToLocalFrame(halfWay, pivotB); - bodyA.pointToLocalFrame(halfWay, pivotA); // The point-to-point constraint will keep a point shared between the bodies - - _this = _PointToPointConstrai.call(this, bodyA, pivotA, bodyB, pivotB, maxForce) || this; // Store initial rotation of the bodies as unit vectors in the local body spaces - - _this.xA = bodyA.vectorToLocalFrame(Vec3.UNIT_X); - _this.xB = bodyB.vectorToLocalFrame(Vec3.UNIT_X); - _this.yA = bodyA.vectorToLocalFrame(Vec3.UNIT_Y); - _this.yB = bodyB.vectorToLocalFrame(Vec3.UNIT_Y); - _this.zA = bodyA.vectorToLocalFrame(Vec3.UNIT_Z); - _this.zB = bodyB.vectorToLocalFrame(Vec3.UNIT_Z); // ...and the following rotational equations will keep all rotational DOF's in place - - var r1 = _this.rotationalEquation1 = new RotationalEquation(bodyA, bodyB, options); - var r2 = _this.rotationalEquation2 = new RotationalEquation(bodyA, bodyB, options); - var r3 = _this.rotationalEquation3 = new RotationalEquation(bodyA, bodyB, options); - - _this.equations.push(r1, r2, r3); - - return _this; - } - - var _proto = LockConstraint.prototype; - - _proto.update = function update() { - var bodyA = this.bodyA; - var bodyB = this.bodyB; - var motor = this.motorEquation; - var r1 = this.rotationalEquation1; - var r2 = this.rotationalEquation2; - var r3 = this.rotationalEquation3; - - _PointToPointConstrai.prototype.update.call(this); // These vector pairs must be orthogonal - - - bodyA.vectorToWorldFrame(this.xA, r1.axisA); - bodyB.vectorToWorldFrame(this.yB, r1.axisB); - bodyA.vectorToWorldFrame(this.yA, r2.axisA); - bodyB.vectorToWorldFrame(this.zB, r2.axisB); - bodyA.vectorToWorldFrame(this.zA, r3.axisA); - bodyB.vectorToWorldFrame(this.xB, r3.axisB); - }; - - return LockConstraint; -}(PointToPointConstraint); -var LockConstraint_update_tmpVec1 = new Vec3(); -var LockConstraint_update_tmpVec2 = new Vec3(); - -/** - * Rotational motor constraint. Tries to keep the relative angular velocity of the bodies to a given value. - * @class RotationalMotorEquation - * @constructor - * @author schteppe - * @param {Body} bodyA - * @param {Body} bodyB - * @param {Number} maxForce - * @extends Equation - */ -var RotationalMotorEquation = /*#__PURE__*/function (_Equation) { - _inheritsLoose(RotationalMotorEquation, _Equation); - - // World oriented rotational axis. - // World oriented rotational axis. - // Motor velocity. - function RotationalMotorEquation(bodyA, bodyB, maxForce) { - var _this; - - if (maxForce === void 0) { - maxForce = 1e6; - } - - _this = _Equation.call(this, bodyA, bodyB, -maxForce, maxForce) || this; - _this.axisA = new Vec3(); - _this.axisB = new Vec3(); - _this.targetVelocity = 0; - return _this; - } - - var _proto = RotationalMotorEquation.prototype; - - _proto.computeB = function computeB(h) { - var a = this.a; - var b = this.b; - var bi = this.bi; - var bj = this.bj; - var axisA = this.axisA; - var axisB = this.axisB; - var GA = this.jacobianElementA; - var GB = this.jacobianElementB; // g = 0 - // gdot = axisA * wi - axisB * wj - // gdot = G * W = G * [vi wi vj wj] - // => - // G = [0 axisA 0 -axisB] - - GA.rotational.copy(axisA); - axisB.negate(GB.rotational); - var GW = this.computeGW() - this.targetVelocity; - var GiMf = this.computeGiMf(); - var B = -GW * b - h * GiMf; - return B; - }; - - return RotationalMotorEquation; -}(Equation); - -/** - * Hinge constraint. Think of it as a door hinge. It tries to keep the door in the correct place and with the correct orientation. - * @class HingeConstraint - * @constructor - * @author schteppe - * @param {Body} bodyA - * @param {Body} bodyB - * @param {object} [options] - * @param {Vec3} [options.pivotA] A point defined locally in bodyA. This defines the offset of axisA. - * @param {Vec3} [options.axisA] An axis that bodyA can rotate around, defined locally in bodyA. - * @param {Vec3} [options.pivotB] - * @param {Vec3} [options.axisB] - * @param {Number} [options.maxForce=1e6] - * @extends PointToPointConstraint - */ -var HingeConstraint = /*#__PURE__*/function (_PointToPointConstrai) { - _inheritsLoose(HingeConstraint, _PointToPointConstrai); - - // Rotation axis, defined locally in bodyA. - // Rotation axis, defined locally in bodyB. - function HingeConstraint(bodyA, bodyB, options) { - var _this; - - if (options === void 0) { - options = {}; - } - - var maxForce = typeof options.maxForce !== 'undefined' ? options.maxForce : 1e6; - var pivotA = options.pivotA ? options.pivotA.clone() : new Vec3(); - var pivotB = options.pivotB ? options.pivotB.clone() : new Vec3(); - _this = _PointToPointConstrai.call(this, bodyA, pivotA, bodyB, pivotB, maxForce) || this; - var axisA = _this.axisA = options.axisA ? options.axisA.clone() : new Vec3(1, 0, 0); - axisA.normalize(); - var axisB = _this.axisB = options.axisB ? options.axisB.clone() : new Vec3(1, 0, 0); - axisB.normalize(); - _this.collideConnected = !!options.collideConnected; - var rotational1 = _this.rotationalEquation1 = new RotationalEquation(bodyA, bodyB, options); - var rotational2 = _this.rotationalEquation2 = new RotationalEquation(bodyA, bodyB, options); - var motor = _this.motorEquation = new RotationalMotorEquation(bodyA, bodyB, maxForce); - motor.enabled = false; // Not enabled by default - // Equations to be fed to the solver - - _this.equations.push(rotational1, rotational2, motor); - - return _this; - } - /** - * @method enableMotor - */ - - - var _proto = HingeConstraint.prototype; - - _proto.enableMotor = function enableMotor() { - this.motorEquation.enabled = true; - } - /** - * @method disableMotor - */ - ; - - _proto.disableMotor = function disableMotor() { - this.motorEquation.enabled = false; - } - /** - * @method setMotorSpeed - * @param {number} speed - */ - ; - - _proto.setMotorSpeed = function setMotorSpeed(speed) { - this.motorEquation.targetVelocity = speed; - } - /** - * @method setMotorMaxForce - * @param {number} maxForce - */ - ; - - _proto.setMotorMaxForce = function setMotorMaxForce(maxForce) { - this.motorEquation.maxForce = maxForce; - this.motorEquation.minForce = -maxForce; - }; - - _proto.update = function update() { - var bodyA = this.bodyA; - var bodyB = this.bodyB; - var motor = this.motorEquation; - var r1 = this.rotationalEquation1; - var r2 = this.rotationalEquation2; - var worldAxisA = HingeConstraint_update_tmpVec1; - var worldAxisB = HingeConstraint_update_tmpVec2; - var axisA = this.axisA; - var axisB = this.axisB; - - _PointToPointConstrai.prototype.update.call(this); // Get world axes - - - bodyA.quaternion.vmult(axisA, worldAxisA); - bodyB.quaternion.vmult(axisB, worldAxisB); - worldAxisA.tangents(r1.axisA, r2.axisA); - r1.axisB.copy(worldAxisB); - r2.axisB.copy(worldAxisB); - - if (this.motorEquation.enabled) { - bodyA.quaternion.vmult(this.axisA, motor.axisA); - bodyB.quaternion.vmult(this.axisB, motor.axisB); - } - }; - - return HingeConstraint; -}(PointToPointConstraint); -var HingeConstraint_update_tmpVec1 = new Vec3(); -var HingeConstraint_update_tmpVec2 = new Vec3(); - -/** - * Constrains the slipping in a contact along a tangent - * @class FrictionEquation - * @constructor - * @author schteppe - * @param {Body} bodyA - * @param {Body} bodyB - * @param {Number} slipForce should be +-F_friction = +-mu * F_normal = +-mu * m * g - * @extends Equation - */ -var FrictionEquation = /*#__PURE__*/function (_Equation) { - _inheritsLoose(FrictionEquation, _Equation); - - // Tangent. - function FrictionEquation(bodyA, bodyB, slipForce) { - var _this; - - _this = _Equation.call(this, bodyA, bodyB, -slipForce, slipForce) || this; - _this.ri = new Vec3(); - _this.rj = new Vec3(); - _this.t = new Vec3(); - return _this; - } - - var _proto = FrictionEquation.prototype; - - _proto.computeB = function computeB(h) { - var a = this.a; - var b = this.b; - var bi = this.bi; - var bj = this.bj; - var ri = this.ri; - var rj = this.rj; - var rixt = FrictionEquation_computeB_temp1; - var rjxt = FrictionEquation_computeB_temp2; - var t = this.t; // Caluclate cross products - - ri.cross(t, rixt); - rj.cross(t, rjxt); // G = [-t -rixt t rjxt] - // And remember, this is a pure velocity constraint, g is always zero! - - var GA = this.jacobianElementA; - var GB = this.jacobianElementB; - t.negate(GA.spatial); - rixt.negate(GA.rotational); - GB.spatial.copy(t); - GB.rotational.copy(rjxt); - var GW = this.computeGW(); - var GiMf = this.computeGiMf(); - var B = -GW * b - h * GiMf; - return B; - }; - - return FrictionEquation; -}(Equation); -var FrictionEquation_computeB_temp1 = new Vec3(); -var FrictionEquation_computeB_temp2 = new Vec3(); - -/** - * Defines what happens when two materials meet. - * @class ContactMaterial - * @constructor - * @param {Material} m1 - * @param {Material} m2 - * @param {object} [options] - * @param {Number} [options.friction=0.3] - * @param {Number} [options.restitution=0.3] - * @param {number} [options.contactEquationStiffness=1e7] - * @param {number} [options.contactEquationRelaxation=3] - * @param {number} [options.frictionEquationStiffness=1e7] - * @param {Number} [options.frictionEquationRelaxation=3] - * @todo Refactor materials to materialA and materialB - */ -var ContactMaterial = // Identifier of this material. -// Participating materials. -// Friction coefficient. -// Restitution coefficient. -// Stiffness of the produced contact equations. -// Relaxation time of the produced contact equations. -// Stiffness of the produced friction equations. -// Relaxation time of the produced friction equations -function ContactMaterial(m1, m2, options) { - options = Utils.defaults(options, { - friction: 0.3, - restitution: 0.3, - contactEquationStiffness: 1e7, - contactEquationRelaxation: 3, - frictionEquationStiffness: 1e7, - frictionEquationRelaxation: 3 - }); - this.id = ContactMaterial.idCounter++; - this.materials = [m1, m2]; - this.friction = options.friction; - this.restitution = options.restitution; - this.contactEquationStiffness = options.contactEquationStiffness; - this.contactEquationRelaxation = options.contactEquationRelaxation; - this.frictionEquationStiffness = options.frictionEquationStiffness; - this.frictionEquationRelaxation = options.frictionEquationRelaxation; -}; -ContactMaterial.idCounter = 0; - -/** - * Defines a physics material. - * @class Material - * @constructor - * @param {object} [options] - * @author schteppe - */ -var Material = // Material name. -// Material id. -// Friction for this material. If non-negative, it will be used instead of the friction given by ContactMaterials. If there's no matching ContactMaterial, the value from .defaultContactMaterial in the World will be used. -// Restitution for this material. If non-negative, it will be used instead of the restitution given by ContactMaterials. If there's no matching ContactMaterial, the value from .defaultContactMaterial in the World will be used. -function Material(options) { - if (options === void 0) { - options = {}; - } - - var name = ''; // Backwards compatibility fix - - if (typeof options === 'string') { - name = options; - options = {}; - } - - this.name = name; - this.id = Material.idCounter++; - this.friction = typeof options.friction !== 'undefined' ? options.friction : -1; - this.restitution = typeof options.restitution !== 'undefined' ? options.restitution : -1; -}; -Material.idCounter = 0; - -/** - * A spring, connecting two bodies. - * - * @class Spring - * @constructor - * @param {Body} bodyA - * @param {Body} bodyB - * @param {Object} [options] - * @param {number} [options.restLength] A number > 0. Default: 1 - * @param {number} [options.stiffness] A number >= 0. Default: 100 - * @param {number} [options.damping] A number >= 0. Default: 1 - * @param {Vec3} [options.worldAnchorA] Where to hook the spring to body A, in world coordinates. - * @param {Vec3} [options.worldAnchorB] - * @param {Vec3} [options.localAnchorA] Where to hook the spring to body A, in local body coordinates. - * @param {Vec3} [options.localAnchorB] - */ -var Spring = /*#__PURE__*/function () { - // Rest length of the spring. - // Stiffness of the spring. - // Damping of the spring. - // First connected body. - // Second connected body. - // Anchor for bodyA in local bodyA coordinates. - // Anchor for bodyB in local bodyB coordinates. - function Spring(bodyA, bodyB, options) { - if (options === void 0) { - options = {}; - } - - this.restLength = typeof options.restLength === 'number' ? options.restLength : 1; - this.stiffness = options.stiffness || 100; - this.damping = options.damping || 1; - this.bodyA = bodyA; - this.bodyB = bodyB; - this.localAnchorA = new Vec3(); - this.localAnchorB = new Vec3(); - - if (options.localAnchorA) { - this.localAnchorA.copy(options.localAnchorA); - } - - if (options.localAnchorB) { - this.localAnchorB.copy(options.localAnchorB); - } - - if (options.worldAnchorA) { - this.setWorldAnchorA(options.worldAnchorA); - } - - if (options.worldAnchorB) { - this.setWorldAnchorB(options.worldAnchorB); - } - } - /** - * Set the anchor point on body A, using world coordinates. - * @method setWorldAnchorA - * @param {Vec3} worldAnchorA - */ - - - var _proto = Spring.prototype; - - _proto.setWorldAnchorA = function setWorldAnchorA(worldAnchorA) { - this.bodyA.pointToLocalFrame(worldAnchorA, this.localAnchorA); - } - /** - * Set the anchor point on body B, using world coordinates. - * @method setWorldAnchorB - * @param {Vec3} worldAnchorB - */ - ; - - _proto.setWorldAnchorB = function setWorldAnchorB(worldAnchorB) { - this.bodyB.pointToLocalFrame(worldAnchorB, this.localAnchorB); - } - /** - * Get the anchor point on body A, in world coordinates. - * @method getWorldAnchorA - * @param {Vec3} result The vector to store the result in. - */ - ; - - _proto.getWorldAnchorA = function getWorldAnchorA(result) { - this.bodyA.pointToWorldFrame(this.localAnchorA, result); - } - /** - * Get the anchor point on body B, in world coordinates. - * @method getWorldAnchorB - * @param {Vec3} result The vector to store the result in. - */ - ; - - _proto.getWorldAnchorB = function getWorldAnchorB(result) { - this.bodyB.pointToWorldFrame(this.localAnchorB, result); - } - /** - * Apply the spring force to the connected bodies. - * @method applyForce - */ - ; - - _proto.applyForce = function applyForce() { - var k = this.stiffness; - var d = this.damping; - var l = this.restLength; - var bodyA = this.bodyA; - var bodyB = this.bodyB; - var r = applyForce_r; - var r_unit = applyForce_r_unit; - var u = applyForce_u; - var f = applyForce_f; - var tmp = applyForce_tmp; - var worldAnchorA = applyForce_worldAnchorA; - var worldAnchorB = applyForce_worldAnchorB; - var ri = applyForce_ri; - var rj = applyForce_rj; - var ri_x_f = applyForce_ri_x_f; - var rj_x_f = applyForce_rj_x_f; // Get world anchors - - this.getWorldAnchorA(worldAnchorA); - this.getWorldAnchorB(worldAnchorB); // Get offset points - - worldAnchorA.vsub(bodyA.position, ri); - worldAnchorB.vsub(bodyB.position, rj); // Compute distance vector between world anchor points - - worldAnchorB.vsub(worldAnchorA, r); - var rlen = r.length(); - r_unit.copy(r); - r_unit.normalize(); // Compute relative velocity of the anchor points, u - - bodyB.velocity.vsub(bodyA.velocity, u); // Add rotational velocity - - bodyB.angularVelocity.cross(rj, tmp); - u.vadd(tmp, u); - bodyA.angularVelocity.cross(ri, tmp); - u.vsub(tmp, u); // F = - k * ( x - L ) - D * ( u ) - - r_unit.scale(-k * (rlen - l) - d * u.dot(r_unit), f); // Add forces to bodies - - bodyA.force.vsub(f, bodyA.force); - bodyB.force.vadd(f, bodyB.force); // Angular force - - ri.cross(f, ri_x_f); - rj.cross(f, rj_x_f); - bodyA.torque.vsub(ri_x_f, bodyA.torque); - bodyB.torque.vadd(rj_x_f, bodyB.torque); - }; - - return Spring; -}(); -var applyForce_r = new Vec3(); -var applyForce_r_unit = new Vec3(); -var applyForce_u = new Vec3(); -var applyForce_f = new Vec3(); -var applyForce_worldAnchorA = new Vec3(); -var applyForce_worldAnchorB = new Vec3(); -var applyForce_ri = new Vec3(); -var applyForce_rj = new Vec3(); -var applyForce_ri_x_f = new Vec3(); -var applyForce_rj_x_f = new Vec3(); -var applyForce_tmp = new Vec3(); - -/** - * @class WheelInfo - * @constructor - * @param {Object} [options] - * - * @param {Vec3} [options.chassisConnectionPointLocal] - * @param {Vec3} [options.chassisConnectionPointWorld] - * @param {Vec3} [options.directionLocal] - * @param {Vec3} [options.directionWorld] - * @param {Vec3} [options.axleLocal] - * @param {Vec3} [options.axleWorld] - * @param {number} [options.suspensionRestLength=1] - * @param {number} [options.suspensionMaxLength=2] - * @param {number} [options.radius=1] - * @param {number} [options.suspensionStiffness=100] - * @param {number} [options.dampingCompression=10] - * @param {number} [options.dampingRelaxation=10] - * @param {number} [options.frictionSlip=10000] - * @param {number} [options.steering=0] - * @param {number} [options.rotation=0] - * @param {number} [options.deltaRotation=0] - * @param {number} [options.rollInfluence=0.01] - * @param {number} [options.maxSuspensionForce] - * @param {boolean} [options.isFrontWheel=true] - * @param {number} [options.clippedInvContactDotSuspension=1] - * @param {number} [options.suspensionRelativeVelocity=0] - * @param {number} [options.suspensionForce=0] - * @param {number} [options.skidInfo=0] - * @param {number} [options.suspensionLength=0] - * @param {number} [options.maxSuspensionTravel=1] - * @param {boolean} [options.useCustomSlidingRotationalSpeed=false] - * @param {number} [options.customSlidingRotationalSpeed=-0.1] - */ -var WheelInfo = /*#__PURE__*/function () { - // Max travel distance of the suspension, in meters. - // Speed to apply to the wheel rotation when the wheel is sliding. - // If the customSlidingRotationalSpeed should be used. - // Connection point, defined locally in the chassis body frame. - // Rotation value, in radians. - // The result from raycasting. - // Wheel world transform. - function WheelInfo(options) { - if (options === void 0) { - options = {}; - } - - options = Utils.defaults(options, { - chassisConnectionPointLocal: new Vec3(), - chassisConnectionPointWorld: new Vec3(), - directionLocal: new Vec3(), - directionWorld: new Vec3(), - axleLocal: new Vec3(), - axleWorld: new Vec3(), - suspensionRestLength: 1, - suspensionMaxLength: 2, - radius: 1, - suspensionStiffness: 100, - dampingCompression: 10, - dampingRelaxation: 10, - frictionSlip: 10000, - steering: 0, - rotation: 0, - deltaRotation: 0, - rollInfluence: 0.01, - maxSuspensionForce: Number.MAX_VALUE, - isFrontWheel: true, - clippedInvContactDotSuspension: 1, - suspensionRelativeVelocity: 0, - suspensionForce: 0, - slipInfo: 0, - skidInfo: 0, - suspensionLength: 0, - maxSuspensionTravel: 1, - useCustomSlidingRotationalSpeed: false, - customSlidingRotationalSpeed: -0.1 - }); - this.maxSuspensionTravel = options.maxSuspensionTravel; - this.customSlidingRotationalSpeed = options.customSlidingRotationalSpeed; - this.useCustomSlidingRotationalSpeed = options.useCustomSlidingRotationalSpeed; - this.sliding = false; - this.chassisConnectionPointLocal = options.chassisConnectionPointLocal.clone(); - this.chassisConnectionPointWorld = options.chassisConnectionPointWorld.clone(); - this.directionLocal = options.directionLocal.clone(); - this.directionWorld = options.directionWorld.clone(); - this.axleLocal = options.axleLocal.clone(); - this.axleWorld = options.axleWorld.clone(); - this.suspensionRestLength = options.suspensionRestLength; - this.suspensionMaxLength = options.suspensionMaxLength; - this.radius = options.radius; - this.suspensionStiffness = options.suspensionStiffness; - this.dampingCompression = options.dampingCompression; - this.dampingRelaxation = options.dampingRelaxation; - this.frictionSlip = options.frictionSlip; - this.steering = 0; - this.rotation = 0; - this.deltaRotation = 0; - this.rollInfluence = options.rollInfluence; - this.maxSuspensionForce = options.maxSuspensionForce; - this.engineForce = 0; - this.brake = 0; - this.isFrontWheel = options.isFrontWheel; - this.clippedInvContactDotSuspension = 1; - this.suspensionRelativeVelocity = 0; - this.suspensionForce = 0; - this.slipInfo = 0; - this.skidInfo = 0; - this.suspensionLength = 0; - this.sideImpulse = 0; - this.forwardImpulse = 0; - this.raycastResult = new RaycastResult(); - this.worldTransform = new Transform(); - this.isInContact = false; - } - - var _proto = WheelInfo.prototype; - - _proto.updateWheel = function updateWheel(chassis) { - var raycastResult = this.raycastResult; - - if (this.isInContact) { - var project = raycastResult.hitNormalWorld.dot(raycastResult.directionWorld); - raycastResult.hitPointWorld.vsub(chassis.position, relpos); - chassis.getVelocityAtWorldPoint(relpos, chassis_velocity_at_contactPoint); - var projVel = raycastResult.hitNormalWorld.dot(chassis_velocity_at_contactPoint); - - if (project >= -0.1) { - this.suspensionRelativeVelocity = 0.0; - this.clippedInvContactDotSuspension = 1.0 / 0.1; - } else { - var inv = -1 / project; - this.suspensionRelativeVelocity = projVel * inv; - this.clippedInvContactDotSuspension = inv; - } - } else { - // Not in contact : position wheel in a nice (rest length) position - raycastResult.suspensionLength = this.suspensionRestLength; - this.suspensionRelativeVelocity = 0.0; - raycastResult.directionWorld.scale(-1, raycastResult.hitNormalWorld); - this.clippedInvContactDotSuspension = 1.0; - } - }; - - return WheelInfo; -}(); -var chassis_velocity_at_contactPoint = new Vec3(); -var relpos = new Vec3(); - -/** - * Vehicle helper class that casts rays from the wheel positions towards the ground and applies forces. - * @class RaycastVehicle - * @constructor - * @param {object} [options] - * @param {Body} [options.chassisBody] The car chassis body. - * @param {integer} [options.indexRightAxis] Axis to use for right. x=0, y=1, z=2 - * @param {integer} [options.indexLeftAxis] - * @param {integer} [options.indexUpAxis] - */ -var RaycastVehicle = /*#__PURE__*/function () { - // Will be set to true if the car is sliding. - // Index of the right axis, 0=x, 1=y, 2=z - // Index of the forward axis, 0=x, 1=y, 2=z - // Index of the up axis, 0=x, 1=y, 2=z - function RaycastVehicle(options) { - this.chassisBody = options.chassisBody; - this.wheelInfos = []; - this.sliding = false; - this.world = null; - this.indexRightAxis = typeof options.indexRightAxis !== 'undefined' ? options.indexRightAxis : 1; - this.indexForwardAxis = typeof options.indexForwardAxis !== 'undefined' ? options.indexForwardAxis : 0; - this.indexUpAxis = typeof options.indexUpAxis !== 'undefined' ? options.indexUpAxis : 2; - this.constraints = []; - - this.preStepCallback = function () {}; - - this.currentVehicleSpeedKmHour = 0; - } - /** - * Add a wheel. For information about the options, see WheelInfo. - * @method addWheel - * @param {object} [options] - */ - - - var _proto = RaycastVehicle.prototype; - - _proto.addWheel = function addWheel(options) { - if (options === void 0) { - options = {}; - } - - var info = new WheelInfo(options); - var index = this.wheelInfos.length; - this.wheelInfos.push(info); - return index; - } - /** - * Set the steering value of a wheel. - * @method setSteeringValue - * @param {number} value - * @param {integer} wheelIndex - */ - ; - - _proto.setSteeringValue = function setSteeringValue(value, wheelIndex) { - var wheel = this.wheelInfos[wheelIndex]; - wheel.steering = value; - } - /** - * Set the wheel force to apply on one of the wheels each time step - * @method applyEngineForce - * @param {number} value - * @param {integer} wheelIndex - */ - ; - - _proto.applyEngineForce = function applyEngineForce(value, wheelIndex) { - this.wheelInfos[wheelIndex].engineForce = value; - } - /** - * Set the braking force of a wheel - * @method setBrake - * @param {number} brake - * @param {integer} wheelIndex - */ - ; - - _proto.setBrake = function setBrake(brake, wheelIndex) { - this.wheelInfos[wheelIndex].brake = brake; - } - /** - * Add the vehicle including its constraints to the world. - * @method addToWorld - * @param {World} world - */ - ; - - _proto.addToWorld = function addToWorld(world) { - var constraints = this.constraints; - world.addBody(this.chassisBody); - var that = this; - - this.preStepCallback = function () { - that.updateVehicle(world.dt); - }; - - world.addEventListener('preStep', this.preStepCallback); - this.world = world; - } - /** - * Get one of the wheel axles, world-oriented. - * @private - * @method getVehicleAxisWorld - * @param {integer} axisIndex - * @param {Vec3} result - */ - ; - - _proto.getVehicleAxisWorld = function getVehicleAxisWorld(axisIndex, result) { - result.set(axisIndex === 0 ? 1 : 0, axisIndex === 1 ? 1 : 0, axisIndex === 2 ? 1 : 0); - this.chassisBody.vectorToWorldFrame(result, result); - }; - - _proto.updateVehicle = function updateVehicle(timeStep) { - var wheelInfos = this.wheelInfos; - var numWheels = wheelInfos.length; - var chassisBody = this.chassisBody; - - for (var i = 0; i < numWheels; i++) { - this.updateWheelTransform(i); - } - - this.currentVehicleSpeedKmHour = 3.6 * chassisBody.velocity.length(); - var forwardWorld = new Vec3(); - this.getVehicleAxisWorld(this.indexForwardAxis, forwardWorld); - - if (forwardWorld.dot(chassisBody.velocity) < 0) { - this.currentVehicleSpeedKmHour *= -1; - } // simulate suspension - - - for (var _i = 0; _i < numWheels; _i++) { - this.castRay(wheelInfos[_i]); - } - - this.updateSuspension(timeStep); - var impulse = new Vec3(); - var relpos = new Vec3(); - - for (var _i2 = 0; _i2 < numWheels; _i2++) { - //apply suspension force - var wheel = wheelInfos[_i2]; - var suspensionForce = wheel.suspensionForce; - - if (suspensionForce > wheel.maxSuspensionForce) { - suspensionForce = wheel.maxSuspensionForce; - } - - wheel.raycastResult.hitNormalWorld.scale(suspensionForce * timeStep, impulse); - wheel.raycastResult.hitPointWorld.vsub(chassisBody.position, relpos); - chassisBody.applyImpulse(impulse, relpos); - } - - this.updateFriction(timeStep); - var hitNormalWorldScaledWithProj = new Vec3(); - var fwd = new Vec3(); - var vel = new Vec3(); - - for (var _i3 = 0; _i3 < numWheels; _i3++) { - var _wheel = wheelInfos[_i3]; //const relpos = new Vec3(); - //wheel.chassisConnectionPointWorld.vsub(chassisBody.position, relpos); - - chassisBody.getVelocityAtWorldPoint(_wheel.chassisConnectionPointWorld, vel); // Hack to get the rotation in the correct direction - - var m = 1; - - switch (this.indexUpAxis) { - case 1: - m = -1; - break; - } - - if (_wheel.isInContact) { - this.getVehicleAxisWorld(this.indexForwardAxis, fwd); - var proj = fwd.dot(_wheel.raycastResult.hitNormalWorld); - - _wheel.raycastResult.hitNormalWorld.scale(proj, hitNormalWorldScaledWithProj); - - fwd.vsub(hitNormalWorldScaledWithProj, fwd); - var proj2 = fwd.dot(vel); - _wheel.deltaRotation = m * proj2 * timeStep / _wheel.radius; - } - - if ((_wheel.sliding || !_wheel.isInContact) && _wheel.engineForce !== 0 && _wheel.useCustomSlidingRotationalSpeed) { - // Apply custom rotation when accelerating and sliding - _wheel.deltaRotation = (_wheel.engineForce > 0 ? 1 : -1) * _wheel.customSlidingRotationalSpeed * timeStep; - } // Lock wheels - - - if (Math.abs(_wheel.brake) > Math.abs(_wheel.engineForce)) { - _wheel.deltaRotation = 0; - } - - _wheel.rotation += _wheel.deltaRotation; // Use the old value - - _wheel.deltaRotation *= 0.99; // damping of rotation when not in contact - } - }; - - _proto.updateSuspension = function updateSuspension(deltaTime) { - var chassisBody = this.chassisBody; - var chassisMass = chassisBody.mass; - var wheelInfos = this.wheelInfos; - var numWheels = wheelInfos.length; - - for (var w_it = 0; w_it < numWheels; w_it++) { - var wheel = wheelInfos[w_it]; - - if (wheel.isInContact) { - var force = void 0; // Spring - - var susp_length = wheel.suspensionRestLength; - var current_length = wheel.suspensionLength; - var length_diff = susp_length - current_length; - force = wheel.suspensionStiffness * length_diff * wheel.clippedInvContactDotSuspension; // Damper - - var projected_rel_vel = wheel.suspensionRelativeVelocity; - var susp_damping = void 0; - - if (projected_rel_vel < 0) { - susp_damping = wheel.dampingCompression; - } else { - susp_damping = wheel.dampingRelaxation; - } - - force -= susp_damping * projected_rel_vel; - wheel.suspensionForce = force * chassisMass; - - if (wheel.suspensionForce < 0) { - wheel.suspensionForce = 0; - } - } else { - wheel.suspensionForce = 0; - } - } - } - /** - * Remove the vehicle including its constraints from the world. - * @method removeFromWorld - * @param {World} world - */ - ; - - _proto.removeFromWorld = function removeFromWorld(world) { - var constraints = this.constraints; - world.removeBody(this.chassisBody); - world.removeEventListener('preStep', this.preStepCallback); - this.world = null; - }; - - _proto.castRay = function castRay(wheel) { - var rayvector = castRay_rayvector; - var target = castRay_target; - this.updateWheelTransformWorld(wheel); - var chassisBody = this.chassisBody; - var depth = -1; - var raylen = wheel.suspensionRestLength + wheel.radius; - wheel.directionWorld.scale(raylen, rayvector); - var source = wheel.chassisConnectionPointWorld; - source.vadd(rayvector, target); - var raycastResult = wheel.raycastResult; - raycastResult.reset(); // Turn off ray collision with the chassis temporarily - - var oldState = chassisBody.collisionResponse; - chassisBody.collisionResponse = false; // Cast ray against world - - this.world.rayTest(source, target, raycastResult); - chassisBody.collisionResponse = oldState; - var object = raycastResult.body; - wheel.raycastResult.groundObject = 0; - - if (object) { - depth = raycastResult.distance; - wheel.raycastResult.hitNormalWorld = raycastResult.hitNormalWorld; - wheel.isInContact = true; - var hitDistance = raycastResult.distance; - wheel.suspensionLength = hitDistance - wheel.radius; // clamp on max suspension travel - - var minSuspensionLength = wheel.suspensionRestLength - wheel.maxSuspensionTravel; - var maxSuspensionLength = wheel.suspensionRestLength + wheel.maxSuspensionTravel; - - if (wheel.suspensionLength < minSuspensionLength) { - wheel.suspensionLength = minSuspensionLength; - } - - if (wheel.suspensionLength > maxSuspensionLength) { - wheel.suspensionLength = maxSuspensionLength; - wheel.raycastResult.reset(); - } - - var denominator = wheel.raycastResult.hitNormalWorld.dot(wheel.directionWorld); - var chassis_velocity_at_contactPoint = new Vec3(); - chassisBody.getVelocityAtWorldPoint(wheel.raycastResult.hitPointWorld, chassis_velocity_at_contactPoint); - var projVel = wheel.raycastResult.hitNormalWorld.dot(chassis_velocity_at_contactPoint); - - if (denominator >= -0.1) { - wheel.suspensionRelativeVelocity = 0; - wheel.clippedInvContactDotSuspension = 1 / 0.1; - } else { - var inv = -1 / denominator; - wheel.suspensionRelativeVelocity = projVel * inv; - wheel.clippedInvContactDotSuspension = inv; - } - } else { - //put wheel info as in rest position - wheel.suspensionLength = wheel.suspensionRestLength + 0 * wheel.maxSuspensionTravel; - wheel.suspensionRelativeVelocity = 0.0; - wheel.directionWorld.scale(-1, wheel.raycastResult.hitNormalWorld); - wheel.clippedInvContactDotSuspension = 1.0; - } - - return depth; - }; - - _proto.updateWheelTransformWorld = function updateWheelTransformWorld(wheel) { - wheel.isInContact = false; - var chassisBody = this.chassisBody; - chassisBody.pointToWorldFrame(wheel.chassisConnectionPointLocal, wheel.chassisConnectionPointWorld); - chassisBody.vectorToWorldFrame(wheel.directionLocal, wheel.directionWorld); - chassisBody.vectorToWorldFrame(wheel.axleLocal, wheel.axleWorld); - } - /** - * Update one of the wheel transform. - * Note when rendering wheels: during each step, wheel transforms are updated BEFORE the chassis; ie. their position becomes invalid after the step. Thus when you render wheels, you must update wheel transforms before rendering them. See raycastVehicle demo for an example. - * @method updateWheelTransform - * @param {integer} wheelIndex The wheel index to update. - */ - ; - - _proto.updateWheelTransform = function updateWheelTransform(wheelIndex) { - var up = tmpVec4; - var right = tmpVec5; - var fwd = tmpVec6; - var wheel = this.wheelInfos[wheelIndex]; - this.updateWheelTransformWorld(wheel); - wheel.directionLocal.scale(-1, up); - right.copy(wheel.axleLocal); - up.cross(right, fwd); - fwd.normalize(); - right.normalize(); // Rotate around steering over the wheelAxle - - var steering = wheel.steering; - var steeringOrn = new Quaternion(); - steeringOrn.setFromAxisAngle(up, steering); - var rotatingOrn = new Quaternion(); - rotatingOrn.setFromAxisAngle(right, wheel.rotation); // World rotation of the wheel - - var q = wheel.worldTransform.quaternion; - this.chassisBody.quaternion.mult(steeringOrn, q); - q.mult(rotatingOrn, q); - q.normalize(); // world position of the wheel - - var p = wheel.worldTransform.position; - p.copy(wheel.directionWorld); - p.scale(wheel.suspensionLength, p); - p.vadd(wheel.chassisConnectionPointWorld, p); - } - /** - * Get the world transform of one of the wheels - * @method getWheelTransformWorld - * @param {integer} wheelIndex - * @return {Transform} - */ - ; - - _proto.getWheelTransformWorld = function getWheelTransformWorld(wheelIndex) { - return this.wheelInfos[wheelIndex].worldTransform; - }; - - _proto.updateFriction = function updateFriction(timeStep) { - var surfNormalWS_scaled_proj = updateFriction_surfNormalWS_scaled_proj; //calculate the impulse, so that the wheels don't move sidewards - - var wheelInfos = this.wheelInfos; - var numWheels = wheelInfos.length; - var chassisBody = this.chassisBody; - var forwardWS = updateFriction_forwardWS; - var axle = updateFriction_axle; - - for (var i = 0; i < numWheels; i++) { - var wheel = wheelInfos[i]; - var groundObject = wheel.raycastResult.body; - - wheel.sideImpulse = 0; - wheel.forwardImpulse = 0; - - if (!forwardWS[i]) { - forwardWS[i] = new Vec3(); - } - - if (!axle[i]) { - axle[i] = new Vec3(); - } - } - - for (var _i4 = 0; _i4 < numWheels; _i4++) { - var _wheel2 = wheelInfos[_i4]; - var _groundObject = _wheel2.raycastResult.body; - - if (_groundObject) { - var axlei = axle[_i4]; - var wheelTrans = this.getWheelTransformWorld(_i4); // Get world axle - - wheelTrans.vectorToWorldFrame(directions[this.indexRightAxis], axlei); - var surfNormalWS = _wheel2.raycastResult.hitNormalWorld; - var proj = axlei.dot(surfNormalWS); - surfNormalWS.scale(proj, surfNormalWS_scaled_proj); - axlei.vsub(surfNormalWS_scaled_proj, axlei); - axlei.normalize(); - surfNormalWS.cross(axlei, forwardWS[_i4]); - - forwardWS[_i4].normalize(); - - _wheel2.sideImpulse = resolveSingleBilateral(chassisBody, _wheel2.raycastResult.hitPointWorld, _groundObject, _wheel2.raycastResult.hitPointWorld, axlei); - _wheel2.sideImpulse *= sideFrictionStiffness2; - } - } - - var sideFactor = 1; - var fwdFactor = 0.5; - this.sliding = false; - - for (var _i5 = 0; _i5 < numWheels; _i5++) { - var _wheel3 = wheelInfos[_i5]; - var _groundObject2 = _wheel3.raycastResult.body; - var rollingFriction = 0; - _wheel3.slipInfo = 1; - - if (_groundObject2) { - var defaultRollingFrictionImpulse = 0; - var maxImpulse = _wheel3.brake ? _wheel3.brake : defaultRollingFrictionImpulse; // btWheelContactPoint contactPt(chassisBody,groundObject,wheelInfraycastInfo.hitPointWorld,forwardWS[wheel],maxImpulse); - // rollingFriction = calcRollingFriction(contactPt); - - rollingFriction = calcRollingFriction(chassisBody, _groundObject2, _wheel3.raycastResult.hitPointWorld, forwardWS[_i5], maxImpulse); - rollingFriction += _wheel3.engineForce * timeStep; // rollingFriction = 0; - - var factor = maxImpulse / rollingFriction; - _wheel3.slipInfo *= factor; - } //switch between active rolling (throttle), braking and non-active rolling friction (nthrottle/break) - - - _wheel3.forwardImpulse = 0; - _wheel3.skidInfo = 1; - - if (_groundObject2) { - _wheel3.skidInfo = 1; - var maximp = _wheel3.suspensionForce * timeStep * _wheel3.frictionSlip; - var maximpSide = maximp; - var maximpSquared = maximp * maximpSide; - _wheel3.forwardImpulse = rollingFriction; //wheelInfo.engineForce* timeStep; - - var x = _wheel3.forwardImpulse * fwdFactor; - var y = _wheel3.sideImpulse * sideFactor; - var impulseSquared = x * x + y * y; - _wheel3.sliding = false; - - if (impulseSquared > maximpSquared) { - this.sliding = true; - _wheel3.sliding = true; - - var _factor = maximp / Math.sqrt(impulseSquared); - - _wheel3.skidInfo *= _factor; - } - } - } - - if (this.sliding) { - for (var _i6 = 0; _i6 < numWheels; _i6++) { - var _wheel4 = wheelInfos[_i6]; - - if (_wheel4.sideImpulse !== 0) { - if (_wheel4.skidInfo < 1) { - _wheel4.forwardImpulse *= _wheel4.skidInfo; - _wheel4.sideImpulse *= _wheel4.skidInfo; - } - } - } - } // apply the impulses - - - for (var _i7 = 0; _i7 < numWheels; _i7++) { - var _wheel5 = wheelInfos[_i7]; - var rel_pos = new Vec3(); - - _wheel5.raycastResult.hitPointWorld.vsub(chassisBody.position, rel_pos); // cannons applyimpulse is using world coord for the position - //rel_pos.copy(wheel.raycastResult.hitPointWorld); - - - if (_wheel5.forwardImpulse !== 0) { - var impulse = new Vec3(); - - forwardWS[_i7].scale(_wheel5.forwardImpulse, impulse); - - chassisBody.applyImpulse(impulse, rel_pos); - } - - if (_wheel5.sideImpulse !== 0) { - var _groundObject3 = _wheel5.raycastResult.body; - var rel_pos2 = new Vec3(); - - _wheel5.raycastResult.hitPointWorld.vsub(_groundObject3.position, rel_pos2); //rel_pos2.copy(wheel.raycastResult.hitPointWorld); - - - var sideImp = new Vec3(); - - axle[_i7].scale(_wheel5.sideImpulse, sideImp); // Scale the relative position in the up direction with rollInfluence. - // If rollInfluence is 1, the impulse will be applied on the hitPoint (easy to roll over), if it is zero it will be applied in the same plane as the center of mass (not easy to roll over). - - - chassisBody.vectorToLocalFrame(rel_pos, rel_pos); - rel_pos['xyz'[this.indexUpAxis]] *= _wheel5.rollInfluence; - chassisBody.vectorToWorldFrame(rel_pos, rel_pos); - chassisBody.applyImpulse(sideImp, rel_pos); //apply friction impulse on the ground - - sideImp.scale(-1, sideImp); - - _groundObject3.applyImpulse(sideImp, rel_pos2); - } - } - }; - - return RaycastVehicle; -}(); -var tmpVec1$2 = new Vec3(); -var tmpVec2$2 = new Vec3(); -var tmpVec3 = new Vec3(); -var tmpVec4 = new Vec3(); -var tmpVec5 = new Vec3(); -var tmpVec6 = new Vec3(); -var tmpRay = new Ray(); -var torque = new Vec3(); -var castRay_rayvector = new Vec3(); -var castRay_target = new Vec3(); -var directions = [new Vec3(1, 0, 0), new Vec3(0, 1, 0), new Vec3(0, 0, 1)]; -var updateFriction_surfNormalWS_scaled_proj = new Vec3(); -var updateFriction_axle = []; -var updateFriction_forwardWS = []; -var sideFrictionStiffness2 = 1; -var calcRollingFriction_vel1 = new Vec3(); -var calcRollingFriction_vel2 = new Vec3(); -var calcRollingFriction_vel = new Vec3(); - -function calcRollingFriction(body0, body1, frictionPosWorld, frictionDirectionWorld, maxImpulse) { - var j1 = 0; - var contactPosWorld = frictionPosWorld; // const rel_pos1 = new Vec3(); - // const rel_pos2 = new Vec3(); - - var vel1 = calcRollingFriction_vel1; - var vel2 = calcRollingFriction_vel2; - var vel = calcRollingFriction_vel; // contactPosWorld.vsub(body0.position, rel_pos1); - // contactPosWorld.vsub(body1.position, rel_pos2); - - body0.getVelocityAtWorldPoint(contactPosWorld, vel1); - body1.getVelocityAtWorldPoint(contactPosWorld, vel2); - vel1.vsub(vel2, vel); - var vrel = frictionDirectionWorld.dot(vel); - var denom0 = computeImpulseDenominator(body0, frictionPosWorld, frictionDirectionWorld); - var denom1 = computeImpulseDenominator(body1, frictionPosWorld, frictionDirectionWorld); - var relaxation = 1; - var jacDiagABInv = relaxation / (denom0 + denom1); // calculate j that moves us to zero relative velocity - - j1 = -vrel * jacDiagABInv; - - if (maxImpulse < j1) { - j1 = maxImpulse; - } - - if (j1 < -maxImpulse) { - j1 = -maxImpulse; - } - - return j1; -} - -var computeImpulseDenominator_r0 = new Vec3(); -var computeImpulseDenominator_c0 = new Vec3(); -var computeImpulseDenominator_vec = new Vec3(); -var computeImpulseDenominator_m = new Vec3(); - -function computeImpulseDenominator(body, pos, normal) { - var r0 = computeImpulseDenominator_r0; - var c0 = computeImpulseDenominator_c0; - var vec = computeImpulseDenominator_vec; - var m = computeImpulseDenominator_m; - pos.vsub(body.position, r0); - r0.cross(normal, c0); - body.invInertiaWorld.vmult(c0, m); - m.cross(r0, vec); - return body.invMass + normal.dot(vec); -} - -var resolveSingleBilateral_vel1 = new Vec3(); -var resolveSingleBilateral_vel2 = new Vec3(); -var resolveSingleBilateral_vel = new Vec3(); //bilateral constraint between two dynamic objects - -function resolveSingleBilateral(body1, pos1, body2, pos2, normal) { - var normalLenSqr = normal.lengthSquared(); - - if (normalLenSqr > 1.1) { - return 0; // no impulse - } // const rel_pos1 = new Vec3(); - // const rel_pos2 = new Vec3(); - // pos1.vsub(body1.position, rel_pos1); - // pos2.vsub(body2.position, rel_pos2); - - - var vel1 = resolveSingleBilateral_vel1; - var vel2 = resolveSingleBilateral_vel2; - var vel = resolveSingleBilateral_vel; - body1.getVelocityAtWorldPoint(pos1, vel1); - body2.getVelocityAtWorldPoint(pos2, vel2); - vel1.vsub(vel2, vel); - var rel_vel = normal.dot(vel); - var contactDamping = 0.2; - var massTerm = 1 / (body1.invMass + body2.invMass); - var impulse = -contactDamping * rel_vel * massTerm; - return impulse; -} - -/** - * Spherical shape - * @class Sphere - * @constructor - * @extends Shape - * @param {Number} radius The radius of the sphere, a non-negative number. - * @author schteppe / http://github.com/schteppe - */ -var Sphere = /*#__PURE__*/function (_Shape) { - _inheritsLoose(Sphere, _Shape); - - function Sphere(radius) { - var _this; - - _this = _Shape.call(this, { - type: Shape.types.SPHERE - }) || this; - _this.radius = radius !== undefined ? radius : 1.0; - - if (_this.radius < 0) { - throw new Error('The sphere radius cannot be negative.'); - } - - _this.updateBoundingSphereRadius(); - - return _this; - } - - var _proto = Sphere.prototype; - - _proto.calculateLocalInertia = function calculateLocalInertia(mass, target) { - if (target === void 0) { - target = new Vec3(); - } - - var I = 2.0 * mass * this.radius * this.radius / 5.0; - target.x = I; - target.y = I; - target.z = I; - return target; - }; - - _proto.volume = function volume() { - return 4.0 * Math.PI * Math.pow(this.radius, 3) / 3.0; - }; - - _proto.updateBoundingSphereRadius = function updateBoundingSphereRadius() { - this.boundingSphereRadius = this.radius; - }; - - _proto.calculateWorldAABB = function calculateWorldAABB(pos, quat, min, max) { - var r = this.radius; - var axes = ['x', 'y', 'z']; - - for (var i = 0; i < axes.length; i++) { - var ax = axes[i]; - min[ax] = pos[ax] - r; - max[ax] = pos[ax] + r; - } - }; - - return Sphere; -}(Shape); - -/** - * Simple vehicle helper class with spherical rigid body wheels. - * @class RigidVehicle - * @constructor - * @param {Body} [options.chassisBody] - */ -var RigidVehicle = /*#__PURE__*/function () { - function RigidVehicle(options) { - if (options === void 0) { - options = {}; - } - - this.wheelBodies = []; - this.coordinateSystem = typeof options.coordinateSystem !== 'undefined' ? options.coordinateSystem.clone() : new Vec3(1, 2, 3); - - if (options.chassisBody) { - this.chassisBody = options.chassisBody; - } else { - // No chassis body given. Create it! - this.chassisBody = new Body({ - mass: 1, - shape: new Box(new Vec3(5, 2, 0.5)) - }); - } - - this.constraints = []; - this.wheelAxes = []; - this.wheelForces = []; - } - /** - * Add a wheel - * @method addWheel - * @param {object} options - * @param {boolean} [options.isFrontWheel] - * @param {Vec3} [options.position] Position of the wheel, locally in the chassis body. - * @param {Vec3} [options.direction] Slide direction of the wheel along the suspension. - * @param {Vec3} [options.axis] Axis of rotation of the wheel, locally defined in the chassis. - * @param {Body} [options.body] The wheel body. - */ - - - var _proto = RigidVehicle.prototype; - - _proto.addWheel = function addWheel(options) { - if (options === void 0) { - options = {}; - } - - var wheelBody; - - if (options.body) { - wheelBody = options.body; - } else { - // No wheel body given. Create it! - wheelBody = new Body({ - mass: 1, - shape: new Sphere(1.2) - }); - } - - this.wheelBodies.push(wheelBody); - this.wheelForces.push(0); // Position constrain wheels - - var zero = new Vec3(); - var position = typeof options.position !== 'undefined' ? options.position.clone() : new Vec3(); // Set position locally to the chassis - - var worldPosition = new Vec3(); - this.chassisBody.pointToWorldFrame(position, worldPosition); - wheelBody.position.set(worldPosition.x, worldPosition.y, worldPosition.z); // Constrain wheel - - var axis = typeof options.axis !== 'undefined' ? options.axis.clone() : new Vec3(0, 1, 0); - this.wheelAxes.push(axis); - var hingeConstraint = new HingeConstraint(this.chassisBody, wheelBody, { - pivotA: position, - axisA: axis, - pivotB: Vec3.ZERO, - axisB: axis, - collideConnected: false - }); - this.constraints.push(hingeConstraint); - return this.wheelBodies.length - 1; - } - /** - * Set the steering value of a wheel. - * @method setSteeringValue - * @param {number} value - * @param {integer} wheelIndex - * @todo check coordinateSystem - */ - ; - - _proto.setSteeringValue = function setSteeringValue(value, wheelIndex) { - // Set angle of the hinge axis - var axis = this.wheelAxes[wheelIndex]; - var c = Math.cos(value); - var s = Math.sin(value); - var x = axis.x; - var y = axis.y; - this.constraints[wheelIndex].axisA.set(c * x - s * y, s * x + c * y, 0); - } - /** - * Set the target rotational speed of the hinge constraint. - * @method setMotorSpeed - * @param {number} value - * @param {integer} wheelIndex - */ - ; - - _proto.setMotorSpeed = function setMotorSpeed(value, wheelIndex) { - var hingeConstraint = this.constraints[wheelIndex]; - hingeConstraint.enableMotor(); - hingeConstraint.motorTargetVelocity = value; - } - /** - * Set the target rotational speed of the hinge constraint. - * @method disableMotor - * @param {number} value - * @param {integer} wheelIndex - */ - ; - - _proto.disableMotor = function disableMotor(wheelIndex) { - var hingeConstraint = this.constraints[wheelIndex]; - hingeConstraint.disableMotor(); - } - /** - * Set the wheel force to apply on one of the wheels each time step - * @method setWheelForce - * @param {number} value - * @param {integer} wheelIndex - */ - ; - - _proto.setWheelForce = function setWheelForce(value, wheelIndex) { - this.wheelForces[wheelIndex] = value; - } - /** - * Apply a torque on one of the wheels. - * @method applyWheelForce - * @param {number} value - * @param {integer} wheelIndex - */ - ; - - _proto.applyWheelForce = function applyWheelForce(value, wheelIndex) { - var axis = this.wheelAxes[wheelIndex]; - var wheelBody = this.wheelBodies[wheelIndex]; - var bodyTorque = wheelBody.torque; - axis.scale(value, torque$1); - wheelBody.vectorToWorldFrame(torque$1, torque$1); - bodyTorque.vadd(torque$1, bodyTorque); - } - /** - * Add the vehicle including its constraints to the world. - * @method addToWorld - * @param {World} world - */ - ; - - _proto.addToWorld = function addToWorld(world) { - var constraints = this.constraints; - var bodies = this.wheelBodies.concat([this.chassisBody]); - - for (var i = 0; i < bodies.length; i++) { - world.addBody(bodies[i]); - } - - for (var _i = 0; _i < constraints.length; _i++) { - world.addConstraint(constraints[_i]); - } - - world.addEventListener('preStep', this._update.bind(this)); - }; - - _proto._update = function _update() { - var wheelForces = this.wheelForces; - - for (var i = 0; i < wheelForces.length; i++) { - this.applyWheelForce(wheelForces[i], i); - } - } - /** - * Remove the vehicle including its constraints from the world. - * @method removeFromWorld - * @param {World} world - */ - ; - - _proto.removeFromWorld = function removeFromWorld(world) { - var constraints = this.constraints; - var bodies = this.wheelBodies.concat([this.chassisBody]); - - for (var i = 0; i < bodies.length; i++) { - world.removeBody(bodies[i]); - } - - for (var _i2 = 0; _i2 < constraints.length; _i2++) { - world.removeConstraint(constraints[_i2]); - } - } - /** - * Get current rotational velocity of a wheel - * @method getWheelSpeed - * @param {integer} wheelIndex - */ - ; - - _proto.getWheelSpeed = function getWheelSpeed(wheelIndex) { - var axis = this.wheelAxes[wheelIndex]; - var wheelBody = this.wheelBodies[wheelIndex]; - var w = wheelBody.angularVelocity; - this.chassisBody.vectorToWorldFrame(axis, worldAxis); - return w.dot(worldAxis); - }; - - return RigidVehicle; -}(); -var torque$1 = new Vec3(); -var worldAxis = new Vec3(); - -/** - * Smoothed-particle hydrodynamics system - * @class SPHSystem - * @constructor - */ -var SPHSystem = /*#__PURE__*/function () { - // Density of the system (kg/m3). - // Distance below which two particles are considered to be neighbors. It should be adjusted so there are about 15-20 neighbor particles within this radius. - // Viscosity of the system. - function SPHSystem() { - this.particles = []; - this.density = 1; - this.smoothingRadius = 1; - this.speedOfSound = 1; - this.viscosity = 0.01; - this.eps = 0.000001; // Stuff Computed per particle - - this.pressures = []; - this.densities = []; - this.neighbors = []; - } - /** - * Add a particle to the system. - * @method add - * @param {Body} particle - */ - - - var _proto = SPHSystem.prototype; - - _proto.add = function add(particle) { - this.particles.push(particle); - - if (this.neighbors.length < this.particles.length) { - this.neighbors.push([]); - } - } - /** - * Remove a particle from the system. - * @method remove - * @param {Body} particle - */ - ; - - _proto.remove = function remove(particle) { - var idx = this.particles.indexOf(particle); - - if (idx !== -1) { - this.particles.splice(idx, 1); - - if (this.neighbors.length > this.particles.length) { - this.neighbors.pop(); - } - } - }; - - _proto.getNeighbors = function getNeighbors(particle, neighbors) { - var N = this.particles.length; - var id = particle.id; - var R2 = this.smoothingRadius * this.smoothingRadius; - var dist = SPHSystem_getNeighbors_dist; - - for (var i = 0; i !== N; i++) { - var p = this.particles[i]; - p.position.vsub(particle.position, dist); - - if (id !== p.id && dist.lengthSquared() < R2) { - neighbors.push(p); - } - } - }; - - _proto.update = function update() { - var N = this.particles.length; - var dist = SPHSystem_update_dist; - var cs = this.speedOfSound; - var eps = this.eps; - - for (var i = 0; i !== N; i++) { - var p = this.particles[i]; // Current particle - - var neighbors = this.neighbors[i]; // Get neighbors - - neighbors.length = 0; - this.getNeighbors(p, neighbors); - neighbors.push(this.particles[i]); // Add current too - - var numNeighbors = neighbors.length; // Accumulate density for the particle - - var sum = 0.0; - - for (var j = 0; j !== numNeighbors; j++) { - //printf("Current particle has position %f %f %f\n",objects[id].pos.x(),objects[id].pos.y(),objects[id].pos.z()); - p.position.vsub(neighbors[j].position, dist); - var len = dist.length(); - var weight = this.w(len); - sum += neighbors[j].mass * weight; - } // Save - - - this.densities[i] = sum; - this.pressures[i] = cs * cs * (this.densities[i] - this.density); - } // Add forces - // Sum to these accelerations - - - var a_pressure = SPHSystem_update_a_pressure; - var a_visc = SPHSystem_update_a_visc; - var gradW = SPHSystem_update_gradW; - var r_vec = SPHSystem_update_r_vec; - var u = SPHSystem_update_u; - - for (var _i = 0; _i !== N; _i++) { - var particle = this.particles[_i]; - a_pressure.set(0, 0, 0); - a_visc.set(0, 0, 0); // Init vars - - var Pij = void 0; - var nabla = void 0; - - var _neighbors = this.neighbors[_i]; - var _numNeighbors = _neighbors.length; //printf("Neighbors: "); - - for (var _j = 0; _j !== _numNeighbors; _j++) { - var neighbor = _neighbors[_j]; //printf("%d ",nj); - // Get r once for all.. - - particle.position.vsub(neighbor.position, r_vec); - var r = r_vec.length(); // Pressure contribution - - Pij = -neighbor.mass * (this.pressures[_i] / (this.densities[_i] * this.densities[_i] + eps) + this.pressures[_j] / (this.densities[_j] * this.densities[_j] + eps)); - this.gradw(r_vec, gradW); // Add to pressure acceleration - - gradW.scale(Pij, gradW); - a_pressure.vadd(gradW, a_pressure); // Viscosity contribution - - neighbor.velocity.vsub(particle.velocity, u); - u.scale(1.0 / (0.0001 + this.densities[_i] * this.densities[_j]) * this.viscosity * neighbor.mass, u); - nabla = this.nablaw(r); - u.scale(nabla, u); // Add to viscosity acceleration - - a_visc.vadd(u, a_visc); - } // Calculate force - - - a_visc.scale(particle.mass, a_visc); - a_pressure.scale(particle.mass, a_pressure); // Add force to particles - - particle.force.vadd(a_visc, particle.force); - particle.force.vadd(a_pressure, particle.force); - } - } // Calculate the weight using the W(r) weightfunction - ; - - _proto.w = function w(r) { - // 315 - var h = this.smoothingRadius; - return 315.0 / (64.0 * Math.PI * Math.pow(h, 9)) * Math.pow(h * h - r * r, 3); - } // calculate gradient of the weight function - ; - - _proto.gradw = function gradw(rVec, resultVec) { - var r = rVec.length(); - var h = this.smoothingRadius; - rVec.scale(945.0 / (32.0 * Math.PI * Math.pow(h, 9)) * Math.pow(h * h - r * r, 2), resultVec); - } // Calculate nabla(W) - ; - - _proto.nablaw = function nablaw(r) { - var h = this.smoothingRadius; - var nabla = 945.0 / (32.0 * Math.PI * Math.pow(h, 9)) * (h * h - r * r) * (7 * r * r - 3 * h * h); - return nabla; - }; - - return SPHSystem; -}(); -/** - * Get neighbors within smoothing volume, save in the array neighbors - * @method getNeighbors - * @param {Body} particle - * @param {Array} neighbors - */ - -var SPHSystem_getNeighbors_dist = new Vec3(); // Temp vectors for calculation - -var SPHSystem_update_dist = new Vec3(); // Relative velocity - -var SPHSystem_update_a_pressure = new Vec3(); -var SPHSystem_update_a_visc = new Vec3(); -var SPHSystem_update_gradW = new Vec3(); -var SPHSystem_update_r_vec = new Vec3(); -var SPHSystem_update_u = new Vec3(); - -/** - * @class Cylinder - * @constructor - * @extends ConvexPolyhedron - * @author schteppe / https://github.com/schteppe - * @param {Number} radiusTop - * @param {Number} radiusBottom - * @param {Number} height - * @param {Number} numSegments The number of segments to build the cylinder out of - */ - -var Cylinder = /*#__PURE__*/function (_ConvexPolyhedron) { - _inheritsLoose(Cylinder, _ConvexPolyhedron); - - function Cylinder(radiusTop, radiusBottom, height, numSegments) { - var N = numSegments; - var vertices = []; - var axes = []; - var faces = []; - var bottomface = []; - var topface = []; - var cos = Math.cos; - var sin = Math.sin; // First bottom point - - vertices.push(new Vec3(radiusBottom * cos(0), radiusBottom * sin(0), -height * 0.5)); - bottomface.push(0); // First top point - - vertices.push(new Vec3(radiusTop * cos(0), radiusTop * sin(0), height * 0.5)); - topface.push(1); - - for (var i = 0; i < N; i++) { - var theta = 2 * Math.PI / N * (i + 1); - var thetaN = 2 * Math.PI / N * (i + 0.5); - - if (i < N - 1) { - // Bottom - vertices.push(new Vec3(radiusBottom * cos(theta), radiusBottom * sin(theta), -height * 0.5)); - bottomface.push(2 * i + 2); // Top - - vertices.push(new Vec3(radiusTop * cos(theta), radiusTop * sin(theta), height * 0.5)); - topface.push(2 * i + 3); // Face - - faces.push([2 * i + 2, 2 * i + 3, 2 * i + 1, 2 * i]); - } else { - faces.push([0, 1, 2 * i + 1, 2 * i]); // Connect - } // Axis: we can cut off half of them if we have even number of segments - - - if (N % 2 === 1 || i < N / 2) { - axes.push(new Vec3(cos(thetaN), sin(thetaN), 0)); - } - } - - faces.push(topface); - axes.push(new Vec3(0, 0, 1)); // Reorder bottom face - - var temp = []; - - for (var _i = 0; _i < bottomface.length; _i++) { - temp.push(bottomface[bottomface.length - _i - 1]); - } - - faces.push(temp); - return _ConvexPolyhedron.call(this, { - vertices: vertices, - faces: faces, - axes: axes - }) || this; - } - - return Cylinder; -}(ConvexPolyhedron); - -/** - * Particle shape. - * @class Particle - * @constructor - * @author schteppe - * @extends Shape - */ -var Particle = /*#__PURE__*/function (_Shape) { - _inheritsLoose(Particle, _Shape); - - function Particle() { - return _Shape.call(this, { - type: Shape.types.PARTICLE - }) || this; - } - /** - * @method calculateLocalInertia - * @param {Number} mass - * @param {Vec3} target - * @return {Vec3} - */ - - - var _proto = Particle.prototype; - - _proto.calculateLocalInertia = function calculateLocalInertia(mass, target) { - if (target === void 0) { - target = new Vec3(); - } - - target.set(0, 0, 0); - return target; - }; - - _proto.volume = function volume() { - return 0; - }; - - _proto.updateBoundingSphereRadius = function updateBoundingSphereRadius() { - this.boundingSphereRadius = 0; - }; - - _proto.calculateWorldAABB = function calculateWorldAABB(pos, quat, min, max) { - // Get each axis max - min.copy(pos); - max.copy(pos); - }; - - return Particle; -}(Shape); - -/** - * A plane, facing in the Z direction. The plane has its surface at z=0 and everything below z=0 is assumed to be solid plane. To make the plane face in some other direction than z, you must put it inside a Body and rotate that body. See the demos. - * @class Plane - * @constructor - * @extends Shape - * @author schteppe - */ -var Plane = /*#__PURE__*/function (_Shape) { - _inheritsLoose(Plane, _Shape); - - function Plane() { - var _this; - - _this = _Shape.call(this, { - type: Shape.types.PLANE - }) || this; // World oriented normal - - _this.worldNormal = new Vec3(); - _this.worldNormalNeedsUpdate = true; - _this.boundingSphereRadius = Number.MAX_VALUE; - return _this; - } - - var _proto = Plane.prototype; - - _proto.computeWorldNormal = function computeWorldNormal(quat) { - var n = this.worldNormal; - n.set(0, 0, 1); - quat.vmult(n, n); - this.worldNormalNeedsUpdate = false; - }; - - _proto.calculateLocalInertia = function calculateLocalInertia(mass, target) { - if (target === void 0) { - target = new Vec3(); - } - - return target; - }; - - _proto.volume = function volume() { - return (// The plane is infinite... - Number.MAX_VALUE - ); - }; - - _proto.calculateWorldAABB = function calculateWorldAABB(pos, quat, min, max) { - // The plane AABB is infinite, except if the normal is pointing along any axis - tempNormal.set(0, 0, 1); // Default plane normal is z - - quat.vmult(tempNormal, tempNormal); - var maxVal = Number.MAX_VALUE; - min.set(-maxVal, -maxVal, -maxVal); - max.set(maxVal, maxVal, maxVal); - - if (tempNormal.x === 1) { - max.x = pos.x; - } else if (tempNormal.x === -1) { - min.x = pos.x; - } - - if (tempNormal.y === 1) { - max.y = pos.y; - } else if (tempNormal.y === -1) { - min.y = pos.y; - } - - if (tempNormal.z === 1) { - max.z = pos.z; - } else if (tempNormal.z === -1) { - min.z = pos.z; - } - }; - - _proto.updateBoundingSphereRadius = function updateBoundingSphereRadius() { - this.boundingSphereRadius = Number.MAX_VALUE; - }; - - return Plane; -}(Shape); -var tempNormal = new Vec3(); - -/** - * Heightfield shape class. Height data is given as an array. These data points are spread out evenly with a given distance. - * @class Heightfield - * @extends Shape - * @constructor - * @param {Array} data An array of Y values that will be used to construct the terrain. - * @param {object} options - * @param {Number} [options.minValue] Minimum value of the data points in the data array. Will be computed automatically if not given. - * @param {Number} [options.maxValue] Maximum value. - * @param {Number} [options.elementSize=0.1] World spacing between the data points in X direction. - * @todo Should be possible to use along all axes, not just y - * @todo should be possible to scale along all axes - * @todo Refactor elementSize to elementSizeX and elementSizeY - * - * @example - * // Generate some height data (y-values). - * const data = []; - * for(let i = 0; i < 1000; i++){ - * const y = 0.5 * Math.cos(0.2 * i); - * data.push(y); - * } - * - * // Create the heightfield shape - * const heightfieldShape = new Heightfield(data, { - * elementSize: 1 // Distance between the data points in X and Y directions - * }); - * const heightfieldBody = new Body(); - * heightfieldBody.addShape(heightfieldShape); - * world.addBody(heightfieldBody); - */ -var Heightfield = /*#__PURE__*/function (_Shape) { - _inheritsLoose(Heightfield, _Shape); - - // An array of numbers, or height values, that are spread out along the x axis. - // Max value of the data. - // Max value of the data. - // The width of each element. To do: elementSizeX and Y - function Heightfield(data, options) { - var _this; - - if (options === void 0) { - options = {}; - } - - options = Utils.defaults(options, { - maxValue: null, - minValue: null, - elementSize: 1 - }); - _this = _Shape.call(this, { - type: Shape.types.HEIGHTFIELD - }) || this; - _this.data = data; - _this.maxValue = options.maxValue; - _this.minValue = options.minValue; - _this.elementSize = options.elementSize; - - if (options.minValue === null) { - _this.updateMinValue(); - } - - if (options.maxValue === null) { - _this.updateMaxValue(); - } - - _this.cacheEnabled = true; - _this.pillarConvex = new ConvexPolyhedron(); - _this.pillarOffset = new Vec3(); - - _this.updateBoundingSphereRadius(); // "i_j_isUpper" => { convex: ..., offset: ... } - // for example: - // _cachedPillars["0_2_1"] - - - _this._cachedPillars = {}; - return _this; - } - /** - * Call whenever you change the data array. - * @method update - */ - - - var _proto = Heightfield.prototype; - - _proto.update = function update() { - this._cachedPillars = {}; - } - /** - * Update the .minValue property - * @method updateMinValue - */ - ; - - _proto.updateMinValue = function updateMinValue() { - var data = this.data; - var minValue = data[0][0]; - - for (var i = 0; i !== data.length; i++) { - for (var j = 0; j !== data[i].length; j++) { - var v = data[i][j]; - - if (v < minValue) { - minValue = v; - } - } - } - - this.minValue = minValue; - } - /** - * Update the .maxValue property - * @method updateMaxValue - */ - ; - - _proto.updateMaxValue = function updateMaxValue() { - var data = this.data; - var maxValue = data[0][0]; - - for (var i = 0; i !== data.length; i++) { - for (var j = 0; j !== data[i].length; j++) { - var v = data[i][j]; - - if (v > maxValue) { - maxValue = v; - } - } - } - - this.maxValue = maxValue; - } - /** - * Set the height value at an index. Don't forget to update maxValue and minValue after you're done. - * @method setHeightValueAtIndex - * @param {integer} xi - * @param {integer} yi - * @param {number} value - */ - ; - - _proto.setHeightValueAtIndex = function setHeightValueAtIndex(xi, yi, value) { - var data = this.data; - data[xi][yi] = value; // Invalidate cache - - this.clearCachedConvexTrianglePillar(xi, yi, false); - - if (xi > 0) { - this.clearCachedConvexTrianglePillar(xi - 1, yi, true); - this.clearCachedConvexTrianglePillar(xi - 1, yi, false); - } - - if (yi > 0) { - this.clearCachedConvexTrianglePillar(xi, yi - 1, true); - this.clearCachedConvexTrianglePillar(xi, yi - 1, false); - } - - if (yi > 0 && xi > 0) { - this.clearCachedConvexTrianglePillar(xi - 1, yi - 1, true); - } - } - /** - * Get max/min in a rectangle in the matrix data - * @method getRectMinMax - * @param {integer} iMinX - * @param {integer} iMinY - * @param {integer} iMaxX - * @param {integer} iMaxY - * @param {array} [result] An array to store the results in. - * @return {array} The result array, if it was passed in. Minimum will be at position 0 and max at 1. - */ - ; - - _proto.getRectMinMax = function getRectMinMax(iMinX, iMinY, iMaxX, iMaxY, result) { - if (result === void 0) { - result = []; - } - - // Get max and min of the data - var data = this.data; // Set first value - - var max = this.minValue; - - for (var i = iMinX; i <= iMaxX; i++) { - for (var j = iMinY; j <= iMaxY; j++) { - var height = data[i][j]; - - if (height > max) { - max = height; - } - } - } - - result[0] = this.minValue; - result[1] = max; - } - /** - * Get the index of a local position on the heightfield. The indexes indicate the rectangles, so if your terrain is made of N x N height data points, you will have rectangle indexes ranging from 0 to N-1. - * @method getIndexOfPosition - * @param {number} x - * @param {number} y - * @param {array} result Two-element array - * @param {boolean} clamp If the position should be clamped to the heightfield edge. - * @return {boolean} - */ - ; - - _proto.getIndexOfPosition = function getIndexOfPosition(x, y, result, clamp) { - // Get the index of the data points to test against - var w = this.elementSize; - var data = this.data; - var xi = Math.floor(x / w); - var yi = Math.floor(y / w); - result[0] = xi; - result[1] = yi; - - if (clamp) { - // Clamp index to edges - if (xi < 0) { - xi = 0; - } - - if (yi < 0) { - yi = 0; - } - - if (xi >= data.length - 1) { - xi = data.length - 1; - } - - if (yi >= data[0].length - 1) { - yi = data[0].length - 1; - } - } // Bail out if we are out of the terrain - - - if (xi < 0 || yi < 0 || xi >= data.length - 1 || yi >= data[0].length - 1) { - return false; - } - - return true; - }; - - _proto.getTriangleAt = function getTriangleAt(x, y, edgeClamp, a, b, c) { - var idx = getHeightAt_idx; - this.getIndexOfPosition(x, y, idx, edgeClamp); - var xi = idx[0]; - var yi = idx[1]; - var data = this.data; - - if (edgeClamp) { - xi = Math.min(data.length - 2, Math.max(0, xi)); - yi = Math.min(data[0].length - 2, Math.max(0, yi)); - } - - var elementSize = this.elementSize; - var lowerDist2 = Math.pow(x / elementSize - xi, 2) + Math.pow(y / elementSize - yi, 2); - var upperDist2 = Math.pow(x / elementSize - (xi + 1), 2) + Math.pow(y / elementSize - (yi + 1), 2); - var upper = lowerDist2 > upperDist2; - this.getTriangle(xi, yi, upper, a, b, c); - return upper; - }; - - _proto.getNormalAt = function getNormalAt(x, y, edgeClamp, result) { - var a = getNormalAt_a; - var b = getNormalAt_b; - var c = getNormalAt_c; - var e0 = getNormalAt_e0; - var e1 = getNormalAt_e1; - this.getTriangleAt(x, y, edgeClamp, a, b, c); - b.vsub(a, e0); - c.vsub(a, e1); - e0.cross(e1, result); - result.normalize(); - } - /** - * Get an AABB of a square in the heightfield - * @param {number} xi - * @param {number} yi - * @param {AABB} result - */ - ; - - _proto.getAabbAtIndex = function getAabbAtIndex(xi, yi, _ref) { - var lowerBound = _ref.lowerBound, - upperBound = _ref.upperBound; - var data = this.data; - var elementSize = this.elementSize; - lowerBound.set(xi * elementSize, yi * elementSize, data[xi][yi]); - upperBound.set((xi + 1) * elementSize, (yi + 1) * elementSize, data[xi + 1][yi + 1]); - } - /** - * Get the height in the heightfield at a given position - * @param {number} x - * @param {number} y - * @param {boolean} edgeClamp - * @return {number} - */ - ; - - _proto.getHeightAt = function getHeightAt(x, y, edgeClamp) { - var data = this.data; - var a = getHeightAt_a; - var b = getHeightAt_b; - var c = getHeightAt_c; - var idx = getHeightAt_idx; - this.getIndexOfPosition(x, y, idx, edgeClamp); - var xi = idx[0]; - var yi = idx[1]; - - if (edgeClamp) { - xi = Math.min(data.length - 2, Math.max(0, xi)); - yi = Math.min(data[0].length - 2, Math.max(0, yi)); - } - - var upper = this.getTriangleAt(x, y, edgeClamp, a, b, c); - barycentricWeights(x, y, a.x, a.y, b.x, b.y, c.x, c.y, getHeightAt_weights); - var w = getHeightAt_weights; - - if (upper) { - // Top triangle verts - return data[xi + 1][yi + 1] * w.x + data[xi][yi + 1] * w.y + data[xi + 1][yi] * w.z; - } else { - // Top triangle verts - return data[xi][yi] * w.x + data[xi + 1][yi] * w.y + data[xi][yi + 1] * w.z; - } - }; - - _proto.getCacheConvexTrianglePillarKey = function getCacheConvexTrianglePillarKey(xi, yi, getUpperTriangle) { - return xi + "_" + yi + "_" + (getUpperTriangle ? 1 : 0); - }; - - _proto.getCachedConvexTrianglePillar = function getCachedConvexTrianglePillar(xi, yi, getUpperTriangle) { - return this._cachedPillars[this.getCacheConvexTrianglePillarKey(xi, yi, getUpperTriangle)]; - }; - - _proto.setCachedConvexTrianglePillar = function setCachedConvexTrianglePillar(xi, yi, getUpperTriangle, convex, offset) { - this._cachedPillars[this.getCacheConvexTrianglePillarKey(xi, yi, getUpperTriangle)] = { - convex: convex, - offset: offset - }; - }; - - _proto.clearCachedConvexTrianglePillar = function clearCachedConvexTrianglePillar(xi, yi, getUpperTriangle) { - delete this._cachedPillars[this.getCacheConvexTrianglePillarKey(xi, yi, getUpperTriangle)]; - } - /** - * Get a triangle from the heightfield - * @param {number} xi - * @param {number} yi - * @param {boolean} upper - * @param {Vec3} a - * @param {Vec3} b - * @param {Vec3} c - */ - ; - - _proto.getTriangle = function getTriangle(xi, yi, upper, a, b, c) { - var data = this.data; - var elementSize = this.elementSize; - - if (upper) { - // Top triangle verts - a.set((xi + 1) * elementSize, (yi + 1) * elementSize, data[xi + 1][yi + 1]); - b.set(xi * elementSize, (yi + 1) * elementSize, data[xi][yi + 1]); - c.set((xi + 1) * elementSize, yi * elementSize, data[xi + 1][yi]); - } else { - // Top triangle verts - a.set(xi * elementSize, yi * elementSize, data[xi][yi]); - b.set((xi + 1) * elementSize, yi * elementSize, data[xi + 1][yi]); - c.set(xi * elementSize, (yi + 1) * elementSize, data[xi][yi + 1]); - } - } - /** - * Get a triangle in the terrain in the form of a triangular convex shape. - * @method getConvexTrianglePillar - * @param {integer} i - * @param {integer} j - * @param {boolean} getUpperTriangle - */ - ; - - _proto.getConvexTrianglePillar = function getConvexTrianglePillar(xi, yi, getUpperTriangle) { - var result = this.pillarConvex; - var offsetResult = this.pillarOffset; - - if (this.cacheEnabled) { - var _data = this.getCachedConvexTrianglePillar(xi, yi, getUpperTriangle); - - if (_data) { - this.pillarConvex = _data.convex; - this.pillarOffset = _data.offset; - return; - } - - result = new ConvexPolyhedron(); - offsetResult = new Vec3(); - this.pillarConvex = result; - this.pillarOffset = offsetResult; - } - - var data = this.data; - var elementSize = this.elementSize; - var faces = result.faces; // Reuse verts if possible - - result.vertices.length = 6; - - for (var i = 0; i < 6; i++) { - if (!result.vertices[i]) { - result.vertices[i] = new Vec3(); - } - } // Reuse faces if possible - - - faces.length = 5; - - for (var _i = 0; _i < 5; _i++) { - if (!faces[_i]) { - faces[_i] = []; - } - } - - var verts = result.vertices; - var h = (Math.min(data[xi][yi], data[xi + 1][yi], data[xi][yi + 1], data[xi + 1][yi + 1]) - this.minValue) / 2 + this.minValue; - - if (!getUpperTriangle) { - // Center of the triangle pillar - all polygons are given relative to this one - offsetResult.set((xi + 0.25) * elementSize, // sort of center of a triangle - (yi + 0.25) * elementSize, h // vertical center - ); // Top triangle verts - - verts[0].set(-0.25 * elementSize, -0.25 * elementSize, data[xi][yi] - h); - verts[1].set(0.75 * elementSize, -0.25 * elementSize, data[xi + 1][yi] - h); - verts[2].set(-0.25 * elementSize, 0.75 * elementSize, data[xi][yi + 1] - h); // bottom triangle verts - - verts[3].set(-0.25 * elementSize, -0.25 * elementSize, -h - 1); - verts[4].set(0.75 * elementSize, -0.25 * elementSize, -h - 1); - verts[5].set(-0.25 * elementSize, 0.75 * elementSize, -h - 1); // top triangle - - faces[0][0] = 0; - faces[0][1] = 1; - faces[0][2] = 2; // bottom triangle - - faces[1][0] = 5; - faces[1][1] = 4; - faces[1][2] = 3; // -x facing quad - - faces[2][0] = 0; - faces[2][1] = 2; - faces[2][2] = 5; - faces[2][3] = 3; // -y facing quad - - faces[3][0] = 1; - faces[3][1] = 0; - faces[3][2] = 3; - faces[3][3] = 4; // +xy facing quad - - faces[4][0] = 4; - faces[4][1] = 5; - faces[4][2] = 2; - faces[4][3] = 1; - } else { - // Center of the triangle pillar - all polygons are given relative to this one - offsetResult.set((xi + 0.75) * elementSize, // sort of center of a triangle - (yi + 0.75) * elementSize, h // vertical center - ); // Top triangle verts - - verts[0].set(0.25 * elementSize, 0.25 * elementSize, data[xi + 1][yi + 1] - h); - verts[1].set(-0.75 * elementSize, 0.25 * elementSize, data[xi][yi + 1] - h); - verts[2].set(0.25 * elementSize, -0.75 * elementSize, data[xi + 1][yi] - h); // bottom triangle verts - - verts[3].set(0.25 * elementSize, 0.25 * elementSize, -h - 1); - verts[4].set(-0.75 * elementSize, 0.25 * elementSize, -h - 1); - verts[5].set(0.25 * elementSize, -0.75 * elementSize, -h - 1); // Top triangle - - faces[0][0] = 0; - faces[0][1] = 1; - faces[0][2] = 2; // bottom triangle - - faces[1][0] = 5; - faces[1][1] = 4; - faces[1][2] = 3; // +x facing quad - - faces[2][0] = 2; - faces[2][1] = 5; - faces[2][2] = 3; - faces[2][3] = 0; // +y facing quad - - faces[3][0] = 3; - faces[3][1] = 4; - faces[3][2] = 1; - faces[3][3] = 0; // -xy facing quad - - faces[4][0] = 1; - faces[4][1] = 4; - faces[4][2] = 5; - faces[4][3] = 2; - } - - result.computeNormals(); - result.computeEdges(); - result.updateBoundingSphereRadius(); - this.setCachedConvexTrianglePillar(xi, yi, getUpperTriangle, result, offsetResult); - }; - - _proto.calculateLocalInertia = function calculateLocalInertia(mass, target) { - if (target === void 0) { - target = new Vec3(); - } - - target.set(0, 0, 0); - return target; - }; - - _proto.volume = function volume() { - return (// The terrain is infinite - Number.MAX_VALUE - ); - }; - - _proto.calculateWorldAABB = function calculateWorldAABB(pos, quat, min, max) { - // TODO: do it properly - min.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE); - max.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE); - }; - - _proto.updateBoundingSphereRadius = function updateBoundingSphereRadius() { - // Use the bounding box of the min/max values - var data = this.data; - var s = this.elementSize; - this.boundingSphereRadius = new Vec3(data.length * s, data[0].length * s, Math.max(Math.abs(this.maxValue), Math.abs(this.minValue))).length(); - } - /** - * Sets the height values from an image. Currently only supported in browser. - * @method setHeightsFromImage - * @param {Image} image - * @param {Vec3} scale - */ - ; - - _proto.setHeightsFromImage = function setHeightsFromImage(image, scale) { - var x = scale.x, - z = scale.z, - y = scale.y; - var canvas = document.createElement('canvas'); - canvas.width = image.width; - canvas.height = image.height; - var context = canvas.getContext('2d'); - context.drawImage(image, 0, 0); - var imageData = context.getImageData(0, 0, image.width, image.height); - var matrix = this.data; - matrix.length = 0; - this.elementSize = Math.abs(x) / imageData.width; - - for (var i = 0; i < imageData.height; i++) { - var row = []; - - for (var j = 0; j < imageData.width; j++) { - var a = imageData.data[(i * imageData.height + j) * 4]; - var b = imageData.data[(i * imageData.height + j) * 4 + 1]; - var c = imageData.data[(i * imageData.height + j) * 4 + 2]; - var height = (a + b + c) / 4 / 255 * z; - - if (x < 0) { - row.push(height); - } else { - row.unshift(height); - } - } - - if (y < 0) { - matrix.unshift(row); - } else { - matrix.push(row); - } - } - - this.updateMaxValue(); - this.updateMinValue(); - this.update(); - }; - - return Heightfield; -}(Shape); -var getHeightAt_idx = []; -var getHeightAt_weights = new Vec3(); -var getHeightAt_a = new Vec3(); -var getHeightAt_b = new Vec3(); -var getHeightAt_c = new Vec3(); -var getNormalAt_a = new Vec3(); -var getNormalAt_b = new Vec3(); -var getNormalAt_c = new Vec3(); -var getNormalAt_e0 = new Vec3(); -var getNormalAt_e1 = new Vec3(); // from https://en.wikipedia.org/wiki/Barycentric_coordinate_system - -function barycentricWeights(x, y, ax, ay, bx, by, cx, cy, result) { - result.x = ((by - cy) * (x - cx) + (cx - bx) * (y - cy)) / ((by - cy) * (ax - cx) + (cx - bx) * (ay - cy)); - result.y = ((cy - ay) * (x - cx) + (ax - cx) * (y - cy)) / ((by - cy) * (ax - cx) + (cx - bx) * (ay - cy)); - result.z = 1 - result.x - result.y; -} - -/** - * @class OctreeNode - * @constructor - * @param {object} [options] - * @param {Octree} [options.root] - * @param {AABB} [options.aabb] - */ -var OctreeNode = /*#__PURE__*/function () { - // The root node - // Boundary of this node - // Contained data at the current node level - // Children to this node - function OctreeNode(options) { - if (options === void 0) { - options = {}; - } - - this.root = options.root || null; - this.aabb = options.aabb ? options.aabb.clone() : new AABB(); - this.data = []; - this.children = []; - } - - var _proto = OctreeNode.prototype; - - _proto.reset = function reset() { - this.children.length = this.data.length = 0; - } - /** - * Insert data into this node - * @method insert - * @param {AABB} aabb - * @param {object} elementData - * @return {boolean} True if successful, otherwise false - */ - ; - - _proto.insert = function insert(aabb, elementData, level) { - if (level === void 0) { - level = 0; - } - - var nodeData = this.data; // Ignore objects that do not belong in this node - - if (!this.aabb.contains(aabb)) { - return false; // object cannot be added - } - - var children = this.children; - var maxDepth = this.maxDepth || this.root.maxDepth; - - if (level < maxDepth) { - // Subdivide if there are no children yet - var subdivided = false; - - if (!children.length) { - this.subdivide(); - subdivided = true; - } // add to whichever node will accept it - - - for (var i = 0; i !== 8; i++) { - if (children[i].insert(aabb, elementData, level + 1)) { - return true; - } - } - - if (subdivided) { - // No children accepted! Might as well just remove em since they contain none - children.length = 0; - } - } // Too deep, or children didnt want it. add it in current node - - - nodeData.push(elementData); - return true; - } - /** - * Create 8 equally sized children nodes and put them in the .children array. - * @method subdivide - */ - ; - - _proto.subdivide = function subdivide() { - var aabb = this.aabb; - var l = aabb.lowerBound; - var u = aabb.upperBound; - var children = this.children; - children.push(new OctreeNode({ - aabb: new AABB({ - lowerBound: new Vec3(0, 0, 0) - }) - }), new OctreeNode({ - aabb: new AABB({ - lowerBound: new Vec3(1, 0, 0) - }) - }), new OctreeNode({ - aabb: new AABB({ - lowerBound: new Vec3(1, 1, 0) - }) - }), new OctreeNode({ - aabb: new AABB({ - lowerBound: new Vec3(1, 1, 1) - }) - }), new OctreeNode({ - aabb: new AABB({ - lowerBound: new Vec3(0, 1, 1) - }) - }), new OctreeNode({ - aabb: new AABB({ - lowerBound: new Vec3(0, 0, 1) - }) - }), new OctreeNode({ - aabb: new AABB({ - lowerBound: new Vec3(1, 0, 1) - }) - }), new OctreeNode({ - aabb: new AABB({ - lowerBound: new Vec3(0, 1, 0) - }) - })); - u.vsub(l, halfDiagonal); - halfDiagonal.scale(0.5, halfDiagonal); - var root = this.root || this; - - for (var i = 0; i !== 8; i++) { - var child = children[i]; // Set current node as root - - child.root = root; // Compute bounds - - var lowerBound = child.aabb.lowerBound; - lowerBound.x *= halfDiagonal.x; - lowerBound.y *= halfDiagonal.y; - lowerBound.z *= halfDiagonal.z; - lowerBound.vadd(l, lowerBound); // Upper bound is always lower bound + halfDiagonal - - lowerBound.vadd(halfDiagonal, child.aabb.upperBound); - } - } - /** - * Get all data, potentially within an AABB - * @method aabbQuery - * @param {AABB} aabb - * @param {array} result - * @return {array} The "result" object - */ - ; - - _proto.aabbQuery = function aabbQuery(aabb, result) { - var nodeData = this.data; // abort if the range does not intersect this node - // if (!this.aabb.overlaps(aabb)){ - // return result; - // } - // Add objects at this level - // Array.prototype.push.apply(result, nodeData); - // Add child data - // @todo unwrap recursion into a queue / loop, that's faster in JS - - var children = this.children; // for (let i = 0, N = this.children.length; i !== N; i++) { - // children[i].aabbQuery(aabb, result); - // } - - var queue = [this]; - - while (queue.length) { - var node = queue.pop(); - - if (node.aabb.overlaps(aabb)) { - Array.prototype.push.apply(result, node.data); - } - - Array.prototype.push.apply(queue, node.children); - } - - return result; - } - /** - * Get all data, potentially intersected by a ray. - * @method rayQuery - * @param {Ray} ray - * @param {Transform} treeTransform - * @param {array} result - * @return {array} The "result" object - */ - ; - - _proto.rayQuery = function rayQuery(ray, treeTransform, result) { - // Use aabb query for now. - // @todo implement real ray query which needs less lookups - ray.getAABB(tmpAABB$1); - tmpAABB$1.toLocalFrame(treeTransform, tmpAABB$1); - this.aabbQuery(tmpAABB$1, result); - return result; - } - /** - * @method removeEmptyNodes - */ - ; - - _proto.removeEmptyNodes = function removeEmptyNodes() { - for (var i = this.children.length - 1; i >= 0; i--) { - this.children[i].removeEmptyNodes(); - - if (!this.children[i].children.length && !this.children[i].data.length) { - this.children.splice(i, 1); - } - } - }; - - return OctreeNode; -}(); -/** - * @class Octree - * @param {AABB} aabb The total AABB of the tree - * @param {object} [options] - * @param {number} [options.maxDepth=8] Maximum subdivision depth - * @extends OctreeNode - */ - - -var Octree = /*#__PURE__*/function (_OctreeNode) { - _inheritsLoose(Octree, _OctreeNode); - - // Maximum subdivision depth - function Octree(aabb, options) { - var _this; - - if (options === void 0) { - options = {}; - } - - _this = _OctreeNode.call(this, { - root: null, - aabb: aabb - }) || this; - _this.maxDepth = typeof options.maxDepth !== 'undefined' ? options.maxDepth : 8; - return _this; - } - - return Octree; -}(OctreeNode); -var halfDiagonal = new Vec3(); -var tmpAABB$1 = new AABB(); - -/** - * @class Trimesh - * @constructor - * @param {array} vertices - * @param {array} indices - * @extends Shape - * @example - * // How to make a mesh with a single triangle - * const vertices = [ - * 0, 0, 0, // vertex 0 - * 1, 0, 0, // vertex 1 - * 0, 1, 0 // vertex 2 - * ]; - * const indices = [ - * 0, 1, 2 // triangle 0 - * ]; - * const trimeshShape = new Trimesh(vertices, indices); - */ -var Trimesh = /*#__PURE__*/function (_Shape) { - _inheritsLoose(Trimesh, _Shape); - - // Array of integers, indicating which vertices each triangle consists of. The length of this array is thus 3 times the number of triangles. - // The normals data. - // The local AABB of the mesh. - // References to vertex pairs, making up all unique edges in the trimesh. - // Local scaling of the mesh. Use .setScale() to set it. - // The indexed triangles. Use .updateTree() to update it. - function Trimesh(vertices, indices) { - var _this; - - _this = _Shape.call(this, { - type: Shape.types.TRIMESH - }) || this; - _this.vertices = new Float32Array(vertices); - _this.indices = new Int16Array(indices); - _this.normals = new Float32Array(indices.length); - _this.aabb = new AABB(); - _this.edges = null; - _this.scale = new Vec3(1, 1, 1); - _this.tree = new Octree(); - - _this.updateEdges(); - - _this.updateNormals(); - - _this.updateAABB(); - - _this.updateBoundingSphereRadius(); - - _this.updateTree(); - - return _this; - } - /** - * @method updateTree - */ - - - var _proto = Trimesh.prototype; - - _proto.updateTree = function updateTree() { - var tree = this.tree; - tree.reset(); - tree.aabb.copy(this.aabb); - var scale = this.scale; // The local mesh AABB is scaled, but the octree AABB should be unscaled - - tree.aabb.lowerBound.x *= 1 / scale.x; - tree.aabb.lowerBound.y *= 1 / scale.y; - tree.aabb.lowerBound.z *= 1 / scale.z; - tree.aabb.upperBound.x *= 1 / scale.x; - tree.aabb.upperBound.y *= 1 / scale.y; - tree.aabb.upperBound.z *= 1 / scale.z; // Insert all triangles - - var triangleAABB = new AABB(); - var a = new Vec3(); - var b = new Vec3(); - var c = new Vec3(); - var points = [a, b, c]; - - for (var i = 0; i < this.indices.length / 3; i++) { - //this.getTriangleVertices(i, a, b, c); - // Get unscaled triangle verts - var i3 = i * 3; - - this._getUnscaledVertex(this.indices[i3], a); - - this._getUnscaledVertex(this.indices[i3 + 1], b); - - this._getUnscaledVertex(this.indices[i3 + 2], c); - - triangleAABB.setFromPoints(points); - tree.insert(triangleAABB, i); - } - - tree.removeEmptyNodes(); - } - /** - * Get triangles in a local AABB from the trimesh. - * @method getTrianglesInAABB - * @param {AABB} aabb - * @param {array} result An array of integers, referencing the queried triangles. - */ - ; - - _proto.getTrianglesInAABB = function getTrianglesInAABB(aabb, result) { - unscaledAABB.copy(aabb); // Scale it to local - - var scale = this.scale; - var isx = scale.x; - var isy = scale.y; - var isz = scale.z; - var l = unscaledAABB.lowerBound; - var u = unscaledAABB.upperBound; - l.x /= isx; - l.y /= isy; - l.z /= isz; - u.x /= isx; - u.y /= isy; - u.z /= isz; - return this.tree.aabbQuery(unscaledAABB, result); - } - /** - * @method setScale - * @param {Vec3} scale - */ - ; - - _proto.setScale = function setScale(scale) { - var wasUniform = this.scale.x === this.scale.y && this.scale.y === this.scale.z; - var isUniform = scale.x === scale.y && scale.y === scale.z; - - if (!(wasUniform && isUniform)) { - // Non-uniform scaling. Need to update normals. - this.updateNormals(); - } - - this.scale.copy(scale); - this.updateAABB(); - this.updateBoundingSphereRadius(); - } - /** - * Compute the normals of the faces. Will save in the .normals array. - * @method updateNormals - */ - ; - - _proto.updateNormals = function updateNormals() { - var n = computeNormals_n; // Generate normals - - var normals = this.normals; - - for (var i = 0; i < this.indices.length / 3; i++) { - var i3 = i * 3; - var a = this.indices[i3]; - var b = this.indices[i3 + 1]; - var c = this.indices[i3 + 2]; - this.getVertex(a, va); - this.getVertex(b, vb); - this.getVertex(c, vc); - Trimesh.computeNormal(vb, va, vc, n); - normals[i3] = n.x; - normals[i3 + 1] = n.y; - normals[i3 + 2] = n.z; - } - } - /** - * Update the .edges property - * @method updateEdges - */ - ; - - _proto.updateEdges = function updateEdges() { - var edges = {}; - - var add = function add(a, b) { - var key = a < b ? a + "_" + b : b + "_" + a; - edges[key] = true; - }; - - for (var i = 0; i < this.indices.length / 3; i++) { - var i3 = i * 3; - var a = this.indices[i3]; - var b = this.indices[i3 + 1]; - var c = this.indices[i3 + 2]; - add(a, b); - add(b, c); - add(c, a); - } - - var keys = Object.keys(edges); - this.edges = new Int16Array(keys.length * 2); - - for (var _i = 0; _i < keys.length; _i++) { - var indices = keys[_i].split('_'); - - this.edges[2 * _i] = parseInt(indices[0], 10); - this.edges[2 * _i + 1] = parseInt(indices[1], 10); - } - } - /** - * Get an edge vertex - * @method getEdgeVertex - * @param {number} edgeIndex - * @param {number} firstOrSecond 0 or 1, depending on which one of the vertices you need. - * @param {Vec3} vertexStore Where to store the result - */ - ; - - _proto.getEdgeVertex = function getEdgeVertex(edgeIndex, firstOrSecond, vertexStore) { - var vertexIndex = this.edges[edgeIndex * 2 + (firstOrSecond ? 1 : 0)]; - this.getVertex(vertexIndex, vertexStore); - } - /** - * Get a vector along an edge. - * @method getEdgeVector - * @param {number} edgeIndex - * @param {Vec3} vectorStore - */ - ; - - _proto.getEdgeVector = function getEdgeVector(edgeIndex, vectorStore) { - var va = getEdgeVector_va; - var vb = getEdgeVector_vb; - this.getEdgeVertex(edgeIndex, 0, va); - this.getEdgeVertex(edgeIndex, 1, vb); - vb.vsub(va, vectorStore); - } - /** - * Get vertex i. - * @method getVertex - * @param {number} i - * @param {Vec3} out - * @return {Vec3} The "out" vector object - */ - ; - - _proto.getVertex = function getVertex(i, out) { - var scale = this.scale; - - this._getUnscaledVertex(i, out); - - out.x *= scale.x; - out.y *= scale.y; - out.z *= scale.z; - return out; - } - /** - * Get raw vertex i - * @private - * @method _getUnscaledVertex - * @param {number} i - * @param {Vec3} out - * @return {Vec3} The "out" vector object - */ - ; - - _proto._getUnscaledVertex = function _getUnscaledVertex(i, out) { - var i3 = i * 3; - var vertices = this.vertices; - return out.set(vertices[i3], vertices[i3 + 1], vertices[i3 + 2]); - } - /** - * Get a vertex from the trimesh,transformed by the given position and quaternion. - * @method getWorldVertex - * @param {number} i - * @param {Vec3} pos - * @param {Quaternion} quat - * @param {Vec3} out - * @return {Vec3} The "out" vector object - */ - ; - - _proto.getWorldVertex = function getWorldVertex(i, pos, quat, out) { - this.getVertex(i, out); - Transform.pointToWorldFrame(pos, quat, out, out); - return out; - } - /** - * Get the three vertices for triangle i. - * @method getTriangleVertices - * @param {number} i - * @param {Vec3} a - * @param {Vec3} b - * @param {Vec3} c - */ - ; - - _proto.getTriangleVertices = function getTriangleVertices(i, a, b, c) { - var i3 = i * 3; - this.getVertex(this.indices[i3], a); - this.getVertex(this.indices[i3 + 1], b); - this.getVertex(this.indices[i3 + 2], c); - } - /** - * Compute the normal of triangle i. - * @method getNormal - * @param {Number} i - * @param {Vec3} target - * @return {Vec3} The "target" vector object - */ - ; - - _proto.getNormal = function getNormal(i, target) { - var i3 = i * 3; - return target.set(this.normals[i3], this.normals[i3 + 1], this.normals[i3 + 2]); - } - /** - * @method calculateLocalInertia - * @param {Number} mass - * @param {Vec3} target - * @return {Vec3} The "target" vector object - */ - ; - - _proto.calculateLocalInertia = function calculateLocalInertia(mass, target) { - // Approximate with box inertia - // Exact inertia calculation is overkill, but see http://geometrictools.com/Documentation/PolyhedralMassProperties.pdf for the correct way to do it - this.computeLocalAABB(cli_aabb); - var x = cli_aabb.upperBound.x - cli_aabb.lowerBound.x; - var y = cli_aabb.upperBound.y - cli_aabb.lowerBound.y; - var z = cli_aabb.upperBound.z - cli_aabb.lowerBound.z; - return target.set(1.0 / 12.0 * mass * (2 * y * 2 * y + 2 * z * 2 * z), 1.0 / 12.0 * mass * (2 * x * 2 * x + 2 * z * 2 * z), 1.0 / 12.0 * mass * (2 * y * 2 * y + 2 * x * 2 * x)); - } - /** - * Compute the local AABB for the trimesh - * @method computeLocalAABB - * @param {AABB} aabb - */ - ; - - _proto.computeLocalAABB = function computeLocalAABB(aabb) { - var l = aabb.lowerBound; - var u = aabb.upperBound; - var n = this.vertices.length; - var vertices = this.vertices; - var v = computeLocalAABB_worldVert; - this.getVertex(0, v); - l.copy(v); - u.copy(v); - - for (var i = 0; i !== n; i++) { - this.getVertex(i, v); - - if (v.x < l.x) { - l.x = v.x; - } else if (v.x > u.x) { - u.x = v.x; - } - - if (v.y < l.y) { - l.y = v.y; - } else if (v.y > u.y) { - u.y = v.y; - } - - if (v.z < l.z) { - l.z = v.z; - } else if (v.z > u.z) { - u.z = v.z; - } - } - } - /** - * Update the .aabb property - * @method updateAABB - */ - ; - - _proto.updateAABB = function updateAABB() { - this.computeLocalAABB(this.aabb); - } - /** - * Will update the .boundingSphereRadius property - * @method updateBoundingSphereRadius - */ - ; - - _proto.updateBoundingSphereRadius = function updateBoundingSphereRadius() { - // Assume points are distributed with local (0,0,0) as center - var max2 = 0; - var vertices = this.vertices; - var v = new Vec3(); - - for (var i = 0, N = vertices.length / 3; i !== N; i++) { - this.getVertex(i, v); - var norm2 = v.lengthSquared(); - - if (norm2 > max2) { - max2 = norm2; - } - } - - this.boundingSphereRadius = Math.sqrt(max2); - } - /** - * @method calculateWorldAABB - * @param {Vec3} pos - * @param {Quaternion} quat - * @param {Vec3} min - * @param {Vec3} max - */ - ; - - _proto.calculateWorldAABB = function calculateWorldAABB(pos, quat, min, max) { - /* - const n = this.vertices.length / 3, - verts = this.vertices; - const minx,miny,minz,maxx,maxy,maxz; - const v = tempWorldVertex; - for(let i=0; i maxx || maxx===undefined){ - maxx = v.x; - } - if (v.y < miny || miny===undefined){ - miny = v.y; - } else if(v.y > maxy || maxy===undefined){ - maxy = v.y; - } - if (v.z < minz || minz===undefined){ - minz = v.z; - } else if(v.z > maxz || maxz===undefined){ - maxz = v.z; - } - } - min.set(minx,miny,minz); - max.set(maxx,maxy,maxz); - */ - // Faster approximation using local AABB - var frame = calculateWorldAABB_frame; - var result = calculateWorldAABB_aabb; - frame.position = pos; - frame.quaternion = quat; - this.aabb.toWorldFrame(frame, result); - min.copy(result.lowerBound); - max.copy(result.upperBound); - } - /** - * Get approximate volume - * @method volume - * @return {Number} - */ - ; - - _proto.volume = function volume() { - return 4.0 * Math.PI * this.boundingSphereRadius / 3.0; - }; - - return Trimesh; -}(Shape); -var computeNormals_n = new Vec3(); -var unscaledAABB = new AABB(); -var getEdgeVector_va = new Vec3(); -var getEdgeVector_vb = new Vec3(); -/** - * Get face normal given 3 vertices - * @static - * @method computeNormal - * @param {Vec3} va - * @param {Vec3} vb - * @param {Vec3} vc - * @param {Vec3} target - */ - -var cb = new Vec3(); -var ab = new Vec3(); - -Trimesh.computeNormal = function (va, vb, vc, target) { - vb.vsub(va, ab); - vc.vsub(vb, cb); - cb.cross(ab, target); - - if (!target.isZero()) { - target.normalize(); - } -}; - -var va = new Vec3(); -var vb = new Vec3(); -var vc = new Vec3(); -var cli_aabb = new AABB(); -var computeLocalAABB_worldVert = new Vec3(); -var calculateWorldAABB_frame = new Transform(); -var calculateWorldAABB_aabb = new AABB(); -/** - * Create a Trimesh instance, shaped as a torus. - * @static - * @method createTorus - * @param {number} [radius=1] - * @param {number} [tube=0.5] - * @param {number} [radialSegments=8] - * @param {number} [tubularSegments=6] - * @param {number} [arc=6.283185307179586] - * @return {Trimesh} A torus - */ - -Trimesh.createTorus = function (radius, tube, radialSegments, tubularSegments, arc) { - if (radius === void 0) { - radius = 1; - } - - if (tube === void 0) { - tube = 0.5; - } - - if (radialSegments === void 0) { - radialSegments = 8; - } - - if (tubularSegments === void 0) { - tubularSegments = 6; - } - - if (arc === void 0) { - arc = Math.PI * 2; - } - - var vertices = []; - var indices = []; - - for (var j = 0; j <= radialSegments; j++) { - for (var i = 0; i <= tubularSegments; i++) { - var u = i / tubularSegments * arc; - var v = j / radialSegments * Math.PI * 2; - var x = (radius + tube * Math.cos(v)) * Math.cos(u); - var y = (radius + tube * Math.cos(v)) * Math.sin(u); - var z = tube * Math.sin(v); - vertices.push(x, y, z); - } - } - - for (var _j = 1; _j <= radialSegments; _j++) { - for (var _i2 = 1; _i2 <= tubularSegments; _i2++) { - var a = (tubularSegments + 1) * _j + _i2 - 1; - var b = (tubularSegments + 1) * (_j - 1) + _i2 - 1; - var c = (tubularSegments + 1) * (_j - 1) + _i2; - var d = (tubularSegments + 1) * _j + _i2; - indices.push(a, b, d); - indices.push(b, c, d); - } - } - - return new Trimesh(vertices, indices); -}; - -/** - * Constraint equation solver base class. - * @class Solver - * @constructor - * @author schteppe / https://github.com/schteppe - */ -var Solver = /*#__PURE__*/function () { - // All equations to be solved - function Solver() { - this.equations = []; - } - /** - * Should be implemented in subclasses! - * @method solve - * @param {Number} dt - * @param {World} world - * @return {Number} number of iterations performed - */ - - - var _proto = Solver.prototype; - - _proto.solve = function solve(dt, world) { - return (// Should return the number of iterations done! - 0 - ); - } - /** - * Add an equation - * @method addEquation - * @param {Equation} eq - */ - ; - - _proto.addEquation = function addEquation(eq) { - if (eq.enabled) { - this.equations.push(eq); - } - } - /** - * Remove an equation - * @method removeEquation - * @param {Equation} eq - */ - ; - - _proto.removeEquation = function removeEquation(eq) { - var eqs = this.equations; - var i = eqs.indexOf(eq); - - if (i !== -1) { - eqs.splice(i, 1); - } - } - /** - * Add all equations - * @method removeAllEquations - */ - ; - - _proto.removeAllEquations = function removeAllEquations() { - this.equations.length = 0; - }; - - return Solver; -}(); - -/** - * Constraint equation Gauss-Seidel solver. - * @class GSSolver - * @constructor - * @todo The spook parameters should be specified for each constraint, not globally. - * @author schteppe / https://github.com/schteppe - * @see https://www8.cs.umu.se/kurser/5DV058/VT09/lectures/spooknotes.pdf - * @extends Solver - */ -var GSSolver = /*#__PURE__*/function (_Solver) { - _inheritsLoose(GSSolver, _Solver); - - // The number of solver iterations determines quality of the constraints in the world. The more iterations, the more correct simulation. More iterations need more computations though. If you have a large gravity force in your world, you will need more iterations. - // When tolerance is reached, the system is assumed to be converged. - function GSSolver() { - var _this; - - _this = _Solver.call(this) || this; - _this.iterations = 10; - _this.tolerance = 1e-7; - return _this; - } - /** - * Solve - * @method solve - * @param {Number} dt - * @param {World} world - * @return {Number} number of iterations performed - */ - - - var _proto = GSSolver.prototype; - - _proto.solve = function solve(dt, world) { - var iter = 0; - var maxIter = this.iterations; - var tolSquared = this.tolerance * this.tolerance; - var equations = this.equations; - var Neq = equations.length; - var bodies = world.bodies; - var Nbodies = bodies.length; - var h = dt; - var B; - var invC; - var deltalambda; - var deltalambdaTot; - var GWlambda; - var lambdaj; // Update solve mass - - if (Neq !== 0) { - for (var i = 0; i !== Nbodies; i++) { - bodies[i].updateSolveMassProperties(); - } - } // Things that does not change during iteration can be computed once - - - var invCs = GSSolver_solve_invCs; - var Bs = GSSolver_solve_Bs; - var lambda = GSSolver_solve_lambda; - invCs.length = Neq; - Bs.length = Neq; - lambda.length = Neq; - - for (var _i = 0; _i !== Neq; _i++) { - var c = equations[_i]; - lambda[_i] = 0.0; - Bs[_i] = c.computeB(h); - invCs[_i] = 1.0 / c.computeC(); - } - - if (Neq !== 0) { - // Reset vlambda - for (var _i2 = 0; _i2 !== Nbodies; _i2++) { - var b = bodies[_i2]; - var vlambda = b.vlambda; - var wlambda = b.wlambda; - vlambda.set(0, 0, 0); - wlambda.set(0, 0, 0); - } // Iterate over equations - - - for (iter = 0; iter !== maxIter; iter++) { - // Accumulate the total error for each iteration. - deltalambdaTot = 0.0; - - for (var j = 0; j !== Neq; j++) { - var _c = equations[j]; // Compute iteration - - B = Bs[j]; - invC = invCs[j]; - lambdaj = lambda[j]; - GWlambda = _c.computeGWlambda(); - deltalambda = invC * (B - GWlambda - _c.eps * lambdaj); // Clamp if we are not within the min/max interval - - if (lambdaj + deltalambda < _c.minForce) { - deltalambda = _c.minForce - lambdaj; - } else if (lambdaj + deltalambda > _c.maxForce) { - deltalambda = _c.maxForce - lambdaj; - } - - lambda[j] += deltalambda; - deltalambdaTot += deltalambda > 0.0 ? deltalambda : -deltalambda; // abs(deltalambda) - - _c.addToWlambda(deltalambda); - } // If the total error is small enough - stop iterate - - - if (deltalambdaTot * deltalambdaTot < tolSquared) { - break; - } - } // Add result to velocity - - - for (var _i3 = 0; _i3 !== Nbodies; _i3++) { - var _b = bodies[_i3]; - var v = _b.velocity; - var w = _b.angularVelocity; - - _b.vlambda.vmul(_b.linearFactor, _b.vlambda); - - v.vadd(_b.vlambda, v); - - _b.wlambda.vmul(_b.angularFactor, _b.wlambda); - - w.vadd(_b.wlambda, w); - } // Set the .multiplier property of each equation - - - var l = equations.length; - var invDt = 1 / h; - - while (l--) { - equations[l].multiplier = lambda[l] * invDt; - } - } - - return iter; - }; - - return GSSolver; -}(Solver); -var GSSolver_solve_lambda = []; // Just temporary number holders that we want to reuse each solve. - -var GSSolver_solve_invCs = []; -var GSSolver_solve_Bs = []; - -/** - * Splits the equations into islands and solves them independently. Can improve performance. - * @class SplitSolver - * @constructor - * @extends Solver - * @param {Solver} subsolver - */ -var SplitSolver = /*#__PURE__*/function (_Solver) { - _inheritsLoose(SplitSolver, _Solver); - - // The number of solver iterations determines quality of the constraints in the world. The more iterations, the more correct simulation. More iterations need more computations though. If you have a large gravity force in your world, you will need more iterations. - // When tolerance is reached, the system is assumed to be converged. - function SplitSolver(subsolver) { - var _this; - - _this = _Solver.call(this) || this; - _this.iterations = 10; - _this.tolerance = 1e-7; - _this.subsolver = subsolver; - _this.nodes = []; - _this.nodePool = []; // Create needed nodes, reuse if possible - - while (_this.nodePool.length < 128) { - _this.nodePool.push(_this.createNode()); - } - - return _this; - } - - var _proto = SplitSolver.prototype; - - _proto.createNode = function createNode() { - return { - body: null, - children: [], - eqs: [], - visited: false - }; - } - /** - * Solve the subsystems - * @method solve - * @param {Number} dt - * @param {World} world - * @return {Number} number of iterations performed - */ - ; - - _proto.solve = function solve(dt, world) { - var nodes = SplitSolver_solve_nodes; - var nodePool = this.nodePool; - var bodies = world.bodies; - var equations = this.equations; - var Neq = equations.length; - var Nbodies = bodies.length; - var subsolver = this.subsolver; // Create needed nodes, reuse if possible - - while (nodePool.length < Nbodies) { - nodePool.push(this.createNode()); - } - - nodes.length = Nbodies; - - for (var i = 0; i < Nbodies; i++) { - nodes[i] = nodePool[i]; - } // Reset node values - - - for (var _i = 0; _i !== Nbodies; _i++) { - var _node = nodes[_i]; - _node.body = bodies[_i]; - _node.children.length = 0; - _node.eqs.length = 0; - _node.visited = false; - } - - for (var k = 0; k !== Neq; k++) { - var eq = equations[k]; - - var _i2 = bodies.indexOf(eq.bi); - - var j = bodies.indexOf(eq.bj); - var ni = nodes[_i2]; - var nj = nodes[j]; - ni.children.push(nj); - ni.eqs.push(eq); - nj.children.push(ni); - nj.eqs.push(eq); - } - - var child; - var n = 0; - var eqs = SplitSolver_solve_eqs; - subsolver.tolerance = this.tolerance; - subsolver.iterations = this.iterations; - var dummyWorld = SplitSolver_solve_dummyWorld; - - while (child = getUnvisitedNode(nodes)) { - eqs.length = 0; - dummyWorld.bodies.length = 0; - bfs(child, visitFunc, dummyWorld.bodies, eqs); - var Neqs = eqs.length; - eqs = eqs.sort(sortById); - - for (var _i3 = 0; _i3 !== Neqs; _i3++) { - subsolver.addEquation(eqs[_i3]); - } - - var iter = subsolver.solve(dt, dummyWorld); - subsolver.removeAllEquations(); - n++; - } - - return n; - }; - - return SplitSolver; -}(Solver); // Returns the number of subsystems - -var SplitSolver_solve_nodes = []; // All allocated node objects - -var SplitSolver_solve_eqs = []; // Temp array - -var SplitSolver_solve_dummyWorld = { - bodies: [] -}; // Temp object - -var STATIC = Body.STATIC; - -function getUnvisitedNode(nodes) { - var Nnodes = nodes.length; - - for (var i = 0; i !== Nnodes; i++) { - var _node2 = nodes[i]; - - if (!_node2.visited && !(_node2.body.type & STATIC)) { - return _node2; - } - } - - return false; -} - -var queue = []; - -function bfs(root, visitFunc, bds, eqs) { - queue.push(root); - root.visited = true; - visitFunc(root, bds, eqs); - - while (queue.length) { - var _node3 = queue.pop(); // Loop over unvisited child nodes - - - var child = void 0; - - while (child = getUnvisitedNode(_node3.children)) { - child.visited = true; - visitFunc(child, bds, eqs); - queue.push(child); - } - } -} - -function visitFunc(node, bds, eqs) { - bds.push(node.body); - var Neqs = node.eqs.length; - - for (var i = 0; i !== Neqs; i++) { - var eq = node.eqs[i]; - - if (!eqs.includes(eq)) { - eqs.push(eq); - } - } -} - -function sortById(a, b) { - return b.id - a.id; -} - -/** - * For pooling objects that can be reused. - * @class Pool - * @constructor - */ -var Pool = /*#__PURE__*/function () { - function Pool() { - this.objects = []; - this.type = Object; - } - /** - * Release an object after use - * @method release - * @param {Object} obj - */ - - - var _proto = Pool.prototype; - - _proto.release = function release() { - var Nargs = arguments.length; - - for (var i = 0; i !== Nargs; i++) { - this.objects.push(i < 0 || arguments.length <= i ? undefined : arguments[i]); - } - - return this; - } - /** - * Get an object - * @method get - * @return {mixed} - */ - ; - - _proto.get = function get() { - if (this.objects.length === 0) { - return this.constructObject(); - } else { - return this.objects.pop(); - } - } - /** - * Construct an object. Should be implemented in each subclass. - * @method constructObject - * @return {mixed} - */ - ; - - _proto.constructObject = function constructObject() { - throw new Error('constructObject() not implemented in this Pool subclass yet!'); - } - /** - * @method resize - * @param {number} size - * @return {Pool} Self, for chaining - */ - ; - - _proto.resize = function resize(size) { - var objects = this.objects; - - while (objects.length > size) { - objects.pop(); - } - - while (objects.length < size) { - objects.push(this.constructObject()); - } - - return this; - }; - - return Pool; -}(); - -/** - * @class Vec3Pool - * @constructor - * @extends Pool - */ - -var Vec3Pool = /*#__PURE__*/function (_Pool) { - _inheritsLoose(Vec3Pool, _Pool); - - function Vec3Pool() { - var _this; - - _this = _Pool.call(this) || this; - _this.type = Vec3; - return _this; - } - /** - * Construct a vector - * @method constructObject - * @return {Vec3} - */ - - - var _proto = Vec3Pool.prototype; - - _proto.constructObject = function constructObject() { - return new Vec3(); - }; - - return Vec3Pool; -}(Pool); - -var COLLISION_TYPES = { - sphereSphere: Shape.types.SPHERE, - spherePlane: Shape.types.SPHERE | Shape.types.PLANE, - boxBox: Shape.types.BOX | Shape.types.BOX, - sphereBox: Shape.types.SPHERE | Shape.types.BOX, - planeBox: Shape.types.PLANE | Shape.types.BOX, - convexConvex: Shape.types.CONVEXPOLYHEDRON, - sphereConvex: Shape.types.SPHERE | Shape.types.CONVEXPOLYHEDRON, - planeConvex: Shape.types.PLANE | Shape.types.CONVEXPOLYHEDRON, - boxConvex: Shape.types.BOX | Shape.types.CONVEXPOLYHEDRON, - sphereHeightfield: Shape.types.SPHERE | Shape.types.HEIGHTFIELD, - boxHeightfield: Shape.types.BOX | Shape.types.HEIGHTFIELD, - convexHeightfield: Shape.types.CONVEXPOLYHEDRON | Shape.types.HEIGHTFIELD, - sphereParticle: Shape.types.PARTICLE | Shape.types.SPHERE, - planeParticle: Shape.types.PLANE | Shape.types.PARTICLE, - boxParticle: Shape.types.BOX | Shape.types.PARTICLE, - convexParticle: Shape.types.PARTICLE | Shape.types.CONVEXPOLYHEDRON, - sphereTrimesh: Shape.types.SPHERE | Shape.types.TRIMESH, - planeTrimesh: Shape.types.PLANE | Shape.types.TRIMESH -}; - -/** - * Helper class for the World. Generates ContactEquations. - * @class Narrowphase - * @constructor - * @todo Sphere-ConvexPolyhedron contacts - * @todo Contact reduction - * @todo should move methods to prototype - */ -var Narrowphase = /*#__PURE__*/function () { - // Internal storage of pooled contact points. - // Pooled vectors. - function Narrowphase(world) { - this.contactPointPool = []; - this.frictionEquationPool = []; - this.result = []; - this.frictionResult = []; - this.v3pool = new Vec3Pool(); - this.world = world; - this.currentContactMaterial = world.defaultContactMaterial; - this.enableFrictionReduction = false; - } - /** - * Make a contact object, by using the internal pool or creating a new one. - * @method createContactEquation - * @param {Body} bi - * @param {Body} bj - * @param {Shape} si - * @param {Shape} sj - * @param {Shape} overrideShapeA - * @param {Shape} overrideShapeB - * @return {ContactEquation} - */ - - - var _proto = Narrowphase.prototype; - - _proto.createContactEquation = function createContactEquation(bi, bj, si, sj, overrideShapeA, overrideShapeB) { - var c; - - if (this.contactPointPool.length) { - c = this.contactPointPool.pop(); - c.bi = bi; - c.bj = bj; - } else { - c = new ContactEquation(bi, bj); - } - - c.enabled = bi.collisionResponse && bj.collisionResponse && si.collisionResponse && sj.collisionResponse; - var cm = this.currentContactMaterial; - c.restitution = cm.restitution; - c.setSpookParams(cm.contactEquationStiffness, cm.contactEquationRelaxation, this.world.dt); - var matA = si.material || bi.material; - var matB = sj.material || bj.material; - - if (matA && matB && matA.restitution >= 0 && matB.restitution >= 0) { - c.restitution = matA.restitution * matB.restitution; - } - - c.si = overrideShapeA || si; - c.sj = overrideShapeB || sj; - return c; - }; - - _proto.createFrictionEquationsFromContact = function createFrictionEquationsFromContact(contactEquation, outArray) { - var bodyA = contactEquation.bi; - var bodyB = contactEquation.bj; - var shapeA = contactEquation.si; - var shapeB = contactEquation.sj; - var world = this.world; - var cm = this.currentContactMaterial; // If friction or restitution were specified in the material, use them - - var friction = cm.friction; - var matA = shapeA.material || bodyA.material; - var matB = shapeB.material || bodyB.material; - - if (matA && matB && matA.friction >= 0 && matB.friction >= 0) { - friction = matA.friction * matB.friction; - } - - if (friction > 0) { - // Create 2 tangent equations - var mug = friction * world.gravity.length(); - var reducedMass = bodyA.invMass + bodyB.invMass; - - if (reducedMass > 0) { - reducedMass = 1 / reducedMass; - } - - var pool = this.frictionEquationPool; - var c1 = pool.length ? pool.pop() : new FrictionEquation(bodyA, bodyB, mug * reducedMass); - var c2 = pool.length ? pool.pop() : new FrictionEquation(bodyA, bodyB, mug * reducedMass); - c1.bi = c2.bi = bodyA; - c1.bj = c2.bj = bodyB; - c1.minForce = c2.minForce = -mug * reducedMass; - c1.maxForce = c2.maxForce = mug * reducedMass; // Copy over the relative vectors - - c1.ri.copy(contactEquation.ri); - c1.rj.copy(contactEquation.rj); - c2.ri.copy(contactEquation.ri); - c2.rj.copy(contactEquation.rj); // Construct tangents - - contactEquation.ni.tangents(c1.t, c2.t); // Set spook params - - c1.setSpookParams(cm.frictionEquationStiffness, cm.frictionEquationRelaxation, world.dt); - c2.setSpookParams(cm.frictionEquationStiffness, cm.frictionEquationRelaxation, world.dt); - c1.enabled = c2.enabled = contactEquation.enabled; - outArray.push(c1, c2); - return true; - } - - return false; - } // Take the average N latest contact point on the plane. - ; - - _proto.createFrictionFromAverage = function createFrictionFromAverage(numContacts) { - // The last contactEquation - var c = this.result[this.result.length - 1]; // Create the result: two "average" friction equations - - if (!this.createFrictionEquationsFromContact(c, this.frictionResult) || numContacts === 1) { - return; - } - - var f1 = this.frictionResult[this.frictionResult.length - 2]; - var f2 = this.frictionResult[this.frictionResult.length - 1]; - averageNormal.setZero(); - averageContactPointA.setZero(); - averageContactPointB.setZero(); - var bodyA = c.bi; - var bodyB = c.bj; - - for (var i = 0; i !== numContacts; i++) { - c = this.result[this.result.length - 1 - i]; - - if (c.bi !== bodyA) { - averageNormal.vadd(c.ni, averageNormal); - averageContactPointA.vadd(c.ri, averageContactPointA); - averageContactPointB.vadd(c.rj, averageContactPointB); - } else { - averageNormal.vsub(c.ni, averageNormal); - averageContactPointA.vadd(c.rj, averageContactPointA); - averageContactPointB.vadd(c.ri, averageContactPointB); - } - } - - var invNumContacts = 1 / numContacts; - averageContactPointA.scale(invNumContacts, f1.ri); - averageContactPointB.scale(invNumContacts, f1.rj); - f2.ri.copy(f1.ri); // Should be the same - - f2.rj.copy(f1.rj); - averageNormal.normalize(); - averageNormal.tangents(f1.t, f2.t); // return eq; - } - /** - * Generate all contacts between a list of body pairs - * @method getContacts - * @param {array} p1 Array of body indices - * @param {array} p2 Array of body indices - * @param {World} world - * @param {array} result Array to store generated contacts - * @param {array} oldcontacts Optional. Array of reusable contact objects - */ - ; - - _proto.getContacts = function getContacts(p1, p2, world, result, oldcontacts, frictionResult, frictionPool) { - // Save old contact objects - this.contactPointPool = oldcontacts; - this.frictionEquationPool = frictionPool; - this.result = result; - this.frictionResult = frictionResult; - var qi = tmpQuat1; - var qj = tmpQuat2; - var xi = tmpVec1$3; - var xj = tmpVec2$3; - - for (var k = 0, N = p1.length; k !== N; k++) { - // Get current collision bodies - var bi = p1[k]; - var bj = p2[k]; // Get contact material - - var bodyContactMaterial = null; - - if (bi.material && bj.material) { - bodyContactMaterial = world.getContactMaterial(bi.material, bj.material) || null; - } - - var justTest = bi.type & Body.KINEMATIC && bj.type & Body.STATIC || bi.type & Body.STATIC && bj.type & Body.KINEMATIC || bi.type & Body.KINEMATIC && bj.type & Body.KINEMATIC; - - for (var i = 0; i < bi.shapes.length; i++) { - bi.quaternion.mult(bi.shapeOrientations[i], qi); - bi.quaternion.vmult(bi.shapeOffsets[i], xi); - xi.vadd(bi.position, xi); - var si = bi.shapes[i]; - - for (var j = 0; j < bj.shapes.length; j++) { - // Compute world transform of shapes - bj.quaternion.mult(bj.shapeOrientations[j], qj); - bj.quaternion.vmult(bj.shapeOffsets[j], xj); - xj.vadd(bj.position, xj); - var sj = bj.shapes[j]; - - if (!(si.collisionFilterMask & sj.collisionFilterGroup && sj.collisionFilterMask & si.collisionFilterGroup)) { - continue; - } - - if (xi.distanceTo(xj) > si.boundingSphereRadius + sj.boundingSphereRadius) { - continue; - } // Get collision material - - - var shapeContactMaterial = null; - - if (si.material && sj.material) { - shapeContactMaterial = world.getContactMaterial(si.material, sj.material) || null; - } - - this.currentContactMaterial = shapeContactMaterial || bodyContactMaterial || world.defaultContactMaterial; // Get contacts - - var resolverIndex = si.type | sj.type; - var resolver = this[resolverIndex]; - - if (resolver) { - var retval = false; // TO DO: investigate why sphereParticle and convexParticle - // resolvers expect si and sj shapes to be in reverse order - // (i.e. larger integer value type first instead of smaller first) - - if (si.type < sj.type) { - retval = resolver.call(this, si, sj, xi, xj, qi, qj, bi, bj, si, sj, justTest); - } else { - retval = resolver.call(this, sj, si, xj, xi, qj, qi, bj, bi, si, sj, justTest); - } - - if (retval && justTest) { - // Register overlap - world.shapeOverlapKeeper.set(si.id, sj.id); - world.bodyOverlapKeeper.set(bi.id, bj.id); - } - } - } - } - } - }; - - _proto.sphereSphere = function sphereSphere(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) { - if (justTest) { - return xi.distanceSquared(xj) < Math.pow(si.radius + sj.radius, 2); - } // We will have only one contact in this case - - - var r = this.createContactEquation(bi, bj, si, sj, rsi, rsj); // Contact normal - - xj.vsub(xi, r.ni); - r.ni.normalize(); // Contact point locations - - r.ri.copy(r.ni); - r.rj.copy(r.ni); - r.ri.scale(si.radius, r.ri); - r.rj.scale(-sj.radius, r.rj); - r.ri.vadd(xi, r.ri); - r.ri.vsub(bi.position, r.ri); - r.rj.vadd(xj, r.rj); - r.rj.vsub(bj.position, r.rj); - this.result.push(r); - this.createFrictionEquationsFromContact(r, this.frictionResult); - }; - - _proto.spherePlane = function spherePlane(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) { - // We will have one contact in this case - var r = this.createContactEquation(bi, bj, si, sj, rsi, rsj); // Contact normal - - r.ni.set(0, 0, 1); - qj.vmult(r.ni, r.ni); - r.ni.negate(r.ni); // body i is the sphere, flip normal - - r.ni.normalize(); // Needed? - // Vector from sphere center to contact point - - r.ni.scale(si.radius, r.ri); // Project down sphere on plane - - xi.vsub(xj, point_on_plane_to_sphere); - r.ni.scale(r.ni.dot(point_on_plane_to_sphere), plane_to_sphere_ortho); - point_on_plane_to_sphere.vsub(plane_to_sphere_ortho, r.rj); // The sphere position projected to plane - - if (-point_on_plane_to_sphere.dot(r.ni) <= si.radius) { - if (justTest) { - return true; - } // Make it relative to the body - - - var ri = r.ri; - var rj = r.rj; - ri.vadd(xi, ri); - ri.vsub(bi.position, ri); - rj.vadd(xj, rj); - rj.vsub(bj.position, rj); - this.result.push(r); - this.createFrictionEquationsFromContact(r, this.frictionResult); - } - }; - - _proto.boxBox = function boxBox(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) { - si.convexPolyhedronRepresentation.material = si.material; - sj.convexPolyhedronRepresentation.material = sj.material; - si.convexPolyhedronRepresentation.collisionResponse = si.collisionResponse; - sj.convexPolyhedronRepresentation.collisionResponse = sj.collisionResponse; - return this.convexConvex(si.convexPolyhedronRepresentation, sj.convexPolyhedronRepresentation, xi, xj, qi, qj, bi, bj, si, sj, justTest); - }; - - _proto.sphereBox = function sphereBox(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) { - var v3pool = this.v3pool; // we refer to the box as body j - - var sides = sphereBox_sides; - xi.vsub(xj, box_to_sphere); - sj.getSideNormals(sides, qj); - var R = si.radius; - - var found = false; // Store the resulting side penetration info - - var side_ns = sphereBox_side_ns; - var side_ns1 = sphereBox_side_ns1; - var side_ns2 = sphereBox_side_ns2; - var side_h = null; - var side_penetrations = 0; - var side_dot1 = 0; - var side_dot2 = 0; - var side_distance = null; - - for (var idx = 0, nsides = sides.length; idx !== nsides && found === false; idx++) { - // Get the plane side normal (ns) - var ns = sphereBox_ns; - ns.copy(sides[idx]); - var h = ns.length(); - ns.normalize(); // The normal/distance dot product tells which side of the plane we are - - var dot = box_to_sphere.dot(ns); - - if (dot < h + R && dot > 0) { - // Intersects plane. Now check the other two dimensions - var ns1 = sphereBox_ns1; - var ns2 = sphereBox_ns2; - ns1.copy(sides[(idx + 1) % 3]); - ns2.copy(sides[(idx + 2) % 3]); - var h1 = ns1.length(); - var h2 = ns2.length(); - ns1.normalize(); - ns2.normalize(); - var dot1 = box_to_sphere.dot(ns1); - var dot2 = box_to_sphere.dot(ns2); - - if (dot1 < h1 && dot1 > -h1 && dot2 < h2 && dot2 > -h2) { - var _dist = Math.abs(dot - h - R); - - if (side_distance === null || _dist < side_distance) { - side_distance = _dist; - side_dot1 = dot1; - side_dot2 = dot2; - side_h = h; - side_ns.copy(ns); - side_ns1.copy(ns1); - side_ns2.copy(ns2); - side_penetrations++; - - if (justTest) { - return true; - } - } - } - } - } - - if (side_penetrations) { - found = true; - - var _r = this.createContactEquation(bi, bj, si, sj, rsi, rsj); - - side_ns.scale(-R, _r.ri); // Sphere r - - _r.ni.copy(side_ns); - - _r.ni.negate(_r.ni); // Normal should be out of sphere - - - side_ns.scale(side_h, side_ns); - side_ns1.scale(side_dot1, side_ns1); - side_ns.vadd(side_ns1, side_ns); - side_ns2.scale(side_dot2, side_ns2); - side_ns.vadd(side_ns2, _r.rj); // Make relative to bodies - - _r.ri.vadd(xi, _r.ri); - - _r.ri.vsub(bi.position, _r.ri); - - _r.rj.vadd(xj, _r.rj); - - _r.rj.vsub(bj.position, _r.rj); - - this.result.push(_r); - this.createFrictionEquationsFromContact(_r, this.frictionResult); - } // Check corners - - - var rj = v3pool.get(); - var sphere_to_corner = sphereBox_sphere_to_corner; - - for (var j = 0; j !== 2 && !found; j++) { - for (var k = 0; k !== 2 && !found; k++) { - for (var l = 0; l !== 2 && !found; l++) { - rj.set(0, 0, 0); - - if (j) { - rj.vadd(sides[0], rj); - } else { - rj.vsub(sides[0], rj); - } - - if (k) { - rj.vadd(sides[1], rj); - } else { - rj.vsub(sides[1], rj); - } - - if (l) { - rj.vadd(sides[2], rj); - } else { - rj.vsub(sides[2], rj); - } // World position of corner - - - xj.vadd(rj, sphere_to_corner); - sphere_to_corner.vsub(xi, sphere_to_corner); - - if (sphere_to_corner.lengthSquared() < R * R) { - if (justTest) { - return true; - } - - found = true; - - var _r2 = this.createContactEquation(bi, bj, si, sj, rsi, rsj); - - _r2.ri.copy(sphere_to_corner); - - _r2.ri.normalize(); - - _r2.ni.copy(_r2.ri); - - _r2.ri.scale(R, _r2.ri); - - _r2.rj.copy(rj); // Make relative to bodies - - - _r2.ri.vadd(xi, _r2.ri); - - _r2.ri.vsub(bi.position, _r2.ri); - - _r2.rj.vadd(xj, _r2.rj); - - _r2.rj.vsub(bj.position, _r2.rj); - - this.result.push(_r2); - this.createFrictionEquationsFromContact(_r2, this.frictionResult); - } - } - } - } - - v3pool.release(rj); - rj = null; // Check edges - - var edgeTangent = v3pool.get(); - var edgeCenter = v3pool.get(); - var r = v3pool.get(); // r = edge center to sphere center - - var orthogonal = v3pool.get(); - var dist = v3pool.get(); - var Nsides = sides.length; - - for (var _j = 0; _j !== Nsides && !found; _j++) { - for (var _k = 0; _k !== Nsides && !found; _k++) { - if (_j % 3 !== _k % 3) { - // Get edge tangent - sides[_k].cross(sides[_j], edgeTangent); - - edgeTangent.normalize(); - - sides[_j].vadd(sides[_k], edgeCenter); - - r.copy(xi); - r.vsub(edgeCenter, r); - r.vsub(xj, r); - var orthonorm = r.dot(edgeTangent); // distance from edge center to sphere center in the tangent direction - - edgeTangent.scale(orthonorm, orthogonal); // Vector from edge center to sphere center in the tangent direction - // Find the third side orthogonal to this one - - var _l = 0; - - while (_l === _j % 3 || _l === _k % 3) { - _l++; - } // vec from edge center to sphere projected to the plane orthogonal to the edge tangent - - - dist.copy(xi); - dist.vsub(orthogonal, dist); - dist.vsub(edgeCenter, dist); - dist.vsub(xj, dist); // Distances in tangent direction and distance in the plane orthogonal to it - - var tdist = Math.abs(orthonorm); - var ndist = dist.length(); - - if (tdist < sides[_l].length() && ndist < R) { - if (justTest) { - return true; - } - - found = true; - var res = this.createContactEquation(bi, bj, si, sj, rsi, rsj); - edgeCenter.vadd(orthogonal, res.rj); // box rj - - res.rj.copy(res.rj); - dist.negate(res.ni); - res.ni.normalize(); - res.ri.copy(res.rj); - res.ri.vadd(xj, res.ri); - res.ri.vsub(xi, res.ri); - res.ri.normalize(); - res.ri.scale(R, res.ri); // Make relative to bodies - - res.ri.vadd(xi, res.ri); - res.ri.vsub(bi.position, res.ri); - res.rj.vadd(xj, res.rj); - res.rj.vsub(bj.position, res.rj); - this.result.push(res); - this.createFrictionEquationsFromContact(res, this.frictionResult); - } - } - } - } - - v3pool.release(edgeTangent, edgeCenter, r, orthogonal, dist); - }; - - _proto.planeBox = function planeBox(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) { - sj.convexPolyhedronRepresentation.material = sj.material; - sj.convexPolyhedronRepresentation.collisionResponse = sj.collisionResponse; - sj.convexPolyhedronRepresentation.id = sj.id; - return this.planeConvex(si, sj.convexPolyhedronRepresentation, xi, xj, qi, qj, bi, bj, si, sj, justTest); - }; - - _proto.convexConvex = function convexConvex(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest, faceListA, faceListB) { - var sepAxis = convexConvex_sepAxis; - - if (xi.distanceTo(xj) > si.boundingSphereRadius + sj.boundingSphereRadius) { - return; - } - - if (si.findSeparatingAxis(sj, xi, qi, xj, qj, sepAxis, faceListA, faceListB)) { - var res = []; - var q = convexConvex_q; - si.clipAgainstHull(xi, qi, sj, xj, qj, sepAxis, -100, 100, res); - var numContacts = 0; - - for (var j = 0; j !== res.length; j++) { - if (justTest) { - return true; - } - - var r = this.createContactEquation(bi, bj, si, sj, rsi, rsj); - var ri = r.ri; - var rj = r.rj; - sepAxis.negate(r.ni); - res[j].normal.negate(q); - q.scale(res[j].depth, q); - res[j].point.vadd(q, ri); - rj.copy(res[j].point); // Contact points are in world coordinates. Transform back to relative - - ri.vsub(xi, ri); - rj.vsub(xj, rj); // Make relative to bodies - - ri.vadd(xi, ri); - ri.vsub(bi.position, ri); - rj.vadd(xj, rj); - rj.vsub(bj.position, rj); - this.result.push(r); - numContacts++; - - if (!this.enableFrictionReduction) { - this.createFrictionEquationsFromContact(r, this.frictionResult); - } - } - - if (this.enableFrictionReduction && numContacts) { - this.createFrictionFromAverage(numContacts); - } - } - }; - - _proto.sphereConvex = function sphereConvex(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) { - var v3pool = this.v3pool; - xi.vsub(xj, convex_to_sphere); - var normals = sj.faceNormals; - var faces = sj.faces; - var verts = sj.vertices; - var R = si.radius; - // return; - // } - - var found = false; // Check corners - - for (var i = 0; i !== verts.length; i++) { - var v = verts[i]; // World position of corner - - var worldCorner = sphereConvex_worldCorner; - qj.vmult(v, worldCorner); - xj.vadd(worldCorner, worldCorner); - var sphere_to_corner = sphereConvex_sphereToCorner; - worldCorner.vsub(xi, sphere_to_corner); - - if (sphere_to_corner.lengthSquared() < R * R) { - if (justTest) { - return true; - } - - found = true; - var r = this.createContactEquation(bi, bj, si, sj, rsi, rsj); - r.ri.copy(sphere_to_corner); - r.ri.normalize(); - r.ni.copy(r.ri); - r.ri.scale(R, r.ri); - worldCorner.vsub(xj, r.rj); // Should be relative to the body. - - r.ri.vadd(xi, r.ri); - r.ri.vsub(bi.position, r.ri); // Should be relative to the body. - - r.rj.vadd(xj, r.rj); - r.rj.vsub(bj.position, r.rj); - this.result.push(r); - this.createFrictionEquationsFromContact(r, this.frictionResult); - return; - } - } // Check side (plane) intersections - - - for (var _i = 0, nfaces = faces.length; _i !== nfaces && found === false; _i++) { - var normal = normals[_i]; - var face = faces[_i]; // Get world-transformed normal of the face - - var worldNormal = sphereConvex_worldNormal; - qj.vmult(normal, worldNormal); // Get a world vertex from the face - - var worldPoint = sphereConvex_worldPoint; - qj.vmult(verts[face[0]], worldPoint); - worldPoint.vadd(xj, worldPoint); // Get a point on the sphere, closest to the face normal - - var worldSpherePointClosestToPlane = sphereConvex_worldSpherePointClosestToPlane; - worldNormal.scale(-R, worldSpherePointClosestToPlane); - xi.vadd(worldSpherePointClosestToPlane, worldSpherePointClosestToPlane); // Vector from a face point to the closest point on the sphere - - var penetrationVec = sphereConvex_penetrationVec; - worldSpherePointClosestToPlane.vsub(worldPoint, penetrationVec); // The penetration. Negative value means overlap. - - var penetration = penetrationVec.dot(worldNormal); - var worldPointToSphere = sphereConvex_sphereToWorldPoint; - xi.vsub(worldPoint, worldPointToSphere); - - if (penetration < 0 && worldPointToSphere.dot(worldNormal) > 0) { - // Intersects plane. Now check if the sphere is inside the face polygon - var faceVerts = []; // Face vertices, in world coords - - for (var j = 0, Nverts = face.length; j !== Nverts; j++) { - var worldVertex = v3pool.get(); - qj.vmult(verts[face[j]], worldVertex); - xj.vadd(worldVertex, worldVertex); - faceVerts.push(worldVertex); - } - - if (pointInPolygon(faceVerts, worldNormal, xi)) { - // Is the sphere center in the face polygon? - if (justTest) { - return true; - } - - found = true; - - var _r3 = this.createContactEquation(bi, bj, si, sj, rsi, rsj); - - worldNormal.scale(-R, _r3.ri); // Contact offset, from sphere center to contact - - worldNormal.negate(_r3.ni); // Normal pointing out of sphere - - var penetrationVec2 = v3pool.get(); - worldNormal.scale(-penetration, penetrationVec2); - var penetrationSpherePoint = v3pool.get(); - worldNormal.scale(-R, penetrationSpherePoint); //xi.vsub(xj).vadd(penetrationSpherePoint).vadd(penetrationVec2 , r.rj); - - xi.vsub(xj, _r3.rj); - - _r3.rj.vadd(penetrationSpherePoint, _r3.rj); - - _r3.rj.vadd(penetrationVec2, _r3.rj); // Should be relative to the body. - - - _r3.rj.vadd(xj, _r3.rj); - - _r3.rj.vsub(bj.position, _r3.rj); // Should be relative to the body. - - - _r3.ri.vadd(xi, _r3.ri); - - _r3.ri.vsub(bi.position, _r3.ri); - - v3pool.release(penetrationVec2); - v3pool.release(penetrationSpherePoint); - this.result.push(_r3); - this.createFrictionEquationsFromContact(_r3, this.frictionResult); // Release world vertices - - for (var _j2 = 0, Nfaceverts = faceVerts.length; _j2 !== Nfaceverts; _j2++) { - v3pool.release(faceVerts[_j2]); - } - - return; // We only expect *one* face contact - } else { - // Edge? - for (var _j3 = 0; _j3 !== face.length; _j3++) { - // Get two world transformed vertices - var v1 = v3pool.get(); - var v2 = v3pool.get(); - qj.vmult(verts[face[(_j3 + 1) % face.length]], v1); - qj.vmult(verts[face[(_j3 + 2) % face.length]], v2); - xj.vadd(v1, v1); - xj.vadd(v2, v2); // Construct edge vector - - var edge = sphereConvex_edge; - v2.vsub(v1, edge); // Construct the same vector, but normalized - - var edgeUnit = sphereConvex_edgeUnit; - edge.unit(edgeUnit); // p is xi projected onto the edge - - var p = v3pool.get(); - var v1_to_xi = v3pool.get(); - xi.vsub(v1, v1_to_xi); - var dot = v1_to_xi.dot(edgeUnit); - edgeUnit.scale(dot, p); - p.vadd(v1, p); // Compute a vector from p to the center of the sphere - - var xi_to_p = v3pool.get(); - p.vsub(xi, xi_to_p); // Collision if the edge-sphere distance is less than the radius - // AND if p is in between v1 and v2 - - if (dot > 0 && dot * dot < edge.lengthSquared() && xi_to_p.lengthSquared() < R * R) { - // Collision if the edge-sphere distance is less than the radius - // Edge contact! - if (justTest) { - return true; - } - - var _r4 = this.createContactEquation(bi, bj, si, sj, rsi, rsj); - - p.vsub(xj, _r4.rj); - p.vsub(xi, _r4.ni); - - _r4.ni.normalize(); - - _r4.ni.scale(R, _r4.ri); // Should be relative to the body. - - - _r4.rj.vadd(xj, _r4.rj); - - _r4.rj.vsub(bj.position, _r4.rj); // Should be relative to the body. - - - _r4.ri.vadd(xi, _r4.ri); - - _r4.ri.vsub(bi.position, _r4.ri); - - this.result.push(_r4); - this.createFrictionEquationsFromContact(_r4, this.frictionResult); // Release world vertices - - for (var _j4 = 0, _Nfaceverts = faceVerts.length; _j4 !== _Nfaceverts; _j4++) { - v3pool.release(faceVerts[_j4]); - } - - v3pool.release(v1); - v3pool.release(v2); - v3pool.release(p); - v3pool.release(xi_to_p); - v3pool.release(v1_to_xi); - return; - } - - v3pool.release(v1); - v3pool.release(v2); - v3pool.release(p); - v3pool.release(xi_to_p); - v3pool.release(v1_to_xi); - } - } // Release world vertices - - - for (var _j5 = 0, _Nfaceverts2 = faceVerts.length; _j5 !== _Nfaceverts2; _j5++) { - v3pool.release(faceVerts[_j5]); - } - } - } - }; - - _proto.planeConvex = function planeConvex(planeShape, convexShape, planePosition, convexPosition, planeQuat, convexQuat, planeBody, convexBody, si, sj, justTest) { - // Simply return the points behind the plane. - var worldVertex = planeConvex_v; - var worldNormal = planeConvex_normal; - worldNormal.set(0, 0, 1); - planeQuat.vmult(worldNormal, worldNormal); // Turn normal according to plane orientation - - var numContacts = 0; - var relpos = planeConvex_relpos; - - for (var i = 0; i !== convexShape.vertices.length; i++) { - // Get world convex vertex - worldVertex.copy(convexShape.vertices[i]); - convexQuat.vmult(worldVertex, worldVertex); - convexPosition.vadd(worldVertex, worldVertex); - worldVertex.vsub(planePosition, relpos); - var dot = worldNormal.dot(relpos); - - if (dot <= 0.0) { - if (justTest) { - return true; - } - - var r = this.createContactEquation(planeBody, convexBody, planeShape, convexShape, si, sj); // Get vertex position projected on plane - - var projected = planeConvex_projected; - worldNormal.scale(worldNormal.dot(relpos), projected); - worldVertex.vsub(projected, projected); - projected.vsub(planePosition, r.ri); // From plane to vertex projected on plane - - r.ni.copy(worldNormal); // Contact normal is the plane normal out from plane - // rj is now just the vector from the convex center to the vertex - - worldVertex.vsub(convexPosition, r.rj); // Make it relative to the body - - r.ri.vadd(planePosition, r.ri); - r.ri.vsub(planeBody.position, r.ri); - r.rj.vadd(convexPosition, r.rj); - r.rj.vsub(convexBody.position, r.rj); - this.result.push(r); - numContacts++; - - if (!this.enableFrictionReduction) { - this.createFrictionEquationsFromContact(r, this.frictionResult); - } - } - } - - if (this.enableFrictionReduction && numContacts) { - this.createFrictionFromAverage(numContacts); - } - }; - - _proto.boxConvex = function boxConvex(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) { - si.convexPolyhedronRepresentation.material = si.material; - si.convexPolyhedronRepresentation.collisionResponse = si.collisionResponse; - return this.convexConvex(si.convexPolyhedronRepresentation, sj, xi, xj, qi, qj, bi, bj, si, sj, justTest); - }; - - _proto.sphereHeightfield = function sphereHeightfield(sphereShape, hfShape, spherePos, hfPos, sphereQuat, hfQuat, sphereBody, hfBody, rsi, rsj, justTest) { - var data = hfShape.data; - var radius = sphereShape.radius; - var w = hfShape.elementSize; - var worldPillarOffset = sphereHeightfield_tmp2; // Get sphere position to heightfield local! - - var localSpherePos = sphereHeightfield_tmp1; - Transform.pointToLocalFrame(hfPos, hfQuat, spherePos, localSpherePos); // Get the index of the data points to test against - - var iMinX = Math.floor((localSpherePos.x - radius) / w) - 1; - var iMaxX = Math.ceil((localSpherePos.x + radius) / w) + 1; - var iMinY = Math.floor((localSpherePos.y - radius) / w) - 1; - var iMaxY = Math.ceil((localSpherePos.y + radius) / w) + 1; // Bail out if we are out of the terrain - - if (iMaxX < 0 || iMaxY < 0 || iMinX > data.length || iMinY > data[0].length) { - return; - } // Clamp index to edges - - - if (iMinX < 0) { - iMinX = 0; - } - - if (iMaxX < 0) { - iMaxX = 0; - } - - if (iMinY < 0) { - iMinY = 0; - } - - if (iMaxY < 0) { - iMaxY = 0; - } - - if (iMinX >= data.length) { - iMinX = data.length - 1; - } - - if (iMaxX >= data.length) { - iMaxX = data.length - 1; - } - - if (iMaxY >= data[0].length) { - iMaxY = data[0].length - 1; - } - - if (iMinY >= data[0].length) { - iMinY = data[0].length - 1; - } - - var minMax = []; - hfShape.getRectMinMax(iMinX, iMinY, iMaxX, iMaxY, minMax); - var min = minMax[0]; - var max = minMax[1]; // Bail out if we can't touch the bounding height box - - if (localSpherePos.z - radius > max || localSpherePos.z + radius < min) { - return; - } - - var result = this.result; - - for (var i = iMinX; i < iMaxX; i++) { - for (var j = iMinY; j < iMaxY; j++) { - var numContactsBefore = result.length; - var intersecting = false; // Lower triangle - - hfShape.getConvexTrianglePillar(i, j, false); - Transform.pointToWorldFrame(hfPos, hfQuat, hfShape.pillarOffset, worldPillarOffset); - - if (spherePos.distanceTo(worldPillarOffset) < hfShape.pillarConvex.boundingSphereRadius + sphereShape.boundingSphereRadius) { - intersecting = this.sphereConvex(sphereShape, hfShape.pillarConvex, spherePos, worldPillarOffset, sphereQuat, hfQuat, sphereBody, hfBody, sphereShape, hfShape, justTest); - } - - if (justTest && intersecting) { - return true; - } // Upper triangle - - - hfShape.getConvexTrianglePillar(i, j, true); - Transform.pointToWorldFrame(hfPos, hfQuat, hfShape.pillarOffset, worldPillarOffset); - - if (spherePos.distanceTo(worldPillarOffset) < hfShape.pillarConvex.boundingSphereRadius + sphereShape.boundingSphereRadius) { - intersecting = this.sphereConvex(sphereShape, hfShape.pillarConvex, spherePos, worldPillarOffset, sphereQuat, hfQuat, sphereBody, hfBody, sphereShape, hfShape, justTest); - } - - if (justTest && intersecting) { - return true; - } - - var numContacts = result.length - numContactsBefore; - - if (numContacts > 2) { - return; - } - /* - // Skip all but 1 - for (let k = 0; k < numContacts - 1; k++) { - result.pop(); - } - */ - - } - } - }; - - _proto.boxHeightfield = function boxHeightfield(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) { - si.convexPolyhedronRepresentation.material = si.material; - si.convexPolyhedronRepresentation.collisionResponse = si.collisionResponse; - return this.convexHeightfield(si.convexPolyhedronRepresentation, sj, xi, xj, qi, qj, bi, bj, si, sj, justTest); - }; - - _proto.convexHeightfield = function convexHeightfield(convexShape, hfShape, convexPos, hfPos, convexQuat, hfQuat, convexBody, hfBody, rsi, rsj, justTest) { - var data = hfShape.data; - var w = hfShape.elementSize; - var radius = convexShape.boundingSphereRadius; - var worldPillarOffset = convexHeightfield_tmp2; - var faceList = convexHeightfield_faceList; // Get sphere position to heightfield local! - - var localConvexPos = convexHeightfield_tmp1; - Transform.pointToLocalFrame(hfPos, hfQuat, convexPos, localConvexPos); // Get the index of the data points to test against - - var iMinX = Math.floor((localConvexPos.x - radius) / w) - 1; - var iMaxX = Math.ceil((localConvexPos.x + radius) / w) + 1; - var iMinY = Math.floor((localConvexPos.y - radius) / w) - 1; - var iMaxY = Math.ceil((localConvexPos.y + radius) / w) + 1; // Bail out if we are out of the terrain - - if (iMaxX < 0 || iMaxY < 0 || iMinX > data.length || iMinY > data[0].length) { - return; - } // Clamp index to edges - - - if (iMinX < 0) { - iMinX = 0; - } - - if (iMaxX < 0) { - iMaxX = 0; - } - - if (iMinY < 0) { - iMinY = 0; - } - - if (iMaxY < 0) { - iMaxY = 0; - } - - if (iMinX >= data.length) { - iMinX = data.length - 1; - } - - if (iMaxX >= data.length) { - iMaxX = data.length - 1; - } - - if (iMaxY >= data[0].length) { - iMaxY = data[0].length - 1; - } - - if (iMinY >= data[0].length) { - iMinY = data[0].length - 1; - } - - var minMax = []; - hfShape.getRectMinMax(iMinX, iMinY, iMaxX, iMaxY, minMax); - var min = minMax[0]; - var max = minMax[1]; // Bail out if we're cant touch the bounding height box - - if (localConvexPos.z - radius > max || localConvexPos.z + radius < min) { - return; - } - - for (var i = iMinX; i < iMaxX; i++) { - for (var j = iMinY; j < iMaxY; j++) { - var intersecting = false; // Lower triangle - - hfShape.getConvexTrianglePillar(i, j, false); - Transform.pointToWorldFrame(hfPos, hfQuat, hfShape.pillarOffset, worldPillarOffset); - - if (convexPos.distanceTo(worldPillarOffset) < hfShape.pillarConvex.boundingSphereRadius + convexShape.boundingSphereRadius) { - intersecting = this.convexConvex(convexShape, hfShape.pillarConvex, convexPos, worldPillarOffset, convexQuat, hfQuat, convexBody, hfBody, null, null, justTest, faceList, null); - } - - if (justTest && intersecting) { - return true; - } // Upper triangle - - - hfShape.getConvexTrianglePillar(i, j, true); - Transform.pointToWorldFrame(hfPos, hfQuat, hfShape.pillarOffset, worldPillarOffset); - - if (convexPos.distanceTo(worldPillarOffset) < hfShape.pillarConvex.boundingSphereRadius + convexShape.boundingSphereRadius) { - intersecting = this.convexConvex(convexShape, hfShape.pillarConvex, convexPos, worldPillarOffset, convexQuat, hfQuat, convexBody, hfBody, null, null, justTest, faceList, null); - } - - if (justTest && intersecting) { - return true; - } - } - } - }; - - _proto.sphereParticle = function sphereParticle(sj, si, xj, xi, qj, qi, bj, bi, rsi, rsj, justTest) { - // The normal is the unit vector from sphere center to particle center - var normal = particleSphere_normal; - normal.set(0, 0, 1); - xi.vsub(xj, normal); - var lengthSquared = normal.lengthSquared(); - - if (lengthSquared <= sj.radius * sj.radius) { - if (justTest) { - return true; - } - - var r = this.createContactEquation(bi, bj, si, sj, rsi, rsj); - normal.normalize(); - r.rj.copy(normal); - r.rj.scale(sj.radius, r.rj); - r.ni.copy(normal); // Contact normal - - r.ni.negate(r.ni); - r.ri.set(0, 0, 0); // Center of particle - - this.result.push(r); - this.createFrictionEquationsFromContact(r, this.frictionResult); - } - }; - - _proto.planeParticle = function planeParticle(sj, si, xj, xi, qj, qi, bj, bi, rsi, rsj, justTest) { - var normal = particlePlane_normal; - normal.set(0, 0, 1); - bj.quaternion.vmult(normal, normal); // Turn normal according to plane orientation - - var relpos = particlePlane_relpos; - xi.vsub(bj.position, relpos); - var dot = normal.dot(relpos); - - if (dot <= 0.0) { - if (justTest) { - return true; - } - - var r = this.createContactEquation(bi, bj, si, sj, rsi, rsj); - r.ni.copy(normal); // Contact normal is the plane normal - - r.ni.negate(r.ni); - r.ri.set(0, 0, 0); // Center of particle - // Get particle position projected on plane - - var projected = particlePlane_projected; - normal.scale(normal.dot(xi), projected); - xi.vsub(projected, projected); //projected.vadd(bj.position,projected); - // rj is now the projected world position minus plane position - - r.rj.copy(projected); - this.result.push(r); - this.createFrictionEquationsFromContact(r, this.frictionResult); - } - }; - - _proto.boxParticle = function boxParticle(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) { - si.convexPolyhedronRepresentation.material = si.material; - si.convexPolyhedronRepresentation.collisionResponse = si.collisionResponse; - return this.convexParticle(si.convexPolyhedronRepresentation, sj, xi, xj, qi, qj, bi, bj, si, sj, justTest); - }; - - _proto.convexParticle = function convexParticle(sj, si, xj, xi, qj, qi, bj, bi, rsi, rsj, justTest) { - var penetratedFaceIndex = -1; - var penetratedFaceNormal = convexParticle_penetratedFaceNormal; - var worldPenetrationVec = convexParticle_worldPenetrationVec; - var minPenetration = null; - - var local = convexParticle_local; - local.copy(xi); - local.vsub(xj, local); // Convert position to relative the convex origin - - qj.conjugate(cqj); - cqj.vmult(local, local); - - if (sj.pointIsInside(local)) { - if (sj.worldVerticesNeedsUpdate) { - sj.computeWorldVertices(xj, qj); - } - - if (sj.worldFaceNormalsNeedsUpdate) { - sj.computeWorldFaceNormals(qj); - } // For each world polygon in the polyhedra - - - for (var i = 0, nfaces = sj.faces.length; i !== nfaces; i++) { - // Construct world face vertices - var verts = [sj.worldVertices[sj.faces[i][0]]]; - var normal = sj.worldFaceNormals[i]; // Check how much the particle penetrates the polygon plane. - - xi.vsub(verts[0], convexParticle_vertexToParticle); - var penetration = -normal.dot(convexParticle_vertexToParticle); - - if (minPenetration === null || Math.abs(penetration) < Math.abs(minPenetration)) { - if (justTest) { - return true; - } - - minPenetration = penetration; - penetratedFaceIndex = i; - penetratedFaceNormal.copy(normal); - } - } - - if (penetratedFaceIndex !== -1) { - // Setup contact - var r = this.createContactEquation(bi, bj, si, sj, rsi, rsj); - penetratedFaceNormal.scale(minPenetration, worldPenetrationVec); // rj is the particle position projected to the face - - worldPenetrationVec.vadd(xi, worldPenetrationVec); - worldPenetrationVec.vsub(xj, worldPenetrationVec); - r.rj.copy(worldPenetrationVec); //const projectedToFace = xi.vsub(xj).vadd(worldPenetrationVec); - //projectedToFace.copy(r.rj); - //qj.vmult(r.rj,r.rj); - - penetratedFaceNormal.negate(r.ni); // Contact normal - - r.ri.set(0, 0, 0); // Center of particle - - var ri = r.ri; - var rj = r.rj; // Make relative to bodies - - ri.vadd(xi, ri); - ri.vsub(bi.position, ri); - rj.vadd(xj, rj); - rj.vsub(bj.position, rj); - this.result.push(r); - this.createFrictionEquationsFromContact(r, this.frictionResult); - } else { - console.warn('Point found inside convex, but did not find penetrating face!'); - } - } - }; - - _proto.sphereTrimesh = function sphereTrimesh(sphereShape, trimeshShape, spherePos, trimeshPos, sphereQuat, trimeshQuat, sphereBody, trimeshBody, rsi, rsj, justTest) { - var edgeVertexA = sphereTrimesh_edgeVertexA; - var edgeVertexB = sphereTrimesh_edgeVertexB; - var edgeVector = sphereTrimesh_edgeVector; - var edgeVectorUnit = sphereTrimesh_edgeVectorUnit; - var localSpherePos = sphereTrimesh_localSpherePos; - var tmp = sphereTrimesh_tmp; - var localSphereAABB = sphereTrimesh_localSphereAABB; - var v2 = sphereTrimesh_v2; - var relpos = sphereTrimesh_relpos; - var triangles = sphereTrimesh_triangles; // Convert sphere position to local in the trimesh - - Transform.pointToLocalFrame(trimeshPos, trimeshQuat, spherePos, localSpherePos); // Get the aabb of the sphere locally in the trimesh - - var sphereRadius = sphereShape.radius; - localSphereAABB.lowerBound.set(localSpherePos.x - sphereRadius, localSpherePos.y - sphereRadius, localSpherePos.z - sphereRadius); - localSphereAABB.upperBound.set(localSpherePos.x + sphereRadius, localSpherePos.y + sphereRadius, localSpherePos.z + sphereRadius); - trimeshShape.getTrianglesInAABB(localSphereAABB, triangles); //for (let i = 0; i < trimeshShape.indices.length / 3; i++) triangles.push(i); // All - // Vertices - - var v = sphereTrimesh_v; - var radiusSquared = sphereShape.radius * sphereShape.radius; - - for (var i = 0; i < triangles.length; i++) { - for (var j = 0; j < 3; j++) { - trimeshShape.getVertex(trimeshShape.indices[triangles[i] * 3 + j], v); // Check vertex overlap in sphere - - v.vsub(localSpherePos, relpos); - - if (relpos.lengthSquared() <= radiusSquared) { - // Safe up - v2.copy(v); - Transform.pointToWorldFrame(trimeshPos, trimeshQuat, v2, v); - v.vsub(spherePos, relpos); - - if (justTest) { - return true; - } - - var r = this.createContactEquation(sphereBody, trimeshBody, sphereShape, trimeshShape, rsi, rsj); - r.ni.copy(relpos); - r.ni.normalize(); // ri is the vector from sphere center to the sphere surface - - r.ri.copy(r.ni); - r.ri.scale(sphereShape.radius, r.ri); - r.ri.vadd(spherePos, r.ri); - r.ri.vsub(sphereBody.position, r.ri); - r.rj.copy(v); - r.rj.vsub(trimeshBody.position, r.rj); // Store result - - this.result.push(r); - this.createFrictionEquationsFromContact(r, this.frictionResult); - } - } - } // Check all edges - - - for (var _i2 = 0; _i2 < triangles.length; _i2++) { - for (var _j6 = 0; _j6 < 3; _j6++) { - trimeshShape.getVertex(trimeshShape.indices[triangles[_i2] * 3 + _j6], edgeVertexA); - trimeshShape.getVertex(trimeshShape.indices[triangles[_i2] * 3 + (_j6 + 1) % 3], edgeVertexB); - edgeVertexB.vsub(edgeVertexA, edgeVector); // Project sphere position to the edge - - localSpherePos.vsub(edgeVertexB, tmp); - var positionAlongEdgeB = tmp.dot(edgeVector); - localSpherePos.vsub(edgeVertexA, tmp); - var positionAlongEdgeA = tmp.dot(edgeVector); - - if (positionAlongEdgeA > 0 && positionAlongEdgeB < 0) { - // Now check the orthogonal distance from edge to sphere center - localSpherePos.vsub(edgeVertexA, tmp); - edgeVectorUnit.copy(edgeVector); - edgeVectorUnit.normalize(); - positionAlongEdgeA = tmp.dot(edgeVectorUnit); - edgeVectorUnit.scale(positionAlongEdgeA, tmp); - tmp.vadd(edgeVertexA, tmp); // tmp is now the sphere center position projected to the edge, defined locally in the trimesh frame - - var dist = tmp.distanceTo(localSpherePos); - - if (dist < sphereShape.radius) { - if (justTest) { - return true; - } - - var _r5 = this.createContactEquation(sphereBody, trimeshBody, sphereShape, trimeshShape, rsi, rsj); - - tmp.vsub(localSpherePos, _r5.ni); - - _r5.ni.normalize(); - - _r5.ni.scale(sphereShape.radius, _r5.ri); - - _r5.ri.vadd(spherePos, _r5.ri); - - _r5.ri.vsub(sphereBody.position, _r5.ri); - - Transform.pointToWorldFrame(trimeshPos, trimeshQuat, tmp, tmp); - tmp.vsub(trimeshBody.position, _r5.rj); - Transform.vectorToWorldFrame(trimeshQuat, _r5.ni, _r5.ni); - Transform.vectorToWorldFrame(trimeshQuat, _r5.ri, _r5.ri); - this.result.push(_r5); - this.createFrictionEquationsFromContact(_r5, this.frictionResult); - } - } - } - } // Triangle faces - - - var va = sphereTrimesh_va; - var vb = sphereTrimesh_vb; - var vc = sphereTrimesh_vc; - var normal = sphereTrimesh_normal; - - for (var _i3 = 0, N = triangles.length; _i3 !== N; _i3++) { - trimeshShape.getTriangleVertices(triangles[_i3], va, vb, vc); - trimeshShape.getNormal(triangles[_i3], normal); - localSpherePos.vsub(va, tmp); - - var _dist2 = tmp.dot(normal); - - normal.scale(_dist2, tmp); - localSpherePos.vsub(tmp, tmp); // tmp is now the sphere position projected to the triangle plane - - _dist2 = tmp.distanceTo(localSpherePos); - - if (Ray.pointInTriangle(tmp, va, vb, vc) && _dist2 < sphereShape.radius) { - if (justTest) { - return true; - } - - var _r6 = this.createContactEquation(sphereBody, trimeshBody, sphereShape, trimeshShape, rsi, rsj); - - tmp.vsub(localSpherePos, _r6.ni); - - _r6.ni.normalize(); - - _r6.ni.scale(sphereShape.radius, _r6.ri); - - _r6.ri.vadd(spherePos, _r6.ri); - - _r6.ri.vsub(sphereBody.position, _r6.ri); - - Transform.pointToWorldFrame(trimeshPos, trimeshQuat, tmp, tmp); - tmp.vsub(trimeshBody.position, _r6.rj); - Transform.vectorToWorldFrame(trimeshQuat, _r6.ni, _r6.ni); - Transform.vectorToWorldFrame(trimeshQuat, _r6.ri, _r6.ri); - this.result.push(_r6); - this.createFrictionEquationsFromContact(_r6, this.frictionResult); - } - } - - triangles.length = 0; - }; - - _proto.planeTrimesh = function planeTrimesh(planeShape, trimeshShape, planePos, trimeshPos, planeQuat, trimeshQuat, planeBody, trimeshBody, rsi, rsj, justTest) { - // Make contacts! - var v = new Vec3(); - var normal = planeTrimesh_normal; - normal.set(0, 0, 1); - planeQuat.vmult(normal, normal); // Turn normal according to plane - - for (var i = 0; i < trimeshShape.vertices.length / 3; i++) { - // Get world vertex from trimesh - trimeshShape.getVertex(i, v); // Safe up - - var v2 = new Vec3(); - v2.copy(v); - Transform.pointToWorldFrame(trimeshPos, trimeshQuat, v2, v); // Check plane side - - var relpos = planeTrimesh_relpos; - v.vsub(planePos, relpos); - var dot = normal.dot(relpos); - - if (dot <= 0.0) { - if (justTest) { - return true; - } - - var r = this.createContactEquation(planeBody, trimeshBody, planeShape, trimeshShape, rsi, rsj); - r.ni.copy(normal); // Contact normal is the plane normal - // Get vertex position projected on plane - - var projected = planeTrimesh_projected; - normal.scale(relpos.dot(normal), projected); - v.vsub(projected, projected); // ri is the projected world position minus plane position - - r.ri.copy(projected); - r.ri.vsub(planeBody.position, r.ri); - r.rj.copy(v); - r.rj.vsub(trimeshBody.position, r.rj); // Store result - - this.result.push(r); - this.createFrictionEquationsFromContact(r, this.frictionResult); - } - } - } // convexTrimesh( - // si: ConvexPolyhedron, sj: Trimesh, xi: Vec3, xj: Vec3, qi: Quaternion, qj: Quaternion, - // bi: Body, bj: Body, rsi?: Shape | null, rsj?: Shape | null, - // faceListA?: number[] | null, faceListB?: number[] | null, - // ) { - // const sepAxis = convexConvex_sepAxis; - // if(xi.distanceTo(xj) > si.boundingSphereRadius + sj.boundingSphereRadius){ - // return; - // } - // // Construct a temp hull for each triangle - // const hullB = new ConvexPolyhedron(); - // hullB.faces = [[0,1,2]]; - // const va = new Vec3(); - // const vb = new Vec3(); - // const vc = new Vec3(); - // hullB.vertices = [ - // va, - // vb, - // vc - // ]; - // for (let i = 0; i < sj.indices.length / 3; i++) { - // const triangleNormal = new Vec3(); - // sj.getNormal(i, triangleNormal); - // hullB.faceNormals = [triangleNormal]; - // sj.getTriangleVertices(i, va, vb, vc); - // let d = si.testSepAxis(triangleNormal, hullB, xi, qi, xj, qj); - // if(!d){ - // triangleNormal.scale(-1, triangleNormal); - // d = si.testSepAxis(triangleNormal, hullB, xi, qi, xj, qj); - // if(!d){ - // continue; - // } - // } - // const res: ConvexPolyhedronContactPoint[] = []; - // const q = convexConvex_q; - // si.clipAgainstHull(xi,qi,hullB,xj,qj,triangleNormal,-100,100,res); - // for(let j = 0; j !== res.length; j++){ - // const r = this.createContactEquation(bi,bj,si,sj,rsi,rsj), - // ri = r.ri, - // rj = r.rj; - // r.ni.copy(triangleNormal); - // r.ni.negate(r.ni); - // res[j].normal.negate(q); - // q.mult(res[j].depth, q); - // res[j].point.vadd(q, ri); - // rj.copy(res[j].point); - // // Contact points are in world coordinates. Transform back to relative - // ri.vsub(xi,ri); - // rj.vsub(xj,rj); - // // Make relative to bodies - // ri.vadd(xi, ri); - // ri.vsub(bi.position, ri); - // rj.vadd(xj, rj); - // rj.vsub(bj.position, rj); - // result.push(r); - // } - // } - // } - ; - - return Narrowphase; -}(); -var averageNormal = new Vec3(); -var averageContactPointA = new Vec3(); -var averageContactPointB = new Vec3(); -var tmpVec1$3 = new Vec3(); -var tmpVec2$3 = new Vec3(); -var tmpQuat1 = new Quaternion(); -var tmpQuat2 = new Quaternion(); - -Narrowphase.prototype[COLLISION_TYPES.boxBox] = Narrowphase.prototype.boxBox; -Narrowphase.prototype[COLLISION_TYPES.boxConvex] = Narrowphase.prototype.boxConvex; -Narrowphase.prototype[COLLISION_TYPES.boxParticle] = Narrowphase.prototype.boxParticle; -Narrowphase.prototype[COLLISION_TYPES.sphereSphere] = Narrowphase.prototype.sphereSphere; -var planeTrimesh_normal = new Vec3(); -var planeTrimesh_relpos = new Vec3(); -var planeTrimesh_projected = new Vec3(); -Narrowphase.prototype[COLLISION_TYPES.planeTrimesh] = Narrowphase.prototype.planeTrimesh; -var sphereTrimesh_normal = new Vec3(); -var sphereTrimesh_relpos = new Vec3(); -var sphereTrimesh_projected = new Vec3(); -var sphereTrimesh_v = new Vec3(); -var sphereTrimesh_v2 = new Vec3(); -var sphereTrimesh_edgeVertexA = new Vec3(); -var sphereTrimesh_edgeVertexB = new Vec3(); -var sphereTrimesh_edgeVector = new Vec3(); -var sphereTrimesh_edgeVectorUnit = new Vec3(); -var sphereTrimesh_localSpherePos = new Vec3(); -var sphereTrimesh_tmp = new Vec3(); -var sphereTrimesh_va = new Vec3(); -var sphereTrimesh_vb = new Vec3(); -var sphereTrimesh_vc = new Vec3(); -var sphereTrimesh_localSphereAABB = new AABB(); -var sphereTrimesh_triangles = []; -Narrowphase.prototype[COLLISION_TYPES.sphereTrimesh] = Narrowphase.prototype.sphereTrimesh; -var point_on_plane_to_sphere = new Vec3(); -var plane_to_sphere_ortho = new Vec3(); -Narrowphase.prototype[COLLISION_TYPES.spherePlane] = Narrowphase.prototype.spherePlane; // See http://bulletphysics.com/Bullet/BulletFull/SphereTriangleDetector_8cpp_source.html - -var pointInPolygon_edge = new Vec3(); -var pointInPolygon_edge_x_normal = new Vec3(); -var pointInPolygon_vtp = new Vec3(); - -function pointInPolygon(verts, normal, p) { - var positiveResult = null; - var N = verts.length; - - for (var i = 0; i !== N; i++) { - var v = verts[i]; // Get edge to the next vertex - - var edge = pointInPolygon_edge; - verts[(i + 1) % N].vsub(v, edge); // Get cross product between polygon normal and the edge - - var edge_x_normal = pointInPolygon_edge_x_normal; //const edge_x_normal = new Vec3(); - - edge.cross(normal, edge_x_normal); // Get vector between point and current vertex - - var vertex_to_p = pointInPolygon_vtp; - p.vsub(v, vertex_to_p); // This dot product determines which side of the edge the point is - - var r = edge_x_normal.dot(vertex_to_p); // If all such dot products have same sign, we are inside the polygon. - - if (positiveResult === null || r > 0 && positiveResult === true || r <= 0 && positiveResult === false) { - if (positiveResult === null) { - positiveResult = r > 0; - } - - continue; - } else { - return false; // Encountered some other sign. Exit. - } - } // If we got here, all dot products were of the same sign. - - - return true; -} - -var box_to_sphere = new Vec3(); -var sphereBox_ns = new Vec3(); -var sphereBox_ns1 = new Vec3(); -var sphereBox_ns2 = new Vec3(); -var sphereBox_sides = [new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3()]; -var sphereBox_sphere_to_corner = new Vec3(); -var sphereBox_side_ns = new Vec3(); -var sphereBox_side_ns1 = new Vec3(); -var sphereBox_side_ns2 = new Vec3(); -Narrowphase.prototype[COLLISION_TYPES.sphereBox] = Narrowphase.prototype.sphereBox; -var convex_to_sphere = new Vec3(); -var sphereConvex_edge = new Vec3(); -var sphereConvex_edgeUnit = new Vec3(); -var sphereConvex_sphereToCorner = new Vec3(); -var sphereConvex_worldCorner = new Vec3(); -var sphereConvex_worldNormal = new Vec3(); -var sphereConvex_worldPoint = new Vec3(); -var sphereConvex_worldSpherePointClosestToPlane = new Vec3(); -var sphereConvex_penetrationVec = new Vec3(); -var sphereConvex_sphereToWorldPoint = new Vec3(); -Narrowphase.prototype[COLLISION_TYPES.sphereConvex] = Narrowphase.prototype.sphereConvex; -var planeBox_normal = new Vec3(); -var plane_to_corner = new Vec3(); -Narrowphase.prototype[COLLISION_TYPES.planeBox] = Narrowphase.prototype.planeBox; -var planeConvex_v = new Vec3(); -var planeConvex_normal = new Vec3(); -var planeConvex_relpos = new Vec3(); -var planeConvex_projected = new Vec3(); -Narrowphase.prototype[COLLISION_TYPES.planeConvex] = Narrowphase.prototype.planeConvex; -var convexConvex_sepAxis = new Vec3(); -var convexConvex_q = new Vec3(); -Narrowphase.prototype[COLLISION_TYPES.convexConvex] = Narrowphase.prototype.convexConvex; // Narrowphase.prototype[COLLISION_TYPES.convexTrimesh] = Narrowphase.prototype.convexTrimesh - -var particlePlane_normal = new Vec3(); -var particlePlane_relpos = new Vec3(); -var particlePlane_projected = new Vec3(); -Narrowphase.prototype[COLLISION_TYPES.planeParticle] = Narrowphase.prototype.planeParticle; -var particleSphere_normal = new Vec3(); -Narrowphase.prototype[COLLISION_TYPES.sphereParticle] = Narrowphase.prototype.sphereParticle; // WIP - -var cqj = new Quaternion(); -var convexParticle_local = new Vec3(); -var convexParticle_normal = new Vec3(); -var convexParticle_penetratedFaceNormal = new Vec3(); -var convexParticle_vertexToParticle = new Vec3(); -var convexParticle_worldPenetrationVec = new Vec3(); -Narrowphase.prototype[COLLISION_TYPES.convexParticle] = Narrowphase.prototype.convexParticle; -Narrowphase.prototype[COLLISION_TYPES.boxHeightfield] = Narrowphase.prototype.boxHeightfield; -var convexHeightfield_tmp1 = new Vec3(); -var convexHeightfield_tmp2 = new Vec3(); -var convexHeightfield_faceList = [0]; -Narrowphase.prototype[COLLISION_TYPES.convexHeightfield] = Narrowphase.prototype.convexHeightfield; -var sphereHeightfield_tmp1 = new Vec3(); -var sphereHeightfield_tmp2 = new Vec3(); -Narrowphase.prototype[COLLISION_TYPES.sphereHeightfield] = Narrowphase.prototype.sphereHeightfield; - -/** - * @class OverlapKeeper - * @constructor - */ -var OverlapKeeper = /*#__PURE__*/function () { - function OverlapKeeper() { - this.current = []; - this.previous = []; - } - - var _proto = OverlapKeeper.prototype; - - _proto.getKey = function getKey(i, j) { - if (j < i) { - var temp = j; - j = i; - i = temp; - } - - return i << 16 | j; - } - /** - * @method set - * @param {Number} i - * @param {Number} j - */ - ; - - _proto.set = function set(i, j) { - // Insertion sort. This way the diff will have linear complexity. - var key = this.getKey(i, j); - var current = this.current; - var index = 0; - - while (key > current[index]) { - index++; - } - - if (key === current[index]) { - return; // Pair was already added - } - - for (var _j = current.length - 1; _j >= index; _j--) { - current[_j + 1] = current[_j]; - } - - current[index] = key; - } - /** - * @method tick - */ - ; - - _proto.tick = function tick() { - var tmp = this.current; - this.current = this.previous; - this.previous = tmp; - this.current.length = 0; - } - /** - * @method getDiff - * @param {array} additions - * @param {array} removals - */ - ; - - _proto.getDiff = function getDiff(additions, removals) { - var a = this.current; - var b = this.previous; - var al = a.length; - var bl = b.length; - var j = 0; - - for (var i = 0; i < al; i++) { - var found = false; - var keyA = a[i]; - - while (keyA > b[j]) { - j++; - } - - found = keyA === b[j]; - - if (!found) { - unpackAndPush(additions, keyA); - } - } - - j = 0; - - for (var _i = 0; _i < bl; _i++) { - var _found = false; - var keyB = b[_i]; - - while (keyB > a[j]) { - j++; - } - - _found = a[j] === keyB; - - if (!_found) { - unpackAndPush(removals, keyB); - } - } - }; - - return OverlapKeeper; -}(); - -function unpackAndPush(array, key) { - array.push((key & 0xffff0000) >> 16, key & 0x0000ffff); -} - -/** - * @class TupleDictionary - * @constructor - */ -var TupleDictionary = /*#__PURE__*/function () { - function TupleDictionary() { - this.data = { - keys: [] - }; - } - /** - * @method get - * @param {Number} i - * @param {Number} j - * @return {Object} - */ - - - var _proto = TupleDictionary.prototype; - - _proto.get = function get(i, j) { - if (i > j) { - // swap - var temp = j; - j = i; - i = temp; - } - - return this.data[i + "-" + j]; - } - /** - * @method set - * @param {Number} i - * @param {Number} j - * @param {Object} value - */ - ; - - _proto.set = function set(i, j, value) { - if (i > j) { - var temp = j; - j = i; - i = temp; - } - - var key = i + "-" + j; // Check if key already exists - - if (!this.get(i, j)) { - this.data.keys.push(key); - } - - this.data[key] = value; - } - /** - * @method reset - */ - ; - - _proto.reset = function reset() { - var data = this.data; - var keys = data.keys; - - while (keys.length > 0) { - var key = keys.pop(); - delete data[key]; - } - }; - - return TupleDictionary; -}(); - -/** - * The physics world - * @class World - * @constructor - * @extends EventTarget - * @param {object} [options] - * @param {Vec3} [options.gravity] - * @param {boolean} [options.allowSleep] - * @param {Broadphase} [options.broadphase] - * @param {Solver} [options.solver] - * @param {boolean} [options.quatNormalizeFast] - * @param {number} [options.quatNormalizeSkip] - */ -var World = /*#__PURE__*/function (_EventTarget) { - _inheritsLoose(World, _EventTarget); - - // Currently / last used timestep. Is set to -1 if not available. This value is updated before each internal step, which means that it is "fresh" inside event callbacks. - // Makes bodies go to sleep when they've been inactive. - // All the current contacts (instances of ContactEquation) in the world. - // How often to normalize quaternions. Set to 0 for every step, 1 for every second etc.. A larger value increases performance. If bodies tend to explode, set to a smaller value (zero to be sure nothing can go wrong). - // Set to true to use fast quaternion normalization. It is often enough accurate to use. If bodies tend to explode, set to false. - // The wall-clock time since simulation start. - // Number of timesteps taken since start. - // Default and last timestep sizes. - // The broadphase algorithm to use. Default is NaiveBroadphase. - // All bodies in this world - // True if any bodies are not sleeping, false if every body is sleeping. - // The solver algorithm to use. Default is GSSolver. - // CollisionMatrix from the previous step. - // All added materials. - // Used to look up a ContactMaterial given two instances of Material. - // This contact material is used if no suitable contactmaterial is found for a contact. - // Time accumulator for interpolation. See http://gafferongames.com/game-physics/fix-your-timestep/ - // Dispatched after a body has been added to the world. - // Dispatched after a body has been removed from the world. - function World(options) { - var _this; - - if (options === void 0) { - options = {}; - } - - _this = _EventTarget.call(this) || this; - _this.dt = -1; - _this.allowSleep = !!options.allowSleep; - _this.contacts = []; - _this.frictionEquations = []; - _this.quatNormalizeSkip = options.quatNormalizeSkip !== undefined ? options.quatNormalizeSkip : 0; - _this.quatNormalizeFast = options.quatNormalizeFast !== undefined ? options.quatNormalizeFast : false; - _this.time = 0.0; - _this.stepnumber = 0; - _this.default_dt = 1 / 60; - _this.nextId = 0; - _this.gravity = new Vec3(); - - if (options.gravity) { - _this.gravity.copy(options.gravity); - } - - _this.broadphase = options.broadphase !== undefined ? options.broadphase : new NaiveBroadphase(); - _this.bodies = []; - _this.hasActiveBodies = false; - _this.solver = options.solver !== undefined ? options.solver : new GSSolver(); - _this.constraints = []; - _this.narrowphase = new Narrowphase(_assertThisInitialized(_this)); - _this.collisionMatrix = new ArrayCollisionMatrix(); - _this.collisionMatrixPrevious = new ArrayCollisionMatrix(); - _this.bodyOverlapKeeper = new OverlapKeeper(); - _this.shapeOverlapKeeper = new OverlapKeeper(); - _this.materials = []; - _this.contactmaterials = []; - _this.contactMaterialTable = new TupleDictionary(); - _this.defaultMaterial = new Material('default'); - _this.defaultContactMaterial = new ContactMaterial(_this.defaultMaterial, _this.defaultMaterial, { - friction: 0.3, - restitution: 0.0 - }); - _this.doProfiling = false; - _this.profile = { - solve: 0, - makeContactConstraints: 0, - broadphase: 0, - integrate: 0, - narrowphase: 0 - }; - _this.accumulator = 0; - _this.subsystems = []; - _this.addBodyEvent = { - type: 'addBody', - body: null - }; - _this.removeBodyEvent = { - type: 'removeBody', - body: null - }; - _this.idToBodyMap = {}; - - _this.broadphase.setWorld(_assertThisInitialized(_this)); - - return _this; - } - /** - * Get the contact material between materials m1 and m2 - * @method getContactMaterial - * @param {Material} m1 - * @param {Material} m2 - * @return {ContactMaterial} The contact material if it was found. - */ - - - var _proto = World.prototype; - - _proto.getContactMaterial = function getContactMaterial(m1, m2) { - return this.contactMaterialTable.get(m1.id, m2.id); - } - /** - * Get number of objects in the world. - * @method numObjects - * @return {Number} - * @deprecated - */ - ; - - _proto.numObjects = function numObjects() { - return this.bodies.length; - } - /** - * Store old collision state info - * @method collisionMatrixTick - */ - ; - - _proto.collisionMatrixTick = function collisionMatrixTick() { - var temp = this.collisionMatrixPrevious; - this.collisionMatrixPrevious = this.collisionMatrix; - this.collisionMatrix = temp; - this.collisionMatrix.reset(); - this.bodyOverlapKeeper.tick(); - this.shapeOverlapKeeper.tick(); - } - /** - * Add a constraint to the simulation. - * @method addConstraint - * @param {Constraint} c - */ - ; - - _proto.addConstraint = function addConstraint(c) { - this.constraints.push(c); - } - /** - * Removes a constraint - * @method removeConstraint - * @param {Constraint} c - */ - ; - - _proto.removeConstraint = function removeConstraint(c) { - var idx = this.constraints.indexOf(c); - - if (idx !== -1) { - this.constraints.splice(idx, 1); - } - } - /** - * Raycast test - * @method rayTest - * @param {Vec3} from - * @param {Vec3} to - * @param {RaycastResult} result - * @deprecated Use .raycastAll, .raycastClosest or .raycastAny instead. - */ - ; - - _proto.rayTest = function rayTest(from, to, result) { - if (result instanceof RaycastResult) { - // Do raycastClosest - this.raycastClosest(from, to, { - skipBackfaces: true - }, result); - } else { - // Do raycastAll - this.raycastAll(from, to, { - skipBackfaces: true - }, result); - } - } - /** - * Ray cast against all bodies. The provided callback will be executed for each hit with a RaycastResult as single argument. - * @method raycastAll - * @param {Vec3} from - * @param {Vec3} to - * @param {Object} options - * @param {number} [options.collisionFilterMask=-1] - * @param {number} [options.collisionFilterGroup=-1] - * @param {boolean} [options.skipBackfaces=false] - * @param {boolean} [options.checkCollisionResponse=true] - * @param {Function} callback - * @return {boolean} True if any body was hit. - */ - ; - - _proto.raycastAll = function raycastAll(from, to, options, callback) { - if (options === void 0) { - options = {}; - } - - options.mode = Ray.ALL; - options.from = from; - options.to = to; - options.callback = callback; - return tmpRay$1.intersectWorld(this, options); - } - /** - * Ray cast, and stop at the first result. Note that the order is random - but the method is fast. - * @method raycastAny - * @param {Vec3} from - * @param {Vec3} to - * @param {Object} options - * @param {number} [options.collisionFilterMask=-1] - * @param {number} [options.collisionFilterGroup=-1] - * @param {boolean} [options.skipBackfaces=false] - * @param {boolean} [options.checkCollisionResponse=true] - * @param {RaycastResult} result - * @return {boolean} True if any body was hit. - */ - ; - - _proto.raycastAny = function raycastAny(from, to, options, result) { - if (options === void 0) { - options = {}; - } - - options.mode = Ray.ANY; - options.from = from; - options.to = to; - options.result = result; - return tmpRay$1.intersectWorld(this, options); - } - /** - * Ray cast, and return information of the closest hit. - * @method raycastClosest - * @param {Vec3} from - * @param {Vec3} to - * @param {Object} options - * @param {number} [options.collisionFilterMask=-1] - * @param {number} [options.collisionFilterGroup=-1] - * @param {boolean} [options.skipBackfaces=false] - * @param {boolean} [options.checkCollisionResponse=true] - * @param {RaycastResult} result - * @return {boolean} True if any body was hit. - */ - ; - - _proto.raycastClosest = function raycastClosest(from, to, options, result) { - if (options === void 0) { - options = {}; - } - - options.mode = Ray.CLOSEST; - options.from = from; - options.to = to; - options.result = result; - return tmpRay$1.intersectWorld(this, options); - } - /** - * Add a rigid body to the simulation. - * @method add - * @param {Body} body - * @todo If the simulation has not yet started, why recrete and copy arrays for each body? Accumulate in dynamic arrays in this case. - * @todo Adding an array of bodies should be possible. This would save some loops too - */ - ; - - _proto.addBody = function addBody(body) { - if (this.bodies.includes(body)) { - return; - } - - body.index = this.bodies.length; - this.bodies.push(body); - body.world = this; - body.initPosition.copy(body.position); - body.initVelocity.copy(body.velocity); - body.timeLastSleepy = this.time; - - if (body instanceof Body) { - body.initAngularVelocity.copy(body.angularVelocity); - body.initQuaternion.copy(body.quaternion); - } - - this.collisionMatrix.setNumObjects(this.bodies.length); - this.addBodyEvent.body = body; - this.idToBodyMap[body.id] = body; - this.dispatchEvent(this.addBodyEvent); - } - /** - * Remove a rigid body from the simulation. - * @method remove - * @param {Body} body - */ - ; - - _proto.removeBody = function removeBody(body) { - body.world = null; - var n = this.bodies.length - 1; - var bodies = this.bodies; - var idx = bodies.indexOf(body); - - if (idx !== -1) { - bodies.splice(idx, 1); // Todo: should use a garbage free method - // Recompute index - - for (var i = 0; i !== bodies.length; i++) { - bodies[i].index = i; - } - - this.collisionMatrix.setNumObjects(n); - this.removeBodyEvent.body = body; - delete this.idToBodyMap[body.id]; - this.dispatchEvent(this.removeBodyEvent); - } - }; - - _proto.getBodyById = function getBodyById(id) { - return this.idToBodyMap[id]; - } // TODO Make a faster map - ; - - _proto.getShapeById = function getShapeById(id) { - var bodies = this.bodies; - - for (var i = 0, bl = bodies.length; i < bl; i++) { - var shapes = bodies[i].shapes; - - for (var j = 0, sl = shapes.length; j < sl; j++) { - var shape = shapes[j]; - - if (shape.id === id) { - return shape; - } - } - } - } - /** - * Adds a material to the World. - * @method addMaterial - * @param {Material} m - * @todo Necessary? - */ - ; - - _proto.addMaterial = function addMaterial(m) { - this.materials.push(m); - } - /** - * Adds a contact material to the World - * @method addContactMaterial - * @param {ContactMaterial} cmat - */ - ; - - _proto.addContactMaterial = function addContactMaterial(cmat) { - // Add contact material - this.contactmaterials.push(cmat); // Add current contact material to the material table - - this.contactMaterialTable.set(cmat.materials[0].id, cmat.materials[1].id, cmat); - } - /** - * Step the physics world forward in time. - * - * There are two modes. The simple mode is fixed timestepping without interpolation. In this case you only use the first argument. The second case uses interpolation. In that you also provide the time since the function was last used, as well as the maximum fixed timesteps to take. - * - * @method step - * @param {Number} dt The fixed time step size to use. - * @param {Number} [timeSinceLastCalled] The time elapsed since the function was last called. - * @param {Number} [maxSubSteps=10] Maximum number of fixed steps to take per function call. - * - * @example - * // fixed timestepping without interpolation - * world.step(1/60); - * - * @see http://bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World - */ - ; - - _proto.step = function step(dt, timeSinceLastCalled, maxSubSteps) { - if (timeSinceLastCalled === void 0) { - timeSinceLastCalled = 0; - } - - if (maxSubSteps === void 0) { - maxSubSteps = 10; - } - - if (timeSinceLastCalled === 0) { - // Fixed, simple stepping - this.internalStep(dt); // Increment time - - this.time += dt; - } else { - this.accumulator += timeSinceLastCalled; - var substeps = 0; - - while (this.accumulator >= dt && substeps < maxSubSteps) { - // Do fixed steps to catch up - this.internalStep(dt); - this.accumulator -= dt; - substeps++; - } - - var t = this.accumulator % dt / dt; - - for (var j = 0; j !== this.bodies.length; j++) { - var b = this.bodies[j]; - b.previousPosition.lerp(b.position, t, b.interpolatedPosition); - b.previousQuaternion.slerp(b.quaternion, t, b.interpolatedQuaternion); - b.previousQuaternion.normalize(); - } - - this.time += timeSinceLastCalled; - } - }; - - _proto.internalStep = function internalStep(dt) { - this.dt = dt; - var contacts = this.contacts; - var p1 = World_step_p1; - var p2 = World_step_p2; - var N = this.numObjects(); - var bodies = this.bodies; - var solver = this.solver; - var gravity = this.gravity; - var doProfiling = this.doProfiling; - var profile = this.profile; - var DYNAMIC = Body.DYNAMIC; - var profilingStart = -Infinity; - var constraints = this.constraints; - var frictionEquationPool = World_step_frictionEquationPool; - var gnorm = gravity.length(); - var gx = gravity.x; - var gy = gravity.y; - var gz = gravity.z; - var i = 0; - - if (doProfiling) { - profilingStart = performance.now(); - } // Add gravity to all objects - - - for (i = 0; i !== N; i++) { - var bi = bodies[i]; - - if (bi.type === DYNAMIC) { - // Only for dynamic bodies - var f = bi.force; - var m = bi.mass; - f.x += m * gx; - f.y += m * gy; - f.z += m * gz; - } - } // Update subsystems - - - for (var _i = 0, Nsubsystems = this.subsystems.length; _i !== Nsubsystems; _i++) { - this.subsystems[_i].update(); - } // Collision detection - - - if (doProfiling) { - profilingStart = performance.now(); - } - - p1.length = 0; // Clean up pair arrays from last step - - p2.length = 0; - this.broadphase.collisionPairs(this, p1, p2); - - if (doProfiling) { - profile.broadphase = performance.now() - profilingStart; - } // Remove constrained pairs with collideConnected == false - - - var Nconstraints = constraints.length; - - for (i = 0; i !== Nconstraints; i++) { - var c = constraints[i]; - - if (!c.collideConnected) { - for (var j = p1.length - 1; j >= 0; j -= 1) { - if (c.bodyA === p1[j] && c.bodyB === p2[j] || c.bodyB === p1[j] && c.bodyA === p2[j]) { - p1.splice(j, 1); - p2.splice(j, 1); - } - } - } - } - - this.collisionMatrixTick(); // Generate contacts - - if (doProfiling) { - profilingStart = performance.now(); - } - - var oldcontacts = World_step_oldContacts; - var NoldContacts = contacts.length; - - for (i = 0; i !== NoldContacts; i++) { - oldcontacts.push(contacts[i]); - } - - contacts.length = 0; // Transfer FrictionEquation from current list to the pool for reuse - - var NoldFrictionEquations = this.frictionEquations.length; - - for (i = 0; i !== NoldFrictionEquations; i++) { - frictionEquationPool.push(this.frictionEquations[i]); - } - - this.frictionEquations.length = 0; - this.narrowphase.getContacts(p1, p2, this, contacts, oldcontacts, // To be reused - this.frictionEquations, frictionEquationPool); - - if (doProfiling) { - profile.narrowphase = performance.now() - profilingStart; - } // Loop over all collisions - - - if (doProfiling) { - profilingStart = performance.now(); - } // Add all friction eqs - - - for (i = 0; i < this.frictionEquations.length; i++) { - solver.addEquation(this.frictionEquations[i]); - } - - var ncontacts = contacts.length; - - for (var k = 0; k !== ncontacts; k++) { - // Current contact - var _c = contacts[k]; // Get current collision indeces - - var _bi = _c.bi; - var bj = _c.bj; - var si = _c.si; - var sj = _c.sj; // Get collision properties - - var cm = void 0; - - if (_bi.material && bj.material) { - cm = this.getContactMaterial(_bi.material, bj.material) || this.defaultContactMaterial; - } else { - cm = this.defaultContactMaterial; - } // c.enabled = bi.collisionResponse && bj.collisionResponse && si.collisionResponse && sj.collisionResponse; - - - var mu = cm.friction; // c.restitution = cm.restitution; - // If friction or restitution were specified in the material, use them - - if (_bi.material && bj.material) { - if (_bi.material.friction >= 0 && bj.material.friction >= 0) { - mu = _bi.material.friction * bj.material.friction; - } - - if (_bi.material.restitution >= 0 && bj.material.restitution >= 0) { - _c.restitution = _bi.material.restitution * bj.material.restitution; - } - } // c.setSpookParams( - // cm.contactEquationStiffness, - // cm.contactEquationRelaxation, - // dt - // ); - - - solver.addEquation(_c); // // Add friction constraint equation - // if(mu > 0){ - // // Create 2 tangent equations - // const mug = mu * gnorm; - // const reducedMass = (bi.invMass + bj.invMass); - // if(reducedMass > 0){ - // reducedMass = 1/reducedMass; - // } - // const pool = frictionEquationPool; - // const c1 = pool.length ? pool.pop() : new FrictionEquation(bi,bj,mug*reducedMass); - // const c2 = pool.length ? pool.pop() : new FrictionEquation(bi,bj,mug*reducedMass); - // this.frictionEquations.push(c1, c2); - // c1.bi = c2.bi = bi; - // c1.bj = c2.bj = bj; - // c1.minForce = c2.minForce = -mug*reducedMass; - // c1.maxForce = c2.maxForce = mug*reducedMass; - // // Copy over the relative vectors - // c1.ri.copy(c.ri); - // c1.rj.copy(c.rj); - // c2.ri.copy(c.ri); - // c2.rj.copy(c.rj); - // // Construct tangents - // c.ni.tangents(c1.t, c2.t); - // // Set spook params - // c1.setSpookParams(cm.frictionEquationStiffness, cm.frictionEquationRelaxation, dt); - // c2.setSpookParams(cm.frictionEquationStiffness, cm.frictionEquationRelaxation, dt); - // c1.enabled = c2.enabled = c.enabled; - // // Add equations to solver - // solver.addEquation(c1); - // solver.addEquation(c2); - // } - - if (_bi.allowSleep && _bi.type === Body.DYNAMIC && _bi.sleepState === Body.SLEEPING && bj.sleepState === Body.AWAKE && bj.type !== Body.STATIC) { - var speedSquaredB = bj.velocity.lengthSquared() + bj.angularVelocity.lengthSquared(); - var speedLimitSquaredB = Math.pow(bj.sleepSpeedLimit, 2); - - if (speedSquaredB >= speedLimitSquaredB * 2) { - _bi.wakeUpAfterNarrowphase = true; - } - } - - if (bj.allowSleep && bj.type === Body.DYNAMIC && bj.sleepState === Body.SLEEPING && _bi.sleepState === Body.AWAKE && _bi.type !== Body.STATIC) { - var speedSquaredA = _bi.velocity.lengthSquared() + _bi.angularVelocity.lengthSquared(); - - var speedLimitSquaredA = Math.pow(_bi.sleepSpeedLimit, 2); - - if (speedSquaredA >= speedLimitSquaredA * 2) { - bj.wakeUpAfterNarrowphase = true; - } - } // Now we know that i and j are in contact. Set collision matrix state - - - this.collisionMatrix.set(_bi, bj, true); - - if (!this.collisionMatrixPrevious.get(_bi, bj)) { - // First contact! - // We reuse the collideEvent object, otherwise we will end up creating new objects for each new contact, even if there's no event listener attached. - World_step_collideEvent.body = bj; - World_step_collideEvent.contact = _c; - - _bi.dispatchEvent(World_step_collideEvent); - - World_step_collideEvent.body = _bi; - bj.dispatchEvent(World_step_collideEvent); - } - - this.bodyOverlapKeeper.set(_bi.id, bj.id); - this.shapeOverlapKeeper.set(si.id, sj.id); - } - - this.emitContactEvents(); - - if (doProfiling) { - profile.makeContactConstraints = performance.now() - profilingStart; - profilingStart = performance.now(); - } // Wake up bodies - - - for (i = 0; i !== N; i++) { - var _bi2 = bodies[i]; - - if (_bi2.wakeUpAfterNarrowphase) { - _bi2.wakeUp(); - - _bi2.wakeUpAfterNarrowphase = false; - } - } // Add user-added constraints - - - Nconstraints = constraints.length; - - for (i = 0; i !== Nconstraints; i++) { - var _c2 = constraints[i]; - - _c2.update(); - - for (var _j = 0, Neq = _c2.equations.length; _j !== Neq; _j++) { - var eq = _c2.equations[_j]; - solver.addEquation(eq); - } - } // Solve the constrained system - - - solver.solve(dt, this); - - if (doProfiling) { - profile.solve = performance.now() - profilingStart; - } // Remove all contacts from solver - - - solver.removeAllEquations(); // Apply damping, see http://code.google.com/p/bullet/issues/detail?id=74 for details - - var pow = Math.pow; - - for (i = 0; i !== N; i++) { - var _bi3 = bodies[i]; - - if (_bi3.type & DYNAMIC) { - // Only for dynamic bodies - var ld = pow(1.0 - _bi3.linearDamping, dt); - var v = _bi3.velocity; - v.scale(ld, v); - var av = _bi3.angularVelocity; - - if (av) { - var ad = pow(1.0 - _bi3.angularDamping, dt); - av.scale(ad, av); - } - } - } - - this.dispatchEvent(World_step_preStepEvent); // Invoke pre-step callbacks - - for (i = 0; i !== N; i++) { - var _bi4 = bodies[i]; - - if (_bi4.preStep) { - _bi4.preStep.call(_bi4); - } - } // Leap frog - // vnew = v + h*f/m - // xnew = x + h*vnew - - - if (doProfiling) { - profilingStart = performance.now(); - } - - var stepnumber = this.stepnumber; - var quatNormalize = stepnumber % (this.quatNormalizeSkip + 1) === 0; - var quatNormalizeFast = this.quatNormalizeFast; - - for (i = 0; i !== N; i++) { - bodies[i].integrate(dt, quatNormalize, quatNormalizeFast); - } - - this.clearForces(); - this.broadphase.dirty = true; - - if (doProfiling) { - profile.integrate = performance.now() - profilingStart; - } // Update world time - - - this.time += dt; - this.stepnumber += 1; - this.dispatchEvent(World_step_postStepEvent); // Invoke post-step callbacks - - for (i = 0; i !== N; i++) { - var _bi5 = bodies[i]; - var postStep = _bi5.postStep; - - if (postStep) { - postStep.call(_bi5); - } - } // Sleeping update - - - var hasActiveBodies = true; - - if (this.allowSleep) { - hasActiveBodies = false; - - for (i = 0; i !== N; i++) { - var _bi6 = bodies[i]; - - _bi6.sleepTick(this.time); - - if (_bi6.sleepState !== Body.SLEEPING) { - hasActiveBodies = true; - } - } - } - - this.hasActiveBodies = hasActiveBodies; - } - /** - * Sets all body forces in the world to zero. - * @method clearForces - */ - ; - - _proto.clearForces = function clearForces() { - var bodies = this.bodies; - var N = bodies.length; - - for (var i = 0; i !== N; i++) { - var b = bodies[i]; - var force = b.force; - var tau = b.torque; - b.force.set(0, 0, 0); - b.torque.set(0, 0, 0); - } - }; - - return World; -}(EventTarget); // Temp stuff - -var tmpAABB1 = new AABB(); -var tmpRay$1 = new Ray(); // performance.now() - -if (typeof performance === 'undefined') { - performance = {}; -} - -if (!performance.now) { - var nowOffset = Date.now(); - - if (performance.timing && performance.timing.navigationStart) { - nowOffset = performance.timing.navigationStart; - } - - performance.now = function () { - return Date.now() - nowOffset; - }; -} - -var step_tmp1 = new Vec3(); // Dispatched after the world has stepped forward in time. -// Reusable event objects to save memory. - -var World_step_postStepEvent = { - type: 'postStep' -}; // Dispatched before the world steps forward in time. - -var World_step_preStepEvent = { - type: 'preStep' -}; -var World_step_collideEvent = { - type: Body.COLLIDE_EVENT_NAME, - body: null, - contact: null -}; // Pools for unused objects - -var World_step_oldContacts = []; -var World_step_frictionEquationPool = []; // Reusable arrays for collision pairs - -var World_step_p1 = []; -var World_step_p2 = []; - -World.prototype.emitContactEvents = function () { - var additions = []; - var removals = []; - var beginContactEvent = { - type: 'beginContact', - bodyA: null, - bodyB: null - }; - var endContactEvent = { - type: 'endContact', - bodyA: null, - bodyB: null - }; - var beginShapeContactEvent = { - type: 'beginShapeContact', - bodyA: null, - bodyB: null, - shapeA: null, - shapeB: null - }; - var endShapeContactEvent = { - type: 'endShapeContact', - bodyA: null, - bodyB: null, - shapeA: null, - shapeB: null - }; - return function () { - var hasBeginContact = this.hasAnyEventListener('beginContact'); - var hasEndContact = this.hasAnyEventListener('endContact'); - - if (hasBeginContact || hasEndContact) { - this.bodyOverlapKeeper.getDiff(additions, removals); - } - - if (hasBeginContact) { - for (var i = 0, l = additions.length; i < l; i += 2) { - beginContactEvent.bodyA = this.getBodyById(additions[i]); - beginContactEvent.bodyB = this.getBodyById(additions[i + 1]); - this.dispatchEvent(beginContactEvent); - } - - beginContactEvent.bodyA = beginContactEvent.bodyB = null; - } - - if (hasEndContact) { - for (var _i2 = 0, _l = removals.length; _i2 < _l; _i2 += 2) { - endContactEvent.bodyA = this.getBodyById(removals[_i2]); - endContactEvent.bodyB = this.getBodyById(removals[_i2 + 1]); - this.dispatchEvent(endContactEvent); - } - - endContactEvent.bodyA = endContactEvent.bodyB = null; - } - - additions.length = removals.length = 0; - var hasBeginShapeContact = this.hasAnyEventListener('beginShapeContact'); - var hasEndShapeContact = this.hasAnyEventListener('endShapeContact'); - - if (hasBeginShapeContact || hasEndShapeContact) { - this.shapeOverlapKeeper.getDiff(additions, removals); - } - - if (hasBeginShapeContact) { - for (var _i3 = 0, _l2 = additions.length; _i3 < _l2; _i3 += 2) { - var shapeA = this.getShapeById(additions[_i3]); - var shapeB = this.getShapeById(additions[_i3 + 1]); - beginShapeContactEvent.shapeA = shapeA; - beginShapeContactEvent.shapeB = shapeB; - beginShapeContactEvent.bodyA = shapeA.body; - beginShapeContactEvent.bodyB = shapeB.body; - this.dispatchEvent(beginShapeContactEvent); - } - - beginShapeContactEvent.bodyA = beginShapeContactEvent.bodyB = beginShapeContactEvent.shapeA = beginShapeContactEvent.shapeB = null; - } - - if (hasEndShapeContact) { - for (var _i4 = 0, _l3 = removals.length; _i4 < _l3; _i4 += 2) { - var _shapeA = this.getShapeById(removals[_i4]); - - var _shapeB = this.getShapeById(removals[_i4 + 1]); - - endShapeContactEvent.shapeA = _shapeA; - endShapeContactEvent.shapeB = _shapeB; - endShapeContactEvent.bodyA = _shapeA.body; - endShapeContactEvent.bodyB = _shapeB.body; - this.dispatchEvent(endShapeContactEvent); - } - - endShapeContactEvent.bodyA = endShapeContactEvent.bodyB = endShapeContactEvent.shapeA = endShapeContactEvent.shapeB = null; - } - }; -}(); - -exports.AABB = AABB; -exports.ArrayCollisionMatrix = ArrayCollisionMatrix; -exports.BODY_SLEEP_STATES = BODY_SLEEP_STATES; -exports.BODY_TYPES = BODY_TYPES; -exports.Body = Body; -exports.Box = Box; -exports.Broadphase = Broadphase; -exports.COLLISION_TYPES = COLLISION_TYPES; -exports.ConeTwistConstraint = ConeTwistConstraint; -exports.Constraint = Constraint; -exports.ContactEquation = ContactEquation; -exports.ContactMaterial = ContactMaterial; -exports.ConvexPolyhedron = ConvexPolyhedron; -exports.Cylinder = Cylinder; -exports.DistanceConstraint = DistanceConstraint; -exports.Equation = Equation; -exports.EventTarget = EventTarget; -exports.FrictionEquation = FrictionEquation; -exports.GSSolver = GSSolver; -exports.GridBroadphase = GridBroadphase; -exports.Heightfield = Heightfield; -exports.HingeConstraint = HingeConstraint; -exports.JacobianElement = JacobianElement; -exports.LockConstraint = LockConstraint; -exports.Mat3 = Mat3; -exports.Material = Material; -exports.NaiveBroadphase = NaiveBroadphase; -exports.Narrowphase = Narrowphase; -exports.ObjectCollisionMatrix = ObjectCollisionMatrix; -exports.Particle = Particle; -exports.Plane = Plane; -exports.PointToPointConstraint = PointToPointConstraint; -exports.Pool = Pool; -exports.Quaternion = Quaternion; -exports.RAY_MODES = RAY_MODES; -exports.Ray = Ray; -exports.RaycastResult = RaycastResult; -exports.RaycastVehicle = RaycastVehicle; -exports.RigidVehicle = RigidVehicle; -exports.RotationalEquation = RotationalEquation; -exports.RotationalMotorEquation = RotationalMotorEquation; -exports.SAPBroadphase = SAPBroadphase; -exports.SHAPE_TYPES = SHAPE_TYPES; -exports.SPHSystem = SPHSystem; -exports.Shape = Shape; -exports.Solver = Solver; -exports.Sphere = Sphere; -exports.SplitSolver = SplitSolver; -exports.Spring = Spring; -exports.Transform = Transform; -exports.Trimesh = Trimesh; -exports.Vec3 = Vec3; -exports.Vec3Pool = Vec3Pool; -exports.World = World; - -},{}],6:[function(require,module,exports){ -"use strict"; -/* global Ammo,THREE */ - -const TYPE = (exports.TYPE = { - BOX: "box", - CYLINDER: "cylinder", - SPHERE: "sphere", - CAPSULE: "capsule", - CONE: "cone", - HULL: "hull", - HACD: "hacd", //Hierarchical Approximate Convex Decomposition - VHACD: "vhacd", //Volumetric Hierarchical Approximate Convex Decomposition - MESH: "mesh", - HEIGHTFIELD: "heightfield" -}); - -const FIT = (exports.FIT = { - ALL: "all", //A single shape is automatically sized to bound all meshes within the entity. - MANUAL: "manual" //A single shape is sized manually. Requires halfExtents or sphereRadius. -}); - -const HEIGHTFIELD_DATA_TYPE = (exports.HEIGHTFIELD_DATA_TYPE = { - short: "short", - float: "float" -}); - -const hasUpdateMatricesFunction = THREE.Object3D.prototype.hasOwnProperty("updateMatrices"); - -exports.createCollisionShapes = function(root, options) { - switch (options.type) { - case TYPE.BOX: - return [this.createBoxShape(root, options)]; - case TYPE.CYLINDER: - return [this.createCylinderShape(root, options)]; - case TYPE.CAPSULE: - return [this.createCapsuleShape(root, options)]; - case TYPE.CONE: - return [this.createConeShape(root, options)]; - case TYPE.SPHERE: - return [this.createSphereShape(root, options)]; - case TYPE.HULL: - return [this.createHullShape(root, options)]; - case TYPE.HACD: - return this.createHACDShapes(root, options); - case TYPE.VHACD: - return this.createVHACDShapes(root, options); - case TYPE.MESH: - return [this.createTriMeshShape(root, options)]; - case TYPE.HEIGHTFIELD: - return [this.createHeightfieldTerrainShape(root, options)]; - default: - console.warn(options.type + " is not currently supported"); - return []; - } -}; - -//TODO: support gimpact (dynamic trimesh) and heightmap - -exports.createBoxShape = function(root, options) { - options.type = TYPE.BOX; - _setOptions(options); - - if (options.fit === FIT.ALL) { - options.halfExtents = _computeHalfExtents( - root, - _computeBounds(root, options), - options.minHalfExtent, - options.maxHalfExtent - ); - } - - const btHalfExtents = new Ammo.btVector3(options.halfExtents.x, options.halfExtents.y, options.halfExtents.z); - const collisionShape = new Ammo.btBoxShape(btHalfExtents); - Ammo.destroy(btHalfExtents); - - _finishCollisionShape(collisionShape, options, _computeScale(root, options)); - return collisionShape; -}; - -exports.createCylinderShape = function(root, options) { - options.type = TYPE.CYLINDER; - _setOptions(options); - - if (options.fit === FIT.ALL) { - options.halfExtents = _computeHalfExtents( - root, - _computeBounds(root, options), - options.minHalfExtent, - options.maxHalfExtent - ); - } - - const btHalfExtents = new Ammo.btVector3(options.halfExtents.x, options.halfExtents.y, options.halfExtents.z); - const collisionShape = (() => { - switch (options.cylinderAxis) { - case "y": - return new Ammo.btCylinderShape(btHalfExtents); - case "x": - return new Ammo.btCylinderShapeX(btHalfExtents); - case "z": - return new Ammo.btCylinderShapeZ(btHalfExtents); - } - return null; - })(); - Ammo.destroy(btHalfExtents); - - _finishCollisionShape(collisionShape, options, _computeScale(root, options)); - return collisionShape; -}; - -exports.createCapsuleShape = function(root, options) { - options.type = TYPE.CAPSULE; - _setOptions(options); - - if (options.fit === FIT.ALL) { - options.halfExtents = _computeHalfExtents( - root, - _computeBounds(root, options), - options.minHalfExtent, - options.maxHalfExtent - ); - } - - const { x, y, z } = options.halfExtents; - const collisionShape = (() => { - switch (options.cylinderAxis) { - case "y": - return new Ammo.btCapsuleShape(Math.max(x, z), y * 2); - case "x": - return new Ammo.btCapsuleShapeX(Math.max(y, z), x * 2); - case "z": - return new Ammo.btCapsuleShapeZ(Math.max(x, y), z * 2); - } - return null; - })(); - - _finishCollisionShape(collisionShape, options, _computeScale(root, options)); - return collisionShape; -}; - -exports.createConeShape = function(root, options) { - options.type = TYPE.CONE; - _setOptions(options); - - if (options.fit === FIT.ALL) { - options.halfExtents = _computeHalfExtents( - root, - _computeBounds(root, options), - options.minHalfExtent, - options.maxHalfExtent - ); - } - - const { x, y, z } = options.halfExtents; - const collisionShape = (() => { - switch (options.cylinderAxis) { - case "y": - return new Ammo.btConeShape(Math.max(x, z), y * 2); - case "x": - return new Ammo.btConeShapeX(Math.max(y, z), x * 2); - case "z": - return new Ammo.btConeShapeZ(Math.max(x, y), z * 2); - } - return null; - })(); - - _finishCollisionShape(collisionShape, options, _computeScale(root, options)); - return collisionShape; -}; - -exports.createSphereShape = function(root, options) { - options.type = TYPE.SPHERE; - _setOptions(options); - - let radius; - if (options.fit === FIT.MANUAL && !isNaN(options.sphereRadius)) { - radius = options.sphereRadius; - } else { - radius = _computeRadius(root, options, _computeBounds(root, options)); - } - - const collisionShape = new Ammo.btSphereShape(radius); - _finishCollisionShape(collisionShape, options, _computeScale(root, options)); - - return collisionShape; -}; - -exports.createHullShape = (function() { - const vertex = new THREE.Vector3(); - const center = new THREE.Vector3(); - return function(root, options) { - options.type = TYPE.HULL; - _setOptions(options); - - if (options.fit === FIT.MANUAL) { - console.warn("cannot use fit: manual with type: hull"); - return null; - } - - const bounds = _computeBounds(root, options); - - const btVertex = new Ammo.btVector3(); - const originalHull = new Ammo.btConvexHullShape(); - originalHull.setMargin(options.margin); - center.addVectors(bounds.max, bounds.min).multiplyScalar(0.5); - - let vertexCount = 0; - _iterateGeometries(root, options, geo => { - vertexCount += geo.attributes.position.array.length / 3; - }); - - const maxVertices = options.hullMaxVertices || 100000; - // todo: might want to implement this in a deterministic way that doesn't do O(verts) calls to Math.random - if (vertexCount > maxVertices) { - console.warn(`too many vertices for hull shape; sampling ~${maxVertices} from ~${vertexCount} vertices`); - } - const p = Math.min(1, maxVertices / vertexCount); - - _iterateGeometries(root, options, (geo, transform) => { - const components = geo.attributes.position.array; - for (let i = 0; i < components.length; i += 3) { - if (Math.random() <= p) { - vertex - .set(components[i], components[i + 1], components[i + 2]) - .applyMatrix4(transform) - .sub(center); - btVertex.setValue(vertex.x, vertex.y, vertex.z); - originalHull.addPoint(btVertex, i === components.length - 3); // todo: better to recalc AABB only on last geometry - } - } - }); - - let collisionShape = originalHull; - if (originalHull.getNumVertices() >= 100) { - //Bullet documentation says don't use convexHulls with 100 verts or more - const shapeHull = new Ammo.btShapeHull(originalHull); - shapeHull.buildHull(options.margin); - Ammo.destroy(originalHull); - collisionShape = new Ammo.btConvexHullShape( - Ammo.getPointer(shapeHull.getVertexPointer()), - shapeHull.numVertices() - ); - Ammo.destroy(shapeHull); // btConvexHullShape makes a copy - } - - Ammo.destroy(btVertex); - - _finishCollisionShape(collisionShape, options, _computeScale(root, options)); - return collisionShape; - }; -})(); - -exports.createHACDShapes = (function() { - const v = new THREE.Vector3(); - const center = new THREE.Vector3(); - return function(root, options) { - options.type = TYPE.HACD; - _setOptions(options); - - if (options.fit === FIT.MANUAL) { - console.warn("cannot use fit: manual with type: hacd"); - return []; - } - - if (!Ammo.hasOwnProperty("HACD")) { - console.warn( - "HACD unavailable in included build of Ammo.js. Visit https://github.com/mozillareality/ammo.js for the latest version." - ); - return []; - } - - const bounds = _computeBounds(root); - const scale = _computeScale(root, options); - - let vertexCount = 0; - let triCount = 0; - center.addVectors(bounds.max, bounds.min).multiplyScalar(0.5); - - _iterateGeometries(root, options, geo => { - vertexCount += geo.attributes.position.array.length / 3; - if (geo.index) { - triCount += geo.index.array.length / 3; - } else { - triCount += geo.attributes.position.array.length / 9; - } - }); - - const hacd = new Ammo.HACD(); - if (options.hasOwnProperty("compacityWeight")) hacd.SetCompacityWeight(options.compacityWeight); - if (options.hasOwnProperty("volumeWeight")) hacd.SetVolumeWeight(options.volumeWeight); - if (options.hasOwnProperty("nClusters")) hacd.SetNClusters(options.nClusters); - if (options.hasOwnProperty("nVerticesPerCH")) hacd.SetNVerticesPerCH(options.nVerticesPerCH); - if (options.hasOwnProperty("concavity")) hacd.SetConcavity(options.concavity); - - const points = Ammo._malloc(vertexCount * 3 * 8); - const triangles = Ammo._malloc(triCount * 3 * 4); - hacd.SetPoints(points); - hacd.SetTriangles(triangles); - hacd.SetNPoints(vertexCount); - hacd.SetNTriangles(triCount); - - const pptr = points / 8, - tptr = triangles / 4; - _iterateGeometries(root, options, (geo, transform) => { - const components = geo.attributes.position.array; - const indices = geo.index ? geo.index.array : null; - for (let i = 0; i < components.length; i += 3) { - v.set(components[i + 0], components[i + 1], components[i + 2]) - .applyMatrix4(transform) - .sub(center); - Ammo.HEAPF64[pptr + i + 0] = v.x; - Ammo.HEAPF64[pptr + i + 1] = v.y; - Ammo.HEAPF64[pptr + i + 2] = v.z; - } - if (indices) { - for (let i = 0; i < indices.length; i++) { - Ammo.HEAP32[tptr + i] = indices[i]; - } - } else { - for (let i = 0; i < components.length / 3; i++) { - Ammo.HEAP32[tptr + i] = i; - } - } - }); - - hacd.Compute(); - Ammo._free(points); - Ammo._free(triangles); - const nClusters = hacd.GetNClusters(); - - const shapes = []; - for (let i = 0; i < nClusters; i++) { - const hull = new Ammo.btConvexHullShape(); - hull.setMargin(options.margin); - const nPoints = hacd.GetNPointsCH(i); - const nTriangles = hacd.GetNTrianglesCH(i); - const hullPoints = Ammo._malloc(nPoints * 3 * 8); - const hullTriangles = Ammo._malloc(nTriangles * 3 * 4); - hacd.GetCH(i, hullPoints, hullTriangles); - - const pptr = hullPoints / 8; - for (let pi = 0; pi < nPoints; pi++) { - const btVertex = new Ammo.btVector3(); - const px = Ammo.HEAPF64[pptr + pi * 3 + 0]; - const py = Ammo.HEAPF64[pptr + pi * 3 + 1]; - const pz = Ammo.HEAPF64[pptr + pi * 3 + 2]; - btVertex.setValue(px, py, pz); - hull.addPoint(btVertex, pi === nPoints - 1); - Ammo.destroy(btVertex); - } - - _finishCollisionShape(hull, options, scale); - shapes.push(hull); - } - - return shapes; - }; -})(); - -exports.createVHACDShapes = (function() { - const v = new THREE.Vector3(); - const center = new THREE.Vector3(); - return function(root, options) { - options.type = TYPE.VHACD; - _setOptions(options); - - if (options.fit === FIT.MANUAL) { - console.warn("cannot use fit: manual with type: vhacd"); - return []; - } - - if (!Ammo.hasOwnProperty("VHACD")) { - console.warn( - "VHACD unavailable in included build of Ammo.js. Visit https://github.com/mozillareality/ammo.js for the latest version." - ); - return []; - } - - const bounds = _computeBounds(root, options); - const scale = _computeScale(root, options); - - let vertexCount = 0; - let triCount = 0; - center.addVectors(bounds.max, bounds.min).multiplyScalar(0.5); - - _iterateGeometries(root, options, geo => { - vertexCount += geo.attributes.position.count; - if (geo.index) { - triCount += geo.index.count / 3; - } else { - triCount += geo.attributes.position.count / 3; - } - }); - - const vhacd = new Ammo.VHACD(); - const params = new Ammo.Parameters(); - //https://kmamou.blogspot.com/2014/12/v-hacd-20-parameters-description.html - if (options.hasOwnProperty("resolution")) params.set_m_resolution(options.resolution); - if (options.hasOwnProperty("depth")) params.set_m_depth(options.depth); - if (options.hasOwnProperty("concavity")) params.set_m_concavity(options.concavity); - if (options.hasOwnProperty("planeDownsampling")) params.set_m_planeDownsampling(options.planeDownsampling); - if (options.hasOwnProperty("convexhullDownsampling")) - params.set_m_convexhullDownsampling(options.convexhullDownsampling); - if (options.hasOwnProperty("alpha")) params.set_m_alpha(options.alpha); - if (options.hasOwnProperty("beta")) params.set_m_beta(options.beta); - if (options.hasOwnProperty("gamma")) params.set_m_gamma(options.gamma); - if (options.hasOwnProperty("pca")) params.set_m_pca(options.pca); - if (options.hasOwnProperty("mode")) params.set_m_mode(options.mode); - if (options.hasOwnProperty("maxNumVerticesPerCH")) params.set_m_maxNumVerticesPerCH(options.maxNumVerticesPerCH); - if (options.hasOwnProperty("minVolumePerCH")) params.set_m_minVolumePerCH(options.minVolumePerCH); - if (options.hasOwnProperty("convexhullApproximation")) - params.set_m_convexhullApproximation(options.convexhullApproximation); - if (options.hasOwnProperty("oclAcceleration")) params.set_m_oclAcceleration(options.oclAcceleration); - - const points = Ammo._malloc(vertexCount * 3 * 8); - const triangles = Ammo._malloc(triCount * 3 * 4); - - let pptr = points / 8, - tptr = triangles / 4; - _iterateGeometries(root, options, (geo, transform) => { - const components = geo.attributes.position.array; - const indices = geo.index ? geo.index.array : null; - for (let i = 0; i < components.length; i += 3) { - v.set(components[i + 0], components[i + 1], components[i + 2]) - .applyMatrix4(transform) - .sub(center); - Ammo.HEAPF64[pptr + 0] = v.x; - Ammo.HEAPF64[pptr + 1] = v.y; - Ammo.HEAPF64[pptr + 2] = v.z; - pptr += 3; - } - if (indices) { - for (let i = 0; i < indices.length; i++) { - Ammo.HEAP32[tptr] = indices[i]; - tptr++; - } - } else { - for (let i = 0; i < components.length / 3; i++) { - Ammo.HEAP32[tptr] = i; - tptr++; - } - } - }); - - vhacd.Compute(points, 3, vertexCount, triangles, 3, triCount, params); - Ammo._free(points); - Ammo._free(triangles); - const nHulls = vhacd.GetNConvexHulls(); - - const shapes = []; - const ch = new Ammo.ConvexHull(); - for (let i = 0; i < nHulls; i++) { - vhacd.GetConvexHull(i, ch); - const nPoints = ch.get_m_nPoints(); - const hullPoints = ch.get_m_points(); - - const hull = new Ammo.btConvexHullShape(); - hull.setMargin(options.margin); - - for (let pi = 0; pi < nPoints; pi++) { - const btVertex = new Ammo.btVector3(); - const px = ch.get_m_points(pi * 3 + 0); - const py = ch.get_m_points(pi * 3 + 1); - const pz = ch.get_m_points(pi * 3 + 2); - btVertex.setValue(px, py, pz); - hull.addPoint(btVertex, pi === nPoints - 1); - Ammo.destroy(btVertex); - } - - _finishCollisionShape(hull, options, scale); - shapes.push(hull); - } - Ammo.destroy(ch); - Ammo.destroy(vhacd); - - return shapes; - }; -})(); - -exports.createTriMeshShape = (function() { - const va = new THREE.Vector3(); - const vb = new THREE.Vector3(); - const vc = new THREE.Vector3(); - return function(root, options) { - options.type = TYPE.MESH; - _setOptions(options); - - if (options.fit === FIT.MANUAL) { - console.warn("cannot use fit: manual with type: mesh"); - return null; - } - - const scale = _computeScale(root, options); - - const bta = new Ammo.btVector3(); - const btb = new Ammo.btVector3(); - const btc = new Ammo.btVector3(); - const triMesh = new Ammo.btTriangleMesh(true, false); - - _iterateGeometries(root, options, (geo, transform) => { - const components = geo.attributes.position.array; - if (geo.index) { - for (let i = 0; i < geo.index.count; i += 3) { - const ai = geo.index.array[i] * 3; - const bi = geo.index.array[i + 1] * 3; - const ci = geo.index.array[i + 2] * 3; - va.set(components[ai], components[ai + 1], components[ai + 2]).applyMatrix4(transform); - vb.set(components[bi], components[bi + 1], components[bi + 2]).applyMatrix4(transform); - vc.set(components[ci], components[ci + 1], components[ci + 2]).applyMatrix4(transform); - bta.setValue(va.x, va.y, va.z); - btb.setValue(vb.x, vb.y, vb.z); - btc.setValue(vc.x, vc.y, vc.z); - triMesh.addTriangle(bta, btb, btc, false); - } - } else { - for (let i = 0; i < components.length; i += 9) { - va.set(components[i + 0], components[i + 1], components[i + 2]).applyMatrix4(transform); - vb.set(components[i + 3], components[i + 4], components[i + 5]).applyMatrix4(transform); - vc.set(components[i + 6], components[i + 7], components[i + 8]).applyMatrix4(transform); - bta.setValue(va.x, va.y, va.z); - btb.setValue(vb.x, vb.y, vb.z); - btc.setValue(vc.x, vc.y, vc.z); - triMesh.addTriangle(bta, btb, btc, false); - } - } - }); - - const localScale = new Ammo.btVector3(scale.x, scale.y, scale.z); - triMesh.setScaling(localScale); - Ammo.destroy(localScale); - - const collisionShape = new Ammo.btBvhTriangleMeshShape(triMesh, true, true); - collisionShape.resources = [triMesh]; - - Ammo.destroy(bta); - Ammo.destroy(btb); - Ammo.destroy(btc); - - _finishCollisionShape(collisionShape, options); - return collisionShape; - }; -})(); - -exports.createHeightfieldTerrainShape = function(root, options) { - _setOptions(options); - - if (options.fit === FIT.ALL) { - console.warn("cannot use fit: all with type: heightfield"); - return null; - } - const heightfieldDistance = options.heightfieldDistance || 1; - const heightfieldData = options.heightfieldData || []; - const heightScale = options.heightScale || 0; - const upAxis = options.hasOwnProperty("upAxis") ? options.upAxis : 1; // x = 0; y = 1; z = 2 - const hdt = (() => { - switch (options.heightDataType) { - case "short": - return Ammo.PHY_SHORT; - case "float": - return Ammo.PHY_FLOAT; - default: - return Ammo.PHY_FLOAT; - } - })(); - const flipQuadEdges = options.hasOwnProperty("flipQuadEdges") ? options.flipQuadEdges : true; - - const heightStickLength = heightfieldData.length; - const heightStickWidth = heightStickLength > 0 ? heightfieldData[0].length : 0; - - const data = Ammo._malloc(heightStickLength * heightStickWidth * 4); - const ptr = data / 4; - - let minHeight = Number.POSITIVE_INFINITY; - let maxHeight = Number.NEGATIVE_INFINITY; - let index = 0; - for (let l = 0; l < heightStickLength; l++) { - for (let w = 0; w < heightStickWidth; w++) { - const height = heightfieldData[l][w]; - Ammo.HEAPF32[ptr + index] = height; - index++; - minHeight = Math.min(minHeight, height); - maxHeight = Math.max(maxHeight, height); - } - } - - const collisionShape = new Ammo.btHeightfieldTerrainShape( - heightStickWidth, - heightStickLength, - data, - heightScale, - minHeight, - maxHeight, - upAxis, - hdt, - flipQuadEdges - ); - - const scale = new Ammo.btVector3(heightfieldDistance, 1, heightfieldDistance); - collisionShape.setLocalScaling(scale); - Ammo.destroy(scale); - - collisionShape.heightfieldData = data; - - _finishCollisionShape(collisionShape, options); - return collisionShape; -}; - -function _setOptions(options) { - options.fit = options.hasOwnProperty("fit") ? options.fit : FIT.ALL; - options.type = options.type || TYPE.HULL; - options.minHalfExtent = options.hasOwnProperty("minHalfExtent") ? options.minHalfExtent : 0; - options.maxHalfExtent = options.hasOwnProperty("maxHalfExtent") ? options.maxHalfExtent : Number.POSITIVE_INFINITY; - options.cylinderAxis = options.cylinderAxis || "y"; - options.margin = options.hasOwnProperty("margin") ? options.margin : 0.01; - options.includeInvisible = options.hasOwnProperty("includeInvisible") ? options.includeInvisible : false; - - if (!options.offset) { - options.offset = new THREE.Vector3(); - } - - if (!options.orientation) { - options.orientation = new THREE.Quaternion(); - } -} - -const _finishCollisionShape = function(collisionShape, options, scale) { - collisionShape.type = options.type; - collisionShape.setMargin(options.margin); - collisionShape.destroy = () => { - for (let res of collisionShape.resources || []) { - Ammo.destroy(res); - } - if (collisionShape.heightfieldData) { - Ammo._free(collisionShape.heightfieldData); - } - Ammo.destroy(collisionShape); - }; - - const localTransform = new Ammo.btTransform(); - const rotation = new Ammo.btQuaternion(); - localTransform.setIdentity(); - - localTransform.getOrigin().setValue(options.offset.x, options.offset.y, options.offset.z); - rotation.setValue(options.orientation.x, options.orientation.y, options.orientation.z, options.orientation.w); - - localTransform.setRotation(rotation); - Ammo.destroy(rotation); - - if (scale) { - const localScale = new Ammo.btVector3(scale.x, scale.y, scale.z); - collisionShape.setLocalScaling(localScale); - Ammo.destroy(localScale); - } - - collisionShape.localTransform = localTransform; -}; - -// Calls `cb(geo, transform)` for each geometry under `root` whose vertices we should take into account for the physics shape. -// `transform` is the transform required to transform the given geometry's vertices into root-local space. -const _iterateGeometries = (function() { - const transform = new THREE.Matrix4(); - const inverse = new THREE.Matrix4(); - const bufferGeometry = new THREE.BufferGeometry(); - return function(root, options, cb) { - inverse.getInverse(root.matrixWorld); - root.traverse(mesh => { - if ( - mesh.isMesh && - (!THREE.Sky || mesh.__proto__ != THREE.Sky.prototype) && - (options.includeInvisible || ((mesh.el && mesh.el.object3D.visible) || mesh.visible)) - ) { - if (mesh === root) { - transform.identity(); - } else { - if (hasUpdateMatricesFunction) mesh.updateMatrices(); - transform.multiplyMatrices(inverse, mesh.matrixWorld); - } - // todo: might want to return null xform if this is the root so that callers can avoid multiplying - // things by the identity matrix - cb(mesh.geometry.isBufferGeometry ? mesh.geometry : bufferGeometry.fromGeometry(mesh.geometry), transform); - } - }); - }; -})(); - -const _computeScale = function(root, options) { - const scale = new THREE.Vector3(1, 1, 1); - if (options.fit === FIT.ALL) { - scale.setFromMatrixScale(root.matrixWorld); - } - return scale; -}; - -const _computeRadius = (function() { - const v = new THREE.Vector3(); - const center = new THREE.Vector3(); - return function(root, options, bounds) { - let maxRadiusSq = 0; - let { x: cx, y: cy, z: cz } = bounds.getCenter(center); - _iterateGeometries(root, options, (geo, transform) => { - const components = geo.attributes.position.array; - for (let i = 0; i < components.length; i += 3) { - v.set(components[i], components[i + 1], components[i + 2]).applyMatrix4(transform); - const dx = cx - v.x; - const dy = cy - v.y; - const dz = cz - v.z; - maxRadiusSq = Math.max(maxRadiusSq, dx * dx + dy * dy + dz * dz); - } - }); - return Math.sqrt(maxRadiusSq); - }; -})(); - -const _computeHalfExtents = function(root, bounds, minHalfExtent, maxHalfExtent) { - const halfExtents = new THREE.Vector3(); - return halfExtents - .subVectors(bounds.max, bounds.min) - .multiplyScalar(0.5) - .clampScalar(minHalfExtent, maxHalfExtent); -}; - -const _computeLocalOffset = function(matrix, bounds, target) { - target - .addVectors(bounds.max, bounds.min) - .multiplyScalar(0.5) - .applyMatrix4(matrix); - return target; -}; - -// returns the bounding box for the geometries underneath `root`. -const _computeBounds = (function() { - const v = new THREE.Vector3(); - return function(root, options) { - const bounds = new THREE.Box3(); - let minX = +Infinity; - let minY = +Infinity; - let minZ = +Infinity; - let maxX = -Infinity; - let maxY = -Infinity; - let maxZ = -Infinity; - bounds.min.set(0, 0, 0); - bounds.max.set(0, 0, 0); - _iterateGeometries(root, options, (geo, transform) => { - const components = geo.attributes.position.array; - for (let i = 0; i < components.length; i += 3) { - v.set(components[i], components[i + 1], components[i + 2]).applyMatrix4(transform); - if (v.x < minX) minX = v.x; - if (v.y < minY) minY = v.y; - if (v.z < minZ) minZ = v.z; - if (v.x > maxX) maxX = v.x; - if (v.y > maxY) maxY = v.y; - if (v.z > maxZ) maxZ = v.z; - } - }); - bounds.min.set(minX, minY, minZ); - bounds.max.set(maxX, maxY, maxZ); - return bounds; - }; -})(); - -},{}],7:[function(require,module,exports){ -(function (global){ -var cannonEs = require('cannon-es'); -var three = (typeof window !== "undefined" ? window['THREE'] : typeof global !== "undefined" ? global['THREE'] : null); - -/** - * Ported from: https://github.com/maurizzzio/quickhull3d/ by Mauricio Poppe (https://github.com/maurizzzio) - */ - -var ConvexHull = function () { - var Visible = 0; - var Deleted = 1; - var v1 = new three.Vector3(); - - function ConvexHull() { - this.tolerance = -1; - this.faces = []; // the generated faces of the convex hull - - this.newFaces = []; // this array holds the faces that are generated within a single iteration - // the vertex lists work as follows: - // - // let 'a' and 'b' be 'Face' instances - // let 'v' be points wrapped as instance of 'Vertex' - // - // [v, v, ..., v, v, v, ...] - // ^ ^ - // | | - // a.outside b.outside - // - - this.assigned = new VertexList(); - this.unassigned = new VertexList(); - this.vertices = []; // vertices of the hull (internal representation of given geometry data) - } - - Object.assign(ConvexHull.prototype, { - setFromPoints: function (points) { - if (Array.isArray(points) !== true) { - console.error('THREE.ConvexHull: Points parameter is not an array.'); - } - - if (points.length < 4) { - console.error('THREE.ConvexHull: The algorithm needs at least four points.'); - } - - this.makeEmpty(); - - for (var i = 0, l = points.length; i < l; i++) { - this.vertices.push(new VertexNode(points[i])); - } - - this.compute(); - return this; - }, - setFromObject: function (object) { - var points = []; - object.updateMatrixWorld(true); - object.traverse(function (node) { - var i, l, point; - var geometry = node.geometry; - if (geometry === undefined) return; - - if (geometry.isGeometry) { - geometry = geometry.toBufferGeometry ? geometry.toBufferGeometry() : new three.BufferGeometry().fromGeometry(geometry); - } - - if (geometry.isBufferGeometry) { - var attribute = geometry.attributes.position; - - if (attribute !== undefined) { - for (i = 0, l = attribute.count; i < l; i++) { - point = new three.Vector3(); - point.fromBufferAttribute(attribute, i).applyMatrix4(node.matrixWorld); - points.push(point); - } - } - } - }); - return this.setFromPoints(points); - }, - containsPoint: function (point) { - var faces = this.faces; - - for (var i = 0, l = faces.length; i < l; i++) { - var face = faces[i]; // compute signed distance and check on what half space the point lies - - if (face.distanceToPoint(point) > this.tolerance) return false; - } - - return true; - }, - intersectRay: function (ray, target) { - // based on "Fast Ray-Convex Polyhedron Intersection" by Eric Haines, GRAPHICS GEMS II - var faces = this.faces; - var tNear = -Infinity; - var tFar = Infinity; - - for (var i = 0, l = faces.length; i < l; i++) { - var face = faces[i]; // interpret faces as planes for the further computation - - var vN = face.distanceToPoint(ray.origin); - var vD = face.normal.dot(ray.direction); // if the origin is on the positive side of a plane (so the plane can "see" the origin) and - // the ray is turned away or parallel to the plane, there is no intersection - - if (vN > 0 && vD >= 0) return null; // compute the distance from the ray’s origin to the intersection with the plane - - var t = vD !== 0 ? -vN / vD : 0; // only proceed if the distance is positive. a negative distance means the intersection point - // lies "behind" the origin - - if (t <= 0) continue; // now categorized plane as front-facing or back-facing - - if (vD > 0) { - // plane faces away from the ray, so this plane is a back-face - tFar = Math.min(t, tFar); - } else { - // front-face - tNear = Math.max(t, tNear); - } - - if (tNear > tFar) { - // if tNear ever is greater than tFar, the ray must miss the convex hull - return null; - } - } // evaluate intersection point - // always try tNear first since its the closer intersection point - - - if (tNear !== -Infinity) { - ray.at(tNear, target); - } else { - ray.at(tFar, target); - } - - return target; - }, - intersectsRay: function (ray) { - return this.intersectRay(ray, v1) !== null; - }, - makeEmpty: function () { - this.faces = []; - this.vertices = []; - return this; - }, - // Adds a vertex to the 'assigned' list of vertices and assigns it to the given face - addVertexToFace: function (vertex, face) { - vertex.face = face; - - if (face.outside === null) { - this.assigned.append(vertex); - } else { - this.assigned.insertBefore(face.outside, vertex); - } - - face.outside = vertex; - return this; - }, - // Removes a vertex from the 'assigned' list of vertices and from the given face - removeVertexFromFace: function (vertex, face) { - if (vertex === face.outside) { - // fix face.outside link - if (vertex.next !== null && vertex.next.face === face) { - // face has at least 2 outside vertices, move the 'outside' reference - face.outside = vertex.next; - } else { - // vertex was the only outside vertex that face had - face.outside = null; - } - } - - this.assigned.remove(vertex); - return this; - }, - // Removes all the visible vertices that a given face is able to see which are stored in the 'assigned' vertext list - removeAllVerticesFromFace: function (face) { - if (face.outside !== null) { - // reference to the first and last vertex of this face - var start = face.outside; - var end = face.outside; - - while (end.next !== null && end.next.face === face) { - end = end.next; - } - - this.assigned.removeSubList(start, end); // fix references - - start.prev = end.next = null; - face.outside = null; - return start; - } - }, - // Removes all the visible vertices that 'face' is able to see - deleteFaceVertices: function (face, absorbingFace) { - var faceVertices = this.removeAllVerticesFromFace(face); - - if (faceVertices !== undefined) { - if (absorbingFace === undefined) { - // mark the vertices to be reassigned to some other face - this.unassigned.appendChain(faceVertices); - } else { - // if there's an absorbing face try to assign as many vertices as possible to it - var vertex = faceVertices; - - do { - // we need to buffer the subsequent vertex at this point because the 'vertex.next' reference - // will be changed by upcoming method calls - var nextVertex = vertex.next; - var distance = absorbingFace.distanceToPoint(vertex.point); // check if 'vertex' is able to see 'absorbingFace' - - if (distance > this.tolerance) { - this.addVertexToFace(vertex, absorbingFace); - } else { - this.unassigned.append(vertex); - } // now assign next vertex - - - vertex = nextVertex; - } while (vertex !== null); - } - } - - return this; - }, - // Reassigns as many vertices as possible from the unassigned list to the new faces - resolveUnassignedPoints: function (newFaces) { - if (this.unassigned.isEmpty() === false) { - var vertex = this.unassigned.first(); - - do { - // buffer 'next' reference, see .deleteFaceVertices() - var nextVertex = vertex.next; - var maxDistance = this.tolerance; - var maxFace = null; - - for (var i = 0; i < newFaces.length; i++) { - var face = newFaces[i]; - - if (face.mark === Visible) { - var distance = face.distanceToPoint(vertex.point); - - if (distance > maxDistance) { - maxDistance = distance; - maxFace = face; - } - - if (maxDistance > 1000 * this.tolerance) break; - } - } // 'maxFace' can be null e.g. if there are identical vertices - - - if (maxFace !== null) { - this.addVertexToFace(vertex, maxFace); - } - - vertex = nextVertex; - } while (vertex !== null); - } - - return this; - }, - // Computes the extremes of a simplex which will be the initial hull - computeExtremes: function () { - var min = new three.Vector3(); - var max = new three.Vector3(); - var minVertices = []; - var maxVertices = []; - var i, l, j; // initially assume that the first vertex is the min/max - - for (i = 0; i < 3; i++) { - minVertices[i] = maxVertices[i] = this.vertices[0]; - } - - min.copy(this.vertices[0].point); - max.copy(this.vertices[0].point); // compute the min/max vertex on all six directions - - for (i = 0, l = this.vertices.length; i < l; i++) { - var vertex = this.vertices[i]; - var point = vertex.point; // update the min coordinates - - for (j = 0; j < 3; j++) { - if (point.getComponent(j) < min.getComponent(j)) { - min.setComponent(j, point.getComponent(j)); - minVertices[j] = vertex; - } - } // update the max coordinates - - - for (j = 0; j < 3; j++) { - if (point.getComponent(j) > max.getComponent(j)) { - max.setComponent(j, point.getComponent(j)); - maxVertices[j] = vertex; - } - } - } // use min/max vectors to compute an optimal epsilon - - - this.tolerance = 3 * Number.EPSILON * (Math.max(Math.abs(min.x), Math.abs(max.x)) + Math.max(Math.abs(min.y), Math.abs(max.y)) + Math.max(Math.abs(min.z), Math.abs(max.z))); - return { - min: minVertices, - max: maxVertices - }; - }, - // Computes the initial simplex assigning to its faces all the points - // that are candidates to form part of the hull - computeInitialHull: function () { - var line3, plane, closestPoint; - return function computeInitialHull() { - if (line3 === undefined) { - line3 = new three.Line3(); - plane = new three.Plane(); - closestPoint = new three.Vector3(); - } - - var vertex, - vertices = this.vertices; - var extremes = this.computeExtremes(); - var min = extremes.min; - var max = extremes.max; - var v0, v1, v2, v3; - var i, l, j; // 1. Find the two vertices 'v0' and 'v1' with the greatest 1d separation - // (max.x - min.x) - // (max.y - min.y) - // (max.z - min.z) - - var distance, - maxDistance = 0; - var index = 0; - - for (i = 0; i < 3; i++) { - distance = max[i].point.getComponent(i) - min[i].point.getComponent(i); - - if (distance > maxDistance) { - maxDistance = distance; - index = i; - } - } - - v0 = min[index]; - v1 = max[index]; // 2. The next vertex 'v2' is the one farthest to the line formed by 'v0' and 'v1' - - maxDistance = 0; - line3.set(v0.point, v1.point); - - for (i = 0, l = this.vertices.length; i < l; i++) { - vertex = vertices[i]; - - if (vertex !== v0 && vertex !== v1) { - line3.closestPointToPoint(vertex.point, true, closestPoint); - distance = closestPoint.distanceToSquared(vertex.point); - - if (distance > maxDistance) { - maxDistance = distance; - v2 = vertex; - } - } - } // 3. The next vertex 'v3' is the one farthest to the plane 'v0', 'v1', 'v2' - - - maxDistance = -1; - plane.setFromCoplanarPoints(v0.point, v1.point, v2.point); - - for (i = 0, l = this.vertices.length; i < l; i++) { - vertex = vertices[i]; - - if (vertex !== v0 && vertex !== v1 && vertex !== v2) { - distance = Math.abs(plane.distanceToPoint(vertex.point)); - - if (distance > maxDistance) { - maxDistance = distance; - v3 = vertex; - } - } - } - - var faces = []; - - if (plane.distanceToPoint(v3.point) < 0) { - // the face is not able to see the point so 'plane.normal' is pointing outside the tetrahedron - faces.push(Face.create(v0, v1, v2), Face.create(v3, v1, v0), Face.create(v3, v2, v1), Face.create(v3, v0, v2)); // set the twin edge - - for (i = 0; i < 3; i++) { - j = (i + 1) % 3; // join face[ i ] i > 0, with the first face - - faces[i + 1].getEdge(2).setTwin(faces[0].getEdge(j)); // join face[ i ] with face[ i + 1 ], 1 <= i <= 3 - - faces[i + 1].getEdge(1).setTwin(faces[j + 1].getEdge(0)); - } - } else { - // the face is able to see the point so 'plane.normal' is pointing inside the tetrahedron - faces.push(Face.create(v0, v2, v1), Face.create(v3, v0, v1), Face.create(v3, v1, v2), Face.create(v3, v2, v0)); // set the twin edge - - for (i = 0; i < 3; i++) { - j = (i + 1) % 3; // join face[ i ] i > 0, with the first face - - faces[i + 1].getEdge(2).setTwin(faces[0].getEdge((3 - i) % 3)); // join face[ i ] with face[ i + 1 ] - - faces[i + 1].getEdge(0).setTwin(faces[j + 1].getEdge(1)); - } - } // the initial hull is the tetrahedron - - - for (i = 0; i < 4; i++) { - this.faces.push(faces[i]); - } // initial assignment of vertices to the faces of the tetrahedron - - - for (i = 0, l = vertices.length; i < l; i++) { - vertex = vertices[i]; - - if (vertex !== v0 && vertex !== v1 && vertex !== v2 && vertex !== v3) { - maxDistance = this.tolerance; - var maxFace = null; - - for (j = 0; j < 4; j++) { - distance = this.faces[j].distanceToPoint(vertex.point); - - if (distance > maxDistance) { - maxDistance = distance; - maxFace = this.faces[j]; - } - } - - if (maxFace !== null) { - this.addVertexToFace(vertex, maxFace); - } - } - } - - return this; - }; - }(), - // Removes inactive faces - reindexFaces: function () { - var activeFaces = []; - - for (var i = 0; i < this.faces.length; i++) { - var face = this.faces[i]; - - if (face.mark === Visible) { - activeFaces.push(face); - } - } - - this.faces = activeFaces; - return this; - }, - // Finds the next vertex to create faces with the current hull - nextVertexToAdd: function () { - // if the 'assigned' list of vertices is empty, no vertices are left. return with 'undefined' - if (this.assigned.isEmpty() === false) { - var eyeVertex, - maxDistance = 0; // grap the first available face and start with the first visible vertex of that face - - var eyeFace = this.assigned.first().face; - var vertex = eyeFace.outside; // now calculate the farthest vertex that face can see - - do { - var distance = eyeFace.distanceToPoint(vertex.point); - - if (distance > maxDistance) { - maxDistance = distance; - eyeVertex = vertex; - } - - vertex = vertex.next; - } while (vertex !== null && vertex.face === eyeFace); - - return eyeVertex; - } - }, - // Computes a chain of half edges in CCW order called the 'horizon'. - // For an edge to be part of the horizon it must join a face that can see - // 'eyePoint' and a face that cannot see 'eyePoint'. - computeHorizon: function (eyePoint, crossEdge, face, horizon) { - // moves face's vertices to the 'unassigned' vertex list - this.deleteFaceVertices(face); - face.mark = Deleted; - var edge; - - if (crossEdge === null) { - edge = crossEdge = face.getEdge(0); - } else { - // start from the next edge since 'crossEdge' was already analyzed - // (actually 'crossEdge.twin' was the edge who called this method recursively) - edge = crossEdge.next; - } - - do { - var twinEdge = edge.twin; - var oppositeFace = twinEdge.face; - - if (oppositeFace.mark === Visible) { - if (oppositeFace.distanceToPoint(eyePoint) > this.tolerance) { - // the opposite face can see the vertex, so proceed with next edge - this.computeHorizon(eyePoint, twinEdge, oppositeFace, horizon); - } else { - // the opposite face can't see the vertex, so this edge is part of the horizon - horizon.push(edge); - } - } - - edge = edge.next; - } while (edge !== crossEdge); - - return this; - }, - // Creates a face with the vertices 'eyeVertex.point', 'horizonEdge.tail' and 'horizonEdge.head' in CCW order - addAdjoiningFace: function (eyeVertex, horizonEdge) { - // all the half edges are created in ccw order thus the face is always pointing outside the hull - var face = Face.create(eyeVertex, horizonEdge.tail(), horizonEdge.head()); - this.faces.push(face); // join face.getEdge( - 1 ) with the horizon's opposite edge face.getEdge( - 1 ) = face.getEdge( 2 ) - - face.getEdge(-1).setTwin(horizonEdge.twin); - return face.getEdge(0); // the half edge whose vertex is the eyeVertex - }, - // Adds 'horizon.length' faces to the hull, each face will be linked with the - // horizon opposite face and the face on the left/right - addNewFaces: function (eyeVertex, horizon) { - this.newFaces = []; - var firstSideEdge = null; - var previousSideEdge = null; - - for (var i = 0; i < horizon.length; i++) { - var horizonEdge = horizon[i]; // returns the right side edge - - var sideEdge = this.addAdjoiningFace(eyeVertex, horizonEdge); - - if (firstSideEdge === null) { - firstSideEdge = sideEdge; - } else { - // joins face.getEdge( 1 ) with previousFace.getEdge( 0 ) - sideEdge.next.setTwin(previousSideEdge); - } - - this.newFaces.push(sideEdge.face); - previousSideEdge = sideEdge; - } // perform final join of new faces - - - firstSideEdge.next.setTwin(previousSideEdge); - return this; - }, - // Adds a vertex to the hull - addVertexToHull: function (eyeVertex) { - var horizon = []; - this.unassigned.clear(); // remove 'eyeVertex' from 'eyeVertex.face' so that it can't be added to the 'unassigned' vertex list - - this.removeVertexFromFace(eyeVertex, eyeVertex.face); - this.computeHorizon(eyeVertex.point, null, eyeVertex.face, horizon); - this.addNewFaces(eyeVertex, horizon); // reassign 'unassigned' vertices to the new faces - - this.resolveUnassignedPoints(this.newFaces); - return this; - }, - cleanup: function () { - this.assigned.clear(); - this.unassigned.clear(); - this.newFaces = []; - return this; - }, - compute: function () { - var vertex; - this.computeInitialHull(); // add all available vertices gradually to the hull - - while ((vertex = this.nextVertexToAdd()) !== undefined) { - this.addVertexToHull(vertex); - } - - this.reindexFaces(); - this.cleanup(); - return this; - } - }); // - - function Face() { - this.normal = new three.Vector3(); - this.midpoint = new three.Vector3(); - this.area = 0; - this.constant = 0; // signed distance from face to the origin - - this.outside = null; // reference to a vertex in a vertex list this face can see - - this.mark = Visible; - this.edge = null; - } - - Object.assign(Face, { - create: function (a, b, c) { - var face = new Face(); - var e0 = new HalfEdge(a, face); - var e1 = new HalfEdge(b, face); - var e2 = new HalfEdge(c, face); // join edges - - e0.next = e2.prev = e1; - e1.next = e0.prev = e2; - e2.next = e1.prev = e0; // main half edge reference - - face.edge = e0; - return face.compute(); - } - }); - Object.assign(Face.prototype, { - getEdge: function (i) { - var edge = this.edge; - - while (i > 0) { - edge = edge.next; - i--; - } - - while (i < 0) { - edge = edge.prev; - i++; - } - - return edge; - }, - compute: function () { - var triangle; - return function compute() { - if (triangle === undefined) triangle = new three.Triangle(); - var a = this.edge.tail(); - var b = this.edge.head(); - var c = this.edge.next.head(); - triangle.set(a.point, b.point, c.point); - triangle.getNormal(this.normal); - triangle.getMidpoint(this.midpoint); - this.area = triangle.getArea(); - this.constant = this.normal.dot(this.midpoint); - return this; - }; - }(), - distanceToPoint: function (point) { - return this.normal.dot(point) - this.constant; - } - }); // Entity for a Doubly-Connected Edge List (DCEL). - - function HalfEdge(vertex, face) { - this.vertex = vertex; - this.prev = null; - this.next = null; - this.twin = null; - this.face = face; - } - - Object.assign(HalfEdge.prototype, { - head: function () { - return this.vertex; - }, - tail: function () { - return this.prev ? this.prev.vertex : null; - }, - length: function () { - var head = this.head(); - var tail = this.tail(); - - if (tail !== null) { - return tail.point.distanceTo(head.point); - } - - return -1; - }, - lengthSquared: function () { - var head = this.head(); - var tail = this.tail(); - - if (tail !== null) { - return tail.point.distanceToSquared(head.point); - } - - return -1; - }, - setTwin: function (edge) { - this.twin = edge; - edge.twin = this; - return this; - } - }); // A vertex as a double linked list node. - - function VertexNode(point) { - this.point = point; - this.prev = null; - this.next = null; - this.face = null; // the face that is able to see this vertex - } // A double linked list that contains vertex nodes. - - - function VertexList() { - this.head = null; - this.tail = null; - } - - Object.assign(VertexList.prototype, { - first: function () { - return this.head; - }, - last: function () { - return this.tail; - }, - clear: function () { - this.head = this.tail = null; - return this; - }, - // Inserts a vertex before the target vertex - insertBefore: function (target, vertex) { - vertex.prev = target.prev; - vertex.next = target; - - if (vertex.prev === null) { - this.head = vertex; - } else { - vertex.prev.next = vertex; - } - - target.prev = vertex; - return this; - }, - // Inserts a vertex after the target vertex - insertAfter: function (target, vertex) { - vertex.prev = target; - vertex.next = target.next; - - if (vertex.next === null) { - this.tail = vertex; - } else { - vertex.next.prev = vertex; - } - - target.next = vertex; - return this; - }, - // Appends a vertex to the end of the linked list - append: function (vertex) { - if (this.head === null) { - this.head = vertex; - } else { - this.tail.next = vertex; - } - - vertex.prev = this.tail; - vertex.next = null; // the tail has no subsequent vertex - - this.tail = vertex; - return this; - }, - // Appends a chain of vertices where 'vertex' is the head. - appendChain: function (vertex) { - if (this.head === null) { - this.head = vertex; - } else { - this.tail.next = vertex; - } - - vertex.prev = this.tail; // ensure that the 'tail' reference points to the last vertex of the chain - - while (vertex.next !== null) { - vertex = vertex.next; - } - - this.tail = vertex; - return this; - }, - // Removes a vertex from the linked list - remove: function (vertex) { - if (vertex.prev === null) { - this.head = vertex.next; - } else { - vertex.prev.next = vertex.next; - } - - if (vertex.next === null) { - this.tail = vertex.prev; - } else { - vertex.next.prev = vertex.prev; - } - - return this; - }, - // Removes a list of vertices whose 'head' is 'a' and whose 'tail' is b - removeSubList: function (a, b) { - if (a.prev === null) { - this.head = b.next; - } else { - a.prev.next = b.next; - } - - if (b.next === null) { - this.tail = a.prev; - } else { - b.next.prev = a.prev; - } - - return this; - }, - isEmpty: function () { - return this.head === null; - } - }); - return ConvexHull; -}(); - -const _v1 = new three.Vector3(); - -const _v2 = new three.Vector3(); - -const _q1 = new three.Quaternion(); -/** -* Returns a single geometry for the given object. If the object is compound, -* its geometries are automatically merged. Bake world scale into each -* geometry, because we can't easily apply that to the cannonjs shapes later. -*/ - - -function getGeometry(object) { - const meshes = getMeshes(object); - if (meshes.length === 0) return null; // Single mesh. Return, preserving original type. - - if (meshes.length === 1) { - return normalizeGeometry(meshes[0]); - } // Multiple meshes. Merge and return. - - - let mesh; - const geometries = []; - - while (mesh = meshes.pop()) { - geometries.push(simplifyGeometry(normalizeGeometry(mesh))); - } - - return mergeBufferGeometries(geometries); -} - -function normalizeGeometry(mesh) { - let geometry = mesh.geometry; - - if (geometry.toBufferGeometry) { - geometry = geometry.toBufferGeometry(); - } else { - // Preserve original type, e.g. CylinderBufferGeometry. - geometry = geometry.clone(); - } - - mesh.updateMatrixWorld(); - mesh.matrixWorld.decompose(_v1, _q1, _v2); - geometry.scale(_v2.x, _v2.y, _v2.z); - return geometry; -} -/** - * Greatly simplified version of BufferGeometryUtils.mergeBufferGeometries. - * Because we only care about the vertex positions, and not the indices or - * other attributes, we throw everything else away. +/* + * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). + * This devtool is neither made for production nor for readable output files. + * It uses "eval()" calls to create a separate source file in the browser devtools. + * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) + * or disable the default devtool with "devtool: false". + * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/). */ +/******/ (() => { // webpackBootstrap +/******/ var __webpack_modules__ = ({ +/***/ "./index.js": +/*!******************!*\ + !*** ./index.js ***! + \******************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { -function mergeBufferGeometries(geometries) { - let vertexCount = 0; - - for (let i = 0; i < geometries.length; i++) { - const position = geometries[i].attributes.position; - - if (position && position.itemSize === 3) { - vertexCount += position.count; - } - } - - const positionArray = new Float32Array(vertexCount * 3); - let positionOffset = 0; - - for (let i = 0; i < geometries.length; i++) { - const position = geometries[i].attributes.position; - - if (position && position.itemSize === 3) { - for (let j = 0; j < position.count; j++) { - positionArray[positionOffset++] = position.getX(j); - positionArray[positionOffset++] = position.getY(j); - positionArray[positionOffset++] = position.getZ(j); - } - } - } - - return new three.BufferGeometry().setAttribute('position', new three.BufferAttribute(positionArray, 3)); -} - -function getVertices(geometry) { - const position = geometry.attributes.position; - const vertices = new Float32Array(position.count * 3); - - for (let i = 0; i < position.count; i++) { - vertices[i * 3] = position.getX(i); - vertices[i * 3 + 1] = position.getY(i); - vertices[i * 3 + 2] = position.getZ(i); - } +eval("var CANNON = __webpack_require__(/*! cannon-es */ \"./node_modules/cannon-es/dist/cannon-es.js\");\r\n\r\n__webpack_require__(/*! ./src/components/math */ \"./src/components/math/index.js\");\r\n__webpack_require__(/*! ./src/components/body/ammo-body */ \"./src/components/body/ammo-body.js\");\r\n__webpack_require__(/*! ./src/components/body/body */ \"./src/components/body/body.js\");\r\n__webpack_require__(/*! ./src/components/body/dynamic-body */ \"./src/components/body/dynamic-body.js\");\r\n__webpack_require__(/*! ./src/components/body/static-body */ \"./src/components/body/static-body.js\");\r\n__webpack_require__(/*! ./src/components/shape/shape */ \"./src/components/shape/shape.js\");\r\n__webpack_require__(/*! ./src/components/shape/ammo-shape */ \"./src/components/shape/ammo-shape.js\")\r\n__webpack_require__(/*! ./src/components/ammo-constraint */ \"./src/components/ammo-constraint.js\");\r\n__webpack_require__(/*! ./src/components/constraint */ \"./src/components/constraint.js\");\r\n__webpack_require__(/*! ./src/components/spring */ \"./src/components/spring.js\");\r\n__webpack_require__(/*! ./src/system */ \"./src/system.js\");\r\n\r\nmodule.exports = {\r\n registerAll: function () {\r\n console.warn('registerAll() is deprecated. Components are automatically registered.');\r\n }\r\n};\r\n\r\n// Export CANNON.js.\r\nwindow.CANNON = window.CANNON || CANNON;\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./index.js?"); - return vertices; -} -/** -* Returns a flat array of THREE.Mesh instances from the given object. If -* nested transformations are found, they are applied to child meshes -* as mesh.userData.matrix, so that each mesh has its position/rotation/scale -* independently of all of its parents except the top-level object. -*/ +/***/ }), -function getMeshes(object) { - const meshes = []; - object.traverse(function (o) { - if (o.isMesh) { - meshes.push(o); - } - }); - return meshes; -} +/***/ "./lib/CANNON-shape2mesh.js": +/*!**********************************!*\ + !*** ./lib/CANNON-shape2mesh.js ***! + \**********************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { -function getComponent(v, component) { - switch (component) { - case 'x': - return v.x; +eval("/**\r\n * CANNON.shape2mesh\r\n *\r\n * Source: http://schteppe.github.io/cannon.js/build/cannon.demo.js\r\n * Author: @schteppe\r\n */\r\nvar CANNON = __webpack_require__(/*! cannon-es */ \"./node_modules/cannon-es/dist/cannon-es.js\");\r\n\r\nCANNON.shape2mesh = function(body){\r\n var obj = new THREE.Object3D();\r\n\r\n function createBufferGeometry(positions, faces) {\r\n\r\n var geometry = new THREE.BufferGeometry();\r\n geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );\r\n geometry.setIndex(faces);\r\n geometry.computeBoundingSphere();\r\n return geometry;\r\n }\r\n\r\n for (var l = 0; l < body.shapes.length; l++) {\r\n var shape = body.shapes[l];\r\n\r\n var mesh;\r\n\r\n switch(shape.type){\r\n\r\n case CANNON.Shape.types.SPHERE:\r\n var sphere_geometry = new THREE.SphereGeometry( shape.radius, 8, 8);\r\n mesh = new THREE.Mesh( sphere_geometry, this.currentMaterial );\r\n break;\r\n\r\n case CANNON.Shape.types.PARTICLE:\r\n mesh = new THREE.Mesh( this.particleGeo, this.particleMaterial );\r\n var s = this.settings;\r\n mesh.scale.set(s.particleSize,s.particleSize,s.particleSize);\r\n break;\r\n\r\n case CANNON.Shape.types.PLANE:\r\n var geometry = new THREE.PlaneGeometry(10, 10, 4, 4);\r\n mesh = new THREE.Object3D();\r\n var submesh = new THREE.Object3D();\r\n var ground = new THREE.Mesh( geometry, this.currentMaterial );\r\n ground.scale.set(100, 100, 100);\r\n submesh.add(ground);\r\n\r\n ground.castShadow = true;\r\n ground.receiveShadow = true;\r\n\r\n mesh.add(submesh);\r\n break;\r\n\r\n case CANNON.Shape.types.BOX:\r\n var box_geometry = new THREE.BoxGeometry( shape.halfExtents.x*2,\r\n shape.halfExtents.y*2,\r\n shape.halfExtents.z*2 );\r\n mesh = new THREE.Mesh( box_geometry, this.currentMaterial );\r\n break;\r\n\r\n case CANNON.Shape.types.CONVEXPOLYHEDRON:\r\n \r\n // Add vertices\r\n var positions = []\r\n for (var i = 0; i < shape.vertices.length; i++) {\r\n var v = shape.vertices[i];\r\n positions.push(v.x, v.y, v.z);\r\n }\r\n\r\n var faces = []\r\n for(var i=0; i < shape.faces.length; i++){\r\n var face = shape.faces[i];\r\n\r\n // add triangles\r\n var a = face[0];\r\n for (var j = 1; j < face.length - 1; j++) {\r\n var b = face[j];\r\n var c = face[j + 1];\r\n faces.push(a, b, c);\r\n }\r\n }\r\n\r\n var geo = createBufferGeometry(positions, faces);\r\n mesh = new THREE.Mesh( geo, this.currentMaterial );\r\n break;\r\n\r\n case CANNON.Shape.types.HEIGHTFIELD:\r\n\r\n var v0 = new CANNON.Vec3();\r\n var v1 = new CANNON.Vec3();\r\n var v2 = new CANNON.Vec3();\r\n var positions = [];\r\n var faces = [];\r\n for (var xi = 0; xi < shape.data.length - 1; xi++) {\r\n for (var yi = 0; yi < shape.data[xi].length - 1; yi++) {\r\n for (var k = 0; k < 2; k++) {\r\n shape.getConvexTrianglePillar(xi, yi, k===0);\r\n v0.copy(shape.pillarConvex.vertices[0]);\r\n v1.copy(shape.pillarConvex.vertices[1]);\r\n v2.copy(shape.pillarConvex.vertices[2]);\r\n v0.vadd(shape.pillarOffset, v0);\r\n v1.vadd(shape.pillarOffset, v1);\r\n v2.vadd(shape.pillarOffset, v2);\r\n positions.push(\r\n v0.x, v0.y, v0.z,\r\n v1.x, v1.y, v1.z,\r\n v2.x, v2.y, v2.z\r\n );\r\n var i = positions.length / 3 - 3;\r\n faces.push(i, i+1, i+2);\r\n }\r\n }\r\n }\r\n var geometry = createBufferGeometry(positions, faces);\r\n mesh = new THREE.Mesh(geometry, this.currentMaterial);\r\n break;\r\n\r\n case CANNON.Shape.types.TRIMESH:\r\n var geometry = new THREE.BufferGeometry();\r\n\r\n var v0 = new CANNON.Vec3();\r\n var v1 = new CANNON.Vec3();\r\n var v2 = new CANNON.Vec3();\r\n var positions = [];\r\n var faces = [];\r\n for (var i = 0; i < shape.indices.length / 3; i++) {\r\n shape.getTriangleVertices(i, v0, v1, v2);\r\n positions.push(\r\n v0.x, v0.y, v0.z,\r\n v1.x, v1.y, v1.z,\r\n v2.x, v2.y, v2.z\r\n );\r\n var j = positions.length / 3 - 3;\r\n faces.push(j, j+1, j+2);\r\n }\r\n var geometry = createBufferGeometry(positions, faces);\r\n mesh = new THREE.Mesh(geometry, this.currentMaterial);\r\n break;\r\n\r\n default:\r\n throw \"Visual type not recognized: \"+shape.type;\r\n }\r\n\r\n mesh.receiveShadow = true;\r\n mesh.castShadow = true;\r\n if(mesh.children){\r\n for(var i=0; i { - throw new Error("Unexpected component " + component); -} -/** -* Modified version of BufferGeometryUtils.mergeVertices, ignoring vertex -* attributes other than position. -* -* @param {THREE.BufferGeometry} geometry -* @param {number} tolerance -* @return {THREE.BufferGeometry>} -*/ +eval("AFRAME.registerComponent('stats-panel', {\r\n schema: {\r\n merge: {type: 'boolean', default: true}\r\n },\r\n\r\n init() {\r\n\r\n const container = document.querySelector('.rs-container')\r\n\r\n if (container && this.data.merge) {\r\n //stats panel exists, just merge into it.\r\n this.container = container\r\n return;\r\n }\r\n\r\n // if stats panel doesn't exist, add one to support our custom stats.\r\n this.base = document.createElement('div')\r\n this.base.classList.add('rs-base')\r\n const body = document.body || document.getElementsByTagName('body')[0]\r\n\r\n if (container && !this.data.merge) {\r\n this.base.style.top = \"auto\"\r\n this.base.style.bottom = \"20px\"\r\n }\r\n\r\n body.appendChild(this.base)\r\n\r\n this.container = document.createElement('div')\r\n this.container.classList.add('rs-container')\r\n this.base.appendChild(this.container)\r\n }\r\n});\r\n\r\nAFRAME.registerComponent('stats-group', {\r\n multiple: true,\r\n schema: {\r\n label: {type: 'string'}\r\n },\r\n\r\n init() {\r\n\r\n let container\r\n const baseComponent = this.el.components['stats-panel']\r\n if (baseComponent) {\r\n container = baseComponent.container\r\n }\r\n else {\r\n container = document.querySelector('.rs-container')\r\n }\r\n\r\n if (!container) {\r\n console.warn(`Couldn't find stats container to add stats to.\r\n Add either stats or stats-panel component to a-scene`)\r\n return;\r\n }\r\n \r\n this.groupHeader = document.createElement('h1')\r\n this.groupHeader.innerHTML = this.data.label\r\n container.appendChild(this.groupHeader)\r\n\r\n this.group = document.createElement('div')\r\n this.group.classList.add('rs-group')\r\n // rs-group hs style flex-direction of 'column-reverse'\r\n // No idea why it's like that, but it's not what we want for our stats.\r\n // We prefer them rendered in the order speified.\r\n // So override this style.\r\n this.group.style.flexDirection = 'column'\r\n this.group.style.webKitFlexDirection = 'column'\r\n container.appendChild(this.group)\r\n }\r\n});\r\n\r\nAFRAME.registerComponent('stats-row', {\r\n multiple: true,\r\n schema: {\r\n // name of the group to add the stats row to.\r\n group: {type: 'string'},\r\n\r\n // name of an event to listen for\r\n event: {type: 'string'},\r\n\r\n // property from event to output in stats panel\r\n properties: {type: 'array'},\r\n\r\n // label for the row in the stats panel\r\n label: {type: 'string'}\r\n },\r\n\r\n init () {\r\n\r\n const groupComponentName = \"stats-group__\" + this.data.group\r\n const groupComponent = this.el.components[groupComponentName] ||\r\n this.el.sceneEl.components[groupComponentName] ||\r\n this.el.components[\"stats-group\"] ||\r\n this.el.sceneEl.components[\"stats-group\"]\r\n\r\n if (!groupComponent) {\r\n console.warn(`Couldn't find stats group ${groupComponentName}`)\r\n return;\r\n }\r\n \r\n this.counter = document.createElement('div')\r\n this.counter.classList.add('rs-counter-base')\r\n groupComponent.group.appendChild(this.counter)\r\n\r\n this.counterId = document.createElement('div')\r\n this.counterId.classList.add('rs-counter-id')\r\n this.counterId.innerHTML = this.data.label\r\n this.counter.appendChild(this.counterId)\r\n\r\n this.counterValues = {}\r\n this.data.properties.forEach((property) => {\r\n const counterValue = document.createElement('div')\r\n counterValue.classList.add('rs-counter-value')\r\n counterValue.innerHTML = \"...\"\r\n this.counter.appendChild(counterValue)\r\n this.counterValues[property] = counterValue\r\n })\r\n\r\n this.updateData = this.updateData.bind(this)\r\n this.el.addEventListener(this.data.event, this.updateData)\r\n\r\n this.splitCache = {}\r\n },\r\n\r\n updateData(e) {\r\n \r\n this.data.properties.forEach((property) => {\r\n const split = this.splitDot(property);\r\n let value = e.detail;\r\n for (i = 0; i < split.length; i++) {\r\n value = value[split[i]];\r\n }\r\n this.counterValues[property].innerHTML = value\r\n })\r\n },\r\n\r\n splitDot (path) {\r\n if (path in this.splitCache) { return this.splitCache[path]; }\r\n this.splitCache[path] = path.split('.');\r\n return this.splitCache[path];\r\n }\r\n\r\n});\r\n\r\nAFRAME.registerComponent('stats-collector', {\r\n multiple: true,\r\n\r\n schema: {\r\n // name of an event to listen for\r\n inEvent: {type: 'string'},\r\n\r\n // property from event to output in stats panel\r\n properties: {type: 'array'},\r\n\r\n // frequency of output in terms of events received.\r\n outputFrequency: {type: 'number', default: 100},\r\n\r\n // name of event to emit\r\n outEvent: {type: 'string'},\r\n \r\n // outputs (generated for each property)\r\n // Combination of: mean, max, percentile__XX.X (where XX.X is a number)\r\n outputs: {type: 'array'},\r\n\r\n // Whether to output to console as well as generating events\r\n // If a string is specified, this is output to console, together with the event data\r\n // If no string is specified, nothing is output to console.\r\n outputToConsole: {type: 'string'}\r\n },\r\n\r\n init() {\r\n \r\n this.statsData = {}\r\n this.resetData()\r\n this.outputDetail = {}\r\n this.data.properties.forEach((property) => {\r\n this.outputDetail[property] = {}\r\n })\r\n\r\n this.statsReceived = this.statsReceived.bind(this)\r\n this.el.addEventListener(this.data.inEvent, this.statsReceived)\r\n },\r\n \r\n resetData() {\r\n\r\n this.counter = 0\r\n this.data.properties.forEach((property) => {\r\n \r\n // For calculating percentiles like 0.01 and 99.9% we'll want to store\r\n // additional data - something like this...\r\n // Store off outliers, and discard data.\r\n // const min = Math.min(...this.statsData[property])\r\n // this.lowOutliers[property].push(min)\r\n // const max = Math.max(...this.statsData[property])\r\n // this.highOutliers[property].push(max)\r\n\r\n this.statsData[property] = []\r\n })\r\n },\r\n\r\n statsReceived(e) {\r\n\r\n this.updateData(e.detail)\r\n\r\n this.counter++ \r\n if (this.counter === this.data.outputFrequency) {\r\n this.outputData()\r\n this.resetData()\r\n }\r\n },\r\n\r\n updateData(detail) {\r\n\r\n this.data.properties.forEach((property) => {\r\n let value = detail;\r\n value = value[property];\r\n this.statsData[property].push(value)\r\n })\r\n },\r\n\r\n outputData() {\r\n this.data.properties.forEach((property) => {\r\n this.data.outputs.forEach((output) => {\r\n this.outputDetail[property][output] = this.computeOutput(output, this.statsData[property])\r\n })\r\n })\r\n\r\n if (this.data.outEvent) {\r\n this.el.emit(this.data.outEvent, this.outputDetail)\r\n }\r\n\r\n if (this.data.outputToConsole) {\r\n console.log(this.data.outputToConsole, this.outputDetail)\r\n }\r\n },\r\n\r\n computeOutput(outputInstruction, data) {\r\n\r\n const outputInstructions = outputInstruction.split(\"__\")\r\n const outputType = outputInstructions[0]\r\n let output\r\n\r\n switch (outputType) {\r\n case \"mean\":\r\n output = data.reduce((a, b) => a + b, 0) / data.length;\r\n break;\r\n \r\n case \"max\":\r\n output = Math.max(...data)\r\n break;\r\n\r\n case \"min\":\r\n output = Math.min(...data)\r\n break;\r\n\r\n case \"percentile\":\r\n const sorted = data.sort((a, b) => a - b)\r\n // decimal percentiles encoded like 99+9 rather than 99.9 due to \".\" being used as a \r\n // separator for nested properties.\r\n const percentileString = outputInstructions[1].replace(\"_\", \".\")\r\n const proportion = +percentileString / 100\r\n\r\n // Note that this calculation of the percentile is inaccurate when there is insufficient data\r\n // e.g. for 0.1th or 99.9th percentile when only 100 data points.\r\n // Greater accuracy would require storing off more data (specifically outliers) and folding these\r\n // into the computation.\r\n const position = (data.length - 1) * proportion\r\n const base = Math.floor(position)\r\n const delta = position - base;\r\n if (sorted[base + 1] !== undefined) {\r\n output = sorted[base] + delta * (sorted[base + 1] - sorted[base]);\r\n } else {\r\n output = sorted[base];\r\n }\r\n break;\r\n }\r\n return output.toFixed(2)\r\n }\r\n});\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./node_modules/aframe-stats-panel/index.js?"); -function simplifyGeometry(geometry, tolerance = 1e-4) { - tolerance = Math.max(tolerance, Number.EPSILON); // Generate an index buffer if the geometry doesn't have one, or optimize it - // if it's already available. +/***/ }), - const hashToIndex = {}; - const indices = geometry.getIndex(); - const positions = geometry.getAttribute('position'); - const vertexCount = indices ? indices.count : positions.count; // Next value for triangle indices. +/***/ "./node_modules/ammo-debug-drawer/AmmoDebugDrawer.js": +/*!***********************************************************!*\ + !*** ./node_modules/ammo-debug-drawer/AmmoDebugDrawer.js ***! + \***********************************************************/ +/***/ (() => { - let nextIndex = 0; - const newIndices = []; - const newPositions = []; // Convert the error tolerance to an amount of decimal places to truncate to. +eval("/* global Ammo,THREE */\n\nTHREE.AmmoDebugConstants = {\n NoDebug: 0,\n DrawWireframe: 1,\n DrawAabb: 2,\n DrawFeaturesText: 4,\n DrawContactPoints: 8,\n NoDeactivation: 16,\n NoHelpText: 32,\n DrawText: 64,\n ProfileTimings: 128,\n EnableSatComparison: 256,\n DisableBulletLCP: 512,\n EnableCCD: 1024,\n DrawConstraints: 1 << 11, //2048\n DrawConstraintLimits: 1 << 12, //4096\n FastWireframe: 1 << 13, //8192\n DrawNormals: 1 << 14, //16384\n DrawOnTop: 1 << 15, //32768\n MAX_DEBUG_DRAW_MODE: 0xffffffff\n};\n\n/**\n * An implementation of the btIDebugDraw interface in Ammo.js, for debug rendering of Ammo shapes\n * @class AmmoDebugDrawer\n * @param {THREE.Scene} scene\n * @param {Ammo.btCollisionWorld} world\n * @param {object} [options]\n */\nTHREE.AmmoDebugDrawer = function(scene, world, options) {\n this.scene = scene;\n this.world = world;\n options = options || {};\n\n this.debugDrawMode = options.debugDrawMode || THREE.AmmoDebugConstants.DrawWireframe;\n var drawOnTop = this.debugDrawMode & THREE.AmmoDebugConstants.DrawOnTop || false;\n var maxBufferSize = options.maxBufferSize || 1000000;\n\n this.geometry = new THREE.BufferGeometry();\n var vertices = new Float32Array(maxBufferSize * 3);\n var colors = new Float32Array(maxBufferSize * 3);\n\n this.geometry.addAttribute(\"position\", new THREE.BufferAttribute(vertices, 3).setDynamic(true));\n this.geometry.addAttribute(\"color\", new THREE.BufferAttribute(colors, 3).setDynamic(true));\n\n this.index = 0;\n\n var material = new THREE.LineBasicMaterial({\n vertexColors: THREE.VertexColors,\n depthTest: !drawOnTop\n });\n\n this.mesh = new THREE.LineSegments(this.geometry, material);\n if (drawOnTop) this.mesh.renderOrder = 999;\n this.mesh.frustumCulled = false;\n\n this.enabled = false;\n\n this.debugDrawer = new Ammo.DebugDrawer();\n this.debugDrawer.drawLine = this.drawLine.bind(this);\n this.debugDrawer.drawContactPoint = this.drawContactPoint.bind(this);\n this.debugDrawer.reportErrorWarning = this.reportErrorWarning.bind(this);\n this.debugDrawer.draw3dText = this.draw3dText.bind(this);\n this.debugDrawer.setDebugMode = this.setDebugMode.bind(this);\n this.debugDrawer.getDebugMode = this.getDebugMode.bind(this);\n this.debugDrawer.enable = this.enable.bind(this);\n this.debugDrawer.disable = this.disable.bind(this);\n this.debugDrawer.update = this.update.bind(this);\n\n this.world.setDebugDrawer(this.debugDrawer);\n};\n\nTHREE.AmmoDebugDrawer.prototype = function() {\n return this.debugDrawer;\n};\n\nTHREE.AmmoDebugDrawer.prototype.enable = function() {\n this.enabled = true;\n this.scene.add(this.mesh);\n};\n\nTHREE.AmmoDebugDrawer.prototype.disable = function() {\n this.enabled = false;\n this.scene.remove(this.mesh);\n};\n\nTHREE.AmmoDebugDrawer.prototype.update = function() {\n if (!this.enabled) {\n return;\n }\n\n if (this.index != 0) {\n this.geometry.attributes.position.needsUpdate = true;\n this.geometry.attributes.color.needsUpdate = true;\n }\n\n this.index = 0;\n\n this.world.debugDrawWorld();\n\n this.geometry.setDrawRange(0, this.index);\n};\n\nTHREE.AmmoDebugDrawer.prototype.drawLine = function(from, to, color) {\n const heap = Ammo.HEAPF32;\n const r = heap[(color + 0) / 4];\n const g = heap[(color + 4) / 4];\n const b = heap[(color + 8) / 4];\n\n const fromX = heap[(from + 0) / 4];\n const fromY = heap[(from + 4) / 4];\n const fromZ = heap[(from + 8) / 4];\n this.geometry.attributes.position.setXYZ(this.index, fromX, fromY, fromZ);\n this.geometry.attributes.color.setXYZ(this.index++, r, g, b);\n\n const toX = heap[(to + 0) / 4];\n const toY = heap[(to + 4) / 4];\n const toZ = heap[(to + 8) / 4];\n this.geometry.attributes.position.setXYZ(this.index, toX, toY, toZ);\n this.geometry.attributes.color.setXYZ(this.index++, r, g, b);\n};\n\n//TODO: figure out how to make lifeTime work\nTHREE.AmmoDebugDrawer.prototype.drawContactPoint = function(pointOnB, normalOnB, distance, lifeTime, color) {\n const heap = Ammo.HEAPF32;\n const r = heap[(color + 0) / 4];\n const g = heap[(color + 4) / 4];\n const b = heap[(color + 8) / 4];\n\n const x = heap[(pointOnB + 0) / 4];\n const y = heap[(pointOnB + 4) / 4];\n const z = heap[(pointOnB + 8) / 4];\n this.geometry.attributes.position.setXYZ(this.index, x, y, z);\n this.geometry.attributes.color.setXYZ(this.index++, r, g, b);\n\n const dx = heap[(normalOnB + 0) / 4] * distance;\n const dy = heap[(normalOnB + 4) / 4] * distance;\n const dz = heap[(normalOnB + 8) / 4] * distance;\n this.geometry.attributes.position.setXYZ(this.index, x + dx, y + dy, z + dz);\n this.geometry.attributes.color.setXYZ(this.index++, r, g, b);\n};\n\nTHREE.AmmoDebugDrawer.prototype.reportErrorWarning = function(warningString) {\n if (Ammo.hasOwnProperty(\"Pointer_stringify\")) {\n console.warn(Ammo.Pointer_stringify(warningString));\n } else if (!this.warnedOnce) {\n this.warnedOnce = true;\n console.warn(\"Cannot print warningString, please rebuild Ammo.js using 'debug' flag\");\n }\n};\n\nTHREE.AmmoDebugDrawer.prototype.draw3dText = function(location, textString) {\n //TODO\n console.warn(\"TODO: draw3dText\");\n};\n\nTHREE.AmmoDebugDrawer.prototype.setDebugMode = function(debugMode) {\n this.debugDrawMode = debugMode;\n};\n\nTHREE.AmmoDebugDrawer.prototype.getDebugMode = function() {\n return this.debugDrawMode;\n};\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./node_modules/ammo-debug-drawer/AmmoDebugDrawer.js?"); - const decimalShift = Math.log10(1 / tolerance); - const shiftMultiplier = Math.pow(10, decimalShift); +/***/ }), - for (let i = 0; i < vertexCount; i++) { - const index = indices ? indices.getX(i) : i; // Generate a hash for the vertex attributes at the current index 'i'. +/***/ "./node_modules/cannon-es/dist/cannon-es.js": +/*!**************************************************!*\ + !*** ./node_modules/cannon-es/dist/cannon-es.js ***! + \**************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - let hash = ''; // Double tilde truncates the decimal value. - - hash += ~~(positions.getX(index) * shiftMultiplier) + ","; - hash += ~~(positions.getY(index) * shiftMultiplier) + ","; - hash += ~~(positions.getZ(index) * shiftMultiplier) + ","; // Add another reference to the vertex if it's already - // used by another index. - - if (hash in hashToIndex) { - newIndices.push(hashToIndex[hash]); - } else { - newPositions.push(positions.getX(index)); - newPositions.push(positions.getY(index)); - newPositions.push(positions.getZ(index)); - hashToIndex[hash] = nextIndex; - newIndices.push(nextIndex); - nextIndex++; - } - } // Construct merged BufferGeometry. - - - const positionAttribute = new three.BufferAttribute(new Float32Array(newPositions), positions.itemSize, positions.normalized); - const result = new three.BufferGeometry(); - result.setAttribute('position', positionAttribute); - result.setIndex(newIndices); - return result; -} - -const PI_2 = Math.PI / 2; -exports.ShapeType = void 0; - -(function (ShapeType) { - ShapeType["BOX"] = "Box"; - ShapeType["CYLINDER"] = "Cylinder"; - ShapeType["SPHERE"] = "Sphere"; - ShapeType["HULL"] = "ConvexPolyhedron"; - ShapeType["MESH"] = "Trimesh"; -})(exports.ShapeType || (exports.ShapeType = {})); -/** - * Given a THREE.Object3D instance, creates parameters for a CANNON shape. - */ - - -const getShapeParameters = function (object, options = {}) { - let geometry; - - if (options.type === exports.ShapeType.BOX) { - return getBoundingBoxParameters(object); - } else if (options.type === exports.ShapeType.CYLINDER) { - return getBoundingCylinderParameters(object, options); - } else if (options.type === exports.ShapeType.SPHERE) { - return getBoundingSphereParameters(object, options); - } else if (options.type === exports.ShapeType.HULL) { - return getConvexPolyhedronParameters(object); - } else if (options.type === exports.ShapeType.MESH) { - geometry = getGeometry(object); - return geometry ? getTrimeshParameters(geometry) : null; - } else if (options.type) { - throw new Error("[CANNON.getShapeParameters] Invalid type \"" + options.type + "\"."); - } +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"AABB\": () => (/* binding */ AABB),\n/* harmony export */ \"ArrayCollisionMatrix\": () => (/* binding */ ArrayCollisionMatrix),\n/* harmony export */ \"BODY_SLEEP_STATES\": () => (/* binding */ BODY_SLEEP_STATES),\n/* harmony export */ \"BODY_TYPES\": () => (/* binding */ BODY_TYPES),\n/* harmony export */ \"Body\": () => (/* binding */ Body),\n/* harmony export */ \"Box\": () => (/* binding */ Box),\n/* harmony export */ \"Broadphase\": () => (/* binding */ Broadphase),\n/* harmony export */ \"COLLISION_TYPES\": () => (/* binding */ COLLISION_TYPES),\n/* harmony export */ \"ConeTwistConstraint\": () => (/* binding */ ConeTwistConstraint),\n/* harmony export */ \"Constraint\": () => (/* binding */ Constraint),\n/* harmony export */ \"ContactEquation\": () => (/* binding */ ContactEquation),\n/* harmony export */ \"ContactMaterial\": () => (/* binding */ ContactMaterial),\n/* harmony export */ \"ConvexPolyhedron\": () => (/* binding */ ConvexPolyhedron),\n/* harmony export */ \"Cylinder\": () => (/* binding */ Cylinder),\n/* harmony export */ \"DistanceConstraint\": () => (/* binding */ DistanceConstraint),\n/* harmony export */ \"Equation\": () => (/* binding */ Equation),\n/* harmony export */ \"EventTarget\": () => (/* binding */ EventTarget),\n/* harmony export */ \"FrictionEquation\": () => (/* binding */ FrictionEquation),\n/* harmony export */ \"GSSolver\": () => (/* binding */ GSSolver),\n/* harmony export */ \"GridBroadphase\": () => (/* binding */ GridBroadphase),\n/* harmony export */ \"Heightfield\": () => (/* binding */ Heightfield),\n/* harmony export */ \"HingeConstraint\": () => (/* binding */ HingeConstraint),\n/* harmony export */ \"JacobianElement\": () => (/* binding */ JacobianElement),\n/* harmony export */ \"LockConstraint\": () => (/* binding */ LockConstraint),\n/* harmony export */ \"Mat3\": () => (/* binding */ Mat3),\n/* harmony export */ \"Material\": () => (/* binding */ Material),\n/* harmony export */ \"NaiveBroadphase\": () => (/* binding */ NaiveBroadphase),\n/* harmony export */ \"Narrowphase\": () => (/* binding */ Narrowphase),\n/* harmony export */ \"ObjectCollisionMatrix\": () => (/* binding */ ObjectCollisionMatrix),\n/* harmony export */ \"Particle\": () => (/* binding */ Particle),\n/* harmony export */ \"Plane\": () => (/* binding */ Plane),\n/* harmony export */ \"PointToPointConstraint\": () => (/* binding */ PointToPointConstraint),\n/* harmony export */ \"Pool\": () => (/* binding */ Pool),\n/* harmony export */ \"Quaternion\": () => (/* binding */ Quaternion),\n/* harmony export */ \"RAY_MODES\": () => (/* binding */ RAY_MODES),\n/* harmony export */ \"Ray\": () => (/* binding */ Ray),\n/* harmony export */ \"RaycastResult\": () => (/* binding */ RaycastResult),\n/* harmony export */ \"RaycastVehicle\": () => (/* binding */ RaycastVehicle),\n/* harmony export */ \"RigidVehicle\": () => (/* binding */ RigidVehicle),\n/* harmony export */ \"RotationalEquation\": () => (/* binding */ RotationalEquation),\n/* harmony export */ \"RotationalMotorEquation\": () => (/* binding */ RotationalMotorEquation),\n/* harmony export */ \"SAPBroadphase\": () => (/* binding */ SAPBroadphase),\n/* harmony export */ \"SHAPE_TYPES\": () => (/* binding */ SHAPE_TYPES),\n/* harmony export */ \"SPHSystem\": () => (/* binding */ SPHSystem),\n/* harmony export */ \"Shape\": () => (/* binding */ Shape),\n/* harmony export */ \"Solver\": () => (/* binding */ Solver),\n/* harmony export */ \"Sphere\": () => (/* binding */ Sphere),\n/* harmony export */ \"SplitSolver\": () => (/* binding */ SplitSolver),\n/* harmony export */ \"Spring\": () => (/* binding */ Spring),\n/* harmony export */ \"Transform\": () => (/* binding */ Transform),\n/* harmony export */ \"Trimesh\": () => (/* binding */ Trimesh),\n/* harmony export */ \"Vec3\": () => (/* binding */ Vec3),\n/* harmony export */ \"Vec3Pool\": () => (/* binding */ Vec3Pool),\n/* harmony export */ \"World\": () => (/* binding */ World)\n/* harmony export */ });\n/**\r\n * Records what objects are colliding with each other\r\n * @class ObjectCollisionMatrix\r\n * @constructor\r\n */\nclass ObjectCollisionMatrix {\n // The matrix storage.\n constructor() {\n this.matrix = {};\n }\n /**\r\n * @method get\r\n * @param {Body} i\r\n * @param {Body} j\r\n * @return {boolean}\r\n */\n\n\n get(bi, bj) {\n let {\n id: i\n } = bi;\n let {\n id: j\n } = bj;\n\n if (j > i) {\n const temp = j;\n j = i;\n i = temp;\n }\n\n return i + \"-\" + j in this.matrix;\n }\n /**\r\n * @method set\r\n * @param {Body} i\r\n * @param {Body} j\r\n * @param {boolean} value\r\n */\n\n\n set(bi, bj, value) {\n let {\n id: i\n } = bi;\n let {\n id: j\n } = bj;\n\n if (j > i) {\n const temp = j;\n j = i;\n i = temp;\n }\n\n if (value) {\n this.matrix[i + \"-\" + j] = true;\n } else {\n delete this.matrix[i + \"-\" + j];\n }\n }\n /**\r\n * Empty the matrix\r\n * @method reset\r\n */\n\n\n reset() {\n this.matrix = {};\n }\n /**\r\n * Set max number of objects\r\n * @method setNumObjects\r\n * @param {Number} n\r\n */\n\n\n setNumObjects(n) {}\n\n}\n\n/**\r\n * A 3x3 matrix.\r\n * @class Mat3\r\n * @constructor\r\n * @param {Array} elements A vector of length 9, containing all matrix elements. Optional.\r\n * @author schteppe / http://github.com/schteppe\r\n */\nclass Mat3 {\n constructor(elements = [0, 0, 0, 0, 0, 0, 0, 0, 0]) {\n this.elements = elements;\n }\n /**\r\n * Sets the matrix to identity\r\n * @method identity\r\n * @todo Should perhaps be renamed to setIdentity() to be more clear.\r\n * @todo Create another function that immediately creates an identity matrix eg. eye()\r\n */\n\n\n identity() {\n const e = this.elements;\n e[0] = 1;\n e[1] = 0;\n e[2] = 0;\n e[3] = 0;\n e[4] = 1;\n e[5] = 0;\n e[6] = 0;\n e[7] = 0;\n e[8] = 1;\n }\n /**\r\n * Set all elements to zero\r\n * @method setZero\r\n */\n\n\n setZero() {\n const e = this.elements;\n e[0] = 0;\n e[1] = 0;\n e[2] = 0;\n e[3] = 0;\n e[4] = 0;\n e[5] = 0;\n e[6] = 0;\n e[7] = 0;\n e[8] = 0;\n }\n /**\r\n * Sets the matrix diagonal elements from a Vec3\r\n * @method setTrace\r\n * @param {Vec3} vec3\r\n */\n\n\n setTrace(vector) {\n const e = this.elements;\n e[0] = vector.x;\n e[4] = vector.y;\n e[8] = vector.z;\n }\n /**\r\n * Gets the matrix diagonal elements\r\n * @method getTrace\r\n * @return {Vec3}\r\n */\n\n\n getTrace(target = new Vec3()) {\n const e = this.elements;\n target.x = e[0];\n target.y = e[4];\n target.z = e[8];\n }\n /**\r\n * Matrix-Vector multiplication\r\n * @method vmult\r\n * @param {Vec3} v The vector to multiply with\r\n * @param {Vec3} target Optional, target to save the result in.\r\n */\n\n\n vmult(v, target = new Vec3()) {\n const e = this.elements;\n const x = v.x;\n const y = v.y;\n const z = v.z;\n target.x = e[0] * x + e[1] * y + e[2] * z;\n target.y = e[3] * x + e[4] * y + e[5] * z;\n target.z = e[6] * x + e[7] * y + e[8] * z;\n return target;\n }\n /**\r\n * Matrix-scalar multiplication\r\n * @method smult\r\n * @param {Number} s\r\n */\n\n\n smult(s) {\n for (let i = 0; i < this.elements.length; i++) {\n this.elements[i] *= s;\n }\n }\n /**\r\n * Matrix multiplication\r\n * @method mmult\r\n * @param {Mat3} matrix Matrix to multiply with from left side.\r\n * @return {Mat3} The result.\r\n */\n\n\n mmult(matrix, target = new Mat3()) {\n const {\n elements\n } = matrix;\n\n for (let i = 0; i < 3; i++) {\n for (let j = 0; j < 3; j++) {\n let sum = 0.0;\n\n for (let k = 0; k < 3; k++) {\n sum += elements[i + k * 3] * this.elements[k + j * 3];\n }\n\n target.elements[i + j * 3] = sum;\n }\n }\n\n return target;\n }\n /**\r\n * Scale each column of the matrix\r\n * @method scale\r\n * @param {Vec3} v\r\n * @return {Mat3} The result.\r\n */\n\n\n scale(vector, target = new Mat3()) {\n const e = this.elements;\n const t = target.elements;\n\n for (let i = 0; i !== 3; i++) {\n t[3 * i + 0] = vector.x * e[3 * i + 0];\n t[3 * i + 1] = vector.y * e[3 * i + 1];\n t[3 * i + 2] = vector.z * e[3 * i + 2];\n }\n\n return target;\n }\n /**\r\n * Solve Ax=b\r\n * @method solve\r\n * @param {Vec3} b The right hand side\r\n * @param {Vec3} target Optional. Target vector to save in.\r\n * @return {Vec3} The solution x\r\n * @todo should reuse arrays\r\n */\n\n\n solve(b, target = new Vec3()) {\n // Construct equations\n const nr = 3; // num rows\n\n const nc = 4; // num cols\n\n const eqns = [];\n let i;\n let j;\n\n for (i = 0; i < nr * nc; i++) {\n eqns.push(0);\n }\n\n for (i = 0; i < 3; i++) {\n for (j = 0; j < 3; j++) {\n eqns[i + nc * j] = this.elements[i + 3 * j];\n }\n }\n\n eqns[3 + 4 * 0] = b.x;\n eqns[3 + 4 * 1] = b.y;\n eqns[3 + 4 * 2] = b.z; // Compute right upper triangular version of the matrix - Gauss elimination\n\n let n = 3;\n const k = n;\n let np;\n const kp = 4; // num rows\n\n let p;\n\n do {\n i = k - n;\n\n if (eqns[i + nc * i] === 0) {\n // the pivot is null, swap lines\n for (j = i + 1; j < k; j++) {\n if (eqns[i + nc * j] !== 0) {\n np = kp;\n\n do {\n // do ligne( i ) = ligne( i ) + ligne( k )\n p = kp - np;\n eqns[p + nc * i] += eqns[p + nc * j];\n } while (--np);\n\n break;\n }\n }\n }\n\n if (eqns[i + nc * i] !== 0) {\n for (j = i + 1; j < k; j++) {\n const multiplier = eqns[i + nc * j] / eqns[i + nc * i];\n np = kp;\n\n do {\n // do ligne( k ) = ligne( k ) - multiplier * ligne( i )\n p = kp - np;\n eqns[p + nc * j] = p <= i ? 0 : eqns[p + nc * j] - eqns[p + nc * i] * multiplier;\n } while (--np);\n }\n }\n } while (--n); // Get the solution\n\n\n target.z = eqns[2 * nc + 3] / eqns[2 * nc + 2];\n target.y = (eqns[1 * nc + 3] - eqns[1 * nc + 2] * target.z) / eqns[1 * nc + 1];\n target.x = (eqns[0 * nc + 3] - eqns[0 * nc + 2] * target.z - eqns[0 * nc + 1] * target.y) / eqns[0 * nc + 0];\n\n if (isNaN(target.x) || isNaN(target.y) || isNaN(target.z) || target.x === Infinity || target.y === Infinity || target.z === Infinity) {\n throw \"Could not solve equation! Got x=[\" + target.toString() + \"], b=[\" + b.toString() + \"], A=[\" + this.toString() + \"]\";\n }\n\n return target;\n }\n /**\r\n * Get an element in the matrix by index. Index starts at 0, not 1!!!\r\n * @method e\r\n * @param {Number} row\r\n * @param {Number} column\r\n * @param {Number} value Optional. If provided, the matrix element will be set to this value.\r\n * @return {Number}\r\n */\n\n\n e(row, column, value) {\n if (value === undefined) {\n return this.elements[column + 3 * row];\n } else {\n // Set value\n this.elements[column + 3 * row] = value;\n }\n }\n /**\r\n * Copy another matrix into this matrix object.\r\n * @method copy\r\n * @param {Mat3} source\r\n * @return {Mat3} this\r\n */\n\n\n copy(matrix) {\n for (let i = 0; i < matrix.elements.length; i++) {\n this.elements[i] = matrix.elements[i];\n }\n\n return this;\n }\n /**\r\n * Returns a string representation of the matrix.\r\n * @method toString\r\n * @return string\r\n */\n\n\n toString() {\n let r = '';\n const sep = ',';\n\n for (let i = 0; i < 9; i++) {\n r += this.elements[i] + sep;\n }\n\n return r;\n }\n /**\r\n * reverse the matrix\r\n * @method reverse\r\n * @param {Mat3} target Optional. Target matrix to save in.\r\n * @return {Mat3} The solution x\r\n */\n\n\n reverse(target = new Mat3()) {\n // Construct equations\n const nr = 3; // num rows\n\n const nc = 6; // num cols\n\n const eqns = [];\n let i;\n let j;\n\n for (i = 0; i < nr * nc; i++) {\n eqns.push(0);\n }\n\n for (i = 0; i < 3; i++) {\n for (j = 0; j < 3; j++) {\n eqns[i + nc * j] = this.elements[i + 3 * j];\n }\n }\n\n eqns[3 + 6 * 0] = 1;\n eqns[3 + 6 * 1] = 0;\n eqns[3 + 6 * 2] = 0;\n eqns[4 + 6 * 0] = 0;\n eqns[4 + 6 * 1] = 1;\n eqns[4 + 6 * 2] = 0;\n eqns[5 + 6 * 0] = 0;\n eqns[5 + 6 * 1] = 0;\n eqns[5 + 6 * 2] = 1; // Compute right upper triangular version of the matrix - Gauss elimination\n\n let n = 3;\n const k = n;\n let np;\n const kp = nc; // num rows\n\n let p;\n\n do {\n i = k - n;\n\n if (eqns[i + nc * i] === 0) {\n // the pivot is null, swap lines\n for (j = i + 1; j < k; j++) {\n if (eqns[i + nc * j] !== 0) {\n np = kp;\n\n do {\n // do line( i ) = line( i ) + line( k )\n p = kp - np;\n eqns[p + nc * i] += eqns[p + nc * j];\n } while (--np);\n\n break;\n }\n }\n }\n\n if (eqns[i + nc * i] !== 0) {\n for (j = i + 1; j < k; j++) {\n const multiplier = eqns[i + nc * j] / eqns[i + nc * i];\n np = kp;\n\n do {\n // do line( k ) = line( k ) - multiplier * line( i )\n p = kp - np;\n eqns[p + nc * j] = p <= i ? 0 : eqns[p + nc * j] - eqns[p + nc * i] * multiplier;\n } while (--np);\n }\n }\n } while (--n); // eliminate the upper left triangle of the matrix\n\n\n i = 2;\n\n do {\n j = i - 1;\n\n do {\n const multiplier = eqns[i + nc * j] / eqns[i + nc * i];\n np = nc;\n\n do {\n p = nc - np;\n eqns[p + nc * j] = eqns[p + nc * j] - eqns[p + nc * i] * multiplier;\n } while (--np);\n } while (j--);\n } while (--i); // operations on the diagonal\n\n\n i = 2;\n\n do {\n const multiplier = 1 / eqns[i + nc * i];\n np = nc;\n\n do {\n p = nc - np;\n eqns[p + nc * i] = eqns[p + nc * i] * multiplier;\n } while (--np);\n } while (i--);\n\n i = 2;\n\n do {\n j = 2;\n\n do {\n p = eqns[nr + j + nc * i];\n\n if (isNaN(p) || p === Infinity) {\n throw \"Could not reverse! A=[\" + this.toString() + \"]\";\n }\n\n target.e(i, j, p);\n } while (j--);\n } while (i--);\n\n return target;\n }\n /**\r\n * Set the matrix from a quaterion\r\n * @method setRotationFromQuaternion\r\n * @param {Quaternion} q\r\n */\n\n\n setRotationFromQuaternion(q) {\n const x = q.x;\n const y = q.y;\n const z = q.z;\n const w = q.w;\n const x2 = x + x;\n const y2 = y + y;\n const z2 = z + z;\n const xx = x * x2;\n const xy = x * y2;\n const xz = x * z2;\n const yy = y * y2;\n const yz = y * z2;\n const zz = z * z2;\n const wx = w * x2;\n const wy = w * y2;\n const wz = w * z2;\n const e = this.elements;\n e[3 * 0 + 0] = 1 - (yy + zz);\n e[3 * 0 + 1] = xy - wz;\n e[3 * 0 + 2] = xz + wy;\n e[3 * 1 + 0] = xy + wz;\n e[3 * 1 + 1] = 1 - (xx + zz);\n e[3 * 1 + 2] = yz - wx;\n e[3 * 2 + 0] = xz - wy;\n e[3 * 2 + 1] = yz + wx;\n e[3 * 2 + 2] = 1 - (xx + yy);\n return this;\n }\n /**\r\n * Transpose the matrix\r\n * @method transpose\r\n * @param {Mat3} target Optional. Where to store the result.\r\n * @return {Mat3} The target Mat3, or a new Mat3 if target was omitted.\r\n */\n\n\n transpose(target = new Mat3()) {\n const Mt = target.elements;\n const M = this.elements;\n\n for (let i = 0; i !== 3; i++) {\n for (let j = 0; j !== 3; j++) {\n Mt[3 * i + j] = M[3 * j + i];\n }\n }\n\n return target;\n }\n\n}\n\n/**\r\n * 3-dimensional vector\r\n * @class Vec3\r\n * @constructor\r\n * @param {Number} x\r\n * @param {Number} y\r\n * @param {Number} z\r\n * @author schteppe\r\n * @example\r\n * const v = new Vec3(1, 2, 3);\r\n * console.log('x=' + v.x); // x=1\r\n */\n\nclass Vec3 {\n constructor(x = 0.0, y = 0.0, z = 0.0) {\n this.x = x;\n this.y = y;\n this.z = z;\n }\n /**\r\n * Vector cross product\r\n * @method cross\r\n * @param {Vec3} v\r\n * @param {Vec3} target Optional. Target to save in.\r\n * @return {Vec3}\r\n */\n\n\n cross(vector, target = new Vec3()) {\n const vx = vector.x;\n const vy = vector.y;\n const vz = vector.z;\n const x = this.x;\n const y = this.y;\n const z = this.z;\n target.x = y * vz - z * vy;\n target.y = z * vx - x * vz;\n target.z = x * vy - y * vx;\n return target;\n }\n /**\r\n * Set the vectors' 3 elements\r\n * @method set\r\n * @param {Number} x\r\n * @param {Number} y\r\n * @param {Number} z\r\n * @return Vec3\r\n */\n\n\n set(x, y, z) {\n this.x = x;\n this.y = y;\n this.z = z;\n return this;\n }\n /**\r\n * Set all components of the vector to zero.\r\n * @method setZero\r\n */\n\n\n setZero() {\n this.x = this.y = this.z = 0;\n }\n /**\r\n * Vector addition\r\n * @method vadd\r\n * @param {Vec3} v\r\n * @param {Vec3} target Optional.\r\n * @return {Vec3}\r\n */\n\n\n vadd(vector, target) {\n if (target) {\n target.x = vector.x + this.x;\n target.y = vector.y + this.y;\n target.z = vector.z + this.z;\n } else {\n return new Vec3(this.x + vector.x, this.y + vector.y, this.z + vector.z);\n }\n }\n /**\r\n * Vector subtraction\r\n * @method vsub\r\n * @param {Vec3} v\r\n * @param {Vec3} target Optional. Target to save in.\r\n * @return {Vec3}\r\n */\n\n\n vsub(vector, target) {\n if (target) {\n target.x = this.x - vector.x;\n target.y = this.y - vector.y;\n target.z = this.z - vector.z;\n } else {\n return new Vec3(this.x - vector.x, this.y - vector.y, this.z - vector.z);\n }\n }\n /**\r\n * Get the cross product matrix a_cross from a vector, such that a x b = a_cross * b = c\r\n * @method crossmat\r\n * @see http://www8.cs.umu.se/kurser/TDBD24/VT06/lectures/Lecture6.pdf\r\n * @return {Mat3}\r\n */\n\n\n crossmat() {\n return new Mat3([0, -this.z, this.y, this.z, 0, -this.x, -this.y, this.x, 0]);\n }\n /**\r\n * Normalize the vector. Note that this changes the values in the vector.\r\n * @method normalize\r\n * @return {Number} Returns the norm of the vector\r\n */\n\n\n normalize() {\n const x = this.x;\n const y = this.y;\n const z = this.z;\n const n = Math.sqrt(x * x + y * y + z * z);\n\n if (n > 0.0) {\n const invN = 1 / n;\n this.x *= invN;\n this.y *= invN;\n this.z *= invN;\n } else {\n // Make something up\n this.x = 0;\n this.y = 0;\n this.z = 0;\n }\n\n return n;\n }\n /**\r\n * Get the version of this vector that is of length 1.\r\n * @method unit\r\n * @param {Vec3} target Optional target to save in\r\n * @return {Vec3} Returns the unit vector\r\n */\n\n\n unit(target = new Vec3()) {\n const x = this.x;\n const y = this.y;\n const z = this.z;\n let ninv = Math.sqrt(x * x + y * y + z * z);\n\n if (ninv > 0.0) {\n ninv = 1.0 / ninv;\n target.x = x * ninv;\n target.y = y * ninv;\n target.z = z * ninv;\n } else {\n target.x = 1;\n target.y = 0;\n target.z = 0;\n }\n\n return target;\n }\n /**\r\n * Get the length of the vector\r\n * @method length\r\n * @return {Number}\r\n */\n\n\n length() {\n const x = this.x;\n const y = this.y;\n const z = this.z;\n return Math.sqrt(x * x + y * y + z * z);\n }\n /**\r\n * Get the squared length of the vector.\r\n * @method lengthSquared\r\n * @return {Number}\r\n */\n\n\n lengthSquared() {\n return this.dot(this);\n }\n /**\r\n * Get distance from this point to another point\r\n * @method distanceTo\r\n * @param {Vec3} p\r\n * @return {Number}\r\n */\n\n\n distanceTo(p) {\n const x = this.x;\n const y = this.y;\n const z = this.z;\n const px = p.x;\n const py = p.y;\n const pz = p.z;\n return Math.sqrt((px - x) * (px - x) + (py - y) * (py - y) + (pz - z) * (pz - z));\n }\n /**\r\n * Get squared distance from this point to another point\r\n * @method distanceSquared\r\n * @param {Vec3} p\r\n * @return {Number}\r\n */\n\n\n distanceSquared(p) {\n const x = this.x;\n const y = this.y;\n const z = this.z;\n const px = p.x;\n const py = p.y;\n const pz = p.z;\n return (px - x) * (px - x) + (py - y) * (py - y) + (pz - z) * (pz - z);\n }\n /**\r\n * Multiply all the components of the vector with a scalar.\r\n * @method scale\r\n * @param {Number} scalar\r\n * @param {Vec3} target The vector to save the result in.\r\n * @return {Vec3}\r\n */\n\n\n scale(scalar, target = new Vec3()) {\n const x = this.x;\n const y = this.y;\n const z = this.z;\n target.x = scalar * x;\n target.y = scalar * y;\n target.z = scalar * z;\n return target;\n }\n /**\r\n * Multiply the vector with an other vector, component-wise.\r\n * @method vmult\r\n * @param {Number} vector\r\n * @param {Vec3} target The vector to save the result in.\r\n * @return {Vec3}\r\n */\n\n\n vmul(vector, target = new Vec3()) {\n target.x = vector.x * this.x;\n target.y = vector.y * this.y;\n target.z = vector.z * this.z;\n return target;\n }\n /**\r\n * Scale a vector and add it to this vector. Save the result in \"target\". (target = this + vector * scalar)\r\n * @method addScaledVector\r\n * @param {Number} scalar\r\n * @param {Vec3} vector\r\n * @param {Vec3} target The vector to save the result in.\r\n * @return {Vec3}\r\n */\n\n\n addScaledVector(scalar, vector, target = new Vec3()) {\n target.x = this.x + scalar * vector.x;\n target.y = this.y + scalar * vector.y;\n target.z = this.z + scalar * vector.z;\n return target;\n }\n /**\r\n * Calculate dot product\r\n * @method dot\r\n * @param {Vec3} v\r\n * @return {Number}\r\n */\n\n\n dot(vector) {\n return this.x * vector.x + this.y * vector.y + this.z * vector.z;\n }\n /**\r\n * @method isZero\r\n * @return bool\r\n */\n\n\n isZero() {\n return this.x === 0 && this.y === 0 && this.z === 0;\n }\n /**\r\n * Make the vector point in the opposite direction.\r\n * @method negate\r\n * @param {Vec3} target Optional target to save in\r\n * @return {Vec3}\r\n */\n\n\n negate(target = new Vec3()) {\n target.x = -this.x;\n target.y = -this.y;\n target.z = -this.z;\n return target;\n }\n /**\r\n * Compute two artificial tangents to the vector\r\n * @method tangents\r\n * @param {Vec3} t1 Vector object to save the first tangent in\r\n * @param {Vec3} t2 Vector object to save the second tangent in\r\n */\n\n\n tangents(t1, t2) {\n const norm = this.length();\n\n if (norm > 0.0) {\n const n = Vec3_tangents_n;\n const inorm = 1 / norm;\n n.set(this.x * inorm, this.y * inorm, this.z * inorm);\n const randVec = Vec3_tangents_randVec;\n\n if (Math.abs(n.x) < 0.9) {\n randVec.set(1, 0, 0);\n n.cross(randVec, t1);\n } else {\n randVec.set(0, 1, 0);\n n.cross(randVec, t1);\n }\n\n n.cross(t1, t2);\n } else {\n // The normal length is zero, make something up\n t1.set(1, 0, 0);\n t2.set(0, 1, 0);\n }\n }\n /**\r\n * Converts to a more readable format\r\n * @method toString\r\n * @return string\r\n */\n\n\n toString() {\n return this.x + \",\" + this.y + \",\" + this.z;\n }\n /**\r\n * Converts to an array\r\n * @method toArray\r\n * @return Array\r\n */\n\n\n toArray() {\n return [this.x, this.y, this.z];\n }\n /**\r\n * Copies value of source to this vector.\r\n * @method copy\r\n * @param {Vec3} source\r\n * @return {Vec3} this\r\n */\n\n\n copy(vector) {\n this.x = vector.x;\n this.y = vector.y;\n this.z = vector.z;\n return this;\n }\n /**\r\n * Do a linear interpolation between two vectors\r\n * @method lerp\r\n * @param {Vec3} v\r\n * @param {Number} t A number between 0 and 1. 0 will make this function return u, and 1 will make it return v. Numbers in between will generate a vector in between them.\r\n * @param {Vec3} target\r\n */\n\n\n lerp(vector, t, target) {\n const x = this.x;\n const y = this.y;\n const z = this.z;\n target.x = x + (vector.x - x) * t;\n target.y = y + (vector.y - y) * t;\n target.z = z + (vector.z - z) * t;\n }\n /**\r\n * Check if a vector equals is almost equal to another one.\r\n * @method almostEquals\r\n * @param {Vec3} v\r\n * @param {Number} precision\r\n * @return bool\r\n */\n\n\n almostEquals(vector, precision = 1e-6) {\n if (Math.abs(this.x - vector.x) > precision || Math.abs(this.y - vector.y) > precision || Math.abs(this.z - vector.z) > precision) {\n return false;\n }\n\n return true;\n }\n /**\r\n * Check if a vector is almost zero\r\n * @method almostZero\r\n * @param {Number} precision\r\n */\n\n\n almostZero(precision = 1e-6) {\n if (Math.abs(this.x) > precision || Math.abs(this.y) > precision || Math.abs(this.z) > precision) {\n return false;\n }\n\n return true;\n }\n /**\r\n * Check if the vector is anti-parallel to another vector.\r\n * @method isAntiparallelTo\r\n * @param {Vec3} v\r\n * @param {Number} precision Set to zero for exact comparisons\r\n * @return {Boolean}\r\n */\n\n\n isAntiparallelTo(vector, precision) {\n this.negate(antip_neg);\n return antip_neg.almostEquals(vector, precision);\n }\n /**\r\n * Clone the vector\r\n * @method clone\r\n * @return {Vec3}\r\n */\n\n\n clone() {\n return new Vec3(this.x, this.y, this.z);\n }\n\n}\nVec3.ZERO = new Vec3(0, 0, 0);\nVec3.UNIT_X = new Vec3(1, 0, 0);\nVec3.UNIT_Y = new Vec3(0, 1, 0);\nVec3.UNIT_Z = new Vec3(0, 0, 1);\n/**\r\n * Compute two artificial tangents to the vector\r\n * @method tangents\r\n * @param {Vec3} t1 Vector object to save the first tangent in\r\n * @param {Vec3} t2 Vector object to save the second tangent in\r\n */\n\nconst Vec3_tangents_n = new Vec3();\nconst Vec3_tangents_randVec = new Vec3();\nconst antip_neg = new Vec3();\n\n/**\r\n * Axis aligned bounding box class.\r\n * @class AABB\r\n * @constructor\r\n * @param {Object} [options]\r\n * @param {Vec3} [options.upperBound] The upper bound of the bounding box.\r\n * @param {Vec3} [options.lowerBound] The lower bound of the bounding box\r\n */\nclass AABB {\n // The lower bound of the bounding box\n // The upper bound of the bounding box\n constructor(options = {}) {\n this.lowerBound = new Vec3();\n this.upperBound = new Vec3();\n\n if (options.lowerBound) {\n this.lowerBound.copy(options.lowerBound);\n }\n\n if (options.upperBound) {\n this.upperBound.copy(options.upperBound);\n }\n }\n /**\r\n * Set the AABB bounds from a set of points.\r\n * @method setFromPoints\r\n * @param {Array} points An array of Vec3's.\r\n * @param {Vec3} position Optional.\r\n * @param {Quaternion} quaternion Optional.\r\n * @param {number} skinSize Optional.\r\n * @return {AABB} The self object\r\n */\n\n\n setFromPoints(points, position, quaternion, skinSize) {\n const l = this.lowerBound;\n const u = this.upperBound;\n const q = quaternion; // Set to the first point\n\n l.copy(points[0]);\n\n if (q) {\n q.vmult(l, l);\n }\n\n u.copy(l);\n\n for (let i = 1; i < points.length; i++) {\n let p = points[i];\n\n if (q) {\n q.vmult(p, tmp);\n p = tmp;\n }\n\n if (p.x > u.x) {\n u.x = p.x;\n }\n\n if (p.x < l.x) {\n l.x = p.x;\n }\n\n if (p.y > u.y) {\n u.y = p.y;\n }\n\n if (p.y < l.y) {\n l.y = p.y;\n }\n\n if (p.z > u.z) {\n u.z = p.z;\n }\n\n if (p.z < l.z) {\n l.z = p.z;\n }\n } // Add offset\n\n\n if (position) {\n position.vadd(l, l);\n position.vadd(u, u);\n }\n\n if (skinSize) {\n l.x -= skinSize;\n l.y -= skinSize;\n l.z -= skinSize;\n u.x += skinSize;\n u.y += skinSize;\n u.z += skinSize;\n }\n\n return this;\n }\n /**\r\n * Copy bounds from an AABB to this AABB\r\n * @method copy\r\n * @param {AABB} aabb Source to copy from\r\n * @return {AABB} The this object, for chainability\r\n */\n\n\n copy(aabb) {\n this.lowerBound.copy(aabb.lowerBound);\n this.upperBound.copy(aabb.upperBound);\n return this;\n }\n /**\r\n * Clone an AABB\r\n * @method clone\r\n */\n\n\n clone() {\n return new AABB().copy(this);\n }\n /**\r\n * Extend this AABB so that it covers the given AABB too.\r\n * @method extend\r\n * @param {AABB} aabb\r\n */\n\n\n extend(aabb) {\n this.lowerBound.x = Math.min(this.lowerBound.x, aabb.lowerBound.x);\n this.upperBound.x = Math.max(this.upperBound.x, aabb.upperBound.x);\n this.lowerBound.y = Math.min(this.lowerBound.y, aabb.lowerBound.y);\n this.upperBound.y = Math.max(this.upperBound.y, aabb.upperBound.y);\n this.lowerBound.z = Math.min(this.lowerBound.z, aabb.lowerBound.z);\n this.upperBound.z = Math.max(this.upperBound.z, aabb.upperBound.z);\n }\n /**\r\n * Returns true if the given AABB overlaps this AABB.\r\n * @method overlaps\r\n * @param {AABB} aabb\r\n * @return {Boolean}\r\n */\n\n\n overlaps(aabb) {\n const l1 = this.lowerBound;\n const u1 = this.upperBound;\n const l2 = aabb.lowerBound;\n const u2 = aabb.upperBound; // l2 u2\n // |---------|\n // |--------|\n // l1 u1\n\n const overlapsX = l2.x <= u1.x && u1.x <= u2.x || l1.x <= u2.x && u2.x <= u1.x;\n const overlapsY = l2.y <= u1.y && u1.y <= u2.y || l1.y <= u2.y && u2.y <= u1.y;\n const overlapsZ = l2.z <= u1.z && u1.z <= u2.z || l1.z <= u2.z && u2.z <= u1.z;\n return overlapsX && overlapsY && overlapsZ;\n } // Mostly for debugging\n\n\n volume() {\n const l = this.lowerBound;\n const u = this.upperBound;\n return (u.x - l.x) * (u.y - l.y) * (u.z - l.z);\n }\n /**\r\n * Returns true if the given AABB is fully contained in this AABB.\r\n * @method contains\r\n * @param {AABB} aabb\r\n * @return {Boolean}\r\n */\n\n\n contains(aabb) {\n const l1 = this.lowerBound;\n const u1 = this.upperBound;\n const l2 = aabb.lowerBound;\n const u2 = aabb.upperBound; // l2 u2\n // |---------|\n // |---------------|\n // l1 u1\n\n return l1.x <= l2.x && u1.x >= u2.x && l1.y <= l2.y && u1.y >= u2.y && l1.z <= l2.z && u1.z >= u2.z;\n }\n /**\r\n * @method getCorners\r\n * @param {Vec3} a\r\n * @param {Vec3} b\r\n * @param {Vec3} c\r\n * @param {Vec3} d\r\n * @param {Vec3} e\r\n * @param {Vec3} f\r\n * @param {Vec3} g\r\n * @param {Vec3} h\r\n */\n\n\n getCorners(a, b, c, d, e, f, g, h) {\n const l = this.lowerBound;\n const u = this.upperBound;\n a.copy(l);\n b.set(u.x, l.y, l.z);\n c.set(u.x, u.y, l.z);\n d.set(l.x, u.y, u.z);\n e.set(u.x, l.y, u.z);\n f.set(l.x, u.y, l.z);\n g.set(l.x, l.y, u.z);\n h.copy(u);\n }\n /**\r\n * Get the representation of an AABB in another frame.\r\n * @method toLocalFrame\r\n * @param {Transform} frame\r\n * @param {AABB} target\r\n * @return {AABB} The \"target\" AABB object.\r\n */\n\n\n toLocalFrame(frame, target) {\n const corners = transformIntoFrame_corners;\n const a = corners[0];\n const b = corners[1];\n const c = corners[2];\n const d = corners[3];\n const e = corners[4];\n const f = corners[5];\n const g = corners[6];\n const h = corners[7]; // Get corners in current frame\n\n this.getCorners(a, b, c, d, e, f, g, h); // Transform them to new local frame\n\n for (let i = 0; i !== 8; i++) {\n const corner = corners[i];\n frame.pointToLocal(corner, corner);\n }\n\n return target.setFromPoints(corners);\n }\n /**\r\n * Get the representation of an AABB in the global frame.\r\n * @method toWorldFrame\r\n * @param {Transform} frame\r\n * @param {AABB} target\r\n * @return {AABB} The \"target\" AABB object.\r\n */\n\n\n toWorldFrame(frame, target) {\n const corners = transformIntoFrame_corners;\n const a = corners[0];\n const b = corners[1];\n const c = corners[2];\n const d = corners[3];\n const e = corners[4];\n const f = corners[5];\n const g = corners[6];\n const h = corners[7]; // Get corners in current frame\n\n this.getCorners(a, b, c, d, e, f, g, h); // Transform them to new local frame\n\n for (let i = 0; i !== 8; i++) {\n const corner = corners[i];\n frame.pointToWorld(corner, corner);\n }\n\n return target.setFromPoints(corners);\n }\n /**\r\n * Check if the AABB is hit by a ray.\r\n * @param {Ray} ray\r\n * @return {Boolean}\r\n */\n\n\n overlapsRay(ray) {\n const {\n direction,\n from\n } = ray;\n\n const dirFracX = 1 / direction.x;\n const dirFracY = 1 / direction.y;\n const dirFracZ = 1 / direction.z; // this.lowerBound is the corner of AABB with minimal coordinates - left bottom, rt is maximal corner\n\n const t1 = (this.lowerBound.x - from.x) * dirFracX;\n const t2 = (this.upperBound.x - from.x) * dirFracX;\n const t3 = (this.lowerBound.y - from.y) * dirFracY;\n const t4 = (this.upperBound.y - from.y) * dirFracY;\n const t5 = (this.lowerBound.z - from.z) * dirFracZ;\n const t6 = (this.upperBound.z - from.z) * dirFracZ; // const tmin = Math.max(Math.max(Math.min(t1, t2), Math.min(t3, t4)));\n // const tmax = Math.min(Math.min(Math.max(t1, t2), Math.max(t3, t4)));\n\n const tmin = Math.max(Math.max(Math.min(t1, t2), Math.min(t3, t4)), Math.min(t5, t6));\n const tmax = Math.min(Math.min(Math.max(t1, t2), Math.max(t3, t4)), Math.max(t5, t6)); // if tmax < 0, ray (line) is intersecting AABB, but whole AABB is behing us\n\n if (tmax < 0) {\n //t = tmax;\n return false;\n } // if tmin > tmax, ray doesn't intersect AABB\n\n\n if (tmin > tmax) {\n //t = tmax;\n return false;\n }\n\n return true;\n }\n\n}\nconst tmp = new Vec3();\nconst transformIntoFrame_corners = [new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3()];\n\n/**\r\n * Collision \"matrix\". It's actually a triangular-shaped array of whether two bodies are touching this step, for reference next step\r\n * @class ArrayCollisionMatrix\r\n * @constructor\r\n */\nclass ArrayCollisionMatrix {\n // The matrix storage.\n constructor() {\n this.matrix = [];\n }\n /**\r\n * Get an element\r\n * @method get\r\n * @param {Body} i\r\n * @param {Body} j\r\n * @return {Number}\r\n */\n\n\n get(bi, bj) {\n let {\n index: i\n } = bi;\n let {\n index: j\n } = bj;\n\n if (j > i) {\n const temp = j;\n j = i;\n i = temp;\n }\n\n return this.matrix[(i * (i + 1) >> 1) + j - 1];\n }\n /**\r\n * Set an element\r\n * @method set\r\n * @param {Body} i\r\n * @param {Body} j\r\n * @param {boolean} value\r\n */\n\n\n set(bi, bj, value) {\n let {\n index: i\n } = bi;\n let {\n index: j\n } = bj;\n\n if (j > i) {\n const temp = j;\n j = i;\n i = temp;\n }\n\n this.matrix[(i * (i + 1) >> 1) + j - 1] = value ? 1 : 0;\n }\n /**\r\n * Sets all elements to zero\r\n * @method reset\r\n */\n\n\n reset() {\n for (let i = 0, l = this.matrix.length; i !== l; i++) {\n this.matrix[i] = 0;\n }\n }\n /**\r\n * Sets the max number of objects\r\n * @method setNumObjects\r\n * @param {Number} n\r\n */\n\n\n setNumObjects(n) {\n this.matrix.length = n * (n - 1) >> 1;\n }\n\n}\n\n/**\r\n * Base class for objects that dispatches events.\r\n * @class EventTarget\r\n * @constructor\r\n */\nclass EventTarget {\n constructor() {}\n /**\r\n * Add an event listener\r\n * @method addEventListener\r\n * @param {String} type\r\n * @param {Function} listener\r\n * @return {EventTarget} The self object, for chainability.\r\n */\n\n\n addEventListener(type, listener) {\n if (this._listeners === undefined) {\n this._listeners = {};\n }\n\n const listeners = this._listeners;\n\n if (listeners[type] === undefined) {\n listeners[type] = [];\n }\n\n if (!listeners[type].includes(listener)) {\n listeners[type].push(listener);\n }\n\n return this;\n }\n /**\r\n * Check if an event listener is added\r\n * @method hasEventListener\r\n * @param {String} type\r\n * @param {Function} listener\r\n * @return {Boolean}\r\n */\n\n\n hasEventListener(type, listener) {\n if (this._listeners === undefined) {\n return false;\n }\n\n const listeners = this._listeners;\n\n if (listeners[type] !== undefined && listeners[type].includes(listener)) {\n return true;\n }\n\n return false;\n }\n /**\r\n * Check if any event listener of the given type is added\r\n * @method hasAnyEventListener\r\n * @param {String} type\r\n * @return {Boolean}\r\n */\n\n\n hasAnyEventListener(type) {\n if (this._listeners === undefined) {\n return false;\n }\n\n const listeners = this._listeners;\n return listeners[type] !== undefined;\n }\n /**\r\n * Remove an event listener\r\n * @method removeEventListener\r\n * @param {String} type\r\n * @param {Function} listener\r\n * @return {EventTarget} The self object, for chainability.\r\n */\n\n\n removeEventListener(type, listener) {\n if (this._listeners === undefined) {\n return this;\n }\n\n const listeners = this._listeners;\n\n if (listeners[type] === undefined) {\n return this;\n }\n\n const index = listeners[type].indexOf(listener);\n\n if (index !== -1) {\n listeners[type].splice(index, 1);\n }\n\n return this;\n }\n /**\r\n * Emit an event.\r\n * @method dispatchEvent\r\n * @param {Object} event\r\n * @param {String} event.type\r\n * @return {EventTarget} The self object, for chainability.\r\n */\n\n\n dispatchEvent(event) {\n if (this._listeners === undefined) {\n return this;\n }\n\n const listeners = this._listeners;\n const listenerArray = listeners[event.type];\n\n if (listenerArray !== undefined) {\n event.target = this;\n\n for (let i = 0, l = listenerArray.length; i < l; i++) {\n listenerArray[i].call(this, event);\n }\n }\n\n return this;\n }\n\n}\n\n/**\n * A Quaternion describes a rotation in 3D space. The Quaternion is mathematically defined as Q = x*i + y*j + z*k + w, where (i,j,k) are imaginary basis vectors. (x,y,z) can be seen as a vector related to the axis of rotation, while the real multiplier, w, is related to the amount of rotation.\n * @param {Number} x Multiplier of the imaginary basis vector i.\n * @param {Number} y Multiplier of the imaginary basis vector j.\n * @param {Number} z Multiplier of the imaginary basis vector k.\n * @param {Number} w Multiplier of the real part.\n * @see http://en.wikipedia.org/wiki/Quaternion\n */\n\nclass Quaternion {\n constructor(x = 0, y = 0, z = 0, w = 1) {\n this.x = x;\n this.y = y;\n this.z = z;\n this.w = w;\n }\n /**\n * Set the value of the quaternion.\n */\n\n\n set(x, y, z, w) {\n this.x = x;\n this.y = y;\n this.z = z;\n this.w = w;\n return this;\n }\n /**\n * Convert to a readable format\n * @return {String} \"x,y,z,w\"\n */\n\n\n toString() {\n return this.x + \",\" + this.y + \",\" + this.z + \",\" + this.w;\n }\n /**\n * Convert to an Array\n * @return {Array} [x, y, z, w]\n */\n\n\n toArray() {\n return [this.x, this.y, this.z, this.w];\n }\n /**\n * Set the quaternion components given an axis and an angle in radians.\n */\n\n\n setFromAxisAngle(vector, angle) {\n const s = Math.sin(angle * 0.5);\n this.x = vector.x * s;\n this.y = vector.y * s;\n this.z = vector.z * s;\n this.w = Math.cos(angle * 0.5);\n return this;\n }\n /**\n * Converts the quaternion to [ axis, angle ] representation.\n * @param {Vec3} [targetAxis] A vector object to reuse for storing the axis.\n * @return {Array} An array, first element is the axis and the second is the angle in radians.\n */\n\n\n toAxisAngle(targetAxis = new Vec3()) {\n this.normalize(); // if w>1 acos and sqrt will produce errors, this cant happen if quaternion is normalised\n\n const angle = 2 * Math.acos(this.w);\n const s = Math.sqrt(1 - this.w * this.w); // assuming quaternion normalised then w is less than 1, so term always positive.\n\n if (s < 0.001) {\n // test to avoid divide by zero, s is always positive due to sqrt\n // if s close to zero then direction of axis not important\n targetAxis.x = this.x; // if it is important that axis is normalised then replace with x=1; y=z=0;\n\n targetAxis.y = this.y;\n targetAxis.z = this.z;\n } else {\n targetAxis.x = this.x / s; // normalise axis\n\n targetAxis.y = this.y / s;\n targetAxis.z = this.z / s;\n }\n\n return [targetAxis, angle];\n }\n /**\n * Set the quaternion value given two vectors. The resulting rotation will be the needed rotation to rotate u to v.\n */\n\n\n setFromVectors(u, v) {\n if (u.isAntiparallelTo(v)) {\n const t1 = sfv_t1;\n const t2 = sfv_t2;\n u.tangents(t1, t2);\n this.setFromAxisAngle(t1, Math.PI);\n } else {\n const a = u.cross(v);\n this.x = a.x;\n this.y = a.y;\n this.z = a.z;\n this.w = Math.sqrt(u.length() ** 2 * v.length() ** 2) + u.dot(v);\n this.normalize();\n }\n\n return this;\n }\n /**\n * Multiply the quaternion with an other quaternion.\n */\n\n\n mult(quat, target = new Quaternion()) {\n const ax = this.x;\n const ay = this.y;\n const az = this.z;\n const aw = this.w;\n const bx = quat.x;\n const by = quat.y;\n const bz = quat.z;\n const bw = quat.w;\n target.x = ax * bw + aw * bx + ay * bz - az * by;\n target.y = ay * bw + aw * by + az * bx - ax * bz;\n target.z = az * bw + aw * bz + ax * by - ay * bx;\n target.w = aw * bw - ax * bx - ay * by - az * bz;\n return target;\n }\n /**\n * Get the inverse quaternion rotation.\n */\n\n\n inverse(target = new Quaternion()) {\n const x = this.x;\n const y = this.y;\n const z = this.z;\n const w = this.w;\n this.conjugate(target);\n const inorm2 = 1 / (x * x + y * y + z * z + w * w);\n target.x *= inorm2;\n target.y *= inorm2;\n target.z *= inorm2;\n target.w *= inorm2;\n return target;\n }\n /**\n * Get the quaternion conjugate\n */\n\n\n conjugate(target = new Quaternion()) {\n target.x = -this.x;\n target.y = -this.y;\n target.z = -this.z;\n target.w = this.w;\n return target;\n }\n /**\n * Normalize the quaternion. Note that this changes the values of the quaternion.\n * @method normalize\n */\n\n\n normalize() {\n let l = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);\n\n if (l === 0) {\n this.x = 0;\n this.y = 0;\n this.z = 0;\n this.w = 0;\n } else {\n l = 1 / l;\n this.x *= l;\n this.y *= l;\n this.z *= l;\n this.w *= l;\n }\n\n return this;\n }\n /**\n * Approximation of quaternion normalization. Works best when quat is already almost-normalized.\n * @see http://jsperf.com/fast-quaternion-normalization\n * @author unphased, https://github.com/unphased\n */\n\n\n normalizeFast() {\n const f = (3.0 - (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w)) / 2.0;\n\n if (f === 0) {\n this.x = 0;\n this.y = 0;\n this.z = 0;\n this.w = 0;\n } else {\n this.x *= f;\n this.y *= f;\n this.z *= f;\n this.w *= f;\n }\n\n return this;\n }\n /**\n * Multiply the quaternion by a vector\n */\n\n\n vmult(v, target = new Vec3()) {\n const x = v.x;\n const y = v.y;\n const z = v.z;\n const qx = this.x;\n const qy = this.y;\n const qz = this.z;\n const qw = this.w; // q*v\n\n const ix = qw * x + qy * z - qz * y;\n const iy = qw * y + qz * x - qx * z;\n const iz = qw * z + qx * y - qy * x;\n const iw = -qx * x - qy * y - qz * z;\n target.x = ix * qw + iw * -qx + iy * -qz - iz * -qy;\n target.y = iy * qw + iw * -qy + iz * -qx - ix * -qz;\n target.z = iz * qw + iw * -qz + ix * -qy - iy * -qx;\n return target;\n }\n /**\n * Copies value of source to this quaternion.\n * @method copy\n * @param {Quaternion} source\n * @return {Quaternion} this\n */\n\n\n copy(quat) {\n this.x = quat.x;\n this.y = quat.y;\n this.z = quat.z;\n this.w = quat.w;\n return this;\n }\n /**\n * Convert the quaternion to euler angle representation. Order: YZX, as this page describes: http://www.euclideanspace.com/maths/standards/index.htm\n * @method toEuler\n * @param {Vec3} target\n * @param {String} order Three-character string, defaults to \"YZX\"\n */\n\n\n toEuler(target, order = 'YZX') {\n let heading;\n let attitude;\n let bank;\n const x = this.x;\n const y = this.y;\n const z = this.z;\n const w = this.w;\n\n switch (order) {\n case 'YZX':\n const test = x * y + z * w;\n\n if (test > 0.499) {\n // singularity at north pole\n heading = 2 * Math.atan2(x, w);\n attitude = Math.PI / 2;\n bank = 0;\n }\n\n if (test < -0.499) {\n // singularity at south pole\n heading = -2 * Math.atan2(x, w);\n attitude = -Math.PI / 2;\n bank = 0;\n }\n\n if (heading === undefined) {\n const sqx = x * x;\n const sqy = y * y;\n const sqz = z * z;\n heading = Math.atan2(2 * y * w - 2 * x * z, 1 - 2 * sqy - 2 * sqz); // Heading\n\n attitude = Math.asin(2 * test); // attitude\n\n bank = Math.atan2(2 * x * w - 2 * y * z, 1 - 2 * sqx - 2 * sqz); // bank\n }\n\n break;\n\n default:\n throw new Error(\"Euler order \" + order + \" not supported yet.\");\n }\n\n target.y = heading;\n target.z = attitude;\n target.x = bank;\n }\n /**\n * @param {Number} x\n * @param {Number} y\n * @param {Number} z\n * @param {String} order The order to apply angles: 'XYZ' or 'YXZ' or any other combination\n * @see http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/content/SpinCalc.m\n */\n\n\n setFromEuler(x, y, z, order = 'XYZ') {\n const c1 = Math.cos(x / 2);\n const c2 = Math.cos(y / 2);\n const c3 = Math.cos(z / 2);\n const s1 = Math.sin(x / 2);\n const s2 = Math.sin(y / 2);\n const s3 = Math.sin(z / 2);\n\n if (order === 'XYZ') {\n this.x = s1 * c2 * c3 + c1 * s2 * s3;\n this.y = c1 * s2 * c3 - s1 * c2 * s3;\n this.z = c1 * c2 * s3 + s1 * s2 * c3;\n this.w = c1 * c2 * c3 - s1 * s2 * s3;\n } else if (order === 'YXZ') {\n this.x = s1 * c2 * c3 + c1 * s2 * s3;\n this.y = c1 * s2 * c3 - s1 * c2 * s3;\n this.z = c1 * c2 * s3 - s1 * s2 * c3;\n this.w = c1 * c2 * c3 + s1 * s2 * s3;\n } else if (order === 'ZXY') {\n this.x = s1 * c2 * c3 - c1 * s2 * s3;\n this.y = c1 * s2 * c3 + s1 * c2 * s3;\n this.z = c1 * c2 * s3 + s1 * s2 * c3;\n this.w = c1 * c2 * c3 - s1 * s2 * s3;\n } else if (order === 'ZYX') {\n this.x = s1 * c2 * c3 - c1 * s2 * s3;\n this.y = c1 * s2 * c3 + s1 * c2 * s3;\n this.z = c1 * c2 * s3 - s1 * s2 * c3;\n this.w = c1 * c2 * c3 + s1 * s2 * s3;\n } else if (order === 'YZX') {\n this.x = s1 * c2 * c3 + c1 * s2 * s3;\n this.y = c1 * s2 * c3 + s1 * c2 * s3;\n this.z = c1 * c2 * s3 - s1 * s2 * c3;\n this.w = c1 * c2 * c3 - s1 * s2 * s3;\n } else if (order === 'XZY') {\n this.x = s1 * c2 * c3 - c1 * s2 * s3;\n this.y = c1 * s2 * c3 - s1 * c2 * s3;\n this.z = c1 * c2 * s3 + s1 * s2 * c3;\n this.w = c1 * c2 * c3 + s1 * s2 * s3;\n }\n\n return this;\n }\n /**\n * @method clone\n * @return {Quaternion}\n */\n\n\n clone() {\n return new Quaternion(this.x, this.y, this.z, this.w);\n }\n /**\n * Performs a spherical linear interpolation between two quat\n *\n * @param {Quaternion} toQuat second operand\n * @param {Number} t interpolation amount between the self quaternion and toQuat\n * @param {Quaternion} [target] A quaternion to store the result in. If not provided, a new one will be created.\n * @returns {Quaternion} The \"target\" object\n */\n\n\n slerp(toQuat, t, target = new Quaternion()) {\n const ax = this.x;\n const ay = this.y;\n const az = this.z;\n const aw = this.w;\n let bx = toQuat.x;\n let by = toQuat.y;\n let bz = toQuat.z;\n let bw = toQuat.w;\n let omega;\n let cosom;\n let sinom;\n let scale0;\n let scale1; // calc cosine\n\n cosom = ax * bx + ay * by + az * bz + aw * bw; // adjust signs (if necessary)\n\n if (cosom < 0.0) {\n cosom = -cosom;\n bx = -bx;\n by = -by;\n bz = -bz;\n bw = -bw;\n } // calculate coefficients\n\n\n if (1.0 - cosom > 0.000001) {\n // standard case (slerp)\n omega = Math.acos(cosom);\n sinom = Math.sin(omega);\n scale0 = Math.sin((1.0 - t) * omega) / sinom;\n scale1 = Math.sin(t * omega) / sinom;\n } else {\n // \"from\" and \"to\" quaternions are very close\n // ... so we can do a linear interpolation\n scale0 = 1.0 - t;\n scale1 = t;\n } // calculate final values\n\n\n target.x = scale0 * ax + scale1 * bx;\n target.y = scale0 * ay + scale1 * by;\n target.z = scale0 * az + scale1 * bz;\n target.w = scale0 * aw + scale1 * bw;\n return target;\n }\n /**\n * Rotate an absolute orientation quaternion given an angular velocity and a time step.\n */\n\n\n integrate(angularVelocity, dt, angularFactor, target = new Quaternion()) {\n const ax = angularVelocity.x * angularFactor.x,\n ay = angularVelocity.y * angularFactor.y,\n az = angularVelocity.z * angularFactor.z,\n bx = this.x,\n by = this.y,\n bz = this.z,\n bw = this.w;\n const half_dt = dt * 0.5;\n target.x += half_dt * (ax * bw + ay * bz - az * by);\n target.y += half_dt * (ay * bw + az * bx - ax * bz);\n target.z += half_dt * (az * bw + ax * by - ay * bx);\n target.w += half_dt * (-ax * bx - ay * by - az * bz);\n return target;\n }\n\n}\nconst sfv_t1 = new Vec3();\nconst sfv_t2 = new Vec3();\n\nconst SHAPE_TYPES = {\n SPHERE: 1,\n PLANE: 2,\n BOX: 4,\n COMPOUND: 8,\n CONVEXPOLYHEDRON: 16,\n HEIGHTFIELD: 32,\n PARTICLE: 64,\n CYLINDER: 128,\n TRIMESH: 256\n};\n\n/**\n * Base class for shapes\n * @class Shape\n * @constructor\n * @param {object} [options]\n * @param {number} [options.collisionFilterGroup=1]\n * @param {number} [options.collisionFilterMask=-1]\n * @param {number} [options.collisionResponse=true]\n * @param {number} [options.material=null]\n * @author schteppe\n */\nclass Shape {\n // Identifyer of the Shape.\n // The type of this shape. Must be set to an int > 0 by subclasses.\n // The local bounding sphere radius of this shape.\n // Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled.\n constructor(options = {}) {\n this.id = Shape.idCounter++;\n this.type = options.type || 0;\n this.boundingSphereRadius = 0;\n this.collisionResponse = options.collisionResponse ? options.collisionResponse : true;\n this.collisionFilterGroup = options.collisionFilterGroup !== undefined ? options.collisionFilterGroup : 1;\n this.collisionFilterMask = options.collisionFilterMask !== undefined ? options.collisionFilterMask : -1;\n this.material = options.material ? options.material : null;\n this.body = null;\n }\n /**\n * Computes the bounding sphere radius. The result is stored in the property .boundingSphereRadius\n * @method updateBoundingSphereRadius\n */\n\n\n updateBoundingSphereRadius() {\n throw \"computeBoundingSphereRadius() not implemented for shape type \" + this.type;\n }\n /**\n * Get the volume of this shape\n * @method volume\n * @return {Number}\n */\n\n\n volume() {\n throw \"volume() not implemented for shape type \" + this.type;\n }\n /**\n * Calculates the inertia in the local frame for this shape.\n * @method calculateLocalInertia\n * @param {Number} mass\n * @param {Vec3} target\n * @see http://en.wikipedia.org/wiki/List_of_moments_of_inertia\n */\n\n\n calculateLocalInertia(mass, target) {\n throw \"calculateLocalInertia() not implemented for shape type \" + this.type;\n }\n\n calculateWorldAABB(pos, quat, min, max) {\n throw \"calculateWorldAABB() not implemented for shape type \" + this.type;\n }\n\n}\nShape.idCounter = 0;\n/**\n * The available shape types.\n * @static\n * @property types\n * @type {Object}\n */\n\nShape.types = SHAPE_TYPES;\n\nclass Transform {\n constructor(options = {}) {\n this.position = new Vec3();\n this.quaternion = new Quaternion();\n\n if (options.position) {\n this.position.copy(options.position);\n }\n\n if (options.quaternion) {\n this.quaternion.copy(options.quaternion);\n }\n }\n /**\r\n * Get a global point in local transform coordinates.\r\n */\n\n\n pointToLocal(worldPoint, result) {\n return Transform.pointToLocalFrame(this.position, this.quaternion, worldPoint, result);\n }\n /**\r\n * Get a local point in global transform coordinates.\r\n */\n\n\n pointToWorld(localPoint, result) {\n return Transform.pointToWorldFrame(this.position, this.quaternion, localPoint, result);\n }\n\n vectorToWorldFrame(localVector, result = new Vec3()) {\n this.quaternion.vmult(localVector, result);\n return result;\n }\n\n static pointToLocalFrame(position, quaternion, worldPoint, result = new Vec3()) {\n worldPoint.vsub(position, result);\n quaternion.conjugate(tmpQuat);\n tmpQuat.vmult(result, result);\n return result;\n }\n\n static pointToWorldFrame(position, quaternion, localPoint, result = new Vec3()) {\n quaternion.vmult(localPoint, result);\n result.vadd(position, result);\n return result;\n }\n\n static vectorToWorldFrame(quaternion, localVector, result = new Vec3()) {\n quaternion.vmult(localVector, result);\n return result;\n }\n\n static vectorToLocalFrame(position, quaternion, worldVector, result = new Vec3()) {\n quaternion.w *= -1;\n quaternion.vmult(worldVector, result);\n quaternion.w *= -1;\n return result;\n }\n\n}\nconst tmpQuat = new Quaternion();\n\n/**\r\n * A set of polygons describing a convex shape.\r\n * @class ConvexPolyhedron\r\n * @constructor\r\n * @extends Shape\r\n * @description The shape MUST be convex for the code to work properly. No polygons may be coplanar (contained\r\n * in the same 3D plane), instead these should be merged into one polygon.\r\n *\r\n * @param {array} points An array of Vec3's\r\n * @param {array} faces Array of integer arrays, describing which vertices that is included in each face.\r\n *\r\n * @author qiao / https://github.com/qiao (original author, see https://github.com/qiao/three.js/commit/85026f0c769e4000148a67d45a9e9b9c5108836f)\r\n * @author schteppe / https://github.com/schteppe\r\n * @see http://www.altdevblogaday.com/2011/05/13/contact-generation-between-3d-convex-meshes/\r\n *\r\n * @todo Move the clipping functions to ContactGenerator?\r\n * @todo Automatically merge coplanar polygons in constructor.\r\n */\nclass ConvexPolyhedron extends Shape {\n // Array of integer arrays, indicating which vertices each face consists of\n // If given, these locally defined, normalized axes are the only ones being checked when doing separating axis check.\n constructor(props = {}) {\n const {\n vertices = [],\n faces = [],\n normals = [],\n axes,\n boundingSphereRadius\n } = props;\n super({\n type: Shape.types.CONVEXPOLYHEDRON\n });\n this.vertices = vertices;\n this.faces = faces;\n this.faceNormals = normals;\n\n if (this.faceNormals.length === 0) {\n this.computeNormals();\n }\n\n if (!boundingSphereRadius) {\n this.updateBoundingSphereRadius();\n } else {\n this.boundingSphereRadius = boundingSphereRadius;\n }\n\n this.worldVertices = []; // World transformed version of .vertices\n\n this.worldVerticesNeedsUpdate = true;\n this.worldFaceNormals = []; // World transformed version of .faceNormals\n\n this.worldFaceNormalsNeedsUpdate = true;\n this.uniqueAxes = axes ? axes.slice() : null;\n this.uniqueEdges = [];\n this.computeEdges();\n }\n /**\r\n * Computes uniqueEdges\r\n * @method computeEdges\r\n */\n\n\n computeEdges() {\n const faces = this.faces;\n const vertices = this.vertices;\n const edges = this.uniqueEdges;\n edges.length = 0;\n const edge = new Vec3();\n\n for (let i = 0; i !== faces.length; i++) {\n const face = faces[i];\n const numVertices = face.length;\n\n for (let j = 0; j !== numVertices; j++) {\n const k = (j + 1) % numVertices;\n vertices[face[j]].vsub(vertices[face[k]], edge);\n edge.normalize();\n let found = false;\n\n for (let p = 0; p !== edges.length; p++) {\n if (edges[p].almostEquals(edge) || edges[p].almostEquals(edge)) {\n found = true;\n break;\n }\n }\n\n if (!found) {\n edges.push(edge.clone());\n }\n }\n }\n }\n /**\r\n * Compute the normals of the faces. Will reuse existing Vec3 objects in the .faceNormals array if they exist.\r\n * @method computeNormals\r\n */\n\n\n computeNormals() {\n this.faceNormals.length = this.faces.length; // Generate normals\n\n for (let i = 0; i < this.faces.length; i++) {\n // Check so all vertices exists for this face\n for (let j = 0; j < this.faces[i].length; j++) {\n if (!this.vertices[this.faces[i][j]]) {\n throw new Error(\"Vertex \" + this.faces[i][j] + \" not found!\");\n }\n }\n\n const n = this.faceNormals[i] || new Vec3();\n this.getFaceNormal(i, n);\n n.negate(n);\n this.faceNormals[i] = n;\n const vertex = this.vertices[this.faces[i][0]];\n\n if (n.dot(vertex) < 0) {\n console.error(\".faceNormals[\" + i + \"] = Vec3(\" + n.toString() + \") looks like it points into the shape? The vertices follow. Make sure they are ordered CCW around the normal, using the right hand rule.\");\n\n for (let j = 0; j < this.faces[i].length; j++) {\n console.warn(\".vertices[\" + this.faces[i][j] + \"] = Vec3(\" + this.vertices[this.faces[i][j]].toString() + \")\");\n }\n }\n }\n }\n /**\r\n * Compute the normal of a face from its vertices\r\n * @method getFaceNormal\r\n * @param {Number} i\r\n * @param {Vec3} target\r\n */\n\n\n getFaceNormal(i, target) {\n const f = this.faces[i];\n const va = this.vertices[f[0]];\n const vb = this.vertices[f[1]];\n const vc = this.vertices[f[2]];\n ConvexPolyhedron.computeNormal(va, vb, vc, target);\n }\n /**\r\n * @method clipAgainstHull\r\n * @param {Vec3} posA\r\n * @param {Quaternion} quatA\r\n * @param {ConvexPolyhedron} hullB\r\n * @param {Vec3} posB\r\n * @param {Quaternion} quatB\r\n * @param {Vec3} separatingNormal\r\n * @param {Number} minDist Clamp distance\r\n * @param {Number} maxDist\r\n * @param {array} result The an array of contact point objects, see clipFaceAgainstHull\r\n */\n\n\n clipAgainstHull(posA, quatA, hullB, posB, quatB, separatingNormal, minDist, maxDist, result) {\n const WorldNormal = new Vec3();\n let closestFaceB = -1;\n let dmax = -Number.MAX_VALUE;\n\n for (let face = 0; face < hullB.faces.length; face++) {\n WorldNormal.copy(hullB.faceNormals[face]);\n quatB.vmult(WorldNormal, WorldNormal);\n const d = WorldNormal.dot(separatingNormal);\n\n if (d > dmax) {\n dmax = d;\n closestFaceB = face;\n }\n }\n\n const worldVertsB1 = [];\n\n for (let i = 0; i < hullB.faces[closestFaceB].length; i++) {\n const b = hullB.vertices[hullB.faces[closestFaceB][i]];\n const worldb = new Vec3();\n worldb.copy(b);\n quatB.vmult(worldb, worldb);\n posB.vadd(worldb, worldb);\n worldVertsB1.push(worldb);\n }\n\n if (closestFaceB >= 0) {\n this.clipFaceAgainstHull(separatingNormal, posA, quatA, worldVertsB1, minDist, maxDist, result);\n }\n }\n /**\r\n * Find the separating axis between this hull and another\r\n * @method findSeparatingAxis\r\n * @param {ConvexPolyhedron} hullB\r\n * @param {Vec3} posA\r\n * @param {Quaternion} quatA\r\n * @param {Vec3} posB\r\n * @param {Quaternion} quatB\r\n * @param {Vec3} target The target vector to save the axis in\r\n * @return {bool} Returns false if a separation is found, else true\r\n */\n\n\n findSeparatingAxis(hullB, posA, quatA, posB, quatB, target, faceListA, faceListB) {\n const faceANormalWS3 = new Vec3();\n const Worldnormal1 = new Vec3();\n const deltaC = new Vec3();\n const worldEdge0 = new Vec3();\n const worldEdge1 = new Vec3();\n const Cross = new Vec3();\n let dmin = Number.MAX_VALUE;\n const hullA = this;\n\n if (!hullA.uniqueAxes) {\n const numFacesA = faceListA ? faceListA.length : hullA.faces.length; // Test face normals from hullA\n\n for (let i = 0; i < numFacesA; i++) {\n const fi = faceListA ? faceListA[i] : i; // Get world face normal\n\n faceANormalWS3.copy(hullA.faceNormals[fi]);\n quatA.vmult(faceANormalWS3, faceANormalWS3);\n const d = hullA.testSepAxis(faceANormalWS3, hullB, posA, quatA, posB, quatB);\n\n if (d === false) {\n return false;\n }\n\n if (d < dmin) {\n dmin = d;\n target.copy(faceANormalWS3);\n }\n }\n } else {\n // Test unique axes\n for (let i = 0; i !== hullA.uniqueAxes.length; i++) {\n // Get world axis\n quatA.vmult(hullA.uniqueAxes[i], faceANormalWS3);\n const d = hullA.testSepAxis(faceANormalWS3, hullB, posA, quatA, posB, quatB);\n\n if (d === false) {\n return false;\n }\n\n if (d < dmin) {\n dmin = d;\n target.copy(faceANormalWS3);\n }\n }\n }\n\n if (!hullB.uniqueAxes) {\n // Test face normals from hullB\n const numFacesB = faceListB ? faceListB.length : hullB.faces.length;\n\n for (let i = 0; i < numFacesB; i++) {\n const fi = faceListB ? faceListB[i] : i;\n Worldnormal1.copy(hullB.faceNormals[fi]);\n quatB.vmult(Worldnormal1, Worldnormal1);\n const d = hullA.testSepAxis(Worldnormal1, hullB, posA, quatA, posB, quatB);\n\n if (d === false) {\n return false;\n }\n\n if (d < dmin) {\n dmin = d;\n target.copy(Worldnormal1);\n }\n }\n } else {\n // Test unique axes in B\n for (let i = 0; i !== hullB.uniqueAxes.length; i++) {\n quatB.vmult(hullB.uniqueAxes[i], Worldnormal1);\n const d = hullA.testSepAxis(Worldnormal1, hullB, posA, quatA, posB, quatB);\n\n if (d === false) {\n return false;\n }\n\n if (d < dmin) {\n dmin = d;\n target.copy(Worldnormal1);\n }\n }\n } // Test edges\n\n\n for (let e0 = 0; e0 !== hullA.uniqueEdges.length; e0++) {\n // Get world edge\n quatA.vmult(hullA.uniqueEdges[e0], worldEdge0);\n\n for (let e1 = 0; e1 !== hullB.uniqueEdges.length; e1++) {\n // Get world edge 2\n quatB.vmult(hullB.uniqueEdges[e1], worldEdge1);\n worldEdge0.cross(worldEdge1, Cross);\n\n if (!Cross.almostZero()) {\n Cross.normalize();\n const dist = hullA.testSepAxis(Cross, hullB, posA, quatA, posB, quatB);\n\n if (dist === false) {\n return false;\n }\n\n if (dist < dmin) {\n dmin = dist;\n target.copy(Cross);\n }\n }\n }\n }\n\n posB.vsub(posA, deltaC);\n\n if (deltaC.dot(target) > 0.0) {\n target.negate(target);\n }\n\n return true;\n }\n /**\r\n * Test separating axis against two hulls. Both hulls are projected onto the axis and the overlap size is returned if there is one.\r\n * @method testSepAxis\r\n * @param {Vec3} axis\r\n * @param {ConvexPolyhedron} hullB\r\n * @param {Vec3} posA\r\n * @param {Quaternion} quatA\r\n * @param {Vec3} posB\r\n * @param {Quaternion} quatB\r\n * @return {number} The overlap depth, or FALSE if no penetration.\r\n */\n\n\n testSepAxis(axis, hullB, posA, quatA, posB, quatB) {\n const hullA = this;\n ConvexPolyhedron.project(hullA, axis, posA, quatA, maxminA);\n ConvexPolyhedron.project(hullB, axis, posB, quatB, maxminB);\n const maxA = maxminA[0];\n const minA = maxminA[1];\n const maxB = maxminB[0];\n const minB = maxminB[1];\n\n if (maxA < minB || maxB < minA) {\n return false; // Separated\n }\n\n const d0 = maxA - minB;\n const d1 = maxB - minA;\n const depth = d0 < d1 ? d0 : d1;\n return depth;\n }\n /**\r\n * @method calculateLocalInertia\r\n * @param {Number} mass\r\n * @param {Vec3} target\r\n */\n\n\n calculateLocalInertia(mass, target) {\n // Approximate with box inertia\n // Exact inertia calculation is overkill, but see http://geometrictools.com/Documentation/PolyhedralMassProperties.pdf for the correct way to do it\n const aabbmax = new Vec3();\n const aabbmin = new Vec3();\n this.computeLocalAABB(aabbmin, aabbmax);\n const x = aabbmax.x - aabbmin.x;\n const y = aabbmax.y - aabbmin.y;\n const z = aabbmax.z - aabbmin.z;\n target.x = 1.0 / 12.0 * mass * (2 * y * 2 * y + 2 * z * 2 * z);\n target.y = 1.0 / 12.0 * mass * (2 * x * 2 * x + 2 * z * 2 * z);\n target.z = 1.0 / 12.0 * mass * (2 * y * 2 * y + 2 * x * 2 * x);\n }\n /**\r\n * @method getPlaneConstantOfFace\r\n * @param {Number} face_i Index of the face\r\n * @return {Number}\r\n */\n\n\n getPlaneConstantOfFace(face_i) {\n const f = this.faces[face_i];\n const n = this.faceNormals[face_i];\n const v = this.vertices[f[0]];\n const c = -n.dot(v);\n return c;\n }\n /**\r\n * Clip a face against a hull.\r\n * @method clipFaceAgainstHull\r\n * @param {Vec3} separatingNormal\r\n * @param {Vec3} posA\r\n * @param {Quaternion} quatA\r\n * @param {Array} worldVertsB1 An array of Vec3 with vertices in the world frame.\r\n * @param {Number} minDist Distance clamping\r\n * @param {Number} maxDist\r\n * @param Array result Array to store resulting contact points in. Will be objects with properties: point, depth, normal. These are represented in world coordinates.\r\n */\n\n\n clipFaceAgainstHull(separatingNormal, posA, quatA, worldVertsB1, minDist, maxDist, result) {\n const faceANormalWS = new Vec3();\n const edge0 = new Vec3();\n const WorldEdge0 = new Vec3();\n const worldPlaneAnormal1 = new Vec3();\n const planeNormalWS1 = new Vec3();\n const worldA1 = new Vec3();\n const localPlaneNormal = new Vec3();\n const planeNormalWS = new Vec3();\n const hullA = this;\n const worldVertsB2 = [];\n const pVtxIn = worldVertsB1;\n const pVtxOut = worldVertsB2;\n let closestFaceA = -1;\n let dmin = Number.MAX_VALUE; // Find the face with normal closest to the separating axis\n\n for (let face = 0; face < hullA.faces.length; face++) {\n faceANormalWS.copy(hullA.faceNormals[face]);\n quatA.vmult(faceANormalWS, faceANormalWS);\n const d = faceANormalWS.dot(separatingNormal);\n\n if (d < dmin) {\n dmin = d;\n closestFaceA = face;\n }\n }\n\n if (closestFaceA < 0) {\n return;\n } // Get the face and construct connected faces\n\n\n const polyA = hullA.faces[closestFaceA];\n polyA.connectedFaces = [];\n\n for (let i = 0; i < hullA.faces.length; i++) {\n for (let j = 0; j < hullA.faces[i].length; j++) {\n if (\n /* Sharing a vertex*/\n polyA.indexOf(hullA.faces[i][j]) !== -1 &&\n /* Not the one we are looking for connections from */\n i !== closestFaceA &&\n /* Not already added */\n polyA.connectedFaces.indexOf(i) === -1) {\n polyA.connectedFaces.push(i);\n }\n }\n } // Clip the polygon to the back of the planes of all faces of hull A,\n // that are adjacent to the witness face\n\n\n const numVerticesA = polyA.length;\n\n for (let i = 0; i < numVerticesA; i++) {\n const a = hullA.vertices[polyA[i]];\n const b = hullA.vertices[polyA[(i + 1) % numVerticesA]];\n a.vsub(b, edge0);\n WorldEdge0.copy(edge0);\n quatA.vmult(WorldEdge0, WorldEdge0);\n posA.vadd(WorldEdge0, WorldEdge0);\n worldPlaneAnormal1.copy(this.faceNormals[closestFaceA]);\n quatA.vmult(worldPlaneAnormal1, worldPlaneAnormal1);\n posA.vadd(worldPlaneAnormal1, worldPlaneAnormal1);\n WorldEdge0.cross(worldPlaneAnormal1, planeNormalWS1);\n planeNormalWS1.negate(planeNormalWS1);\n worldA1.copy(a);\n quatA.vmult(worldA1, worldA1);\n posA.vadd(worldA1, worldA1);\n const otherFace = polyA.connectedFaces[i];\n localPlaneNormal.copy(this.faceNormals[otherFace]);\n const localPlaneEq = this.getPlaneConstantOfFace(otherFace);\n planeNormalWS.copy(localPlaneNormal);\n quatA.vmult(planeNormalWS, planeNormalWS);\n const planeEqWS = localPlaneEq - planeNormalWS.dot(posA); // Clip face against our constructed plane\n\n this.clipFaceAgainstPlane(pVtxIn, pVtxOut, planeNormalWS, planeEqWS); // Throw away all clipped points, but save the remaining until next clip\n\n while (pVtxIn.length) {\n pVtxIn.shift();\n }\n\n while (pVtxOut.length) {\n pVtxIn.push(pVtxOut.shift());\n }\n } // only keep contact points that are behind the witness face\n\n\n localPlaneNormal.copy(this.faceNormals[closestFaceA]);\n const localPlaneEq = this.getPlaneConstantOfFace(closestFaceA);\n planeNormalWS.copy(localPlaneNormal);\n quatA.vmult(planeNormalWS, planeNormalWS);\n const planeEqWS = localPlaneEq - planeNormalWS.dot(posA);\n\n for (let i = 0; i < pVtxIn.length; i++) {\n let depth = planeNormalWS.dot(pVtxIn[i]) + planeEqWS; // ???\n\n if (depth <= minDist) {\n console.log(\"clamped: depth=\" + depth + \" to minDist=\" + minDist);\n depth = minDist;\n }\n\n if (depth <= maxDist) {\n const point = pVtxIn[i];\n\n if (depth <= 1e-6) {\n const p = {\n point,\n normal: planeNormalWS,\n depth\n };\n result.push(p);\n }\n }\n }\n }\n /**\r\n * Clip a face in a hull against the back of a plane.\r\n * @method clipFaceAgainstPlane\r\n * @param {Array} inVertices\r\n * @param {Array} outVertices\r\n * @param {Vec3} planeNormal\r\n * @param {Number} planeConstant The constant in the mathematical plane equation\r\n */\n\n\n clipFaceAgainstPlane(inVertices, outVertices, planeNormal, planeConstant) {\n let n_dot_first;\n let n_dot_last;\n const numVerts = inVertices.length;\n\n if (numVerts < 2) {\n return outVertices;\n }\n\n let firstVertex = inVertices[inVertices.length - 1];\n let lastVertex = inVertices[0];\n n_dot_first = planeNormal.dot(firstVertex) + planeConstant;\n\n for (let vi = 0; vi < numVerts; vi++) {\n lastVertex = inVertices[vi];\n n_dot_last = planeNormal.dot(lastVertex) + planeConstant;\n\n if (n_dot_first < 0) {\n if (n_dot_last < 0) {\n // Start < 0, end < 0, so output lastVertex\n const newv = new Vec3();\n newv.copy(lastVertex);\n outVertices.push(newv);\n } else {\n // Start < 0, end >= 0, so output intersection\n const newv = new Vec3();\n firstVertex.lerp(lastVertex, n_dot_first / (n_dot_first - n_dot_last), newv);\n outVertices.push(newv);\n }\n } else {\n if (n_dot_last < 0) {\n // Start >= 0, end < 0 so output intersection and end\n const newv = new Vec3();\n firstVertex.lerp(lastVertex, n_dot_first / (n_dot_first - n_dot_last), newv);\n outVertices.push(newv);\n outVertices.push(lastVertex);\n }\n }\n\n firstVertex = lastVertex;\n n_dot_first = n_dot_last;\n }\n\n return outVertices;\n } // Updates .worldVertices and sets .worldVerticesNeedsUpdate to false.\n\n\n computeWorldVertices(position, quat) {\n while (this.worldVertices.length < this.vertices.length) {\n this.worldVertices.push(new Vec3());\n }\n\n const verts = this.vertices;\n const worldVerts = this.worldVertices;\n\n for (let i = 0; i !== this.vertices.length; i++) {\n quat.vmult(verts[i], worldVerts[i]);\n position.vadd(worldVerts[i], worldVerts[i]);\n }\n\n this.worldVerticesNeedsUpdate = false;\n }\n\n computeLocalAABB(aabbmin, aabbmax) {\n const vertices = this.vertices;\n aabbmin.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);\n aabbmax.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);\n\n for (let i = 0; i < this.vertices.length; i++) {\n const v = vertices[i];\n\n if (v.x < aabbmin.x) {\n aabbmin.x = v.x;\n } else if (v.x > aabbmax.x) {\n aabbmax.x = v.x;\n }\n\n if (v.y < aabbmin.y) {\n aabbmin.y = v.y;\n } else if (v.y > aabbmax.y) {\n aabbmax.y = v.y;\n }\n\n if (v.z < aabbmin.z) {\n aabbmin.z = v.z;\n } else if (v.z > aabbmax.z) {\n aabbmax.z = v.z;\n }\n }\n }\n /**\r\n * Updates .worldVertices and sets .worldVerticesNeedsUpdate to false.\r\n * @method computeWorldFaceNormals\r\n * @param {Quaternion} quat\r\n */\n\n\n computeWorldFaceNormals(quat) {\n const N = this.faceNormals.length;\n\n while (this.worldFaceNormals.length < N) {\n this.worldFaceNormals.push(new Vec3());\n }\n\n const normals = this.faceNormals;\n const worldNormals = this.worldFaceNormals;\n\n for (let i = 0; i !== N; i++) {\n quat.vmult(normals[i], worldNormals[i]);\n }\n\n this.worldFaceNormalsNeedsUpdate = false;\n }\n /**\r\n * @method updateBoundingSphereRadius\r\n */\n\n\n updateBoundingSphereRadius() {\n // Assume points are distributed with local (0,0,0) as center\n let max2 = 0;\n const verts = this.vertices;\n\n for (let i = 0; i !== verts.length; i++) {\n const norm2 = verts[i].lengthSquared();\n\n if (norm2 > max2) {\n max2 = norm2;\n }\n }\n\n this.boundingSphereRadius = Math.sqrt(max2);\n }\n /**\r\n * @method calculateWorldAABB\r\n * @param {Vec3} pos\r\n * @param {Quaternion} quat\r\n * @param {Vec3} min\r\n * @param {Vec3} max\r\n */\n\n\n calculateWorldAABB(pos, quat, min, max) {\n const verts = this.vertices;\n let minx;\n let miny;\n let minz;\n let maxx;\n let maxy;\n let maxz;\n let tempWorldVertex = new Vec3();\n\n for (let i = 0; i < verts.length; i++) {\n tempWorldVertex.copy(verts[i]);\n quat.vmult(tempWorldVertex, tempWorldVertex);\n pos.vadd(tempWorldVertex, tempWorldVertex);\n const v = tempWorldVertex;\n\n if (minx === undefined || v.x < minx) {\n minx = v.x;\n }\n\n if (maxx === undefined || v.x > maxx) {\n maxx = v.x;\n }\n\n if (miny === undefined || v.y < miny) {\n miny = v.y;\n }\n\n if (maxy === undefined || v.y > maxy) {\n maxy = v.y;\n }\n\n if (minz === undefined || v.z < minz) {\n minz = v.z;\n }\n\n if (maxz === undefined || v.z > maxz) {\n maxz = v.z;\n }\n }\n\n min.set(minx, miny, minz);\n max.set(maxx, maxy, maxz);\n }\n /**\r\n * Get approximate convex volume\r\n * @method volume\r\n * @return {Number}\r\n */\n\n\n volume() {\n return 4.0 * Math.PI * this.boundingSphereRadius / 3.0;\n }\n /**\r\n * Get an average of all the vertices positions\r\n * @method getAveragePointLocal\r\n * @param {Vec3} target\r\n * @return {Vec3}\r\n */\n\n\n getAveragePointLocal(target = new Vec3()) {\n const verts = this.vertices;\n\n for (let i = 0; i < verts.length; i++) {\n target.vadd(verts[i], target);\n }\n\n target.scale(1 / verts.length, target);\n return target;\n }\n /**\r\n * Transform all local points. Will change the .vertices\r\n * @method transformAllPoints\r\n * @param {Vec3} offset\r\n * @param {Quaternion} quat\r\n */\n\n\n transformAllPoints(offset, quat) {\n const n = this.vertices.length;\n const verts = this.vertices; // Apply rotation\n\n if (quat) {\n // Rotate vertices\n for (let i = 0; i < n; i++) {\n const v = verts[i];\n quat.vmult(v, v);\n } // Rotate face normals\n\n\n for (let i = 0; i < this.faceNormals.length; i++) {\n const v = this.faceNormals[i];\n quat.vmult(v, v);\n }\n /*\r\n // Rotate edges\r\n for(let i=0; i 0 || r1 > 0 && r2 < 0) {\n return false; // Encountered some other sign. Exit.\n }\n } // If we got here, all dot products were of the same sign.\n\n\n return -1;\n }\n\n}\n/**\r\n * Get face normal given 3 vertices\r\n * @static\r\n * @method computeNormal\r\n * @param {Vec3} va\r\n * @param {Vec3} vb\r\n * @param {Vec3} vc\r\n * @param {Vec3} target\r\n */\n\nConvexPolyhedron.computeNormal = (va, vb, vc, target) => {\n const cb = new Vec3();\n const ab = new Vec3();\n vb.vsub(va, ab);\n vc.vsub(vb, cb);\n cb.cross(ab, target);\n\n if (!target.isZero()) {\n target.normalize();\n }\n};\n\nconst maxminA = [];\nconst maxminB = [];\n/**\r\n * Get max and min dot product of a convex hull at position (pos,quat) projected onto an axis.\r\n * Results are saved in the array maxmin.\r\n * @static\r\n * @method project\r\n * @param {ConvexPolyhedron} hull\r\n * @param {Vec3} axis\r\n * @param {Vec3} pos\r\n * @param {Quaternion} quat\r\n * @param {array} result result[0] and result[1] will be set to maximum and minimum, respectively.\r\n */\n\nConvexPolyhedron.project = (shape, axis, pos, quat, result) => {\n const n = shape.vertices.length;\n const localAxis = new Vec3();\n let max = 0;\n let min = 0;\n const localOrigin = new Vec3();\n const vs = shape.vertices;\n localOrigin.setZero(); // Transform the axis to local\n\n Transform.vectorToLocalFrame(pos, quat, axis, localAxis);\n Transform.pointToLocalFrame(pos, quat, localOrigin, localOrigin);\n const add = localOrigin.dot(localAxis);\n min = max = vs[0].dot(localAxis);\n\n for (let i = 1; i < n; i++) {\n const val = vs[i].dot(localAxis);\n\n if (val > max) {\n max = val;\n }\n\n if (val < min) {\n min = val;\n }\n }\n\n min -= add;\n max -= add;\n\n if (min > max) {\n // Inconsistent - swap\n const temp = min;\n min = max;\n max = temp;\n } // Output\n\n\n result[0] = max;\n result[1] = min;\n};\n\n/**\n * A 3d box shape.\n * @class Box\n * @constructor\n * @param {Vec3} halfExtents\n * @author schteppe\n * @extends Shape\n */\nclass Box extends Shape {\n // Used by the contact generator to make contacts with other convex polyhedra for example.\n constructor(halfExtents) {\n super({\n type: Shape.types.BOX\n });\n this.halfExtents = halfExtents;\n this.convexPolyhedronRepresentation = null;\n this.updateConvexPolyhedronRepresentation();\n this.updateBoundingSphereRadius();\n }\n /**\n * Updates the local convex polyhedron representation used for some collisions.\n * @method updateConvexPolyhedronRepresentation\n */\n\n\n updateConvexPolyhedronRepresentation() {\n const sx = this.halfExtents.x;\n const sy = this.halfExtents.y;\n const sz = this.halfExtents.z;\n const V = Vec3;\n const vertices = [new V(-sx, -sy, -sz), new V(sx, -sy, -sz), new V(sx, sy, -sz), new V(-sx, sy, -sz), new V(-sx, -sy, sz), new V(sx, -sy, sz), new V(sx, sy, sz), new V(-sx, sy, sz)];\n const faces = [[3, 2, 1, 0], // -z\n [4, 5, 6, 7], // +z\n [5, 4, 0, 1], // -y\n [2, 3, 7, 6], // +y\n [0, 4, 7, 3], // -x\n [1, 2, 6, 5] // +x\n ];\n const axes = [new V(0, 0, 1), new V(0, 1, 0), new V(1, 0, 0)];\n const h = new ConvexPolyhedron({\n vertices,\n faces,\n axes\n });\n this.convexPolyhedronRepresentation = h;\n h.material = this.material;\n }\n /**\n * @method calculateLocalInertia\n * @param {Number} mass\n * @param {Vec3} target\n * @return {Vec3}\n */\n\n\n calculateLocalInertia(mass, target = new Vec3()) {\n Box.calculateInertia(this.halfExtents, mass, target);\n return target;\n }\n /**\n * Get the box 6 side normals\n * @method getSideNormals\n * @param {array} sixTargetVectors An array of 6 vectors, to store the resulting side normals in.\n * @param {Quaternion} quat Orientation to apply to the normal vectors. If not provided, the vectors will be in respect to the local frame.\n * @return {array}\n */\n\n\n getSideNormals(sixTargetVectors, quat) {\n const sides = sixTargetVectors;\n const ex = this.halfExtents;\n sides[0].set(ex.x, 0, 0);\n sides[1].set(0, ex.y, 0);\n sides[2].set(0, 0, ex.z);\n sides[3].set(-ex.x, 0, 0);\n sides[4].set(0, -ex.y, 0);\n sides[5].set(0, 0, -ex.z);\n\n if (quat !== undefined) {\n for (let i = 0; i !== sides.length; i++) {\n quat.vmult(sides[i], sides[i]);\n }\n }\n\n return sides;\n }\n\n volume() {\n return 8.0 * this.halfExtents.x * this.halfExtents.y * this.halfExtents.z;\n }\n\n updateBoundingSphereRadius() {\n this.boundingSphereRadius = this.halfExtents.length();\n }\n\n forEachWorldCorner(pos, quat, callback) {\n const e = this.halfExtents;\n const corners = [[e.x, e.y, e.z], [-e.x, e.y, e.z], [-e.x, -e.y, e.z], [-e.x, -e.y, -e.z], [e.x, -e.y, -e.z], [e.x, e.y, -e.z], [-e.x, e.y, -e.z], [e.x, -e.y, e.z]];\n\n for (let i = 0; i < corners.length; i++) {\n worldCornerTempPos.set(corners[i][0], corners[i][1], corners[i][2]);\n quat.vmult(worldCornerTempPos, worldCornerTempPos);\n pos.vadd(worldCornerTempPos, worldCornerTempPos);\n callback(worldCornerTempPos.x, worldCornerTempPos.y, worldCornerTempPos.z);\n }\n }\n\n calculateWorldAABB(pos, quat, min, max) {\n const e = this.halfExtents;\n worldCornersTemp[0].set(e.x, e.y, e.z);\n worldCornersTemp[1].set(-e.x, e.y, e.z);\n worldCornersTemp[2].set(-e.x, -e.y, e.z);\n worldCornersTemp[3].set(-e.x, -e.y, -e.z);\n worldCornersTemp[4].set(e.x, -e.y, -e.z);\n worldCornersTemp[5].set(e.x, e.y, -e.z);\n worldCornersTemp[6].set(-e.x, e.y, -e.z);\n worldCornersTemp[7].set(e.x, -e.y, e.z);\n const wc = worldCornersTemp[0];\n quat.vmult(wc, wc);\n pos.vadd(wc, wc);\n max.copy(wc);\n min.copy(wc);\n\n for (let i = 1; i < 8; i++) {\n const wc = worldCornersTemp[i];\n quat.vmult(wc, wc);\n pos.vadd(wc, wc);\n const x = wc.x;\n const y = wc.y;\n const z = wc.z;\n\n if (x > max.x) {\n max.x = x;\n }\n\n if (y > max.y) {\n max.y = y;\n }\n\n if (z > max.z) {\n max.z = z;\n }\n\n if (x < min.x) {\n min.x = x;\n }\n\n if (y < min.y) {\n min.y = y;\n }\n\n if (z < min.z) {\n min.z = z;\n }\n } // Get each axis max\n // min.set(Infinity,Infinity,Infinity);\n // max.set(-Infinity,-Infinity,-Infinity);\n // this.forEachWorldCorner(pos,quat,function(x,y,z){\n // if(x > max.x){\n // max.x = x;\n // }\n // if(y > max.y){\n // max.y = y;\n // }\n // if(z > max.z){\n // max.z = z;\n // }\n // if(x < min.x){\n // min.x = x;\n // }\n // if(y < min.y){\n // min.y = y;\n // }\n // if(z < min.z){\n // min.z = z;\n // }\n // });\n\n }\n\n}\n\nBox.calculateInertia = (halfExtents, mass, target) => {\n const e = halfExtents;\n target.x = 1.0 / 12.0 * mass * (2 * e.y * 2 * e.y + 2 * e.z * 2 * e.z);\n target.y = 1.0 / 12.0 * mass * (2 * e.x * 2 * e.x + 2 * e.z * 2 * e.z);\n target.z = 1.0 / 12.0 * mass * (2 * e.y * 2 * e.y + 2 * e.x * 2 * e.x);\n};\n\nconst worldCornerTempPos = new Vec3();\nconst worldCornersTemp = [new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3()];\n\nconst BODY_TYPES = {\n DYNAMIC: 1,\n STATIC: 2,\n KINEMATIC: 4\n};\nconst BODY_SLEEP_STATES = {\n AWAKE: 0,\n SLEEPY: 1,\n SLEEPING: 2\n};\n\n/**\r\n * Base class for all body types.\r\n * @class Body\r\n * @constructor\r\n * @extends EventTarget\r\n * @param {object} [options]\r\n * @param {Vec3} [options.position]\r\n * @param {Vec3} [options.velocity]\r\n * @param {Vec3} [options.angularVelocity]\r\n * @param {Quaternion} [options.quaternion]\r\n * @param {number} [options.mass]\r\n * @param {Material} [options.material]\r\n * @param {number} [options.type]\r\n * @param {number} [options.linearDamping=0.01]\r\n * @param {number} [options.angularDamping=0.01]\r\n * @param {boolean} [options.allowSleep=true]\r\n * @param {number} [options.sleepSpeedLimit=0.1]\r\n * @param {number} [options.sleepTimeLimit=1]\r\n * @param {number} [options.collisionFilterGroup=1]\r\n * @param {number} [options.collisionFilterMask=-1]\r\n * @param {boolean} [options.fixedRotation=false]\r\n * @param {Vec3} [options.linearFactor]\r\n * @param {Vec3} [options.angularFactor]\r\n * @param {Shape} [options.shape]\r\n * @example\r\n * const body = new Body({\r\n * mass: 1\r\n * });\r\n * const shape = new Sphere(1);\r\n * body.addShape(shape);\r\n * world.addBody(body);\r\n */\nclass Body extends EventTarget {\n // Position of body in World.bodies. Updated by World and used in ArrayCollisionMatrix.\n // Reference to the world the body is living in.\n // Callback function that is used BEFORE stepping the system. Use it to apply forces, for example. Inside the function, \"this\" will refer to this Body object. Deprecated - use World events instead.\n // Callback function that is used AFTER stepping the system. Inside the function, \"this\" will refer to this Body object. Deprecated - use World events instead.\n // Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled - i.e. \"collide\" events will be raised, but forces will not be altered.\n // World space position of the body.\n // Interpolated position of the body.\n // Initial position of the body.\n // World space velocity of the body.\n // Linear force on the body in world space.\n // One of: Body.DYNAMIC, Body.STATIC and Body.KINEMATIC.\n // If true, the body will automatically fall to sleep.\n // Current sleep state.\n // If the speed (the norm of the velocity) is smaller than this value, the body is considered sleepy.\n // If the body has been sleepy for this sleepTimeLimit seconds, it is considered sleeping.\n // World space rotational force on the body, around center of mass.\n // World space orientation of the body.\n // Interpolated orientation of the body.\n // Angular velocity of the body, in world space. Think of the angular velocity as a vector, which the body rotates around. The length of this vector determines how fast (in radians per second) the body rotates.\n // Position of each Shape in the body, given in local Body space.\n // Orientation of each Shape, given in local Body space.\n // Set to true if you don't want the body to rotate. Make sure to run .updateMassProperties() after changing this.\n // Use this property to limit the motion along any world axis. (1,1,1) will allow motion along all axes while (0,0,0) allows none.\n // Use this property to limit the rotational motion along any world axis. (1,1,1) will allow rotation along all axes while (0,0,0) allows none.\n // World space bounding box of the body and its shapes.\n // Indicates if the AABB needs to be updated before use.\n // Total bounding radius of the Body including its shapes, relative to body.position.\n constructor(options = {}) {\n super();\n this.id = Body.idCounter++;\n this.index = -1;\n this.world = null;\n this.preStep = null;\n this.postStep = null;\n this.vlambda = new Vec3();\n this.collisionFilterGroup = typeof options.collisionFilterGroup === 'number' ? options.collisionFilterGroup : 1;\n this.collisionFilterMask = typeof options.collisionFilterMask === 'number' ? options.collisionFilterMask : -1;\n this.collisionResponse = typeof options.collisionResponse === 'boolean' ? options.collisionResponse : true;\n this.position = new Vec3();\n this.previousPosition = new Vec3();\n this.interpolatedPosition = new Vec3();\n this.initPosition = new Vec3();\n\n if (options.position) {\n this.position.copy(options.position);\n this.previousPosition.copy(options.position);\n this.interpolatedPosition.copy(options.position);\n this.initPosition.copy(options.position);\n }\n\n this.velocity = new Vec3();\n\n if (options.velocity) {\n this.velocity.copy(options.velocity);\n }\n\n this.initVelocity = new Vec3();\n this.force = new Vec3();\n const mass = typeof options.mass === 'number' ? options.mass : 0;\n this.mass = mass;\n this.invMass = mass > 0 ? 1.0 / mass : 0;\n this.material = options.material || null;\n this.linearDamping = typeof options.linearDamping === 'number' ? options.linearDamping : 0.01;\n this.type = mass <= 0.0 ? Body.STATIC : Body.DYNAMIC;\n\n if (typeof options.type === typeof Body.STATIC) {\n this.type = options.type;\n }\n\n this.allowSleep = typeof options.allowSleep !== 'undefined' ? options.allowSleep : true;\n this.sleepState = 0;\n this.sleepSpeedLimit = typeof options.sleepSpeedLimit !== 'undefined' ? options.sleepSpeedLimit : 0.1;\n this.sleepTimeLimit = typeof options.sleepTimeLimit !== 'undefined' ? options.sleepTimeLimit : 1;\n this.timeLastSleepy = 0;\n this.wakeUpAfterNarrowphase = false;\n this.torque = new Vec3();\n this.quaternion = new Quaternion();\n this.initQuaternion = new Quaternion();\n this.previousQuaternion = new Quaternion();\n this.interpolatedQuaternion = new Quaternion();\n\n if (options.quaternion) {\n this.quaternion.copy(options.quaternion);\n this.initQuaternion.copy(options.quaternion);\n this.previousQuaternion.copy(options.quaternion);\n this.interpolatedQuaternion.copy(options.quaternion);\n }\n\n this.angularVelocity = new Vec3();\n\n if (options.angularVelocity) {\n this.angularVelocity.copy(options.angularVelocity);\n }\n\n this.initAngularVelocity = new Vec3();\n this.shapes = [];\n this.shapeOffsets = [];\n this.shapeOrientations = [];\n this.inertia = new Vec3();\n this.invInertia = new Vec3();\n this.invInertiaWorld = new Mat3();\n this.invMassSolve = 0;\n this.invInertiaSolve = new Vec3();\n this.invInertiaWorldSolve = new Mat3();\n this.fixedRotation = typeof options.fixedRotation !== 'undefined' ? options.fixedRotation : false;\n this.angularDamping = typeof options.angularDamping !== 'undefined' ? options.angularDamping : 0.01;\n this.linearFactor = new Vec3(1, 1, 1);\n\n if (options.linearFactor) {\n this.linearFactor.copy(options.linearFactor);\n }\n\n this.angularFactor = new Vec3(1, 1, 1);\n\n if (options.angularFactor) {\n this.angularFactor.copy(options.angularFactor);\n }\n\n this.aabb = new AABB();\n this.aabbNeedsUpdate = true;\n this.boundingRadius = 0;\n this.wlambda = new Vec3();\n\n if (options.shape) {\n this.addShape(options.shape);\n }\n\n this.updateMassProperties();\n }\n /**\r\n * Wake the body up.\r\n * @method wakeUp\r\n */\n\n\n wakeUp() {\n const prevState = this.sleepState;\n this.sleepState = 0;\n this.wakeUpAfterNarrowphase = false;\n\n if (prevState === Body.SLEEPING) {\n this.dispatchEvent(Body.wakeupEvent);\n }\n }\n /**\r\n * Force body sleep\r\n * @method sleep\r\n */\n\n\n sleep() {\n this.sleepState = Body.SLEEPING;\n this.velocity.set(0, 0, 0);\n this.angularVelocity.set(0, 0, 0);\n this.wakeUpAfterNarrowphase = false;\n }\n /**\r\n * Called every timestep to update internal sleep timer and change sleep state if needed.\r\n * @method sleepTick\r\n * @param {Number} time The world time in seconds\r\n */\n\n\n sleepTick(time) {\n if (this.allowSleep) {\n const sleepState = this.sleepState;\n const speedSquared = this.velocity.lengthSquared() + this.angularVelocity.lengthSquared();\n const speedLimitSquared = this.sleepSpeedLimit ** 2;\n\n if (sleepState === Body.AWAKE && speedSquared < speedLimitSquared) {\n this.sleepState = Body.SLEEPY; // Sleepy\n\n this.timeLastSleepy = time;\n this.dispatchEvent(Body.sleepyEvent);\n } else if (sleepState === Body.SLEEPY && speedSquared > speedLimitSquared) {\n this.wakeUp(); // Wake up\n } else if (sleepState === Body.SLEEPY && time - this.timeLastSleepy > this.sleepTimeLimit) {\n this.sleep(); // Sleeping\n\n this.dispatchEvent(Body.sleepEvent);\n }\n }\n }\n /**\r\n * If the body is sleeping, it should be immovable / have infinite mass during solve. We solve it by having a separate \"solve mass\".\r\n * @method updateSolveMassProperties\r\n */\n\n\n updateSolveMassProperties() {\n if (this.sleepState === Body.SLEEPING || this.type === Body.KINEMATIC) {\n this.invMassSolve = 0;\n this.invInertiaSolve.setZero();\n this.invInertiaWorldSolve.setZero();\n } else {\n this.invMassSolve = this.invMass;\n this.invInertiaSolve.copy(this.invInertia);\n this.invInertiaWorldSolve.copy(this.invInertiaWorld);\n }\n }\n /**\r\n * Convert a world point to local body frame.\r\n * @method pointToLocalFrame\r\n * @param {Vec3} worldPoint\r\n * @param {Vec3} result\r\n * @return {Vec3}\r\n */\n\n\n pointToLocalFrame(worldPoint, result = new Vec3()) {\n worldPoint.vsub(this.position, result);\n this.quaternion.conjugate().vmult(result, result);\n return result;\n }\n /**\r\n * Convert a world vector to local body frame.\r\n * @method vectorToLocalFrame\r\n * @param {Vec3} worldPoint\r\n * @param {Vec3} result\r\n * @return {Vec3}\r\n */\n\n\n vectorToLocalFrame(worldVector, result = new Vec3()) {\n this.quaternion.conjugate().vmult(worldVector, result);\n return result;\n }\n /**\r\n * Convert a local body point to world frame.\r\n * @method pointToWorldFrame\r\n * @param {Vec3} localPoint\r\n * @param {Vec3} result\r\n * @return {Vec3}\r\n */\n\n\n pointToWorldFrame(localPoint, result = new Vec3()) {\n this.quaternion.vmult(localPoint, result);\n result.vadd(this.position, result);\n return result;\n }\n /**\r\n * Convert a local body point to world frame.\r\n * @method vectorToWorldFrame\r\n * @param {Vec3} localVector\r\n * @param {Vec3} result\r\n * @return {Vec3}\r\n */\n\n\n vectorToWorldFrame(localVector, result = new Vec3()) {\n this.quaternion.vmult(localVector, result);\n return result;\n }\n /**\r\n * Add a shape to the body with a local offset and orientation.\r\n * @method addShape\r\n * @param {Shape} shape\r\n * @param {Vec3} [_offset]\r\n * @param {Quaternion} [_orientation]\r\n * @return {Body} The body object, for chainability.\r\n */\n\n\n addShape(shape, _offset, _orientation) {\n const offset = new Vec3();\n const orientation = new Quaternion();\n\n if (_offset) {\n offset.copy(_offset);\n }\n\n if (_orientation) {\n orientation.copy(_orientation);\n }\n\n this.shapes.push(shape);\n this.shapeOffsets.push(offset);\n this.shapeOrientations.push(orientation);\n this.updateMassProperties();\n this.updateBoundingRadius();\n this.aabbNeedsUpdate = true;\n shape.body = this;\n return this;\n }\n /**\r\n * Update the bounding radius of the body. Should be done if any of the shapes are changed.\r\n * @method updateBoundingRadius\r\n */\n\n\n updateBoundingRadius() {\n const shapes = this.shapes;\n const shapeOffsets = this.shapeOffsets;\n const N = shapes.length;\n let radius = 0;\n\n for (let i = 0; i !== N; i++) {\n const shape = shapes[i];\n shape.updateBoundingSphereRadius();\n const offset = shapeOffsets[i].length();\n const r = shape.boundingSphereRadius;\n\n if (offset + r > radius) {\n radius = offset + r;\n }\n }\n\n this.boundingRadius = radius;\n }\n /**\r\n * Updates the .aabb\r\n * @method computeAABB\r\n * @todo rename to updateAABB()\r\n */\n\n\n computeAABB() {\n const shapes = this.shapes;\n const shapeOffsets = this.shapeOffsets;\n const shapeOrientations = this.shapeOrientations;\n const N = shapes.length;\n const offset = tmpVec;\n const orientation = tmpQuat$1;\n const bodyQuat = this.quaternion;\n const aabb = this.aabb;\n const shapeAABB = computeAABB_shapeAABB;\n\n for (let i = 0; i !== N; i++) {\n const shape = shapes[i]; // Get shape world position\n\n bodyQuat.vmult(shapeOffsets[i], offset);\n offset.vadd(this.position, offset); // Get shape world quaternion\n\n bodyQuat.mult(shapeOrientations[i], orientation); // Get shape AABB\n\n shape.calculateWorldAABB(offset, orientation, shapeAABB.lowerBound, shapeAABB.upperBound);\n\n if (i === 0) {\n aabb.copy(shapeAABB);\n } else {\n aabb.extend(shapeAABB);\n }\n }\n\n this.aabbNeedsUpdate = false;\n }\n /**\r\n * Update .inertiaWorld and .invInertiaWorld\r\n * @method updateInertiaWorld\r\n */\n\n\n updateInertiaWorld(force) {\n const I = this.invInertia;\n\n if (I.x === I.y && I.y === I.z && !force) ; else {\n const m1 = uiw_m1;\n const m2 = uiw_m2;\n m1.setRotationFromQuaternion(this.quaternion);\n m1.transpose(m2);\n m1.scale(I, m1);\n m1.mmult(m2, this.invInertiaWorld);\n }\n }\n\n applyForce(force, relativePoint) {\n if (this.type !== Body.DYNAMIC) {\n // Needed?\n return;\n } // Compute produced rotational force\n\n\n const rotForce = Body_applyForce_rotForce;\n relativePoint.cross(force, rotForce); // Add linear force\n\n this.force.vadd(force, this.force); // Add rotational force\n\n this.torque.vadd(rotForce, this.torque);\n }\n\n applyLocalForce(localForce, localPoint) {\n if (this.type !== Body.DYNAMIC) {\n return;\n }\n\n const worldForce = Body_applyLocalForce_worldForce;\n const relativePointWorld = Body_applyLocalForce_relativePointWorld; // Transform the force vector to world space\n\n this.vectorToWorldFrame(localForce, worldForce);\n this.vectorToWorldFrame(localPoint, relativePointWorld);\n this.applyForce(worldForce, relativePointWorld);\n }\n\n applyImpulse(impulse, relativePoint) {\n if (this.type !== Body.DYNAMIC) {\n return;\n } // Compute point position relative to the body center\n\n\n const r = relativePoint; // Compute produced central impulse velocity\n\n const velo = Body_applyImpulse_velo;\n velo.copy(impulse);\n velo.scale(this.invMass, velo); // Add linear impulse\n\n this.velocity.vadd(velo, this.velocity); // Compute produced rotational impulse velocity\n\n const rotVelo = Body_applyImpulse_rotVelo;\n r.cross(impulse, rotVelo);\n /*\r\n rotVelo.x *= this.invInertia.x;\r\n rotVelo.y *= this.invInertia.y;\r\n rotVelo.z *= this.invInertia.z;\r\n */\n\n this.invInertiaWorld.vmult(rotVelo, rotVelo); // Add rotational Impulse\n\n this.angularVelocity.vadd(rotVelo, this.angularVelocity);\n }\n\n applyLocalImpulse(localImpulse, localPoint) {\n if (this.type !== Body.DYNAMIC) {\n return;\n }\n\n const worldImpulse = Body_applyLocalImpulse_worldImpulse;\n const relativePointWorld = Body_applyLocalImpulse_relativePoint; // Transform the force vector to world space\n\n this.vectorToWorldFrame(localImpulse, worldImpulse);\n this.vectorToWorldFrame(localPoint, relativePointWorld);\n this.applyImpulse(worldImpulse, relativePointWorld);\n }\n /**\r\n * Should be called whenever you change the body shape or mass.\r\n * @method updateMassProperties\r\n */\n\n\n updateMassProperties() {\n const halfExtents = Body_updateMassProperties_halfExtents;\n this.invMass = this.mass > 0 ? 1.0 / this.mass : 0;\n const I = this.inertia;\n const fixed = this.fixedRotation; // Approximate with AABB box\n\n this.computeAABB();\n halfExtents.set((this.aabb.upperBound.x - this.aabb.lowerBound.x) / 2, (this.aabb.upperBound.y - this.aabb.lowerBound.y) / 2, (this.aabb.upperBound.z - this.aabb.lowerBound.z) / 2);\n Box.calculateInertia(halfExtents, this.mass, I);\n this.invInertia.set(I.x > 0 && !fixed ? 1.0 / I.x : 0, I.y > 0 && !fixed ? 1.0 / I.y : 0, I.z > 0 && !fixed ? 1.0 / I.z : 0);\n this.updateInertiaWorld(true);\n }\n /**\r\n * Get world velocity of a point in the body.\r\n * @method getVelocityAtWorldPoint\r\n * @param {Vec3} worldPoint\r\n * @param {Vec3} result\r\n * @return {Vec3} The result vector.\r\n */\n\n\n getVelocityAtWorldPoint(worldPoint, result) {\n const r = new Vec3();\n worldPoint.vsub(this.position, r);\n this.angularVelocity.cross(r, result);\n this.velocity.vadd(result, result);\n return result;\n }\n /**\r\n * Move the body forward in time.\r\n * @param {number} dt Time step\r\n * @param {boolean} quatNormalize Set to true to normalize the body quaternion\r\n * @param {boolean} quatNormalizeFast If the quaternion should be normalized using \"fast\" quaternion normalization\r\n */\n\n\n integrate(dt, quatNormalize, quatNormalizeFast) {\n // Save previous position\n this.previousPosition.copy(this.position);\n this.previousQuaternion.copy(this.quaternion);\n\n if (!(this.type === Body.DYNAMIC || this.type === Body.KINEMATIC) || this.sleepState === Body.SLEEPING) {\n // Only for dynamic\n return;\n }\n\n const velo = this.velocity;\n const angularVelo = this.angularVelocity;\n const pos = this.position;\n const force = this.force;\n const torque = this.torque;\n const quat = this.quaternion;\n const invMass = this.invMass;\n const invInertia = this.invInertiaWorld;\n const linearFactor = this.linearFactor;\n const iMdt = invMass * dt;\n velo.x += force.x * iMdt * linearFactor.x;\n velo.y += force.y * iMdt * linearFactor.y;\n velo.z += force.z * iMdt * linearFactor.z;\n const e = invInertia.elements;\n const angularFactor = this.angularFactor;\n const tx = torque.x * angularFactor.x;\n const ty = torque.y * angularFactor.y;\n const tz = torque.z * angularFactor.z;\n angularVelo.x += dt * (e[0] * tx + e[1] * ty + e[2] * tz);\n angularVelo.y += dt * (e[3] * tx + e[4] * ty + e[5] * tz);\n angularVelo.z += dt * (e[6] * tx + e[7] * ty + e[8] * tz); // Use new velocity - leap frog\n\n pos.x += velo.x * dt;\n pos.y += velo.y * dt;\n pos.z += velo.z * dt;\n quat.integrate(this.angularVelocity, dt, this.angularFactor, quat);\n\n if (quatNormalize) {\n if (quatNormalizeFast) {\n quat.normalizeFast();\n } else {\n quat.normalize();\n }\n }\n\n this.aabbNeedsUpdate = true; // Update world inertia\n\n this.updateInertiaWorld();\n }\n\n}\n/**\r\n * Dispatched after two bodies collide. This event is dispatched on each\r\n * of the two bodies involved in the collision.\r\n * @event collide\r\n * @param {Body} body The body that was involved in the collision.\r\n * @param {ContactEquation} contact The details of the collision.\r\n */\n\nBody.COLLIDE_EVENT_NAME = 'collide';\n/**\r\n * A dynamic body is fully simulated. Can be moved manually by the user, but normally they move according to forces. A dynamic body can collide with all body types. A dynamic body always has finite, non-zero mass.\r\n * @static\r\n * @property DYNAMIC\r\n * @type {Number}\r\n */\n\nBody.DYNAMIC = 1;\n/**\r\n * A static body does not move during simulation and behaves as if it has infinite mass. Static bodies can be moved manually by setting the position of the body. The velocity of a static body is always zero. Static bodies do not collide with other static or kinematic bodies.\r\n * @static\r\n * @property STATIC\r\n * @type {Number}\r\n */\n\nBody.STATIC = 2;\n/**\r\n * A kinematic body moves under simulation according to its velocity. They do not respond to forces. They can be moved manually, but normally a kinematic body is moved by setting its velocity. A kinematic body behaves as if it has infinite mass. Kinematic bodies do not collide with other static or kinematic bodies.\r\n * @static\r\n * @property KINEMATIC\r\n * @type {Number}\r\n */\n\nBody.KINEMATIC = 4;\n/**\r\n * @static\r\n * @property AWAKE\r\n * @type {number}\r\n */\n\nBody.AWAKE = BODY_SLEEP_STATES.AWAKE;\nBody.SLEEPY = BODY_SLEEP_STATES.SLEEPY;\nBody.SLEEPING = BODY_SLEEP_STATES.SLEEPING;\nBody.idCounter = 0;\n/**\r\n * Dispatched after a sleeping body has woken up.\r\n * @event wakeup\r\n */\n\nBody.wakeupEvent = {\n type: 'wakeup'\n};\n/**\r\n * Dispatched after a body has gone in to the sleepy state.\r\n * @event sleepy\r\n */\n\nBody.sleepyEvent = {\n type: 'sleepy'\n};\n/**\r\n * Dispatched after a body has fallen asleep.\r\n * @event sleep\r\n */\n\nBody.sleepEvent = {\n type: 'sleep'\n};\nconst tmpVec = new Vec3();\nconst tmpQuat$1 = new Quaternion();\nconst computeAABB_shapeAABB = new AABB();\nconst uiw_m1 = new Mat3();\nconst uiw_m2 = new Mat3();\n/**\r\n * Apply force to a world point. This could for example be a point on the Body surface. Applying force this way will add to Body.force and Body.torque.\r\n * @method applyForce\r\n * @param {Vec3} force The amount of force to add.\r\n * @param {Vec3} relativePoint A point relative to the center of mass to apply the force on.\r\n */\n\nconst Body_applyForce_rotForce = new Vec3();\n/**\r\n * Apply force to a local point in the body.\r\n * @method applyLocalForce\r\n * @param {Vec3} force The force vector to apply, defined locally in the body frame.\r\n * @param {Vec3} localPoint A local point in the body to apply the force on.\r\n */\n\nconst Body_applyLocalForce_worldForce = new Vec3();\nconst Body_applyLocalForce_relativePointWorld = new Vec3();\n/**\r\n * Apply impulse to a world point. This could for example be a point on the Body surface. An impulse is a force added to a body during a short period of time (impulse = force * time). Impulses will be added to Body.velocity and Body.angularVelocity.\r\n * @method applyImpulse\r\n * @param {Vec3} impulse The amount of impulse to add.\r\n * @param {Vec3} relativePoint A point relative to the center of mass to apply the force on.\r\n */\n\nconst Body_applyImpulse_velo = new Vec3();\nconst Body_applyImpulse_rotVelo = new Vec3();\n/**\r\n * Apply locally-defined impulse to a local point in the body.\r\n * @method applyLocalImpulse\r\n * @param {Vec3} force The force vector to apply, defined locally in the body frame.\r\n * @param {Vec3} localPoint A local point in the body to apply the force on.\r\n */\n\nconst Body_applyLocalImpulse_worldImpulse = new Vec3();\nconst Body_applyLocalImpulse_relativePoint = new Vec3();\nconst Body_updateMassProperties_halfExtents = new Vec3();\n\n/**\n * Base class for broadphase implementations\n * @class Broadphase\n * @constructor\n * @author schteppe\n */\nclass Broadphase {\n // The world to search for collisions in.\n // If set to true, the broadphase uses bounding boxes for intersection test, else it uses bounding spheres.\n // Set to true if the objects in the world moved.\n constructor() {\n this.world = null;\n this.useBoundingBoxes = false;\n this.dirty = true;\n }\n /**\n * Get the collision pairs from the world\n * @method collisionPairs\n * @param {World} world The world to search in\n * @param {Array} p1 Empty array to be filled with body objects\n * @param {Array} p2 Empty array to be filled with body objects\n */\n\n\n collisionPairs(world, p1, p2) {\n throw new Error('collisionPairs not implemented for this BroadPhase class!');\n }\n /**\n * Check if a body pair needs to be intersection tested at all.\n * @method needBroadphaseCollision\n * @param {Body} bodyA\n * @param {Body} bodyB\n * @return {bool}\n */\n\n\n needBroadphaseCollision(bodyA, bodyB) {\n // Check collision filter masks\n if ((bodyA.collisionFilterGroup & bodyB.collisionFilterMask) === 0 || (bodyB.collisionFilterGroup & bodyA.collisionFilterMask) === 0) {\n return false;\n } // Check types\n\n\n if (((bodyA.type & Body.STATIC) !== 0 || bodyA.sleepState === Body.SLEEPING) && ((bodyB.type & Body.STATIC) !== 0 || bodyB.sleepState === Body.SLEEPING)) {\n // Both bodies are static or sleeping. Skip.\n return false;\n }\n\n return true;\n }\n /**\n * Check if the bounding volumes of two bodies intersect.\n * @method intersectionTest\n * @param {Body} bodyA\n * @param {Body} bodyB\n * @param {array} pairs1\n * @param {array} pairs2\n */\n\n\n intersectionTest(bodyA, bodyB, pairs1, pairs2) {\n if (this.useBoundingBoxes) {\n this.doBoundingBoxBroadphase(bodyA, bodyB, pairs1, pairs2);\n } else {\n this.doBoundingSphereBroadphase(bodyA, bodyB, pairs1, pairs2);\n }\n }\n\n doBoundingSphereBroadphase(bodyA, bodyB, pairs1, pairs2) {\n const r = Broadphase_collisionPairs_r;\n bodyB.position.vsub(bodyA.position, r);\n const boundingRadiusSum2 = (bodyA.boundingRadius + bodyB.boundingRadius) ** 2;\n const norm2 = r.lengthSquared();\n\n if (norm2 < boundingRadiusSum2) {\n pairs1.push(bodyA);\n pairs2.push(bodyB);\n }\n }\n /**\n * Check if the bounding boxes of two bodies are intersecting.\n * @method doBoundingBoxBroadphase\n * @param {Body} bodyA\n * @param {Body} bodyB\n * @param {Array} pairs1\n * @param {Array} pairs2\n */\n\n\n doBoundingBoxBroadphase(bodyA, bodyB, pairs1, pairs2) {\n if (bodyA.aabbNeedsUpdate) {\n bodyA.computeAABB();\n }\n\n if (bodyB.aabbNeedsUpdate) {\n bodyB.computeAABB();\n } // Check AABB / AABB\n\n\n if (bodyA.aabb.overlaps(bodyB.aabb)) {\n pairs1.push(bodyA);\n pairs2.push(bodyB);\n }\n }\n\n makePairsUnique(pairs1, pairs2) {\n const t = Broadphase_makePairsUnique_temp;\n const p1 = Broadphase_makePairsUnique_p1;\n const p2 = Broadphase_makePairsUnique_p2;\n const N = pairs1.length;\n\n for (let i = 0; i !== N; i++) {\n p1[i] = pairs1[i];\n p2[i] = pairs2[i];\n }\n\n pairs1.length = 0;\n pairs2.length = 0;\n\n for (let i = 0; i !== N; i++) {\n const id1 = p1[i].id;\n const id2 = p2[i].id;\n const key = id1 < id2 ? id1 + \",\" + id2 : id2 + \",\" + id1;\n t[key] = i;\n t.keys.push(key);\n }\n\n for (let i = 0; i !== t.keys.length; i++) {\n const key = t.keys.pop();\n const pairIndex = t[key];\n pairs1.push(p1[pairIndex]);\n pairs2.push(p2[pairIndex]);\n delete t[key];\n }\n }\n /**\n * To be implemented by subcasses\n * @method setWorld\n * @param {World} world\n */\n\n\n setWorld(world) {}\n /**\n * Returns all the bodies within the AABB.\n * @method aabbQuery\n * @param {World} world\n * @param {AABB} aabb\n * @param {array} result An array to store resulting bodies in.\n * @return {array}\n */\n\n\n aabbQuery(world, aabb, result) {\n console.warn('.aabbQuery is not implemented in this Broadphase subclass.');\n return [];\n }\n\n}\n/**\n * Check if the bounding spheres of two bodies are intersecting.\n * @method doBoundingSphereBroadphase\n * @param {Body} bodyA\n * @param {Body} bodyB\n * @param {Array} pairs1 bodyA is appended to this array if intersection\n * @param {Array} pairs2 bodyB is appended to this array if intersection\n */\n\nconst // Temp objects\nBroadphase_collisionPairs_r = new Vec3();\n/**\n * Removes duplicate pairs from the pair arrays.\n * @method makePairsUnique\n * @param {Array} pairs1\n * @param {Array} pairs2\n */\n\nconst Broadphase_makePairsUnique_temp = {\n keys: []\n};\nconst Broadphase_makePairsUnique_p1 = [];\nconst Broadphase_makePairsUnique_p2 = [];\n\nBroadphase.boundingSphereCheck = (bodyA, bodyB) => {\n const dist = new Vec3(); // bsc_dist;\n\n bodyA.position.vsub(bodyB.position, dist);\n const sa = bodyA.shapes[0];\n const sb = bodyB.shapes[0];\n return Math.pow(sa.boundingSphereRadius + sb.boundingSphereRadius, 2) > dist.lengthSquared();\n};\n\n/**\r\n * Axis aligned uniform grid broadphase.\r\n * @class GridBroadphase\r\n * @constructor\r\n * @extends Broadphase\r\n * @todo Needs support for more than just planes and spheres.\r\n * @param {Vec3} aabbMin\r\n * @param {Vec3} aabbMax\r\n * @param {Number} nx Number of boxes along x\r\n * @param {Number} ny Number of boxes along y\r\n * @param {Number} nz Number of boxes along z\r\n */\nclass GridBroadphase extends Broadphase {\n constructor(aabbMin = new Vec3(100, 100, 100), aabbMax = new Vec3(-100, -100, -100), nx = 10, ny = 10, nz = 10) {\n super();\n this.nx = nx;\n this.ny = ny;\n this.nz = nz;\n this.aabbMin = aabbMin;\n this.aabbMax = aabbMax;\n const nbins = this.nx * this.ny * this.nz;\n\n if (nbins <= 0) {\n throw \"GridBroadphase: Each dimension's n must be >0\";\n }\n\n this.bins = [];\n this.binLengths = []; //Rather than continually resizing arrays (thrashing the memory), just record length and allow them to grow\n\n this.bins.length = nbins;\n this.binLengths.length = nbins;\n\n for (let i = 0; i < nbins; i++) {\n this.bins[i] = [];\n this.binLengths[i] = 0;\n }\n }\n\n collisionPairs(world, pairs1, pairs2) {\n const N = world.numObjects();\n const bodies = world.bodies;\n const max = this.aabbMax;\n const min = this.aabbMin;\n const nx = this.nx;\n const ny = this.ny;\n const nz = this.nz;\n const xstep = ny * nz;\n const ystep = nz;\n const zstep = 1;\n const xmax = max.x;\n const ymax = max.y;\n const zmax = max.z;\n const xmin = min.x;\n const ymin = min.y;\n const zmin = min.z;\n const xmult = nx / (xmax - xmin);\n const ymult = ny / (ymax - ymin);\n const zmult = nz / (zmax - zmin);\n const binsizeX = (xmax - xmin) / nx;\n const binsizeY = (ymax - ymin) / ny;\n const binsizeZ = (zmax - zmin) / nz;\n const binRadius = Math.sqrt(binsizeX * binsizeX + binsizeY * binsizeY + binsizeZ * binsizeZ) * 0.5;\n const types = Shape.types;\n const SPHERE = types.SPHERE;\n const PLANE = types.PLANE;\n const BOX = types.BOX;\n const COMPOUND = types.COMPOUND;\n const CONVEXPOLYHEDRON = types.CONVEXPOLYHEDRON;\n const bins = this.bins;\n const binLengths = this.binLengths;\n const Nbins = this.bins.length; // Reset bins\n\n for (let i = 0; i !== Nbins; i++) {\n binLengths[i] = 0;\n }\n\n const ceil = Math.ceil;\n\n function addBoxToBins(x0, y0, z0, x1, y1, z1, bi) {\n let xoff0 = (x0 - xmin) * xmult | 0;\n let yoff0 = (y0 - ymin) * ymult | 0;\n let zoff0 = (z0 - zmin) * zmult | 0;\n let xoff1 = ceil((x1 - xmin) * xmult);\n let yoff1 = ceil((y1 - ymin) * ymult);\n let zoff1 = ceil((z1 - zmin) * zmult);\n\n if (xoff0 < 0) {\n xoff0 = 0;\n } else if (xoff0 >= nx) {\n xoff0 = nx - 1;\n }\n\n if (yoff0 < 0) {\n yoff0 = 0;\n } else if (yoff0 >= ny) {\n yoff0 = ny - 1;\n }\n\n if (zoff0 < 0) {\n zoff0 = 0;\n } else if (zoff0 >= nz) {\n zoff0 = nz - 1;\n }\n\n if (xoff1 < 0) {\n xoff1 = 0;\n } else if (xoff1 >= nx) {\n xoff1 = nx - 1;\n }\n\n if (yoff1 < 0) {\n yoff1 = 0;\n } else if (yoff1 >= ny) {\n yoff1 = ny - 1;\n }\n\n if (zoff1 < 0) {\n zoff1 = 0;\n } else if (zoff1 >= nz) {\n zoff1 = nz - 1;\n }\n\n xoff0 *= xstep;\n yoff0 *= ystep;\n zoff0 *= zstep;\n xoff1 *= xstep;\n yoff1 *= ystep;\n zoff1 *= zstep;\n\n for (let xoff = xoff0; xoff <= xoff1; xoff += xstep) {\n for (let yoff = yoff0; yoff <= yoff1; yoff += ystep) {\n for (let zoff = zoff0; zoff <= zoff1; zoff += zstep) {\n const idx = xoff + yoff + zoff;\n bins[idx][binLengths[idx]++] = bi;\n }\n }\n }\n } // Put all bodies into the bins\n\n\n for (let i = 0; i !== N; i++) {\n const bi = bodies[i];\n const si = bi.shapes[0];\n\n switch (si.type) {\n case SPHERE:\n {\n const shape = si; // Put in bin\n // check if overlap with other bins\n\n const x = bi.position.x;\n const y = bi.position.y;\n const z = bi.position.z;\n const r = shape.radius;\n addBoxToBins(x - r, y - r, z - r, x + r, y + r, z + r, bi);\n break;\n }\n\n case PLANE:\n {\n const shape = si;\n\n if (shape.worldNormalNeedsUpdate) {\n shape.computeWorldNormal(bi.quaternion);\n }\n\n const planeNormal = shape.worldNormal; //Relative position from origin of plane object to the first bin\n //Incremented as we iterate through the bins\n\n const xreset = xmin + binsizeX * 0.5 - bi.position.x;\n const yreset = ymin + binsizeY * 0.5 - bi.position.y;\n const zreset = zmin + binsizeZ * 0.5 - bi.position.z;\n const d = GridBroadphase_collisionPairs_d;\n d.set(xreset, yreset, zreset);\n\n for (let xi = 0, xoff = 0; xi !== nx; xi++, xoff += xstep, d.y = yreset, d.x += binsizeX) {\n for (let yi = 0, yoff = 0; yi !== ny; yi++, yoff += ystep, d.z = zreset, d.y += binsizeY) {\n for (let zi = 0, zoff = 0; zi !== nz; zi++, zoff += zstep, d.z += binsizeZ) {\n if (d.dot(planeNormal) < binRadius) {\n const idx = xoff + yoff + zoff;\n bins[idx][binLengths[idx]++] = bi;\n }\n }\n }\n }\n\n break;\n }\n\n default:\n {\n if (bi.aabbNeedsUpdate) {\n bi.computeAABB();\n }\n\n addBoxToBins(bi.aabb.lowerBound.x, bi.aabb.lowerBound.y, bi.aabb.lowerBound.z, bi.aabb.upperBound.x, bi.aabb.upperBound.y, bi.aabb.upperBound.z, bi);\n break;\n }\n }\n } // Check each bin\n\n\n for (let i = 0; i !== Nbins; i++) {\n const binLength = binLengths[i]; //Skip bins with no potential collisions\n\n if (binLength > 1) {\n const bin = bins[i]; // Do N^2 broadphase inside\n\n for (let xi = 0; xi !== binLength; xi++) {\n const bi = bin[xi];\n\n for (let yi = 0; yi !== xi; yi++) {\n const bj = bin[yi];\n\n if (this.needBroadphaseCollision(bi, bj)) {\n this.intersectionTest(bi, bj, pairs1, pairs2);\n }\n }\n }\n }\n } //\tfor (let zi = 0, zoff=0; zi < nz; zi++, zoff+= zstep) {\n //\t\tconsole.log(\"layer \"+zi);\n //\t\tfor (let yi = 0, yoff=0; yi < ny; yi++, yoff += ystep) {\n //\t\t\tconst row = '';\n //\t\t\tfor (let xi = 0, xoff=0; xi < nx; xi++, xoff += xstep) {\n //\t\t\t\tconst idx = xoff + yoff + zoff;\n //\t\t\t\trow += ' ' + binLengths[idx];\n //\t\t\t}\n //\t\t\tconsole.log(row);\n //\t\t}\n //\t}\n\n\n this.makePairsUnique(pairs1, pairs2);\n }\n\n}\n/**\r\n * Get all the collision pairs in the physics world\r\n * @method collisionPairs\r\n * @param {World} world\r\n * @param {Array} pairs1\r\n * @param {Array} pairs2\r\n */\n\nconst GridBroadphase_collisionPairs_d = new Vec3();\n\n/**\r\n * Naive broadphase implementation, used in lack of better ones.\r\n * @class NaiveBroadphase\r\n * @constructor\r\n * @description The naive broadphase looks at all possible pairs without restriction, therefore it has complexity N^2 (which is bad)\r\n * @extends Broadphase\r\n */\nclass NaiveBroadphase extends Broadphase {\n constructor() {\n super();\n }\n /**\r\n * Get all the collision pairs in the physics world\r\n * @method collisionPairs\r\n * @param {World} world\r\n * @param {Array} pairs1\r\n * @param {Array} pairs2\r\n */\n\n\n collisionPairs(world, pairs1, pairs2) {\n const bodies = world.bodies;\n const n = bodies.length;\n let bi;\n let bj; // Naive N^2 ftw!\n\n for (let i = 0; i !== n; i++) {\n for (let j = 0; j !== i; j++) {\n bi = bodies[i];\n bj = bodies[j];\n\n if (!this.needBroadphaseCollision(bi, bj)) {\n continue;\n }\n\n this.intersectionTest(bi, bj, pairs1, pairs2);\n }\n }\n }\n /**\r\n * Returns all the bodies within an AABB.\r\n * @method aabbQuery\r\n * @param {World} world\r\n * @param {AABB} aabb\r\n * @param {array} result An array to store resulting bodies in.\r\n * @return {array}\r\n */\n\n\n aabbQuery(world, aabb, result = []) {\n for (let i = 0; i < world.bodies.length; i++) {\n const b = world.bodies[i];\n\n if (b.aabbNeedsUpdate) {\n b.computeAABB();\n } // Ugly hack until Body gets aabb\n\n\n if (b.aabb.overlaps(aabb)) {\n result.push(b);\n }\n }\n\n return result;\n }\n\n}\n\n/**\r\n * Storage for Ray casting data.\r\n * @class RaycastResult\r\n * @constructor\r\n */\nclass RaycastResult {\n // The index of the hit triangle, if the hit shape was a trimesh.\n // Distance to the hit. Will be set to -1 if there was no hit.\n // If the ray should stop traversing the bodies.\n constructor() {\n this.rayFromWorld = new Vec3();\n this.rayToWorld = new Vec3();\n this.hitNormalWorld = new Vec3();\n this.hitPointWorld = new Vec3();\n this.hasHit = false;\n this.shape = null;\n this.body = null;\n this.hitFaceIndex = -1;\n this.distance = -1;\n this.shouldStop = false;\n }\n /**\r\n * Reset all result data.\r\n * @method reset\r\n */\n\n\n reset() {\n this.rayFromWorld.setZero();\n this.rayToWorld.setZero();\n this.hitNormalWorld.setZero();\n this.hitPointWorld.setZero();\n this.hasHit = false;\n this.shape = null;\n this.body = null;\n this.hitFaceIndex = -1;\n this.distance = -1;\n this.shouldStop = false;\n }\n /**\r\n * @method abort\r\n */\n\n\n abort() {\n this.shouldStop = true;\n }\n /**\r\n * @method set\r\n * @param {Vec3} rayFromWorld\r\n * @param {Vec3} rayToWorld\r\n * @param {Vec3} hitNormalWorld\r\n * @param {Vec3} hitPointWorld\r\n * @param {Shape} shape\r\n * @param {Body} body\r\n * @param {number} distance\r\n */\n\n\n set(rayFromWorld, rayToWorld, hitNormalWorld, hitPointWorld, shape, body, distance) {\n this.rayFromWorld.copy(rayFromWorld);\n this.rayToWorld.copy(rayToWorld);\n this.hitNormalWorld.copy(hitNormalWorld);\n this.hitPointWorld.copy(hitPointWorld);\n this.shape = shape;\n this.body = body;\n this.distance = distance;\n }\n\n}\n\nconst RAY_MODES = {\n CLOSEST: 1,\n ANY: 2,\n ALL: 4\n};\n\n/**\r\n * A line in 3D space that intersects bodies and return points.\r\n * @class Ray\r\n * @constructor\r\n * @param {Vec3} from\r\n * @param {Vec3} to\r\n */\nclass Ray {\n // The precision of the ray. Used when checking parallelity etc.\n // Set to true if you want the Ray to take .collisionResponse flags into account on bodies and shapes.\n // If set to true, the ray skips any hits with normal.dot(rayDirection) < 0.\n // The intersection mode. Should be Ray.ANY, Ray.ALL or Ray.CLOSEST.\n // Current result object.\n // Will be set to true during intersectWorld() if the ray hit anything.\n // User-provided result callback. Will be used if mode is Ray.ALL.\n constructor(from = new Vec3(), to = new Vec3()) {\n this.from = from.clone();\n this.to = to.clone();\n this.direction = new Vec3();\n this.precision = 0.0001;\n this.checkCollisionResponse = true;\n this.skipBackfaces = false;\n this.collisionFilterMask = -1;\n this.collisionFilterGroup = -1;\n this.mode = Ray.ANY;\n this.result = new RaycastResult();\n this.hasHit = false;\n\n this.callback = result => {};\n }\n /**\r\n * Do itersection against all bodies in the given World.\r\n * @method intersectWorld\r\n * @param {World} world\r\n * @param {object} options\r\n * @return {Boolean} True if the ray hit anything, otherwise false.\r\n */\n\n\n intersectWorld(world, options) {\n this.mode = options.mode || Ray.ANY;\n this.result = options.result || new RaycastResult();\n this.skipBackfaces = !!options.skipBackfaces;\n this.collisionFilterMask = typeof options.collisionFilterMask !== 'undefined' ? options.collisionFilterMask : -1;\n this.collisionFilterGroup = typeof options.collisionFilterGroup !== 'undefined' ? options.collisionFilterGroup : -1;\n this.checkCollisionResponse = typeof options.checkCollisionResponse !== 'undefined' ? options.checkCollisionResponse : true;\n\n if (options.from) {\n this.from.copy(options.from);\n }\n\n if (options.to) {\n this.to.copy(options.to);\n }\n\n this.callback = options.callback || (() => {});\n\n this.hasHit = false;\n this.result.reset();\n this.updateDirection();\n this.getAABB(tmpAABB);\n tmpArray.length = 0;\n world.broadphase.aabbQuery(world, tmpAABB, tmpArray);\n this.intersectBodies(tmpArray);\n return this.hasHit;\n }\n /**\r\n * Shoot a ray at a body, get back information about the hit.\r\n * @param {Body} body\r\n * @param {RaycastResult} [result] Deprecated - set the result property of the Ray instead.\r\n */\n\n\n intersectBody(body, result) {\n if (result) {\n this.result = result;\n this.updateDirection();\n }\n\n const checkCollisionResponse = this.checkCollisionResponse;\n\n if (checkCollisionResponse && !body.collisionResponse) {\n return;\n }\n\n if ((this.collisionFilterGroup & body.collisionFilterMask) === 0 || (body.collisionFilterGroup & this.collisionFilterMask) === 0) {\n return;\n }\n\n const xi = intersectBody_xi;\n const qi = intersectBody_qi;\n\n for (let i = 0, N = body.shapes.length; i < N; i++) {\n const shape = body.shapes[i];\n\n if (checkCollisionResponse && !shape.collisionResponse) {\n continue; // Skip\n }\n\n body.quaternion.mult(body.shapeOrientations[i], qi);\n body.quaternion.vmult(body.shapeOffsets[i], xi);\n xi.vadd(body.position, xi);\n this.intersectShape(shape, qi, xi, body);\n\n if (this.result.shouldStop) {\n break;\n }\n }\n }\n /**\r\n * @method intersectBodies\r\n * @param {Array} bodies An array of Body objects.\r\n * @param {RaycastResult} [result] Deprecated\r\n */\n\n\n intersectBodies(bodies, result) {\n if (result) {\n this.result = result;\n this.updateDirection();\n }\n\n for (let i = 0, l = bodies.length; !this.result.shouldStop && i < l; i++) {\n this.intersectBody(bodies[i]);\n }\n }\n /**\r\n * Updates the direction vector.\r\n */\n\n\n updateDirection() {\n this.to.vsub(this.from, this.direction);\n this.direction.normalize();\n }\n\n intersectShape(shape, quat, position, body) {\n const from = this.from; // Checking boundingSphere\n\n const distance = distanceFromIntersection(from, this.direction, position);\n\n if (distance > shape.boundingSphereRadius) {\n return;\n }\n\n const intersectMethod = this[shape.type];\n\n if (intersectMethod) {\n intersectMethod.call(this, shape, quat, position, body, shape);\n }\n }\n\n _intersectBox(box, quat, position, body, reportedShape) {\n return this._intersectConvex(box.convexPolyhedronRepresentation, quat, position, body, reportedShape);\n }\n\n _intersectPlane(shape, quat, position, body, reportedShape) {\n const from = this.from;\n const to = this.to;\n const direction = this.direction; // Get plane normal\n\n const worldNormal = new Vec3(0, 0, 1);\n quat.vmult(worldNormal, worldNormal);\n const len = new Vec3();\n from.vsub(position, len);\n const planeToFrom = len.dot(worldNormal);\n to.vsub(position, len);\n const planeToTo = len.dot(worldNormal);\n\n if (planeToFrom * planeToTo > 0) {\n // \"from\" and \"to\" are on the same side of the plane... bail out\n return;\n }\n\n if (from.distanceTo(to) < planeToFrom) {\n return;\n }\n\n const n_dot_dir = worldNormal.dot(direction);\n\n if (Math.abs(n_dot_dir) < this.precision) {\n // No intersection\n return;\n }\n\n const planePointToFrom = new Vec3();\n const dir_scaled_with_t = new Vec3();\n const hitPointWorld = new Vec3();\n from.vsub(position, planePointToFrom);\n const t = -worldNormal.dot(planePointToFrom) / n_dot_dir;\n direction.scale(t, dir_scaled_with_t);\n from.vadd(dir_scaled_with_t, hitPointWorld);\n this.reportIntersection(worldNormal, hitPointWorld, reportedShape, body, -1);\n }\n /**\r\n * Get the world AABB of the ray.\r\n */\n\n\n getAABB(aabb) {\n const {\n lowerBound,\n upperBound\n } = aabb;\n const to = this.to;\n const from = this.from;\n lowerBound.x = Math.min(to.x, from.x);\n lowerBound.y = Math.min(to.y, from.y);\n lowerBound.z = Math.min(to.z, from.z);\n upperBound.x = Math.max(to.x, from.x);\n upperBound.y = Math.max(to.y, from.y);\n upperBound.z = Math.max(to.z, from.z);\n }\n\n _intersectHeightfield(shape, quat, position, body, reportedShape) {\n const data = shape.data;\n const w = shape.elementSize; // Convert the ray to local heightfield coordinates\n\n const localRay = intersectHeightfield_localRay; //new Ray(this.from, this.to);\n\n localRay.from.copy(this.from);\n localRay.to.copy(this.to);\n Transform.pointToLocalFrame(position, quat, localRay.from, localRay.from);\n Transform.pointToLocalFrame(position, quat, localRay.to, localRay.to);\n localRay.updateDirection(); // Get the index of the data points to test against\n\n const index = intersectHeightfield_index;\n let iMinX;\n let iMinY;\n let iMaxX;\n let iMaxY; // Set to max\n\n iMinX = iMinY = 0;\n iMaxX = iMaxY = shape.data.length - 1;\n const aabb = new AABB();\n localRay.getAABB(aabb);\n shape.getIndexOfPosition(aabb.lowerBound.x, aabb.lowerBound.y, index, true);\n iMinX = Math.max(iMinX, index[0]);\n iMinY = Math.max(iMinY, index[1]);\n shape.getIndexOfPosition(aabb.upperBound.x, aabb.upperBound.y, index, true);\n iMaxX = Math.min(iMaxX, index[0] + 1);\n iMaxY = Math.min(iMaxY, index[1] + 1);\n\n for (let i = iMinX; i < iMaxX; i++) {\n for (let j = iMinY; j < iMaxY; j++) {\n if (this.result.shouldStop) {\n return;\n }\n\n shape.getAabbAtIndex(i, j, aabb);\n\n if (!aabb.overlapsRay(localRay)) {\n continue;\n } // Lower triangle\n\n\n shape.getConvexTrianglePillar(i, j, false);\n Transform.pointToWorldFrame(position, quat, shape.pillarOffset, worldPillarOffset);\n\n this._intersectConvex(shape.pillarConvex, quat, worldPillarOffset, body, reportedShape, intersectConvexOptions);\n\n if (this.result.shouldStop) {\n return;\n } // Upper triangle\n\n\n shape.getConvexTrianglePillar(i, j, true);\n Transform.pointToWorldFrame(position, quat, shape.pillarOffset, worldPillarOffset);\n\n this._intersectConvex(shape.pillarConvex, quat, worldPillarOffset, body, reportedShape, intersectConvexOptions);\n }\n }\n }\n\n _intersectSphere(sphere, quat, position, body, reportedShape) {\n const from = this.from;\n const to = this.to;\n const r = sphere.radius;\n const a = (to.x - from.x) ** 2 + (to.y - from.y) ** 2 + (to.z - from.z) ** 2;\n const b = 2 * ((to.x - from.x) * (from.x - position.x) + (to.y - from.y) * (from.y - position.y) + (to.z - from.z) * (from.z - position.z));\n const c = (from.x - position.x) ** 2 + (from.y - position.y) ** 2 + (from.z - position.z) ** 2 - r ** 2;\n const delta = b ** 2 - 4 * a * c;\n const intersectionPoint = Ray_intersectSphere_intersectionPoint;\n const normal = Ray_intersectSphere_normal;\n\n if (delta < 0) {\n // No intersection\n return;\n } else if (delta === 0) {\n // single intersection point\n from.lerp(to, delta, intersectionPoint);\n intersectionPoint.vsub(position, normal);\n normal.normalize();\n this.reportIntersection(normal, intersectionPoint, reportedShape, body, -1);\n } else {\n const d1 = (-b - Math.sqrt(delta)) / (2 * a);\n const d2 = (-b + Math.sqrt(delta)) / (2 * a);\n\n if (d1 >= 0 && d1 <= 1) {\n from.lerp(to, d1, intersectionPoint);\n intersectionPoint.vsub(position, normal);\n normal.normalize();\n this.reportIntersection(normal, intersectionPoint, reportedShape, body, -1);\n }\n\n if (this.result.shouldStop) {\n return;\n }\n\n if (d2 >= 0 && d2 <= 1) {\n from.lerp(to, d2, intersectionPoint);\n intersectionPoint.vsub(position, normal);\n normal.normalize();\n this.reportIntersection(normal, intersectionPoint, reportedShape, body, -1);\n }\n }\n }\n\n _intersectConvex(shape, quat, position, body, reportedShape, options) {\n const normal = intersectConvex_normal;\n const vector = intersectConvex_vector;\n const faceList = options && options.faceList || null; // Checking faces\n\n const faces = shape.faces;\n const vertices = shape.vertices;\n const normals = shape.faceNormals;\n const direction = this.direction;\n const from = this.from;\n const to = this.to;\n const fromToDistance = from.distanceTo(to);\n const Nfaces = faceList ? faceList.length : faces.length;\n const result = this.result;\n\n for (let j = 0; !result.shouldStop && j < Nfaces; j++) {\n const fi = faceList ? faceList[j] : j;\n const face = faces[fi];\n const faceNormal = normals[fi];\n const q = quat;\n const x = position; // determine if ray intersects the plane of the face\n // note: this works regardless of the direction of the face normal\n // Get plane point in world coordinates...\n\n vector.copy(vertices[face[0]]);\n q.vmult(vector, vector);\n vector.vadd(x, vector); // ...but make it relative to the ray from. We'll fix this later.\n\n vector.vsub(from, vector); // Get plane normal\n\n q.vmult(faceNormal, normal); // If this dot product is negative, we have something interesting\n\n const dot = direction.dot(normal); // Bail out if ray and plane are parallel\n\n if (Math.abs(dot) < this.precision) {\n continue;\n } // calc distance to plane\n\n\n const scalar = normal.dot(vector) / dot; // if negative distance, then plane is behind ray\n\n if (scalar < 0) {\n continue;\n } // if (dot < 0) {\n // Intersection point is from + direction * scalar\n\n\n direction.scale(scalar, intersectPoint);\n intersectPoint.vadd(from, intersectPoint); // a is the point we compare points b and c with.\n\n a.copy(vertices[face[0]]);\n q.vmult(a, a);\n x.vadd(a, a);\n\n for (let i = 1; !result.shouldStop && i < face.length - 1; i++) {\n // Transform 3 vertices to world coords\n b.copy(vertices[face[i]]);\n c.copy(vertices[face[i + 1]]);\n q.vmult(b, b);\n q.vmult(c, c);\n x.vadd(b, b);\n x.vadd(c, c);\n const distance = intersectPoint.distanceTo(from);\n\n if (!(pointInTriangle(intersectPoint, a, b, c) || pointInTriangle(intersectPoint, b, a, c)) || distance > fromToDistance) {\n continue;\n }\n\n this.reportIntersection(normal, intersectPoint, reportedShape, body, fi);\n } // }\n\n }\n }\n /**\r\n * @todo Optimize by transforming the world to local space first.\r\n * @todo Use Octree lookup\r\n */\n\n\n _intersectTrimesh(mesh, quat, position, body, reportedShape, options) {\n const normal = intersectTrimesh_normal;\n const triangles = intersectTrimesh_triangles;\n const treeTransform = intersectTrimesh_treeTransform;\n const vector = intersectConvex_vector;\n const localDirection = intersectTrimesh_localDirection;\n const localFrom = intersectTrimesh_localFrom;\n const localTo = intersectTrimesh_localTo;\n const worldIntersectPoint = intersectTrimesh_worldIntersectPoint;\n const worldNormal = intersectTrimesh_worldNormal;\n const faceList = options && options.faceList || null; // Checking faces\n\n const indices = mesh.indices;\n const vertices = mesh.vertices; // const normals = mesh.faceNormals\n\n const from = this.from;\n const to = this.to;\n const direction = this.direction;\n treeTransform.position.copy(position);\n treeTransform.quaternion.copy(quat); // Transform ray to local space!\n\n Transform.vectorToLocalFrame(position, quat, direction, localDirection);\n Transform.pointToLocalFrame(position, quat, from, localFrom);\n Transform.pointToLocalFrame(position, quat, to, localTo);\n localTo.x *= mesh.scale.x;\n localTo.y *= mesh.scale.y;\n localTo.z *= mesh.scale.z;\n localFrom.x *= mesh.scale.x;\n localFrom.y *= mesh.scale.y;\n localFrom.z *= mesh.scale.z;\n localTo.vsub(localFrom, localDirection);\n localDirection.normalize();\n const fromToDistanceSquared = localFrom.distanceSquared(localTo);\n mesh.tree.rayQuery(this, treeTransform, triangles);\n\n for (let i = 0, N = triangles.length; !this.result.shouldStop && i !== N; i++) {\n const trianglesIndex = triangles[i];\n mesh.getNormal(trianglesIndex, normal); // determine if ray intersects the plane of the face\n // note: this works regardless of the direction of the face normal\n // Get plane point in world coordinates...\n\n mesh.getVertex(indices[trianglesIndex * 3], a); // ...but make it relative to the ray from. We'll fix this later.\n\n a.vsub(localFrom, vector); // If this dot product is negative, we have something interesting\n\n const dot = localDirection.dot(normal); // Bail out if ray and plane are parallel\n // if (Math.abs( dot ) < this.precision){\n // continue;\n // }\n // calc distance to plane\n\n const scalar = normal.dot(vector) / dot; // if negative distance, then plane is behind ray\n\n if (scalar < 0) {\n continue;\n } // Intersection point is from + direction * scalar\n\n\n localDirection.scale(scalar, intersectPoint);\n intersectPoint.vadd(localFrom, intersectPoint); // Get triangle vertices\n\n mesh.getVertex(indices[trianglesIndex * 3 + 1], b);\n mesh.getVertex(indices[trianglesIndex * 3 + 2], c);\n const squaredDistance = intersectPoint.distanceSquared(localFrom);\n\n if (!(pointInTriangle(intersectPoint, b, a, c) || pointInTriangle(intersectPoint, a, b, c)) || squaredDistance > fromToDistanceSquared) {\n continue;\n } // transform intersectpoint and normal to world\n\n\n Transform.vectorToWorldFrame(quat, normal, worldNormal);\n Transform.pointToWorldFrame(position, quat, intersectPoint, worldIntersectPoint);\n this.reportIntersection(worldNormal, worldIntersectPoint, reportedShape, body, trianglesIndex);\n }\n\n triangles.length = 0;\n }\n /**\r\n * @return {boolean} True if the intersections should continue\r\n */\n\n\n reportIntersection(normal, hitPointWorld, shape, body, hitFaceIndex) {\n const from = this.from;\n const to = this.to;\n const distance = from.distanceTo(hitPointWorld);\n const result = this.result; // Skip back faces?\n\n if (this.skipBackfaces && normal.dot(this.direction) > 0) {\n return;\n }\n\n result.hitFaceIndex = typeof hitFaceIndex !== 'undefined' ? hitFaceIndex : -1;\n\n switch (this.mode) {\n case Ray.ALL:\n this.hasHit = true;\n result.set(from, to, normal, hitPointWorld, shape, body, distance);\n result.hasHit = true;\n this.callback(result);\n break;\n\n case Ray.CLOSEST:\n // Store if closer than current closest\n if (distance < result.distance || !result.hasHit) {\n this.hasHit = true;\n result.hasHit = true;\n result.set(from, to, normal, hitPointWorld, shape, body, distance);\n }\n\n break;\n\n case Ray.ANY:\n // Report and stop.\n this.hasHit = true;\n result.hasHit = true;\n result.set(from, to, normal, hitPointWorld, shape, body, distance);\n result.shouldStop = true;\n break;\n }\n }\n\n}\nRay.CLOSEST = 1;\nRay.ANY = 2;\nRay.ALL = 4;\nconst tmpAABB = new AABB();\nconst tmpArray = [];\nconst v1 = new Vec3();\nconst v2 = new Vec3();\n/*\r\n * As per \"Barycentric Technique\" as named here http://www.blackpawn.com/texts/pointinpoly/default.html But without the division\r\n */\n\nRay.pointInTriangle = pointInTriangle;\n\nfunction pointInTriangle(p, a, b, c) {\n c.vsub(a, v0);\n b.vsub(a, v1);\n p.vsub(a, v2);\n const dot00 = v0.dot(v0);\n const dot01 = v0.dot(v1);\n const dot02 = v0.dot(v2);\n const dot11 = v1.dot(v1);\n const dot12 = v1.dot(v2);\n let u;\n let v;\n return (u = dot11 * dot02 - dot01 * dot12) >= 0 && (v = dot00 * dot12 - dot01 * dot02) >= 0 && u + v < dot00 * dot11 - dot01 * dot01;\n}\n\nconst intersectBody_xi = new Vec3();\nconst intersectBody_qi = new Quaternion();\nconst intersectPoint = new Vec3();\nconst a = new Vec3();\nconst b = new Vec3();\nconst c = new Vec3();\nRay.prototype[Shape.types.BOX] = Ray.prototype._intersectBox;\nRay.prototype[Shape.types.PLANE] = Ray.prototype._intersectPlane;\nconst intersectConvexOptions = {\n faceList: [0]\n};\nconst worldPillarOffset = new Vec3();\nconst intersectHeightfield_localRay = new Ray();\nconst intersectHeightfield_index = [];\nRay.prototype[Shape.types.HEIGHTFIELD] = Ray.prototype._intersectHeightfield;\nconst Ray_intersectSphere_intersectionPoint = new Vec3();\nconst Ray_intersectSphere_normal = new Vec3();\nRay.prototype[Shape.types.SPHERE] = Ray.prototype._intersectSphere;\nconst intersectConvex_normal = new Vec3();\nconst intersectConvex_vector = new Vec3();\nRay.prototype[Shape.types.CONVEXPOLYHEDRON] = Ray.prototype._intersectConvex;\nconst intersectTrimesh_normal = new Vec3();\nconst intersectTrimesh_localDirection = new Vec3();\nconst intersectTrimesh_localFrom = new Vec3();\nconst intersectTrimesh_localTo = new Vec3();\nconst intersectTrimesh_worldNormal = new Vec3();\nconst intersectTrimesh_worldIntersectPoint = new Vec3();\nconst intersectTrimesh_localAABB = new AABB();\nconst intersectTrimesh_triangles = [];\nconst intersectTrimesh_treeTransform = new Transform();\nRay.prototype[Shape.types.TRIMESH] = Ray.prototype._intersectTrimesh;\nconst v0 = new Vec3();\nconst intersect = new Vec3();\n\nfunction distanceFromIntersection(from, direction, position) {\n // v0 is vector from from to position\n position.vsub(from, v0);\n const dot = v0.dot(direction); // intersect = direction*dot + from\n\n direction.scale(dot, intersect);\n intersect.vadd(from, intersect);\n const distance = position.distanceTo(intersect);\n return distance;\n}\n\n/**\r\n * Sweep and prune broadphase along one axis.\r\n *\r\n * @class SAPBroadphase\r\n * @constructor\r\n * @param {World} [world]\r\n * @extends Broadphase\r\n */\nclass SAPBroadphase extends Broadphase {\n // List of bodies currently in the broadphase.\n // The world to search in.\n // Axis to sort the bodies along. Set to 0 for x axis, and 1 for y axis. For best performance, choose an axis that the bodies are spread out more on.\n constructor(world) {\n super();\n this.axisList = [];\n this.world = null;\n this.axisIndex = 0;\n const axisList = this.axisList;\n\n this._addBodyHandler = event => {\n axisList.push(event.body);\n };\n\n this._removeBodyHandler = event => {\n const idx = axisList.indexOf(event.body);\n\n if (idx !== -1) {\n axisList.splice(idx, 1);\n }\n };\n\n if (world) {\n this.setWorld(world);\n }\n }\n /**\r\n * Change the world\r\n * @method setWorld\r\n * @param {World} world\r\n */\n\n\n setWorld(world) {\n // Clear the old axis array\n this.axisList.length = 0; // Add all bodies from the new world\n\n for (let i = 0; i < world.bodies.length; i++) {\n this.axisList.push(world.bodies[i]);\n } // Remove old handlers, if any\n\n\n world.removeEventListener('addBody', this._addBodyHandler);\n world.removeEventListener('removeBody', this._removeBodyHandler); // Add handlers to update the list of bodies.\n\n world.addEventListener('addBody', this._addBodyHandler);\n world.addEventListener('removeBody', this._removeBodyHandler);\n this.world = world;\n this.dirty = true;\n }\n /**\r\n * Collect all collision pairs\r\n * @method collisionPairs\r\n * @param {World} world\r\n * @param {Array} p1\r\n * @param {Array} p2\r\n */\n\n\n collisionPairs(world, p1, p2) {\n const bodies = this.axisList;\n const N = bodies.length;\n const axisIndex = this.axisIndex;\n let i;\n let j;\n\n if (this.dirty) {\n this.sortList();\n this.dirty = false;\n } // Look through the list\n\n\n for (i = 0; i !== N; i++) {\n const bi = bodies[i];\n\n for (j = i + 1; j < N; j++) {\n const bj = bodies[j];\n\n if (!this.needBroadphaseCollision(bi, bj)) {\n continue;\n }\n\n if (!SAPBroadphase.checkBounds(bi, bj, axisIndex)) {\n break;\n }\n\n this.intersectionTest(bi, bj, p1, p2);\n }\n }\n }\n\n sortList() {\n const axisList = this.axisList;\n const axisIndex = this.axisIndex;\n const N = axisList.length; // Update AABBs\n\n for (let i = 0; i !== N; i++) {\n const bi = axisList[i];\n\n if (bi.aabbNeedsUpdate) {\n bi.computeAABB();\n }\n } // Sort the list\n\n\n if (axisIndex === 0) {\n SAPBroadphase.insertionSortX(axisList);\n } else if (axisIndex === 1) {\n SAPBroadphase.insertionSortY(axisList);\n } else if (axisIndex === 2) {\n SAPBroadphase.insertionSortZ(axisList);\n }\n }\n /**\r\n * Computes the variance of the body positions and estimates the best\r\n * axis to use. Will automatically set property .axisIndex.\r\n * @method autoDetectAxis\r\n */\n\n\n autoDetectAxis() {\n let sumX = 0;\n let sumX2 = 0;\n let sumY = 0;\n let sumY2 = 0;\n let sumZ = 0;\n let sumZ2 = 0;\n const bodies = this.axisList;\n const N = bodies.length;\n const invN = 1 / N;\n\n for (let i = 0; i !== N; i++) {\n const b = bodies[i];\n const centerX = b.position.x;\n sumX += centerX;\n sumX2 += centerX * centerX;\n const centerY = b.position.y;\n sumY += centerY;\n sumY2 += centerY * centerY;\n const centerZ = b.position.z;\n sumZ += centerZ;\n sumZ2 += centerZ * centerZ;\n }\n\n const varianceX = sumX2 - sumX * sumX * invN;\n const varianceY = sumY2 - sumY * sumY * invN;\n const varianceZ = sumZ2 - sumZ * sumZ * invN;\n\n if (varianceX > varianceY) {\n if (varianceX > varianceZ) {\n this.axisIndex = 0;\n } else {\n this.axisIndex = 2;\n }\n } else if (varianceY > varianceZ) {\n this.axisIndex = 1;\n } else {\n this.axisIndex = 2;\n }\n }\n /**\r\n * Returns all the bodies within an AABB.\r\n * @method aabbQuery\r\n * @param {World} world\r\n * @param {AABB} aabb\r\n * @param {array} result An array to store resulting bodies in.\r\n * @return {array}\r\n */\n\n\n aabbQuery(world, aabb, result = []) {\n if (this.dirty) {\n this.sortList();\n this.dirty = false;\n }\n\n const axisIndex = this.axisIndex;\n let axis = 'x';\n\n if (axisIndex === 1) {\n axis = 'y';\n }\n\n if (axisIndex === 2) {\n axis = 'z';\n }\n\n const axisList = this.axisList;\n const lower = aabb.lowerBound[axis];\n const upper = aabb.upperBound[axis];\n\n for (let i = 0; i < axisList.length; i++) {\n const b = axisList[i];\n\n if (b.aabbNeedsUpdate) {\n b.computeAABB();\n }\n\n if (b.aabb.overlaps(aabb)) {\n result.push(b);\n }\n }\n\n return result;\n }\n\n}\n/**\r\n * @static\r\n * @method insertionSortX\r\n * @param {Array} a\r\n * @return {Array}\r\n */\n\nSAPBroadphase.insertionSortX = a => {\n for (let i = 1, l = a.length; i < l; i++) {\n const v = a[i];\n let j;\n\n for (j = i - 1; j >= 0; j--) {\n if (a[j].aabb.lowerBound.x <= v.aabb.lowerBound.x) {\n break;\n }\n\n a[j + 1] = a[j];\n }\n\n a[j + 1] = v;\n }\n\n return a;\n};\n/**\r\n * @static\r\n * @method insertionSortY\r\n * @param {Array} a\r\n * @return {Array}\r\n */\n\n\nSAPBroadphase.insertionSortY = a => {\n for (let i = 1, l = a.length; i < l; i++) {\n const v = a[i];\n let j;\n\n for (j = i - 1; j >= 0; j--) {\n if (a[j].aabb.lowerBound.y <= v.aabb.lowerBound.y) {\n break;\n }\n\n a[j + 1] = a[j];\n }\n\n a[j + 1] = v;\n }\n\n return a;\n};\n/**\r\n * @static\r\n * @method insertionSortZ\r\n * @param {Array} a\r\n * @return {Array}\r\n */\n\n\nSAPBroadphase.insertionSortZ = a => {\n for (let i = 1, l = a.length; i < l; i++) {\n const v = a[i];\n let j;\n\n for (j = i - 1; j >= 0; j--) {\n if (a[j].aabb.lowerBound.z <= v.aabb.lowerBound.z) {\n break;\n }\n\n a[j + 1] = a[j];\n }\n\n a[j + 1] = v;\n }\n\n return a;\n};\n/**\r\n * Check if the bounds of two bodies overlap, along the given SAP axis.\r\n * @static\r\n * @method checkBounds\r\n * @param {Body} bi\r\n * @param {Body} bj\r\n * @param {Number} axisIndex\r\n * @return {Boolean}\r\n */\n\n\nSAPBroadphase.checkBounds = (bi, bj, axisIndex) => {\n let biPos;\n let bjPos;\n\n if (axisIndex === 0) {\n biPos = bi.position.x;\n bjPos = bj.position.x;\n } else if (axisIndex === 1) {\n biPos = bi.position.y;\n bjPos = bj.position.y;\n } else if (axisIndex === 2) {\n biPos = bi.position.z;\n bjPos = bj.position.z;\n }\n\n const ri = bi.boundingRadius,\n rj = bj.boundingRadius,\n // boundA1 = biPos - ri,\n boundA2 = biPos + ri,\n boundB1 = bjPos - rj; // boundB2 = bjPos + rj;\n\n return boundB1 < boundA2;\n};\n\nfunction Utils() {}\n/**\r\n * Extend an options object with default values.\r\n * @static\r\n * @method defaults\r\n * @param {object} options The options object. May be falsy: in this case, a new object is created and returned.\r\n * @param {object} defaults An object containing default values.\r\n * @return {object} The modified options object.\r\n */\n\nUtils.defaults = (options = {}, defaults) => {\n for (let key in defaults) {\n if (!(key in options)) {\n options[key] = defaults[key];\n }\n }\n\n return options;\n};\n\n/**\r\n * Constraint base class\r\n * @class Constraint\r\n * @author schteppe\r\n * @constructor\r\n * @param {Body} bodyA\r\n * @param {Body} bodyB\r\n * @param {object} [options]\r\n * @param {boolean} [options.collideConnected=true]\r\n * @param {boolean} [options.wakeUpBodies=true]\r\n */\nclass Constraint {\n // Equations to be solved in this constraint.\n // Set to true if you want the bodies to collide when they are connected.\n constructor(bodyA, bodyB, options = {}) {\n options = Utils.defaults(options, {\n collideConnected: true,\n wakeUpBodies: true\n });\n this.equations = [];\n this.bodyA = bodyA;\n this.bodyB = bodyB;\n this.id = Constraint.idCounter++;\n this.collideConnected = options.collideConnected;\n\n if (options.wakeUpBodies) {\n if (bodyA) {\n bodyA.wakeUp();\n }\n\n if (bodyB) {\n bodyB.wakeUp();\n }\n }\n }\n /**\r\n * Update all the equations with data.\r\n * @method update\r\n */\n\n\n update() {\n throw new Error('method update() not implmemented in this Constraint subclass!');\n }\n /**\r\n * Enables all equations in the constraint.\r\n * @method enable\r\n */\n\n\n enable() {\n const eqs = this.equations;\n\n for (let i = 0; i < eqs.length; i++) {\n eqs[i].enabled = true;\n }\n }\n /**\r\n * Disables all equations in the constraint.\r\n * @method disable\r\n */\n\n\n disable() {\n const eqs = this.equations;\n\n for (let i = 0; i < eqs.length; i++) {\n eqs[i].enabled = false;\n }\n }\n\n}\nConstraint.idCounter = 0;\n\n/**\r\n * An element containing 6 entries, 3 spatial and 3 rotational degrees of freedom.\r\n */\n\nclass JacobianElement {\n constructor() {\n this.spatial = new Vec3();\n this.rotational = new Vec3();\n }\n /**\r\n * Multiply with other JacobianElement\r\n */\n\n\n multiplyElement(element) {\n return element.spatial.dot(this.spatial) + element.rotational.dot(this.rotational);\n }\n /**\r\n * Multiply with two vectors\r\n */\n\n\n multiplyVectors(spatial, rotational) {\n return spatial.dot(this.spatial) + rotational.dot(this.rotational);\n }\n\n}\n\n/**\r\n * Equation base class\r\n * @class Equation\r\n * @constructor\r\n * @author schteppe\r\n * @param {Body} bi\r\n * @param {Body} bj\r\n * @param {Number} minForce Minimum (read: negative max) force to be applied by the constraint.\r\n * @param {Number} maxForce Maximum (read: positive max) force to be applied by the constraint.\r\n */\nclass Equation {\n // SPOOK parameter\n // SPOOK parameter\n // SPOOK parameter\n // A number, proportional to the force added to the bodies.\n constructor(bi, bj, minForce = -1e6, maxForce = 1e6) {\n this.id = Equation.id++;\n this.minForce = minForce;\n this.maxForce = maxForce;\n this.bi = bi;\n this.bj = bj;\n this.a = 0.0; // SPOOK parameter\n\n this.b = 0.0; // SPOOK parameter\n\n this.eps = 0.0; // SPOOK parameter\n\n this.jacobianElementA = new JacobianElement();\n this.jacobianElementB = new JacobianElement();\n this.enabled = true;\n this.multiplier = 0;\n this.setSpookParams(1e7, 4, 1 / 60); // Set typical spook params\n }\n /**\r\n * Recalculates a,b,eps.\r\n * @method setSpookParams\r\n */\n\n\n setSpookParams(stiffness, relaxation, timeStep) {\n const d = relaxation;\n const k = stiffness;\n const h = timeStep;\n this.a = 4.0 / (h * (1 + 4 * d));\n this.b = 4.0 * d / (1 + 4 * d);\n this.eps = 4.0 / (h * h * k * (1 + 4 * d));\n }\n /**\r\n * Computes the right hand side of the SPOOK equation\r\n * @method computeB\r\n * @return {Number}\r\n */\n\n\n computeB(a, b, h) {\n const GW = this.computeGW();\n const Gq = this.computeGq();\n const GiMf = this.computeGiMf();\n return -Gq * a - GW * b - GiMf * h;\n }\n /**\r\n * Computes G*q, where q are the generalized body coordinates\r\n * @method computeGq\r\n * @return {Number}\r\n */\n\n\n computeGq() {\n const GA = this.jacobianElementA;\n const GB = this.jacobianElementB;\n const bi = this.bi;\n const bj = this.bj;\n const xi = bi.position;\n const xj = bj.position;\n return GA.spatial.dot(xi) + GB.spatial.dot(xj);\n }\n /**\r\n * Computes G*W, where W are the body velocities\r\n * @method computeGW\r\n * @return {Number}\r\n */\n\n\n computeGW() {\n const GA = this.jacobianElementA;\n const GB = this.jacobianElementB;\n const bi = this.bi;\n const bj = this.bj;\n const vi = bi.velocity;\n const vj = bj.velocity;\n const wi = bi.angularVelocity;\n const wj = bj.angularVelocity;\n return GA.multiplyVectors(vi, wi) + GB.multiplyVectors(vj, wj);\n }\n /**\r\n * Computes G*Wlambda, where W are the body velocities\r\n * @method computeGWlambda\r\n * @return {Number}\r\n */\n\n\n computeGWlambda() {\n const GA = this.jacobianElementA;\n const GB = this.jacobianElementB;\n const bi = this.bi;\n const bj = this.bj;\n const vi = bi.vlambda;\n const vj = bj.vlambda;\n const wi = bi.wlambda;\n const wj = bj.wlambda;\n return GA.multiplyVectors(vi, wi) + GB.multiplyVectors(vj, wj);\n }\n\n computeGiMf() {\n const GA = this.jacobianElementA;\n const GB = this.jacobianElementB;\n const bi = this.bi;\n const bj = this.bj;\n const fi = bi.force;\n const ti = bi.torque;\n const fj = bj.force;\n const tj = bj.torque;\n const invMassi = bi.invMassSolve;\n const invMassj = bj.invMassSolve;\n fi.scale(invMassi, iMfi);\n fj.scale(invMassj, iMfj);\n bi.invInertiaWorldSolve.vmult(ti, invIi_vmult_taui);\n bj.invInertiaWorldSolve.vmult(tj, invIj_vmult_tauj);\n return GA.multiplyVectors(iMfi, invIi_vmult_taui) + GB.multiplyVectors(iMfj, invIj_vmult_tauj);\n }\n\n computeGiMGt() {\n const GA = this.jacobianElementA;\n const GB = this.jacobianElementB;\n const bi = this.bi;\n const bj = this.bj;\n const invMassi = bi.invMassSolve;\n const invMassj = bj.invMassSolve;\n const invIi = bi.invInertiaWorldSolve;\n const invIj = bj.invInertiaWorldSolve;\n let result = invMassi + invMassj;\n invIi.vmult(GA.rotational, tmp$1);\n result += tmp$1.dot(GA.rotational);\n invIj.vmult(GB.rotational, tmp$1);\n result += tmp$1.dot(GB.rotational);\n return result;\n }\n /**\r\n * Add constraint velocity to the bodies.\r\n * @method addToWlambda\r\n * @param {Number} deltalambda\r\n */\n\n\n addToWlambda(deltalambda) {\n const GA = this.jacobianElementA;\n const GB = this.jacobianElementB;\n const bi = this.bi;\n const bj = this.bj;\n const temp = addToWlambda_temp; // Add to linear velocity\n // v_lambda += inv(M) * delta_lamba * G\n\n bi.vlambda.addScaledVector(bi.invMassSolve * deltalambda, GA.spatial, bi.vlambda);\n bj.vlambda.addScaledVector(bj.invMassSolve * deltalambda, GB.spatial, bj.vlambda); // Add to angular velocity\n\n bi.invInertiaWorldSolve.vmult(GA.rotational, temp);\n bi.wlambda.addScaledVector(deltalambda, temp, bi.wlambda);\n bj.invInertiaWorldSolve.vmult(GB.rotational, temp);\n bj.wlambda.addScaledVector(deltalambda, temp, bj.wlambda);\n }\n /**\r\n * Compute the denominator part of the SPOOK equation: C = G*inv(M)*G' + eps\r\n * @method computeInvC\r\n * @param {Number} eps\r\n * @return {Number}\r\n */\n\n\n computeC() {\n return this.computeGiMGt() + this.eps;\n }\n\n}\nEquation.id = 0;\n/**\r\n * Computes G*inv(M)*f, where M is the mass matrix with diagonal blocks for each body, and f are the forces on the bodies.\r\n * @method computeGiMf\r\n * @return {Number}\r\n */\n\nconst iMfi = new Vec3();\nconst iMfj = new Vec3();\nconst invIi_vmult_taui = new Vec3();\nconst invIj_vmult_tauj = new Vec3();\n/**\r\n * Computes G*inv(M)*G'\r\n * @method computeGiMGt\r\n * @return {Number}\r\n */\n\nconst tmp$1 = new Vec3();\nconst addToWlambda_temp = new Vec3();\n\n/**\r\n * Contact/non-penetration constraint equation\r\n * @class ContactEquation\r\n * @constructor\r\n * @author schteppe\r\n * @param {Body} bodyA\r\n * @param {Body} bodyB\r\n * @extends Equation\r\n */\nclass ContactEquation extends Equation {\n // \"bounciness\": u1 = -e*u0\n // World-oriented vector that goes from the center of bi to the contact point.\n // World-oriented vector that starts in body j position and goes to the contact point.\n // Contact normal, pointing out of body i.\n constructor(bodyA, bodyB, maxForce = 1e6) {\n super(bodyA, bodyB, 0, maxForce);\n this.restitution = 0.0;\n this.ri = new Vec3();\n this.rj = new Vec3();\n this.ni = new Vec3();\n }\n\n computeB(h) {\n const a = this.a;\n const b = this.b;\n const bi = this.bi;\n const bj = this.bj;\n const ri = this.ri;\n const rj = this.rj;\n const rixn = ContactEquation_computeB_temp1;\n const rjxn = ContactEquation_computeB_temp2;\n const vi = bi.velocity;\n const wi = bi.angularVelocity;\n const fi = bi.force;\n const taui = bi.torque;\n const vj = bj.velocity;\n const wj = bj.angularVelocity;\n const fj = bj.force;\n const tauj = bj.torque;\n const penetrationVec = ContactEquation_computeB_temp3;\n const GA = this.jacobianElementA;\n const GB = this.jacobianElementB;\n const n = this.ni; // Caluclate cross products\n\n ri.cross(n, rixn);\n rj.cross(n, rjxn); // g = xj+rj -(xi+ri)\n // G = [ -ni -rixn ni rjxn ]\n\n n.negate(GA.spatial);\n rixn.negate(GA.rotational);\n GB.spatial.copy(n);\n GB.rotational.copy(rjxn); // Calculate the penetration vector\n\n penetrationVec.copy(bj.position);\n penetrationVec.vadd(rj, penetrationVec);\n penetrationVec.vsub(bi.position, penetrationVec);\n penetrationVec.vsub(ri, penetrationVec);\n const g = n.dot(penetrationVec); // Compute iteration\n\n const ePlusOne = this.restitution + 1;\n const GW = ePlusOne * vj.dot(n) - ePlusOne * vi.dot(n) + wj.dot(rjxn) - wi.dot(rixn);\n const GiMf = this.computeGiMf();\n const B = -g * a - GW * b - h * GiMf;\n return B;\n }\n /**\r\n * Get the current relative velocity in the contact point.\r\n * @method getImpactVelocityAlongNormal\r\n * @return {number}\r\n */\n\n\n getImpactVelocityAlongNormal() {\n const vi = ContactEquation_getImpactVelocityAlongNormal_vi;\n const vj = ContactEquation_getImpactVelocityAlongNormal_vj;\n const xi = ContactEquation_getImpactVelocityAlongNormal_xi;\n const xj = ContactEquation_getImpactVelocityAlongNormal_xj;\n const relVel = ContactEquation_getImpactVelocityAlongNormal_relVel;\n this.bi.position.vadd(this.ri, xi);\n this.bj.position.vadd(this.rj, xj);\n this.bi.getVelocityAtWorldPoint(xi, vi);\n this.bj.getVelocityAtWorldPoint(xj, vj);\n vi.vsub(vj, relVel);\n return this.ni.dot(relVel);\n }\n\n}\nconst ContactEquation_computeB_temp1 = new Vec3(); // Temp vectors\n\nconst ContactEquation_computeB_temp2 = new Vec3();\nconst ContactEquation_computeB_temp3 = new Vec3();\nconst ContactEquation_getImpactVelocityAlongNormal_vi = new Vec3();\nconst ContactEquation_getImpactVelocityAlongNormal_vj = new Vec3();\nconst ContactEquation_getImpactVelocityAlongNormal_xi = new Vec3();\nconst ContactEquation_getImpactVelocityAlongNormal_xj = new Vec3();\nconst ContactEquation_getImpactVelocityAlongNormal_relVel = new Vec3();\n\n/**\r\n * Connects two bodies at given offset points.\r\n * @class PointToPointConstraint\r\n * @extends Constraint\r\n * @constructor\r\n * @param {Body} bodyA\r\n * @param {Vec3} pivotA The point relative to the center of mass of bodyA which bodyA is constrained to.\r\n * @param {Body} bodyB Body that will be constrained in a similar way to the same point as bodyA. We will therefore get a link between bodyA and bodyB. If not specified, bodyA will be constrained to a static point.\r\n * @param {Vec3} pivotB See pivotA.\r\n * @param {Number} maxForce The maximum force that should be applied to constrain the bodies.\r\n *\r\n * @example\r\n * const bodyA = new Body({ mass: 1 });\r\n * const bodyB = new Body({ mass: 1 });\r\n * bodyA.position.set(-1, 0, 0);\r\n * bodyB.position.set(1, 0, 0);\r\n * bodyA.addShape(shapeA);\r\n * bodyB.addShape(shapeB);\r\n * world.addBody(bodyA);\r\n * world.addBody(bodyB);\r\n * const localPivotA = new Vec3(1, 0, 0);\r\n * const localPivotB = new Vec3(-1, 0, 0);\r\n * const constraint = new PointToPointConstraint(bodyA, localPivotA, bodyB, localPivotB);\r\n * world.addConstraint(constraint);\r\n */\nclass PointToPointConstraint extends Constraint {\n // Pivot, defined locally in bodyA.\n // Pivot, defined locally in bodyB.\n constructor(bodyA, pivotA = new Vec3(), bodyB, pivotB = new Vec3(), maxForce = 1e6) {\n super(bodyA, bodyB);\n this.pivotA = pivotA.clone();\n this.pivotB = pivotB.clone();\n const x = this.equationX = new ContactEquation(bodyA, bodyB);\n const y = this.equationY = new ContactEquation(bodyA, bodyB);\n const z = this.equationZ = new ContactEquation(bodyA, bodyB); // Equations to be fed to the solver\n\n this.equations.push(x, y, z); // Make the equations bidirectional\n\n x.minForce = y.minForce = z.minForce = -maxForce;\n x.maxForce = y.maxForce = z.maxForce = maxForce;\n x.ni.set(1, 0, 0);\n y.ni.set(0, 1, 0);\n z.ni.set(0, 0, 1);\n }\n\n update() {\n const bodyA = this.bodyA;\n const bodyB = this.bodyB;\n const x = this.equationX;\n const y = this.equationY;\n const z = this.equationZ; // Rotate the pivots to world space\n\n bodyA.quaternion.vmult(this.pivotA, x.ri);\n bodyB.quaternion.vmult(this.pivotB, x.rj);\n y.ri.copy(x.ri);\n y.rj.copy(x.rj);\n z.ri.copy(x.ri);\n z.rj.copy(x.rj);\n }\n\n}\n\n/**\r\n * Cone equation. Works to keep the given body world vectors aligned, or tilted within a given angle from each other.\r\n * @class ConeEquation\r\n * @constructor\r\n * @author schteppe\r\n * @param {Body} bodyA\r\n * @param {Body} bodyB\r\n * @param {Vec3} [options.axisA] Local axis in A\r\n * @param {Vec3} [options.axisB] Local axis in B\r\n * @param {Vec3} [options.angle] The \"cone angle\" to keep\r\n * @param {number} [options.maxForce=1e6]\r\n * @extends Equation\r\n */\nclass ConeEquation extends Equation {\n // The cone angle to keep.\n constructor(bodyA, bodyB, options = {}) {\n const maxForce = typeof options.maxForce !== 'undefined' ? options.maxForce : 1e6;\n super(bodyA, bodyB, -maxForce, maxForce);\n this.axisA = options.axisA ? options.axisA.clone() : new Vec3(1, 0, 0);\n this.axisB = options.axisB ? options.axisB.clone() : new Vec3(0, 1, 0);\n this.angle = typeof options.angle !== 'undefined' ? options.angle : 0;\n }\n\n computeB(h) {\n const a = this.a;\n const b = this.b;\n const ni = this.axisA;\n const nj = this.axisB;\n const nixnj = tmpVec1;\n const njxni = tmpVec2;\n const GA = this.jacobianElementA;\n const GB = this.jacobianElementB; // Caluclate cross products\n\n ni.cross(nj, nixnj);\n nj.cross(ni, njxni); // The angle between two vector is:\n // cos(theta) = a * b / (length(a) * length(b) = { len(a) = len(b) = 1 } = a * b\n // g = a * b\n // gdot = (b x a) * wi + (a x b) * wj\n // G = [0 bxa 0 axb]\n // W = [vi wi vj wj]\n\n GA.rotational.copy(njxni);\n GB.rotational.copy(nixnj);\n const g = Math.cos(this.angle) - ni.dot(nj);\n const GW = this.computeGW();\n const GiMf = this.computeGiMf();\n const B = -g * a - GW * b - h * GiMf;\n return B;\n }\n\n}\nconst tmpVec1 = new Vec3();\nconst tmpVec2 = new Vec3();\n\n/**\r\n * Rotational constraint. Works to keep the local vectors orthogonal to each other in world space.\r\n * @class RotationalEquation\r\n * @constructor\r\n * @author schteppe\r\n * @param {Body} bodyA\r\n * @param {Body} bodyB\r\n * @param {Vec3} [options.axisA]\r\n * @param {Vec3} [options.axisB]\r\n * @param {number} [options.maxForce]\r\n * @extends Equation\r\n */\nclass RotationalEquation extends Equation {\n constructor(bodyA, bodyB, options = {}) {\n const maxForce = typeof options.maxForce !== 'undefined' ? options.maxForce : 1e6;\n super(bodyA, bodyB, -maxForce, maxForce);\n this.axisA = options.axisA ? options.axisA.clone() : new Vec3(1, 0, 0);\n this.axisB = options.axisB ? options.axisB.clone() : new Vec3(0, 1, 0);\n this.maxAngle = Math.PI / 2;\n }\n\n computeB(h) {\n const a = this.a;\n const b = this.b;\n const ni = this.axisA;\n const nj = this.axisB;\n const nixnj = tmpVec1$1;\n const njxni = tmpVec2$1;\n const GA = this.jacobianElementA;\n const GB = this.jacobianElementB; // Caluclate cross products\n\n ni.cross(nj, nixnj);\n nj.cross(ni, njxni); // g = ni * nj\n // gdot = (nj x ni) * wi + (ni x nj) * wj\n // G = [0 njxni 0 nixnj]\n // W = [vi wi vj wj]\n\n GA.rotational.copy(njxni);\n GB.rotational.copy(nixnj);\n const g = Math.cos(this.maxAngle) - ni.dot(nj);\n const GW = this.computeGW();\n const GiMf = this.computeGiMf();\n const B = -g * a - GW * b - h * GiMf;\n return B;\n }\n\n}\nconst tmpVec1$1 = new Vec3();\nconst tmpVec2$1 = new Vec3();\n\n/**\r\n * @class ConeTwistConstraint\r\n * @constructor\r\n * @author schteppe\r\n * @param {Body} bodyA\r\n * @param {Body} bodyB\r\n * @param {object} [options]\r\n * @param {Vec3} [options.pivotA]\r\n * @param {Vec3} [options.pivotB]\r\n * @param {Vec3} [options.axisA]\r\n * @param {Vec3} [options.axisB]\r\n * @param {Number} [options.maxForce=1e6]\r\n * @extends PointToPointConstraint\r\n */\nclass ConeTwistConstraint extends PointToPointConstraint {\n constructor(bodyA, bodyB, options = {}) {\n const maxForce = typeof options.maxForce !== 'undefined' ? options.maxForce : 1e6; // Set pivot point in between\n\n const pivotA = options.pivotA ? options.pivotA.clone() : new Vec3();\n const pivotB = options.pivotB ? options.pivotB.clone() : new Vec3();\n super(bodyA, pivotA, bodyB, pivotB, maxForce);\n this.axisA = options.axisA ? options.axisA.clone() : new Vec3();\n this.axisB = options.axisB ? options.axisB.clone() : new Vec3();\n this.collideConnected = !!options.collideConnected;\n this.angle = typeof options.angle !== 'undefined' ? options.angle : 0;\n const c = this.coneEquation = new ConeEquation(bodyA, bodyB, options);\n const t = this.twistEquation = new RotationalEquation(bodyA, bodyB, options);\n this.twistAngle = typeof options.twistAngle !== 'undefined' ? options.twistAngle : 0; // Make the cone equation push the bodies toward the cone axis, not outward\n\n c.maxForce = 0;\n c.minForce = -maxForce; // Make the twist equation add torque toward the initial position\n\n t.maxForce = 0;\n t.minForce = -maxForce;\n this.equations.push(c, t);\n }\n\n update() {\n const bodyA = this.bodyA;\n const bodyB = this.bodyB;\n const cone = this.coneEquation;\n const twist = this.twistEquation;\n super.update(); // Update the axes to the cone constraint\n\n bodyA.vectorToWorldFrame(this.axisA, cone.axisA);\n bodyB.vectorToWorldFrame(this.axisB, cone.axisB); // Update the world axes in the twist constraint\n\n this.axisA.tangents(twist.axisA, twist.axisA);\n bodyA.vectorToWorldFrame(twist.axisA, twist.axisA);\n this.axisB.tangents(twist.axisB, twist.axisB);\n bodyB.vectorToWorldFrame(twist.axisB, twist.axisB);\n cone.angle = this.angle;\n twist.maxAngle = this.twistAngle;\n }\n\n}\n\n/**\r\n * Constrains two bodies to be at a constant distance from each others center of mass.\r\n * @class DistanceConstraint\r\n * @constructor\r\n * @author schteppe\r\n * @param {Body} bodyA\r\n * @param {Body} bodyB\r\n * @param {Number} [distance] The distance to keep. If undefined, it will be set to the current distance between bodyA and bodyB\r\n * @param {Number} [maxForce=1e6]\r\n * @extends Constraint\r\n */\nclass DistanceConstraint extends Constraint {\n constructor(bodyA, bodyB, distance, maxForce = 1e6) {\n super(bodyA, bodyB);\n\n if (typeof distance === 'undefined') {\n distance = bodyA.position.distanceTo(bodyB.position);\n }\n\n this.distance = distance;\n const eq = this.distanceEquation = new ContactEquation(bodyA, bodyB);\n this.equations.push(eq); // Make it bidirectional\n\n eq.minForce = -maxForce;\n eq.maxForce = maxForce;\n }\n\n update() {\n const bodyA = this.bodyA;\n const bodyB = this.bodyB;\n const eq = this.distanceEquation;\n const halfDist = this.distance * 0.5;\n const normal = eq.ni;\n bodyB.position.vsub(bodyA.position, normal);\n normal.normalize();\n normal.scale(halfDist, eq.ri);\n normal.scale(-halfDist, eq.rj);\n }\n\n}\n\n/**\r\n * Lock constraint. Will remove all degrees of freedom between the bodies.\r\n * @class LockConstraint\r\n * @constructor\r\n * @author schteppe\r\n * @param {Body} bodyA\r\n * @param {Body} bodyB\r\n * @param {object} [options]\r\n * @param {Number} [options.maxForce=1e6]\r\n * @extends PointToPointConstraint\r\n */\nclass LockConstraint extends PointToPointConstraint {\n constructor(bodyA, bodyB, options = {}) {\n const maxForce = typeof options.maxForce !== 'undefined' ? options.maxForce : 1e6; // Set pivot point in between\n\n const pivotA = new Vec3();\n const pivotB = new Vec3();\n const halfWay = new Vec3();\n bodyA.position.vadd(bodyB.position, halfWay);\n halfWay.scale(0.5, halfWay);\n bodyB.pointToLocalFrame(halfWay, pivotB);\n bodyA.pointToLocalFrame(halfWay, pivotA); // The point-to-point constraint will keep a point shared between the bodies\n\n super(bodyA, pivotA, bodyB, pivotB, maxForce); // Store initial rotation of the bodies as unit vectors in the local body spaces\n\n this.xA = bodyA.vectorToLocalFrame(Vec3.UNIT_X);\n this.xB = bodyB.vectorToLocalFrame(Vec3.UNIT_X);\n this.yA = bodyA.vectorToLocalFrame(Vec3.UNIT_Y);\n this.yB = bodyB.vectorToLocalFrame(Vec3.UNIT_Y);\n this.zA = bodyA.vectorToLocalFrame(Vec3.UNIT_Z);\n this.zB = bodyB.vectorToLocalFrame(Vec3.UNIT_Z); // ...and the following rotational equations will keep all rotational DOF's in place\n\n const r1 = this.rotationalEquation1 = new RotationalEquation(bodyA, bodyB, options);\n const r2 = this.rotationalEquation2 = new RotationalEquation(bodyA, bodyB, options);\n const r3 = this.rotationalEquation3 = new RotationalEquation(bodyA, bodyB, options);\n this.equations.push(r1, r2, r3);\n }\n\n update() {\n const bodyA = this.bodyA;\n const bodyB = this.bodyB;\n const motor = this.motorEquation;\n const r1 = this.rotationalEquation1;\n const r2 = this.rotationalEquation2;\n const r3 = this.rotationalEquation3;\n super.update(); // These vector pairs must be orthogonal\n\n bodyA.vectorToWorldFrame(this.xA, r1.axisA);\n bodyB.vectorToWorldFrame(this.yB, r1.axisB);\n bodyA.vectorToWorldFrame(this.yA, r2.axisA);\n bodyB.vectorToWorldFrame(this.zB, r2.axisB);\n bodyA.vectorToWorldFrame(this.zA, r3.axisA);\n bodyB.vectorToWorldFrame(this.xB, r3.axisB);\n }\n\n}\n\n/**\r\n * Rotational motor constraint. Tries to keep the relative angular velocity of the bodies to a given value.\r\n * @class RotationalMotorEquation\r\n * @constructor\r\n * @author schteppe\r\n * @param {Body} bodyA\r\n * @param {Body} bodyB\r\n * @param {Number} maxForce\r\n * @extends Equation\r\n */\nclass RotationalMotorEquation extends Equation {\n // World oriented rotational axis.\n // World oriented rotational axis.\n // Motor velocity.\n constructor(bodyA, bodyB, maxForce = 1e6) {\n super(bodyA, bodyB, -maxForce, maxForce);\n this.axisA = new Vec3();\n this.axisB = new Vec3();\n this.targetVelocity = 0;\n }\n\n computeB(h) {\n const a = this.a;\n const b = this.b;\n const bi = this.bi;\n const bj = this.bj;\n const axisA = this.axisA;\n const axisB = this.axisB;\n const GA = this.jacobianElementA;\n const GB = this.jacobianElementB; // g = 0\n // gdot = axisA * wi - axisB * wj\n // gdot = G * W = G * [vi wi vj wj]\n // =>\n // G = [0 axisA 0 -axisB]\n\n GA.rotational.copy(axisA);\n axisB.negate(GB.rotational);\n const GW = this.computeGW() - this.targetVelocity;\n const GiMf = this.computeGiMf();\n const B = -GW * b - h * GiMf;\n return B;\n }\n\n}\n\n/**\r\n * Hinge constraint. Think of it as a door hinge. It tries to keep the door in the correct place and with the correct orientation.\r\n * @class HingeConstraint\r\n * @constructor\r\n * @author schteppe\r\n * @param {Body} bodyA\r\n * @param {Body} bodyB\r\n * @param {object} [options]\r\n * @param {Vec3} [options.pivotA] A point defined locally in bodyA. This defines the offset of axisA.\r\n * @param {Vec3} [options.axisA] An axis that bodyA can rotate around, defined locally in bodyA.\r\n * @param {Vec3} [options.pivotB]\r\n * @param {Vec3} [options.axisB]\r\n * @param {Number} [options.maxForce=1e6]\r\n * @extends PointToPointConstraint\r\n */\nclass HingeConstraint extends PointToPointConstraint {\n // Rotation axis, defined locally in bodyA.\n // Rotation axis, defined locally in bodyB.\n constructor(bodyA, bodyB, options = {}) {\n const maxForce = typeof options.maxForce !== 'undefined' ? options.maxForce : 1e6;\n const pivotA = options.pivotA ? options.pivotA.clone() : new Vec3();\n const pivotB = options.pivotB ? options.pivotB.clone() : new Vec3();\n super(bodyA, pivotA, bodyB, pivotB, maxForce);\n const axisA = this.axisA = options.axisA ? options.axisA.clone() : new Vec3(1, 0, 0);\n axisA.normalize();\n const axisB = this.axisB = options.axisB ? options.axisB.clone() : new Vec3(1, 0, 0);\n axisB.normalize();\n this.collideConnected = !!options.collideConnected;\n const rotational1 = this.rotationalEquation1 = new RotationalEquation(bodyA, bodyB, options);\n const rotational2 = this.rotationalEquation2 = new RotationalEquation(bodyA, bodyB, options);\n const motor = this.motorEquation = new RotationalMotorEquation(bodyA, bodyB, maxForce);\n motor.enabled = false; // Not enabled by default\n // Equations to be fed to the solver\n\n this.equations.push(rotational1, rotational2, motor);\n }\n /**\r\n * @method enableMotor\r\n */\n\n\n enableMotor() {\n this.motorEquation.enabled = true;\n }\n /**\r\n * @method disableMotor\r\n */\n\n\n disableMotor() {\n this.motorEquation.enabled = false;\n }\n /**\r\n * @method setMotorSpeed\r\n * @param {number} speed\r\n */\n\n\n setMotorSpeed(speed) {\n this.motorEquation.targetVelocity = speed;\n }\n /**\r\n * @method setMotorMaxForce\r\n * @param {number} maxForce\r\n */\n\n\n setMotorMaxForce(maxForce) {\n this.motorEquation.maxForce = maxForce;\n this.motorEquation.minForce = -maxForce;\n }\n\n update() {\n const bodyA = this.bodyA;\n const bodyB = this.bodyB;\n const motor = this.motorEquation;\n const r1 = this.rotationalEquation1;\n const r2 = this.rotationalEquation2;\n const worldAxisA = HingeConstraint_update_tmpVec1;\n const worldAxisB = HingeConstraint_update_tmpVec2;\n const axisA = this.axisA;\n const axisB = this.axisB;\n super.update(); // Get world axes\n\n bodyA.quaternion.vmult(axisA, worldAxisA);\n bodyB.quaternion.vmult(axisB, worldAxisB);\n worldAxisA.tangents(r1.axisA, r2.axisA);\n r1.axisB.copy(worldAxisB);\n r2.axisB.copy(worldAxisB);\n\n if (this.motorEquation.enabled) {\n bodyA.quaternion.vmult(this.axisA, motor.axisA);\n bodyB.quaternion.vmult(this.axisB, motor.axisB);\n }\n }\n\n}\nconst HingeConstraint_update_tmpVec1 = new Vec3();\nconst HingeConstraint_update_tmpVec2 = new Vec3();\n\n/**\r\n * Constrains the slipping in a contact along a tangent\r\n * @class FrictionEquation\r\n * @constructor\r\n * @author schteppe\r\n * @param {Body} bodyA\r\n * @param {Body} bodyB\r\n * @param {Number} slipForce should be +-F_friction = +-mu * F_normal = +-mu * m * g\r\n * @extends Equation\r\n */\nclass FrictionEquation extends Equation {\n // Tangent.\n constructor(bodyA, bodyB, slipForce) {\n super(bodyA, bodyB, -slipForce, slipForce);\n this.ri = new Vec3();\n this.rj = new Vec3();\n this.t = new Vec3();\n }\n\n computeB(h) {\n const a = this.a;\n const b = this.b;\n const bi = this.bi;\n const bj = this.bj;\n const ri = this.ri;\n const rj = this.rj;\n const rixt = FrictionEquation_computeB_temp1;\n const rjxt = FrictionEquation_computeB_temp2;\n const t = this.t; // Caluclate cross products\n\n ri.cross(t, rixt);\n rj.cross(t, rjxt); // G = [-t -rixt t rjxt]\n // And remember, this is a pure velocity constraint, g is always zero!\n\n const GA = this.jacobianElementA;\n const GB = this.jacobianElementB;\n t.negate(GA.spatial);\n rixt.negate(GA.rotational);\n GB.spatial.copy(t);\n GB.rotational.copy(rjxt);\n const GW = this.computeGW();\n const GiMf = this.computeGiMf();\n const B = -GW * b - h * GiMf;\n return B;\n }\n\n}\nconst FrictionEquation_computeB_temp1 = new Vec3();\nconst FrictionEquation_computeB_temp2 = new Vec3();\n\n/**\n * Defines what happens when two materials meet.\n * @class ContactMaterial\n * @constructor\n * @param {Material} m1\n * @param {Material} m2\n * @param {object} [options]\n * @param {Number} [options.friction=0.3]\n * @param {Number} [options.restitution=0.3]\n * @param {number} [options.contactEquationStiffness=1e7]\n * @param {number} [options.contactEquationRelaxation=3]\n * @param {number} [options.frictionEquationStiffness=1e7]\n * @param {Number} [options.frictionEquationRelaxation=3]\n * @todo Refactor materials to materialA and materialB\n */\nclass ContactMaterial {\n // Identifier of this material.\n // Participating materials.\n // Friction coefficient.\n // Restitution coefficient.\n // Stiffness of the produced contact equations.\n // Relaxation time of the produced contact equations.\n // Stiffness of the produced friction equations.\n // Relaxation time of the produced friction equations\n constructor(m1, m2, options) {\n options = Utils.defaults(options, {\n friction: 0.3,\n restitution: 0.3,\n contactEquationStiffness: 1e7,\n contactEquationRelaxation: 3,\n frictionEquationStiffness: 1e7,\n frictionEquationRelaxation: 3\n });\n this.id = ContactMaterial.idCounter++;\n this.materials = [m1, m2];\n this.friction = options.friction;\n this.restitution = options.restitution;\n this.contactEquationStiffness = options.contactEquationStiffness;\n this.contactEquationRelaxation = options.contactEquationRelaxation;\n this.frictionEquationStiffness = options.frictionEquationStiffness;\n this.frictionEquationRelaxation = options.frictionEquationRelaxation;\n }\n\n}\nContactMaterial.idCounter = 0;\n\n/**\r\n * Defines a physics material.\r\n * @class Material\r\n * @constructor\r\n * @param {object} [options]\r\n * @author schteppe\r\n */\nclass Material {\n // Material name.\n // Material id.\n // Friction for this material. If non-negative, it will be used instead of the friction given by ContactMaterials. If there's no matching ContactMaterial, the value from .defaultContactMaterial in the World will be used.\n // Restitution for this material. If non-negative, it will be used instead of the restitution given by ContactMaterials. If there's no matching ContactMaterial, the value from .defaultContactMaterial in the World will be used.\n constructor(options = {}) {\n let name = ''; // Backwards compatibility fix\n\n if (typeof options === 'string') {\n name = options;\n options = {};\n }\n\n this.name = name;\n this.id = Material.idCounter++;\n this.friction = typeof options.friction !== 'undefined' ? options.friction : -1;\n this.restitution = typeof options.restitution !== 'undefined' ? options.restitution : -1;\n }\n\n}\nMaterial.idCounter = 0;\n\n/**\r\n * A spring, connecting two bodies.\r\n *\r\n * @class Spring\r\n * @constructor\r\n * @param {Body} bodyA\r\n * @param {Body} bodyB\r\n * @param {Object} [options]\r\n * @param {number} [options.restLength] A number > 0. Default: 1\r\n * @param {number} [options.stiffness] A number >= 0. Default: 100\r\n * @param {number} [options.damping] A number >= 0. Default: 1\r\n * @param {Vec3} [options.worldAnchorA] Where to hook the spring to body A, in world coordinates.\r\n * @param {Vec3} [options.worldAnchorB]\r\n * @param {Vec3} [options.localAnchorA] Where to hook the spring to body A, in local body coordinates.\r\n * @param {Vec3} [options.localAnchorB]\r\n */\nclass Spring {\n // Rest length of the spring.\n // Stiffness of the spring.\n // Damping of the spring.\n // First connected body.\n // Second connected body.\n // Anchor for bodyA in local bodyA coordinates.\n // Anchor for bodyB in local bodyB coordinates.\n constructor(bodyA, bodyB, options = {}) {\n this.restLength = typeof options.restLength === 'number' ? options.restLength : 1;\n this.stiffness = options.stiffness || 100;\n this.damping = options.damping || 1;\n this.bodyA = bodyA;\n this.bodyB = bodyB;\n this.localAnchorA = new Vec3();\n this.localAnchorB = new Vec3();\n\n if (options.localAnchorA) {\n this.localAnchorA.copy(options.localAnchorA);\n }\n\n if (options.localAnchorB) {\n this.localAnchorB.copy(options.localAnchorB);\n }\n\n if (options.worldAnchorA) {\n this.setWorldAnchorA(options.worldAnchorA);\n }\n\n if (options.worldAnchorB) {\n this.setWorldAnchorB(options.worldAnchorB);\n }\n }\n /**\r\n * Set the anchor point on body A, using world coordinates.\r\n * @method setWorldAnchorA\r\n * @param {Vec3} worldAnchorA\r\n */\n\n\n setWorldAnchorA(worldAnchorA) {\n this.bodyA.pointToLocalFrame(worldAnchorA, this.localAnchorA);\n }\n /**\r\n * Set the anchor point on body B, using world coordinates.\r\n * @method setWorldAnchorB\r\n * @param {Vec3} worldAnchorB\r\n */\n\n\n setWorldAnchorB(worldAnchorB) {\n this.bodyB.pointToLocalFrame(worldAnchorB, this.localAnchorB);\n }\n /**\r\n * Get the anchor point on body A, in world coordinates.\r\n * @method getWorldAnchorA\r\n * @param {Vec3} result The vector to store the result in.\r\n */\n\n\n getWorldAnchorA(result) {\n this.bodyA.pointToWorldFrame(this.localAnchorA, result);\n }\n /**\r\n * Get the anchor point on body B, in world coordinates.\r\n * @method getWorldAnchorB\r\n * @param {Vec3} result The vector to store the result in.\r\n */\n\n\n getWorldAnchorB(result) {\n this.bodyB.pointToWorldFrame(this.localAnchorB, result);\n }\n /**\r\n * Apply the spring force to the connected bodies.\r\n * @method applyForce\r\n */\n\n\n applyForce() {\n const k = this.stiffness;\n const d = this.damping;\n const l = this.restLength;\n const bodyA = this.bodyA;\n const bodyB = this.bodyB;\n const r = applyForce_r;\n const r_unit = applyForce_r_unit;\n const u = applyForce_u;\n const f = applyForce_f;\n const tmp = applyForce_tmp;\n const worldAnchorA = applyForce_worldAnchorA;\n const worldAnchorB = applyForce_worldAnchorB;\n const ri = applyForce_ri;\n const rj = applyForce_rj;\n const ri_x_f = applyForce_ri_x_f;\n const rj_x_f = applyForce_rj_x_f; // Get world anchors\n\n this.getWorldAnchorA(worldAnchorA);\n this.getWorldAnchorB(worldAnchorB); // Get offset points\n\n worldAnchorA.vsub(bodyA.position, ri);\n worldAnchorB.vsub(bodyB.position, rj); // Compute distance vector between world anchor points\n\n worldAnchorB.vsub(worldAnchorA, r);\n const rlen = r.length();\n r_unit.copy(r);\n r_unit.normalize(); // Compute relative velocity of the anchor points, u\n\n bodyB.velocity.vsub(bodyA.velocity, u); // Add rotational velocity\n\n bodyB.angularVelocity.cross(rj, tmp);\n u.vadd(tmp, u);\n bodyA.angularVelocity.cross(ri, tmp);\n u.vsub(tmp, u); // F = - k * ( x - L ) - D * ( u )\n\n r_unit.scale(-k * (rlen - l) - d * u.dot(r_unit), f); // Add forces to bodies\n\n bodyA.force.vsub(f, bodyA.force);\n bodyB.force.vadd(f, bodyB.force); // Angular force\n\n ri.cross(f, ri_x_f);\n rj.cross(f, rj_x_f);\n bodyA.torque.vsub(ri_x_f, bodyA.torque);\n bodyB.torque.vadd(rj_x_f, bodyB.torque);\n }\n\n}\nconst applyForce_r = new Vec3();\nconst applyForce_r_unit = new Vec3();\nconst applyForce_u = new Vec3();\nconst applyForce_f = new Vec3();\nconst applyForce_worldAnchorA = new Vec3();\nconst applyForce_worldAnchorB = new Vec3();\nconst applyForce_ri = new Vec3();\nconst applyForce_rj = new Vec3();\nconst applyForce_ri_x_f = new Vec3();\nconst applyForce_rj_x_f = new Vec3();\nconst applyForce_tmp = new Vec3();\n\n/**\r\n * @class WheelInfo\r\n * @constructor\r\n * @param {Object} [options]\r\n *\r\n * @param {Vec3} [options.chassisConnectionPointLocal]\r\n * @param {Vec3} [options.chassisConnectionPointWorld]\r\n * @param {Vec3} [options.directionLocal]\r\n * @param {Vec3} [options.directionWorld]\r\n * @param {Vec3} [options.axleLocal]\r\n * @param {Vec3} [options.axleWorld]\r\n * @param {number} [options.suspensionRestLength=1]\r\n * @param {number} [options.suspensionMaxLength=2]\r\n * @param {number} [options.radius=1]\r\n * @param {number} [options.suspensionStiffness=100]\r\n * @param {number} [options.dampingCompression=10]\r\n * @param {number} [options.dampingRelaxation=10]\r\n * @param {number} [options.frictionSlip=10000]\r\n * @param {number} [options.steering=0]\r\n * @param {number} [options.rotation=0]\r\n * @param {number} [options.deltaRotation=0]\r\n * @param {number} [options.rollInfluence=0.01]\r\n * @param {number} [options.maxSuspensionForce]\r\n * @param {boolean} [options.isFrontWheel=true]\r\n * @param {number} [options.clippedInvContactDotSuspension=1]\r\n * @param {number} [options.suspensionRelativeVelocity=0]\r\n * @param {number} [options.suspensionForce=0]\r\n * @param {number} [options.skidInfo=0]\r\n * @param {number} [options.suspensionLength=0]\r\n * @param {number} [options.maxSuspensionTravel=1]\r\n * @param {boolean} [options.useCustomSlidingRotationalSpeed=false]\r\n * @param {number} [options.customSlidingRotationalSpeed=-0.1]\r\n */\nclass WheelInfo {\n // Max travel distance of the suspension, in meters.\n // Speed to apply to the wheel rotation when the wheel is sliding.\n // If the customSlidingRotationalSpeed should be used.\n // Connection point, defined locally in the chassis body frame.\n // Rotation value, in radians.\n // The result from raycasting.\n // Wheel world transform.\n constructor(options = {}) {\n options = Utils.defaults(options, {\n chassisConnectionPointLocal: new Vec3(),\n chassisConnectionPointWorld: new Vec3(),\n directionLocal: new Vec3(),\n directionWorld: new Vec3(),\n axleLocal: new Vec3(),\n axleWorld: new Vec3(),\n suspensionRestLength: 1,\n suspensionMaxLength: 2,\n radius: 1,\n suspensionStiffness: 100,\n dampingCompression: 10,\n dampingRelaxation: 10,\n frictionSlip: 10000,\n steering: 0,\n rotation: 0,\n deltaRotation: 0,\n rollInfluence: 0.01,\n maxSuspensionForce: Number.MAX_VALUE,\n isFrontWheel: true,\n clippedInvContactDotSuspension: 1,\n suspensionRelativeVelocity: 0,\n suspensionForce: 0,\n slipInfo: 0,\n skidInfo: 0,\n suspensionLength: 0,\n maxSuspensionTravel: 1,\n useCustomSlidingRotationalSpeed: false,\n customSlidingRotationalSpeed: -0.1\n });\n this.maxSuspensionTravel = options.maxSuspensionTravel;\n this.customSlidingRotationalSpeed = options.customSlidingRotationalSpeed;\n this.useCustomSlidingRotationalSpeed = options.useCustomSlidingRotationalSpeed;\n this.sliding = false;\n this.chassisConnectionPointLocal = options.chassisConnectionPointLocal.clone();\n this.chassisConnectionPointWorld = options.chassisConnectionPointWorld.clone();\n this.directionLocal = options.directionLocal.clone();\n this.directionWorld = options.directionWorld.clone();\n this.axleLocal = options.axleLocal.clone();\n this.axleWorld = options.axleWorld.clone();\n this.suspensionRestLength = options.suspensionRestLength;\n this.suspensionMaxLength = options.suspensionMaxLength;\n this.radius = options.radius;\n this.suspensionStiffness = options.suspensionStiffness;\n this.dampingCompression = options.dampingCompression;\n this.dampingRelaxation = options.dampingRelaxation;\n this.frictionSlip = options.frictionSlip;\n this.steering = 0;\n this.rotation = 0;\n this.deltaRotation = 0;\n this.rollInfluence = options.rollInfluence;\n this.maxSuspensionForce = options.maxSuspensionForce;\n this.engineForce = 0;\n this.brake = 0;\n this.isFrontWheel = options.isFrontWheel;\n this.clippedInvContactDotSuspension = 1;\n this.suspensionRelativeVelocity = 0;\n this.suspensionForce = 0;\n this.slipInfo = 0;\n this.skidInfo = 0;\n this.suspensionLength = 0;\n this.sideImpulse = 0;\n this.forwardImpulse = 0;\n this.raycastResult = new RaycastResult();\n this.worldTransform = new Transform();\n this.isInContact = false;\n }\n\n updateWheel(chassis) {\n const raycastResult = this.raycastResult;\n\n if (this.isInContact) {\n const project = raycastResult.hitNormalWorld.dot(raycastResult.directionWorld);\n raycastResult.hitPointWorld.vsub(chassis.position, relpos);\n chassis.getVelocityAtWorldPoint(relpos, chassis_velocity_at_contactPoint);\n const projVel = raycastResult.hitNormalWorld.dot(chassis_velocity_at_contactPoint);\n\n if (project >= -0.1) {\n this.suspensionRelativeVelocity = 0.0;\n this.clippedInvContactDotSuspension = 1.0 / 0.1;\n } else {\n const inv = -1 / project;\n this.suspensionRelativeVelocity = projVel * inv;\n this.clippedInvContactDotSuspension = inv;\n }\n } else {\n // Not in contact : position wheel in a nice (rest length) position\n raycastResult.suspensionLength = this.suspensionRestLength;\n this.suspensionRelativeVelocity = 0.0;\n raycastResult.directionWorld.scale(-1, raycastResult.hitNormalWorld);\n this.clippedInvContactDotSuspension = 1.0;\n }\n }\n\n}\nconst chassis_velocity_at_contactPoint = new Vec3();\nconst relpos = new Vec3();\n\n/**\r\n * Vehicle helper class that casts rays from the wheel positions towards the ground and applies forces.\r\n * @class RaycastVehicle\r\n * @constructor\r\n * @param {object} [options]\r\n * @param {Body} [options.chassisBody] The car chassis body.\r\n * @param {integer} [options.indexRightAxis] Axis to use for right. x=0, y=1, z=2\r\n * @param {integer} [options.indexLeftAxis]\r\n * @param {integer} [options.indexUpAxis]\r\n */\nclass RaycastVehicle {\n // Will be set to true if the car is sliding.\n // Index of the right axis, 0=x, 1=y, 2=z\n // Index of the forward axis, 0=x, 1=y, 2=z\n // Index of the up axis, 0=x, 1=y, 2=z\n constructor(options) {\n this.chassisBody = options.chassisBody;\n this.wheelInfos = [];\n this.sliding = false;\n this.world = null;\n this.indexRightAxis = typeof options.indexRightAxis !== 'undefined' ? options.indexRightAxis : 1;\n this.indexForwardAxis = typeof options.indexForwardAxis !== 'undefined' ? options.indexForwardAxis : 0;\n this.indexUpAxis = typeof options.indexUpAxis !== 'undefined' ? options.indexUpAxis : 2;\n this.constraints = [];\n\n this.preStepCallback = () => {};\n\n this.currentVehicleSpeedKmHour = 0;\n }\n /**\r\n * Add a wheel. For information about the options, see WheelInfo.\r\n * @method addWheel\r\n * @param {object} [options]\r\n */\n\n\n addWheel(options = {}) {\n const info = new WheelInfo(options);\n const index = this.wheelInfos.length;\n this.wheelInfos.push(info);\n return index;\n }\n /**\r\n * Set the steering value of a wheel.\r\n * @method setSteeringValue\r\n * @param {number} value\r\n * @param {integer} wheelIndex\r\n */\n\n\n setSteeringValue(value, wheelIndex) {\n const wheel = this.wheelInfos[wheelIndex];\n wheel.steering = value;\n }\n /**\r\n * Set the wheel force to apply on one of the wheels each time step\r\n * @method applyEngineForce\r\n * @param {number} value\r\n * @param {integer} wheelIndex\r\n */\n\n\n applyEngineForce(value, wheelIndex) {\n this.wheelInfos[wheelIndex].engineForce = value;\n }\n /**\r\n * Set the braking force of a wheel\r\n * @method setBrake\r\n * @param {number} brake\r\n * @param {integer} wheelIndex\r\n */\n\n\n setBrake(brake, wheelIndex) {\n this.wheelInfos[wheelIndex].brake = brake;\n }\n /**\r\n * Add the vehicle including its constraints to the world.\r\n * @method addToWorld\r\n * @param {World} world\r\n */\n\n\n addToWorld(world) {\n const constraints = this.constraints;\n world.addBody(this.chassisBody);\n const that = this;\n\n this.preStepCallback = () => {\n that.updateVehicle(world.dt);\n };\n\n world.addEventListener('preStep', this.preStepCallback);\n this.world = world;\n }\n /**\r\n * Get one of the wheel axles, world-oriented.\r\n * @private\r\n * @method getVehicleAxisWorld\r\n * @param {integer} axisIndex\r\n * @param {Vec3} result\r\n */\n\n\n getVehicleAxisWorld(axisIndex, result) {\n result.set(axisIndex === 0 ? 1 : 0, axisIndex === 1 ? 1 : 0, axisIndex === 2 ? 1 : 0);\n this.chassisBody.vectorToWorldFrame(result, result);\n }\n\n updateVehicle(timeStep) {\n const wheelInfos = this.wheelInfos;\n const numWheels = wheelInfos.length;\n const chassisBody = this.chassisBody;\n\n for (let i = 0; i < numWheels; i++) {\n this.updateWheelTransform(i);\n }\n\n this.currentVehicleSpeedKmHour = 3.6 * chassisBody.velocity.length();\n const forwardWorld = new Vec3();\n this.getVehicleAxisWorld(this.indexForwardAxis, forwardWorld);\n\n if (forwardWorld.dot(chassisBody.velocity) < 0) {\n this.currentVehicleSpeedKmHour *= -1;\n } // simulate suspension\n\n\n for (let i = 0; i < numWheels; i++) {\n this.castRay(wheelInfos[i]);\n }\n\n this.updateSuspension(timeStep);\n const impulse = new Vec3();\n const relpos = new Vec3();\n\n for (let i = 0; i < numWheels; i++) {\n //apply suspension force\n const wheel = wheelInfos[i];\n let suspensionForce = wheel.suspensionForce;\n\n if (suspensionForce > wheel.maxSuspensionForce) {\n suspensionForce = wheel.maxSuspensionForce;\n }\n\n wheel.raycastResult.hitNormalWorld.scale(suspensionForce * timeStep, impulse);\n wheel.raycastResult.hitPointWorld.vsub(chassisBody.position, relpos);\n chassisBody.applyImpulse(impulse, relpos);\n }\n\n this.updateFriction(timeStep);\n const hitNormalWorldScaledWithProj = new Vec3();\n const fwd = new Vec3();\n const vel = new Vec3();\n\n for (let i = 0; i < numWheels; i++) {\n const wheel = wheelInfos[i]; //const relpos = new Vec3();\n //wheel.chassisConnectionPointWorld.vsub(chassisBody.position, relpos);\n\n chassisBody.getVelocityAtWorldPoint(wheel.chassisConnectionPointWorld, vel); // Hack to get the rotation in the correct direction\n\n let m = 1;\n\n switch (this.indexUpAxis) {\n case 1:\n m = -1;\n break;\n }\n\n if (wheel.isInContact) {\n this.getVehicleAxisWorld(this.indexForwardAxis, fwd);\n const proj = fwd.dot(wheel.raycastResult.hitNormalWorld);\n wheel.raycastResult.hitNormalWorld.scale(proj, hitNormalWorldScaledWithProj);\n fwd.vsub(hitNormalWorldScaledWithProj, fwd);\n const proj2 = fwd.dot(vel);\n wheel.deltaRotation = m * proj2 * timeStep / wheel.radius;\n }\n\n if ((wheel.sliding || !wheel.isInContact) && wheel.engineForce !== 0 && wheel.useCustomSlidingRotationalSpeed) {\n // Apply custom rotation when accelerating and sliding\n wheel.deltaRotation = (wheel.engineForce > 0 ? 1 : -1) * wheel.customSlidingRotationalSpeed * timeStep;\n } // Lock wheels\n\n\n if (Math.abs(wheel.brake) > Math.abs(wheel.engineForce)) {\n wheel.deltaRotation = 0;\n }\n\n wheel.rotation += wheel.deltaRotation; // Use the old value\n\n wheel.deltaRotation *= 0.99; // damping of rotation when not in contact\n }\n }\n\n updateSuspension(deltaTime) {\n const chassisBody = this.chassisBody;\n const chassisMass = chassisBody.mass;\n const wheelInfos = this.wheelInfos;\n const numWheels = wheelInfos.length;\n\n for (let w_it = 0; w_it < numWheels; w_it++) {\n const wheel = wheelInfos[w_it];\n\n if (wheel.isInContact) {\n let force; // Spring\n\n const susp_length = wheel.suspensionRestLength;\n const current_length = wheel.suspensionLength;\n const length_diff = susp_length - current_length;\n force = wheel.suspensionStiffness * length_diff * wheel.clippedInvContactDotSuspension; // Damper\n\n const projected_rel_vel = wheel.suspensionRelativeVelocity;\n let susp_damping;\n\n if (projected_rel_vel < 0) {\n susp_damping = wheel.dampingCompression;\n } else {\n susp_damping = wheel.dampingRelaxation;\n }\n\n force -= susp_damping * projected_rel_vel;\n wheel.suspensionForce = force * chassisMass;\n\n if (wheel.suspensionForce < 0) {\n wheel.suspensionForce = 0;\n }\n } else {\n wheel.suspensionForce = 0;\n }\n }\n }\n /**\r\n * Remove the vehicle including its constraints from the world.\r\n * @method removeFromWorld\r\n * @param {World} world\r\n */\n\n\n removeFromWorld(world) {\n const constraints = this.constraints;\n world.removeBody(this.chassisBody);\n world.removeEventListener('preStep', this.preStepCallback);\n this.world = null;\n }\n\n castRay(wheel) {\n const rayvector = castRay_rayvector;\n const target = castRay_target;\n this.updateWheelTransformWorld(wheel);\n const chassisBody = this.chassisBody;\n let depth = -1;\n const raylen = wheel.suspensionRestLength + wheel.radius;\n wheel.directionWorld.scale(raylen, rayvector);\n const source = wheel.chassisConnectionPointWorld;\n source.vadd(rayvector, target);\n const raycastResult = wheel.raycastResult;\n raycastResult.reset(); // Turn off ray collision with the chassis temporarily\n\n const oldState = chassisBody.collisionResponse;\n chassisBody.collisionResponse = false; // Cast ray against world\n\n this.world.rayTest(source, target, raycastResult);\n chassisBody.collisionResponse = oldState;\n const object = raycastResult.body;\n wheel.raycastResult.groundObject = 0;\n\n if (object) {\n depth = raycastResult.distance;\n wheel.raycastResult.hitNormalWorld = raycastResult.hitNormalWorld;\n wheel.isInContact = true;\n const hitDistance = raycastResult.distance;\n wheel.suspensionLength = hitDistance - wheel.radius; // clamp on max suspension travel\n\n const minSuspensionLength = wheel.suspensionRestLength - wheel.maxSuspensionTravel;\n const maxSuspensionLength = wheel.suspensionRestLength + wheel.maxSuspensionTravel;\n\n if (wheel.suspensionLength < minSuspensionLength) {\n wheel.suspensionLength = minSuspensionLength;\n }\n\n if (wheel.suspensionLength > maxSuspensionLength) {\n wheel.suspensionLength = maxSuspensionLength;\n wheel.raycastResult.reset();\n }\n\n const denominator = wheel.raycastResult.hitNormalWorld.dot(wheel.directionWorld);\n const chassis_velocity_at_contactPoint = new Vec3();\n chassisBody.getVelocityAtWorldPoint(wheel.raycastResult.hitPointWorld, chassis_velocity_at_contactPoint);\n const projVel = wheel.raycastResult.hitNormalWorld.dot(chassis_velocity_at_contactPoint);\n\n if (denominator >= -0.1) {\n wheel.suspensionRelativeVelocity = 0;\n wheel.clippedInvContactDotSuspension = 1 / 0.1;\n } else {\n const inv = -1 / denominator;\n wheel.suspensionRelativeVelocity = projVel * inv;\n wheel.clippedInvContactDotSuspension = inv;\n }\n } else {\n //put wheel info as in rest position\n wheel.suspensionLength = wheel.suspensionRestLength + 0 * wheel.maxSuspensionTravel;\n wheel.suspensionRelativeVelocity = 0.0;\n wheel.directionWorld.scale(-1, wheel.raycastResult.hitNormalWorld);\n wheel.clippedInvContactDotSuspension = 1.0;\n }\n\n return depth;\n }\n\n updateWheelTransformWorld(wheel) {\n wheel.isInContact = false;\n const chassisBody = this.chassisBody;\n chassisBody.pointToWorldFrame(wheel.chassisConnectionPointLocal, wheel.chassisConnectionPointWorld);\n chassisBody.vectorToWorldFrame(wheel.directionLocal, wheel.directionWorld);\n chassisBody.vectorToWorldFrame(wheel.axleLocal, wheel.axleWorld);\n }\n /**\r\n * Update one of the wheel transform.\r\n * Note when rendering wheels: during each step, wheel transforms are updated BEFORE the chassis; ie. their position becomes invalid after the step. Thus when you render wheels, you must update wheel transforms before rendering them. See raycastVehicle demo for an example.\r\n * @method updateWheelTransform\r\n * @param {integer} wheelIndex The wheel index to update.\r\n */\n\n\n updateWheelTransform(wheelIndex) {\n const up = tmpVec4;\n const right = tmpVec5;\n const fwd = tmpVec6;\n const wheel = this.wheelInfos[wheelIndex];\n this.updateWheelTransformWorld(wheel);\n wheel.directionLocal.scale(-1, up);\n right.copy(wheel.axleLocal);\n up.cross(right, fwd);\n fwd.normalize();\n right.normalize(); // Rotate around steering over the wheelAxle\n\n const steering = wheel.steering;\n const steeringOrn = new Quaternion();\n steeringOrn.setFromAxisAngle(up, steering);\n const rotatingOrn = new Quaternion();\n rotatingOrn.setFromAxisAngle(right, wheel.rotation); // World rotation of the wheel\n\n const q = wheel.worldTransform.quaternion;\n this.chassisBody.quaternion.mult(steeringOrn, q);\n q.mult(rotatingOrn, q);\n q.normalize(); // world position of the wheel\n\n const p = wheel.worldTransform.position;\n p.copy(wheel.directionWorld);\n p.scale(wheel.suspensionLength, p);\n p.vadd(wheel.chassisConnectionPointWorld, p);\n }\n /**\r\n * Get the world transform of one of the wheels\r\n * @method getWheelTransformWorld\r\n * @param {integer} wheelIndex\r\n * @return {Transform}\r\n */\n\n\n getWheelTransformWorld(wheelIndex) {\n return this.wheelInfos[wheelIndex].worldTransform;\n }\n\n updateFriction(timeStep) {\n const surfNormalWS_scaled_proj = updateFriction_surfNormalWS_scaled_proj; //calculate the impulse, so that the wheels don't move sidewards\n\n const wheelInfos = this.wheelInfos;\n const numWheels = wheelInfos.length;\n const chassisBody = this.chassisBody;\n const forwardWS = updateFriction_forwardWS;\n const axle = updateFriction_axle;\n\n for (let i = 0; i < numWheels; i++) {\n const wheel = wheelInfos[i];\n const groundObject = wheel.raycastResult.body;\n\n wheel.sideImpulse = 0;\n wheel.forwardImpulse = 0;\n\n if (!forwardWS[i]) {\n forwardWS[i] = new Vec3();\n }\n\n if (!axle[i]) {\n axle[i] = new Vec3();\n }\n }\n\n for (let i = 0; i < numWheels; i++) {\n const wheel = wheelInfos[i];\n const groundObject = wheel.raycastResult.body;\n\n if (groundObject) {\n const axlei = axle[i];\n const wheelTrans = this.getWheelTransformWorld(i); // Get world axle\n\n wheelTrans.vectorToWorldFrame(directions[this.indexRightAxis], axlei);\n const surfNormalWS = wheel.raycastResult.hitNormalWorld;\n const proj = axlei.dot(surfNormalWS);\n surfNormalWS.scale(proj, surfNormalWS_scaled_proj);\n axlei.vsub(surfNormalWS_scaled_proj, axlei);\n axlei.normalize();\n surfNormalWS.cross(axlei, forwardWS[i]);\n forwardWS[i].normalize();\n wheel.sideImpulse = resolveSingleBilateral(chassisBody, wheel.raycastResult.hitPointWorld, groundObject, wheel.raycastResult.hitPointWorld, axlei);\n wheel.sideImpulse *= sideFrictionStiffness2;\n }\n }\n\n const sideFactor = 1;\n const fwdFactor = 0.5;\n this.sliding = false;\n\n for (let i = 0; i < numWheels; i++) {\n const wheel = wheelInfos[i];\n const groundObject = wheel.raycastResult.body;\n let rollingFriction = 0;\n wheel.slipInfo = 1;\n\n if (groundObject) {\n const defaultRollingFrictionImpulse = 0;\n const maxImpulse = wheel.brake ? wheel.brake : defaultRollingFrictionImpulse; // btWheelContactPoint contactPt(chassisBody,groundObject,wheelInfraycastInfo.hitPointWorld,forwardWS[wheel],maxImpulse);\n // rollingFriction = calcRollingFriction(contactPt);\n\n rollingFriction = calcRollingFriction(chassisBody, groundObject, wheel.raycastResult.hitPointWorld, forwardWS[i], maxImpulse);\n rollingFriction += wheel.engineForce * timeStep; // rollingFriction = 0;\n\n const factor = maxImpulse / rollingFriction;\n wheel.slipInfo *= factor;\n } //switch between active rolling (throttle), braking and non-active rolling friction (nthrottle/break)\n\n\n wheel.forwardImpulse = 0;\n wheel.skidInfo = 1;\n\n if (groundObject) {\n wheel.skidInfo = 1;\n const maximp = wheel.suspensionForce * timeStep * wheel.frictionSlip;\n const maximpSide = maximp;\n const maximpSquared = maximp * maximpSide;\n wheel.forwardImpulse = rollingFriction; //wheelInfo.engineForce* timeStep;\n\n const x = wheel.forwardImpulse * fwdFactor;\n const y = wheel.sideImpulse * sideFactor;\n const impulseSquared = x * x + y * y;\n wheel.sliding = false;\n\n if (impulseSquared > maximpSquared) {\n this.sliding = true;\n wheel.sliding = true;\n const factor = maximp / Math.sqrt(impulseSquared);\n wheel.skidInfo *= factor;\n }\n }\n }\n\n if (this.sliding) {\n for (let i = 0; i < numWheels; i++) {\n const wheel = wheelInfos[i];\n\n if (wheel.sideImpulse !== 0) {\n if (wheel.skidInfo < 1) {\n wheel.forwardImpulse *= wheel.skidInfo;\n wheel.sideImpulse *= wheel.skidInfo;\n }\n }\n }\n } // apply the impulses\n\n\n for (let i = 0; i < numWheels; i++) {\n const wheel = wheelInfos[i];\n const rel_pos = new Vec3();\n wheel.raycastResult.hitPointWorld.vsub(chassisBody.position, rel_pos); // cannons applyimpulse is using world coord for the position\n //rel_pos.copy(wheel.raycastResult.hitPointWorld);\n\n if (wheel.forwardImpulse !== 0) {\n const impulse = new Vec3();\n forwardWS[i].scale(wheel.forwardImpulse, impulse);\n chassisBody.applyImpulse(impulse, rel_pos);\n }\n\n if (wheel.sideImpulse !== 0) {\n const groundObject = wheel.raycastResult.body;\n const rel_pos2 = new Vec3();\n wheel.raycastResult.hitPointWorld.vsub(groundObject.position, rel_pos2); //rel_pos2.copy(wheel.raycastResult.hitPointWorld);\n\n const sideImp = new Vec3();\n axle[i].scale(wheel.sideImpulse, sideImp); // Scale the relative position in the up direction with rollInfluence.\n // If rollInfluence is 1, the impulse will be applied on the hitPoint (easy to roll over), if it is zero it will be applied in the same plane as the center of mass (not easy to roll over).\n\n chassisBody.vectorToLocalFrame(rel_pos, rel_pos);\n rel_pos['xyz'[this.indexUpAxis]] *= wheel.rollInfluence;\n chassisBody.vectorToWorldFrame(rel_pos, rel_pos);\n chassisBody.applyImpulse(sideImp, rel_pos); //apply friction impulse on the ground\n\n sideImp.scale(-1, sideImp);\n groundObject.applyImpulse(sideImp, rel_pos2);\n }\n }\n }\n\n}\nconst tmpVec4 = new Vec3();\nconst tmpVec5 = new Vec3();\nconst tmpVec6 = new Vec3();\nconst tmpRay = new Ray();\nconst castRay_rayvector = new Vec3();\nconst castRay_target = new Vec3();\nconst directions = [new Vec3(1, 0, 0), new Vec3(0, 1, 0), new Vec3(0, 0, 1)];\nconst updateFriction_surfNormalWS_scaled_proj = new Vec3();\nconst updateFriction_axle = [];\nconst updateFriction_forwardWS = [];\nconst sideFrictionStiffness2 = 1;\nconst calcRollingFriction_vel1 = new Vec3();\nconst calcRollingFriction_vel2 = new Vec3();\nconst calcRollingFriction_vel = new Vec3();\n\nfunction calcRollingFriction(body0, body1, frictionPosWorld, frictionDirectionWorld, maxImpulse) {\n let j1 = 0;\n const contactPosWorld = frictionPosWorld; // const rel_pos1 = new Vec3();\n // const rel_pos2 = new Vec3();\n\n const vel1 = calcRollingFriction_vel1;\n const vel2 = calcRollingFriction_vel2;\n const vel = calcRollingFriction_vel; // contactPosWorld.vsub(body0.position, rel_pos1);\n // contactPosWorld.vsub(body1.position, rel_pos2);\n\n body0.getVelocityAtWorldPoint(contactPosWorld, vel1);\n body1.getVelocityAtWorldPoint(contactPosWorld, vel2);\n vel1.vsub(vel2, vel);\n const vrel = frictionDirectionWorld.dot(vel);\n const denom0 = computeImpulseDenominator(body0, frictionPosWorld, frictionDirectionWorld);\n const denom1 = computeImpulseDenominator(body1, frictionPosWorld, frictionDirectionWorld);\n const relaxation = 1;\n const jacDiagABInv = relaxation / (denom0 + denom1); // calculate j that moves us to zero relative velocity\n\n j1 = -vrel * jacDiagABInv;\n\n if (maxImpulse < j1) {\n j1 = maxImpulse;\n }\n\n if (j1 < -maxImpulse) {\n j1 = -maxImpulse;\n }\n\n return j1;\n}\n\nconst computeImpulseDenominator_r0 = new Vec3();\nconst computeImpulseDenominator_c0 = new Vec3();\nconst computeImpulseDenominator_vec = new Vec3();\nconst computeImpulseDenominator_m = new Vec3();\n\nfunction computeImpulseDenominator(body, pos, normal) {\n const r0 = computeImpulseDenominator_r0;\n const c0 = computeImpulseDenominator_c0;\n const vec = computeImpulseDenominator_vec;\n const m = computeImpulseDenominator_m;\n pos.vsub(body.position, r0);\n r0.cross(normal, c0);\n body.invInertiaWorld.vmult(c0, m);\n m.cross(r0, vec);\n return body.invMass + normal.dot(vec);\n}\n\nconst resolveSingleBilateral_vel1 = new Vec3();\nconst resolveSingleBilateral_vel2 = new Vec3();\nconst resolveSingleBilateral_vel = new Vec3(); //bilateral constraint between two dynamic objects\n\nfunction resolveSingleBilateral(body1, pos1, body2, pos2, normal) {\n const normalLenSqr = normal.lengthSquared();\n\n if (normalLenSqr > 1.1) {\n return 0; // no impulse\n } // const rel_pos1 = new Vec3();\n // const rel_pos2 = new Vec3();\n // pos1.vsub(body1.position, rel_pos1);\n // pos2.vsub(body2.position, rel_pos2);\n\n\n const vel1 = resolveSingleBilateral_vel1;\n const vel2 = resolveSingleBilateral_vel2;\n const vel = resolveSingleBilateral_vel;\n body1.getVelocityAtWorldPoint(pos1, vel1);\n body2.getVelocityAtWorldPoint(pos2, vel2);\n vel1.vsub(vel2, vel);\n const rel_vel = normal.dot(vel);\n const contactDamping = 0.2;\n const massTerm = 1 / (body1.invMass + body2.invMass);\n const impulse = -contactDamping * rel_vel * massTerm;\n return impulse;\n}\n\n/**\r\n * Spherical shape\r\n * @class Sphere\r\n * @constructor\r\n * @extends Shape\r\n * @param {Number} radius The radius of the sphere, a non-negative number.\r\n * @author schteppe / http://github.com/schteppe\r\n */\nclass Sphere extends Shape {\n constructor(radius) {\n super({\n type: Shape.types.SPHERE\n });\n this.radius = radius !== undefined ? radius : 1.0;\n\n if (this.radius < 0) {\n throw new Error('The sphere radius cannot be negative.');\n }\n\n this.updateBoundingSphereRadius();\n }\n\n calculateLocalInertia(mass, target = new Vec3()) {\n const I = 2.0 * mass * this.radius * this.radius / 5.0;\n target.x = I;\n target.y = I;\n target.z = I;\n return target;\n }\n\n volume() {\n return 4.0 * Math.PI * Math.pow(this.radius, 3) / 3.0;\n }\n\n updateBoundingSphereRadius() {\n this.boundingSphereRadius = this.radius;\n }\n\n calculateWorldAABB(pos, quat, min, max) {\n const r = this.radius;\n const axes = ['x', 'y', 'z'];\n\n for (let i = 0; i < axes.length; i++) {\n const ax = axes[i];\n min[ax] = pos[ax] - r;\n max[ax] = pos[ax] + r;\n }\n }\n\n}\n\n/**\r\n * Simple vehicle helper class with spherical rigid body wheels.\r\n * @class RigidVehicle\r\n * @constructor\r\n * @param {Body} [options.chassisBody]\r\n */\nclass RigidVehicle {\n constructor(options = {}) {\n this.wheelBodies = [];\n this.coordinateSystem = typeof options.coordinateSystem !== 'undefined' ? options.coordinateSystem.clone() : new Vec3(1, 2, 3);\n\n if (options.chassisBody) {\n this.chassisBody = options.chassisBody;\n } else {\n // No chassis body given. Create it!\n this.chassisBody = new Body({\n mass: 1,\n shape: new Box(new Vec3(5, 2, 0.5))\n });\n }\n\n this.constraints = [];\n this.wheelAxes = [];\n this.wheelForces = [];\n }\n /**\r\n * Add a wheel\r\n * @method addWheel\r\n * @param {object} options\r\n * @param {boolean} [options.isFrontWheel]\r\n * @param {Vec3} [options.position] Position of the wheel, locally in the chassis body.\r\n * @param {Vec3} [options.direction] Slide direction of the wheel along the suspension.\r\n * @param {Vec3} [options.axis] Axis of rotation of the wheel, locally defined in the chassis.\r\n * @param {Body} [options.body] The wheel body.\r\n */\n\n\n addWheel(options = {}) {\n let wheelBody;\n\n if (options.body) {\n wheelBody = options.body;\n } else {\n // No wheel body given. Create it!\n wheelBody = new Body({\n mass: 1,\n shape: new Sphere(1.2)\n });\n }\n\n this.wheelBodies.push(wheelBody);\n this.wheelForces.push(0); // Position constrain wheels\n const position = typeof options.position !== 'undefined' ? options.position.clone() : new Vec3(); // Set position locally to the chassis\n\n const worldPosition = new Vec3();\n this.chassisBody.pointToWorldFrame(position, worldPosition);\n wheelBody.position.set(worldPosition.x, worldPosition.y, worldPosition.z); // Constrain wheel\n\n const axis = typeof options.axis !== 'undefined' ? options.axis.clone() : new Vec3(0, 1, 0);\n this.wheelAxes.push(axis);\n const hingeConstraint = new HingeConstraint(this.chassisBody, wheelBody, {\n pivotA: position,\n axisA: axis,\n pivotB: Vec3.ZERO,\n axisB: axis,\n collideConnected: false\n });\n this.constraints.push(hingeConstraint);\n return this.wheelBodies.length - 1;\n }\n /**\r\n * Set the steering value of a wheel.\r\n * @method setSteeringValue\r\n * @param {number} value\r\n * @param {integer} wheelIndex\r\n * @todo check coordinateSystem\r\n */\n\n\n setSteeringValue(value, wheelIndex) {\n // Set angle of the hinge axis\n const axis = this.wheelAxes[wheelIndex];\n const c = Math.cos(value);\n const s = Math.sin(value);\n const x = axis.x;\n const y = axis.y;\n this.constraints[wheelIndex].axisA.set(c * x - s * y, s * x + c * y, 0);\n }\n /**\r\n * Set the target rotational speed of the hinge constraint.\r\n * @method setMotorSpeed\r\n * @param {number} value\r\n * @param {integer} wheelIndex\r\n */\n\n\n setMotorSpeed(value, wheelIndex) {\n const hingeConstraint = this.constraints[wheelIndex];\n hingeConstraint.enableMotor();\n hingeConstraint.motorTargetVelocity = value;\n }\n /**\r\n * Set the target rotational speed of the hinge constraint.\r\n * @method disableMotor\r\n * @param {number} value\r\n * @param {integer} wheelIndex\r\n */\n\n\n disableMotor(wheelIndex) {\n const hingeConstraint = this.constraints[wheelIndex];\n hingeConstraint.disableMotor();\n }\n /**\r\n * Set the wheel force to apply on one of the wheels each time step\r\n * @method setWheelForce\r\n * @param {number} value\r\n * @param {integer} wheelIndex\r\n */\n\n\n setWheelForce(value, wheelIndex) {\n this.wheelForces[wheelIndex] = value;\n }\n /**\r\n * Apply a torque on one of the wheels.\r\n * @method applyWheelForce\r\n * @param {number} value\r\n * @param {integer} wheelIndex\r\n */\n\n\n applyWheelForce(value, wheelIndex) {\n const axis = this.wheelAxes[wheelIndex];\n const wheelBody = this.wheelBodies[wheelIndex];\n const bodyTorque = wheelBody.torque;\n axis.scale(value, torque);\n wheelBody.vectorToWorldFrame(torque, torque);\n bodyTorque.vadd(torque, bodyTorque);\n }\n /**\r\n * Add the vehicle including its constraints to the world.\r\n * @method addToWorld\r\n * @param {World} world\r\n */\n\n\n addToWorld(world) {\n const constraints = this.constraints;\n const bodies = this.wheelBodies.concat([this.chassisBody]);\n\n for (let i = 0; i < bodies.length; i++) {\n world.addBody(bodies[i]);\n }\n\n for (let i = 0; i < constraints.length; i++) {\n world.addConstraint(constraints[i]);\n }\n\n world.addEventListener('preStep', this._update.bind(this));\n }\n\n _update() {\n const wheelForces = this.wheelForces;\n\n for (let i = 0; i < wheelForces.length; i++) {\n this.applyWheelForce(wheelForces[i], i);\n }\n }\n /**\r\n * Remove the vehicle including its constraints from the world.\r\n * @method removeFromWorld\r\n * @param {World} world\r\n */\n\n\n removeFromWorld(world) {\n const constraints = this.constraints;\n const bodies = this.wheelBodies.concat([this.chassisBody]);\n\n for (let i = 0; i < bodies.length; i++) {\n world.removeBody(bodies[i]);\n }\n\n for (let i = 0; i < constraints.length; i++) {\n world.removeConstraint(constraints[i]);\n }\n }\n /**\r\n * Get current rotational velocity of a wheel\r\n * @method getWheelSpeed\r\n * @param {integer} wheelIndex\r\n */\n\n\n getWheelSpeed(wheelIndex) {\n const axis = this.wheelAxes[wheelIndex];\n const wheelBody = this.wheelBodies[wheelIndex];\n const w = wheelBody.angularVelocity;\n this.chassisBody.vectorToWorldFrame(axis, worldAxis);\n return w.dot(worldAxis);\n }\n\n}\nconst torque = new Vec3();\nconst worldAxis = new Vec3();\n\n/**\r\n * Smoothed-particle hydrodynamics system\r\n * @class SPHSystem\r\n * @constructor\r\n */\nclass SPHSystem {\n // Density of the system (kg/m3).\n // Distance below which two particles are considered to be neighbors. It should be adjusted so there are about 15-20 neighbor particles within this radius.\n // Viscosity of the system.\n constructor() {\n this.particles = [];\n this.density = 1;\n this.smoothingRadius = 1;\n this.speedOfSound = 1;\n this.viscosity = 0.01;\n this.eps = 0.000001; // Stuff Computed per particle\n\n this.pressures = [];\n this.densities = [];\n this.neighbors = [];\n }\n /**\r\n * Add a particle to the system.\r\n * @method add\r\n * @param {Body} particle\r\n */\n\n\n add(particle) {\n this.particles.push(particle);\n\n if (this.neighbors.length < this.particles.length) {\n this.neighbors.push([]);\n }\n }\n /**\r\n * Remove a particle from the system.\r\n * @method remove\r\n * @param {Body} particle\r\n */\n\n\n remove(particle) {\n const idx = this.particles.indexOf(particle);\n\n if (idx !== -1) {\n this.particles.splice(idx, 1);\n\n if (this.neighbors.length > this.particles.length) {\n this.neighbors.pop();\n }\n }\n }\n\n getNeighbors(particle, neighbors) {\n const N = this.particles.length;\n const id = particle.id;\n const R2 = this.smoothingRadius * this.smoothingRadius;\n const dist = SPHSystem_getNeighbors_dist;\n\n for (let i = 0; i !== N; i++) {\n const p = this.particles[i];\n p.position.vsub(particle.position, dist);\n\n if (id !== p.id && dist.lengthSquared() < R2) {\n neighbors.push(p);\n }\n }\n }\n\n update() {\n const N = this.particles.length;\n const dist = SPHSystem_update_dist;\n const cs = this.speedOfSound;\n const eps = this.eps;\n\n for (let i = 0; i !== N; i++) {\n const p = this.particles[i]; // Current particle\n\n const neighbors = this.neighbors[i]; // Get neighbors\n\n neighbors.length = 0;\n this.getNeighbors(p, neighbors);\n neighbors.push(this.particles[i]); // Add current too\n\n const numNeighbors = neighbors.length; // Accumulate density for the particle\n\n let sum = 0.0;\n\n for (let j = 0; j !== numNeighbors; j++) {\n //printf(\"Current particle has position %f %f %f\\n\",objects[id].pos.x(),objects[id].pos.y(),objects[id].pos.z());\n p.position.vsub(neighbors[j].position, dist);\n const len = dist.length();\n const weight = this.w(len);\n sum += neighbors[j].mass * weight;\n } // Save\n\n\n this.densities[i] = sum;\n this.pressures[i] = cs * cs * (this.densities[i] - this.density);\n } // Add forces\n // Sum to these accelerations\n\n\n const a_pressure = SPHSystem_update_a_pressure;\n const a_visc = SPHSystem_update_a_visc;\n const gradW = SPHSystem_update_gradW;\n const r_vec = SPHSystem_update_r_vec;\n const u = SPHSystem_update_u;\n\n for (let i = 0; i !== N; i++) {\n const particle = this.particles[i];\n a_pressure.set(0, 0, 0);\n a_visc.set(0, 0, 0); // Init vars\n\n let Pij;\n let nabla;\n\n const neighbors = this.neighbors[i];\n const numNeighbors = neighbors.length; //printf(\"Neighbors: \");\n\n for (let j = 0; j !== numNeighbors; j++) {\n const neighbor = neighbors[j]; //printf(\"%d \",nj);\n // Get r once for all..\n\n particle.position.vsub(neighbor.position, r_vec);\n const r = r_vec.length(); // Pressure contribution\n\n Pij = -neighbor.mass * (this.pressures[i] / (this.densities[i] * this.densities[i] + eps) + this.pressures[j] / (this.densities[j] * this.densities[j] + eps));\n this.gradw(r_vec, gradW); // Add to pressure acceleration\n\n gradW.scale(Pij, gradW);\n a_pressure.vadd(gradW, a_pressure); // Viscosity contribution\n\n neighbor.velocity.vsub(particle.velocity, u);\n u.scale(1.0 / (0.0001 + this.densities[i] * this.densities[j]) * this.viscosity * neighbor.mass, u);\n nabla = this.nablaw(r);\n u.scale(nabla, u); // Add to viscosity acceleration\n\n a_visc.vadd(u, a_visc);\n } // Calculate force\n\n\n a_visc.scale(particle.mass, a_visc);\n a_pressure.scale(particle.mass, a_pressure); // Add force to particles\n\n particle.force.vadd(a_visc, particle.force);\n particle.force.vadd(a_pressure, particle.force);\n }\n } // Calculate the weight using the W(r) weightfunction\n\n\n w(r) {\n // 315\n const h = this.smoothingRadius;\n return 315.0 / (64.0 * Math.PI * h ** 9) * (h * h - r * r) ** 3;\n } // calculate gradient of the weight function\n\n\n gradw(rVec, resultVec) {\n const r = rVec.length();\n const h = this.smoothingRadius;\n rVec.scale(945.0 / (32.0 * Math.PI * h ** 9) * (h * h - r * r) ** 2, resultVec);\n } // Calculate nabla(W)\n\n\n nablaw(r) {\n const h = this.smoothingRadius;\n const nabla = 945.0 / (32.0 * Math.PI * h ** 9) * (h * h - r * r) * (7 * r * r - 3 * h * h);\n return nabla;\n }\n\n}\n/**\r\n * Get neighbors within smoothing volume, save in the array neighbors\r\n * @method getNeighbors\r\n * @param {Body} particle\r\n * @param {Array} neighbors\r\n */\n\nconst SPHSystem_getNeighbors_dist = new Vec3(); // Temp vectors for calculation\n\nconst SPHSystem_update_dist = new Vec3(); // Relative velocity\n\nconst SPHSystem_update_a_pressure = new Vec3();\nconst SPHSystem_update_a_visc = new Vec3();\nconst SPHSystem_update_gradW = new Vec3();\nconst SPHSystem_update_r_vec = new Vec3();\nconst SPHSystem_update_u = new Vec3();\n\n/**\r\n * @class Cylinder\r\n * @constructor\r\n * @extends ConvexPolyhedron\r\n * @author schteppe / https://github.com/schteppe\r\n * @param {Number} radiusTop\r\n * @param {Number} radiusBottom\r\n * @param {Number} height\r\n * @param {Number} numSegments The number of segments to build the cylinder out of\r\n */\n\nclass Cylinder extends ConvexPolyhedron {\n constructor(radiusTop, radiusBottom, height, numSegments) {\n const N = numSegments;\n const vertices = [];\n const axes = [];\n const faces = [];\n const bottomface = [];\n const topface = [];\n const cos = Math.cos;\n const sin = Math.sin; // First bottom point\n\n vertices.push(new Vec3(radiusBottom * cos(0), radiusBottom * sin(0), -height * 0.5));\n bottomface.push(0); // First top point\n\n vertices.push(new Vec3(radiusTop * cos(0), radiusTop * sin(0), height * 0.5));\n topface.push(1);\n\n for (let i = 0; i < N; i++) {\n const theta = 2 * Math.PI / N * (i + 1);\n const thetaN = 2 * Math.PI / N * (i + 0.5);\n\n if (i < N - 1) {\n // Bottom\n vertices.push(new Vec3(radiusBottom * cos(theta), radiusBottom * sin(theta), -height * 0.5));\n bottomface.push(2 * i + 2); // Top\n\n vertices.push(new Vec3(radiusTop * cos(theta), radiusTop * sin(theta), height * 0.5));\n topface.push(2 * i + 3); // Face\n\n faces.push([2 * i + 2, 2 * i + 3, 2 * i + 1, 2 * i]);\n } else {\n faces.push([0, 1, 2 * i + 1, 2 * i]); // Connect\n } // Axis: we can cut off half of them if we have even number of segments\n\n\n if (N % 2 === 1 || i < N / 2) {\n axes.push(new Vec3(cos(thetaN), sin(thetaN), 0));\n }\n }\n\n faces.push(topface);\n axes.push(new Vec3(0, 0, 1)); // Reorder bottom face\n\n const temp = [];\n\n for (let i = 0; i < bottomface.length; i++) {\n temp.push(bottomface[bottomface.length - i - 1]);\n }\n\n faces.push(temp);\n super({\n vertices,\n faces,\n axes\n });\n }\n\n}\n\n/**\r\n * Particle shape.\r\n * @class Particle\r\n * @constructor\r\n * @author schteppe\r\n * @extends Shape\r\n */\nclass Particle extends Shape {\n constructor() {\n super({\n type: Shape.types.PARTICLE\n });\n }\n /**\r\n * @method calculateLocalInertia\r\n * @param {Number} mass\r\n * @param {Vec3} target\r\n * @return {Vec3}\r\n */\n\n\n calculateLocalInertia(mass, target = new Vec3()) {\n target.set(0, 0, 0);\n return target;\n }\n\n volume() {\n return 0;\n }\n\n updateBoundingSphereRadius() {\n this.boundingSphereRadius = 0;\n }\n\n calculateWorldAABB(pos, quat, min, max) {\n // Get each axis max\n min.copy(pos);\n max.copy(pos);\n }\n\n}\n\n/**\r\n * A plane, facing in the Z direction. The plane has its surface at z=0 and everything below z=0 is assumed to be solid plane. To make the plane face in some other direction than z, you must put it inside a Body and rotate that body. See the demos.\r\n * @class Plane\r\n * @constructor\r\n * @extends Shape\r\n * @author schteppe\r\n */\nclass Plane extends Shape {\n constructor() {\n super({\n type: Shape.types.PLANE\n }); // World oriented normal\n\n this.worldNormal = new Vec3();\n this.worldNormalNeedsUpdate = true;\n this.boundingSphereRadius = Number.MAX_VALUE;\n }\n\n computeWorldNormal(quat) {\n const n = this.worldNormal;\n n.set(0, 0, 1);\n quat.vmult(n, n);\n this.worldNormalNeedsUpdate = false;\n }\n\n calculateLocalInertia(mass, target = new Vec3()) {\n return target;\n }\n\n volume() {\n return (// The plane is infinite...\n Number.MAX_VALUE\n );\n }\n\n calculateWorldAABB(pos, quat, min, max) {\n // The plane AABB is infinite, except if the normal is pointing along any axis\n tempNormal.set(0, 0, 1); // Default plane normal is z\n\n quat.vmult(tempNormal, tempNormal);\n const maxVal = Number.MAX_VALUE;\n min.set(-maxVal, -maxVal, -maxVal);\n max.set(maxVal, maxVal, maxVal);\n\n if (tempNormal.x === 1) {\n max.x = pos.x;\n } else if (tempNormal.x === -1) {\n min.x = pos.x;\n }\n\n if (tempNormal.y === 1) {\n max.y = pos.y;\n } else if (tempNormal.y === -1) {\n min.y = pos.y;\n }\n\n if (tempNormal.z === 1) {\n max.z = pos.z;\n } else if (tempNormal.z === -1) {\n min.z = pos.z;\n }\n }\n\n updateBoundingSphereRadius() {\n this.boundingSphereRadius = Number.MAX_VALUE;\n }\n\n}\nconst tempNormal = new Vec3();\n\n/**\n * Heightfield shape class. Height data is given as an array. These data points are spread out evenly with a given distance.\n * @class Heightfield\n * @extends Shape\n * @constructor\n * @param {Array} data An array of Y values that will be used to construct the terrain.\n * @param {object} options\n * @param {Number} [options.minValue] Minimum value of the data points in the data array. Will be computed automatically if not given.\n * @param {Number} [options.maxValue] Maximum value.\n * @param {Number} [options.elementSize=0.1] World spacing between the data points in X direction.\n * @todo Should be possible to use along all axes, not just y\n * @todo should be possible to scale along all axes\n * @todo Refactor elementSize to elementSizeX and elementSizeY\n *\n * @example\n * // Generate some height data (y-values).\n * const data = [];\n * for(let i = 0; i < 1000; i++){\n * const y = 0.5 * Math.cos(0.2 * i);\n * data.push(y);\n * }\n *\n * // Create the heightfield shape\n * const heightfieldShape = new Heightfield(data, {\n * elementSize: 1 // Distance between the data points in X and Y directions\n * });\n * const heightfieldBody = new Body();\n * heightfieldBody.addShape(heightfieldShape);\n * world.addBody(heightfieldBody);\n */\nclass Heightfield extends Shape {\n // An array of numbers, or height values, that are spread out along the x axis.\n // Max value of the data.\n // Max value of the data.\n // The width of each element. To do: elementSizeX and Y\n constructor(data, options = {}) {\n options = Utils.defaults(options, {\n maxValue: null,\n minValue: null,\n elementSize: 1\n });\n super({\n type: Shape.types.HEIGHTFIELD\n });\n this.data = data;\n this.maxValue = options.maxValue;\n this.minValue = options.minValue;\n this.elementSize = options.elementSize;\n\n if (options.minValue === null) {\n this.updateMinValue();\n }\n\n if (options.maxValue === null) {\n this.updateMaxValue();\n }\n\n this.cacheEnabled = true;\n this.pillarConvex = new ConvexPolyhedron();\n this.pillarOffset = new Vec3();\n this.updateBoundingSphereRadius(); // \"i_j_isUpper\" => { convex: ..., offset: ... }\n // for example:\n // _cachedPillars[\"0_2_1\"]\n\n this._cachedPillars = {};\n }\n /**\n * Call whenever you change the data array.\n * @method update\n */\n\n\n update() {\n this._cachedPillars = {};\n }\n /**\n * Update the .minValue property\n * @method updateMinValue\n */\n\n\n updateMinValue() {\n const data = this.data;\n let minValue = data[0][0];\n\n for (let i = 0; i !== data.length; i++) {\n for (let j = 0; j !== data[i].length; j++) {\n const v = data[i][j];\n\n if (v < minValue) {\n minValue = v;\n }\n }\n }\n\n this.minValue = minValue;\n }\n /**\n * Update the .maxValue property\n * @method updateMaxValue\n */\n\n\n updateMaxValue() {\n const data = this.data;\n let maxValue = data[0][0];\n\n for (let i = 0; i !== data.length; i++) {\n for (let j = 0; j !== data[i].length; j++) {\n const v = data[i][j];\n\n if (v > maxValue) {\n maxValue = v;\n }\n }\n }\n\n this.maxValue = maxValue;\n }\n /**\n * Set the height value at an index. Don't forget to update maxValue and minValue after you're done.\n * @method setHeightValueAtIndex\n * @param {integer} xi\n * @param {integer} yi\n * @param {number} value\n */\n\n\n setHeightValueAtIndex(xi, yi, value) {\n const data = this.data;\n data[xi][yi] = value; // Invalidate cache\n\n this.clearCachedConvexTrianglePillar(xi, yi, false);\n\n if (xi > 0) {\n this.clearCachedConvexTrianglePillar(xi - 1, yi, true);\n this.clearCachedConvexTrianglePillar(xi - 1, yi, false);\n }\n\n if (yi > 0) {\n this.clearCachedConvexTrianglePillar(xi, yi - 1, true);\n this.clearCachedConvexTrianglePillar(xi, yi - 1, false);\n }\n\n if (yi > 0 && xi > 0) {\n this.clearCachedConvexTrianglePillar(xi - 1, yi - 1, true);\n }\n }\n /**\n * Get max/min in a rectangle in the matrix data\n * @method getRectMinMax\n * @param {integer} iMinX\n * @param {integer} iMinY\n * @param {integer} iMaxX\n * @param {integer} iMaxY\n * @param {array} [result] An array to store the results in.\n * @return {array} The result array, if it was passed in. Minimum will be at position 0 and max at 1.\n */\n\n\n getRectMinMax(iMinX, iMinY, iMaxX, iMaxY, result = []) {\n // Get max and min of the data\n const data = this.data; // Set first value\n\n let max = this.minValue;\n\n for (let i = iMinX; i <= iMaxX; i++) {\n for (let j = iMinY; j <= iMaxY; j++) {\n const height = data[i][j];\n\n if (height > max) {\n max = height;\n }\n }\n }\n\n result[0] = this.minValue;\n result[1] = max;\n }\n /**\n * Get the index of a local position on the heightfield. The indexes indicate the rectangles, so if your terrain is made of N x N height data points, you will have rectangle indexes ranging from 0 to N-1.\n * @method getIndexOfPosition\n * @param {number} x\n * @param {number} y\n * @param {array} result Two-element array\n * @param {boolean} clamp If the position should be clamped to the heightfield edge.\n * @return {boolean}\n */\n\n\n getIndexOfPosition(x, y, result, clamp) {\n // Get the index of the data points to test against\n const w = this.elementSize;\n const data = this.data;\n let xi = Math.floor(x / w);\n let yi = Math.floor(y / w);\n result[0] = xi;\n result[1] = yi;\n\n if (clamp) {\n // Clamp index to edges\n if (xi < 0) {\n xi = 0;\n }\n\n if (yi < 0) {\n yi = 0;\n }\n\n if (xi >= data.length - 1) {\n xi = data.length - 1;\n }\n\n if (yi >= data[0].length - 1) {\n yi = data[0].length - 1;\n }\n } // Bail out if we are out of the terrain\n\n\n if (xi < 0 || yi < 0 || xi >= data.length - 1 || yi >= data[0].length - 1) {\n return false;\n }\n\n return true;\n }\n\n getTriangleAt(x, y, edgeClamp, a, b, c) {\n const idx = getHeightAt_idx;\n this.getIndexOfPosition(x, y, idx, edgeClamp);\n let xi = idx[0];\n let yi = idx[1];\n const data = this.data;\n\n if (edgeClamp) {\n xi = Math.min(data.length - 2, Math.max(0, xi));\n yi = Math.min(data[0].length - 2, Math.max(0, yi));\n }\n\n const elementSize = this.elementSize;\n const lowerDist2 = (x / elementSize - xi) ** 2 + (y / elementSize - yi) ** 2;\n const upperDist2 = (x / elementSize - (xi + 1)) ** 2 + (y / elementSize - (yi + 1)) ** 2;\n const upper = lowerDist2 > upperDist2;\n this.getTriangle(xi, yi, upper, a, b, c);\n return upper;\n }\n\n getNormalAt(x, y, edgeClamp, result) {\n const a = getNormalAt_a;\n const b = getNormalAt_b;\n const c = getNormalAt_c;\n const e0 = getNormalAt_e0;\n const e1 = getNormalAt_e1;\n this.getTriangleAt(x, y, edgeClamp, a, b, c);\n b.vsub(a, e0);\n c.vsub(a, e1);\n e0.cross(e1, result);\n result.normalize();\n }\n /**\n * Get an AABB of a square in the heightfield\n * @param {number} xi\n * @param {number} yi\n * @param {AABB} result\n */\n\n\n getAabbAtIndex(xi, yi, {\n lowerBound,\n upperBound\n }) {\n const data = this.data;\n const elementSize = this.elementSize;\n lowerBound.set(xi * elementSize, yi * elementSize, data[xi][yi]);\n upperBound.set((xi + 1) * elementSize, (yi + 1) * elementSize, data[xi + 1][yi + 1]);\n }\n /**\n * Get the height in the heightfield at a given position\n * @param {number} x\n * @param {number} y\n * @param {boolean} edgeClamp\n * @return {number}\n */\n\n\n getHeightAt(x, y, edgeClamp) {\n const data = this.data;\n const a = getHeightAt_a;\n const b = getHeightAt_b;\n const c = getHeightAt_c;\n const idx = getHeightAt_idx;\n this.getIndexOfPosition(x, y, idx, edgeClamp);\n let xi = idx[0];\n let yi = idx[1];\n\n if (edgeClamp) {\n xi = Math.min(data.length - 2, Math.max(0, xi));\n yi = Math.min(data[0].length - 2, Math.max(0, yi));\n }\n\n const upper = this.getTriangleAt(x, y, edgeClamp, a, b, c);\n barycentricWeights(x, y, a.x, a.y, b.x, b.y, c.x, c.y, getHeightAt_weights);\n const w = getHeightAt_weights;\n\n if (upper) {\n // Top triangle verts\n return data[xi + 1][yi + 1] * w.x + data[xi][yi + 1] * w.y + data[xi + 1][yi] * w.z;\n } else {\n // Top triangle verts\n return data[xi][yi] * w.x + data[xi + 1][yi] * w.y + data[xi][yi + 1] * w.z;\n }\n }\n\n getCacheConvexTrianglePillarKey(xi, yi, getUpperTriangle) {\n return xi + \"_\" + yi + \"_\" + (getUpperTriangle ? 1 : 0);\n }\n\n getCachedConvexTrianglePillar(xi, yi, getUpperTriangle) {\n return this._cachedPillars[this.getCacheConvexTrianglePillarKey(xi, yi, getUpperTriangle)];\n }\n\n setCachedConvexTrianglePillar(xi, yi, getUpperTriangle, convex, offset) {\n this._cachedPillars[this.getCacheConvexTrianglePillarKey(xi, yi, getUpperTriangle)] = {\n convex,\n offset\n };\n }\n\n clearCachedConvexTrianglePillar(xi, yi, getUpperTriangle) {\n delete this._cachedPillars[this.getCacheConvexTrianglePillarKey(xi, yi, getUpperTriangle)];\n }\n /**\n * Get a triangle from the heightfield\n * @param {number} xi\n * @param {number} yi\n * @param {boolean} upper\n * @param {Vec3} a\n * @param {Vec3} b\n * @param {Vec3} c\n */\n\n\n getTriangle(xi, yi, upper, a, b, c) {\n const data = this.data;\n const elementSize = this.elementSize;\n\n if (upper) {\n // Top triangle verts\n a.set((xi + 1) * elementSize, (yi + 1) * elementSize, data[xi + 1][yi + 1]);\n b.set(xi * elementSize, (yi + 1) * elementSize, data[xi][yi + 1]);\n c.set((xi + 1) * elementSize, yi * elementSize, data[xi + 1][yi]);\n } else {\n // Top triangle verts\n a.set(xi * elementSize, yi * elementSize, data[xi][yi]);\n b.set((xi + 1) * elementSize, yi * elementSize, data[xi + 1][yi]);\n c.set(xi * elementSize, (yi + 1) * elementSize, data[xi][yi + 1]);\n }\n }\n /**\n * Get a triangle in the terrain in the form of a triangular convex shape.\n * @method getConvexTrianglePillar\n * @param {integer} i\n * @param {integer} j\n * @param {boolean} getUpperTriangle\n */\n\n\n getConvexTrianglePillar(xi, yi, getUpperTriangle) {\n let result = this.pillarConvex;\n let offsetResult = this.pillarOffset;\n\n if (this.cacheEnabled) {\n const data = this.getCachedConvexTrianglePillar(xi, yi, getUpperTriangle);\n\n if (data) {\n this.pillarConvex = data.convex;\n this.pillarOffset = data.offset;\n return;\n }\n\n result = new ConvexPolyhedron();\n offsetResult = new Vec3();\n this.pillarConvex = result;\n this.pillarOffset = offsetResult;\n }\n\n const data = this.data;\n const elementSize = this.elementSize;\n const faces = result.faces; // Reuse verts if possible\n\n result.vertices.length = 6;\n\n for (let i = 0; i < 6; i++) {\n if (!result.vertices[i]) {\n result.vertices[i] = new Vec3();\n }\n } // Reuse faces if possible\n\n\n faces.length = 5;\n\n for (let i = 0; i < 5; i++) {\n if (!faces[i]) {\n faces[i] = [];\n }\n }\n\n const verts = result.vertices;\n const h = (Math.min(data[xi][yi], data[xi + 1][yi], data[xi][yi + 1], data[xi + 1][yi + 1]) - this.minValue) / 2 + this.minValue;\n\n if (!getUpperTriangle) {\n // Center of the triangle pillar - all polygons are given relative to this one\n offsetResult.set((xi + 0.25) * elementSize, // sort of center of a triangle\n (yi + 0.25) * elementSize, h // vertical center\n ); // Top triangle verts\n\n verts[0].set(-0.25 * elementSize, -0.25 * elementSize, data[xi][yi] - h);\n verts[1].set(0.75 * elementSize, -0.25 * elementSize, data[xi + 1][yi] - h);\n verts[2].set(-0.25 * elementSize, 0.75 * elementSize, data[xi][yi + 1] - h); // bottom triangle verts\n\n verts[3].set(-0.25 * elementSize, -0.25 * elementSize, -h - 1);\n verts[4].set(0.75 * elementSize, -0.25 * elementSize, -h - 1);\n verts[5].set(-0.25 * elementSize, 0.75 * elementSize, -h - 1); // top triangle\n\n faces[0][0] = 0;\n faces[0][1] = 1;\n faces[0][2] = 2; // bottom triangle\n\n faces[1][0] = 5;\n faces[1][1] = 4;\n faces[1][2] = 3; // -x facing quad\n\n faces[2][0] = 0;\n faces[2][1] = 2;\n faces[2][2] = 5;\n faces[2][3] = 3; // -y facing quad\n\n faces[3][0] = 1;\n faces[3][1] = 0;\n faces[3][2] = 3;\n faces[3][3] = 4; // +xy facing quad\n\n faces[4][0] = 4;\n faces[4][1] = 5;\n faces[4][2] = 2;\n faces[4][3] = 1;\n } else {\n // Center of the triangle pillar - all polygons are given relative to this one\n offsetResult.set((xi + 0.75) * elementSize, // sort of center of a triangle\n (yi + 0.75) * elementSize, h // vertical center\n ); // Top triangle verts\n\n verts[0].set(0.25 * elementSize, 0.25 * elementSize, data[xi + 1][yi + 1] - h);\n verts[1].set(-0.75 * elementSize, 0.25 * elementSize, data[xi][yi + 1] - h);\n verts[2].set(0.25 * elementSize, -0.75 * elementSize, data[xi + 1][yi] - h); // bottom triangle verts\n\n verts[3].set(0.25 * elementSize, 0.25 * elementSize, -h - 1);\n verts[4].set(-0.75 * elementSize, 0.25 * elementSize, -h - 1);\n verts[5].set(0.25 * elementSize, -0.75 * elementSize, -h - 1); // Top triangle\n\n faces[0][0] = 0;\n faces[0][1] = 1;\n faces[0][2] = 2; // bottom triangle\n\n faces[1][0] = 5;\n faces[1][1] = 4;\n faces[1][2] = 3; // +x facing quad\n\n faces[2][0] = 2;\n faces[2][1] = 5;\n faces[2][2] = 3;\n faces[2][3] = 0; // +y facing quad\n\n faces[3][0] = 3;\n faces[3][1] = 4;\n faces[3][2] = 1;\n faces[3][3] = 0; // -xy facing quad\n\n faces[4][0] = 1;\n faces[4][1] = 4;\n faces[4][2] = 5;\n faces[4][3] = 2;\n }\n\n result.computeNormals();\n result.computeEdges();\n result.updateBoundingSphereRadius();\n this.setCachedConvexTrianglePillar(xi, yi, getUpperTriangle, result, offsetResult);\n }\n\n calculateLocalInertia(mass, target = new Vec3()) {\n target.set(0, 0, 0);\n return target;\n }\n\n volume() {\n return (// The terrain is infinite\n Number.MAX_VALUE\n );\n }\n\n calculateWorldAABB(pos, quat, min, max) {\n // TODO: do it properly\n min.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);\n max.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);\n }\n\n updateBoundingSphereRadius() {\n // Use the bounding box of the min/max values\n const data = this.data;\n const s = this.elementSize;\n this.boundingSphereRadius = new Vec3(data.length * s, data[0].length * s, Math.max(Math.abs(this.maxValue), Math.abs(this.minValue))).length();\n }\n /**\n * Sets the height values from an image. Currently only supported in browser.\n * @method setHeightsFromImage\n * @param {Image} image\n * @param {Vec3} scale\n */\n\n\n setHeightsFromImage(image, scale) {\n const {\n x,\n z,\n y\n } = scale;\n const canvas = document.createElement('canvas');\n canvas.width = image.width;\n canvas.height = image.height;\n const context = canvas.getContext('2d');\n context.drawImage(image, 0, 0);\n const imageData = context.getImageData(0, 0, image.width, image.height);\n const matrix = this.data;\n matrix.length = 0;\n this.elementSize = Math.abs(x) / imageData.width;\n\n for (let i = 0; i < imageData.height; i++) {\n const row = [];\n\n for (let j = 0; j < imageData.width; j++) {\n const a = imageData.data[(i * imageData.height + j) * 4];\n const b = imageData.data[(i * imageData.height + j) * 4 + 1];\n const c = imageData.data[(i * imageData.height + j) * 4 + 2];\n const height = (a + b + c) / 4 / 255 * z;\n\n if (x < 0) {\n row.push(height);\n } else {\n row.unshift(height);\n }\n }\n\n if (y < 0) {\n matrix.unshift(row);\n } else {\n matrix.push(row);\n }\n }\n\n this.updateMaxValue();\n this.updateMinValue();\n this.update();\n }\n\n}\nconst getHeightAt_idx = [];\nconst getHeightAt_weights = new Vec3();\nconst getHeightAt_a = new Vec3();\nconst getHeightAt_b = new Vec3();\nconst getHeightAt_c = new Vec3();\nconst getNormalAt_a = new Vec3();\nconst getNormalAt_b = new Vec3();\nconst getNormalAt_c = new Vec3();\nconst getNormalAt_e0 = new Vec3();\nconst getNormalAt_e1 = new Vec3(); // from https://en.wikipedia.org/wiki/Barycentric_coordinate_system\n\nfunction barycentricWeights(x, y, ax, ay, bx, by, cx, cy, result) {\n result.x = ((by - cy) * (x - cx) + (cx - bx) * (y - cy)) / ((by - cy) * (ax - cx) + (cx - bx) * (ay - cy));\n result.y = ((cy - ay) * (x - cx) + (ax - cx) * (y - cy)) / ((by - cy) * (ax - cx) + (cx - bx) * (ay - cy));\n result.z = 1 - result.x - result.y;\n}\n\n/**\r\n * @class OctreeNode\r\n * @constructor\r\n * @param {object} [options]\r\n * @param {Octree} [options.root]\r\n * @param {AABB} [options.aabb]\r\n */\nclass OctreeNode {\n // The root node\n // Boundary of this node\n // Contained data at the current node level\n // Children to this node\n constructor(options = {}) {\n this.root = options.root || null;\n this.aabb = options.aabb ? options.aabb.clone() : new AABB();\n this.data = [];\n this.children = [];\n }\n\n reset() {\n this.children.length = this.data.length = 0;\n }\n /**\r\n * Insert data into this node\r\n * @method insert\r\n * @param {AABB} aabb\r\n * @param {object} elementData\r\n * @return {boolean} True if successful, otherwise false\r\n */\n\n\n insert(aabb, elementData, level = 0) {\n const nodeData = this.data; // Ignore objects that do not belong in this node\n\n if (!this.aabb.contains(aabb)) {\n return false; // object cannot be added\n }\n\n const children = this.children;\n const maxDepth = this.maxDepth || this.root.maxDepth;\n\n if (level < maxDepth) {\n // Subdivide if there are no children yet\n let subdivided = false;\n\n if (!children.length) {\n this.subdivide();\n subdivided = true;\n } // add to whichever node will accept it\n\n\n for (let i = 0; i !== 8; i++) {\n if (children[i].insert(aabb, elementData, level + 1)) {\n return true;\n }\n }\n\n if (subdivided) {\n // No children accepted! Might as well just remove em since they contain none\n children.length = 0;\n }\n } // Too deep, or children didnt want it. add it in current node\n\n\n nodeData.push(elementData);\n return true;\n }\n /**\r\n * Create 8 equally sized children nodes and put them in the .children array.\r\n * @method subdivide\r\n */\n\n\n subdivide() {\n const aabb = this.aabb;\n const l = aabb.lowerBound;\n const u = aabb.upperBound;\n const children = this.children;\n children.push(new OctreeNode({\n aabb: new AABB({\n lowerBound: new Vec3(0, 0, 0)\n })\n }), new OctreeNode({\n aabb: new AABB({\n lowerBound: new Vec3(1, 0, 0)\n })\n }), new OctreeNode({\n aabb: new AABB({\n lowerBound: new Vec3(1, 1, 0)\n })\n }), new OctreeNode({\n aabb: new AABB({\n lowerBound: new Vec3(1, 1, 1)\n })\n }), new OctreeNode({\n aabb: new AABB({\n lowerBound: new Vec3(0, 1, 1)\n })\n }), new OctreeNode({\n aabb: new AABB({\n lowerBound: new Vec3(0, 0, 1)\n })\n }), new OctreeNode({\n aabb: new AABB({\n lowerBound: new Vec3(1, 0, 1)\n })\n }), new OctreeNode({\n aabb: new AABB({\n lowerBound: new Vec3(0, 1, 0)\n })\n }));\n u.vsub(l, halfDiagonal);\n halfDiagonal.scale(0.5, halfDiagonal);\n const root = this.root || this;\n\n for (let i = 0; i !== 8; i++) {\n const child = children[i]; // Set current node as root\n\n child.root = root; // Compute bounds\n\n const lowerBound = child.aabb.lowerBound;\n lowerBound.x *= halfDiagonal.x;\n lowerBound.y *= halfDiagonal.y;\n lowerBound.z *= halfDiagonal.z;\n lowerBound.vadd(l, lowerBound); // Upper bound is always lower bound + halfDiagonal\n\n lowerBound.vadd(halfDiagonal, child.aabb.upperBound);\n }\n }\n /**\r\n * Get all data, potentially within an AABB\r\n * @method aabbQuery\r\n * @param {AABB} aabb\r\n * @param {array} result\r\n * @return {array} The \"result\" object\r\n */\n\n\n aabbQuery(aabb, result) {\n const nodeData = this.data; // abort if the range does not intersect this node\n // if (!this.aabb.overlaps(aabb)){\n // return result;\n // }\n // Add objects at this level\n // Array.prototype.push.apply(result, nodeData);\n // Add child data\n // @todo unwrap recursion into a queue / loop, that's faster in JS\n\n const children = this.children; // for (let i = 0, N = this.children.length; i !== N; i++) {\n // children[i].aabbQuery(aabb, result);\n // }\n\n const queue = [this];\n\n while (queue.length) {\n const node = queue.pop();\n\n if (node.aabb.overlaps(aabb)) {\n Array.prototype.push.apply(result, node.data);\n }\n\n Array.prototype.push.apply(queue, node.children);\n }\n\n return result;\n }\n /**\r\n * Get all data, potentially intersected by a ray.\r\n * @method rayQuery\r\n * @param {Ray} ray\r\n * @param {Transform} treeTransform\r\n * @param {array} result\r\n * @return {array} The \"result\" object\r\n */\n\n\n rayQuery(ray, treeTransform, result) {\n // Use aabb query for now.\n // @todo implement real ray query which needs less lookups\n ray.getAABB(tmpAABB$1);\n tmpAABB$1.toLocalFrame(treeTransform, tmpAABB$1);\n this.aabbQuery(tmpAABB$1, result);\n return result;\n }\n /**\r\n * @method removeEmptyNodes\r\n */\n\n\n removeEmptyNodes() {\n for (let i = this.children.length - 1; i >= 0; i--) {\n this.children[i].removeEmptyNodes();\n\n if (!this.children[i].children.length && !this.children[i].data.length) {\n this.children.splice(i, 1);\n }\n }\n }\n\n}\n/**\r\n * @class Octree\r\n * @param {AABB} aabb The total AABB of the tree\r\n * @param {object} [options]\r\n * @param {number} [options.maxDepth=8] Maximum subdivision depth\r\n * @extends OctreeNode\r\n */\n\n\nclass Octree extends OctreeNode {\n // Maximum subdivision depth\n constructor(aabb, options = {}) {\n super({\n root: null,\n aabb\n });\n this.maxDepth = typeof options.maxDepth !== 'undefined' ? options.maxDepth : 8;\n }\n\n}\nconst halfDiagonal = new Vec3();\nconst tmpAABB$1 = new AABB();\n\n/**\n * @class Trimesh\n * @constructor\n * @param {array} vertices\n * @param {array} indices\n * @extends Shape\n * @example\n * // How to make a mesh with a single triangle\n * const vertices = [\n * 0, 0, 0, // vertex 0\n * 1, 0, 0, // vertex 1\n * 0, 1, 0 // vertex 2\n * ];\n * const indices = [\n * 0, 1, 2 // triangle 0\n * ];\n * const trimeshShape = new Trimesh(vertices, indices);\n */\nclass Trimesh extends Shape {\n // Array of integers, indicating which vertices each triangle consists of. The length of this array is thus 3 times the number of triangles.\n // The normals data.\n // The local AABB of the mesh.\n // References to vertex pairs, making up all unique edges in the trimesh.\n // Local scaling of the mesh. Use .setScale() to set it.\n // The indexed triangles. Use .updateTree() to update it.\n constructor(vertices, indices) {\n super({\n type: Shape.types.TRIMESH\n });\n this.vertices = new Float32Array(vertices);\n this.indices = new Int16Array(indices);\n this.normals = new Float32Array(indices.length);\n this.aabb = new AABB();\n this.edges = null;\n this.scale = new Vec3(1, 1, 1);\n this.tree = new Octree();\n this.updateEdges();\n this.updateNormals();\n this.updateAABB();\n this.updateBoundingSphereRadius();\n this.updateTree();\n }\n /**\n * @method updateTree\n */\n\n\n updateTree() {\n const tree = this.tree;\n tree.reset();\n tree.aabb.copy(this.aabb);\n const scale = this.scale; // The local mesh AABB is scaled, but the octree AABB should be unscaled\n\n tree.aabb.lowerBound.x *= 1 / scale.x;\n tree.aabb.lowerBound.y *= 1 / scale.y;\n tree.aabb.lowerBound.z *= 1 / scale.z;\n tree.aabb.upperBound.x *= 1 / scale.x;\n tree.aabb.upperBound.y *= 1 / scale.y;\n tree.aabb.upperBound.z *= 1 / scale.z; // Insert all triangles\n\n const triangleAABB = new AABB();\n const a = new Vec3();\n const b = new Vec3();\n const c = new Vec3();\n const points = [a, b, c];\n\n for (let i = 0; i < this.indices.length / 3; i++) {\n //this.getTriangleVertices(i, a, b, c);\n // Get unscaled triangle verts\n const i3 = i * 3;\n\n this._getUnscaledVertex(this.indices[i3], a);\n\n this._getUnscaledVertex(this.indices[i3 + 1], b);\n\n this._getUnscaledVertex(this.indices[i3 + 2], c);\n\n triangleAABB.setFromPoints(points);\n tree.insert(triangleAABB, i);\n }\n\n tree.removeEmptyNodes();\n }\n /**\n * Get triangles in a local AABB from the trimesh.\n * @method getTrianglesInAABB\n * @param {AABB} aabb\n * @param {array} result An array of integers, referencing the queried triangles.\n */\n\n\n getTrianglesInAABB(aabb, result) {\n unscaledAABB.copy(aabb); // Scale it to local\n\n const scale = this.scale;\n const isx = scale.x;\n const isy = scale.y;\n const isz = scale.z;\n const l = unscaledAABB.lowerBound;\n const u = unscaledAABB.upperBound;\n l.x /= isx;\n l.y /= isy;\n l.z /= isz;\n u.x /= isx;\n u.y /= isy;\n u.z /= isz;\n return this.tree.aabbQuery(unscaledAABB, result);\n }\n /**\n * @method setScale\n * @param {Vec3} scale\n */\n\n\n setScale(scale) {\n const wasUniform = this.scale.x === this.scale.y && this.scale.y === this.scale.z;\n const isUniform = scale.x === scale.y && scale.y === scale.z;\n\n if (!(wasUniform && isUniform)) {\n // Non-uniform scaling. Need to update normals.\n this.updateNormals();\n }\n\n this.scale.copy(scale);\n this.updateAABB();\n this.updateBoundingSphereRadius();\n }\n /**\n * Compute the normals of the faces. Will save in the .normals array.\n * @method updateNormals\n */\n\n\n updateNormals() {\n const n = computeNormals_n; // Generate normals\n\n const normals = this.normals;\n\n for (let i = 0; i < this.indices.length / 3; i++) {\n const i3 = i * 3;\n const a = this.indices[i3];\n const b = this.indices[i3 + 1];\n const c = this.indices[i3 + 2];\n this.getVertex(a, va);\n this.getVertex(b, vb);\n this.getVertex(c, vc);\n Trimesh.computeNormal(vb, va, vc, n);\n normals[i3] = n.x;\n normals[i3 + 1] = n.y;\n normals[i3 + 2] = n.z;\n }\n }\n /**\n * Update the .edges property\n * @method updateEdges\n */\n\n\n updateEdges() {\n const edges = {};\n\n const add = (a, b) => {\n const key = a < b ? a + \"_\" + b : b + \"_\" + a;\n edges[key] = true;\n };\n\n for (let i = 0; i < this.indices.length / 3; i++) {\n const i3 = i * 3;\n const a = this.indices[i3];\n const b = this.indices[i3 + 1];\n const c = this.indices[i3 + 2];\n add(a, b);\n add(b, c);\n add(c, a);\n }\n\n const keys = Object.keys(edges);\n this.edges = new Int16Array(keys.length * 2);\n\n for (let i = 0; i < keys.length; i++) {\n const indices = keys[i].split('_');\n this.edges[2 * i] = parseInt(indices[0], 10);\n this.edges[2 * i + 1] = parseInt(indices[1], 10);\n }\n }\n /**\n * Get an edge vertex\n * @method getEdgeVertex\n * @param {number} edgeIndex\n * @param {number} firstOrSecond 0 or 1, depending on which one of the vertices you need.\n * @param {Vec3} vertexStore Where to store the result\n */\n\n\n getEdgeVertex(edgeIndex, firstOrSecond, vertexStore) {\n const vertexIndex = this.edges[edgeIndex * 2 + (firstOrSecond ? 1 : 0)];\n this.getVertex(vertexIndex, vertexStore);\n }\n /**\n * Get a vector along an edge.\n * @method getEdgeVector\n * @param {number} edgeIndex\n * @param {Vec3} vectorStore\n */\n\n\n getEdgeVector(edgeIndex, vectorStore) {\n const va = getEdgeVector_va;\n const vb = getEdgeVector_vb;\n this.getEdgeVertex(edgeIndex, 0, va);\n this.getEdgeVertex(edgeIndex, 1, vb);\n vb.vsub(va, vectorStore);\n }\n /**\n * Get vertex i.\n * @method getVertex\n * @param {number} i\n * @param {Vec3} out\n * @return {Vec3} The \"out\" vector object\n */\n\n\n getVertex(i, out) {\n const scale = this.scale;\n\n this._getUnscaledVertex(i, out);\n\n out.x *= scale.x;\n out.y *= scale.y;\n out.z *= scale.z;\n return out;\n }\n /**\n * Get raw vertex i\n * @private\n * @method _getUnscaledVertex\n * @param {number} i\n * @param {Vec3} out\n * @return {Vec3} The \"out\" vector object\n */\n\n\n _getUnscaledVertex(i, out) {\n const i3 = i * 3;\n const vertices = this.vertices;\n return out.set(vertices[i3], vertices[i3 + 1], vertices[i3 + 2]);\n }\n /**\n * Get a vertex from the trimesh,transformed by the given position and quaternion.\n * @method getWorldVertex\n * @param {number} i\n * @param {Vec3} pos\n * @param {Quaternion} quat\n * @param {Vec3} out\n * @return {Vec3} The \"out\" vector object\n */\n\n\n getWorldVertex(i, pos, quat, out) {\n this.getVertex(i, out);\n Transform.pointToWorldFrame(pos, quat, out, out);\n return out;\n }\n /**\n * Get the three vertices for triangle i.\n * @method getTriangleVertices\n * @param {number} i\n * @param {Vec3} a\n * @param {Vec3} b\n * @param {Vec3} c\n */\n\n\n getTriangleVertices(i, a, b, c) {\n const i3 = i * 3;\n this.getVertex(this.indices[i3], a);\n this.getVertex(this.indices[i3 + 1], b);\n this.getVertex(this.indices[i3 + 2], c);\n }\n /**\n * Compute the normal of triangle i.\n * @method getNormal\n * @param {Number} i\n * @param {Vec3} target\n * @return {Vec3} The \"target\" vector object\n */\n\n\n getNormal(i, target) {\n const i3 = i * 3;\n return target.set(this.normals[i3], this.normals[i3 + 1], this.normals[i3 + 2]);\n }\n /**\n * @method calculateLocalInertia\n * @param {Number} mass\n * @param {Vec3} target\n * @return {Vec3} The \"target\" vector object\n */\n\n\n calculateLocalInertia(mass, target) {\n // Approximate with box inertia\n // Exact inertia calculation is overkill, but see http://geometrictools.com/Documentation/PolyhedralMassProperties.pdf for the correct way to do it\n this.computeLocalAABB(cli_aabb);\n const x = cli_aabb.upperBound.x - cli_aabb.lowerBound.x;\n const y = cli_aabb.upperBound.y - cli_aabb.lowerBound.y;\n const z = cli_aabb.upperBound.z - cli_aabb.lowerBound.z;\n return target.set(1.0 / 12.0 * mass * (2 * y * 2 * y + 2 * z * 2 * z), 1.0 / 12.0 * mass * (2 * x * 2 * x + 2 * z * 2 * z), 1.0 / 12.0 * mass * (2 * y * 2 * y + 2 * x * 2 * x));\n }\n /**\n * Compute the local AABB for the trimesh\n * @method computeLocalAABB\n * @param {AABB} aabb\n */\n\n\n computeLocalAABB(aabb) {\n const l = aabb.lowerBound;\n const u = aabb.upperBound;\n const n = this.vertices.length;\n const vertices = this.vertices;\n const v = computeLocalAABB_worldVert;\n this.getVertex(0, v);\n l.copy(v);\n u.copy(v);\n\n for (let i = 0; i !== n; i++) {\n this.getVertex(i, v);\n\n if (v.x < l.x) {\n l.x = v.x;\n } else if (v.x > u.x) {\n u.x = v.x;\n }\n\n if (v.y < l.y) {\n l.y = v.y;\n } else if (v.y > u.y) {\n u.y = v.y;\n }\n\n if (v.z < l.z) {\n l.z = v.z;\n } else if (v.z > u.z) {\n u.z = v.z;\n }\n }\n }\n /**\n * Update the .aabb property\n * @method updateAABB\n */\n\n\n updateAABB() {\n this.computeLocalAABB(this.aabb);\n }\n /**\n * Will update the .boundingSphereRadius property\n * @method updateBoundingSphereRadius\n */\n\n\n updateBoundingSphereRadius() {\n // Assume points are distributed with local (0,0,0) as center\n let max2 = 0;\n const vertices = this.vertices;\n const v = new Vec3();\n\n for (let i = 0, N = vertices.length / 3; i !== N; i++) {\n this.getVertex(i, v);\n const norm2 = v.lengthSquared();\n\n if (norm2 > max2) {\n max2 = norm2;\n }\n }\n\n this.boundingSphereRadius = Math.sqrt(max2);\n }\n /**\n * @method calculateWorldAABB\n * @param {Vec3} pos\n * @param {Quaternion} quat\n * @param {Vec3} min\n * @param {Vec3} max\n */\n\n\n calculateWorldAABB(pos, quat, min, max) {\n /*\n const n = this.vertices.length / 3,\n verts = this.vertices;\n const minx,miny,minz,maxx,maxy,maxz;\n const v = tempWorldVertex;\n for(let i=0; i maxx || maxx===undefined){\n maxx = v.x;\n }\n if (v.y < miny || miny===undefined){\n miny = v.y;\n } else if(v.y > maxy || maxy===undefined){\n maxy = v.y;\n }\n if (v.z < minz || minz===undefined){\n minz = v.z;\n } else if(v.z > maxz || maxz===undefined){\n maxz = v.z;\n }\n }\n min.set(minx,miny,minz);\n max.set(maxx,maxy,maxz);\n */\n // Faster approximation using local AABB\n const frame = calculateWorldAABB_frame;\n const result = calculateWorldAABB_aabb;\n frame.position = pos;\n frame.quaternion = quat;\n this.aabb.toWorldFrame(frame, result);\n min.copy(result.lowerBound);\n max.copy(result.upperBound);\n }\n /**\n * Get approximate volume\n * @method volume\n * @return {Number}\n */\n\n\n volume() {\n return 4.0 * Math.PI * this.boundingSphereRadius / 3.0;\n }\n\n}\nconst computeNormals_n = new Vec3();\nconst unscaledAABB = new AABB();\nconst getEdgeVector_va = new Vec3();\nconst getEdgeVector_vb = new Vec3();\n/**\n * Get face normal given 3 vertices\n * @static\n * @method computeNormal\n * @param {Vec3} va\n * @param {Vec3} vb\n * @param {Vec3} vc\n * @param {Vec3} target\n */\n\nconst cb = new Vec3();\nconst ab = new Vec3();\n\nTrimesh.computeNormal = (va, vb, vc, target) => {\n vb.vsub(va, ab);\n vc.vsub(vb, cb);\n cb.cross(ab, target);\n\n if (!target.isZero()) {\n target.normalize();\n }\n};\n\nconst va = new Vec3();\nconst vb = new Vec3();\nconst vc = new Vec3();\nconst cli_aabb = new AABB();\nconst computeLocalAABB_worldVert = new Vec3();\nconst calculateWorldAABB_frame = new Transform();\nconst calculateWorldAABB_aabb = new AABB();\n/**\n * Create a Trimesh instance, shaped as a torus.\n * @static\n * @method createTorus\n * @param {number} [radius=1]\n * @param {number} [tube=0.5]\n * @param {number} [radialSegments=8]\n * @param {number} [tubularSegments=6]\n * @param {number} [arc=6.283185307179586]\n * @return {Trimesh} A torus\n */\n\nTrimesh.createTorus = (radius = 1, tube = 0.5, radialSegments = 8, tubularSegments = 6, arc = Math.PI * 2) => {\n const vertices = [];\n const indices = [];\n\n for (let j = 0; j <= radialSegments; j++) {\n for (let i = 0; i <= tubularSegments; i++) {\n const u = i / tubularSegments * arc;\n const v = j / radialSegments * Math.PI * 2;\n const x = (radius + tube * Math.cos(v)) * Math.cos(u);\n const y = (radius + tube * Math.cos(v)) * Math.sin(u);\n const z = tube * Math.sin(v);\n vertices.push(x, y, z);\n }\n }\n\n for (let j = 1; j <= radialSegments; j++) {\n for (let i = 1; i <= tubularSegments; i++) {\n const a = (tubularSegments + 1) * j + i - 1;\n const b = (tubularSegments + 1) * (j - 1) + i - 1;\n const c = (tubularSegments + 1) * (j - 1) + i;\n const d = (tubularSegments + 1) * j + i;\n indices.push(a, b, d);\n indices.push(b, c, d);\n }\n }\n\n return new Trimesh(vertices, indices);\n};\n\n/**\r\n * Constraint equation solver base class.\r\n * @class Solver\r\n * @constructor\r\n * @author schteppe / https://github.com/schteppe\r\n */\nclass Solver {\n // All equations to be solved\n constructor() {\n this.equations = [];\n }\n /**\r\n * Should be implemented in subclasses!\r\n * @method solve\r\n * @param {Number} dt\r\n * @param {World} world\r\n * @return {Number} number of iterations performed\r\n */\n\n\n solve(dt, world) {\n return (// Should return the number of iterations done!\n 0\n );\n }\n /**\r\n * Add an equation\r\n * @method addEquation\r\n * @param {Equation} eq\r\n */\n\n\n addEquation(eq) {\n if (eq.enabled) {\n this.equations.push(eq);\n }\n }\n /**\r\n * Remove an equation\r\n * @method removeEquation\r\n * @param {Equation} eq\r\n */\n\n\n removeEquation(eq) {\n const eqs = this.equations;\n const i = eqs.indexOf(eq);\n\n if (i !== -1) {\n eqs.splice(i, 1);\n }\n }\n /**\r\n * Add all equations\r\n * @method removeAllEquations\r\n */\n\n\n removeAllEquations() {\n this.equations.length = 0;\n }\n\n}\n\n/**\r\n * Constraint equation Gauss-Seidel solver.\r\n * @class GSSolver\r\n * @constructor\r\n * @todo The spook parameters should be specified for each constraint, not globally.\r\n * @author schteppe / https://github.com/schteppe\r\n * @see https://www8.cs.umu.se/kurser/5DV058/VT09/lectures/spooknotes.pdf\r\n * @extends Solver\r\n */\nclass GSSolver extends Solver {\n // The number of solver iterations determines quality of the constraints in the world. The more iterations, the more correct simulation. More iterations need more computations though. If you have a large gravity force in your world, you will need more iterations.\n // When tolerance is reached, the system is assumed to be converged.\n constructor() {\n super();\n this.iterations = 10;\n this.tolerance = 1e-7;\n }\n /**\r\n * Solve\r\n * @method solve\r\n * @param {Number} dt\r\n * @param {World} world\r\n * @return {Number} number of iterations performed\r\n */\n\n\n solve(dt, world) {\n let iter = 0;\n const maxIter = this.iterations;\n const tolSquared = this.tolerance * this.tolerance;\n const equations = this.equations;\n const Neq = equations.length;\n const bodies = world.bodies;\n const Nbodies = bodies.length;\n const h = dt;\n let B;\n let invC;\n let deltalambda;\n let deltalambdaTot;\n let GWlambda;\n let lambdaj; // Update solve mass\n\n if (Neq !== 0) {\n for (let i = 0; i !== Nbodies; i++) {\n bodies[i].updateSolveMassProperties();\n }\n } // Things that does not change during iteration can be computed once\n\n\n const invCs = GSSolver_solve_invCs;\n const Bs = GSSolver_solve_Bs;\n const lambda = GSSolver_solve_lambda;\n invCs.length = Neq;\n Bs.length = Neq;\n lambda.length = Neq;\n\n for (let i = 0; i !== Neq; i++) {\n const c = equations[i];\n lambda[i] = 0.0;\n Bs[i] = c.computeB(h);\n invCs[i] = 1.0 / c.computeC();\n }\n\n if (Neq !== 0) {\n // Reset vlambda\n for (let i = 0; i !== Nbodies; i++) {\n const b = bodies[i];\n const vlambda = b.vlambda;\n const wlambda = b.wlambda;\n vlambda.set(0, 0, 0);\n wlambda.set(0, 0, 0);\n } // Iterate over equations\n\n\n for (iter = 0; iter !== maxIter; iter++) {\n // Accumulate the total error for each iteration.\n deltalambdaTot = 0.0;\n\n for (let j = 0; j !== Neq; j++) {\n const c = equations[j]; // Compute iteration\n\n B = Bs[j];\n invC = invCs[j];\n lambdaj = lambda[j];\n GWlambda = c.computeGWlambda();\n deltalambda = invC * (B - GWlambda - c.eps * lambdaj); // Clamp if we are not within the min/max interval\n\n if (lambdaj + deltalambda < c.minForce) {\n deltalambda = c.minForce - lambdaj;\n } else if (lambdaj + deltalambda > c.maxForce) {\n deltalambda = c.maxForce - lambdaj;\n }\n\n lambda[j] += deltalambda;\n deltalambdaTot += deltalambda > 0.0 ? deltalambda : -deltalambda; // abs(deltalambda)\n\n c.addToWlambda(deltalambda);\n } // If the total error is small enough - stop iterate\n\n\n if (deltalambdaTot * deltalambdaTot < tolSquared) {\n break;\n }\n } // Add result to velocity\n\n\n for (let i = 0; i !== Nbodies; i++) {\n const b = bodies[i];\n const v = b.velocity;\n const w = b.angularVelocity;\n b.vlambda.vmul(b.linearFactor, b.vlambda);\n v.vadd(b.vlambda, v);\n b.wlambda.vmul(b.angularFactor, b.wlambda);\n w.vadd(b.wlambda, w);\n } // Set the .multiplier property of each equation\n\n\n let l = equations.length;\n const invDt = 1 / h;\n\n while (l--) {\n equations[l].multiplier = lambda[l] * invDt;\n }\n }\n\n return iter;\n }\n\n}\nconst GSSolver_solve_lambda = []; // Just temporary number holders that we want to reuse each solve.\n\nconst GSSolver_solve_invCs = [];\nconst GSSolver_solve_Bs = [];\n\n/**\r\n * Splits the equations into islands and solves them independently. Can improve performance.\r\n * @class SplitSolver\r\n * @constructor\r\n * @extends Solver\r\n * @param {Solver} subsolver\r\n */\nclass SplitSolver extends Solver {\n // The number of solver iterations determines quality of the constraints in the world. The more iterations, the more correct simulation. More iterations need more computations though. If you have a large gravity force in your world, you will need more iterations.\n // When tolerance is reached, the system is assumed to be converged.\n constructor(subsolver) {\n super();\n this.iterations = 10;\n this.tolerance = 1e-7;\n this.subsolver = subsolver;\n this.nodes = [];\n this.nodePool = []; // Create needed nodes, reuse if possible\n\n while (this.nodePool.length < 128) {\n this.nodePool.push(this.createNode());\n }\n }\n\n createNode() {\n return {\n body: null,\n children: [],\n eqs: [],\n visited: false\n };\n }\n /**\r\n * Solve the subsystems\r\n * @method solve\r\n * @param {Number} dt\r\n * @param {World} world\r\n * @return {Number} number of iterations performed\r\n */\n\n\n solve(dt, world) {\n const nodes = SplitSolver_solve_nodes;\n const nodePool = this.nodePool;\n const bodies = world.bodies;\n const equations = this.equations;\n const Neq = equations.length;\n const Nbodies = bodies.length;\n const subsolver = this.subsolver; // Create needed nodes, reuse if possible\n\n while (nodePool.length < Nbodies) {\n nodePool.push(this.createNode());\n }\n\n nodes.length = Nbodies;\n\n for (let i = 0; i < Nbodies; i++) {\n nodes[i] = nodePool[i];\n } // Reset node values\n\n\n for (let i = 0; i !== Nbodies; i++) {\n const node = nodes[i];\n node.body = bodies[i];\n node.children.length = 0;\n node.eqs.length = 0;\n node.visited = false;\n }\n\n for (let k = 0; k !== Neq; k++) {\n const eq = equations[k];\n const i = bodies.indexOf(eq.bi);\n const j = bodies.indexOf(eq.bj);\n const ni = nodes[i];\n const nj = nodes[j];\n ni.children.push(nj);\n ni.eqs.push(eq);\n nj.children.push(ni);\n nj.eqs.push(eq);\n }\n\n let child;\n let n = 0;\n let eqs = SplitSolver_solve_eqs;\n subsolver.tolerance = this.tolerance;\n subsolver.iterations = this.iterations;\n const dummyWorld = SplitSolver_solve_dummyWorld;\n\n while (child = getUnvisitedNode(nodes)) {\n eqs.length = 0;\n dummyWorld.bodies.length = 0;\n bfs(child, visitFunc, dummyWorld.bodies, eqs);\n const Neqs = eqs.length;\n eqs = eqs.sort(sortById);\n\n for (let i = 0; i !== Neqs; i++) {\n subsolver.addEquation(eqs[i]);\n }\n\n const iter = subsolver.solve(dt, dummyWorld);\n subsolver.removeAllEquations();\n n++;\n }\n\n return n;\n }\n\n} // Returns the number of subsystems\n\nconst SplitSolver_solve_nodes = []; // All allocated node objects\n\nconst SplitSolver_solve_eqs = []; // Temp array\n\nconst SplitSolver_solve_dummyWorld = {\n bodies: []\n}; // Temp object\n\nconst STATIC = Body.STATIC;\n\nfunction getUnvisitedNode(nodes) {\n const Nnodes = nodes.length;\n\n for (let i = 0; i !== Nnodes; i++) {\n const node = nodes[i];\n\n if (!node.visited && !(node.body.type & STATIC)) {\n return node;\n }\n }\n\n return false;\n}\n\nconst queue = [];\n\nfunction bfs(root, visitFunc, bds, eqs) {\n queue.push(root);\n root.visited = true;\n visitFunc(root, bds, eqs);\n\n while (queue.length) {\n const node = queue.pop(); // Loop over unvisited child nodes\n\n let child;\n\n while (child = getUnvisitedNode(node.children)) {\n child.visited = true;\n visitFunc(child, bds, eqs);\n queue.push(child);\n }\n }\n}\n\nfunction visitFunc(node, bds, eqs) {\n bds.push(node.body);\n const Neqs = node.eqs.length;\n\n for (let i = 0; i !== Neqs; i++) {\n const eq = node.eqs[i];\n\n if (!eqs.includes(eq)) {\n eqs.push(eq);\n }\n }\n}\n\nfunction sortById(a, b) {\n return b.id - a.id;\n}\n\n/**\r\n * For pooling objects that can be reused.\r\n * @class Pool\r\n * @constructor\r\n */\nclass Pool {\n constructor() {\n this.objects = [];\n this.type = Object;\n }\n /**\r\n * Release an object after use\r\n * @method release\r\n * @param {Object} obj\r\n */\n\n\n release(...args) {\n const Nargs = args.length;\n\n for (let i = 0; i !== Nargs; i++) {\n this.objects.push(args[i]);\n }\n\n return this;\n }\n /**\r\n * Get an object\r\n * @method get\r\n * @return {mixed}\r\n */\n\n\n get() {\n if (this.objects.length === 0) {\n return this.constructObject();\n } else {\n return this.objects.pop();\n }\n }\n /**\r\n * Construct an object. Should be implemented in each subclass.\r\n * @method constructObject\r\n * @return {mixed}\r\n */\n\n\n constructObject() {\n throw new Error('constructObject() not implemented in this Pool subclass yet!');\n }\n /**\r\n * @method resize\r\n * @param {number} size\r\n * @return {Pool} Self, for chaining\r\n */\n\n\n resize(size) {\n const objects = this.objects;\n\n while (objects.length > size) {\n objects.pop();\n }\n\n while (objects.length < size) {\n objects.push(this.constructObject());\n }\n\n return this;\n }\n\n}\n\n/**\r\n * @class Vec3Pool\r\n * @constructor\r\n * @extends Pool\r\n */\n\nclass Vec3Pool extends Pool {\n constructor() {\n super();\n this.type = Vec3;\n }\n /**\r\n * Construct a vector\r\n * @method constructObject\r\n * @return {Vec3}\r\n */\n\n\n constructObject() {\n return new Vec3();\n }\n\n}\n\nconst COLLISION_TYPES = {\n sphereSphere: Shape.types.SPHERE,\n spherePlane: Shape.types.SPHERE | Shape.types.PLANE,\n boxBox: Shape.types.BOX | Shape.types.BOX,\n sphereBox: Shape.types.SPHERE | Shape.types.BOX,\n planeBox: Shape.types.PLANE | Shape.types.BOX,\n convexConvex: Shape.types.CONVEXPOLYHEDRON,\n sphereConvex: Shape.types.SPHERE | Shape.types.CONVEXPOLYHEDRON,\n planeConvex: Shape.types.PLANE | Shape.types.CONVEXPOLYHEDRON,\n boxConvex: Shape.types.BOX | Shape.types.CONVEXPOLYHEDRON,\n sphereHeightfield: Shape.types.SPHERE | Shape.types.HEIGHTFIELD,\n boxHeightfield: Shape.types.BOX | Shape.types.HEIGHTFIELD,\n convexHeightfield: Shape.types.CONVEXPOLYHEDRON | Shape.types.HEIGHTFIELD,\n sphereParticle: Shape.types.PARTICLE | Shape.types.SPHERE,\n planeParticle: Shape.types.PLANE | Shape.types.PARTICLE,\n boxParticle: Shape.types.BOX | Shape.types.PARTICLE,\n convexParticle: Shape.types.PARTICLE | Shape.types.CONVEXPOLYHEDRON,\n sphereTrimesh: Shape.types.SPHERE | Shape.types.TRIMESH,\n planeTrimesh: Shape.types.PLANE | Shape.types.TRIMESH\n};\n\n/**\r\n * Helper class for the World. Generates ContactEquations.\r\n * @class Narrowphase\r\n * @constructor\r\n * @todo Sphere-ConvexPolyhedron contacts\r\n * @todo Contact reduction\r\n * @todo should move methods to prototype\r\n */\nclass Narrowphase {\n // Internal storage of pooled contact points.\n // Pooled vectors.\n constructor(world) {\n this.contactPointPool = [];\n this.frictionEquationPool = [];\n this.result = [];\n this.frictionResult = [];\n this.v3pool = new Vec3Pool();\n this.world = world;\n this.currentContactMaterial = world.defaultContactMaterial;\n this.enableFrictionReduction = false;\n }\n /**\r\n * Make a contact object, by using the internal pool or creating a new one.\r\n * @method createContactEquation\r\n * @param {Body} bi\r\n * @param {Body} bj\r\n * @param {Shape} si\r\n * @param {Shape} sj\r\n * @param {Shape} overrideShapeA\r\n * @param {Shape} overrideShapeB\r\n * @return {ContactEquation}\r\n */\n\n\n createContactEquation(bi, bj, si, sj, overrideShapeA, overrideShapeB) {\n let c;\n\n if (this.contactPointPool.length) {\n c = this.contactPointPool.pop();\n c.bi = bi;\n c.bj = bj;\n } else {\n c = new ContactEquation(bi, bj);\n }\n\n c.enabled = bi.collisionResponse && bj.collisionResponse && si.collisionResponse && sj.collisionResponse;\n const cm = this.currentContactMaterial;\n c.restitution = cm.restitution;\n c.setSpookParams(cm.contactEquationStiffness, cm.contactEquationRelaxation, this.world.dt);\n const matA = si.material || bi.material;\n const matB = sj.material || bj.material;\n\n if (matA && matB && matA.restitution >= 0 && matB.restitution >= 0) {\n c.restitution = matA.restitution * matB.restitution;\n }\n\n c.si = overrideShapeA || si;\n c.sj = overrideShapeB || sj;\n return c;\n }\n\n createFrictionEquationsFromContact(contactEquation, outArray) {\n const bodyA = contactEquation.bi;\n const bodyB = contactEquation.bj;\n const shapeA = contactEquation.si;\n const shapeB = contactEquation.sj;\n const world = this.world;\n const cm = this.currentContactMaterial; // If friction or restitution were specified in the material, use them\n\n let friction = cm.friction;\n const matA = shapeA.material || bodyA.material;\n const matB = shapeB.material || bodyB.material;\n\n if (matA && matB && matA.friction >= 0 && matB.friction >= 0) {\n friction = matA.friction * matB.friction;\n }\n\n if (friction > 0) {\n // Create 2 tangent equations\n const mug = friction * world.gravity.length();\n let reducedMass = bodyA.invMass + bodyB.invMass;\n\n if (reducedMass > 0) {\n reducedMass = 1 / reducedMass;\n }\n\n const pool = this.frictionEquationPool;\n const c1 = pool.length ? pool.pop() : new FrictionEquation(bodyA, bodyB, mug * reducedMass);\n const c2 = pool.length ? pool.pop() : new FrictionEquation(bodyA, bodyB, mug * reducedMass);\n c1.bi = c2.bi = bodyA;\n c1.bj = c2.bj = bodyB;\n c1.minForce = c2.minForce = -mug * reducedMass;\n c1.maxForce = c2.maxForce = mug * reducedMass; // Copy over the relative vectors\n\n c1.ri.copy(contactEquation.ri);\n c1.rj.copy(contactEquation.rj);\n c2.ri.copy(contactEquation.ri);\n c2.rj.copy(contactEquation.rj); // Construct tangents\n\n contactEquation.ni.tangents(c1.t, c2.t); // Set spook params\n\n c1.setSpookParams(cm.frictionEquationStiffness, cm.frictionEquationRelaxation, world.dt);\n c2.setSpookParams(cm.frictionEquationStiffness, cm.frictionEquationRelaxation, world.dt);\n c1.enabled = c2.enabled = contactEquation.enabled;\n outArray.push(c1, c2);\n return true;\n }\n\n return false;\n } // Take the average N latest contact point on the plane.\n\n\n createFrictionFromAverage(numContacts) {\n // The last contactEquation\n let c = this.result[this.result.length - 1]; // Create the result: two \"average\" friction equations\n\n if (!this.createFrictionEquationsFromContact(c, this.frictionResult) || numContacts === 1) {\n return;\n }\n\n const f1 = this.frictionResult[this.frictionResult.length - 2];\n const f2 = this.frictionResult[this.frictionResult.length - 1];\n averageNormal.setZero();\n averageContactPointA.setZero();\n averageContactPointB.setZero();\n const bodyA = c.bi;\n const bodyB = c.bj;\n\n for (let i = 0; i !== numContacts; i++) {\n c = this.result[this.result.length - 1 - i];\n\n if (c.bi !== bodyA) {\n averageNormal.vadd(c.ni, averageNormal);\n averageContactPointA.vadd(c.ri, averageContactPointA);\n averageContactPointB.vadd(c.rj, averageContactPointB);\n } else {\n averageNormal.vsub(c.ni, averageNormal);\n averageContactPointA.vadd(c.rj, averageContactPointA);\n averageContactPointB.vadd(c.ri, averageContactPointB);\n }\n }\n\n const invNumContacts = 1 / numContacts;\n averageContactPointA.scale(invNumContacts, f1.ri);\n averageContactPointB.scale(invNumContacts, f1.rj);\n f2.ri.copy(f1.ri); // Should be the same\n\n f2.rj.copy(f1.rj);\n averageNormal.normalize();\n averageNormal.tangents(f1.t, f2.t); // return eq;\n }\n /**\r\n * Generate all contacts between a list of body pairs\r\n * @method getContacts\r\n * @param {array} p1 Array of body indices\r\n * @param {array} p2 Array of body indices\r\n * @param {World} world\r\n * @param {array} result Array to store generated contacts\r\n * @param {array} oldcontacts Optional. Array of reusable contact objects\r\n */\n\n\n getContacts(p1, p2, world, result, oldcontacts, frictionResult, frictionPool) {\n // Save old contact objects\n this.contactPointPool = oldcontacts;\n this.frictionEquationPool = frictionPool;\n this.result = result;\n this.frictionResult = frictionResult;\n const qi = tmpQuat1;\n const qj = tmpQuat2;\n const xi = tmpVec1$2;\n const xj = tmpVec2$2;\n\n for (let k = 0, N = p1.length; k !== N; k++) {\n // Get current collision bodies\n const bi = p1[k];\n const bj = p2[k]; // Get contact material\n\n let bodyContactMaterial = null;\n\n if (bi.material && bj.material) {\n bodyContactMaterial = world.getContactMaterial(bi.material, bj.material) || null;\n }\n\n const justTest = bi.type & Body.KINEMATIC && bj.type & Body.STATIC || bi.type & Body.STATIC && bj.type & Body.KINEMATIC || bi.type & Body.KINEMATIC && bj.type & Body.KINEMATIC;\n\n for (let i = 0; i < bi.shapes.length; i++) {\n bi.quaternion.mult(bi.shapeOrientations[i], qi);\n bi.quaternion.vmult(bi.shapeOffsets[i], xi);\n xi.vadd(bi.position, xi);\n const si = bi.shapes[i];\n\n for (let j = 0; j < bj.shapes.length; j++) {\n // Compute world transform of shapes\n bj.quaternion.mult(bj.shapeOrientations[j], qj);\n bj.quaternion.vmult(bj.shapeOffsets[j], xj);\n xj.vadd(bj.position, xj);\n const sj = bj.shapes[j];\n\n if (!(si.collisionFilterMask & sj.collisionFilterGroup && sj.collisionFilterMask & si.collisionFilterGroup)) {\n continue;\n }\n\n if (xi.distanceTo(xj) > si.boundingSphereRadius + sj.boundingSphereRadius) {\n continue;\n } // Get collision material\n\n\n let shapeContactMaterial = null;\n\n if (si.material && sj.material) {\n shapeContactMaterial = world.getContactMaterial(si.material, sj.material) || null;\n }\n\n this.currentContactMaterial = shapeContactMaterial || bodyContactMaterial || world.defaultContactMaterial; // Get contacts\n\n const resolverIndex = si.type | sj.type;\n const resolver = this[resolverIndex];\n\n if (resolver) {\n let retval = false; // TO DO: investigate why sphereParticle and convexParticle\n // resolvers expect si and sj shapes to be in reverse order\n // (i.e. larger integer value type first instead of smaller first)\n\n if (si.type < sj.type) {\n retval = resolver.call(this, si, sj, xi, xj, qi, qj, bi, bj, si, sj, justTest);\n } else {\n retval = resolver.call(this, sj, si, xj, xi, qj, qi, bj, bi, si, sj, justTest);\n }\n\n if (retval && justTest) {\n // Register overlap\n world.shapeOverlapKeeper.set(si.id, sj.id);\n world.bodyOverlapKeeper.set(bi.id, bj.id);\n }\n }\n }\n }\n }\n }\n\n sphereSphere(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) {\n if (justTest) {\n return xi.distanceSquared(xj) < (si.radius + sj.radius) ** 2;\n } // We will have only one contact in this case\n\n\n const r = this.createContactEquation(bi, bj, si, sj, rsi, rsj); // Contact normal\n\n xj.vsub(xi, r.ni);\n r.ni.normalize(); // Contact point locations\n\n r.ri.copy(r.ni);\n r.rj.copy(r.ni);\n r.ri.scale(si.radius, r.ri);\n r.rj.scale(-sj.radius, r.rj);\n r.ri.vadd(xi, r.ri);\n r.ri.vsub(bi.position, r.ri);\n r.rj.vadd(xj, r.rj);\n r.rj.vsub(bj.position, r.rj);\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n }\n\n spherePlane(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) {\n // We will have one contact in this case\n const r = this.createContactEquation(bi, bj, si, sj, rsi, rsj); // Contact normal\n\n r.ni.set(0, 0, 1);\n qj.vmult(r.ni, r.ni);\n r.ni.negate(r.ni); // body i is the sphere, flip normal\n\n r.ni.normalize(); // Needed?\n // Vector from sphere center to contact point\n\n r.ni.scale(si.radius, r.ri); // Project down sphere on plane\n\n xi.vsub(xj, point_on_plane_to_sphere);\n r.ni.scale(r.ni.dot(point_on_plane_to_sphere), plane_to_sphere_ortho);\n point_on_plane_to_sphere.vsub(plane_to_sphere_ortho, r.rj); // The sphere position projected to plane\n\n if (-point_on_plane_to_sphere.dot(r.ni) <= si.radius) {\n if (justTest) {\n return true;\n } // Make it relative to the body\n\n\n const ri = r.ri;\n const rj = r.rj;\n ri.vadd(xi, ri);\n ri.vsub(bi.position, ri);\n rj.vadd(xj, rj);\n rj.vsub(bj.position, rj);\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n }\n }\n\n boxBox(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) {\n si.convexPolyhedronRepresentation.material = si.material;\n sj.convexPolyhedronRepresentation.material = sj.material;\n si.convexPolyhedronRepresentation.collisionResponse = si.collisionResponse;\n sj.convexPolyhedronRepresentation.collisionResponse = sj.collisionResponse;\n return this.convexConvex(si.convexPolyhedronRepresentation, sj.convexPolyhedronRepresentation, xi, xj, qi, qj, bi, bj, si, sj, justTest);\n }\n\n sphereBox(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) {\n const v3pool = this.v3pool; // we refer to the box as body j\n\n const sides = sphereBox_sides;\n xi.vsub(xj, box_to_sphere);\n sj.getSideNormals(sides, qj);\n const R = si.radius;\n\n let found = false; // Store the resulting side penetration info\n\n const side_ns = sphereBox_side_ns;\n const side_ns1 = sphereBox_side_ns1;\n const side_ns2 = sphereBox_side_ns2;\n let side_h = null;\n let side_penetrations = 0;\n let side_dot1 = 0;\n let side_dot2 = 0;\n let side_distance = null;\n\n for (let idx = 0, nsides = sides.length; idx !== nsides && found === false; idx++) {\n // Get the plane side normal (ns)\n const ns = sphereBox_ns;\n ns.copy(sides[idx]);\n const h = ns.length();\n ns.normalize(); // The normal/distance dot product tells which side of the plane we are\n\n const dot = box_to_sphere.dot(ns);\n\n if (dot < h + R && dot > 0) {\n // Intersects plane. Now check the other two dimensions\n const ns1 = sphereBox_ns1;\n const ns2 = sphereBox_ns2;\n ns1.copy(sides[(idx + 1) % 3]);\n ns2.copy(sides[(idx + 2) % 3]);\n const h1 = ns1.length();\n const h2 = ns2.length();\n ns1.normalize();\n ns2.normalize();\n const dot1 = box_to_sphere.dot(ns1);\n const dot2 = box_to_sphere.dot(ns2);\n\n if (dot1 < h1 && dot1 > -h1 && dot2 < h2 && dot2 > -h2) {\n const dist = Math.abs(dot - h - R);\n\n if (side_distance === null || dist < side_distance) {\n side_distance = dist;\n side_dot1 = dot1;\n side_dot2 = dot2;\n side_h = h;\n side_ns.copy(ns);\n side_ns1.copy(ns1);\n side_ns2.copy(ns2);\n side_penetrations++;\n\n if (justTest) {\n return true;\n }\n }\n }\n }\n }\n\n if (side_penetrations) {\n found = true;\n const r = this.createContactEquation(bi, bj, si, sj, rsi, rsj);\n side_ns.scale(-R, r.ri); // Sphere r\n\n r.ni.copy(side_ns);\n r.ni.negate(r.ni); // Normal should be out of sphere\n\n side_ns.scale(side_h, side_ns);\n side_ns1.scale(side_dot1, side_ns1);\n side_ns.vadd(side_ns1, side_ns);\n side_ns2.scale(side_dot2, side_ns2);\n side_ns.vadd(side_ns2, r.rj); // Make relative to bodies\n\n r.ri.vadd(xi, r.ri);\n r.ri.vsub(bi.position, r.ri);\n r.rj.vadd(xj, r.rj);\n r.rj.vsub(bj.position, r.rj);\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n } // Check corners\n\n\n let rj = v3pool.get();\n const sphere_to_corner = sphereBox_sphere_to_corner;\n\n for (let j = 0; j !== 2 && !found; j++) {\n for (let k = 0; k !== 2 && !found; k++) {\n for (let l = 0; l !== 2 && !found; l++) {\n rj.set(0, 0, 0);\n\n if (j) {\n rj.vadd(sides[0], rj);\n } else {\n rj.vsub(sides[0], rj);\n }\n\n if (k) {\n rj.vadd(sides[1], rj);\n } else {\n rj.vsub(sides[1], rj);\n }\n\n if (l) {\n rj.vadd(sides[2], rj);\n } else {\n rj.vsub(sides[2], rj);\n } // World position of corner\n\n\n xj.vadd(rj, sphere_to_corner);\n sphere_to_corner.vsub(xi, sphere_to_corner);\n\n if (sphere_to_corner.lengthSquared() < R * R) {\n if (justTest) {\n return true;\n }\n\n found = true;\n const r = this.createContactEquation(bi, bj, si, sj, rsi, rsj);\n r.ri.copy(sphere_to_corner);\n r.ri.normalize();\n r.ni.copy(r.ri);\n r.ri.scale(R, r.ri);\n r.rj.copy(rj); // Make relative to bodies\n\n r.ri.vadd(xi, r.ri);\n r.ri.vsub(bi.position, r.ri);\n r.rj.vadd(xj, r.rj);\n r.rj.vsub(bj.position, r.rj);\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n }\n }\n }\n }\n\n v3pool.release(rj);\n rj = null; // Check edges\n\n const edgeTangent = v3pool.get();\n const edgeCenter = v3pool.get();\n const r = v3pool.get(); // r = edge center to sphere center\n\n const orthogonal = v3pool.get();\n const dist = v3pool.get();\n const Nsides = sides.length;\n\n for (let j = 0; j !== Nsides && !found; j++) {\n for (let k = 0; k !== Nsides && !found; k++) {\n if (j % 3 !== k % 3) {\n // Get edge tangent\n sides[k].cross(sides[j], edgeTangent);\n edgeTangent.normalize();\n sides[j].vadd(sides[k], edgeCenter);\n r.copy(xi);\n r.vsub(edgeCenter, r);\n r.vsub(xj, r);\n const orthonorm = r.dot(edgeTangent); // distance from edge center to sphere center in the tangent direction\n\n edgeTangent.scale(orthonorm, orthogonal); // Vector from edge center to sphere center in the tangent direction\n // Find the third side orthogonal to this one\n\n let l = 0;\n\n while (l === j % 3 || l === k % 3) {\n l++;\n } // vec from edge center to sphere projected to the plane orthogonal to the edge tangent\n\n\n dist.copy(xi);\n dist.vsub(orthogonal, dist);\n dist.vsub(edgeCenter, dist);\n dist.vsub(xj, dist); // Distances in tangent direction and distance in the plane orthogonal to it\n\n const tdist = Math.abs(orthonorm);\n const ndist = dist.length();\n\n if (tdist < sides[l].length() && ndist < R) {\n if (justTest) {\n return true;\n }\n\n found = true;\n const res = this.createContactEquation(bi, bj, si, sj, rsi, rsj);\n edgeCenter.vadd(orthogonal, res.rj); // box rj\n\n res.rj.copy(res.rj);\n dist.negate(res.ni);\n res.ni.normalize();\n res.ri.copy(res.rj);\n res.ri.vadd(xj, res.ri);\n res.ri.vsub(xi, res.ri);\n res.ri.normalize();\n res.ri.scale(R, res.ri); // Make relative to bodies\n\n res.ri.vadd(xi, res.ri);\n res.ri.vsub(bi.position, res.ri);\n res.rj.vadd(xj, res.rj);\n res.rj.vsub(bj.position, res.rj);\n this.result.push(res);\n this.createFrictionEquationsFromContact(res, this.frictionResult);\n }\n }\n }\n }\n\n v3pool.release(edgeTangent, edgeCenter, r, orthogonal, dist);\n }\n\n planeBox(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) {\n sj.convexPolyhedronRepresentation.material = sj.material;\n sj.convexPolyhedronRepresentation.collisionResponse = sj.collisionResponse;\n sj.convexPolyhedronRepresentation.id = sj.id;\n return this.planeConvex(si, sj.convexPolyhedronRepresentation, xi, xj, qi, qj, bi, bj, si, sj, justTest);\n }\n\n convexConvex(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest, faceListA, faceListB) {\n const sepAxis = convexConvex_sepAxis;\n\n if (xi.distanceTo(xj) > si.boundingSphereRadius + sj.boundingSphereRadius) {\n return;\n }\n\n if (si.findSeparatingAxis(sj, xi, qi, xj, qj, sepAxis, faceListA, faceListB)) {\n const res = [];\n const q = convexConvex_q;\n si.clipAgainstHull(xi, qi, sj, xj, qj, sepAxis, -100, 100, res);\n let numContacts = 0;\n\n for (let j = 0; j !== res.length; j++) {\n if (justTest) {\n return true;\n }\n\n const r = this.createContactEquation(bi, bj, si, sj, rsi, rsj);\n const ri = r.ri;\n const rj = r.rj;\n sepAxis.negate(r.ni);\n res[j].normal.negate(q);\n q.scale(res[j].depth, q);\n res[j].point.vadd(q, ri);\n rj.copy(res[j].point); // Contact points are in world coordinates. Transform back to relative\n\n ri.vsub(xi, ri);\n rj.vsub(xj, rj); // Make relative to bodies\n\n ri.vadd(xi, ri);\n ri.vsub(bi.position, ri);\n rj.vadd(xj, rj);\n rj.vsub(bj.position, rj);\n this.result.push(r);\n numContacts++;\n\n if (!this.enableFrictionReduction) {\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n }\n }\n\n if (this.enableFrictionReduction && numContacts) {\n this.createFrictionFromAverage(numContacts);\n }\n }\n }\n\n sphereConvex(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) {\n const v3pool = this.v3pool;\n xi.vsub(xj, convex_to_sphere);\n const normals = sj.faceNormals;\n const faces = sj.faces;\n const verts = sj.vertices;\n const R = si.radius;\n // return;\n // }\n\n let found = false; // Check corners\n\n for (let i = 0; i !== verts.length; i++) {\n const v = verts[i]; // World position of corner\n\n const worldCorner = sphereConvex_worldCorner;\n qj.vmult(v, worldCorner);\n xj.vadd(worldCorner, worldCorner);\n const sphere_to_corner = sphereConvex_sphereToCorner;\n worldCorner.vsub(xi, sphere_to_corner);\n\n if (sphere_to_corner.lengthSquared() < R * R) {\n if (justTest) {\n return true;\n }\n\n found = true;\n const r = this.createContactEquation(bi, bj, si, sj, rsi, rsj);\n r.ri.copy(sphere_to_corner);\n r.ri.normalize();\n r.ni.copy(r.ri);\n r.ri.scale(R, r.ri);\n worldCorner.vsub(xj, r.rj); // Should be relative to the body.\n\n r.ri.vadd(xi, r.ri);\n r.ri.vsub(bi.position, r.ri); // Should be relative to the body.\n\n r.rj.vadd(xj, r.rj);\n r.rj.vsub(bj.position, r.rj);\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n return;\n }\n } // Check side (plane) intersections\n\n\n for (let i = 0, nfaces = faces.length; i !== nfaces && found === false; i++) {\n const normal = normals[i];\n const face = faces[i]; // Get world-transformed normal of the face\n\n const worldNormal = sphereConvex_worldNormal;\n qj.vmult(normal, worldNormal); // Get a world vertex from the face\n\n const worldPoint = sphereConvex_worldPoint;\n qj.vmult(verts[face[0]], worldPoint);\n worldPoint.vadd(xj, worldPoint); // Get a point on the sphere, closest to the face normal\n\n const worldSpherePointClosestToPlane = sphereConvex_worldSpherePointClosestToPlane;\n worldNormal.scale(-R, worldSpherePointClosestToPlane);\n xi.vadd(worldSpherePointClosestToPlane, worldSpherePointClosestToPlane); // Vector from a face point to the closest point on the sphere\n\n const penetrationVec = sphereConvex_penetrationVec;\n worldSpherePointClosestToPlane.vsub(worldPoint, penetrationVec); // The penetration. Negative value means overlap.\n\n const penetration = penetrationVec.dot(worldNormal);\n const worldPointToSphere = sphereConvex_sphereToWorldPoint;\n xi.vsub(worldPoint, worldPointToSphere);\n\n if (penetration < 0 && worldPointToSphere.dot(worldNormal) > 0) {\n // Intersects plane. Now check if the sphere is inside the face polygon\n const faceVerts = []; // Face vertices, in world coords\n\n for (let j = 0, Nverts = face.length; j !== Nverts; j++) {\n const worldVertex = v3pool.get();\n qj.vmult(verts[face[j]], worldVertex);\n xj.vadd(worldVertex, worldVertex);\n faceVerts.push(worldVertex);\n }\n\n if (pointInPolygon(faceVerts, worldNormal, xi)) {\n // Is the sphere center in the face polygon?\n if (justTest) {\n return true;\n }\n\n found = true;\n const r = this.createContactEquation(bi, bj, si, sj, rsi, rsj);\n worldNormal.scale(-R, r.ri); // Contact offset, from sphere center to contact\n\n worldNormal.negate(r.ni); // Normal pointing out of sphere\n\n const penetrationVec2 = v3pool.get();\n worldNormal.scale(-penetration, penetrationVec2);\n const penetrationSpherePoint = v3pool.get();\n worldNormal.scale(-R, penetrationSpherePoint); //xi.vsub(xj).vadd(penetrationSpherePoint).vadd(penetrationVec2 , r.rj);\n\n xi.vsub(xj, r.rj);\n r.rj.vadd(penetrationSpherePoint, r.rj);\n r.rj.vadd(penetrationVec2, r.rj); // Should be relative to the body.\n\n r.rj.vadd(xj, r.rj);\n r.rj.vsub(bj.position, r.rj); // Should be relative to the body.\n\n r.ri.vadd(xi, r.ri);\n r.ri.vsub(bi.position, r.ri);\n v3pool.release(penetrationVec2);\n v3pool.release(penetrationSpherePoint);\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult); // Release world vertices\n\n for (let j = 0, Nfaceverts = faceVerts.length; j !== Nfaceverts; j++) {\n v3pool.release(faceVerts[j]);\n }\n\n return; // We only expect *one* face contact\n } else {\n // Edge?\n for (let j = 0; j !== face.length; j++) {\n // Get two world transformed vertices\n const v1 = v3pool.get();\n const v2 = v3pool.get();\n qj.vmult(verts[face[(j + 1) % face.length]], v1);\n qj.vmult(verts[face[(j + 2) % face.length]], v2);\n xj.vadd(v1, v1);\n xj.vadd(v2, v2); // Construct edge vector\n\n const edge = sphereConvex_edge;\n v2.vsub(v1, edge); // Construct the same vector, but normalized\n\n const edgeUnit = sphereConvex_edgeUnit;\n edge.unit(edgeUnit); // p is xi projected onto the edge\n\n const p = v3pool.get();\n const v1_to_xi = v3pool.get();\n xi.vsub(v1, v1_to_xi);\n const dot = v1_to_xi.dot(edgeUnit);\n edgeUnit.scale(dot, p);\n p.vadd(v1, p); // Compute a vector from p to the center of the sphere\n\n const xi_to_p = v3pool.get();\n p.vsub(xi, xi_to_p); // Collision if the edge-sphere distance is less than the radius\n // AND if p is in between v1 and v2\n\n if (dot > 0 && dot * dot < edge.lengthSquared() && xi_to_p.lengthSquared() < R * R) {\n // Collision if the edge-sphere distance is less than the radius\n // Edge contact!\n if (justTest) {\n return true;\n }\n\n const r = this.createContactEquation(bi, bj, si, sj, rsi, rsj);\n p.vsub(xj, r.rj);\n p.vsub(xi, r.ni);\n r.ni.normalize();\n r.ni.scale(R, r.ri); // Should be relative to the body.\n\n r.rj.vadd(xj, r.rj);\n r.rj.vsub(bj.position, r.rj); // Should be relative to the body.\n\n r.ri.vadd(xi, r.ri);\n r.ri.vsub(bi.position, r.ri);\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult); // Release world vertices\n\n for (let j = 0, Nfaceverts = faceVerts.length; j !== Nfaceverts; j++) {\n v3pool.release(faceVerts[j]);\n }\n\n v3pool.release(v1);\n v3pool.release(v2);\n v3pool.release(p);\n v3pool.release(xi_to_p);\n v3pool.release(v1_to_xi);\n return;\n }\n\n v3pool.release(v1);\n v3pool.release(v2);\n v3pool.release(p);\n v3pool.release(xi_to_p);\n v3pool.release(v1_to_xi);\n }\n } // Release world vertices\n\n\n for (let j = 0, Nfaceverts = faceVerts.length; j !== Nfaceverts; j++) {\n v3pool.release(faceVerts[j]);\n }\n }\n }\n }\n\n planeConvex(planeShape, convexShape, planePosition, convexPosition, planeQuat, convexQuat, planeBody, convexBody, si, sj, justTest) {\n // Simply return the points behind the plane.\n const worldVertex = planeConvex_v;\n const worldNormal = planeConvex_normal;\n worldNormal.set(0, 0, 1);\n planeQuat.vmult(worldNormal, worldNormal); // Turn normal according to plane orientation\n\n let numContacts = 0;\n const relpos = planeConvex_relpos;\n\n for (let i = 0; i !== convexShape.vertices.length; i++) {\n // Get world convex vertex\n worldVertex.copy(convexShape.vertices[i]);\n convexQuat.vmult(worldVertex, worldVertex);\n convexPosition.vadd(worldVertex, worldVertex);\n worldVertex.vsub(planePosition, relpos);\n const dot = worldNormal.dot(relpos);\n\n if (dot <= 0.0) {\n if (justTest) {\n return true;\n }\n\n const r = this.createContactEquation(planeBody, convexBody, planeShape, convexShape, si, sj); // Get vertex position projected on plane\n\n const projected = planeConvex_projected;\n worldNormal.scale(worldNormal.dot(relpos), projected);\n worldVertex.vsub(projected, projected);\n projected.vsub(planePosition, r.ri); // From plane to vertex projected on plane\n\n r.ni.copy(worldNormal); // Contact normal is the plane normal out from plane\n // rj is now just the vector from the convex center to the vertex\n\n worldVertex.vsub(convexPosition, r.rj); // Make it relative to the body\n\n r.ri.vadd(planePosition, r.ri);\n r.ri.vsub(planeBody.position, r.ri);\n r.rj.vadd(convexPosition, r.rj);\n r.rj.vsub(convexBody.position, r.rj);\n this.result.push(r);\n numContacts++;\n\n if (!this.enableFrictionReduction) {\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n }\n }\n }\n\n if (this.enableFrictionReduction && numContacts) {\n this.createFrictionFromAverage(numContacts);\n }\n }\n\n boxConvex(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) {\n si.convexPolyhedronRepresentation.material = si.material;\n si.convexPolyhedronRepresentation.collisionResponse = si.collisionResponse;\n return this.convexConvex(si.convexPolyhedronRepresentation, sj, xi, xj, qi, qj, bi, bj, si, sj, justTest);\n }\n\n sphereHeightfield(sphereShape, hfShape, spherePos, hfPos, sphereQuat, hfQuat, sphereBody, hfBody, rsi, rsj, justTest) {\n const data = hfShape.data;\n const radius = sphereShape.radius;\n const w = hfShape.elementSize;\n const worldPillarOffset = sphereHeightfield_tmp2; // Get sphere position to heightfield local!\n\n const localSpherePos = sphereHeightfield_tmp1;\n Transform.pointToLocalFrame(hfPos, hfQuat, spherePos, localSpherePos); // Get the index of the data points to test against\n\n let iMinX = Math.floor((localSpherePos.x - radius) / w) - 1;\n let iMaxX = Math.ceil((localSpherePos.x + radius) / w) + 1;\n let iMinY = Math.floor((localSpherePos.y - radius) / w) - 1;\n let iMaxY = Math.ceil((localSpherePos.y + radius) / w) + 1; // Bail out if we are out of the terrain\n\n if (iMaxX < 0 || iMaxY < 0 || iMinX > data.length || iMinY > data[0].length) {\n return;\n } // Clamp index to edges\n\n\n if (iMinX < 0) {\n iMinX = 0;\n }\n\n if (iMaxX < 0) {\n iMaxX = 0;\n }\n\n if (iMinY < 0) {\n iMinY = 0;\n }\n\n if (iMaxY < 0) {\n iMaxY = 0;\n }\n\n if (iMinX >= data.length) {\n iMinX = data.length - 1;\n }\n\n if (iMaxX >= data.length) {\n iMaxX = data.length - 1;\n }\n\n if (iMaxY >= data[0].length) {\n iMaxY = data[0].length - 1;\n }\n\n if (iMinY >= data[0].length) {\n iMinY = data[0].length - 1;\n }\n\n const minMax = [];\n hfShape.getRectMinMax(iMinX, iMinY, iMaxX, iMaxY, minMax);\n const min = minMax[0];\n const max = minMax[1]; // Bail out if we can't touch the bounding height box\n\n if (localSpherePos.z - radius > max || localSpherePos.z + radius < min) {\n return;\n }\n\n const result = this.result;\n\n for (let i = iMinX; i < iMaxX; i++) {\n for (let j = iMinY; j < iMaxY; j++) {\n const numContactsBefore = result.length;\n let intersecting = false; // Lower triangle\n\n hfShape.getConvexTrianglePillar(i, j, false);\n Transform.pointToWorldFrame(hfPos, hfQuat, hfShape.pillarOffset, worldPillarOffset);\n\n if (spherePos.distanceTo(worldPillarOffset) < hfShape.pillarConvex.boundingSphereRadius + sphereShape.boundingSphereRadius) {\n intersecting = this.sphereConvex(sphereShape, hfShape.pillarConvex, spherePos, worldPillarOffset, sphereQuat, hfQuat, sphereBody, hfBody, sphereShape, hfShape, justTest);\n }\n\n if (justTest && intersecting) {\n return true;\n } // Upper triangle\n\n\n hfShape.getConvexTrianglePillar(i, j, true);\n Transform.pointToWorldFrame(hfPos, hfQuat, hfShape.pillarOffset, worldPillarOffset);\n\n if (spherePos.distanceTo(worldPillarOffset) < hfShape.pillarConvex.boundingSphereRadius + sphereShape.boundingSphereRadius) {\n intersecting = this.sphereConvex(sphereShape, hfShape.pillarConvex, spherePos, worldPillarOffset, sphereQuat, hfQuat, sphereBody, hfBody, sphereShape, hfShape, justTest);\n }\n\n if (justTest && intersecting) {\n return true;\n }\n\n const numContacts = result.length - numContactsBefore;\n\n if (numContacts > 2) {\n return;\n }\n /*\r\n // Skip all but 1\r\n for (let k = 0; k < numContacts - 1; k++) {\r\n result.pop();\r\n }\r\n */\n\n }\n }\n }\n\n boxHeightfield(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) {\n si.convexPolyhedronRepresentation.material = si.material;\n si.convexPolyhedronRepresentation.collisionResponse = si.collisionResponse;\n return this.convexHeightfield(si.convexPolyhedronRepresentation, sj, xi, xj, qi, qj, bi, bj, si, sj, justTest);\n }\n\n convexHeightfield(convexShape, hfShape, convexPos, hfPos, convexQuat, hfQuat, convexBody, hfBody, rsi, rsj, justTest) {\n const data = hfShape.data;\n const w = hfShape.elementSize;\n const radius = convexShape.boundingSphereRadius;\n const worldPillarOffset = convexHeightfield_tmp2;\n const faceList = convexHeightfield_faceList; // Get sphere position to heightfield local!\n\n const localConvexPos = convexHeightfield_tmp1;\n Transform.pointToLocalFrame(hfPos, hfQuat, convexPos, localConvexPos); // Get the index of the data points to test against\n\n let iMinX = Math.floor((localConvexPos.x - radius) / w) - 1;\n let iMaxX = Math.ceil((localConvexPos.x + radius) / w) + 1;\n let iMinY = Math.floor((localConvexPos.y - radius) / w) - 1;\n let iMaxY = Math.ceil((localConvexPos.y + radius) / w) + 1; // Bail out if we are out of the terrain\n\n if (iMaxX < 0 || iMaxY < 0 || iMinX > data.length || iMinY > data[0].length) {\n return;\n } // Clamp index to edges\n\n\n if (iMinX < 0) {\n iMinX = 0;\n }\n\n if (iMaxX < 0) {\n iMaxX = 0;\n }\n\n if (iMinY < 0) {\n iMinY = 0;\n }\n\n if (iMaxY < 0) {\n iMaxY = 0;\n }\n\n if (iMinX >= data.length) {\n iMinX = data.length - 1;\n }\n\n if (iMaxX >= data.length) {\n iMaxX = data.length - 1;\n }\n\n if (iMaxY >= data[0].length) {\n iMaxY = data[0].length - 1;\n }\n\n if (iMinY >= data[0].length) {\n iMinY = data[0].length - 1;\n }\n\n const minMax = [];\n hfShape.getRectMinMax(iMinX, iMinY, iMaxX, iMaxY, minMax);\n const min = minMax[0];\n const max = minMax[1]; // Bail out if we're cant touch the bounding height box\n\n if (localConvexPos.z - radius > max || localConvexPos.z + radius < min) {\n return;\n }\n\n for (let i = iMinX; i < iMaxX; i++) {\n for (let j = iMinY; j < iMaxY; j++) {\n let intersecting = false; // Lower triangle\n\n hfShape.getConvexTrianglePillar(i, j, false);\n Transform.pointToWorldFrame(hfPos, hfQuat, hfShape.pillarOffset, worldPillarOffset);\n\n if (convexPos.distanceTo(worldPillarOffset) < hfShape.pillarConvex.boundingSphereRadius + convexShape.boundingSphereRadius) {\n intersecting = this.convexConvex(convexShape, hfShape.pillarConvex, convexPos, worldPillarOffset, convexQuat, hfQuat, convexBody, hfBody, null, null, justTest, faceList, null);\n }\n\n if (justTest && intersecting) {\n return true;\n } // Upper triangle\n\n\n hfShape.getConvexTrianglePillar(i, j, true);\n Transform.pointToWorldFrame(hfPos, hfQuat, hfShape.pillarOffset, worldPillarOffset);\n\n if (convexPos.distanceTo(worldPillarOffset) < hfShape.pillarConvex.boundingSphereRadius + convexShape.boundingSphereRadius) {\n intersecting = this.convexConvex(convexShape, hfShape.pillarConvex, convexPos, worldPillarOffset, convexQuat, hfQuat, convexBody, hfBody, null, null, justTest, faceList, null);\n }\n\n if (justTest && intersecting) {\n return true;\n }\n }\n }\n }\n\n sphereParticle(sj, si, xj, xi, qj, qi, bj, bi, rsi, rsj, justTest) {\n // The normal is the unit vector from sphere center to particle center\n const normal = particleSphere_normal;\n normal.set(0, 0, 1);\n xi.vsub(xj, normal);\n const lengthSquared = normal.lengthSquared();\n\n if (lengthSquared <= sj.radius * sj.radius) {\n if (justTest) {\n return true;\n }\n\n const r = this.createContactEquation(bi, bj, si, sj, rsi, rsj);\n normal.normalize();\n r.rj.copy(normal);\n r.rj.scale(sj.radius, r.rj);\n r.ni.copy(normal); // Contact normal\n\n r.ni.negate(r.ni);\n r.ri.set(0, 0, 0); // Center of particle\n\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n }\n }\n\n planeParticle(sj, si, xj, xi, qj, qi, bj, bi, rsi, rsj, justTest) {\n const normal = particlePlane_normal;\n normal.set(0, 0, 1);\n bj.quaternion.vmult(normal, normal); // Turn normal according to plane orientation\n\n const relpos = particlePlane_relpos;\n xi.vsub(bj.position, relpos);\n const dot = normal.dot(relpos);\n\n if (dot <= 0.0) {\n if (justTest) {\n return true;\n }\n\n const r = this.createContactEquation(bi, bj, si, sj, rsi, rsj);\n r.ni.copy(normal); // Contact normal is the plane normal\n\n r.ni.negate(r.ni);\n r.ri.set(0, 0, 0); // Center of particle\n // Get particle position projected on plane\n\n const projected = particlePlane_projected;\n normal.scale(normal.dot(xi), projected);\n xi.vsub(projected, projected); //projected.vadd(bj.position,projected);\n // rj is now the projected world position minus plane position\n\n r.rj.copy(projected);\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n }\n }\n\n boxParticle(si, sj, xi, xj, qi, qj, bi, bj, rsi, rsj, justTest) {\n si.convexPolyhedronRepresentation.material = si.material;\n si.convexPolyhedronRepresentation.collisionResponse = si.collisionResponse;\n return this.convexParticle(si.convexPolyhedronRepresentation, sj, xi, xj, qi, qj, bi, bj, si, sj, justTest);\n }\n\n convexParticle(sj, si, xj, xi, qj, qi, bj, bi, rsi, rsj, justTest) {\n let penetratedFaceIndex = -1;\n const penetratedFaceNormal = convexParticle_penetratedFaceNormal;\n const worldPenetrationVec = convexParticle_worldPenetrationVec;\n let minPenetration = null;\n\n const local = convexParticle_local;\n local.copy(xi);\n local.vsub(xj, local); // Convert position to relative the convex origin\n\n qj.conjugate(cqj);\n cqj.vmult(local, local);\n\n if (sj.pointIsInside(local)) {\n if (sj.worldVerticesNeedsUpdate) {\n sj.computeWorldVertices(xj, qj);\n }\n\n if (sj.worldFaceNormalsNeedsUpdate) {\n sj.computeWorldFaceNormals(qj);\n } // For each world polygon in the polyhedra\n\n\n for (let i = 0, nfaces = sj.faces.length; i !== nfaces; i++) {\n // Construct world face vertices\n const verts = [sj.worldVertices[sj.faces[i][0]]];\n const normal = sj.worldFaceNormals[i]; // Check how much the particle penetrates the polygon plane.\n\n xi.vsub(verts[0], convexParticle_vertexToParticle);\n const penetration = -normal.dot(convexParticle_vertexToParticle);\n\n if (minPenetration === null || Math.abs(penetration) < Math.abs(minPenetration)) {\n if (justTest) {\n return true;\n }\n\n minPenetration = penetration;\n penetratedFaceIndex = i;\n penetratedFaceNormal.copy(normal);\n }\n }\n\n if (penetratedFaceIndex !== -1) {\n // Setup contact\n const r = this.createContactEquation(bi, bj, si, sj, rsi, rsj);\n penetratedFaceNormal.scale(minPenetration, worldPenetrationVec); // rj is the particle position projected to the face\n\n worldPenetrationVec.vadd(xi, worldPenetrationVec);\n worldPenetrationVec.vsub(xj, worldPenetrationVec);\n r.rj.copy(worldPenetrationVec); //const projectedToFace = xi.vsub(xj).vadd(worldPenetrationVec);\n //projectedToFace.copy(r.rj);\n //qj.vmult(r.rj,r.rj);\n\n penetratedFaceNormal.negate(r.ni); // Contact normal\n\n r.ri.set(0, 0, 0); // Center of particle\n\n const ri = r.ri;\n const rj = r.rj; // Make relative to bodies\n\n ri.vadd(xi, ri);\n ri.vsub(bi.position, ri);\n rj.vadd(xj, rj);\n rj.vsub(bj.position, rj);\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n } else {\n console.warn('Point found inside convex, but did not find penetrating face!');\n }\n }\n }\n\n sphereTrimesh(sphereShape, trimeshShape, spherePos, trimeshPos, sphereQuat, trimeshQuat, sphereBody, trimeshBody, rsi, rsj, justTest) {\n const edgeVertexA = sphereTrimesh_edgeVertexA;\n const edgeVertexB = sphereTrimesh_edgeVertexB;\n const edgeVector = sphereTrimesh_edgeVector;\n const edgeVectorUnit = sphereTrimesh_edgeVectorUnit;\n const localSpherePos = sphereTrimesh_localSpherePos;\n const tmp = sphereTrimesh_tmp;\n const localSphereAABB = sphereTrimesh_localSphereAABB;\n const v2 = sphereTrimesh_v2;\n const relpos = sphereTrimesh_relpos;\n const triangles = sphereTrimesh_triangles; // Convert sphere position to local in the trimesh\n\n Transform.pointToLocalFrame(trimeshPos, trimeshQuat, spherePos, localSpherePos); // Get the aabb of the sphere locally in the trimesh\n\n const sphereRadius = sphereShape.radius;\n localSphereAABB.lowerBound.set(localSpherePos.x - sphereRadius, localSpherePos.y - sphereRadius, localSpherePos.z - sphereRadius);\n localSphereAABB.upperBound.set(localSpherePos.x + sphereRadius, localSpherePos.y + sphereRadius, localSpherePos.z + sphereRadius);\n trimeshShape.getTrianglesInAABB(localSphereAABB, triangles); //for (let i = 0; i < trimeshShape.indices.length / 3; i++) triangles.push(i); // All\n // Vertices\n\n const v = sphereTrimesh_v;\n const radiusSquared = sphereShape.radius * sphereShape.radius;\n\n for (let i = 0; i < triangles.length; i++) {\n for (let j = 0; j < 3; j++) {\n trimeshShape.getVertex(trimeshShape.indices[triangles[i] * 3 + j], v); // Check vertex overlap in sphere\n\n v.vsub(localSpherePos, relpos);\n\n if (relpos.lengthSquared() <= radiusSquared) {\n // Safe up\n v2.copy(v);\n Transform.pointToWorldFrame(trimeshPos, trimeshQuat, v2, v);\n v.vsub(spherePos, relpos);\n\n if (justTest) {\n return true;\n }\n\n let r = this.createContactEquation(sphereBody, trimeshBody, sphereShape, trimeshShape, rsi, rsj);\n r.ni.copy(relpos);\n r.ni.normalize(); // ri is the vector from sphere center to the sphere surface\n\n r.ri.copy(r.ni);\n r.ri.scale(sphereShape.radius, r.ri);\n r.ri.vadd(spherePos, r.ri);\n r.ri.vsub(sphereBody.position, r.ri);\n r.rj.copy(v);\n r.rj.vsub(trimeshBody.position, r.rj); // Store result\n\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n }\n }\n } // Check all edges\n\n\n for (let i = 0; i < triangles.length; i++) {\n for (let j = 0; j < 3; j++) {\n trimeshShape.getVertex(trimeshShape.indices[triangles[i] * 3 + j], edgeVertexA);\n trimeshShape.getVertex(trimeshShape.indices[triangles[i] * 3 + (j + 1) % 3], edgeVertexB);\n edgeVertexB.vsub(edgeVertexA, edgeVector); // Project sphere position to the edge\n\n localSpherePos.vsub(edgeVertexB, tmp);\n const positionAlongEdgeB = tmp.dot(edgeVector);\n localSpherePos.vsub(edgeVertexA, tmp);\n let positionAlongEdgeA = tmp.dot(edgeVector);\n\n if (positionAlongEdgeA > 0 && positionAlongEdgeB < 0) {\n // Now check the orthogonal distance from edge to sphere center\n localSpherePos.vsub(edgeVertexA, tmp);\n edgeVectorUnit.copy(edgeVector);\n edgeVectorUnit.normalize();\n positionAlongEdgeA = tmp.dot(edgeVectorUnit);\n edgeVectorUnit.scale(positionAlongEdgeA, tmp);\n tmp.vadd(edgeVertexA, tmp); // tmp is now the sphere center position projected to the edge, defined locally in the trimesh frame\n\n const dist = tmp.distanceTo(localSpherePos);\n\n if (dist < sphereShape.radius) {\n if (justTest) {\n return true;\n }\n\n const r = this.createContactEquation(sphereBody, trimeshBody, sphereShape, trimeshShape, rsi, rsj);\n tmp.vsub(localSpherePos, r.ni);\n r.ni.normalize();\n r.ni.scale(sphereShape.radius, r.ri);\n r.ri.vadd(spherePos, r.ri);\n r.ri.vsub(sphereBody.position, r.ri);\n Transform.pointToWorldFrame(trimeshPos, trimeshQuat, tmp, tmp);\n tmp.vsub(trimeshBody.position, r.rj);\n Transform.vectorToWorldFrame(trimeshQuat, r.ni, r.ni);\n Transform.vectorToWorldFrame(trimeshQuat, r.ri, r.ri);\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n }\n }\n }\n } // Triangle faces\n\n\n const va = sphereTrimesh_va;\n const vb = sphereTrimesh_vb;\n const vc = sphereTrimesh_vc;\n const normal = sphereTrimesh_normal;\n\n for (let i = 0, N = triangles.length; i !== N; i++) {\n trimeshShape.getTriangleVertices(triangles[i], va, vb, vc);\n trimeshShape.getNormal(triangles[i], normal);\n localSpherePos.vsub(va, tmp);\n let dist = tmp.dot(normal);\n normal.scale(dist, tmp);\n localSpherePos.vsub(tmp, tmp); // tmp is now the sphere position projected to the triangle plane\n\n dist = tmp.distanceTo(localSpherePos);\n\n if (Ray.pointInTriangle(tmp, va, vb, vc) && dist < sphereShape.radius) {\n if (justTest) {\n return true;\n }\n\n let r = this.createContactEquation(sphereBody, trimeshBody, sphereShape, trimeshShape, rsi, rsj);\n tmp.vsub(localSpherePos, r.ni);\n r.ni.normalize();\n r.ni.scale(sphereShape.radius, r.ri);\n r.ri.vadd(spherePos, r.ri);\n r.ri.vsub(sphereBody.position, r.ri);\n Transform.pointToWorldFrame(trimeshPos, trimeshQuat, tmp, tmp);\n tmp.vsub(trimeshBody.position, r.rj);\n Transform.vectorToWorldFrame(trimeshQuat, r.ni, r.ni);\n Transform.vectorToWorldFrame(trimeshQuat, r.ri, r.ri);\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n }\n }\n\n triangles.length = 0;\n }\n\n planeTrimesh(planeShape, trimeshShape, planePos, trimeshPos, planeQuat, trimeshQuat, planeBody, trimeshBody, rsi, rsj, justTest) {\n // Make contacts!\n const v = new Vec3();\n const normal = planeTrimesh_normal;\n normal.set(0, 0, 1);\n planeQuat.vmult(normal, normal); // Turn normal according to plane\n\n for (let i = 0; i < trimeshShape.vertices.length / 3; i++) {\n // Get world vertex from trimesh\n trimeshShape.getVertex(i, v); // Safe up\n\n const v2 = new Vec3();\n v2.copy(v);\n Transform.pointToWorldFrame(trimeshPos, trimeshQuat, v2, v); // Check plane side\n\n const relpos = planeTrimesh_relpos;\n v.vsub(planePos, relpos);\n const dot = normal.dot(relpos);\n\n if (dot <= 0.0) {\n if (justTest) {\n return true;\n }\n\n const r = this.createContactEquation(planeBody, trimeshBody, planeShape, trimeshShape, rsi, rsj);\n r.ni.copy(normal); // Contact normal is the plane normal\n // Get vertex position projected on plane\n\n const projected = planeTrimesh_projected;\n normal.scale(relpos.dot(normal), projected);\n v.vsub(projected, projected); // ri is the projected world position minus plane position\n\n r.ri.copy(projected);\n r.ri.vsub(planeBody.position, r.ri);\n r.rj.copy(v);\n r.rj.vsub(trimeshBody.position, r.rj); // Store result\n\n this.result.push(r);\n this.createFrictionEquationsFromContact(r, this.frictionResult);\n }\n }\n } // convexTrimesh(\n // si: ConvexPolyhedron, sj: Trimesh, xi: Vec3, xj: Vec3, qi: Quaternion, qj: Quaternion,\n // bi: Body, bj: Body, rsi?: Shape | null, rsj?: Shape | null,\n // faceListA?: number[] | null, faceListB?: number[] | null,\n // ) {\n // const sepAxis = convexConvex_sepAxis;\n // if(xi.distanceTo(xj) > si.boundingSphereRadius + sj.boundingSphereRadius){\n // return;\n // }\n // // Construct a temp hull for each triangle\n // const hullB = new ConvexPolyhedron();\n // hullB.faces = [[0,1,2]];\n // const va = new Vec3();\n // const vb = new Vec3();\n // const vc = new Vec3();\n // hullB.vertices = [\n // va,\n // vb,\n // vc\n // ];\n // for (let i = 0; i < sj.indices.length / 3; i++) {\n // const triangleNormal = new Vec3();\n // sj.getNormal(i, triangleNormal);\n // hullB.faceNormals = [triangleNormal];\n // sj.getTriangleVertices(i, va, vb, vc);\n // let d = si.testSepAxis(triangleNormal, hullB, xi, qi, xj, qj);\n // if(!d){\n // triangleNormal.scale(-1, triangleNormal);\n // d = si.testSepAxis(triangleNormal, hullB, xi, qi, xj, qj);\n // if(!d){\n // continue;\n // }\n // }\n // const res: ConvexPolyhedronContactPoint[] = [];\n // const q = convexConvex_q;\n // si.clipAgainstHull(xi,qi,hullB,xj,qj,triangleNormal,-100,100,res);\n // for(let j = 0; j !== res.length; j++){\n // const r = this.createContactEquation(bi,bj,si,sj,rsi,rsj),\n // ri = r.ri,\n // rj = r.rj;\n // r.ni.copy(triangleNormal);\n // r.ni.negate(r.ni);\n // res[j].normal.negate(q);\n // q.mult(res[j].depth, q);\n // res[j].point.vadd(q, ri);\n // rj.copy(res[j].point);\n // // Contact points are in world coordinates. Transform back to relative\n // ri.vsub(xi,ri);\n // rj.vsub(xj,rj);\n // // Make relative to bodies\n // ri.vadd(xi, ri);\n // ri.vsub(bi.position, ri);\n // rj.vadd(xj, rj);\n // rj.vsub(bj.position, rj);\n // result.push(r);\n // }\n // }\n // }\n\n\n}\nconst averageNormal = new Vec3();\nconst averageContactPointA = new Vec3();\nconst averageContactPointB = new Vec3();\nconst tmpVec1$2 = new Vec3();\nconst tmpVec2$2 = new Vec3();\nconst tmpQuat1 = new Quaternion();\nconst tmpQuat2 = new Quaternion();\n\nNarrowphase.prototype[COLLISION_TYPES.boxBox] = Narrowphase.prototype.boxBox;\nNarrowphase.prototype[COLLISION_TYPES.boxConvex] = Narrowphase.prototype.boxConvex;\nNarrowphase.prototype[COLLISION_TYPES.boxParticle] = Narrowphase.prototype.boxParticle;\nNarrowphase.prototype[COLLISION_TYPES.sphereSphere] = Narrowphase.prototype.sphereSphere;\nconst planeTrimesh_normal = new Vec3();\nconst planeTrimesh_relpos = new Vec3();\nconst planeTrimesh_projected = new Vec3();\nNarrowphase.prototype[COLLISION_TYPES.planeTrimesh] = Narrowphase.prototype.planeTrimesh;\nconst sphereTrimesh_normal = new Vec3();\nconst sphereTrimesh_relpos = new Vec3();\nconst sphereTrimesh_v = new Vec3();\nconst sphereTrimesh_v2 = new Vec3();\nconst sphereTrimesh_edgeVertexA = new Vec3();\nconst sphereTrimesh_edgeVertexB = new Vec3();\nconst sphereTrimesh_edgeVector = new Vec3();\nconst sphereTrimesh_edgeVectorUnit = new Vec3();\nconst sphereTrimesh_localSpherePos = new Vec3();\nconst sphereTrimesh_tmp = new Vec3();\nconst sphereTrimesh_va = new Vec3();\nconst sphereTrimesh_vb = new Vec3();\nconst sphereTrimesh_vc = new Vec3();\nconst sphereTrimesh_localSphereAABB = new AABB();\nconst sphereTrimesh_triangles = [];\nNarrowphase.prototype[COLLISION_TYPES.sphereTrimesh] = Narrowphase.prototype.sphereTrimesh;\nconst point_on_plane_to_sphere = new Vec3();\nconst plane_to_sphere_ortho = new Vec3();\nNarrowphase.prototype[COLLISION_TYPES.spherePlane] = Narrowphase.prototype.spherePlane; // See http://bulletphysics.com/Bullet/BulletFull/SphereTriangleDetector_8cpp_source.html\n\nconst pointInPolygon_edge = new Vec3();\nconst pointInPolygon_edge_x_normal = new Vec3();\nconst pointInPolygon_vtp = new Vec3();\n\nfunction pointInPolygon(verts, normal, p) {\n let positiveResult = null;\n const N = verts.length;\n\n for (let i = 0; i !== N; i++) {\n const v = verts[i]; // Get edge to the next vertex\n\n const edge = pointInPolygon_edge;\n verts[(i + 1) % N].vsub(v, edge); // Get cross product between polygon normal and the edge\n\n const edge_x_normal = pointInPolygon_edge_x_normal; //const edge_x_normal = new Vec3();\n\n edge.cross(normal, edge_x_normal); // Get vector between point and current vertex\n\n const vertex_to_p = pointInPolygon_vtp;\n p.vsub(v, vertex_to_p); // This dot product determines which side of the edge the point is\n\n const r = edge_x_normal.dot(vertex_to_p); // If all such dot products have same sign, we are inside the polygon.\n\n if (positiveResult === null || r > 0 && positiveResult === true || r <= 0 && positiveResult === false) {\n if (positiveResult === null) {\n positiveResult = r > 0;\n }\n\n continue;\n } else {\n return false; // Encountered some other sign. Exit.\n }\n } // If we got here, all dot products were of the same sign.\n\n\n return true;\n}\n\nconst box_to_sphere = new Vec3();\nconst sphereBox_ns = new Vec3();\nconst sphereBox_ns1 = new Vec3();\nconst sphereBox_ns2 = new Vec3();\nconst sphereBox_sides = [new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3()];\nconst sphereBox_sphere_to_corner = new Vec3();\nconst sphereBox_side_ns = new Vec3();\nconst sphereBox_side_ns1 = new Vec3();\nconst sphereBox_side_ns2 = new Vec3();\nNarrowphase.prototype[COLLISION_TYPES.sphereBox] = Narrowphase.prototype.sphereBox;\nconst convex_to_sphere = new Vec3();\nconst sphereConvex_edge = new Vec3();\nconst sphereConvex_edgeUnit = new Vec3();\nconst sphereConvex_sphereToCorner = new Vec3();\nconst sphereConvex_worldCorner = new Vec3();\nconst sphereConvex_worldNormal = new Vec3();\nconst sphereConvex_worldPoint = new Vec3();\nconst sphereConvex_worldSpherePointClosestToPlane = new Vec3();\nconst sphereConvex_penetrationVec = new Vec3();\nconst sphereConvex_sphereToWorldPoint = new Vec3();\nNarrowphase.prototype[COLLISION_TYPES.sphereConvex] = Narrowphase.prototype.sphereConvex;\nNarrowphase.prototype[COLLISION_TYPES.planeBox] = Narrowphase.prototype.planeBox;\nconst planeConvex_v = new Vec3();\nconst planeConvex_normal = new Vec3();\nconst planeConvex_relpos = new Vec3();\nconst planeConvex_projected = new Vec3();\nNarrowphase.prototype[COLLISION_TYPES.planeConvex] = Narrowphase.prototype.planeConvex;\nconst convexConvex_sepAxis = new Vec3();\nconst convexConvex_q = new Vec3();\nNarrowphase.prototype[COLLISION_TYPES.convexConvex] = Narrowphase.prototype.convexConvex; // Narrowphase.prototype[COLLISION_TYPES.convexTrimesh] = Narrowphase.prototype.convexTrimesh\n\nconst particlePlane_normal = new Vec3();\nconst particlePlane_relpos = new Vec3();\nconst particlePlane_projected = new Vec3();\nNarrowphase.prototype[COLLISION_TYPES.planeParticle] = Narrowphase.prototype.planeParticle;\nconst particleSphere_normal = new Vec3();\nNarrowphase.prototype[COLLISION_TYPES.sphereParticle] = Narrowphase.prototype.sphereParticle; // WIP\n\nconst cqj = new Quaternion();\nconst convexParticle_local = new Vec3();\nconst convexParticle_penetratedFaceNormal = new Vec3();\nconst convexParticle_vertexToParticle = new Vec3();\nconst convexParticle_worldPenetrationVec = new Vec3();\nNarrowphase.prototype[COLLISION_TYPES.convexParticle] = Narrowphase.prototype.convexParticle;\nNarrowphase.prototype[COLLISION_TYPES.boxHeightfield] = Narrowphase.prototype.boxHeightfield;\nconst convexHeightfield_tmp1 = new Vec3();\nconst convexHeightfield_tmp2 = new Vec3();\nconst convexHeightfield_faceList = [0];\nNarrowphase.prototype[COLLISION_TYPES.convexHeightfield] = Narrowphase.prototype.convexHeightfield;\nconst sphereHeightfield_tmp1 = new Vec3();\nconst sphereHeightfield_tmp2 = new Vec3();\nNarrowphase.prototype[COLLISION_TYPES.sphereHeightfield] = Narrowphase.prototype.sphereHeightfield;\n\n/**\r\n * @class OverlapKeeper\r\n * @constructor\r\n */\nclass OverlapKeeper {\n constructor() {\n this.current = [];\n this.previous = [];\n }\n\n getKey(i, j) {\n if (j < i) {\n const temp = j;\n j = i;\n i = temp;\n }\n\n return i << 16 | j;\n }\n /**\r\n * @method set\r\n * @param {Number} i\r\n * @param {Number} j\r\n */\n\n\n set(i, j) {\n // Insertion sort. This way the diff will have linear complexity.\n const key = this.getKey(i, j);\n const current = this.current;\n let index = 0;\n\n while (key > current[index]) {\n index++;\n }\n\n if (key === current[index]) {\n return; // Pair was already added\n }\n\n for (let j = current.length - 1; j >= index; j--) {\n current[j + 1] = current[j];\n }\n\n current[index] = key;\n }\n /**\r\n * @method tick\r\n */\n\n\n tick() {\n const tmp = this.current;\n this.current = this.previous;\n this.previous = tmp;\n this.current.length = 0;\n }\n /**\r\n * @method getDiff\r\n * @param {array} additions\r\n * @param {array} removals\r\n */\n\n\n getDiff(additions, removals) {\n const a = this.current;\n const b = this.previous;\n const al = a.length;\n const bl = b.length;\n let j = 0;\n\n for (let i = 0; i < al; i++) {\n let found = false;\n const keyA = a[i];\n\n while (keyA > b[j]) {\n j++;\n }\n\n found = keyA === b[j];\n\n if (!found) {\n unpackAndPush(additions, keyA);\n }\n }\n\n j = 0;\n\n for (let i = 0; i < bl; i++) {\n let found = false;\n const keyB = b[i];\n\n while (keyB > a[j]) {\n j++;\n }\n\n found = a[j] === keyB;\n\n if (!found) {\n unpackAndPush(removals, keyB);\n }\n }\n }\n\n}\n\nfunction unpackAndPush(array, key) {\n array.push((key & 0xffff0000) >> 16, key & 0x0000ffff);\n}\n\n/**\r\n * @class TupleDictionary\r\n * @constructor\r\n */\nclass TupleDictionary {\n constructor() {\n this.data = {\n keys: []\n };\n }\n /**\r\n * @method get\r\n * @param {Number} i\r\n * @param {Number} j\r\n * @return {Object}\r\n */\n\n\n get(i, j) {\n if (i > j) {\n // swap\n const temp = j;\n j = i;\n i = temp;\n }\n\n return this.data[i + \"-\" + j];\n }\n /**\r\n * @method set\r\n * @param {Number} i\r\n * @param {Number} j\r\n * @param {Object} value\r\n */\n\n\n set(i, j, value) {\n if (i > j) {\n const temp = j;\n j = i;\n i = temp;\n }\n\n const key = i + \"-\" + j; // Check if key already exists\n\n if (!this.get(i, j)) {\n this.data.keys.push(key);\n }\n\n this.data[key] = value;\n }\n /**\r\n * @method reset\r\n */\n\n\n reset() {\n const data = this.data;\n const keys = data.keys;\n\n while (keys.length > 0) {\n const key = keys.pop();\n delete data[key];\n }\n }\n\n}\n\n/**\r\n * The physics world\r\n * @class World\r\n * @constructor\r\n * @extends EventTarget\r\n * @param {object} [options]\r\n * @param {Vec3} [options.gravity]\r\n * @param {boolean} [options.allowSleep]\r\n * @param {Broadphase} [options.broadphase]\r\n * @param {Solver} [options.solver]\r\n * @param {boolean} [options.quatNormalizeFast]\r\n * @param {number} [options.quatNormalizeSkip]\r\n */\nclass World extends EventTarget {\n // Currently / last used timestep. Is set to -1 if not available. This value is updated before each internal step, which means that it is \"fresh\" inside event callbacks.\n // Makes bodies go to sleep when they've been inactive.\n // All the current contacts (instances of ContactEquation) in the world.\n // How often to normalize quaternions. Set to 0 for every step, 1 for every second etc.. A larger value increases performance. If bodies tend to explode, set to a smaller value (zero to be sure nothing can go wrong).\n // Set to true to use fast quaternion normalization. It is often enough accurate to use. If bodies tend to explode, set to false.\n // The wall-clock time since simulation start.\n // Number of timesteps taken since start.\n // Default and last timestep sizes.\n // The broadphase algorithm to use. Default is NaiveBroadphase.\n // All bodies in this world\n // True if any bodies are not sleeping, false if every body is sleeping.\n // The solver algorithm to use. Default is GSSolver.\n // CollisionMatrix from the previous step.\n // All added materials.\n // Used to look up a ContactMaterial given two instances of Material.\n // This contact material is used if no suitable contactmaterial is found for a contact.\n // Time accumulator for interpolation. See http://gafferongames.com/game-physics/fix-your-timestep/\n // Dispatched after a body has been added to the world.\n // Dispatched after a body has been removed from the world.\n constructor(options = {}) {\n super();\n this.dt = -1;\n this.allowSleep = !!options.allowSleep;\n this.contacts = [];\n this.frictionEquations = [];\n this.quatNormalizeSkip = options.quatNormalizeSkip !== undefined ? options.quatNormalizeSkip : 0;\n this.quatNormalizeFast = options.quatNormalizeFast !== undefined ? options.quatNormalizeFast : false;\n this.time = 0.0;\n this.stepnumber = 0;\n this.default_dt = 1 / 60;\n this.nextId = 0;\n this.gravity = new Vec3();\n\n if (options.gravity) {\n this.gravity.copy(options.gravity);\n }\n\n this.broadphase = options.broadphase !== undefined ? options.broadphase : new NaiveBroadphase();\n this.bodies = [];\n this.hasActiveBodies = false;\n this.solver = options.solver !== undefined ? options.solver : new GSSolver();\n this.constraints = [];\n this.narrowphase = new Narrowphase(this);\n this.collisionMatrix = new ArrayCollisionMatrix();\n this.collisionMatrixPrevious = new ArrayCollisionMatrix();\n this.bodyOverlapKeeper = new OverlapKeeper();\n this.shapeOverlapKeeper = new OverlapKeeper();\n this.materials = [];\n this.contactmaterials = [];\n this.contactMaterialTable = new TupleDictionary();\n this.defaultMaterial = new Material('default');\n this.defaultContactMaterial = new ContactMaterial(this.defaultMaterial, this.defaultMaterial, {\n friction: 0.3,\n restitution: 0.0\n });\n this.doProfiling = false;\n this.profile = {\n solve: 0,\n makeContactConstraints: 0,\n broadphase: 0,\n integrate: 0,\n narrowphase: 0\n };\n this.accumulator = 0;\n this.subsystems = [];\n this.addBodyEvent = {\n type: 'addBody',\n body: null\n };\n this.removeBodyEvent = {\n type: 'removeBody',\n body: null\n };\n this.idToBodyMap = {};\n this.broadphase.setWorld(this);\n }\n /**\r\n * Get the contact material between materials m1 and m2\r\n * @method getContactMaterial\r\n * @param {Material} m1\r\n * @param {Material} m2\r\n * @return {ContactMaterial} The contact material if it was found.\r\n */\n\n\n getContactMaterial(m1, m2) {\n return this.contactMaterialTable.get(m1.id, m2.id);\n }\n /**\r\n * Get number of objects in the world.\r\n * @method numObjects\r\n * @return {Number}\r\n * @deprecated\r\n */\n\n\n numObjects() {\n return this.bodies.length;\n }\n /**\r\n * Store old collision state info\r\n * @method collisionMatrixTick\r\n */\n\n\n collisionMatrixTick() {\n const temp = this.collisionMatrixPrevious;\n this.collisionMatrixPrevious = this.collisionMatrix;\n this.collisionMatrix = temp;\n this.collisionMatrix.reset();\n this.bodyOverlapKeeper.tick();\n this.shapeOverlapKeeper.tick();\n }\n /**\r\n * Add a constraint to the simulation.\r\n * @method addConstraint\r\n * @param {Constraint} c\r\n */\n\n\n addConstraint(c) {\n this.constraints.push(c);\n }\n /**\r\n * Removes a constraint\r\n * @method removeConstraint\r\n * @param {Constraint} c\r\n */\n\n\n removeConstraint(c) {\n const idx = this.constraints.indexOf(c);\n\n if (idx !== -1) {\n this.constraints.splice(idx, 1);\n }\n }\n /**\r\n * Raycast test\r\n * @method rayTest\r\n * @param {Vec3} from\r\n * @param {Vec3} to\r\n * @param {RaycastResult} result\r\n * @deprecated Use .raycastAll, .raycastClosest or .raycastAny instead.\r\n */\n\n\n rayTest(from, to, result) {\n if (result instanceof RaycastResult) {\n // Do raycastClosest\n this.raycastClosest(from, to, {\n skipBackfaces: true\n }, result);\n } else {\n // Do raycastAll\n this.raycastAll(from, to, {\n skipBackfaces: true\n }, result);\n }\n }\n /**\r\n * Ray cast against all bodies. The provided callback will be executed for each hit with a RaycastResult as single argument.\r\n * @method raycastAll\r\n * @param {Vec3} from\r\n * @param {Vec3} to\r\n * @param {Object} options\r\n * @param {number} [options.collisionFilterMask=-1]\r\n * @param {number} [options.collisionFilterGroup=-1]\r\n * @param {boolean} [options.skipBackfaces=false]\r\n * @param {boolean} [options.checkCollisionResponse=true]\r\n * @param {Function} callback\r\n * @return {boolean} True if any body was hit.\r\n */\n\n\n raycastAll(from, to, options = {}, callback) {\n options.mode = Ray.ALL;\n options.from = from;\n options.to = to;\n options.callback = callback;\n return tmpRay$1.intersectWorld(this, options);\n }\n /**\r\n * Ray cast, and stop at the first result. Note that the order is random - but the method is fast.\r\n * @method raycastAny\r\n * @param {Vec3} from\r\n * @param {Vec3} to\r\n * @param {Object} options\r\n * @param {number} [options.collisionFilterMask=-1]\r\n * @param {number} [options.collisionFilterGroup=-1]\r\n * @param {boolean} [options.skipBackfaces=false]\r\n * @param {boolean} [options.checkCollisionResponse=true]\r\n * @param {RaycastResult} result\r\n * @return {boolean} True if any body was hit.\r\n */\n\n\n raycastAny(from, to, options = {}, result) {\n options.mode = Ray.ANY;\n options.from = from;\n options.to = to;\n options.result = result;\n return tmpRay$1.intersectWorld(this, options);\n }\n /**\r\n * Ray cast, and return information of the closest hit.\r\n * @method raycastClosest\r\n * @param {Vec3} from\r\n * @param {Vec3} to\r\n * @param {Object} options\r\n * @param {number} [options.collisionFilterMask=-1]\r\n * @param {number} [options.collisionFilterGroup=-1]\r\n * @param {boolean} [options.skipBackfaces=false]\r\n * @param {boolean} [options.checkCollisionResponse=true]\r\n * @param {RaycastResult} result\r\n * @return {boolean} True if any body was hit.\r\n */\n\n\n raycastClosest(from, to, options = {}, result) {\n options.mode = Ray.CLOSEST;\n options.from = from;\n options.to = to;\n options.result = result;\n return tmpRay$1.intersectWorld(this, options);\n }\n /**\r\n * Add a rigid body to the simulation.\r\n * @method add\r\n * @param {Body} body\r\n * @todo If the simulation has not yet started, why recrete and copy arrays for each body? Accumulate in dynamic arrays in this case.\r\n * @todo Adding an array of bodies should be possible. This would save some loops too\r\n */\n\n\n addBody(body) {\n if (this.bodies.includes(body)) {\n return;\n }\n\n body.index = this.bodies.length;\n this.bodies.push(body);\n body.world = this;\n body.initPosition.copy(body.position);\n body.initVelocity.copy(body.velocity);\n body.timeLastSleepy = this.time;\n\n if (body instanceof Body) {\n body.initAngularVelocity.copy(body.angularVelocity);\n body.initQuaternion.copy(body.quaternion);\n }\n\n this.collisionMatrix.setNumObjects(this.bodies.length);\n this.addBodyEvent.body = body;\n this.idToBodyMap[body.id] = body;\n this.dispatchEvent(this.addBodyEvent);\n }\n /**\r\n * Remove a rigid body from the simulation.\r\n * @method remove\r\n * @param {Body} body\r\n */\n\n\n removeBody(body) {\n body.world = null;\n const n = this.bodies.length - 1;\n const bodies = this.bodies;\n const idx = bodies.indexOf(body);\n\n if (idx !== -1) {\n bodies.splice(idx, 1); // Todo: should use a garbage free method\n // Recompute index\n\n for (let i = 0; i !== bodies.length; i++) {\n bodies[i].index = i;\n }\n\n this.collisionMatrix.setNumObjects(n);\n this.removeBodyEvent.body = body;\n delete this.idToBodyMap[body.id];\n this.dispatchEvent(this.removeBodyEvent);\n }\n }\n\n getBodyById(id) {\n return this.idToBodyMap[id];\n } // TODO Make a faster map\n\n\n getShapeById(id) {\n const bodies = this.bodies;\n\n for (let i = 0, bl = bodies.length; i < bl; i++) {\n const shapes = bodies[i].shapes;\n\n for (let j = 0, sl = shapes.length; j < sl; j++) {\n const shape = shapes[j];\n\n if (shape.id === id) {\n return shape;\n }\n }\n }\n }\n /**\r\n * Adds a material to the World.\r\n * @method addMaterial\r\n * @param {Material} m\r\n * @todo Necessary?\r\n */\n\n\n addMaterial(m) {\n this.materials.push(m);\n }\n /**\r\n * Adds a contact material to the World\r\n * @method addContactMaterial\r\n * @param {ContactMaterial} cmat\r\n */\n\n\n addContactMaterial(cmat) {\n // Add contact material\n this.contactmaterials.push(cmat); // Add current contact material to the material table\n\n this.contactMaterialTable.set(cmat.materials[0].id, cmat.materials[1].id, cmat);\n }\n /**\r\n * Step the physics world forward in time.\r\n *\r\n * There are two modes. The simple mode is fixed timestepping without interpolation. In this case you only use the first argument. The second case uses interpolation. In that you also provide the time since the function was last used, as well as the maximum fixed timesteps to take.\r\n *\r\n * @method step\r\n * @param {Number} dt The fixed time step size to use.\r\n * @param {Number} [timeSinceLastCalled] The time elapsed since the function was last called.\r\n * @param {Number} [maxSubSteps=10] Maximum number of fixed steps to take per function call.\r\n *\r\n * @example\r\n * // fixed timestepping without interpolation\r\n * world.step(1/60);\r\n *\r\n * @see http://bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World\r\n */\n\n\n step(dt, timeSinceLastCalled = 0, maxSubSteps = 10) {\n if (timeSinceLastCalled === 0) {\n // Fixed, simple stepping\n this.internalStep(dt); // Increment time\n\n this.time += dt;\n } else {\n this.accumulator += timeSinceLastCalled;\n let substeps = 0;\n\n while (this.accumulator >= dt && substeps < maxSubSteps) {\n // Do fixed steps to catch up\n this.internalStep(dt);\n this.accumulator -= dt;\n substeps++;\n }\n\n const t = this.accumulator % dt / dt;\n\n for (let j = 0; j !== this.bodies.length; j++) {\n const b = this.bodies[j];\n b.previousPosition.lerp(b.position, t, b.interpolatedPosition);\n b.previousQuaternion.slerp(b.quaternion, t, b.interpolatedQuaternion);\n b.previousQuaternion.normalize();\n }\n\n this.time += timeSinceLastCalled;\n }\n }\n\n internalStep(dt) {\n this.dt = dt;\n const contacts = this.contacts;\n const p1 = World_step_p1;\n const p2 = World_step_p2;\n const N = this.numObjects();\n const bodies = this.bodies;\n const solver = this.solver;\n const gravity = this.gravity;\n const doProfiling = this.doProfiling;\n const profile = this.profile;\n const DYNAMIC = Body.DYNAMIC;\n let profilingStart = -Infinity;\n const constraints = this.constraints;\n const frictionEquationPool = World_step_frictionEquationPool;\n const gnorm = gravity.length();\n const gx = gravity.x;\n const gy = gravity.y;\n const gz = gravity.z;\n let i = 0;\n\n if (doProfiling) {\n profilingStart = performance.now();\n } // Add gravity to all objects\n\n\n for (i = 0; i !== N; i++) {\n const bi = bodies[i];\n\n if (bi.type === DYNAMIC) {\n // Only for dynamic bodies\n const f = bi.force;\n const m = bi.mass;\n f.x += m * gx;\n f.y += m * gy;\n f.z += m * gz;\n }\n } // Update subsystems\n\n\n for (let i = 0, Nsubsystems = this.subsystems.length; i !== Nsubsystems; i++) {\n this.subsystems[i].update();\n } // Collision detection\n\n\n if (doProfiling) {\n profilingStart = performance.now();\n }\n\n p1.length = 0; // Clean up pair arrays from last step\n\n p2.length = 0;\n this.broadphase.collisionPairs(this, p1, p2);\n\n if (doProfiling) {\n profile.broadphase = performance.now() - profilingStart;\n } // Remove constrained pairs with collideConnected == false\n\n\n let Nconstraints = constraints.length;\n\n for (i = 0; i !== Nconstraints; i++) {\n const c = constraints[i];\n\n if (!c.collideConnected) {\n for (let j = p1.length - 1; j >= 0; j -= 1) {\n if (c.bodyA === p1[j] && c.bodyB === p2[j] || c.bodyB === p1[j] && c.bodyA === p2[j]) {\n p1.splice(j, 1);\n p2.splice(j, 1);\n }\n }\n }\n }\n\n this.collisionMatrixTick(); // Generate contacts\n\n if (doProfiling) {\n profilingStart = performance.now();\n }\n\n const oldcontacts = World_step_oldContacts;\n const NoldContacts = contacts.length;\n\n for (i = 0; i !== NoldContacts; i++) {\n oldcontacts.push(contacts[i]);\n }\n\n contacts.length = 0; // Transfer FrictionEquation from current list to the pool for reuse\n\n const NoldFrictionEquations = this.frictionEquations.length;\n\n for (i = 0; i !== NoldFrictionEquations; i++) {\n frictionEquationPool.push(this.frictionEquations[i]);\n }\n\n this.frictionEquations.length = 0;\n this.narrowphase.getContacts(p1, p2, this, contacts, oldcontacts, // To be reused\n this.frictionEquations, frictionEquationPool);\n\n if (doProfiling) {\n profile.narrowphase = performance.now() - profilingStart;\n } // Loop over all collisions\n\n\n if (doProfiling) {\n profilingStart = performance.now();\n } // Add all friction eqs\n\n\n for (i = 0; i < this.frictionEquations.length; i++) {\n solver.addEquation(this.frictionEquations[i]);\n }\n\n const ncontacts = contacts.length;\n\n for (let k = 0; k !== ncontacts; k++) {\n // Current contact\n const c = contacts[k]; // Get current collision indeces\n\n const bi = c.bi;\n const bj = c.bj;\n const si = c.si;\n const sj = c.sj; // Get collision properties\n\n let cm;\n\n if (bi.material && bj.material) {\n cm = this.getContactMaterial(bi.material, bj.material) || this.defaultContactMaterial;\n } else {\n cm = this.defaultContactMaterial;\n } // c.enabled = bi.collisionResponse && bj.collisionResponse && si.collisionResponse && sj.collisionResponse;\n\n\n let mu = cm.friction; // c.restitution = cm.restitution;\n // If friction or restitution were specified in the material, use them\n\n if (bi.material && bj.material) {\n if (bi.material.friction >= 0 && bj.material.friction >= 0) {\n mu = bi.material.friction * bj.material.friction;\n }\n\n if (bi.material.restitution >= 0 && bj.material.restitution >= 0) {\n c.restitution = bi.material.restitution * bj.material.restitution;\n }\n } // c.setSpookParams(\n // cm.contactEquationStiffness,\n // cm.contactEquationRelaxation,\n // dt\n // );\n\n\n solver.addEquation(c); // // Add friction constraint equation\n // if(mu > 0){\n // \t// Create 2 tangent equations\n // \tconst mug = mu * gnorm;\n // \tconst reducedMass = (bi.invMass + bj.invMass);\n // \tif(reducedMass > 0){\n // \t\treducedMass = 1/reducedMass;\n // \t}\n // \tconst pool = frictionEquationPool;\n // \tconst c1 = pool.length ? pool.pop() : new FrictionEquation(bi,bj,mug*reducedMass);\n // \tconst c2 = pool.length ? pool.pop() : new FrictionEquation(bi,bj,mug*reducedMass);\n // \tthis.frictionEquations.push(c1, c2);\n // \tc1.bi = c2.bi = bi;\n // \tc1.bj = c2.bj = bj;\n // \tc1.minForce = c2.minForce = -mug*reducedMass;\n // \tc1.maxForce = c2.maxForce = mug*reducedMass;\n // \t// Copy over the relative vectors\n // \tc1.ri.copy(c.ri);\n // \tc1.rj.copy(c.rj);\n // \tc2.ri.copy(c.ri);\n // \tc2.rj.copy(c.rj);\n // \t// Construct tangents\n // \tc.ni.tangents(c1.t, c2.t);\n // // Set spook params\n // c1.setSpookParams(cm.frictionEquationStiffness, cm.frictionEquationRelaxation, dt);\n // c2.setSpookParams(cm.frictionEquationStiffness, cm.frictionEquationRelaxation, dt);\n // c1.enabled = c2.enabled = c.enabled;\n // \t// Add equations to solver\n // \tsolver.addEquation(c1);\n // \tsolver.addEquation(c2);\n // }\n\n if (bi.allowSleep && bi.type === Body.DYNAMIC && bi.sleepState === Body.SLEEPING && bj.sleepState === Body.AWAKE && bj.type !== Body.STATIC) {\n const speedSquaredB = bj.velocity.lengthSquared() + bj.angularVelocity.lengthSquared();\n const speedLimitSquaredB = bj.sleepSpeedLimit ** 2;\n\n if (speedSquaredB >= speedLimitSquaredB * 2) {\n bi.wakeUpAfterNarrowphase = true;\n }\n }\n\n if (bj.allowSleep && bj.type === Body.DYNAMIC && bj.sleepState === Body.SLEEPING && bi.sleepState === Body.AWAKE && bi.type !== Body.STATIC) {\n const speedSquaredA = bi.velocity.lengthSquared() + bi.angularVelocity.lengthSquared();\n const speedLimitSquaredA = bi.sleepSpeedLimit ** 2;\n\n if (speedSquaredA >= speedLimitSquaredA * 2) {\n bj.wakeUpAfterNarrowphase = true;\n }\n } // Now we know that i and j are in contact. Set collision matrix state\n\n\n this.collisionMatrix.set(bi, bj, true);\n\n if (!this.collisionMatrixPrevious.get(bi, bj)) {\n // First contact!\n // We reuse the collideEvent object, otherwise we will end up creating new objects for each new contact, even if there's no event listener attached.\n World_step_collideEvent.body = bj;\n World_step_collideEvent.contact = c;\n bi.dispatchEvent(World_step_collideEvent);\n World_step_collideEvent.body = bi;\n bj.dispatchEvent(World_step_collideEvent);\n }\n\n this.bodyOverlapKeeper.set(bi.id, bj.id);\n this.shapeOverlapKeeper.set(si.id, sj.id);\n }\n\n this.emitContactEvents();\n\n if (doProfiling) {\n profile.makeContactConstraints = performance.now() - profilingStart;\n profilingStart = performance.now();\n } // Wake up bodies\n\n\n for (i = 0; i !== N; i++) {\n const bi = bodies[i];\n\n if (bi.wakeUpAfterNarrowphase) {\n bi.wakeUp();\n bi.wakeUpAfterNarrowphase = false;\n }\n } // Add user-added constraints\n\n\n Nconstraints = constraints.length;\n\n for (i = 0; i !== Nconstraints; i++) {\n const c = constraints[i];\n c.update();\n\n for (let j = 0, Neq = c.equations.length; j !== Neq; j++) {\n const eq = c.equations[j];\n solver.addEquation(eq);\n }\n } // Solve the constrained system\n\n\n solver.solve(dt, this);\n\n if (doProfiling) {\n profile.solve = performance.now() - profilingStart;\n } // Remove all contacts from solver\n\n\n solver.removeAllEquations(); // Apply damping, see http://code.google.com/p/bullet/issues/detail?id=74 for details\n\n const pow = Math.pow;\n\n for (i = 0; i !== N; i++) {\n const bi = bodies[i];\n\n if (bi.type & DYNAMIC) {\n // Only for dynamic bodies\n const ld = pow(1.0 - bi.linearDamping, dt);\n const v = bi.velocity;\n v.scale(ld, v);\n const av = bi.angularVelocity;\n\n if (av) {\n const ad = pow(1.0 - bi.angularDamping, dt);\n av.scale(ad, av);\n }\n }\n }\n\n this.dispatchEvent(World_step_preStepEvent); // Invoke pre-step callbacks\n\n for (i = 0; i !== N; i++) {\n const bi = bodies[i];\n\n if (bi.preStep) {\n bi.preStep.call(bi);\n }\n } // Leap frog\n // vnew = v + h*f/m\n // xnew = x + h*vnew\n\n\n if (doProfiling) {\n profilingStart = performance.now();\n }\n\n const stepnumber = this.stepnumber;\n const quatNormalize = stepnumber % (this.quatNormalizeSkip + 1) === 0;\n const quatNormalizeFast = this.quatNormalizeFast;\n\n for (i = 0; i !== N; i++) {\n bodies[i].integrate(dt, quatNormalize, quatNormalizeFast);\n }\n\n this.clearForces();\n this.broadphase.dirty = true;\n\n if (doProfiling) {\n profile.integrate = performance.now() - profilingStart;\n } // Update world time\n\n\n this.time += dt;\n this.stepnumber += 1;\n this.dispatchEvent(World_step_postStepEvent); // Invoke post-step callbacks\n\n for (i = 0; i !== N; i++) {\n const bi = bodies[i];\n const postStep = bi.postStep;\n\n if (postStep) {\n postStep.call(bi);\n }\n } // Sleeping update\n\n\n let hasActiveBodies = true;\n\n if (this.allowSleep) {\n hasActiveBodies = false;\n\n for (i = 0; i !== N; i++) {\n const bi = bodies[i];\n bi.sleepTick(this.time);\n\n if (bi.sleepState !== Body.SLEEPING) {\n hasActiveBodies = true;\n }\n }\n }\n\n this.hasActiveBodies = hasActiveBodies;\n }\n /**\r\n * Sets all body forces in the world to zero.\r\n * @method clearForces\r\n */\n\n\n clearForces() {\n const bodies = this.bodies;\n const N = bodies.length;\n\n for (let i = 0; i !== N; i++) {\n const b = bodies[i];\n const force = b.force;\n const tau = b.torque;\n b.force.set(0, 0, 0);\n b.torque.set(0, 0, 0);\n }\n }\n\n} // Temp stuff\n\nconst tmpAABB1 = new AABB();\nconst tmpRay$1 = new Ray(); // performance.now()\n\nif (typeof performance === 'undefined') {\n performance = {};\n}\n\nif (!performance.now) {\n let nowOffset = Date.now();\n\n if (performance.timing && performance.timing.navigationStart) {\n nowOffset = performance.timing.navigationStart;\n }\n\n performance.now = () => Date.now() - nowOffset;\n}\n// Reusable event objects to save memory.\n\nconst World_step_postStepEvent = {\n type: 'postStep'\n}; // Dispatched before the world steps forward in time.\n\nconst World_step_preStepEvent = {\n type: 'preStep'\n};\nconst World_step_collideEvent = {\n type: Body.COLLIDE_EVENT_NAME,\n body: null,\n contact: null\n}; // Pools for unused objects\n\nconst World_step_oldContacts = [];\nconst World_step_frictionEquationPool = []; // Reusable arrays for collision pairs\n\nconst World_step_p1 = [];\nconst World_step_p2 = [];\n\nWorld.prototype.emitContactEvents = (() => {\n const additions = [];\n const removals = [];\n const beginContactEvent = {\n type: 'beginContact',\n bodyA: null,\n bodyB: null\n };\n const endContactEvent = {\n type: 'endContact',\n bodyA: null,\n bodyB: null\n };\n const beginShapeContactEvent = {\n type: 'beginShapeContact',\n bodyA: null,\n bodyB: null,\n shapeA: null,\n shapeB: null\n };\n const endShapeContactEvent = {\n type: 'endShapeContact',\n bodyA: null,\n bodyB: null,\n shapeA: null,\n shapeB: null\n };\n return function () {\n const hasBeginContact = this.hasAnyEventListener('beginContact');\n const hasEndContact = this.hasAnyEventListener('endContact');\n\n if (hasBeginContact || hasEndContact) {\n this.bodyOverlapKeeper.getDiff(additions, removals);\n }\n\n if (hasBeginContact) {\n for (let i = 0, l = additions.length; i < l; i += 2) {\n beginContactEvent.bodyA = this.getBodyById(additions[i]);\n beginContactEvent.bodyB = this.getBodyById(additions[i + 1]);\n this.dispatchEvent(beginContactEvent);\n }\n\n beginContactEvent.bodyA = beginContactEvent.bodyB = null;\n }\n\n if (hasEndContact) {\n for (let i = 0, l = removals.length; i < l; i += 2) {\n endContactEvent.bodyA = this.getBodyById(removals[i]);\n endContactEvent.bodyB = this.getBodyById(removals[i + 1]);\n this.dispatchEvent(endContactEvent);\n }\n\n endContactEvent.bodyA = endContactEvent.bodyB = null;\n }\n\n additions.length = removals.length = 0;\n const hasBeginShapeContact = this.hasAnyEventListener('beginShapeContact');\n const hasEndShapeContact = this.hasAnyEventListener('endShapeContact');\n\n if (hasBeginShapeContact || hasEndShapeContact) {\n this.shapeOverlapKeeper.getDiff(additions, removals);\n }\n\n if (hasBeginShapeContact) {\n for (let i = 0, l = additions.length; i < l; i += 2) {\n const shapeA = this.getShapeById(additions[i]);\n const shapeB = this.getShapeById(additions[i + 1]);\n beginShapeContactEvent.shapeA = shapeA;\n beginShapeContactEvent.shapeB = shapeB;\n beginShapeContactEvent.bodyA = shapeA.body;\n beginShapeContactEvent.bodyB = shapeB.body;\n this.dispatchEvent(beginShapeContactEvent);\n }\n\n beginShapeContactEvent.bodyA = beginShapeContactEvent.bodyB = beginShapeContactEvent.shapeA = beginShapeContactEvent.shapeB = null;\n }\n\n if (hasEndShapeContact) {\n for (let i = 0, l = removals.length; i < l; i += 2) {\n const shapeA = this.getShapeById(removals[i]);\n const shapeB = this.getShapeById(removals[i + 1]);\n endShapeContactEvent.shapeA = shapeA;\n endShapeContactEvent.shapeB = shapeB;\n endShapeContactEvent.bodyA = shapeA.body;\n endShapeContactEvent.bodyB = shapeB.body;\n this.dispatchEvent(endShapeContactEvent);\n }\n\n endShapeContactEvent.bodyA = endShapeContactEvent.bodyB = endShapeContactEvent.shapeA = endShapeContactEvent.shapeB = null;\n }\n };\n})();\n\n\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./node_modules/cannon-es/dist/cannon-es.js?"); - geometry = getGeometry(object); - if (!geometry) return null; +/***/ }), - switch (geometry.type) { - case 'BoxGeometry': - case 'BoxBufferGeometry': - return getBoxParameters(geometry); +/***/ "./node_modules/three-to-ammo/index.js": +/*!*********************************************!*\ + !*** ./node_modules/three-to-ammo/index.js ***! + \*********************************************/ +/***/ ((__unused_webpack_module, exports) => { - case 'CylinderGeometry': - case 'CylinderBufferGeometry': - return getCylinderParameters(geometry); +"use strict"; +eval("\n/* global Ammo,THREE */\n\nconst TYPE = (exports.TYPE = {\n BOX: \"box\",\n CYLINDER: \"cylinder\",\n SPHERE: \"sphere\",\n CAPSULE: \"capsule\",\n CONE: \"cone\",\n HULL: \"hull\",\n HACD: \"hacd\", //Hierarchical Approximate Convex Decomposition\n VHACD: \"vhacd\", //Volumetric Hierarchical Approximate Convex Decomposition\n MESH: \"mesh\",\n HEIGHTFIELD: \"heightfield\"\n});\n\nconst FIT = (exports.FIT = {\n ALL: \"all\", //A single shape is automatically sized to bound all meshes within the entity.\n MANUAL: \"manual\" //A single shape is sized manually. Requires halfExtents or sphereRadius.\n});\n\nconst HEIGHTFIELD_DATA_TYPE = (exports.HEIGHTFIELD_DATA_TYPE = {\n short: \"short\",\n float: \"float\"\n});\n\nconst hasUpdateMatricesFunction = THREE.Object3D.prototype.hasOwnProperty(\"updateMatrices\");\n\nexports.createCollisionShapes = function(root, options) {\n switch (options.type) {\n case TYPE.BOX:\n return [this.createBoxShape(root, options)];\n case TYPE.CYLINDER:\n return [this.createCylinderShape(root, options)];\n case TYPE.CAPSULE:\n return [this.createCapsuleShape(root, options)];\n case TYPE.CONE:\n return [this.createConeShape(root, options)];\n case TYPE.SPHERE:\n return [this.createSphereShape(root, options)];\n case TYPE.HULL:\n return [this.createHullShape(root, options)];\n case TYPE.HACD:\n return this.createHACDShapes(root, options);\n case TYPE.VHACD:\n return this.createVHACDShapes(root, options);\n case TYPE.MESH:\n return [this.createTriMeshShape(root, options)];\n case TYPE.HEIGHTFIELD:\n return [this.createHeightfieldTerrainShape(root, options)];\n default:\n console.warn(options.type + \" is not currently supported\");\n return [];\n }\n};\n\n//TODO: support gimpact (dynamic trimesh) and heightmap\n\nexports.createBoxShape = function(root, options) {\n options.type = TYPE.BOX;\n _setOptions(options);\n\n if (options.fit === FIT.ALL) {\n options.halfExtents = _computeHalfExtents(\n root,\n _computeBounds(root, options),\n options.minHalfExtent,\n options.maxHalfExtent\n );\n }\n\n const btHalfExtents = new Ammo.btVector3(options.halfExtents.x, options.halfExtents.y, options.halfExtents.z);\n const collisionShape = new Ammo.btBoxShape(btHalfExtents);\n Ammo.destroy(btHalfExtents);\n\n _finishCollisionShape(collisionShape, options, _computeScale(root, options));\n return collisionShape;\n};\n\nexports.createCylinderShape = function(root, options) {\n options.type = TYPE.CYLINDER;\n _setOptions(options);\n\n if (options.fit === FIT.ALL) {\n options.halfExtents = _computeHalfExtents(\n root,\n _computeBounds(root, options),\n options.minHalfExtent,\n options.maxHalfExtent\n );\n }\n\n const btHalfExtents = new Ammo.btVector3(options.halfExtents.x, options.halfExtents.y, options.halfExtents.z);\n const collisionShape = (() => {\n switch (options.cylinderAxis) {\n case \"y\":\n return new Ammo.btCylinderShape(btHalfExtents);\n case \"x\":\n return new Ammo.btCylinderShapeX(btHalfExtents);\n case \"z\":\n return new Ammo.btCylinderShapeZ(btHalfExtents);\n }\n return null;\n })();\n Ammo.destroy(btHalfExtents);\n\n _finishCollisionShape(collisionShape, options, _computeScale(root, options));\n return collisionShape;\n};\n\nexports.createCapsuleShape = function(root, options) {\n options.type = TYPE.CAPSULE;\n _setOptions(options);\n\n if (options.fit === FIT.ALL) {\n options.halfExtents = _computeHalfExtents(\n root,\n _computeBounds(root, options),\n options.minHalfExtent,\n options.maxHalfExtent\n );\n }\n\n const { x, y, z } = options.halfExtents;\n const collisionShape = (() => {\n switch (options.cylinderAxis) {\n case \"y\":\n return new Ammo.btCapsuleShape(Math.max(x, z), y * 2);\n case \"x\":\n return new Ammo.btCapsuleShapeX(Math.max(y, z), x * 2);\n case \"z\":\n return new Ammo.btCapsuleShapeZ(Math.max(x, y), z * 2);\n }\n return null;\n })();\n\n _finishCollisionShape(collisionShape, options, _computeScale(root, options));\n return collisionShape;\n};\n\nexports.createConeShape = function(root, options) {\n options.type = TYPE.CONE;\n _setOptions(options);\n\n if (options.fit === FIT.ALL) {\n options.halfExtents = _computeHalfExtents(\n root,\n _computeBounds(root, options),\n options.minHalfExtent,\n options.maxHalfExtent\n );\n }\n\n const { x, y, z } = options.halfExtents;\n const collisionShape = (() => {\n switch (options.cylinderAxis) {\n case \"y\":\n return new Ammo.btConeShape(Math.max(x, z), y * 2);\n case \"x\":\n return new Ammo.btConeShapeX(Math.max(y, z), x * 2);\n case \"z\":\n return new Ammo.btConeShapeZ(Math.max(x, y), z * 2);\n }\n return null;\n })();\n\n _finishCollisionShape(collisionShape, options, _computeScale(root, options));\n return collisionShape;\n};\n\nexports.createSphereShape = function(root, options) {\n options.type = TYPE.SPHERE;\n _setOptions(options);\n\n let radius;\n if (options.fit === FIT.MANUAL && !isNaN(options.sphereRadius)) {\n radius = options.sphereRadius;\n } else {\n radius = _computeRadius(root, options, _computeBounds(root, options));\n }\n\n const collisionShape = new Ammo.btSphereShape(radius);\n _finishCollisionShape(collisionShape, options, _computeScale(root, options));\n\n return collisionShape;\n};\n\nexports.createHullShape = (function() {\n const vertex = new THREE.Vector3();\n const center = new THREE.Vector3();\n return function(root, options) {\n options.type = TYPE.HULL;\n _setOptions(options);\n\n if (options.fit === FIT.MANUAL) {\n console.warn(\"cannot use fit: manual with type: hull\");\n return null;\n }\n\n const bounds = _computeBounds(root, options);\n\n const btVertex = new Ammo.btVector3();\n const originalHull = new Ammo.btConvexHullShape();\n originalHull.setMargin(options.margin);\n center.addVectors(bounds.max, bounds.min).multiplyScalar(0.5);\n\n let vertexCount = 0;\n _iterateGeometries(root, options, geo => {\n vertexCount += geo.attributes.position.array.length / 3;\n });\n\n const maxVertices = options.hullMaxVertices || 100000;\n // todo: might want to implement this in a deterministic way that doesn't do O(verts) calls to Math.random\n if (vertexCount > maxVertices) {\n console.warn(`too many vertices for hull shape; sampling ~${maxVertices} from ~${vertexCount} vertices`);\n }\n const p = Math.min(1, maxVertices / vertexCount);\n\n _iterateGeometries(root, options, (geo, transform) => {\n const components = geo.attributes.position.array;\n for (let i = 0; i < components.length; i += 3) {\n if (Math.random() <= p) {\n vertex\n .set(components[i], components[i + 1], components[i + 2])\n .applyMatrix4(transform)\n .sub(center);\n btVertex.setValue(vertex.x, vertex.y, vertex.z);\n originalHull.addPoint(btVertex, i === components.length - 3); // todo: better to recalc AABB only on last geometry\n }\n }\n });\n\n let collisionShape = originalHull;\n if (originalHull.getNumVertices() >= 100) {\n //Bullet documentation says don't use convexHulls with 100 verts or more\n const shapeHull = new Ammo.btShapeHull(originalHull);\n shapeHull.buildHull(options.margin);\n Ammo.destroy(originalHull);\n collisionShape = new Ammo.btConvexHullShape(\n Ammo.getPointer(shapeHull.getVertexPointer()),\n shapeHull.numVertices()\n );\n Ammo.destroy(shapeHull); // btConvexHullShape makes a copy\n }\n\n Ammo.destroy(btVertex);\n\n _finishCollisionShape(collisionShape, options, _computeScale(root, options));\n return collisionShape;\n };\n})();\n\nexports.createHACDShapes = (function() {\n const v = new THREE.Vector3();\n const center = new THREE.Vector3();\n return function(root, options) {\n options.type = TYPE.HACD;\n _setOptions(options);\n\n if (options.fit === FIT.MANUAL) {\n console.warn(\"cannot use fit: manual with type: hacd\");\n return [];\n }\n\n if (!Ammo.hasOwnProperty(\"HACD\")) {\n console.warn(\n \"HACD unavailable in included build of Ammo.js. Visit https://github.com/mozillareality/ammo.js for the latest version.\"\n );\n return [];\n }\n\n const bounds = _computeBounds(root);\n const scale = _computeScale(root, options);\n\n let vertexCount = 0;\n let triCount = 0;\n center.addVectors(bounds.max, bounds.min).multiplyScalar(0.5);\n\n _iterateGeometries(root, options, geo => {\n vertexCount += geo.attributes.position.array.length / 3;\n if (geo.index) {\n triCount += geo.index.array.length / 3;\n } else {\n triCount += geo.attributes.position.array.length / 9;\n }\n });\n\n const hacd = new Ammo.HACD();\n if (options.hasOwnProperty(\"compacityWeight\")) hacd.SetCompacityWeight(options.compacityWeight);\n if (options.hasOwnProperty(\"volumeWeight\")) hacd.SetVolumeWeight(options.volumeWeight);\n if (options.hasOwnProperty(\"nClusters\")) hacd.SetNClusters(options.nClusters);\n if (options.hasOwnProperty(\"nVerticesPerCH\")) hacd.SetNVerticesPerCH(options.nVerticesPerCH);\n if (options.hasOwnProperty(\"concavity\")) hacd.SetConcavity(options.concavity);\n\n const points = Ammo._malloc(vertexCount * 3 * 8);\n const triangles = Ammo._malloc(triCount * 3 * 4);\n hacd.SetPoints(points);\n hacd.SetTriangles(triangles);\n hacd.SetNPoints(vertexCount);\n hacd.SetNTriangles(triCount);\n\n const pptr = points / 8,\n tptr = triangles / 4;\n _iterateGeometries(root, options, (geo, transform) => {\n const components = geo.attributes.position.array;\n const indices = geo.index ? geo.index.array : null;\n for (let i = 0; i < components.length; i += 3) {\n v.set(components[i + 0], components[i + 1], components[i + 2])\n .applyMatrix4(transform)\n .sub(center);\n Ammo.HEAPF64[pptr + i + 0] = v.x;\n Ammo.HEAPF64[pptr + i + 1] = v.y;\n Ammo.HEAPF64[pptr + i + 2] = v.z;\n }\n if (indices) {\n for (let i = 0; i < indices.length; i++) {\n Ammo.HEAP32[tptr + i] = indices[i];\n }\n } else {\n for (let i = 0; i < components.length / 3; i++) {\n Ammo.HEAP32[tptr + i] = i;\n }\n }\n });\n\n hacd.Compute();\n Ammo._free(points);\n Ammo._free(triangles);\n const nClusters = hacd.GetNClusters();\n\n const shapes = [];\n for (let i = 0; i < nClusters; i++) {\n const hull = new Ammo.btConvexHullShape();\n hull.setMargin(options.margin);\n const nPoints = hacd.GetNPointsCH(i);\n const nTriangles = hacd.GetNTrianglesCH(i);\n const hullPoints = Ammo._malloc(nPoints * 3 * 8);\n const hullTriangles = Ammo._malloc(nTriangles * 3 * 4);\n hacd.GetCH(i, hullPoints, hullTriangles);\n\n const pptr = hullPoints / 8;\n for (let pi = 0; pi < nPoints; pi++) {\n const btVertex = new Ammo.btVector3();\n const px = Ammo.HEAPF64[pptr + pi * 3 + 0];\n const py = Ammo.HEAPF64[pptr + pi * 3 + 1];\n const pz = Ammo.HEAPF64[pptr + pi * 3 + 2];\n btVertex.setValue(px, py, pz);\n hull.addPoint(btVertex, pi === nPoints - 1);\n Ammo.destroy(btVertex);\n }\n\n _finishCollisionShape(hull, options, scale);\n shapes.push(hull);\n }\n\n return shapes;\n };\n})();\n\nexports.createVHACDShapes = (function() {\n const v = new THREE.Vector3();\n const center = new THREE.Vector3();\n return function(root, options) {\n options.type = TYPE.VHACD;\n _setOptions(options);\n\n if (options.fit === FIT.MANUAL) {\n console.warn(\"cannot use fit: manual with type: vhacd\");\n return [];\n }\n\n if (!Ammo.hasOwnProperty(\"VHACD\")) {\n console.warn(\n \"VHACD unavailable in included build of Ammo.js. Visit https://github.com/mozillareality/ammo.js for the latest version.\"\n );\n return [];\n }\n\n const bounds = _computeBounds(root, options);\n const scale = _computeScale(root, options);\n\n let vertexCount = 0;\n let triCount = 0;\n center.addVectors(bounds.max, bounds.min).multiplyScalar(0.5);\n\n _iterateGeometries(root, options, geo => {\n vertexCount += geo.attributes.position.count;\n if (geo.index) {\n triCount += geo.index.count / 3;\n } else {\n triCount += geo.attributes.position.count / 3;\n }\n });\n\n const vhacd = new Ammo.VHACD();\n const params = new Ammo.Parameters();\n //https://kmamou.blogspot.com/2014/12/v-hacd-20-parameters-description.html\n if (options.hasOwnProperty(\"resolution\")) params.set_m_resolution(options.resolution);\n if (options.hasOwnProperty(\"depth\")) params.set_m_depth(options.depth);\n if (options.hasOwnProperty(\"concavity\")) params.set_m_concavity(options.concavity);\n if (options.hasOwnProperty(\"planeDownsampling\")) params.set_m_planeDownsampling(options.planeDownsampling);\n if (options.hasOwnProperty(\"convexhullDownsampling\"))\n params.set_m_convexhullDownsampling(options.convexhullDownsampling);\n if (options.hasOwnProperty(\"alpha\")) params.set_m_alpha(options.alpha);\n if (options.hasOwnProperty(\"beta\")) params.set_m_beta(options.beta);\n if (options.hasOwnProperty(\"gamma\")) params.set_m_gamma(options.gamma);\n if (options.hasOwnProperty(\"pca\")) params.set_m_pca(options.pca);\n if (options.hasOwnProperty(\"mode\")) params.set_m_mode(options.mode);\n if (options.hasOwnProperty(\"maxNumVerticesPerCH\")) params.set_m_maxNumVerticesPerCH(options.maxNumVerticesPerCH);\n if (options.hasOwnProperty(\"minVolumePerCH\")) params.set_m_minVolumePerCH(options.minVolumePerCH);\n if (options.hasOwnProperty(\"convexhullApproximation\"))\n params.set_m_convexhullApproximation(options.convexhullApproximation);\n if (options.hasOwnProperty(\"oclAcceleration\")) params.set_m_oclAcceleration(options.oclAcceleration);\n\n const points = Ammo._malloc(vertexCount * 3 * 8);\n const triangles = Ammo._malloc(triCount * 3 * 4);\n\n let pptr = points / 8,\n tptr = triangles / 4;\n _iterateGeometries(root, options, (geo, transform) => {\n const components = geo.attributes.position.array;\n const indices = geo.index ? geo.index.array : null;\n for (let i = 0; i < components.length; i += 3) {\n v.set(components[i + 0], components[i + 1], components[i + 2])\n .applyMatrix4(transform)\n .sub(center);\n Ammo.HEAPF64[pptr + 0] = v.x;\n Ammo.HEAPF64[pptr + 1] = v.y;\n Ammo.HEAPF64[pptr + 2] = v.z;\n pptr += 3;\n }\n if (indices) {\n for (let i = 0; i < indices.length; i++) {\n Ammo.HEAP32[tptr] = indices[i];\n tptr++;\n }\n } else {\n for (let i = 0; i < components.length / 3; i++) {\n Ammo.HEAP32[tptr] = i;\n tptr++;\n }\n }\n });\n\n vhacd.Compute(points, 3, vertexCount, triangles, 3, triCount, params);\n Ammo._free(points);\n Ammo._free(triangles);\n const nHulls = vhacd.GetNConvexHulls();\n\n const shapes = [];\n const ch = new Ammo.ConvexHull();\n for (let i = 0; i < nHulls; i++) {\n vhacd.GetConvexHull(i, ch);\n const nPoints = ch.get_m_nPoints();\n const hullPoints = ch.get_m_points();\n\n const hull = new Ammo.btConvexHullShape();\n hull.setMargin(options.margin);\n\n for (let pi = 0; pi < nPoints; pi++) {\n const btVertex = new Ammo.btVector3();\n const px = ch.get_m_points(pi * 3 + 0);\n const py = ch.get_m_points(pi * 3 + 1);\n const pz = ch.get_m_points(pi * 3 + 2);\n btVertex.setValue(px, py, pz);\n hull.addPoint(btVertex, pi === nPoints - 1);\n Ammo.destroy(btVertex);\n }\n\n _finishCollisionShape(hull, options, scale);\n shapes.push(hull);\n }\n Ammo.destroy(ch);\n Ammo.destroy(vhacd);\n\n return shapes;\n };\n})();\n\nexports.createTriMeshShape = (function() {\n const va = new THREE.Vector3();\n const vb = new THREE.Vector3();\n const vc = new THREE.Vector3();\n return function(root, options) {\n options.type = TYPE.MESH;\n _setOptions(options);\n\n if (options.fit === FIT.MANUAL) {\n console.warn(\"cannot use fit: manual with type: mesh\");\n return null;\n }\n\n const scale = _computeScale(root, options);\n\n const bta = new Ammo.btVector3();\n const btb = new Ammo.btVector3();\n const btc = new Ammo.btVector3();\n const triMesh = new Ammo.btTriangleMesh(true, false);\n\n _iterateGeometries(root, options, (geo, transform) => {\n const components = geo.attributes.position.array;\n if (geo.index) {\n for (let i = 0; i < geo.index.count; i += 3) {\n const ai = geo.index.array[i] * 3;\n const bi = geo.index.array[i + 1] * 3;\n const ci = geo.index.array[i + 2] * 3;\n va.set(components[ai], components[ai + 1], components[ai + 2]).applyMatrix4(transform);\n vb.set(components[bi], components[bi + 1], components[bi + 2]).applyMatrix4(transform);\n vc.set(components[ci], components[ci + 1], components[ci + 2]).applyMatrix4(transform);\n bta.setValue(va.x, va.y, va.z);\n btb.setValue(vb.x, vb.y, vb.z);\n btc.setValue(vc.x, vc.y, vc.z);\n triMesh.addTriangle(bta, btb, btc, false);\n }\n } else {\n for (let i = 0; i < components.length; i += 9) {\n va.set(components[i + 0], components[i + 1], components[i + 2]).applyMatrix4(transform);\n vb.set(components[i + 3], components[i + 4], components[i + 5]).applyMatrix4(transform);\n vc.set(components[i + 6], components[i + 7], components[i + 8]).applyMatrix4(transform);\n bta.setValue(va.x, va.y, va.z);\n btb.setValue(vb.x, vb.y, vb.z);\n btc.setValue(vc.x, vc.y, vc.z);\n triMesh.addTriangle(bta, btb, btc, false);\n }\n }\n });\n\n const localScale = new Ammo.btVector3(scale.x, scale.y, scale.z);\n triMesh.setScaling(localScale);\n Ammo.destroy(localScale);\n\n const collisionShape = new Ammo.btBvhTriangleMeshShape(triMesh, true, true);\n collisionShape.resources = [triMesh];\n\n Ammo.destroy(bta);\n Ammo.destroy(btb);\n Ammo.destroy(btc);\n\n _finishCollisionShape(collisionShape, options);\n return collisionShape;\n };\n})();\n\nexports.createHeightfieldTerrainShape = function(root, options) {\n _setOptions(options);\n\n if (options.fit === FIT.ALL) {\n console.warn(\"cannot use fit: all with type: heightfield\");\n return null;\n }\n const heightfieldDistance = options.heightfieldDistance || 1;\n const heightfieldData = options.heightfieldData || [];\n const heightScale = options.heightScale || 0;\n const upAxis = options.hasOwnProperty(\"upAxis\") ? options.upAxis : 1; // x = 0; y = 1; z = 2\n const hdt = (() => {\n switch (options.heightDataType) {\n case \"short\":\n return Ammo.PHY_SHORT;\n case \"float\":\n return Ammo.PHY_FLOAT;\n default:\n return Ammo.PHY_FLOAT;\n }\n })();\n const flipQuadEdges = options.hasOwnProperty(\"flipQuadEdges\") ? options.flipQuadEdges : true;\n\n const heightStickLength = heightfieldData.length;\n const heightStickWidth = heightStickLength > 0 ? heightfieldData[0].length : 0;\n\n const data = Ammo._malloc(heightStickLength * heightStickWidth * 4);\n const ptr = data / 4;\n\n let minHeight = Number.POSITIVE_INFINITY;\n let maxHeight = Number.NEGATIVE_INFINITY;\n let index = 0;\n for (let l = 0; l < heightStickLength; l++) {\n for (let w = 0; w < heightStickWidth; w++) {\n const height = heightfieldData[l][w];\n Ammo.HEAPF32[ptr + index] = height;\n index++;\n minHeight = Math.min(minHeight, height);\n maxHeight = Math.max(maxHeight, height);\n }\n }\n\n const collisionShape = new Ammo.btHeightfieldTerrainShape(\n heightStickWidth,\n heightStickLength,\n data,\n heightScale,\n minHeight,\n maxHeight,\n upAxis,\n hdt,\n flipQuadEdges\n );\n\n const scale = new Ammo.btVector3(heightfieldDistance, 1, heightfieldDistance);\n collisionShape.setLocalScaling(scale);\n Ammo.destroy(scale);\n\n collisionShape.heightfieldData = data;\n\n _finishCollisionShape(collisionShape, options);\n return collisionShape;\n};\n\nfunction _setOptions(options) {\n options.fit = options.hasOwnProperty(\"fit\") ? options.fit : FIT.ALL;\n options.type = options.type || TYPE.HULL;\n options.minHalfExtent = options.hasOwnProperty(\"minHalfExtent\") ? options.minHalfExtent : 0;\n options.maxHalfExtent = options.hasOwnProperty(\"maxHalfExtent\") ? options.maxHalfExtent : Number.POSITIVE_INFINITY;\n options.cylinderAxis = options.cylinderAxis || \"y\";\n options.margin = options.hasOwnProperty(\"margin\") ? options.margin : 0.01;\n options.includeInvisible = options.hasOwnProperty(\"includeInvisible\") ? options.includeInvisible : false;\n\n if (!options.offset) {\n options.offset = new THREE.Vector3();\n }\n\n if (!options.orientation) {\n options.orientation = new THREE.Quaternion();\n }\n}\n\nconst _finishCollisionShape = function(collisionShape, options, scale) {\n collisionShape.type = options.type;\n collisionShape.setMargin(options.margin);\n collisionShape.destroy = () => {\n for (let res of collisionShape.resources || []) {\n Ammo.destroy(res);\n }\n if (collisionShape.heightfieldData) {\n Ammo._free(collisionShape.heightfieldData);\n }\n Ammo.destroy(collisionShape);\n };\n\n const localTransform = new Ammo.btTransform();\n const rotation = new Ammo.btQuaternion();\n localTransform.setIdentity();\n\n localTransform.getOrigin().setValue(options.offset.x, options.offset.y, options.offset.z);\n rotation.setValue(options.orientation.x, options.orientation.y, options.orientation.z, options.orientation.w);\n\n localTransform.setRotation(rotation);\n Ammo.destroy(rotation);\n\n if (scale) {\n const localScale = new Ammo.btVector3(scale.x, scale.y, scale.z);\n collisionShape.setLocalScaling(localScale);\n Ammo.destroy(localScale);\n }\n\n collisionShape.localTransform = localTransform;\n};\n\n// Calls `cb(geo, transform)` for each geometry under `root` whose vertices we should take into account for the physics shape.\n// `transform` is the transform required to transform the given geometry's vertices into root-local space.\nconst _iterateGeometries = (function() {\n const transform = new THREE.Matrix4();\n const inverse = new THREE.Matrix4();\n const bufferGeometry = new THREE.BufferGeometry();\n return function(root, options, cb) {\n inverse.copy(root.matrixWorld).invert();\n root.traverse(mesh => {\n if (\n mesh.isMesh &&\n (!THREE.Sky || mesh.__proto__ != THREE.Sky.prototype) &&\n (options.includeInvisible || ((mesh.el && mesh.el.object3D.visible) || mesh.visible))\n ) {\n if (mesh === root) {\n transform.identity();\n } else {\n if (hasUpdateMatricesFunction) mesh.updateMatrices();\n transform.multiplyMatrices(inverse, mesh.matrixWorld);\n }\n // todo: might want to return null xform if this is the root so that callers can avoid multiplying\n // things by the identity matrix\n cb(mesh.geometry.isBufferGeometry ? mesh.geometry : bufferGeometry.fromGeometry(mesh.geometry), transform);\n }\n });\n };\n})();\n\nconst _computeScale = function(root, options) {\n const scale = new THREE.Vector3(1, 1, 1);\n if (options.fit === FIT.ALL) {\n scale.setFromMatrixScale(root.matrixWorld);\n }\n return scale;\n};\n\nconst _computeRadius = (function() {\n const v = new THREE.Vector3();\n const center = new THREE.Vector3();\n return function(root, options, bounds) {\n let maxRadiusSq = 0;\n let { x: cx, y: cy, z: cz } = bounds.getCenter(center);\n _iterateGeometries(root, options, (geo, transform) => {\n const components = geo.attributes.position.array;\n for (let i = 0; i < components.length; i += 3) {\n v.set(components[i], components[i + 1], components[i + 2]).applyMatrix4(transform);\n const dx = cx - v.x;\n const dy = cy - v.y;\n const dz = cz - v.z;\n maxRadiusSq = Math.max(maxRadiusSq, dx * dx + dy * dy + dz * dz);\n }\n });\n return Math.sqrt(maxRadiusSq);\n };\n})();\n\nconst _computeHalfExtents = function(root, bounds, minHalfExtent, maxHalfExtent) {\n const halfExtents = new THREE.Vector3();\n return halfExtents\n .subVectors(bounds.max, bounds.min)\n .multiplyScalar(0.5)\n .clampScalar(minHalfExtent, maxHalfExtent);\n};\n\nconst _computeLocalOffset = function(matrix, bounds, target) {\n target\n .addVectors(bounds.max, bounds.min)\n .multiplyScalar(0.5)\n .applyMatrix4(matrix);\n return target;\n};\n\n// returns the bounding box for the geometries underneath `root`.\nconst _computeBounds = (function() {\n const v = new THREE.Vector3();\n return function(root, options) {\n const bounds = new THREE.Box3();\n let minX = +Infinity;\n let minY = +Infinity;\n let minZ = +Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n let maxZ = -Infinity;\n bounds.min.set(0, 0, 0);\n bounds.max.set(0, 0, 0);\n _iterateGeometries(root, options, (geo, transform) => {\n const components = geo.attributes.position.array;\n for (let i = 0; i < components.length; i += 3) {\n v.set(components[i], components[i + 1], components[i + 2]).applyMatrix4(transform);\n if (v.x < minX) minX = v.x;\n if (v.y < minY) minY = v.y;\n if (v.z < minZ) minZ = v.z;\n if (v.x > maxX) maxX = v.x;\n if (v.y > maxY) maxY = v.y;\n if (v.z > maxZ) maxZ = v.z;\n }\n });\n bounds.min.set(minX, minY, minZ);\n bounds.max.set(maxX, maxY, maxZ);\n return bounds;\n };\n})();\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./node_modules/three-to-ammo/index.js?"); - case 'PlaneGeometry': - case 'PlaneBufferGeometry': - return getPlaneParameters(geometry); +/***/ }), - case 'SphereGeometry': - case 'SphereBufferGeometry': - return getSphereParameters(geometry); +/***/ "./node_modules/webworkify-webpack/index.js": +/*!**************************************************!*\ + !*** ./node_modules/webworkify-webpack/index.js ***! + \**************************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - case 'TubeGeometry': - case 'BufferGeometry': - return getBoundingBoxParameters(object); +eval("function webpackBootstrapFunc (modules) {\n/******/ // The module cache\n/******/ var installedModules = {};\n\n/******/ // The require function\n/******/ function __nested_webpack_require_154__(moduleId) {\n\n/******/ // Check if module is in cache\n/******/ if(installedModules[moduleId])\n/******/ return installedModules[moduleId].exports;\n\n/******/ // Create a new module (and put it into the cache)\n/******/ var module = installedModules[moduleId] = {\n/******/ i: moduleId,\n/******/ l: false,\n/******/ exports: {}\n/******/ };\n\n/******/ // Execute the module function\n/******/ modules[moduleId].call(module.exports, module, module.exports, __nested_webpack_require_154__);\n\n/******/ // Flag the module as loaded\n/******/ module.l = true;\n\n/******/ // Return the exports of the module\n/******/ return module.exports;\n/******/ }\n\n/******/ // expose the modules object (__webpack_modules__)\n/******/ __nested_webpack_require_154__.m = modules;\n\n/******/ // expose the module cache\n/******/ __nested_webpack_require_154__.c = installedModules;\n\n/******/ // identity function for calling harmony imports with the correct context\n/******/ __nested_webpack_require_154__.i = function(value) { return value; };\n\n/******/ // define getter function for harmony exports\n/******/ __nested_webpack_require_154__.d = function(exports, name, getter) {\n/******/ if(!__nested_webpack_require_154__.o(exports, name)) {\n/******/ Object.defineProperty(exports, name, {\n/******/ configurable: false,\n/******/ enumerable: true,\n/******/ get: getter\n/******/ });\n/******/ }\n/******/ };\n\n/******/ // define __esModule on exports\n/******/ __nested_webpack_require_154__.r = function(exports) {\n/******/ Object.defineProperty(exports, '__esModule', { value: true });\n/******/ };\n\n/******/ // getDefaultExport function for compatibility with non-harmony modules\n/******/ __nested_webpack_require_154__.n = function(module) {\n/******/ var getter = module && module.__esModule ?\n/******/ function getDefault() { return module['default']; } :\n/******/ function getModuleExports() { return module; };\n/******/ __nested_webpack_require_154__.d(getter, 'a', getter);\n/******/ return getter;\n/******/ };\n\n/******/ // Object.prototype.hasOwnProperty.call\n/******/ __nested_webpack_require_154__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n/******/ // __webpack_public_path__\n/******/ __nested_webpack_require_154__.p = \"/\";\n\n/******/ // on error function for async loading\n/******/ __nested_webpack_require_154__.oe = function(err) { console.error(err); throw err; };\n\n var f = __nested_webpack_require_154__(__nested_webpack_require_154__.s = ENTRY_MODULE)\n return f.default || f // try to call default if defined to also support babel esmodule exports\n}\n\nvar moduleNameReqExp = '[\\\\.|\\\\-|\\\\+|\\\\w|\\/|@]+'\nvar dependencyRegExp = '\\\\(\\\\s*(\\/\\\\*.*?\\\\*\\/)?\\\\s*.*?(' + moduleNameReqExp + ').*?\\\\)' // additional chars when output.pathinfo is true\n\n// http://stackoverflow.com/a/2593661/130442\nfunction quoteRegExp (str) {\n return (str + '').replace(/[.?*+^$[\\]\\\\(){}|-]/g, '\\\\$&')\n}\n\nfunction isNumeric(n) {\n return !isNaN(1 * n); // 1 * n converts integers, integers as string (\"123\"), 1e3 and \"1e3\" to integers and strings to NaN\n}\n\nfunction getModuleDependencies (sources, module, queueName) {\n var retval = {}\n retval[queueName] = []\n\n var fnString = module.toString()\n var wrapperSignature = fnString.match(/^function\\s?\\w*\\(\\w+,\\s*\\w+,\\s*(\\w+)\\)/)\n if (!wrapperSignature) return retval\n var webpackRequireName = wrapperSignature[1]\n\n // main bundle deps\n var re = new RegExp('(\\\\\\\\n|\\\\W)' + quoteRegExp(webpackRequireName) + dependencyRegExp, 'g')\n var match\n while ((match = re.exec(fnString))) {\n if (match[3] === 'dll-reference') continue\n retval[queueName].push(match[3])\n }\n\n // dll deps\n re = new RegExp('\\\\(' + quoteRegExp(webpackRequireName) + '\\\\(\"(dll-reference\\\\s(' + moduleNameReqExp + '))\"\\\\)\\\\)' + dependencyRegExp, 'g')\n while ((match = re.exec(fnString))) {\n if (!sources[match[2]]) {\n retval[queueName].push(match[1])\n sources[match[2]] = __webpack_require__(match[1]).m\n }\n retval[match[2]] = retval[match[2]] || []\n retval[match[2]].push(match[4])\n }\n\n // convert 1e3 back to 1000 - this can be important after uglify-js converted 1000 to 1e3\n var keys = Object.keys(retval);\n for (var i = 0; i < keys.length; i++) {\n for (var j = 0; j < retval[keys[i]].length; j++) {\n if (isNumeric(retval[keys[i]][j])) {\n retval[keys[i]][j] = 1 * retval[keys[i]][j];\n }\n }\n }\n\n return retval\n}\n\nfunction hasValuesInQueues (queues) {\n var keys = Object.keys(queues)\n return keys.reduce(function (hasValues, key) {\n return hasValues || queues[key].length > 0\n }, false)\n}\n\nfunction getRequiredModules (sources, moduleId) {\n var modulesQueue = {\n main: [moduleId]\n }\n var requiredModules = {\n main: []\n }\n var seenModules = {\n main: {}\n }\n\n while (hasValuesInQueues(modulesQueue)) {\n var queues = Object.keys(modulesQueue)\n for (var i = 0; i < queues.length; i++) {\n var queueName = queues[i]\n var queue = modulesQueue[queueName]\n var moduleToCheck = queue.pop()\n seenModules[queueName] = seenModules[queueName] || {}\n if (seenModules[queueName][moduleToCheck] || !sources[queueName][moduleToCheck]) continue\n seenModules[queueName][moduleToCheck] = true\n requiredModules[queueName] = requiredModules[queueName] || []\n requiredModules[queueName].push(moduleToCheck)\n var newModules = getModuleDependencies(sources, sources[queueName][moduleToCheck], queueName)\n var newModulesKeys = Object.keys(newModules)\n for (var j = 0; j < newModulesKeys.length; j++) {\n modulesQueue[newModulesKeys[j]] = modulesQueue[newModulesKeys[j]] || []\n modulesQueue[newModulesKeys[j]] = modulesQueue[newModulesKeys[j]].concat(newModules[newModulesKeys[j]])\n }\n }\n }\n\n return requiredModules\n}\n\nmodule.exports = function (moduleId, options) {\n options = options || {}\n var sources = {\n main: __webpack_require__.m\n }\n\n var requiredModules = options.all ? { main: Object.keys(sources.main) } : getRequiredModules(sources, moduleId)\n\n var src = ''\n\n Object.keys(requiredModules).filter(function (m) { return m !== 'main' }).forEach(function (module) {\n var entryModule = 0\n while (requiredModules[module][entryModule]) {\n entryModule++\n }\n requiredModules[module].push(entryModule)\n sources[module][entryModule] = '(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })'\n src = src + 'var ' + module + ' = (' + webpackBootstrapFunc.toString().replace('ENTRY_MODULE', JSON.stringify(entryModule)) + ')({' + requiredModules[module].map(function (id) { return '' + JSON.stringify(id) + ': ' + sources[module][id].toString() }).join(',') + '});\\n'\n })\n\n src = src + 'new ((' + webpackBootstrapFunc.toString().replace('ENTRY_MODULE', JSON.stringify(moduleId)) + ')({' + requiredModules.main.map(function (id) { return '' + JSON.stringify(id) + ': ' + sources.main[id].toString() }).join(',') + '}))(self);'\n\n var blob = new window.Blob([src], { type: 'text/javascript' })\n if (options.bare) { return blob }\n\n var URL = window.URL || window.webkitURL || window.mozURL || window.msURL\n\n var workerUrl = URL.createObjectURL(blob)\n var worker = new window.Worker(workerUrl)\n worker.objectURL = workerUrl\n\n return worker\n}\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./node_modules/webworkify-webpack/index.js?"); - default: - console.warn('Unrecognized geometry: "%s". Using bounding box as shape.', geometry.type); - return getBoxParameters(geometry); - } -}; -/** - * Given a THREE.Object3D instance, creates a corresponding CANNON shape. - */ +/***/ }), -const threeToCannon = function (object, options = {}) { - const shapeParameters = getShapeParameters(object, options); +/***/ "./src/components/ammo-constraint.js": +/*!*******************************************!*\ + !*** ./src/components/ammo-constraint.js ***! + \*******************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - if (!shapeParameters) { - return null; - } +eval("/* global Ammo */\r\nconst CONSTRAINT = (__webpack_require__(/*! ../constants */ \"./src/constants.js\").CONSTRAINT);\r\n\r\nmodule.exports = AFRAME.registerComponent(\"ammo-constraint\", {\r\n multiple: true,\r\n\r\n schema: {\r\n // Type of constraint.\r\n type: {\r\n default: CONSTRAINT.LOCK,\r\n oneOf: [\r\n CONSTRAINT.LOCK,\r\n CONSTRAINT.FIXED,\r\n CONSTRAINT.SPRING,\r\n CONSTRAINT.SLIDER,\r\n CONSTRAINT.HINGE,\r\n CONSTRAINT.CONE_TWIST,\r\n CONSTRAINT.POINT_TO_POINT\r\n ]\r\n },\r\n\r\n // Target (other) body for the constraint.\r\n target: { type: \"selector\" },\r\n\r\n // Offset of the hinge or point-to-point constraint, defined locally in the body. Used for hinge, coneTwist pointToPoint constraints.\r\n pivot: { type: \"vec3\" },\r\n targetPivot: { type: \"vec3\" },\r\n\r\n // An axis that each body can rotate around, defined locally to that body. Used for hinge constraints.\r\n axis: { type: \"vec3\", default: { x: 0, y: 0, z: 1 } },\r\n targetAxis: { type: \"vec3\", default: { x: 0, y: 0, z: 1 } },\r\n\r\n // damping & stuffness - used for spring contraints only\r\n damping: { type: \"number\", default: 1 },\r\n stiffness: { type: \"number\", default: 100 },\r\n },\r\n\r\n init: function() {\r\n this.system = this.el.sceneEl.systems.physics;\r\n this.constraint = null;\r\n },\r\n\r\n remove: function() {\r\n if (!this.constraint) return;\r\n\r\n this.system.removeConstraint(this.constraint);\r\n this.constraint = null;\r\n },\r\n\r\n update: function() {\r\n const el = this.el,\r\n data = this.data;\r\n\r\n this.remove();\r\n\r\n if (!el.body || !data.target.body) {\r\n (el.body ? data.target : el).addEventListener(\"body-loaded\", this.update.bind(this, {}), { once: true });\r\n return;\r\n }\r\n\r\n this.constraint = this.createConstraint();\r\n this.system.addConstraint(this.constraint);\r\n },\r\n\r\n /**\r\n * @return {Ammo.btTypedConstraint}\r\n */\r\n createConstraint: function() {\r\n let constraint;\r\n const data = this.data,\r\n body = this.el.body,\r\n targetBody = data.target.body;\r\n\r\n const bodyTransform = body\r\n .getCenterOfMassTransform()\r\n .inverse()\r\n .op_mul(targetBody.getWorldTransform());\r\n const targetTransform = new Ammo.btTransform();\r\n targetTransform.setIdentity();\r\n\r\n switch (data.type) {\r\n case CONSTRAINT.LOCK: {\r\n constraint = new Ammo.btGeneric6DofConstraint(body, targetBody, bodyTransform, targetTransform, true);\r\n const zero = new Ammo.btVector3(0, 0, 0);\r\n //TODO: allow these to be configurable\r\n constraint.setLinearLowerLimit(zero);\r\n constraint.setLinearUpperLimit(zero);\r\n constraint.setAngularLowerLimit(zero);\r\n constraint.setAngularUpperLimit(zero);\r\n Ammo.destroy(zero);\r\n break;\r\n }\r\n //TODO: test and verify all other constraint types\r\n case CONSTRAINT.FIXED: {\r\n //btFixedConstraint does not seem to debug render\r\n bodyTransform.setRotation(body.getWorldTransform().getRotation());\r\n targetTransform.setRotation(targetBody.getWorldTransform().getRotation());\r\n constraint = new Ammo.btFixedConstraint(body, targetBody, bodyTransform, targetTransform);\r\n break;\r\n }\r\n case CONSTRAINT.SPRING: {\r\n constraint = new Ammo.btGeneric6DofSpringConstraint(body, targetBody, bodyTransform, targetTransform, true);\r\n\r\n // Very limited initial implementation of spring constraint.\r\n // See: https://github.com/n5ro/aframe-physics-system/issues/171\r\n for (var i in [0,1,2,3,4,5]) {\r\n constraint.enableSpring(1, true)\r\n constraint.setStiffness(1, this.data.stiffness)\r\n constraint.setDamping(1, this.data.damping)\r\n }\r\n const upper = new Ammo.btVector3(-1, -1, -1);\r\n const lower = new Ammo.btVector3(1, 1, 1);\r\n constraint.setLinearUpperLimit(upper);\r\n constraint.setLinearLowerLimit(lower)\r\n Ammo.destroy(upper);\r\n Ammo.destroy(lower);\r\n break;\r\n }\r\n case CONSTRAINT.SLIDER: {\r\n //TODO: support setting linear and angular limits\r\n constraint = new Ammo.btSliderConstraint(body, targetBody, bodyTransform, targetTransform, true);\r\n constraint.setLowerLinLimit(-1);\r\n constraint.setUpperLinLimit(1);\r\n // constraint.setLowerAngLimit();\r\n // constraint.setUpperAngLimit();\r\n break;\r\n }\r\n case CONSTRAINT.HINGE: {\r\n const pivot = new Ammo.btVector3(data.pivot.x, data.pivot.y, data.pivot.z);\r\n const targetPivot = new Ammo.btVector3(data.targetPivot.x, data.targetPivot.y, data.targetPivot.z);\r\n\r\n const axis = new Ammo.btVector3(data.axis.x, data.axis.y, data.axis.z);\r\n const targetAxis = new Ammo.btVector3(data.targetAxis.x, data.targetAxis.y, data.targetAxis.z);\r\n\r\n constraint = new Ammo.btHingeConstraint(body, targetBody, pivot, targetPivot, axis, targetAxis, true);\r\n\r\n Ammo.destroy(pivot);\r\n Ammo.destroy(targetPivot);\r\n Ammo.destroy(axis);\r\n Ammo.destroy(targetAxis);\r\n break;\r\n }\r\n case CONSTRAINT.CONE_TWIST: {\r\n const pivotTransform = new Ammo.btTransform();\r\n pivotTransform.setIdentity();\r\n pivotTransform.getOrigin().setValue(data.pivot.x, data.pivot.y, data.pivot.z);\r\n const targetPivotTransform = new Ammo.btTransform();\r\n targetPivotTransform.setIdentity();\r\n targetPivotTransform.getOrigin().setValue(data.targetPivot.x, data.targetPivot.y, data.targetPivot.z);\r\n constraint = new Ammo.btConeTwistConstraint(body, targetBody, pivotTransform, targetPivotTransform);\r\n Ammo.destroy(pivotTransform);\r\n Ammo.destroy(targetPivotTransform);\r\n break;\r\n }\r\n case CONSTRAINT.POINT_TO_POINT: {\r\n const pivot = new Ammo.btVector3(data.pivot.x, data.pivot.y, data.pivot.z);\r\n const targetPivot = new Ammo.btVector3(data.targetPivot.x, data.targetPivot.y, data.targetPivot.z);\r\n\r\n constraint = new Ammo.btPoint2PointConstraint(body, targetBody, pivot, targetPivot);\r\n\r\n Ammo.destroy(pivot);\r\n Ammo.destroy(targetPivot);\r\n break;\r\n }\r\n default:\r\n throw new Error(\"[constraint] Unexpected type: \" + data.type);\r\n }\r\n\r\n Ammo.destroy(bodyTransform);\r\n Ammo.destroy(targetTransform);\r\n\r\n return constraint;\r\n }\r\n});\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/components/ammo-constraint.js?"); - const { - type, - params, - offset, - orientation - } = shapeParameters; - let shape; +/***/ }), - if (type === exports.ShapeType.BOX) { - shape = createBox(params); - } else if (type === exports.ShapeType.CYLINDER) { - shape = createCylinder(params); - } else if (type === exports.ShapeType.SPHERE) { - shape = createSphere(params); - } else if (type === exports.ShapeType.HULL) { - shape = createConvexPolyhedron(params); - } else { - shape = createTrimesh(params); - } +/***/ "./src/components/body/ammo-body.js": +/*!******************************************!*\ + !*** ./src/components/body/ammo-body.js ***! + \******************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - return { - shape, - offset, - orientation - }; -}; -/****************************************************************************** - * Shape construction - */ +eval("/* global Ammo,THREE */\r\nconst AmmoDebugDrawer = __webpack_require__(/*! ammo-debug-drawer */ \"./node_modules/ammo-debug-drawer/AmmoDebugDrawer.js\");\r\nconst threeToAmmo = __webpack_require__(/*! three-to-ammo */ \"./node_modules/three-to-ammo/index.js\");\r\nconst CONSTANTS = __webpack_require__(/*! ../../constants */ \"./src/constants.js\"),\r\n ACTIVATION_STATE = CONSTANTS.ACTIVATION_STATE,\r\n COLLISION_FLAG = CONSTANTS.COLLISION_FLAG,\r\n SHAPE = CONSTANTS.SHAPE,\r\n TYPE = CONSTANTS.TYPE,\r\n FIT = CONSTANTS.FIT;\r\n\r\nconst ACTIVATION_STATES = [\r\n ACTIVATION_STATE.ACTIVE_TAG,\r\n ACTIVATION_STATE.ISLAND_SLEEPING,\r\n ACTIVATION_STATE.WANTS_DEACTIVATION,\r\n ACTIVATION_STATE.DISABLE_DEACTIVATION,\r\n ACTIVATION_STATE.DISABLE_SIMULATION\r\n];\r\n\r\nconst RIGID_BODY_FLAGS = {\r\n NONE: 0,\r\n DISABLE_WORLD_GRAVITY: 1\r\n};\r\n\r\nfunction almostEqualsVector3(epsilon, u, v) {\r\n return Math.abs(u.x - v.x) < epsilon && Math.abs(u.y - v.y) < epsilon && Math.abs(u.z - v.z) < epsilon;\r\n}\r\n\r\nfunction almostEqualsBtVector3(epsilon, u, v) {\r\n return Math.abs(u.x() - v.x()) < epsilon && Math.abs(u.y() - v.y()) < epsilon && Math.abs(u.z() - v.z()) < epsilon;\r\n}\r\n\r\nfunction almostEqualsQuaternion(epsilon, u, v) {\r\n return (\r\n (Math.abs(u.x - v.x) < epsilon &&\r\n Math.abs(u.y - v.y) < epsilon &&\r\n Math.abs(u.z - v.z) < epsilon &&\r\n Math.abs(u.w - v.w) < epsilon) ||\r\n (Math.abs(u.x + v.x) < epsilon &&\r\n Math.abs(u.y + v.y) < epsilon &&\r\n Math.abs(u.z + v.z) < epsilon &&\r\n Math.abs(u.w + v.w) < epsilon)\r\n );\r\n}\r\n\r\nlet AmmoBody = {\r\n schema: {\r\n loadedEvent: { default: \"\" },\r\n mass: { default: 1 },\r\n gravity: { type: \"vec3\", default: { x: 0, y: -9.8, z: 0 } },\r\n linearDamping: { default: 0.01 },\r\n angularDamping: { default: 0.01 },\r\n linearSleepingThreshold: { default: 1.6 },\r\n angularSleepingThreshold: { default: 2.5 },\r\n angularFactor: { type: \"vec3\", default: { x: 1, y: 1, z: 1 } },\r\n activationState: {\r\n default: ACTIVATION_STATE.ACTIVE_TAG,\r\n oneOf: ACTIVATION_STATES\r\n },\r\n type: { default: \"dynamic\", oneOf: [TYPE.STATIC, TYPE.DYNAMIC, TYPE.KINEMATIC] },\r\n emitCollisionEvents: { default: false },\r\n disableCollision: { default: false },\r\n collisionFilterGroup: { default: 1 }, //32-bit mask,\r\n collisionFilterMask: { default: 1 }, //32-bit mask\r\n scaleAutoUpdate: { default: true },\r\n restitution: {default: 0} // does not support updates\r\n },\r\n\r\n /**\r\n * Initializes a body component, assigning it to the physics system and binding listeners for\r\n * parsing the elements geometry.\r\n */\r\n init: function() {\r\n this.system = this.el.sceneEl.systems.physics;\r\n this.shapeComponents = [];\r\n\r\n if (this.data.loadedEvent === \"\") {\r\n this.loadedEventFired = true;\r\n } else {\r\n this.el.addEventListener(\r\n this.data.loadedEvent,\r\n () => {\r\n this.loadedEventFired = true;\r\n },\r\n { once: true }\r\n );\r\n }\r\n\r\n if (this.system.initialized && this.loadedEventFired) {\r\n this.initBody();\r\n }\r\n },\r\n\r\n /**\r\n * Parses an element's geometry and component metadata to create an Ammo body instance for the\r\n * component.\r\n */\r\n initBody: (function() {\r\n const pos = new THREE.Vector3();\r\n const quat = new THREE.Quaternion();\r\n const boundingBox = new THREE.Box3();\r\n\r\n return function() {\r\n const el = this.el,\r\n data = this.data;\r\n const clamp = (num, min, max) => Math.min(Math.max(num, min), max)\r\n\r\n this.localScaling = new Ammo.btVector3();\r\n\r\n const obj = this.el.object3D;\r\n obj.getWorldPosition(pos);\r\n obj.getWorldQuaternion(quat);\r\n\r\n this.prevScale = new THREE.Vector3(1, 1, 1);\r\n this.prevNumChildShapes = 0;\r\n\r\n this.msTransform = new Ammo.btTransform();\r\n this.msTransform.setIdentity();\r\n this.rotation = new Ammo.btQuaternion(quat.x, quat.y, quat.z, quat.w);\r\n\r\n this.msTransform.getOrigin().setValue(pos.x, pos.y, pos.z);\r\n this.msTransform.setRotation(this.rotation);\r\n\r\n this.motionState = new Ammo.btDefaultMotionState(this.msTransform);\r\n\r\n this.localInertia = new Ammo.btVector3(0, 0, 0);\r\n\r\n this.compoundShape = new Ammo.btCompoundShape(true);\r\n\r\n this.rbInfo = new Ammo.btRigidBodyConstructionInfo(\r\n data.mass,\r\n this.motionState,\r\n this.compoundShape,\r\n this.localInertia\r\n );\r\n this.rbInfo.m_restitution = clamp(this.data.restitution, 0, 1);\r\n this.body = new Ammo.btRigidBody(this.rbInfo);\r\n this.body.setActivationState(ACTIVATION_STATES.indexOf(data.activationState) + 1);\r\n this.body.setSleepingThresholds(data.linearSleepingThreshold, data.angularSleepingThreshold);\r\n\r\n this.body.setDamping(data.linearDamping, data.angularDamping);\r\n\r\n const angularFactor = new Ammo.btVector3(data.angularFactor.x, data.angularFactor.y, data.angularFactor.z);\r\n this.body.setAngularFactor(angularFactor);\r\n Ammo.destroy(angularFactor);\r\n\r\n const gravity = new Ammo.btVector3(data.gravity.x, data.gravity.y, data.gravity.z);\r\n if (!almostEqualsBtVector3(0.001, gravity, this.system.driver.physicsWorld.getGravity())) {\r\n this.body.setGravity(gravity);\r\n this.body.setFlags(RIGID_BODY_FLAGS.DISABLE_WORLD_GRAVITY);\r\n }\r\n Ammo.destroy(gravity);\r\n\r\n this.updateCollisionFlags();\r\n\r\n this.el.body = this.body;\r\n this.body.el = el;\r\n\r\n this.isLoaded = true;\r\n\r\n this.el.emit(\"body-loaded\", { body: this.el.body });\r\n\r\n this._addToSystem();\r\n };\r\n })(),\r\n\r\n tick: function() {\r\n if (this.system.initialized && !this.isLoaded && this.loadedEventFired) {\r\n this.initBody();\r\n }\r\n },\r\n\r\n _updateShapes: (function() {\r\n const needsPolyhedralInitialization = [SHAPE.HULL, SHAPE.HACD, SHAPE.VHACD];\r\n return function() {\r\n let updated = false;\r\n\r\n const obj = this.el.object3D;\r\n if (this.data.scaleAutoUpdate && this.prevScale && !almostEqualsVector3(0.001, obj.scale, this.prevScale)) {\r\n this.prevScale.copy(obj.scale);\r\n updated = true;\r\n\r\n this.localScaling.setValue(this.prevScale.x, this.prevScale.y, this.prevScale.z);\r\n this.compoundShape.setLocalScaling(this.localScaling);\r\n }\r\n\r\n if (this.shapeComponentsChanged) {\r\n this.shapeComponentsChanged = false;\r\n updated = true;\r\n for (let i = 0; i < this.shapeComponents.length; i++) {\r\n const shapeComponent = this.shapeComponents[i];\r\n if (shapeComponent.getShapes().length === 0) {\r\n this._createCollisionShape(shapeComponent);\r\n }\r\n const collisionShapes = shapeComponent.getShapes();\r\n for (let j = 0; j < collisionShapes.length; j++) {\r\n const collisionShape = collisionShapes[j];\r\n if (!collisionShape.added) {\r\n this.compoundShape.addChildShape(collisionShape.localTransform, collisionShape);\r\n collisionShape.added = true;\r\n }\r\n }\r\n }\r\n\r\n if (this.data.type === TYPE.DYNAMIC) {\r\n this.updateMass();\r\n }\r\n\r\n this.system.driver.updateBody(this.body);\r\n }\r\n\r\n //call initializePolyhedralFeatures for hull shapes if debug is turned on and/or scale changes\r\n if (this.system.debug && (updated || !this.polyHedralFeaturesInitialized)) {\r\n for (let i = 0; i < this.shapeComponents.length; i++) {\r\n const collisionShapes = this.shapeComponents[i].getShapes();\r\n for (let j = 0; j < collisionShapes.length; j++) {\r\n const collisionShape = collisionShapes[j];\r\n if (needsPolyhedralInitialization.indexOf(collisionShape.type) !== -1) {\r\n collisionShape.initializePolyhedralFeatures(0);\r\n }\r\n }\r\n }\r\n this.polyHedralFeaturesInitialized = true;\r\n }\r\n };\r\n })(),\r\n\r\n _createCollisionShape: function(shapeComponent) {\r\n const data = shapeComponent.data;\r\n const collisionShapes = threeToAmmo.createCollisionShapes(shapeComponent.getMesh(), data);\r\n shapeComponent.addShapes(collisionShapes);\r\n return;\r\n },\r\n\r\n /**\r\n * Registers the component with the physics system.\r\n */\r\n play: function() {\r\n if (this.isLoaded) {\r\n this._addToSystem();\r\n }\r\n },\r\n\r\n _addToSystem: function() {\r\n if (!this.addedToSystem) {\r\n this.system.addBody(this.body, this.data.collisionFilterGroup, this.data.collisionFilterMask);\r\n\r\n if (this.data.emitCollisionEvents) {\r\n this.system.driver.addEventListener(this.body);\r\n }\r\n\r\n this.system.addComponent(this);\r\n this.addedToSystem = true;\r\n }\r\n },\r\n\r\n /**\r\n * Unregisters the component with the physics system.\r\n */\r\n pause: function() {\r\n if (this.addedToSystem) {\r\n this.system.removeComponent(this);\r\n this.system.removeBody(this.body);\r\n this.addedToSystem = false;\r\n }\r\n },\r\n\r\n /**\r\n * Updates the rigid body instance, where possible.\r\n */\r\n update: function(prevData) {\r\n if (this.isLoaded) {\r\n if (!this.hasUpdated) {\r\n //skip the first update\r\n this.hasUpdated = true;\r\n return;\r\n }\r\n\r\n const data = this.data;\r\n\r\n if (prevData.type !== data.type || prevData.disableCollision !== data.disableCollision) {\r\n this.updateCollisionFlags();\r\n }\r\n\r\n if (prevData.activationState !== data.activationState) {\r\n this.body.forceActivationState(ACTIVATION_STATES.indexOf(data.activationState) + 1);\r\n if (data.activationState === ACTIVATION_STATE.ACTIVE_TAG) {\r\n this.body.activate(true);\r\n }\r\n }\r\n\r\n if (\r\n prevData.collisionFilterGroup !== data.collisionFilterGroup ||\r\n prevData.collisionFilterMask !== data.collisionFilterMask\r\n ) {\r\n const broadphaseProxy = this.body.getBroadphaseProxy();\r\n broadphaseProxy.set_m_collisionFilterGroup(data.collisionFilterGroup);\r\n broadphaseProxy.set_m_collisionFilterMask(data.collisionFilterMask);\r\n this.system.driver.broadphase\r\n .getOverlappingPairCache()\r\n .removeOverlappingPairsContainingProxy(broadphaseProxy, this.system.driver.dispatcher);\r\n }\r\n\r\n if (prevData.linearDamping != data.linearDamping || prevData.angularDamping != data.angularDamping) {\r\n this.body.setDamping(data.linearDamping, data.angularDamping);\r\n }\r\n\r\n if (!almostEqualsVector3(0.001, prevData.gravity, data.gravity)) {\r\n const gravity = new Ammo.btVector3(data.gravity.x, data.gravity.y, data.gravity.z);\r\n if (!almostEqualsBtVector3(0.001, gravity, this.system.driver.physicsWorld.getGravity())) {\r\n this.body.setFlags(RIGID_BODY_FLAGS.DISABLE_WORLD_GRAVITY);\r\n } else {\r\n this.body.setFlags(RIGID_BODY_FLAGS.NONE);\r\n }\r\n this.body.setGravity(gravity);\r\n Ammo.destroy(gravity);\r\n }\r\n\r\n if (\r\n prevData.linearSleepingThreshold != data.linearSleepingThreshold ||\r\n prevData.angularSleepingThreshold != data.angularSleepingThreshold\r\n ) {\r\n this.body.setSleepingThresholds(data.linearSleepingThreshold, data.angularSleepingThreshold);\r\n }\r\n\r\n if (!almostEqualsVector3(0.001, prevData.angularFactor, data.angularFactor)) {\r\n const angularFactor = new Ammo.btVector3(data.angularFactor.x, data.angularFactor.y, data.angularFactor.z);\r\n this.body.setAngularFactor(angularFactor);\r\n Ammo.destroy(angularFactor);\r\n }\r\n\r\n if (prevData.restitution != data.restitution ) {\r\n console.warn(\"ammo-body restitution cannot be updated from its initial value.\")\r\n }\r\n\r\n //TODO: support dynamic update for other properties\r\n }\r\n },\r\n\r\n /**\r\n * Removes the component and all physics and scene side effects.\r\n */\r\n remove: function() {\r\n if (this.triMesh) Ammo.destroy(this.triMesh);\r\n if (this.localScaling) Ammo.destroy(this.localScaling);\r\n if (this.compoundShape) Ammo.destroy(this.compoundShape);\r\n if (this.body) {\r\n Ammo.destroy(this.body);\r\n delete this.body;\r\n }\r\n Ammo.destroy(this.rbInfo);\r\n Ammo.destroy(this.msTransform);\r\n Ammo.destroy(this.motionState);\r\n Ammo.destroy(this.localInertia);\r\n Ammo.destroy(this.rotation);\r\n },\r\n\r\n beforeStep: function() {\r\n this._updateShapes();\r\n // Note that since static objects don't move,\r\n // we don't sync them to physics on a routine basis.\r\n if (this.data.type === TYPE.KINEMATIC) {\r\n this.syncToPhysics();\r\n }\r\n },\r\n\r\n step: function() {\r\n if (this.data.type === TYPE.DYNAMIC) {\r\n this.syncFromPhysics();\r\n }\r\n },\r\n\r\n /**\r\n * Updates the rigid body's position, velocity, and rotation, based on the scene.\r\n */\r\n syncToPhysics: (function() {\r\n const q = new THREE.Quaternion();\r\n const v = new THREE.Vector3();\r\n const q2 = new THREE.Vector3();\r\n const v2 = new THREE.Vector3();\r\n return function() {\r\n const el = this.el,\r\n parentEl = el.parentEl,\r\n body = this.body;\r\n\r\n if (!body) return;\r\n\r\n this.motionState.getWorldTransform(this.msTransform);\r\n\r\n if (parentEl.isScene) {\r\n v.copy(el.object3D.position);\r\n q.copy(el.object3D.quaternion);\r\n } else {\r\n el.object3D.getWorldPosition(v);\r\n el.object3D.getWorldQuaternion(q);\r\n }\r\n\r\n const position = this.msTransform.getOrigin();\r\n v2.set(position.x(), position.y(), position.z());\r\n\r\n const quaternion = this.msTransform.getRotation();\r\n q2.set(quaternion.x(), quaternion.y(), quaternion.z(), quaternion.w());\r\n\r\n if (!almostEqualsVector3(0.001, v, v2) || !almostEqualsQuaternion(0.001, q, q2)) {\r\n if (!this.body.isActive()) {\r\n this.body.activate(true);\r\n }\r\n this.msTransform.getOrigin().setValue(v.x, v.y, v.z);\r\n this.rotation.setValue(q.x, q.y, q.z, q.w);\r\n this.msTransform.setRotation(this.rotation);\r\n this.motionState.setWorldTransform(this.msTransform);\r\n\r\n if (this.data.type === TYPE.STATIC) {\r\n this.body.setCenterOfMassTransform(this.msTransform);\r\n }\r\n }\r\n };\r\n })(),\r\n\r\n /**\r\n * Updates the scene object's position and rotation, based on the physics simulation.\r\n */\r\n syncFromPhysics: (function() {\r\n const v = new THREE.Vector3(),\r\n q1 = new THREE.Quaternion(),\r\n q2 = new THREE.Quaternion();\r\n return function() {\r\n this.motionState.getWorldTransform(this.msTransform);\r\n const position = this.msTransform.getOrigin();\r\n const quaternion = this.msTransform.getRotation();\r\n\r\n const el = this.el,\r\n body = this.body;\r\n\r\n // For the parent, prefer to use the THHREE.js scene graph parent (if it can be determined)\r\n // and only use the HTML scene graph parent as a fallback.\r\n // Usually these are the same, but there are various cases where it's useful to modify the THREE.js\r\n // scene graph so that it deviates from the HTML.\r\n // In these cases the THREE.js scene graph should be considered the definitive reference in terms\r\n // of object positioning etc.\r\n // For specific examples, and more discussion, see:\r\n // https://github.com/c-frame/aframe-physics-system/pull/1#issuecomment-1264686433\r\n const parentEl = el.object3D.parent.el ? el.object3D.parent.el : el.parentEl;\r\n\r\n if (!body) return;\r\n if (!parentEl) return;\r\n\r\n if (parentEl.isScene) {\r\n el.object3D.position.set(position.x(), position.y(), position.z());\r\n el.object3D.quaternion.set(quaternion.x(), quaternion.y(), quaternion.z(), quaternion.w());\r\n } else {\r\n q1.set(quaternion.x(), quaternion.y(), quaternion.z(), quaternion.w());\r\n parentEl.object3D.getWorldQuaternion(q2);\r\n q1.multiply(q2.invert());\r\n el.object3D.quaternion.copy(q1);\r\n\r\n v.set(position.x(), position.y(), position.z());\r\n parentEl.object3D.worldToLocal(v);\r\n el.object3D.position.copy(v);\r\n }\r\n };\r\n })(),\r\n\r\n addShapeComponent: function(shapeComponent) {\r\n if (shapeComponent.data.type === SHAPE.MESH && this.data.type !== TYPE.STATIC) {\r\n console.warn(\"non-static mesh colliders not supported\");\r\n return;\r\n }\r\n\r\n this.shapeComponents.push(shapeComponent);\r\n this.shapeComponentsChanged = true;\r\n },\r\n\r\n removeShapeComponent: function(shapeComponent) {\r\n const index = this.shapeComponents.indexOf(shapeComponent);\r\n if (this.compoundShape && index !== -1 && this.body) {\r\n const shapes = shapeComponent.getShapes();\r\n for (var i = 0; i < shapes.length; i++) {\r\n this.compoundShape.removeChildShape(shapes[i]);\r\n }\r\n this.shapeComponentsChanged = true;\r\n this.shapeComponents.splice(index, 1);\r\n }\r\n },\r\n\r\n updateMass: function() {\r\n const shape = this.body.getCollisionShape();\r\n const mass = this.data.type === TYPE.DYNAMIC ? this.data.mass : 0;\r\n shape.calculateLocalInertia(mass, this.localInertia);\r\n this.body.setMassProps(mass, this.localInertia);\r\n this.body.updateInertiaTensor();\r\n },\r\n\r\n updateCollisionFlags: function() {\r\n let flags = this.data.disableCollision ? 4 : 0;\r\n switch (this.data.type) {\r\n case TYPE.STATIC:\r\n flags |= COLLISION_FLAG.STATIC_OBJECT;\r\n break;\r\n case TYPE.KINEMATIC:\r\n flags |= COLLISION_FLAG.KINEMATIC_OBJECT;\r\n break;\r\n default:\r\n this.body.applyGravity();\r\n break;\r\n }\r\n this.body.setCollisionFlags(flags);\r\n\r\n this.updateMass();\r\n\r\n // TODO: enable CCD if dynamic?\r\n // this.body.setCcdMotionThreshold(0.001);\r\n // this.body.setCcdSweptSphereRadius(0.001);\r\n\r\n this.system.driver.updateBody(this.body);\r\n },\r\n\r\n getVelocity: function() {\r\n return this.body.getLinearVelocity();\r\n }\r\n};\r\n\r\nmodule.exports.definition = AmmoBody;\r\nmodule.exports.Component = AFRAME.registerComponent(\"ammo-body\", AmmoBody);\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/components/body/ammo-body.js?"); -function createBox(params) { - const { - x, - y, - z - } = params; - const shape = new cannonEs.Box(new cannonEs.Vec3(x, y, z)); - return shape; -} +/***/ }), -function createCylinder(params) { - const { - radiusTop, - radiusBottom, - height, - segments - } = params; - const shape = new cannonEs.Cylinder(radiusTop, radiusBottom, height, segments); // Include metadata for serialization. - // TODO(cleanup): Is this still necessary? +/***/ "./src/components/body/body.js": +/*!*************************************!*\ + !*** ./src/components/body/body.js ***! + \*************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - shape.radiusTop = radiusBottom; - shape.radiusBottom = radiusBottom; - shape.height = height; - shape.numSegments = segments; - return shape; -} +eval("var CANNON = __webpack_require__(/*! cannon-es */ \"./node_modules/cannon-es/dist/cannon-es.js\");\r\nconst { threeToCannon, ShapeType } = __webpack_require__(/*! three-to-cannon */ \"./node_modules/three-to-cannon/dist/three-to-cannon.cjs\");\r\nconst identityQuaternion = new THREE.Quaternion()\r\n\r\nfunction mesh2shape (object, options) {\r\n\r\n const result = threeToCannon(object, options);\r\n return result;\r\n}\r\n\r\n__webpack_require__(/*! ../../../lib/CANNON-shape2mesh */ \"./lib/CANNON-shape2mesh.js\");\r\n\r\nvar Body = {\r\n dependencies: ['velocity'],\r\n\r\n schema: {\r\n mass: {default: 5, if: {type: 'dynamic'}},\r\n linearDamping: { default: 0.01, if: {type: 'dynamic'}},\r\n angularDamping: { default: 0.01, if: {type: 'dynamic'}},\r\n shape: {default: 'auto', oneOf: ['auto', 'box', 'cylinder', 'sphere', 'hull', 'mesh', 'none']},\r\n cylinderAxis: {default: 'y', oneOf: ['x', 'y', 'z']},\r\n sphereRadius: {default: NaN},\r\n type: {default: 'dynamic', oneOf: ['static', 'dynamic']}\r\n },\r\n\r\n /**\r\n * Initializes a body component, assigning it to the physics system and binding listeners for\r\n * parsing the elements geometry.\r\n */\r\n init: function () {\r\n this.system = this.el.sceneEl.systems.physics;\r\n\r\n if (this.el.sceneEl.hasLoaded) {\r\n this.initBody();\r\n } else {\r\n this.el.sceneEl.addEventListener('loaded', this.initBody.bind(this));\r\n }\r\n },\r\n\r\n /**\r\n * Parses an element's geometry and component metadata to create a CANNON.Body instance for the\r\n * component.\r\n */\r\n initBody: function () {\r\n var el = this.el,\r\n data = this.data;\r\n\r\n var obj = this.el.object3D;\r\n var pos = obj.position;\r\n var quat = obj.quaternion;\r\n\r\n this.body = new CANNON.Body({\r\n mass: data.type === 'static' ? 0 : data.mass || 0,\r\n material: this.system.getMaterial('defaultMaterial'),\r\n position: new CANNON.Vec3(pos.x, pos.y, pos.z),\r\n quaternion: new CANNON.Quaternion(quat.x, quat.y, quat.z, quat.w),\r\n linearDamping: data.linearDamping,\r\n angularDamping: data.angularDamping,\r\n type: data.type === 'dynamic' ? CANNON.Body.DYNAMIC : CANNON.Body.STATIC,\r\n });\r\n\r\n // Matrix World must be updated at root level, if scale is to be applied – updateMatrixWorld()\r\n // only checks an object's parent, not the rest of the ancestors. Hence, a wrapping entity with\r\n // scale=\"0.5 0.5 0.5\" will be ignored.\r\n // Reference: https://github.com/mrdoob/three.js/blob/master/src/core/Object3D.js#L511-L541\r\n // Potential fix: https://github.com/mrdoob/three.js/pull/7019\r\n this.el.object3D.updateMatrixWorld(true);\r\n\r\n if(data.shape !== 'none') {\r\n var options = data.shape === 'auto' ? undefined : AFRAME.utils.extend({}, this.data, {\r\n type: ShapeType[data.shape.toUpperCase()]\r\n });\r\n\r\n var { shape, offset, orientation } = mesh2shape(this.el.object3D, options);\r\n\r\n if (!shape) {\r\n el.addEventListener('object3dset', this.initBody.bind(this));\r\n return;\r\n }\r\n this.body.addShape(shape, offset, orientation);\r\n\r\n // Show wireframe\r\n if (this.system.debug) {\r\n this.shouldUpdateWireframe = true;\r\n }\r\n\r\n this.isLoaded = true;\r\n }\r\n\r\n this.el.body = this.body;\r\n this.body.el = el;\r\n\r\n // If component wasn't initialized when play() was called, finish up.\r\n if (this.isPlaying) {\r\n this._play();\r\n }\r\n\r\n if (this.isLoaded) {\r\n this.el.emit('body-loaded', {body: this.el.body});\r\n }\r\n },\r\n\r\n addShape: function(shape, offset, orientation) {\r\n if (this.data.shape !== 'none') {\r\n console.warn('shape can only be added if shape property is none');\r\n return;\r\n }\r\n\r\n if (!shape) {\r\n console.warn('shape cannot be null');\r\n return;\r\n }\r\n\r\n if (!this.body) {\r\n console.warn('shape cannot be added before body is loaded');\r\n return;\r\n }\r\n this.body.addShape(shape, offset, orientation);\r\n\r\n if (this.system.debug) {\r\n this.shouldUpdateWireframe = true;\r\n }\r\n\r\n this.shouldUpdateBody = true;\r\n },\r\n\r\n tick: function () {\r\n if (this.shouldUpdateBody) {\r\n this.isLoaded = true;\r\n\r\n this._play();\r\n\r\n this.el.emit('body-loaded', {body: this.el.body});\r\n this.shouldUpdateBody = false;\r\n }\r\n\r\n if (this.shouldUpdateWireframe) {\r\n this.createWireframe(this.body);\r\n this.shouldUpdateWireframe = false;\r\n }\r\n },\r\n\r\n /**\r\n * Registers the component with the physics system, if ready.\r\n */\r\n play: function () {\r\n if (this.isLoaded) this._play();\r\n },\r\n\r\n /**\r\n * Internal helper to register component with physics system.\r\n */\r\n _play: function () {\r\n this.syncToPhysics();\r\n this.system.addComponent(this);\r\n this.system.addBody(this.body);\r\n if (this.wireframe) this.el.sceneEl.object3D.add(this.wireframe);\r\n },\r\n\r\n /**\r\n * Unregisters the component with the physics system.\r\n */\r\n pause: function () {\r\n if (this.isLoaded) this._pause();\r\n },\r\n\r\n _pause: function () {\r\n this.system.removeComponent(this);\r\n if (this.body) this.system.removeBody(this.body);\r\n if (this.wireframe) this.el.sceneEl.object3D.remove(this.wireframe);\r\n },\r\n\r\n /**\r\n * Updates the CANNON.Body instance, where possible.\r\n */\r\n update: function (prevData) {\r\n if (!this.body) return;\r\n\r\n var data = this.data;\r\n\r\n if (prevData.type != undefined && data.type != prevData.type) {\r\n this.body.type = data.type === 'dynamic' ? CANNON.Body.DYNAMIC : CANNON.Body.STATIC;\r\n }\r\n\r\n this.body.mass = data.mass || 0;\r\n if (data.type === 'dynamic') {\r\n this.body.linearDamping = data.linearDamping;\r\n this.body.angularDamping = data.angularDamping;\r\n }\r\n if (data.mass !== prevData.mass) {\r\n this.body.updateMassProperties();\r\n }\r\n if (this.body.updateProperties) this.body.updateProperties();\r\n },\r\n\r\n /**\r\n * Removes the component and all physics and scene side effects.\r\n */\r\n remove: function () {\r\n if (this.body) {\r\n delete this.body.el;\r\n delete this.body;\r\n }\r\n delete this.el.body;\r\n delete this.wireframe;\r\n },\r\n\r\n beforeStep: function () {\r\n if (this.body.mass === 0) {\r\n this.syncToPhysics();\r\n }\r\n },\r\n\r\n step: function () {\r\n if (this.body.mass !== 0) {\r\n this.syncFromPhysics();\r\n }\r\n },\r\n\r\n /**\r\n * Creates a wireframe for the body, for debugging.\r\n * TODO(donmccurdy) – Refactor this into a standalone utility or component.\r\n * @param {CANNON.Body} body\r\n * @param {CANNON.Shape} shape\r\n */\r\n createWireframe: function (body) {\r\n if (this.wireframe) {\r\n this.el.sceneEl.object3D.remove(this.wireframe);\r\n delete this.wireframe;\r\n }\r\n this.wireframe = new THREE.Object3D();\r\n this.el.sceneEl.object3D.add(this.wireframe);\r\n\r\n var offset, mesh;\r\n var orientation = new THREE.Quaternion();\r\n for (var i = 0; i < this.body.shapes.length; i++)\r\n {\r\n offset = this.body.shapeOffsets[i],\r\n orientation.copy(this.body.shapeOrientations[i]),\r\n mesh = CANNON.shape2mesh(this.body).children[i];\r\n\r\n var wireframe = new THREE.LineSegments(\r\n new THREE.EdgesGeometry(mesh.geometry),\r\n new THREE.LineBasicMaterial({color: 0xff0000})\r\n );\r\n\r\n if (offset) {\r\n wireframe.position.copy(offset);\r\n }\r\n\r\n if (orientation) {\r\n wireframe.quaternion.copy(orientation);\r\n }\r\n\r\n this.wireframe.add(wireframe);\r\n }\r\n\r\n this.syncWireframe();\r\n },\r\n\r\n /**\r\n * Updates the debugging wireframe's position and rotation.\r\n */\r\n syncWireframe: function () {\r\n var offset,\r\n wireframe = this.wireframe;\r\n\r\n if (!this.wireframe) return;\r\n\r\n // Apply rotation. If the shape required custom orientation, also apply\r\n // that on the wireframe.\r\n wireframe.quaternion.copy(this.body.quaternion);\r\n if (wireframe.orientation) {\r\n wireframe.quaternion.multiply(wireframe.orientation);\r\n }\r\n\r\n // Apply position. If the shape required custom offset, also apply that on\r\n // the wireframe.\r\n wireframe.position.copy(this.body.position);\r\n if (wireframe.offset) {\r\n offset = wireframe.offset.clone().applyQuaternion(wireframe.quaternion);\r\n wireframe.position.add(offset);\r\n }\r\n\r\n wireframe.updateMatrix();\r\n },\r\n\r\n /**\r\n * Updates the CANNON.Body instance's position, velocity, and rotation, based on the scene.\r\n */\r\n syncToPhysics: (function () {\r\n var q = new THREE.Quaternion(),\r\n v = new THREE.Vector3();\r\n return function () {\r\n var el = this.el,\r\n parentEl = el.parentEl,\r\n body = this.body;\r\n\r\n if (!body) return;\r\n\r\n if (el.components.velocity) body.velocity.copy(el.getAttribute('velocity'));\r\n\r\n if (parentEl.isScene) {\r\n body.quaternion.copy(el.object3D.quaternion);\r\n body.position.copy(el.object3D.position);\r\n } else {\r\n el.object3D.getWorldQuaternion(q);\r\n body.quaternion.copy(q);\r\n el.object3D.getWorldPosition(v);\r\n body.position.copy(v);\r\n }\r\n\r\n if (this.body.updateProperties) this.body.updateProperties();\r\n if (this.wireframe) this.syncWireframe();\r\n };\r\n }()),\r\n\r\n /**\r\n * Updates the scene object's position and rotation, based on the physics simulation.\r\n */\r\n syncFromPhysics: (function () {\r\n var v = new THREE.Vector3(),\r\n q1 = new THREE.Quaternion(),\r\n q2 = new THREE.Quaternion();\r\n return function () {\r\n var el = this.el,\r\n parentEl = el.parentEl,\r\n body = this.body;\r\n\r\n if (!body) return;\r\n if (!parentEl) return;\r\n\r\n if (parentEl.isScene) {\r\n el.object3D.quaternion.copy(body.quaternion);\r\n el.object3D.position.copy(body.position);\r\n } else {\r\n q1.copy(body.quaternion);\r\n parentEl.object3D.getWorldQuaternion(q2);\r\n q1.premultiply(q2.invert());\r\n el.object3D.quaternion.copy(q1);\r\n\r\n v.copy(body.position);\r\n parentEl.object3D.worldToLocal(v);\r\n el.object3D.position.copy(v);\r\n }\r\n\r\n if (this.wireframe) this.syncWireframe();\r\n };\r\n }())\r\n};\r\n\r\nmodule.exports.definition = Body;\r\nmodule.exports.Component = AFRAME.registerComponent('body', Body);\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/components/body/body.js?"); -function createSphere(params) { - const shape = new cannonEs.Sphere(params.radius); - return shape; -} +/***/ }), -function createConvexPolyhedron(params) { - const { - faces, - vertices: verticesArray - } = params; - const vertices = []; +/***/ "./src/components/body/dynamic-body.js": +/*!*********************************************!*\ + !*** ./src/components/body/dynamic-body.js ***! + \*********************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - for (let i = 0; i < verticesArray.length; i += 3) { - vertices.push(new cannonEs.Vec3(verticesArray[i], verticesArray[i + 1], verticesArray[i + 2])); - } +eval("var Body = __webpack_require__(/*! ./body */ \"./src/components/body/body.js\");\r\n\r\n/**\r\n * Dynamic body.\r\n *\r\n * Moves according to physics simulation, and may collide with other objects.\r\n */\r\nvar DynamicBody = AFRAME.utils.extend({}, Body.definition);\r\n\r\nmodule.exports = AFRAME.registerComponent('dynamic-body', DynamicBody);\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/components/body/dynamic-body.js?"); - const shape = new cannonEs.ConvexPolyhedron({ - faces, - vertices - }); - return shape; -} +/***/ }), -function createTrimesh(params) { - const { - vertices, - indices - } = params; - const shape = new cannonEs.Trimesh(vertices, indices); - return shape; -} -/****************************************************************************** - * Shape parameters - */ +/***/ "./src/components/body/static-body.js": +/*!********************************************!*\ + !*** ./src/components/body/static-body.js ***! + \********************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +eval("var Body = __webpack_require__(/*! ./body */ \"./src/components/body/body.js\");\r\n\r\n/**\r\n * Static body.\r\n *\r\n * Solid body with a fixed position. Unaffected by gravity and collisions, but\r\n * other objects may collide with it.\r\n */\r\nvar StaticBody = AFRAME.utils.extend({}, Body.definition);\r\n\r\nStaticBody.schema = AFRAME.utils.extend({}, Body.definition.schema, {\r\n type: {default: 'static', oneOf: ['static', 'dynamic']},\r\n mass: {default: 0}\r\n});\r\n\r\nmodule.exports = AFRAME.registerComponent('static-body', StaticBody);\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/components/body/static-body.js?"); -function getBoxParameters(geometry) { - const vertices = getVertices(geometry); - if (!vertices.length) return null; - geometry.computeBoundingBox(); - const box = geometry.boundingBox; - return { - type: exports.ShapeType.BOX, - params: { - x: (box.max.x - box.min.x) / 2, - y: (box.max.y - box.min.y) / 2, - z: (box.max.z - box.min.z) / 2 - } - }; -} -/** Bounding box needs to be computed with the entire subtree, not just geometry. */ +/***/ }), +/***/ "./src/components/constraint.js": +/*!**************************************!*\ + !*** ./src/components/constraint.js ***! + \**************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { -function getBoundingBoxParameters(object) { - const clone = object.clone(); - clone.quaternion.set(0, 0, 0, 1); - clone.updateMatrixWorld(); - const box = new three.Box3().setFromObject(clone); - if (!isFinite(box.min.lengthSq())) return null; - const localPosition = box.translate(clone.position.negate()).getCenter(new three.Vector3()); - return { - type: exports.ShapeType.BOX, - params: { - x: (box.max.x - box.min.x) / 2, - y: (box.max.y - box.min.y) / 2, - z: (box.max.z - box.min.z) / 2 - }, - offset: localPosition.lengthSq() ? new cannonEs.Vec3(localPosition.x, localPosition.y, localPosition.z) : undefined - }; -} -/** Computes 3D convex hull as a CANNON.ConvexPolyhedron. */ +eval("var CANNON = __webpack_require__(/*! cannon-es */ \"./node_modules/cannon-es/dist/cannon-es.js\");\r\n\r\nmodule.exports = AFRAME.registerComponent(\"constraint\", {\r\n multiple: true,\r\n\r\n schema: {\r\n // Type of constraint.\r\n type: { default: \"lock\", oneOf: [\"coneTwist\", \"distance\", \"hinge\", \"lock\", \"pointToPoint\"] },\r\n\r\n // Target (other) body for the constraint.\r\n target: { type: \"selector\" },\r\n\r\n // Maximum force that should be applied to constraint the bodies.\r\n maxForce: { default: 1e6, min: 0 },\r\n\r\n // If true, bodies can collide when they are connected.\r\n collideConnected: { default: true },\r\n\r\n // Wake up bodies when connected.\r\n wakeUpBodies: { default: true },\r\n\r\n // The distance to be kept between the bodies. If 0, will be set to current distance.\r\n distance: { default: 0, min: 0 },\r\n\r\n // Offset of the hinge or point-to-point constraint, defined locally in the body.\r\n pivot: { type: \"vec3\" },\r\n targetPivot: { type: \"vec3\" },\r\n\r\n // An axis that each body can rotate around, defined locally to that body.\r\n axis: { type: \"vec3\", default: { x: 0, y: 0, z: 1 } },\r\n targetAxis: { type: \"vec3\", default: { x: 0, y: 0, z: 1 } }\r\n },\r\n\r\n init: function() {\r\n this.system = this.el.sceneEl.systems.physics;\r\n this.constraint = /* {CANNON.Constraint} */ null;\r\n },\r\n\r\n remove: function() {\r\n if (!this.constraint) return;\r\n\r\n this.system.removeConstraint(this.constraint);\r\n this.constraint = null;\r\n },\r\n\r\n update: function() {\r\n var el = this.el,\r\n data = this.data;\r\n\r\n this.remove();\r\n\r\n if (!el.body || !data.target.body) {\r\n (el.body ? data.target : el).addEventListener(\"body-loaded\", this.update.bind(this, {}));\r\n return;\r\n }\r\n\r\n this.constraint = this.createConstraint();\r\n this.system.addConstraint(this.constraint);\r\n },\r\n\r\n /**\r\n * Creates a new constraint, given current component data. The CANNON.js constructors are a bit\r\n * different for each constraint type. A `.type` property is added to each constraint, because\r\n * `instanceof` checks are not reliable for some types. These types are needed for serialization.\r\n * @return {CANNON.Constraint}\r\n */\r\n createConstraint: function() {\r\n var constraint,\r\n data = this.data,\r\n pivot = new CANNON.Vec3(data.pivot.x, data.pivot.y, data.pivot.z),\r\n targetPivot = new CANNON.Vec3(data.targetPivot.x, data.targetPivot.y, data.targetPivot.z),\r\n axis = new CANNON.Vec3(data.axis.x, data.axis.y, data.axis.z),\r\n targetAxis = new CANNON.Vec3(data.targetAxis.x, data.targetAxis.y, data.targetAxis.z);\r\n\r\n var constraint;\r\n\r\n switch (data.type) {\r\n case \"lock\":\r\n constraint = new CANNON.LockConstraint(this.el.body, data.target.body, { maxForce: data.maxForce });\r\n constraint.type = \"LockConstraint\";\r\n break;\r\n\r\n case \"distance\":\r\n constraint = new CANNON.DistanceConstraint(this.el.body, data.target.body, data.distance, data.maxForce);\r\n constraint.type = \"DistanceConstraint\";\r\n break;\r\n\r\n case \"hinge\":\r\n constraint = new CANNON.HingeConstraint(this.el.body, data.target.body, {\r\n pivotA: pivot,\r\n pivotB: targetPivot,\r\n axisA: axis,\r\n axisB: targetAxis,\r\n maxForce: data.maxForce\r\n });\r\n constraint.type = \"HingeConstraint\";\r\n break;\r\n\r\n case \"coneTwist\":\r\n constraint = new CANNON.ConeTwistConstraint(this.el.body, data.target.body, {\r\n pivotA: pivot,\r\n pivotB: targetPivot,\r\n axisA: axis,\r\n axisB: targetAxis,\r\n maxForce: data.maxForce\r\n });\r\n constraint.type = \"ConeTwistConstraint\";\r\n break;\r\n\r\n case \"pointToPoint\":\r\n constraint = new CANNON.PointToPointConstraint(\r\n this.el.body,\r\n pivot,\r\n data.target.body,\r\n targetPivot,\r\n data.maxForce\r\n );\r\n constraint.type = \"PointToPointConstraint\";\r\n break;\r\n\r\n default:\r\n throw new Error(\"[constraint] Unexpected type: \" + data.type);\r\n }\r\n\r\n constraint.collideConnected = data.collideConnected;\r\n return constraint;\r\n }\r\n});\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/components/constraint.js?"); +/***/ }), -function getConvexPolyhedronParameters(object) { - const geometry = getGeometry(object); - if (!geometry) return null; // Perturb. +/***/ "./src/components/math/index.js": +/*!**************************************!*\ + !*** ./src/components/math/index.js ***! + \**************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - const eps = 1e-4; +eval("module.exports = {\r\n 'velocity': __webpack_require__(/*! ./velocity */ \"./src/components/math/velocity.js\"),\r\n\r\n registerAll: function (AFRAME) {\r\n if (this._registered) return;\r\n\r\n AFRAME = AFRAME || window.AFRAME;\r\n\r\n if (!AFRAME.components['velocity']) AFRAME.registerComponent('velocity', this.velocity);\r\n\r\n this._registered = true;\r\n }\r\n};\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/components/math/index.js?"); - for (let i = 0; i < geometry.attributes.position.count; i++) { - geometry.attributes.position.setXYZ(i, geometry.attributes.position.getX(i) + (Math.random() - 0.5) * eps, geometry.attributes.position.getY(i) + (Math.random() - 0.5) * eps, geometry.attributes.position.getZ(i) + (Math.random() - 0.5) * eps); - } // Compute the 3D convex hull. +/***/ }), +/***/ "./src/components/math/velocity.js": +/*!*****************************************!*\ + !*** ./src/components/math/velocity.js ***! + \*****************************************/ +/***/ ((module) => { - const hull = new ConvexHull().setFromObject(new three.Mesh(geometry)); - const hullFaces = hull.faces; - const vertices = []; - const faces = []; - let currentFaceVertex = 0; +eval("/**\r\n * Velocity, in m/s.\r\n */\r\nmodule.exports = AFRAME.registerComponent('velocity', {\r\n schema: {type: 'vec3'},\r\n\r\n init: function () {\r\n this.system = this.el.sceneEl.systems.physics;\r\n\r\n if (this.system) {\r\n this.system.addComponent(this);\r\n }\r\n },\r\n\r\n remove: function () {\r\n if (this.system) {\r\n this.system.removeComponent(this);\r\n }\r\n },\r\n\r\n tick: function (t, dt) {\r\n if (!dt) return;\r\n if (this.system) return;\r\n this.afterStep(t, dt);\r\n },\r\n\r\n afterStep: function (t, dt) {\r\n if (!dt) return;\r\n\r\n var physics = this.el.sceneEl.systems.physics || {data: {maxInterval: 1 / 60}},\r\n\r\n // TODO - There's definitely a bug with getComputedAttribute and el.data.\r\n velocity = this.el.getAttribute('velocity') || {x: 0, y: 0, z: 0},\r\n position = this.el.object3D.position || {x: 0, y: 0, z: 0};\r\n\r\n dt = Math.min(dt, physics.data.maxInterval * 1000);\r\n\r\n this.el.object3D.position.set(\r\n position.x + velocity.x * dt / 1000,\r\n position.y + velocity.y * dt / 1000,\r\n position.z + velocity.z * dt / 1000\r\n );\r\n }\r\n});\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/components/math/velocity.js?"); - for (let i = 0; i < hullFaces.length; i++) { - const hullFace = hullFaces[i]; - const face = []; - faces.push(face); - let edge = hullFace.edge; +/***/ }), - do { - const point = edge.head().point; - vertices.push(point.x, point.y, point.z); - face.push(currentFaceVertex); - currentFaceVertex++; - edge = edge.next; - } while (edge !== hullFace.edge); - } +/***/ "./src/components/shape/ammo-shape.js": +/*!********************************************!*\ + !*** ./src/components/shape/ammo-shape.js ***! + \********************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - const verticesTypedArray = new Float32Array(vertices.length); - verticesTypedArray.set(vertices); - return { - type: exports.ShapeType.HULL, - params: { - vertices: verticesTypedArray, - faces - } - }; -} +eval("/* global Ammo,THREE */\r\nconst threeToAmmo = __webpack_require__(/*! three-to-ammo */ \"./node_modules/three-to-ammo/index.js\");\r\nconst CONSTANTS = __webpack_require__(/*! ../../constants */ \"./src/constants.js\"),\r\n SHAPE = CONSTANTS.SHAPE,\r\n FIT = CONSTANTS.FIT;\r\n\r\nvar AmmoShape = {\r\n schema: {\r\n type: {\r\n default: SHAPE.HULL,\r\n oneOf: [\r\n SHAPE.BOX,\r\n SHAPE.CYLINDER,\r\n SHAPE.SPHERE,\r\n SHAPE.CAPSULE,\r\n SHAPE.CONE,\r\n SHAPE.HULL,\r\n SHAPE.HACD,\r\n SHAPE.VHACD,\r\n SHAPE.MESH,\r\n SHAPE.HEIGHTFIELD\r\n ]\r\n },\r\n fit: { default: FIT.ALL, oneOf: [FIT.ALL, FIT.MANUAL] },\r\n halfExtents: { type: \"vec3\", default: { x: 1, y: 1, z: 1 } },\r\n minHalfExtent: { default: 0 },\r\n maxHalfExtent: { default: Number.POSITIVE_INFINITY },\r\n sphereRadius: { default: NaN },\r\n cylinderAxis: { default: \"y\", oneOf: [\"x\", \"y\", \"z\"] },\r\n margin: { default: 0.01 },\r\n offset: { type: \"vec3\", default: { x: 0, y: 0, z: 0 } },\r\n orientation: { type: \"vec4\", default: { x: 0, y: 0, z: 0, w: 1 } },\r\n heightfieldData: { default: [] },\r\n heightfieldDistance: { default: 1 },\r\n includeInvisible: { default: false }\r\n },\r\n\r\n multiple: true,\r\n\r\n init: function() {\r\n this.system = this.el.sceneEl.systems.physics;\r\n this.collisionShapes = [];\r\n\r\n let bodyEl = this.el;\r\n this.body = bodyEl.components[\"ammo-body\"] || null;\r\n while (!this.body && bodyEl.parentNode != this.el.sceneEl) {\r\n bodyEl = bodyEl.parentNode;\r\n if (bodyEl.components[\"ammo-body\"]) {\r\n this.body = bodyEl.components[\"ammo-body\"];\r\n }\r\n }\r\n if (!this.body) {\r\n console.warn(\"body not found\");\r\n return;\r\n }\r\n if (this.data.fit !== FIT.MANUAL) {\r\n if (!this.el.object3DMap.mesh) {\r\n console.error(\"Cannot use FIT.ALL without object3DMap.mesh\");\r\n return;\r\n }\r\n this.mesh = this.el.object3DMap.mesh;\r\n }\r\n this.body.addShapeComponent(this);\r\n },\r\n\r\n getMesh: function() {\r\n return this.mesh || null;\r\n },\r\n\r\n addShapes: function(collisionShapes) {\r\n this.collisionShapes = collisionShapes;\r\n },\r\n\r\n getShapes: function() {\r\n return this.collisionShapes;\r\n },\r\n\r\n remove: function() {\r\n if (!this.body) {\r\n return;\r\n }\r\n\r\n this.body.removeShapeComponent(this);\r\n\r\n while (this.collisionShapes.length > 0) {\r\n const collisionShape = this.collisionShapes.pop();\r\n collisionShape.destroy();\r\n Ammo.destroy(collisionShape.localTransform);\r\n }\r\n }\r\n};\r\n\r\nmodule.exports.definition = AmmoShape;\r\nmodule.exports.Component = AFRAME.registerComponent(\"ammo-shape\", AmmoShape);\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/components/shape/ammo-shape.js?"); -function getCylinderParameters(geometry) { - const params = geometry.parameters; - return { - type: exports.ShapeType.CYLINDER, - params: { - radiusTop: params.radiusTop, - radiusBottom: params.radiusBottom, - height: params.height, - segments: params.radialSegments - }, - orientation: new cannonEs.Quaternion().setFromEuler(three.MathUtils.degToRad(-90), 0, 0, 'XYZ').normalize() - }; -} +/***/ }), -function getBoundingCylinderParameters(object, options) { - const axes = ['x', 'y', 'z']; - const majorAxis = options.cylinderAxis || 'y'; - const minorAxes = axes.splice(axes.indexOf(majorAxis), 1) && axes; - const box = new three.Box3().setFromObject(object); - if (!isFinite(box.min.lengthSq())) return null; // Compute cylinder dimensions. +/***/ "./src/components/shape/shape.js": +/*!***************************************!*\ + !*** ./src/components/shape/shape.js ***! + \***************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - const height = box.max[majorAxis] - box.min[majorAxis]; - const radius = 0.5 * Math.max(getComponent(box.max, minorAxes[0]) - getComponent(box.min, minorAxes[0]), getComponent(box.max, minorAxes[1]) - getComponent(box.min, minorAxes[1])); - const eulerX = majorAxis === 'y' ? PI_2 : 0; - const eulerY = majorAxis === 'z' ? PI_2 : 0; - return { - type: exports.ShapeType.CYLINDER, - params: { - radiusTop: radius, - radiusBottom: radius, - height, - segments: 12 - }, - orientation: new cannonEs.Quaternion().setFromEuler(eulerX, eulerY, 0, 'XYZ').normalize() - }; -} +eval("var CANNON = __webpack_require__(/*! cannon-es */ \"./node_modules/cannon-es/dist/cannon-es.js\");\r\n\r\nvar Shape = {\r\n schema: {\r\n shape: {default: 'box', oneOf: ['box', 'sphere', 'cylinder']},\r\n offset: {type: 'vec3', default: {x: 0, y: 0, z: 0}},\r\n orientation: {type: 'vec4', default: {x: 0, y: 0, z: 0, w: 1}},\r\n\r\n // sphere\r\n radius: {type: 'number', default: 1, if: {shape: ['sphere']}},\r\n\r\n // box\r\n halfExtents: {type: 'vec3', default: {x: 0.5, y: 0.5, z: 0.5}, if: {shape: ['box']}},\r\n \r\n // cylinder\r\n radiusTop: {type: 'number', default: 1, if: {shape: ['cylinder']}},\r\n radiusBottom: {type: 'number', default: 1, if: {shape: ['cylinder']}},\r\n height: {type: 'number', default: 1, if: {shape: ['cylinder']}},\r\n numSegments: {type: 'int', default: 8, if: {shape: ['cylinder']}}\r\n },\r\n\r\n multiple: true,\r\n\r\n init: function() {\r\n if (this.el.sceneEl.hasLoaded) {\r\n this.initShape();\r\n } else {\r\n this.el.sceneEl.addEventListener('loaded', this.initShape.bind(this));\r\n }\r\n },\r\n\r\n initShape: function() {\r\n this.bodyEl = this.el;\r\n var bodyType = this._findType(this.bodyEl);\r\n var data = this.data;\r\n\r\n while (!bodyType && this.bodyEl.parentNode != this.el.sceneEl) {\r\n this.bodyEl = this.bodyEl.parentNode;\r\n bodyType = this._findType(this.bodyEl);\r\n }\r\n\r\n if (!bodyType) {\r\n console.warn('body not found');\r\n return;\r\n }\r\n\r\n var scale = new THREE.Vector3();\r\n this.bodyEl.object3D.getWorldScale(scale);\r\n var shape, offset, orientation;\r\n\r\n if (data.hasOwnProperty('offset')) {\r\n offset = new CANNON.Vec3(\r\n data.offset.x * scale.x, \r\n data.offset.y * scale.y, \r\n data.offset.z * scale.z\r\n );\r\n }\r\n\r\n if (data.hasOwnProperty('orientation')) {\r\n orientation = new CANNON.Quaternion();\r\n orientation.copy(data.orientation);\r\n }\r\n\r\n switch(data.shape) {\r\n case 'sphere':\r\n shape = new CANNON.Sphere(data.radius * scale.x);\r\n break;\r\n case 'box':\r\n var halfExtents = new CANNON.Vec3(\r\n data.halfExtents.x * scale.x, \r\n data.halfExtents.y * scale.y, \r\n data.halfExtents.z * scale.z\r\n );\r\n shape = new CANNON.Box(halfExtents);\r\n break;\r\n case 'cylinder':\r\n shape = new CANNON.Cylinder(\r\n data.radiusTop * scale.x, \r\n data.radiusBottom * scale.x, \r\n data.height * scale.y, \r\n data.numSegments\r\n );\r\n\r\n //rotate by 90 degrees similar to mesh2shape:createCylinderShape\r\n var quat = new CANNON.Quaternion();\r\n quat.setFromEuler(90 * THREE.Math.DEG2RAD, 0, 0, 'XYZ').normalize();\r\n orientation.mult(quat, orientation);\r\n break;\r\n default:\r\n console.warn(data.shape + ' shape not supported');\r\n return;\r\n }\r\n\r\n if (this.bodyEl.body) {\r\n this.bodyEl.components[bodyType].addShape(shape, offset, orientation);\r\n } else {\r\n this.bodyEl.addEventListener('body-loaded', function() {\r\n this.bodyEl.components[bodyType].addShape(shape, offset, orientation);\r\n }, {once: true});\r\n }\r\n },\r\n\r\n _findType: function(el) {\r\n if (el.hasAttribute('body')) {\r\n return 'body';\r\n } else if (el.hasAttribute('dynamic-body')) {\r\n return 'dynamic-body';\r\n } else if (el.hasAttribute('static-body')) {\r\n return'static-body';\r\n }\r\n return null;\r\n },\r\n\r\n remove: function() {\r\n if (this.bodyEl.parentNode) {\r\n console.warn('removing shape component not currently supported');\r\n }\r\n }\r\n};\r\n\r\nmodule.exports.definition = Shape;\r\nmodule.exports.Component = AFRAME.registerComponent('shape', Shape);\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/components/shape/shape.js?"); -function getPlaneParameters(geometry) { - geometry.computeBoundingBox(); - const box = geometry.boundingBox; - return { - type: exports.ShapeType.BOX, - params: { - x: (box.max.x - box.min.x) / 2 || 0.1, - y: (box.max.y - box.min.y) / 2 || 0.1, - z: (box.max.z - box.min.z) / 2 || 0.1 - } - }; -} +/***/ }), -function getSphereParameters(geometry) { - return { - type: exports.ShapeType.SPHERE, - params: { - radius: geometry.parameters.radius - } - }; -} +/***/ "./src/components/spring.js": +/*!**********************************!*\ + !*** ./src/components/spring.js ***! + \**********************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { -function getBoundingSphereParameters(object, options) { - if (options.sphereRadius) { - return { - type: exports.ShapeType.SPHERE, - params: { - radius: options.sphereRadius - } - }; - } +eval("var CANNON = __webpack_require__(/*! cannon-es */ \"./node_modules/cannon-es/dist/cannon-es.js\");\r\n\r\nmodule.exports = AFRAME.registerComponent('spring', {\r\n\r\n multiple: true,\r\n\r\n schema: {\r\n // Target (other) body for the constraint.\r\n target: {type: 'selector'},\r\n\r\n // Length of the spring, when no force acts upon it.\r\n restLength: {default: 1, min: 0},\r\n\r\n // How much will the spring suppress the force.\r\n stiffness: {default: 100, min: 0},\r\n\r\n // Stretch factor of the spring.\r\n damping: {default: 1, min: 0},\r\n\r\n // Offsets.\r\n localAnchorA: {type: 'vec3', default: {x: 0, y: 0, z: 0}},\r\n localAnchorB: {type: 'vec3', default: {x: 0, y: 0, z: 0}},\r\n },\r\n\r\n init: function() {\r\n this.system = this.el.sceneEl.systems.physics;\r\n this.system.addComponent(this);\r\n this.isActive = true;\r\n this.spring = /* {CANNON.Spring} */ null;\r\n },\r\n\r\n update: function(oldData) {\r\n var el = this.el;\r\n var data = this.data;\r\n\r\n if (!data.target) {\r\n console.warn('Spring: invalid target specified.');\r\n return; \r\n }\r\n \r\n // wait until the CANNON bodies is created and attached\r\n if (!el.body || !data.target.body) {\r\n (el.body ? data.target : el).addEventListener('body-loaded', this.update.bind(this, {}));\r\n return;\r\n }\r\n\r\n // create the spring if necessary\r\n this.createSpring();\r\n // apply new data to the spring\r\n this.updateSpring(oldData);\r\n },\r\n\r\n updateSpring: function(oldData) {\r\n if (!this.spring) {\r\n console.warn('Spring: Component attempted to change spring before its created. No changes made.');\r\n return;\r\n } \r\n var data = this.data;\r\n var spring = this.spring;\r\n\r\n // Cycle through the schema and check if an attribute has changed.\r\n // if so, apply it to the spring\r\n Object.keys(data).forEach(function(attr) {\r\n if (data[attr] !== oldData[attr]) {\r\n if (attr === 'target') {\r\n // special case for the target selector\r\n spring.bodyB = data.target.body;\r\n return;\r\n }\r\n spring[attr] = data[attr];\r\n }\r\n })\r\n },\r\n\r\n createSpring: function() {\r\n if (this.spring) return; // no need to create a new spring\r\n this.spring = new CANNON.Spring(this.el.body);\r\n },\r\n\r\n // If the spring is valid, update the force each tick the physics are calculated\r\n step: function(t, dt) {\r\n return this.spring && this.isActive ? this.spring.applyForce() : void 0;\r\n },\r\n\r\n // resume updating the force when component upon calling play()\r\n play: function() {\r\n this.isActive = true;\r\n },\r\n\r\n // stop updating the force when component upon calling stop()\r\n pause: function() {\r\n this.isActive = false;\r\n },\r\n\r\n //remove the event listener + delete the spring\r\n remove: function() {\r\n if (this.spring)\r\n delete this.spring;\r\n this.spring = null;\r\n }\r\n})\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/components/spring.js?"); - const geometry = getGeometry(object); - if (!geometry) return null; - geometry.computeBoundingSphere(); - return { - type: exports.ShapeType.SPHERE, - params: { - radius: geometry.boundingSphere.radius - } - }; -} +/***/ }), -function getTrimeshParameters(geometry) { - const vertices = getVertices(geometry); - if (!vertices.length) return null; - const indices = new Uint32Array(vertices.length); +/***/ "./src/constants.js": +/*!**************************!*\ + !*** ./src/constants.js ***! + \**************************/ +/***/ ((module) => { - for (let i = 0; i < vertices.length; i++) { - indices[i] = i; - } +eval("module.exports = {\r\n GRAVITY: -9.8,\r\n MAX_INTERVAL: 4 / 60,\r\n ITERATIONS: 10,\r\n CONTACT_MATERIAL: {\r\n friction: 0.01,\r\n restitution: 0.3,\r\n contactEquationStiffness: 1e8,\r\n contactEquationRelaxation: 3,\r\n frictionEquationStiffness: 1e8,\r\n frictionEquationRegularization: 3\r\n },\r\n ACTIVATION_STATE: {\r\n ACTIVE_TAG: \"active\",\r\n ISLAND_SLEEPING: \"islandSleeping\",\r\n WANTS_DEACTIVATION: \"wantsDeactivation\",\r\n DISABLE_DEACTIVATION: \"disableDeactivation\",\r\n DISABLE_SIMULATION: \"disableSimulation\"\r\n },\r\n COLLISION_FLAG: {\r\n STATIC_OBJECT: 1,\r\n KINEMATIC_OBJECT: 2,\r\n NO_CONTACT_RESPONSE: 4,\r\n CUSTOM_MATERIAL_CALLBACK: 8, //this allows per-triangle material (friction/restitution)\r\n CHARACTER_OBJECT: 16,\r\n DISABLE_VISUALIZE_OBJECT: 32, //disable debug drawing\r\n DISABLE_SPU_COLLISION_PROCESSING: 64 //disable parallel/SPU processing\r\n },\r\n TYPE: {\r\n STATIC: \"static\",\r\n DYNAMIC: \"dynamic\",\r\n KINEMATIC: \"kinematic\"\r\n },\r\n SHAPE: {\r\n BOX: \"box\",\r\n CYLINDER: \"cylinder\",\r\n SPHERE: \"sphere\",\r\n CAPSULE: \"capsule\",\r\n CONE: \"cone\",\r\n HULL: \"hull\",\r\n HACD: \"hacd\",\r\n VHACD: \"vhacd\",\r\n MESH: \"mesh\",\r\n HEIGHTFIELD: \"heightfield\"\r\n },\r\n FIT: {\r\n ALL: \"all\",\r\n MANUAL: \"manual\"\r\n },\r\n CONSTRAINT: {\r\n LOCK: \"lock\",\r\n FIXED: \"fixed\",\r\n SPRING: \"spring\",\r\n SLIDER: \"slider\",\r\n HINGE: \"hinge\",\r\n CONE_TWIST: \"coneTwist\",\r\n POINT_TO_POINT: \"pointToPoint\"\r\n }\r\n};\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/constants.js?"); - return { - type: exports.ShapeType.MESH, - params: { - vertices, - indices - } - }; -} +/***/ }), -exports.getShapeParameters = getShapeParameters; -exports.threeToCannon = threeToCannon; +/***/ "./src/drivers/ammo-driver.js": +/*!************************************!*\ + !*** ./src/drivers/ammo-driver.js ***! + \************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { +eval("/* global THREE */\r\nconst Driver = __webpack_require__(/*! ./driver */ \"./src/drivers/driver.js\");\r\n\r\nif (typeof window !== 'undefined') {\r\n window.AmmoModule = window.Ammo;\r\n window.Ammo = null;\r\n}\r\n\r\nconst EPS = 10e-6;\r\n\r\nfunction AmmoDriver() {\r\n this.collisionConfiguration = null;\r\n this.dispatcher = null;\r\n this.broadphase = null;\r\n this.solver = null;\r\n this.physicsWorld = null;\r\n this.debugDrawer = null;\r\n\r\n this.els = new Map();\r\n this.eventListeners = [];\r\n this.collisions = new Map();\r\n this.collisionKeys = [];\r\n this.currentCollisions = new Map();\r\n}\r\n\r\nAmmoDriver.prototype = new Driver();\r\nAmmoDriver.prototype.constructor = AmmoDriver;\r\n\r\nmodule.exports = AmmoDriver;\r\n\r\n/* @param {object} worldConfig */\r\nAmmoDriver.prototype.init = function(worldConfig) {\r\n //Emscripten doesn't use real promises, just a .then() callback, so it necessary to wrap in a real promise.\r\n return new Promise(resolve => {\r\n AmmoModule().then(result => {\r\n Ammo = result;\r\n this.epsilon = worldConfig.epsilon || EPS;\r\n this.debugDrawMode = worldConfig.debugDrawMode || THREE.AmmoDebugConstants.NoDebug;\r\n this.maxSubSteps = worldConfig.maxSubSteps || 4;\r\n this.fixedTimeStep = worldConfig.fixedTimeStep || 1 / 60;\r\n this.collisionConfiguration = new Ammo.btDefaultCollisionConfiguration();\r\n this.dispatcher = new Ammo.btCollisionDispatcher(this.collisionConfiguration);\r\n this.broadphase = new Ammo.btDbvtBroadphase();\r\n this.solver = new Ammo.btSequentialImpulseConstraintSolver();\r\n this.physicsWorld = new Ammo.btDiscreteDynamicsWorld(\r\n this.dispatcher,\r\n this.broadphase,\r\n this.solver,\r\n this.collisionConfiguration\r\n );\r\n this.physicsWorld.setForceUpdateAllAabbs(false);\r\n this.physicsWorld.setGravity(\r\n new Ammo.btVector3(0, worldConfig.hasOwnProperty(\"gravity\") ? worldConfig.gravity : -9.8, 0)\r\n );\r\n this.physicsWorld.getSolverInfo().set_m_numIterations(worldConfig.solverIterations);\r\n resolve();\r\n });\r\n });\r\n};\r\n\r\n/* @param {Ammo.btCollisionObject} body */\r\nAmmoDriver.prototype.addBody = function(body, group, mask) {\r\n this.physicsWorld.addRigidBody(body, group, mask);\r\n this.els.set(Ammo.getPointer(body), body.el);\r\n};\r\n\r\n/* @param {Ammo.btCollisionObject} body */\r\nAmmoDriver.prototype.removeBody = function(body) {\r\n this.physicsWorld.removeRigidBody(body);\r\n this.removeEventListener(body);\r\n const bodyptr = Ammo.getPointer(body);\r\n this.els.delete(bodyptr);\r\n this.collisions.delete(bodyptr);\r\n this.collisionKeys.splice(this.collisionKeys.indexOf(bodyptr), 1);\r\n this.currentCollisions.delete(bodyptr);\r\n};\r\n\r\nAmmoDriver.prototype.updateBody = function(body) {\r\n if (this.els.has(Ammo.getPointer(body))) {\r\n this.physicsWorld.updateSingleAabb(body);\r\n }\r\n};\r\n\r\n/* @param {number} deltaTime */\r\nAmmoDriver.prototype.step = function(deltaTime) {\r\n this.physicsWorld.stepSimulation(deltaTime, this.maxSubSteps, this.fixedTimeStep);\r\n\r\n const numManifolds = this.dispatcher.getNumManifolds();\r\n for (let i = 0; i < numManifolds; i++) {\r\n const persistentManifold = this.dispatcher.getManifoldByIndexInternal(i);\r\n const numContacts = persistentManifold.getNumContacts();\r\n const body0ptr = Ammo.getPointer(persistentManifold.getBody0());\r\n const body1ptr = Ammo.getPointer(persistentManifold.getBody1());\r\n let collided = false;\r\n\r\n for (let j = 0; j < numContacts; j++) {\r\n const manifoldPoint = persistentManifold.getContactPoint(j);\r\n const distance = manifoldPoint.getDistance();\r\n if (distance <= this.epsilon) {\r\n collided = true;\r\n break;\r\n }\r\n }\r\n\r\n if (collided) {\r\n if (!this.collisions.has(body0ptr)) {\r\n this.collisions.set(body0ptr, []);\r\n this.collisionKeys.push(body0ptr);\r\n }\r\n if (this.collisions.get(body0ptr).indexOf(body1ptr) === -1) {\r\n this.collisions.get(body0ptr).push(body1ptr);\r\n if (this.eventListeners.indexOf(body0ptr) !== -1) {\r\n this.els.get(body0ptr).emit(\"collidestart\", { targetEl: this.els.get(body1ptr) });\r\n }\r\n if (this.eventListeners.indexOf(body1ptr) !== -1) {\r\n this.els.get(body1ptr).emit(\"collidestart\", { targetEl: this.els.get(body0ptr) });\r\n }\r\n }\r\n if (!this.currentCollisions.has(body0ptr)) {\r\n this.currentCollisions.set(body0ptr, new Set());\r\n }\r\n this.currentCollisions.get(body0ptr).add(body1ptr);\r\n }\r\n }\r\n\r\n for (let i = 0; i < this.collisionKeys.length; i++) {\r\n const body0ptr = this.collisionKeys[i];\r\n const body1ptrs = this.collisions.get(body0ptr);\r\n for (let j = body1ptrs.length - 1; j >= 0; j--) {\r\n const body1ptr = body1ptrs[j];\r\n if (this.currentCollisions.get(body0ptr).has(body1ptr)) {\r\n continue;\r\n }\r\n if (this.eventListeners.indexOf(body0ptr) !== -1) {\r\n this.els.get(body0ptr).emit(\"collideend\", { targetEl: this.els.get(body1ptr) });\r\n }\r\n if (this.eventListeners.indexOf(body1ptr) !== -1) {\r\n this.els.get(body1ptr).emit(\"collideend\", { targetEl: this.els.get(body0ptr) });\r\n }\r\n body1ptrs.splice(j, 1);\r\n }\r\n this.currentCollisions.get(body0ptr).clear();\r\n }\r\n\r\n if (this.debugDrawer) {\r\n this.debugDrawer.update();\r\n }\r\n};\r\n\r\n/* @param {?} constraint */\r\nAmmoDriver.prototype.addConstraint = function(constraint) {\r\n this.physicsWorld.addConstraint(constraint, false);\r\n};\r\n\r\n/* @param {?} constraint */\r\nAmmoDriver.prototype.removeConstraint = function(constraint) {\r\n this.physicsWorld.removeConstraint(constraint);\r\n};\r\n\r\n/* @param {Ammo.btCollisionObject} body */\r\nAmmoDriver.prototype.addEventListener = function(body) {\r\n this.eventListeners.push(Ammo.getPointer(body));\r\n};\r\n\r\n/* @param {Ammo.btCollisionObject} body */\r\nAmmoDriver.prototype.removeEventListener = function(body) {\r\n const ptr = Ammo.getPointer(body);\r\n if (this.eventListeners.indexOf(ptr) !== -1) {\r\n this.eventListeners.splice(this.eventListeners.indexOf(ptr), 1);\r\n }\r\n};\r\n\r\nAmmoDriver.prototype.destroy = function() {\r\n Ammo.destroy(this.collisionConfiguration);\r\n Ammo.destroy(this.dispatcher);\r\n Ammo.destroy(this.broadphase);\r\n Ammo.destroy(this.solver);\r\n Ammo.destroy(this.physicsWorld);\r\n Ammo.destroy(this.debugDrawer);\r\n};\r\n\r\n/**\r\n * @param {THREE.Scene} scene\r\n * @param {object} options\r\n */\r\nAmmoDriver.prototype.getDebugDrawer = function(scene, options) {\r\n if (!this.debugDrawer) {\r\n options = options || {};\r\n options.debugDrawMode = options.debugDrawMode || this.debugDrawMode;\r\n this.debugDrawer = new THREE.AmmoDebugDrawer(scene, this.physicsWorld, options);\r\n }\r\n return this.debugDrawer;\r\n};\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/drivers/ammo-driver.js?"); -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"cannon-es":5}],8:[function(require,module,exports){ -var bundleFn = arguments[3]; -var sources = arguments[4]; -var cache = arguments[5]; +/***/ }), -var stringify = JSON.stringify; +/***/ "./src/drivers/driver.js": +/*!*******************************!*\ + !*** ./src/drivers/driver.js ***! + \*******************************/ +/***/ ((module) => { -module.exports = function (fn, options) { - var wkey; - var cacheKeys = Object.keys(cache); +eval("/**\r\n * Driver - defines limited API to local and remote physics controllers.\r\n */\r\n\r\nfunction Driver () {}\r\n\r\nmodule.exports = Driver;\r\n\r\n/******************************************************************************\r\n * Lifecycle\r\n */\r\n\r\n/* @param {object} worldConfig */\r\nDriver.prototype.init = abstractMethod;\r\n\r\n/* @param {number} deltaMS */\r\nDriver.prototype.step = abstractMethod;\r\n\r\nDriver.prototype.destroy = abstractMethod;\r\n\r\n/******************************************************************************\r\n * Bodies\r\n */\r\n\r\n/* @param {CANNON.Body} body */\r\nDriver.prototype.addBody = abstractMethod;\r\n\r\n/* @param {CANNON.Body} body */\r\nDriver.prototype.removeBody = abstractMethod;\r\n\r\n/**\r\n * @param {CANNON.Body} body\r\n * @param {string} methodName\r\n * @param {Array} args\r\n */\r\nDriver.prototype.applyBodyMethod = abstractMethod;\r\n\r\n/** @param {CANNON.Body} body */\r\nDriver.prototype.updateBodyProperties = abstractMethod;\r\n\r\n/******************************************************************************\r\n * Materials\r\n */\r\n\r\n/** @param {object} materialConfig */\r\nDriver.prototype.addMaterial = abstractMethod;\r\n\r\n/**\r\n * @param {string} materialName1\r\n * @param {string} materialName2\r\n * @param {object} contactMaterialConfig\r\n */\r\nDriver.prototype.addContactMaterial = abstractMethod;\r\n\r\n/******************************************************************************\r\n * Constraints\r\n */\r\n\r\n/* @param {CANNON.Constraint} constraint */\r\nDriver.prototype.addConstraint = abstractMethod;\r\n\r\n/* @param {CANNON.Constraint} constraint */\r\nDriver.prototype.removeConstraint = abstractMethod;\r\n\r\n/******************************************************************************\r\n * Contacts\r\n */\r\n\r\n/** @return {Array} */\r\nDriver.prototype.getContacts = abstractMethod;\r\n\r\n/*****************************************************************************/\r\n\r\nfunction abstractMethod () {\r\n throw new Error('Method not implemented.');\r\n}\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/drivers/driver.js?"); - for (var i = 0, l = cacheKeys.length; i < l; i++) { - var key = cacheKeys[i]; - var exp = cache[key].exports; - // Using babel as a transpiler to use esmodule, the export will always - // be an object with the default export as a property of it. To ensure - // the existing api and babel esmodule exports are both supported we - // check for both - if (exp === fn || exp && exp.default === fn) { - wkey = key; - break; - } - } +/***/ }), - if (!wkey) { - wkey = Math.floor(Math.pow(16, 8) * Math.random()).toString(16); - var wcache = {}; - for (var i = 0, l = cacheKeys.length; i < l; i++) { - var key = cacheKeys[i]; - wcache[key] = key; - } - sources[wkey] = [ - Function(['require','module','exports'], '(' + fn + ')(self)'), - wcache - ]; - } - var skey = Math.floor(Math.pow(16, 8) * Math.random()).toString(16); +/***/ "./src/drivers/event.js": +/*!******************************!*\ + !*** ./src/drivers/event.js ***! + \******************************/ +/***/ ((module) => { - var scache = {}; scache[wkey] = wkey; - sources[skey] = [ - Function(['require'], ( - // try to call default if defined to also support babel esmodule - // exports - 'var f = require(' + stringify(wkey) + ');' + - '(f.default ? f.default : f)(self);' - )), - scache - ]; +eval("module.exports = {\r\n INIT: 'init',\r\n STEP: 'step',\r\n\r\n // Bodies.\r\n ADD_BODY: 'add-body',\r\n REMOVE_BODY: 'remove-body',\r\n APPLY_BODY_METHOD: 'apply-body-method',\r\n UPDATE_BODY_PROPERTIES: 'update-body-properties',\r\n\r\n // Materials.\r\n ADD_MATERIAL: 'add-material',\r\n ADD_CONTACT_MATERIAL: 'add-contact-material',\r\n\r\n // Constraints.\r\n ADD_CONSTRAINT: 'add-constraint',\r\n REMOVE_CONSTRAINT: 'remove-constraint',\r\n\r\n // Events.\r\n COLLIDE: 'collide'\r\n};\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/drivers/event.js?"); - var workerSources = {}; - resolveSources(skey); +/***/ }), - function resolveSources(key) { - workerSources[key] = true; +/***/ "./src/drivers/local-driver.js": +/*!*************************************!*\ + !*** ./src/drivers/local-driver.js ***! + \*************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - for (var depPath in sources[key][1]) { - var depKey = sources[key][1][depPath]; - if (!workerSources[depKey]) { - resolveSources(depKey); - } - } - } +eval("var CANNON = __webpack_require__(/*! cannon-es */ \"./node_modules/cannon-es/dist/cannon-es.js\"),\r\n Driver = __webpack_require__(/*! ./driver */ \"./src/drivers/driver.js\");\r\n\r\nfunction LocalDriver () {\r\n this.world = null;\r\n this.materials = {};\r\n this.contactMaterial = null;\r\n}\r\n\r\nLocalDriver.prototype = new Driver();\r\nLocalDriver.prototype.constructor = LocalDriver;\r\n\r\nmodule.exports = LocalDriver;\r\n\r\n/******************************************************************************\r\n * Lifecycle\r\n */\r\n\r\n/* @param {object} worldConfig */\r\nLocalDriver.prototype.init = function (worldConfig) {\r\n var world = new CANNON.World();\r\n world.quatNormalizeSkip = worldConfig.quatNormalizeSkip;\r\n world.quatNormalizeFast = worldConfig.quatNormalizeFast;\r\n world.solver.iterations = worldConfig.solverIterations;\r\n world.gravity.set(0, worldConfig.gravity, 0);\r\n world.broadphase = new CANNON.NaiveBroadphase();\r\n\r\n this.world = world;\r\n};\r\n\r\n/* @param {number} deltaMS */\r\nLocalDriver.prototype.step = function (deltaMS) {\r\n this.world.step(deltaMS);\r\n};\r\n\r\nLocalDriver.prototype.destroy = function () {\r\n delete this.world;\r\n delete this.contactMaterial;\r\n this.materials = {};\r\n};\r\n\r\n/******************************************************************************\r\n * Bodies\r\n */\r\n\r\n/* @param {CANNON.Body} body */\r\nLocalDriver.prototype.addBody = function (body) {\r\n this.world.addBody(body);\r\n};\r\n\r\n/* @param {CANNON.Body} body */\r\nLocalDriver.prototype.removeBody = function (body) {\r\n this.world.removeBody(body);\r\n};\r\n\r\n/**\r\n * @param {CANNON.Body} body\r\n * @param {string} methodName\r\n * @param {Array} args\r\n */\r\nLocalDriver.prototype.applyBodyMethod = function (body, methodName, args) {\r\n body['__' + methodName].apply(body, args);\r\n};\r\n\r\n/** @param {CANNON.Body} body */\r\nLocalDriver.prototype.updateBodyProperties = function () {};\r\n\r\n/******************************************************************************\r\n * Materials\r\n */\r\n\r\n/**\r\n * @param {string} name\r\n * @return {CANNON.Material}\r\n */\r\nLocalDriver.prototype.getMaterial = function (name) {\r\n return this.materials[name];\r\n};\r\n\r\n/** @param {object} materialConfig */\r\nLocalDriver.prototype.addMaterial = function (materialConfig) {\r\n this.materials[materialConfig.name] = new CANNON.Material(materialConfig);\r\n this.materials[materialConfig.name].name = materialConfig.name;\r\n};\r\n\r\n/**\r\n * @param {string} matName1\r\n * @param {string} matName2\r\n * @param {object} contactMaterialConfig\r\n */\r\nLocalDriver.prototype.addContactMaterial = function (matName1, matName2, contactMaterialConfig) {\r\n var mat1 = this.materials[matName1],\r\n mat2 = this.materials[matName2];\r\n this.contactMaterial = new CANNON.ContactMaterial(mat1, mat2, contactMaterialConfig);\r\n this.world.addContactMaterial(this.contactMaterial);\r\n};\r\n\r\n/******************************************************************************\r\n * Constraints\r\n */\r\n\r\n/* @param {CANNON.Constraint} constraint */\r\nLocalDriver.prototype.addConstraint = function (constraint) {\r\n if (!constraint.type) {\r\n if (constraint instanceof CANNON.LockConstraint) {\r\n constraint.type = 'LockConstraint';\r\n } else if (constraint instanceof CANNON.DistanceConstraint) {\r\n constraint.type = 'DistanceConstraint';\r\n } else if (constraint instanceof CANNON.HingeConstraint) {\r\n constraint.type = 'HingeConstraint';\r\n } else if (constraint instanceof CANNON.ConeTwistConstraint) {\r\n constraint.type = 'ConeTwistConstraint';\r\n } else if (constraint instanceof CANNON.PointToPointConstraint) {\r\n constraint.type = 'PointToPointConstraint';\r\n }\r\n }\r\n this.world.addConstraint(constraint);\r\n};\r\n\r\n/* @param {CANNON.Constraint} constraint */\r\nLocalDriver.prototype.removeConstraint = function (constraint) {\r\n this.world.removeConstraint(constraint);\r\n};\r\n\r\n/******************************************************************************\r\n * Contacts\r\n */\r\n\r\n/** @return {Array} */\r\nLocalDriver.prototype.getContacts = function () {\r\n return this.world.contacts;\r\n};\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/drivers/local-driver.js?"); - var src = '(' + bundleFn + ')({' - + Object.keys(workerSources).map(function (key) { - return stringify(key) + ':[' - + sources[key][0] - + ',' + stringify(sources[key][1]) + ']' - ; - }).join(',') - + '},{},[' + stringify(skey) + '])' - ; +/***/ }), - var URL = window.URL || window.webkitURL || window.mozURL || window.msURL; +/***/ "./src/drivers/network-driver.js": +/*!***************************************!*\ + !*** ./src/drivers/network-driver.js ***! + \***************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - var blob = new Blob([src], { type: 'text/javascript' }); - if (options && options.bare) { return blob; } - var workerUrl = URL.createObjectURL(blob); - var worker = new Worker(workerUrl); - worker.objectURL = workerUrl; - return worker; -}; +eval("var Driver = __webpack_require__(/*! ./driver */ \"./src/drivers/driver.js\");\r\n\r\nfunction NetworkDriver () {\r\n throw new Error('[NetworkDriver] Driver not implemented.');\r\n}\r\n\r\nNetworkDriver.prototype = new Driver();\r\nNetworkDriver.prototype.constructor = NetworkDriver;\r\n\r\nmodule.exports = NetworkDriver;\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/drivers/network-driver.js?"); -},{}],9:[function(require,module,exports){ -/* global Ammo */ -const CONSTRAINT = require("../constants").CONSTRAINT; - -module.exports = AFRAME.registerComponent("ammo-constraint", { - multiple: true, - - schema: { - // Type of constraint. - type: { - default: CONSTRAINT.LOCK, - oneOf: [ - CONSTRAINT.LOCK, - CONSTRAINT.FIXED, - CONSTRAINT.SPRING, - CONSTRAINT.SLIDER, - CONSTRAINT.HINGE, - CONSTRAINT.CONE_TWIST, - CONSTRAINT.POINT_TO_POINT - ] - }, - - // Target (other) body for the constraint. - target: { type: "selector" }, - - // Offset of the hinge or point-to-point constraint, defined locally in the body. Used for hinge, coneTwist pointToPoint constraints. - pivot: { type: "vec3" }, - targetPivot: { type: "vec3" }, - - // An axis that each body can rotate around, defined locally to that body. Used for hinge constraints. - axis: { type: "vec3", default: { x: 0, y: 0, z: 1 } }, - targetAxis: { type: "vec3", default: { x: 0, y: 0, z: 1 } }, - - // damping & stuffness - used for spring contraints only - damping: { type: "number", default: 1 }, - stiffness: { type: "number", default: 100 }, - }, - - init: function() { - this.system = this.el.sceneEl.systems.physics; - this.constraint = null; - }, - - remove: function() { - if (!this.constraint) return; - - this.system.removeConstraint(this.constraint); - this.constraint = null; - }, - - update: function() { - const el = this.el, - data = this.data; - - this.remove(); - - if (!el.body || !data.target.body) { - (el.body ? data.target : el).addEventListener("body-loaded", this.update.bind(this, {}), { once: true }); - return; - } - - this.constraint = this.createConstraint(); - this.system.addConstraint(this.constraint); - }, - - /** - * @return {Ammo.btTypedConstraint} - */ - createConstraint: function() { - let constraint; - const data = this.data, - body = this.el.body, - targetBody = data.target.body; - - const bodyTransform = body - .getCenterOfMassTransform() - .inverse() - .op_mul(targetBody.getWorldTransform()); - const targetTransform = new Ammo.btTransform(); - targetTransform.setIdentity(); - - switch (data.type) { - case CONSTRAINT.LOCK: { - constraint = new Ammo.btGeneric6DofConstraint(body, targetBody, bodyTransform, targetTransform, true); - const zero = new Ammo.btVector3(0, 0, 0); - //TODO: allow these to be configurable - constraint.setLinearLowerLimit(zero); - constraint.setLinearUpperLimit(zero); - constraint.setAngularLowerLimit(zero); - constraint.setAngularUpperLimit(zero); - Ammo.destroy(zero); - break; - } - //TODO: test and verify all other constraint types - case CONSTRAINT.FIXED: { - //btFixedConstraint does not seem to debug render - bodyTransform.setRotation(body.getWorldTransform().getRotation()); - targetTransform.setRotation(targetBody.getWorldTransform().getRotation()); - constraint = new Ammo.btFixedConstraint(body, targetBody, bodyTransform, targetTransform); - break; - } - case CONSTRAINT.SPRING: { - constraint = new Ammo.btGeneric6DofSpringConstraint(body, targetBody, bodyTransform, targetTransform, true); - - // Very limited initial implementation of spring constraint. - // See: https://github.com/n5ro/aframe-physics-system/issues/171 - for (var i in [0,1,2,3,4,5]) { - constraint.enableSpring(1, true) - constraint.setStiffness(1, this.data.stiffness) - constraint.setDamping(1, this.data.damping) - } - const upper = new Ammo.btVector3(-1, -1, -1); - const lower = new Ammo.btVector3(1, 1, 1); - constraint.setLinearUpperLimit(upper); - constraint.setLinearLowerLimit(lower) - Ammo.destroy(upper); - Ammo.destroy(lower); - break; - } - case CONSTRAINT.SLIDER: { - //TODO: support setting linear and angular limits - constraint = new Ammo.btSliderConstraint(body, targetBody, bodyTransform, targetTransform, true); - constraint.setLowerLinLimit(-1); - constraint.setUpperLinLimit(1); - // constraint.setLowerAngLimit(); - // constraint.setUpperAngLimit(); - break; - } - case CONSTRAINT.HINGE: { - const pivot = new Ammo.btVector3(data.pivot.x, data.pivot.y, data.pivot.z); - const targetPivot = new Ammo.btVector3(data.targetPivot.x, data.targetPivot.y, data.targetPivot.z); - - const axis = new Ammo.btVector3(data.axis.x, data.axis.y, data.axis.z); - const targetAxis = new Ammo.btVector3(data.targetAxis.x, data.targetAxis.y, data.targetAxis.z); - - constraint = new Ammo.btHingeConstraint(body, targetBody, pivot, targetPivot, axis, targetAxis, true); - - Ammo.destroy(pivot); - Ammo.destroy(targetPivot); - Ammo.destroy(axis); - Ammo.destroy(targetAxis); - break; - } - case CONSTRAINT.CONE_TWIST: { - const pivotTransform = new Ammo.btTransform(); - pivotTransform.setIdentity(); - pivotTransform.getOrigin().setValue(data.pivot.x, data.pivot.y, data.pivot.z); - const targetPivotTransform = new Ammo.btTransform(); - targetPivotTransform.setIdentity(); - targetPivotTransform.getOrigin().setValue(data.targetPivot.x, data.targetPivot.y, data.targetPivot.z); - constraint = new Ammo.btConeTwistConstraint(body, targetBody, pivotTransform, targetPivotTransform); - Ammo.destroy(pivotTransform); - Ammo.destroy(targetPivotTransform); - break; - } - case CONSTRAINT.POINT_TO_POINT: { - const pivot = new Ammo.btVector3(data.pivot.x, data.pivot.y, data.pivot.z); - const targetPivot = new Ammo.btVector3(data.targetPivot.x, data.targetPivot.y, data.targetPivot.z); - - constraint = new Ammo.btPoint2PointConstraint(body, targetBody, pivot, targetPivot); - - Ammo.destroy(pivot); - Ammo.destroy(targetPivot); - break; - } - default: - throw new Error("[constraint] Unexpected type: " + data.type); - } - - Ammo.destroy(bodyTransform); - Ammo.destroy(targetTransform); - - return constraint; - } -}); +/***/ }), -},{"../constants":20}],10:[function(require,module,exports){ -/* global Ammo,THREE */ -const AmmoDebugDrawer = require("ammo-debug-drawer"); -const threeToAmmo = require("three-to-ammo"); -const CONSTANTS = require("../../constants"), - ACTIVATION_STATE = CONSTANTS.ACTIVATION_STATE, - COLLISION_FLAG = CONSTANTS.COLLISION_FLAG, - SHAPE = CONSTANTS.SHAPE, - TYPE = CONSTANTS.TYPE, - FIT = CONSTANTS.FIT; - -const ACTIVATION_STATES = [ - ACTIVATION_STATE.ACTIVE_TAG, - ACTIVATION_STATE.ISLAND_SLEEPING, - ACTIVATION_STATE.WANTS_DEACTIVATION, - ACTIVATION_STATE.DISABLE_DEACTIVATION, - ACTIVATION_STATE.DISABLE_SIMULATION -]; - -const RIGID_BODY_FLAGS = { - NONE: 0, - DISABLE_WORLD_GRAVITY: 1 -}; - -function almostEqualsVector3(epsilon, u, v) { - return Math.abs(u.x - v.x) < epsilon && Math.abs(u.y - v.y) < epsilon && Math.abs(u.z - v.z) < epsilon; -} - -function almostEqualsBtVector3(epsilon, u, v) { - return Math.abs(u.x() - v.x()) < epsilon && Math.abs(u.y() - v.y()) < epsilon && Math.abs(u.z() - v.z()) < epsilon; -} - -function almostEqualsQuaternion(epsilon, u, v) { - return ( - (Math.abs(u.x - v.x) < epsilon && - Math.abs(u.y - v.y) < epsilon && - Math.abs(u.z - v.z) < epsilon && - Math.abs(u.w - v.w) < epsilon) || - (Math.abs(u.x + v.x) < epsilon && - Math.abs(u.y + v.y) < epsilon && - Math.abs(u.z + v.z) < epsilon && - Math.abs(u.w + v.w) < epsilon) - ); -} - -let AmmoBody = { - schema: { - loadedEvent: { default: "" }, - mass: { default: 1 }, - gravity: { type: "vec3", default: { x: 0, y: -9.8, z: 0 } }, - linearDamping: { default: 0.01 }, - angularDamping: { default: 0.01 }, - linearSleepingThreshold: { default: 1.6 }, - angularSleepingThreshold: { default: 2.5 }, - angularFactor: { type: "vec3", default: { x: 1, y: 1, z: 1 } }, - activationState: { - default: ACTIVATION_STATE.ACTIVE_TAG, - oneOf: ACTIVATION_STATES - }, - type: { default: "dynamic", oneOf: [TYPE.STATIC, TYPE.DYNAMIC, TYPE.KINEMATIC] }, - emitCollisionEvents: { default: false }, - disableCollision: { default: false }, - collisionFilterGroup: { default: 1 }, //32-bit mask, - collisionFilterMask: { default: 1 }, //32-bit mask - scaleAutoUpdate: { default: true }, - restitution: {default: 0} // does not support updates - }, - - /** - * Initializes a body component, assigning it to the physics system and binding listeners for - * parsing the elements geometry. - */ - init: function() { - this.system = this.el.sceneEl.systems.physics; - this.shapeComponents = []; - - if (this.data.loadedEvent === "") { - this.loadedEventFired = true; - } else { - this.el.addEventListener( - this.data.loadedEvent, - () => { - this.loadedEventFired = true; - }, - { once: true } - ); - } - - if (this.system.initialized && this.loadedEventFired) { - this.initBody(); - } - }, - - /** - * Parses an element's geometry and component metadata to create an Ammo body instance for the - * component. - */ - initBody: (function() { - const pos = new THREE.Vector3(); - const quat = new THREE.Quaternion(); - const boundingBox = new THREE.Box3(); - - return function() { - const el = this.el, - data = this.data; - const clamp = (num, min, max) => Math.min(Math.max(num, min), max) - - this.localScaling = new Ammo.btVector3(); - - const obj = this.el.object3D; - obj.getWorldPosition(pos); - obj.getWorldQuaternion(quat); - - this.prevScale = new THREE.Vector3(1, 1, 1); - this.prevNumChildShapes = 0; - - this.msTransform = new Ammo.btTransform(); - this.msTransform.setIdentity(); - this.rotation = new Ammo.btQuaternion(quat.x, quat.y, quat.z, quat.w); - - this.msTransform.getOrigin().setValue(pos.x, pos.y, pos.z); - this.msTransform.setRotation(this.rotation); - - this.motionState = new Ammo.btDefaultMotionState(this.msTransform); - - this.localInertia = new Ammo.btVector3(0, 0, 0); - - this.compoundShape = new Ammo.btCompoundShape(true); - - this.rbInfo = new Ammo.btRigidBodyConstructionInfo( - data.mass, - this.motionState, - this.compoundShape, - this.localInertia - ); - this.rbInfo.m_restitution = clamp(this.data.restitution, 0, 1); - this.body = new Ammo.btRigidBody(this.rbInfo); - this.body.setActivationState(ACTIVATION_STATES.indexOf(data.activationState) + 1); - this.body.setSleepingThresholds(data.linearSleepingThreshold, data.angularSleepingThreshold); - - this.body.setDamping(data.linearDamping, data.angularDamping); - - const angularFactor = new Ammo.btVector3(data.angularFactor.x, data.angularFactor.y, data.angularFactor.z); - this.body.setAngularFactor(angularFactor); - Ammo.destroy(angularFactor); - - const gravity = new Ammo.btVector3(data.gravity.x, data.gravity.y, data.gravity.z); - if (!almostEqualsBtVector3(0.001, gravity, this.system.driver.physicsWorld.getGravity())) { - this.body.setGravity(gravity); - this.body.setFlags(RIGID_BODY_FLAGS.DISABLE_WORLD_GRAVITY); - } - Ammo.destroy(gravity); - - this.updateCollisionFlags(); - - this.el.body = this.body; - this.body.el = el; - - this.isLoaded = true; - - this.el.emit("body-loaded", { body: this.el.body }); - - this._addToSystem(); - }; - })(), - - tick: function() { - if (this.system.initialized && !this.isLoaded && this.loadedEventFired) { - this.initBody(); - } - }, - - _updateShapes: (function() { - const needsPolyhedralInitialization = [SHAPE.HULL, SHAPE.HACD, SHAPE.VHACD]; - return function() { - let updated = false; - - const obj = this.el.object3D; - if (this.data.scaleAutoUpdate && this.prevScale && !almostEqualsVector3(0.001, obj.scale, this.prevScale)) { - this.prevScale.copy(obj.scale); - updated = true; - - this.localScaling.setValue(this.prevScale.x, this.prevScale.y, this.prevScale.z); - this.compoundShape.setLocalScaling(this.localScaling); - } - - if (this.shapeComponentsChanged) { - this.shapeComponentsChanged = false; - updated = true; - for (let i = 0; i < this.shapeComponents.length; i++) { - const shapeComponent = this.shapeComponents[i]; - if (shapeComponent.getShapes().length === 0) { - this._createCollisionShape(shapeComponent); - } - const collisionShapes = shapeComponent.getShapes(); - for (let j = 0; j < collisionShapes.length; j++) { - const collisionShape = collisionShapes[j]; - if (!collisionShape.added) { - this.compoundShape.addChildShape(collisionShape.localTransform, collisionShape); - collisionShape.added = true; - } - } - } - - if (this.data.type === TYPE.DYNAMIC) { - this.updateMass(); - } - - this.system.driver.updateBody(this.body); - } - - //call initializePolyhedralFeatures for hull shapes if debug is turned on and/or scale changes - if (this.system.debug && (updated || !this.polyHedralFeaturesInitialized)) { - for (let i = 0; i < this.shapeComponents.length; i++) { - const collisionShapes = this.shapeComponents[i].getShapes(); - for (let j = 0; j < collisionShapes.length; j++) { - const collisionShape = collisionShapes[j]; - if (needsPolyhedralInitialization.indexOf(collisionShape.type) !== -1) { - collisionShape.initializePolyhedralFeatures(0); - } - } - } - this.polyHedralFeaturesInitialized = true; - } - }; - })(), - - _createCollisionShape: function(shapeComponent) { - const data = shapeComponent.data; - const collisionShapes = threeToAmmo.createCollisionShapes(shapeComponent.getMesh(), data); - shapeComponent.addShapes(collisionShapes); - return; - }, - - /** - * Registers the component with the physics system. - */ - play: function() { - if (this.isLoaded) { - this._addToSystem(); - } - }, - - _addToSystem: function() { - if (!this.addedToSystem) { - this.system.addBody(this.body, this.data.collisionFilterGroup, this.data.collisionFilterMask); - - if (this.data.emitCollisionEvents) { - this.system.driver.addEventListener(this.body); - } - - this.system.addComponent(this); - this.addedToSystem = true; - } - }, - - /** - * Unregisters the component with the physics system. - */ - pause: function() { - if (this.addedToSystem) { - this.system.removeComponent(this); - this.system.removeBody(this.body); - this.addedToSystem = false; - } - }, - - /** - * Updates the rigid body instance, where possible. - */ - update: function(prevData) { - if (this.isLoaded) { - if (!this.hasUpdated) { - //skip the first update - this.hasUpdated = true; - return; - } - - const data = this.data; - - if (prevData.type !== data.type || prevData.disableCollision !== data.disableCollision) { - this.updateCollisionFlags(); - } - - if (prevData.activationState !== data.activationState) { - this.body.forceActivationState(ACTIVATION_STATES.indexOf(data.activationState) + 1); - if (data.activationState === ACTIVATION_STATE.ACTIVE_TAG) { - this.body.activate(true); - } - } - - if ( - prevData.collisionFilterGroup !== data.collisionFilterGroup || - prevData.collisionFilterMask !== data.collisionFilterMask - ) { - const broadphaseProxy = this.body.getBroadphaseProxy(); - broadphaseProxy.set_m_collisionFilterGroup(data.collisionFilterGroup); - broadphaseProxy.set_m_collisionFilterMask(data.collisionFilterMask); - this.system.driver.broadphase - .getOverlappingPairCache() - .removeOverlappingPairsContainingProxy(broadphaseProxy, this.system.driver.dispatcher); - } - - if (prevData.linearDamping != data.linearDamping || prevData.angularDamping != data.angularDamping) { - this.body.setDamping(data.linearDamping, data.angularDamping); - } - - if (!almostEqualsVector3(0.001, prevData.gravity, data.gravity)) { - const gravity = new Ammo.btVector3(data.gravity.x, data.gravity.y, data.gravity.z); - if (!almostEqualsBtVector3(0.001, gravity, this.system.driver.physicsWorld.getGravity())) { - this.body.setFlags(RIGID_BODY_FLAGS.DISABLE_WORLD_GRAVITY); - } else { - this.body.setFlags(RIGID_BODY_FLAGS.NONE); - } - this.body.setGravity(gravity); - Ammo.destroy(gravity); - } - - if ( - prevData.linearSleepingThreshold != data.linearSleepingThreshold || - prevData.angularSleepingThreshold != data.angularSleepingThreshold - ) { - this.body.setSleepingThresholds(data.linearSleepingThreshold, data.angularSleepingThreshold); - } - - if (!almostEqualsVector3(0.001, prevData.angularFactor, data.angularFactor)) { - const angularFactor = new Ammo.btVector3(data.angularFactor.x, data.angularFactor.y, data.angularFactor.z); - this.body.setAngularFactor(angularFactor); - Ammo.destroy(angularFactor); - } - - if (prevData.restitution != data.restitution ) { - console.warn("ammo-body restitution cannot be updated from its initial value.") - } - - //TODO: support dynamic update for other properties - } - }, - - /** - * Removes the component and all physics and scene side effects. - */ - remove: function() { - if (this.triMesh) Ammo.destroy(this.triMesh); - if (this.localScaling) Ammo.destroy(this.localScaling); - if (this.compoundShape) Ammo.destroy(this.compoundShape); - if (this.body) { - Ammo.destroy(this.body); - delete this.body; - } - Ammo.destroy(this.rbInfo); - Ammo.destroy(this.msTransform); - Ammo.destroy(this.motionState); - Ammo.destroy(this.localInertia); - Ammo.destroy(this.rotation); - }, - - beforeStep: function() { - this._updateShapes(); - // Note that since static objects don't move, - // we don't sync them to physics on a routine basis. - if (this.data.type === TYPE.KINEMATIC) { - this.syncToPhysics(); - } - }, - - step: function() { - if (this.data.type === TYPE.DYNAMIC) { - this.syncFromPhysics(); - } - }, - - /** - * Updates the rigid body's position, velocity, and rotation, based on the scene. - */ - syncToPhysics: (function() { - const q = new THREE.Quaternion(); - const v = new THREE.Vector3(); - const q2 = new THREE.Vector3(); - const v2 = new THREE.Vector3(); - return function() { - const el = this.el, - parentEl = el.parentEl, - body = this.body; - - if (!body) return; - - this.motionState.getWorldTransform(this.msTransform); - - if (parentEl.isScene) { - v.copy(el.object3D.position); - q.copy(el.object3D.quaternion); - } else { - el.object3D.getWorldPosition(v); - el.object3D.getWorldQuaternion(q); - } - - const position = this.msTransform.getOrigin(); - v2.set(position.x(), position.y(), position.z()); - - const quaternion = this.msTransform.getRotation(); - q2.set(quaternion.x(), quaternion.y(), quaternion.z(), quaternion.w()); - - if (!almostEqualsVector3(0.001, v, v2) || !almostEqualsQuaternion(0.001, q, q2)) { - if (!this.body.isActive()) { - this.body.activate(true); - } - this.msTransform.getOrigin().setValue(v.x, v.y, v.z); - this.rotation.setValue(q.x, q.y, q.z, q.w); - this.msTransform.setRotation(this.rotation); - this.motionState.setWorldTransform(this.msTransform); - - if (this.data.type === TYPE.STATIC) { - this.body.setCenterOfMassTransform(this.msTransform); - } - } - }; - })(), - - /** - * Updates the scene object's position and rotation, based on the physics simulation. - */ - syncFromPhysics: (function() { - const v = new THREE.Vector3(), - q1 = new THREE.Quaternion(), - q2 = new THREE.Quaternion(); - return function() { - this.motionState.getWorldTransform(this.msTransform); - const position = this.msTransform.getOrigin(); - const quaternion = this.msTransform.getRotation(); - - const el = this.el, - body = this.body; - - // For the parent, prefer to use the THHREE.js scene graph parent (if it can be determined) - // and only use the HTML scene graph parent as a fallback. - // Usually these are the same, but there are various cases where it's useful to modify the THREE.js - // scene graph so that it deviates from the HTML. - // In these cases the THREE.js scene graph should be considered the definitive reference in terms - // of object positioning etc. - // For specific examples, and more discussion, see: - // https://github.com/c-frame/aframe-physics-system/pull/1#issuecomment-1264686433 - const parentEl = el.object3D.parent.el ? el.object3D.parent.el : el.parentEl; - - if (!body) return; - if (!parentEl) return; - - if (parentEl.isScene) { - el.object3D.position.set(position.x(), position.y(), position.z()); - el.object3D.quaternion.set(quaternion.x(), quaternion.y(), quaternion.z(), quaternion.w()); - } else { - q1.set(quaternion.x(), quaternion.y(), quaternion.z(), quaternion.w()); - parentEl.object3D.getWorldQuaternion(q2); - q1.multiply(q2.invert()); - el.object3D.quaternion.copy(q1); - - v.set(position.x(), position.y(), position.z()); - parentEl.object3D.worldToLocal(v); - el.object3D.position.copy(v); - } - }; - })(), - - addShapeComponent: function(shapeComponent) { - if (shapeComponent.data.type === SHAPE.MESH && this.data.type !== TYPE.STATIC) { - console.warn("non-static mesh colliders not supported"); - return; - } - - this.shapeComponents.push(shapeComponent); - this.shapeComponentsChanged = true; - }, - - removeShapeComponent: function(shapeComponent) { - const index = this.shapeComponents.indexOf(shapeComponent); - if (this.compoundShape && index !== -1 && this.body) { - const shapes = shapeComponent.getShapes(); - for (var i = 0; i < shapes.length; i++) { - this.compoundShape.removeChildShape(shapes[i]); - } - this.shapeComponentsChanged = true; - this.shapeComponents.splice(index, 1); - } - }, - - updateMass: function() { - const shape = this.body.getCollisionShape(); - const mass = this.data.type === TYPE.DYNAMIC ? this.data.mass : 0; - shape.calculateLocalInertia(mass, this.localInertia); - this.body.setMassProps(mass, this.localInertia); - this.body.updateInertiaTensor(); - }, - - updateCollisionFlags: function() { - let flags = this.data.disableCollision ? 4 : 0; - switch (this.data.type) { - case TYPE.STATIC: - flags |= COLLISION_FLAG.STATIC_OBJECT; - break; - case TYPE.KINEMATIC: - flags |= COLLISION_FLAG.KINEMATIC_OBJECT; - break; - default: - this.body.applyGravity(); - break; - } - this.body.setCollisionFlags(flags); - - this.updateMass(); - - // TODO: enable CCD if dynamic? - // this.body.setCcdMotionThreshold(0.001); - // this.body.setCcdSweptSphereRadius(0.001); - - this.system.driver.updateBody(this.body); - }, - - getVelocity: function() { - return this.body.getLinearVelocity(); - } -}; - -module.exports.definition = AmmoBody; -module.exports.Component = AFRAME.registerComponent("ammo-body", AmmoBody); +/***/ "./src/drivers/webworkify-debug.js": +/*!*****************************************!*\ + !*** ./src/drivers/webworkify-debug.js ***! + \*****************************************/ +/***/ ((module) => { -},{"../../constants":20,"ammo-debug-drawer":4,"three-to-ammo":6}],11:[function(require,module,exports){ -var CANNON = require('cannon-es'); -const { threeToCannon, ShapeType } = require('three-to-cannon'); -const identityQuaternion = new THREE.Quaternion() - -function mesh2shape (object, options) { - - const result = threeToCannon(object, options); - return result; -} - -require('../../../lib/CANNON-shape2mesh'); - -var Body = { - dependencies: ['velocity'], - - schema: { - mass: {default: 5, if: {type: 'dynamic'}}, - linearDamping: { default: 0.01, if: {type: 'dynamic'}}, - angularDamping: { default: 0.01, if: {type: 'dynamic'}}, - shape: {default: 'auto', oneOf: ['auto', 'box', 'cylinder', 'sphere', 'hull', 'mesh', 'none']}, - cylinderAxis: {default: 'y', oneOf: ['x', 'y', 'z']}, - sphereRadius: {default: NaN}, - type: {default: 'dynamic', oneOf: ['static', 'dynamic']} - }, - - /** - * Initializes a body component, assigning it to the physics system and binding listeners for - * parsing the elements geometry. - */ - init: function () { - this.system = this.el.sceneEl.systems.physics; - - if (this.el.sceneEl.hasLoaded) { - this.initBody(); - } else { - this.el.sceneEl.addEventListener('loaded', this.initBody.bind(this)); - } - }, - - /** - * Parses an element's geometry and component metadata to create a CANNON.Body instance for the - * component. - */ - initBody: function () { - var el = this.el, - data = this.data; - - var obj = this.el.object3D; - var pos = obj.position; - var quat = obj.quaternion; - - this.body = new CANNON.Body({ - mass: data.type === 'static' ? 0 : data.mass || 0, - material: this.system.getMaterial('defaultMaterial'), - position: new CANNON.Vec3(pos.x, pos.y, pos.z), - quaternion: new CANNON.Quaternion(quat.x, quat.y, quat.z, quat.w), - linearDamping: data.linearDamping, - angularDamping: data.angularDamping, - type: data.type === 'dynamic' ? CANNON.Body.DYNAMIC : CANNON.Body.STATIC, - }); - - // Matrix World must be updated at root level, if scale is to be applied – updateMatrixWorld() - // only checks an object's parent, not the rest of the ancestors. Hence, a wrapping entity with - // scale="0.5 0.5 0.5" will be ignored. - // Reference: https://github.com/mrdoob/three.js/blob/master/src/core/Object3D.js#L511-L541 - // Potential fix: https://github.com/mrdoob/three.js/pull/7019 - this.el.object3D.updateMatrixWorld(true); - - if(data.shape !== 'none') { - var options = data.shape === 'auto' ? undefined : AFRAME.utils.extend({}, this.data, { - type: ShapeType[data.shape.toUpperCase()] - }); - - var { shape, offset, orientation } = mesh2shape(this.el.object3D, options); - - if (!shape) { - el.addEventListener('object3dset', this.initBody.bind(this)); - return; - } - this.body.addShape(shape, offset, orientation); - - // Show wireframe - if (this.system.debug) { - this.shouldUpdateWireframe = true; - } - - this.isLoaded = true; - } - - this.el.body = this.body; - this.body.el = el; - - // If component wasn't initialized when play() was called, finish up. - if (this.isPlaying) { - this._play(); - } - - if (this.isLoaded) { - this.el.emit('body-loaded', {body: this.el.body}); - } - }, - - addShape: function(shape, offset, orientation) { - if (this.data.shape !== 'none') { - console.warn('shape can only be added if shape property is none'); - return; - } - - if (!shape) { - console.warn('shape cannot be null'); - return; - } - - if (!this.body) { - console.warn('shape cannot be added before body is loaded'); - return; - } - this.body.addShape(shape, offset, orientation); - - if (this.system.debug) { - this.shouldUpdateWireframe = true; - } - - this.shouldUpdateBody = true; - }, - - tick: function () { - if (this.shouldUpdateBody) { - this.isLoaded = true; - - this._play(); - - this.el.emit('body-loaded', {body: this.el.body}); - this.shouldUpdateBody = false; - } - - if (this.shouldUpdateWireframe) { - this.createWireframe(this.body); - this.shouldUpdateWireframe = false; - } - }, - - /** - * Registers the component with the physics system, if ready. - */ - play: function () { - if (this.isLoaded) this._play(); - }, - - /** - * Internal helper to register component with physics system. - */ - _play: function () { - this.syncToPhysics(); - this.system.addComponent(this); - this.system.addBody(this.body); - if (this.wireframe) this.el.sceneEl.object3D.add(this.wireframe); - }, - - /** - * Unregisters the component with the physics system. - */ - pause: function () { - if (this.isLoaded) this._pause(); - }, - - _pause: function () { - this.system.removeComponent(this); - if (this.body) this.system.removeBody(this.body); - if (this.wireframe) this.el.sceneEl.object3D.remove(this.wireframe); - }, - - /** - * Updates the CANNON.Body instance, where possible. - */ - update: function (prevData) { - if (!this.body) return; - - var data = this.data; - - if (prevData.type != undefined && data.type != prevData.type) { - this.body.type = data.type === 'dynamic' ? CANNON.Body.DYNAMIC : CANNON.Body.STATIC; - } - - this.body.mass = data.mass || 0; - if (data.type === 'dynamic') { - this.body.linearDamping = data.linearDamping; - this.body.angularDamping = data.angularDamping; - } - if (data.mass !== prevData.mass) { - this.body.updateMassProperties(); - } - if (this.body.updateProperties) this.body.updateProperties(); - }, - - /** - * Removes the component and all physics and scene side effects. - */ - remove: function () { - if (this.body) { - delete this.body.el; - delete this.body; - } - delete this.el.body; - delete this.wireframe; - }, - - beforeStep: function () { - if (this.body.mass === 0) { - this.syncToPhysics(); - } - }, - - step: function () { - if (this.body.mass !== 0) { - this.syncFromPhysics(); - } - }, - - /** - * Creates a wireframe for the body, for debugging. - * TODO(donmccurdy) – Refactor this into a standalone utility or component. - * @param {CANNON.Body} body - * @param {CANNON.Shape} shape - */ - createWireframe: function (body) { - if (this.wireframe) { - this.el.sceneEl.object3D.remove(this.wireframe); - delete this.wireframe; - } - this.wireframe = new THREE.Object3D(); - this.el.sceneEl.object3D.add(this.wireframe); - - var offset, mesh; - var orientation = new THREE.Quaternion(); - for (var i = 0; i < this.body.shapes.length; i++) - { - offset = this.body.shapeOffsets[i], - orientation.copy(this.body.shapeOrientations[i]), - mesh = CANNON.shape2mesh(this.body).children[i]; - - var wireframe = new THREE.LineSegments( - new THREE.EdgesGeometry(mesh.geometry), - new THREE.LineBasicMaterial({color: 0xff0000}) - ); - - if (offset) { - wireframe.position.copy(offset); - } - - if (orientation) { - wireframe.quaternion.copy(orientation); - } - - this.wireframe.add(wireframe); - } - - this.syncWireframe(); - }, - - /** - * Updates the debugging wireframe's position and rotation. - */ - syncWireframe: function () { - var offset, - wireframe = this.wireframe; - - if (!this.wireframe) return; - - // Apply rotation. If the shape required custom orientation, also apply - // that on the wireframe. - wireframe.quaternion.copy(this.body.quaternion); - if (wireframe.orientation) { - wireframe.quaternion.multiply(wireframe.orientation); - } - - // Apply position. If the shape required custom offset, also apply that on - // the wireframe. - wireframe.position.copy(this.body.position); - if (wireframe.offset) { - offset = wireframe.offset.clone().applyQuaternion(wireframe.quaternion); - wireframe.position.add(offset); - } - - wireframe.updateMatrix(); - }, - - /** - * Updates the CANNON.Body instance's position, velocity, and rotation, based on the scene. - */ - syncToPhysics: (function () { - var q = new THREE.Quaternion(), - v = new THREE.Vector3(); - return function () { - var el = this.el, - parentEl = el.parentEl, - body = this.body; - - if (!body) return; - - if (el.components.velocity) body.velocity.copy(el.getAttribute('velocity')); - - if (parentEl.isScene) { - body.quaternion.copy(el.object3D.quaternion); - body.position.copy(el.object3D.position); - } else { - el.object3D.getWorldQuaternion(q); - body.quaternion.copy(q); - el.object3D.getWorldPosition(v); - body.position.copy(v); - } - - if (this.body.updateProperties) this.body.updateProperties(); - if (this.wireframe) this.syncWireframe(); - }; - }()), - - /** - * Updates the scene object's position and rotation, based on the physics simulation. - */ - syncFromPhysics: (function () { - var v = new THREE.Vector3(), - q1 = new THREE.Quaternion(), - q2 = new THREE.Quaternion(); - return function () { - var el = this.el, - parentEl = el.parentEl, - body = this.body; - - if (!body) return; - if (!parentEl) return; - - if (parentEl.isScene) { - el.object3D.quaternion.copy(body.quaternion); - el.object3D.position.copy(body.position); - } else { - q1.copy(body.quaternion); - parentEl.object3D.getWorldQuaternion(q2); - q1.premultiply(q2.invert()); - el.object3D.quaternion.copy(q1); - - v.copy(body.position); - parentEl.object3D.worldToLocal(v); - el.object3D.position.copy(v); - } - - if (this.wireframe) this.syncWireframe(); - }; - }()) -}; - -module.exports.definition = Body; -module.exports.Component = AFRAME.registerComponent('body', Body); +eval("/**\r\n * Stub version of webworkify, for debugging code outside of a webworker.\r\n */\r\nfunction webworkifyDebug (worker) {\r\n var targetA = new EventTarget(),\r\n targetB = new EventTarget();\r\n\r\n targetA.setTarget(targetB);\r\n targetB.setTarget(targetA);\r\n\r\n worker(targetA);\r\n return targetB;\r\n}\r\n\r\nmodule.exports = webworkifyDebug;\r\n\r\n/******************************************************************************\r\n * EventTarget\r\n */\r\n\r\nfunction EventTarget () {\r\n this.listeners = [];\r\n}\r\n\r\nEventTarget.prototype.setTarget = function (target) {\r\n this.target = target;\r\n};\r\n\r\nEventTarget.prototype.addEventListener = function (type, fn) {\r\n this.listeners.push(fn);\r\n};\r\n\r\nEventTarget.prototype.dispatchEvent = function (type, event) {\r\n for (var i = 0; i < this.listeners.length; i++) {\r\n this.listeners[i](event);\r\n }\r\n};\r\n\r\nEventTarget.prototype.postMessage = function (msg) {\r\n this.target.dispatchEvent('message', {data: msg});\r\n};\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/drivers/webworkify-debug.js?"); -},{"../../../lib/CANNON-shape2mesh":2,"cannon-es":5,"three-to-cannon":7}],12:[function(require,module,exports){ -var Body = require('./body'); - -/** - * Dynamic body. - * - * Moves according to physics simulation, and may collide with other objects. - */ -var DynamicBody = AFRAME.utils.extend({}, Body.definition); - -module.exports = AFRAME.registerComponent('dynamic-body', DynamicBody); +/***/ }), -},{"./body":11}],13:[function(require,module,exports){ -var Body = require('./body'); - -/** - * Static body. - * - * Solid body with a fixed position. Unaffected by gravity and collisions, but - * other objects may collide with it. - */ -var StaticBody = AFRAME.utils.extend({}, Body.definition); - -StaticBody.schema = AFRAME.utils.extend({}, Body.definition.schema, { - type: {default: 'static', oneOf: ['static', 'dynamic']}, - mass: {default: 0} -}); - -module.exports = AFRAME.registerComponent('static-body', StaticBody); +/***/ "./src/drivers/worker-driver.js": +/*!**************************************!*\ + !*** ./src/drivers/worker-driver.js ***! + \**************************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { -},{"./body":11}],14:[function(require,module,exports){ -var CANNON = require("cannon-es"); - -module.exports = AFRAME.registerComponent("constraint", { - multiple: true, - - schema: { - // Type of constraint. - type: { default: "lock", oneOf: ["coneTwist", "distance", "hinge", "lock", "pointToPoint"] }, - - // Target (other) body for the constraint. - target: { type: "selector" }, - - // Maximum force that should be applied to constraint the bodies. - maxForce: { default: 1e6, min: 0 }, - - // If true, bodies can collide when they are connected. - collideConnected: { default: true }, - - // Wake up bodies when connected. - wakeUpBodies: { default: true }, - - // The distance to be kept between the bodies. If 0, will be set to current distance. - distance: { default: 0, min: 0 }, - - // Offset of the hinge or point-to-point constraint, defined locally in the body. - pivot: { type: "vec3" }, - targetPivot: { type: "vec3" }, - - // An axis that each body can rotate around, defined locally to that body. - axis: { type: "vec3", default: { x: 0, y: 0, z: 1 } }, - targetAxis: { type: "vec3", default: { x: 0, y: 0, z: 1 } } - }, - - init: function() { - this.system = this.el.sceneEl.systems.physics; - this.constraint = /* {CANNON.Constraint} */ null; - }, - - remove: function() { - if (!this.constraint) return; - - this.system.removeConstraint(this.constraint); - this.constraint = null; - }, - - update: function() { - var el = this.el, - data = this.data; - - this.remove(); - - if (!el.body || !data.target.body) { - (el.body ? data.target : el).addEventListener("body-loaded", this.update.bind(this, {})); - return; - } - - this.constraint = this.createConstraint(); - this.system.addConstraint(this.constraint); - }, - - /** - * Creates a new constraint, given current component data. The CANNON.js constructors are a bit - * different for each constraint type. A `.type` property is added to each constraint, because - * `instanceof` checks are not reliable for some types. These types are needed for serialization. - * @return {CANNON.Constraint} - */ - createConstraint: function() { - var constraint, - data = this.data, - pivot = new CANNON.Vec3(data.pivot.x, data.pivot.y, data.pivot.z), - targetPivot = new CANNON.Vec3(data.targetPivot.x, data.targetPivot.y, data.targetPivot.z), - axis = new CANNON.Vec3(data.axis.x, data.axis.y, data.axis.z), - targetAxis = new CANNON.Vec3(data.targetAxis.x, data.targetAxis.y, data.targetAxis.z); - - var constraint; - - switch (data.type) { - case "lock": - constraint = new CANNON.LockConstraint(this.el.body, data.target.body, { maxForce: data.maxForce }); - constraint.type = "LockConstraint"; - break; - - case "distance": - constraint = new CANNON.DistanceConstraint(this.el.body, data.target.body, data.distance, data.maxForce); - constraint.type = "DistanceConstraint"; - break; - - case "hinge": - constraint = new CANNON.HingeConstraint(this.el.body, data.target.body, { - pivotA: pivot, - pivotB: targetPivot, - axisA: axis, - axisB: targetAxis, - maxForce: data.maxForce - }); - constraint.type = "HingeConstraint"; - break; - - case "coneTwist": - constraint = new CANNON.ConeTwistConstraint(this.el.body, data.target.body, { - pivotA: pivot, - pivotB: targetPivot, - axisA: axis, - axisB: targetAxis, - maxForce: data.maxForce - }); - constraint.type = "ConeTwistConstraint"; - break; - - case "pointToPoint": - constraint = new CANNON.PointToPointConstraint( - this.el.body, - pivot, - data.target.body, - targetPivot, - data.maxForce - ); - constraint.type = "PointToPointConstraint"; - break; - - default: - throw new Error("[constraint] Unexpected type: " + data.type); - } - - constraint.collideConnected = data.collideConnected; - return constraint; - } -}); +eval("/* global performance */\r\n\r\nvar webworkify = __webpack_require__(/*! webworkify-webpack */ \"./node_modules/webworkify-webpack/index.js\"),\r\n webworkifyDebug = __webpack_require__(/*! ./webworkify-debug */ \"./src/drivers/webworkify-debug.js\"),\r\n Driver = __webpack_require__(/*! ./driver */ \"./src/drivers/driver.js\"),\r\n Event = __webpack_require__(/*! ./event */ \"./src/drivers/event.js\"),\r\n worker = __webpack_require__(/*! ./worker */ \"./src/drivers/worker.js\"),\r\n protocol = __webpack_require__(/*! ../utils/protocol */ \"./src/utils/protocol.js\");\r\n\r\nvar ID = protocol.ID;\r\n\r\n/******************************************************************************\r\n * Constructor\r\n */\r\n\r\nfunction WorkerDriver (options) {\r\n this.fps = options.fps;\r\n this.engine = options.engine;\r\n this.interpolate = options.interpolate;\r\n // Approximate number of physics steps to 'pad' rendering.\r\n this.interpBufferSize = options.interpolationBufferSize;\r\n this.debug = options.debug;\r\n\r\n this.bodies = {};\r\n this.contacts = [];\r\n\r\n // https://gafferongames.com/post/snapshot_interpolation/\r\n this.frameDelay = this.interpBufferSize * 1000 / this.fps;\r\n this.frameBuffer = [];\r\n\r\n this.worker = this.debug\r\n ? webworkifyDebug(worker)\r\n : webworkify(worker);\r\n this.worker.addEventListener('message', this._onMessage.bind(this));\r\n}\r\n\r\nWorkerDriver.prototype = new Driver();\r\nWorkerDriver.prototype.constructor = WorkerDriver;\r\n\r\nmodule.exports = WorkerDriver;\r\n\r\n/******************************************************************************\r\n * Lifecycle\r\n */\r\n\r\n/* @param {object} worldConfig */\r\nWorkerDriver.prototype.init = function (worldConfig) {\r\n this.worker.postMessage({\r\n type: Event.INIT,\r\n worldConfig: worldConfig,\r\n fps: this.fps,\r\n engine: this.engine\r\n });\r\n};\r\n\r\n/**\r\n * Increments the physics world forward one step, if interpolation is enabled.\r\n * If disabled, increments are performed as messages arrive.\r\n * @param {number} deltaMS\r\n */\r\nWorkerDriver.prototype.step = function () {\r\n if (!this.interpolate) return;\r\n\r\n // Get the two oldest frames that haven't expired. Ideally we would use all\r\n // available frames to keep things smooth, but lerping is easier and faster.\r\n var prevFrame = this.frameBuffer[0];\r\n var nextFrame = this.frameBuffer[1];\r\n var timestamp = performance.now();\r\n while (prevFrame && nextFrame && timestamp - prevFrame.timestamp > this.frameDelay) {\r\n this.frameBuffer.shift();\r\n prevFrame = this.frameBuffer[0];\r\n nextFrame = this.frameBuffer[1];\r\n }\r\n\r\n if (!prevFrame || !nextFrame) return;\r\n\r\n var mix = (timestamp - prevFrame.timestamp) / this.frameDelay;\r\n mix = (mix - (1 - 1 / this.interpBufferSize)) * this.interpBufferSize;\r\n\r\n for (var id in prevFrame.bodies) {\r\n if (prevFrame.bodies.hasOwnProperty(id) && nextFrame.bodies.hasOwnProperty(id)) {\r\n protocol.deserializeInterpBodyUpdate(\r\n prevFrame.bodies[id],\r\n nextFrame.bodies[id],\r\n this.bodies[id],\r\n mix\r\n );\r\n }\r\n }\r\n};\r\n\r\nWorkerDriver.prototype.destroy = function () {\r\n this.worker.terminate();\r\n delete this.worker;\r\n};\r\n\r\n/** {Event} event */\r\nWorkerDriver.prototype._onMessage = function (event) {\r\n if (event.data.type === Event.STEP) {\r\n var data = event.data,\r\n bodies = data.bodies;\r\n\r\n this.contacts = event.data.contacts;\r\n\r\n // If interpolation is enabled, store the frame. If not, update all bodies\r\n // immediately.\r\n if (this.interpolate) {\r\n this.frameBuffer.push({timestamp: performance.now(), bodies: bodies});\r\n } else {\r\n for (var id in bodies) {\r\n if (bodies.hasOwnProperty(id)) {\r\n protocol.deserializeBodyUpdate(bodies[id], this.bodies[id]);\r\n }\r\n }\r\n }\r\n\r\n } else if (event.data.type === Event.COLLIDE) {\r\n var body = this.bodies[event.data.bodyID];\r\n var target = this.bodies[event.data.targetID];\r\n var contact = protocol.deserializeContact(event.data.contact, this.bodies);\r\n if (!body._listeners || !body._listeners.collide) return;\r\n for (var i = 0; i < body._listeners.collide.length; i++) {\r\n body._listeners.collide[i]({target: target, body: body, contact: contact});\r\n }\r\n\r\n } else {\r\n throw new Error('[WorkerDriver] Unexpected message type.');\r\n }\r\n};\r\n\r\n/******************************************************************************\r\n * Bodies\r\n */\r\n\r\n/* @param {CANNON.Body} body */\r\nWorkerDriver.prototype.addBody = function (body) {\r\n protocol.assignID('body', body);\r\n this.bodies[body[ID]] = body;\r\n this.worker.postMessage({type: Event.ADD_BODY, body: protocol.serializeBody(body)});\r\n};\r\n\r\n/* @param {CANNON.Body} body */\r\nWorkerDriver.prototype.removeBody = function (body) {\r\n this.worker.postMessage({type: Event.REMOVE_BODY, bodyID: body[ID]});\r\n delete this.bodies[body[ID]];\r\n};\r\n\r\n/**\r\n * @param {CANNON.Body} body\r\n * @param {string} methodName\r\n * @param {Array} args\r\n */\r\nWorkerDriver.prototype.applyBodyMethod = function (body, methodName, args) {\r\n switch (methodName) {\r\n case 'applyForce':\r\n case 'applyImpulse':\r\n this.worker.postMessage({\r\n type: Event.APPLY_BODY_METHOD,\r\n bodyID: body[ID],\r\n methodName: methodName,\r\n args: [args[0].toArray(), args[1].toArray()]\r\n });\r\n break;\r\n default:\r\n throw new Error('Unexpected methodName: %s', methodName);\r\n }\r\n};\r\n\r\n/** @param {CANNON.Body} body */\r\nWorkerDriver.prototype.updateBodyProperties = function (body) {\r\n this.worker.postMessage({\r\n type: Event.UPDATE_BODY_PROPERTIES,\r\n body: protocol.serializeBody(body)\r\n });\r\n};\r\n\r\n/******************************************************************************\r\n * Materials\r\n */\r\n\r\n/**\r\n * @param {string} name\r\n * @return {CANNON.Material}\r\n */\r\nWorkerDriver.prototype.getMaterial = function (name) {\r\n // No access to materials here. Eventually we might return the name or ID, if\r\n // multiple materials were selected, but for now there's only one and it's safe\r\n // to assume the worker is already using it.\r\n return undefined;\r\n};\r\n\r\n/** @param {object} materialConfig */\r\nWorkerDriver.prototype.addMaterial = function (materialConfig) {\r\n this.worker.postMessage({type: Event.ADD_MATERIAL, materialConfig: materialConfig});\r\n};\r\n\r\n/**\r\n * @param {string} matName1\r\n * @param {string} matName2\r\n * @param {object} contactMaterialConfig\r\n */\r\nWorkerDriver.prototype.addContactMaterial = function (matName1, matName2, contactMaterialConfig) {\r\n this.worker.postMessage({\r\n type: Event.ADD_CONTACT_MATERIAL,\r\n materialName1: matName1,\r\n materialName2: matName2,\r\n contactMaterialConfig: contactMaterialConfig\r\n });\r\n};\r\n\r\n/******************************************************************************\r\n * Constraints\r\n */\r\n\r\n/* @param {CANNON.Constraint} constraint */\r\nWorkerDriver.prototype.addConstraint = function (constraint) {\r\n if (!constraint.type) {\r\n if (constraint instanceof CANNON.LockConstraint) {\r\n constraint.type = 'LockConstraint';\r\n } else if (constraint instanceof CANNON.DistanceConstraint) {\r\n constraint.type = 'DistanceConstraint';\r\n } else if (constraint instanceof CANNON.HingeConstraint) {\r\n constraint.type = 'HingeConstraint';\r\n } else if (constraint instanceof CANNON.ConeTwistConstraint) {\r\n constraint.type = 'ConeTwistConstraint';\r\n } else if (constraint instanceof CANNON.PointToPointConstraint) {\r\n constraint.type = 'PointToPointConstraint';\r\n }\r\n }\r\n protocol.assignID('constraint', constraint);\r\n this.worker.postMessage({\r\n type: Event.ADD_CONSTRAINT,\r\n constraint: protocol.serializeConstraint(constraint)\r\n });\r\n};\r\n\r\n/* @param {CANNON.Constraint} constraint */\r\nWorkerDriver.prototype.removeConstraint = function (constraint) {\r\n this.worker.postMessage({\r\n type: Event.REMOVE_CONSTRAINT,\r\n constraintID: constraint[ID]\r\n });\r\n};\r\n\r\n/******************************************************************************\r\n * Contacts\r\n */\r\n\r\n/** @return {Array} */\r\nWorkerDriver.prototype.getContacts = function () {\r\n // TODO(donmccurdy): There's some wasted memory allocation here.\r\n var bodies = this.bodies;\r\n return this.contacts.map(function (message) {\r\n return protocol.deserializeContact(message, bodies);\r\n });\r\n};\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/drivers/worker-driver.js?"); -},{"cannon-es":5}],15:[function(require,module,exports){ -module.exports = { - 'velocity': require('./velocity'), - - registerAll: function (AFRAME) { - if (this._registered) return; - - AFRAME = AFRAME || window.AFRAME; - - if (!AFRAME.components['velocity']) AFRAME.registerComponent('velocity', this.velocity); - - this._registered = true; - } -}; +/***/ }), -},{"./velocity":16}],16:[function(require,module,exports){ -/** - * Velocity, in m/s. - */ -module.exports = AFRAME.registerComponent('velocity', { - schema: {type: 'vec3'}, - - init: function () { - this.system = this.el.sceneEl.systems.physics; - - if (this.system) { - this.system.addComponent(this); - } - }, - - remove: function () { - if (this.system) { - this.system.removeComponent(this); - } - }, - - tick: function (t, dt) { - if (!dt) return; - if (this.system) return; - this.afterStep(t, dt); - }, - - afterStep: function (t, dt) { - if (!dt) return; - - var physics = this.el.sceneEl.systems.physics || {data: {maxInterval: 1 / 60}}, - - // TODO - There's definitely a bug with getComputedAttribute and el.data. - velocity = this.el.getAttribute('velocity') || {x: 0, y: 0, z: 0}, - position = this.el.object3D.position || {x: 0, y: 0, z: 0}; - - dt = Math.min(dt, physics.data.maxInterval * 1000); - - this.el.object3D.position.set( - position.x + velocity.x * dt / 1000, - position.y + velocity.y * dt / 1000, - position.z + velocity.z * dt / 1000 - ); - } -}); +/***/ "./src/drivers/worker.js": +/*!*******************************!*\ + !*** ./src/drivers/worker.js ***! + \*******************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { -},{}],17:[function(require,module,exports){ -/* global Ammo,THREE */ -const threeToAmmo = require("three-to-ammo"); -const CONSTANTS = require("../../constants"), - SHAPE = CONSTANTS.SHAPE, - FIT = CONSTANTS.FIT; - -var AmmoShape = { - schema: { - type: { - default: SHAPE.HULL, - oneOf: [ - SHAPE.BOX, - SHAPE.CYLINDER, - SHAPE.SPHERE, - SHAPE.CAPSULE, - SHAPE.CONE, - SHAPE.HULL, - SHAPE.HACD, - SHAPE.VHACD, - SHAPE.MESH, - SHAPE.HEIGHTFIELD - ] - }, - fit: { default: FIT.ALL, oneOf: [FIT.ALL, FIT.MANUAL] }, - halfExtents: { type: "vec3", default: { x: 1, y: 1, z: 1 } }, - minHalfExtent: { default: 0 }, - maxHalfExtent: { default: Number.POSITIVE_INFINITY }, - sphereRadius: { default: NaN }, - cylinderAxis: { default: "y", oneOf: ["x", "y", "z"] }, - margin: { default: 0.01 }, - offset: { type: "vec3", default: { x: 0, y: 0, z: 0 } }, - orientation: { type: "vec4", default: { x: 0, y: 0, z: 0, w: 1 } }, - heightfieldData: { default: [] }, - heightfieldDistance: { default: 1 }, - includeInvisible: { default: false } - }, - - multiple: true, - - init: function() { - this.system = this.el.sceneEl.systems.physics; - this.collisionShapes = []; - - let bodyEl = this.el; - this.body = bodyEl.components["ammo-body"] || null; - while (!this.body && bodyEl.parentNode != this.el.sceneEl) { - bodyEl = bodyEl.parentNode; - if (bodyEl.components["ammo-body"]) { - this.body = bodyEl.components["ammo-body"]; - } - } - if (!this.body) { - console.warn("body not found"); - return; - } - if (this.data.fit !== FIT.MANUAL) { - if (!this.el.object3DMap.mesh) { - console.error("Cannot use FIT.ALL without object3DMap.mesh"); - return; - } - this.mesh = this.el.object3DMap.mesh; - } - this.body.addShapeComponent(this); - }, - - getMesh: function() { - return this.mesh || null; - }, - - addShapes: function(collisionShapes) { - this.collisionShapes = collisionShapes; - }, - - getShapes: function() { - return this.collisionShapes; - }, - - remove: function() { - if (!this.body) { - return; - } - - this.body.removeShapeComponent(this); - - while (this.collisionShapes.length > 0) { - const collisionShape = this.collisionShapes.pop(); - collisionShape.destroy(); - Ammo.destroy(collisionShape.localTransform); - } - } -}; - -module.exports.definition = AmmoShape; -module.exports.Component = AFRAME.registerComponent("ammo-shape", AmmoShape); +eval("var Event = __webpack_require__(/*! ./event */ \"./src/drivers/event.js\"),\r\n LocalDriver = __webpack_require__(/*! ./local-driver */ \"./src/drivers/local-driver.js\"),\r\n AmmoDriver = __webpack_require__(/*! ./ammo-driver */ \"./src/drivers/ammo-driver.js\"),\r\n protocol = __webpack_require__(/*! ../utils/protocol */ \"./src/utils/protocol.js\");\r\n\r\nvar ID = protocol.ID;\r\n\r\nmodule.exports = function (self) {\r\n var driver = null;\r\n var bodies = {};\r\n var constraints = {};\r\n var stepSize;\r\n\r\n self.addEventListener('message', function (event) {\r\n var data = event.data;\r\n\r\n switch (data.type) {\r\n // Lifecycle.\r\n case Event.INIT:\r\n driver = data.engine === 'cannon'\r\n ? new LocalDriver()\r\n : new AmmoDriver();\r\n driver.init(data.worldConfig);\r\n stepSize = 1 / data.fps;\r\n setInterval(step, 1000 / data.fps);\r\n break;\r\n\r\n // Bodies.\r\n case Event.ADD_BODY:\r\n var body = protocol.deserializeBody(data.body);\r\n body.material = driver.getMaterial( 'defaultMaterial' );\r\n bodies[body[ID]] = body;\r\n\r\n body.addEventListener('collide', function (evt) {\r\n var message = {\r\n type: Event.COLLIDE,\r\n bodyID: evt.target[ID], // set the target as the body to be identical to the local driver\r\n targetID: evt.body[ID], // set the body as the target to be identical to the local driver\r\n contact: protocol.serializeContact(evt.contact)\r\n }\r\n self.postMessage(message);\r\n });\r\n driver.addBody(body);\r\n break;\r\n case Event.REMOVE_BODY:\r\n driver.removeBody(bodies[data.bodyID]);\r\n delete bodies[data.bodyID];\r\n break;\r\n case Event.APPLY_BODY_METHOD:\r\n bodies[data.bodyID][data.methodName](\r\n protocol.deserializeVec3(data.args[0]),\r\n protocol.deserializeVec3(data.args[1])\r\n );\r\n break;\r\n case Event.UPDATE_BODY_PROPERTIES:\r\n protocol.deserializeBodyUpdate(data.body, bodies[data.body.id]);\r\n break;\r\n\r\n // Materials.\r\n case Event.ADD_MATERIAL:\r\n driver.addMaterial(data.materialConfig);\r\n break;\r\n case Event.ADD_CONTACT_MATERIAL:\r\n driver.addContactMaterial(\r\n data.materialName1,\r\n data.materialName2,\r\n data.contactMaterialConfig\r\n );\r\n break;\r\n\r\n // Constraints.\r\n case Event.ADD_CONSTRAINT:\r\n var constraint = protocol.deserializeConstraint(data.constraint, bodies);\r\n constraints[constraint[ID]] = constraint;\r\n driver.addConstraint(constraint);\r\n break;\r\n case Event.REMOVE_CONSTRAINT:\r\n driver.removeConstraint(constraints[data.constraintID]);\r\n delete constraints[data.constraintID];\r\n break;\r\n\r\n default:\r\n throw new Error('[Worker] Unexpected event type: %s', data.type);\r\n\r\n }\r\n });\r\n\r\n function step () {\r\n driver.step(stepSize);\r\n\r\n var bodyMessages = {};\r\n Object.keys(bodies).forEach(function (id) {\r\n bodyMessages[id] = protocol.serializeBody(bodies[id]);\r\n });\r\n\r\n self.postMessage({\r\n type: Event.STEP,\r\n bodies: bodyMessages,\r\n contacts: driver.getContacts().map(protocol.serializeContact)\r\n });\r\n }\r\n};\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/drivers/worker.js?"); -},{"../../constants":20,"three-to-ammo":6}],18:[function(require,module,exports){ -var CANNON = require('cannon-es'); - -var Shape = { - schema: { - shape: {default: 'box', oneOf: ['box', 'sphere', 'cylinder']}, - offset: {type: 'vec3', default: {x: 0, y: 0, z: 0}}, - orientation: {type: 'vec4', default: {x: 0, y: 0, z: 0, w: 1}}, - - // sphere - radius: {type: 'number', default: 1, if: {shape: ['sphere']}}, - - // box - halfExtents: {type: 'vec3', default: {x: 0.5, y: 0.5, z: 0.5}, if: {shape: ['box']}}, - - // cylinder - radiusTop: {type: 'number', default: 1, if: {shape: ['cylinder']}}, - radiusBottom: {type: 'number', default: 1, if: {shape: ['cylinder']}}, - height: {type: 'number', default: 1, if: {shape: ['cylinder']}}, - numSegments: {type: 'int', default: 8, if: {shape: ['cylinder']}} - }, - - multiple: true, - - init: function() { - if (this.el.sceneEl.hasLoaded) { - this.initShape(); - } else { - this.el.sceneEl.addEventListener('loaded', this.initShape.bind(this)); - } - }, - - initShape: function() { - this.bodyEl = this.el; - var bodyType = this._findType(this.bodyEl); - var data = this.data; - - while (!bodyType && this.bodyEl.parentNode != this.el.sceneEl) { - this.bodyEl = this.bodyEl.parentNode; - bodyType = this._findType(this.bodyEl); - } - - if (!bodyType) { - console.warn('body not found'); - return; - } - - var scale = new THREE.Vector3(); - this.bodyEl.object3D.getWorldScale(scale); - var shape, offset, orientation; - - if (data.hasOwnProperty('offset')) { - offset = new CANNON.Vec3( - data.offset.x * scale.x, - data.offset.y * scale.y, - data.offset.z * scale.z - ); - } - - if (data.hasOwnProperty('orientation')) { - orientation = new CANNON.Quaternion(); - orientation.copy(data.orientation); - } - - switch(data.shape) { - case 'sphere': - shape = new CANNON.Sphere(data.radius * scale.x); - break; - case 'box': - var halfExtents = new CANNON.Vec3( - data.halfExtents.x * scale.x, - data.halfExtents.y * scale.y, - data.halfExtents.z * scale.z - ); - shape = new CANNON.Box(halfExtents); - break; - case 'cylinder': - shape = new CANNON.Cylinder( - data.radiusTop * scale.x, - data.radiusBottom * scale.x, - data.height * scale.y, - data.numSegments - ); - - //rotate by 90 degrees similar to mesh2shape:createCylinderShape - var quat = new CANNON.Quaternion(); - quat.setFromEuler(90 * THREE.Math.DEG2RAD, 0, 0, 'XYZ').normalize(); - orientation.mult(quat, orientation); - break; - default: - console.warn(data.shape + ' shape not supported'); - return; - } - - if (this.bodyEl.body) { - this.bodyEl.components[bodyType].addShape(shape, offset, orientation); - } else { - this.bodyEl.addEventListener('body-loaded', function() { - this.bodyEl.components[bodyType].addShape(shape, offset, orientation); - }, {once: true}); - } - }, - - _findType: function(el) { - if (el.hasAttribute('body')) { - return 'body'; - } else if (el.hasAttribute('dynamic-body')) { - return 'dynamic-body'; - } else if (el.hasAttribute('static-body')) { - return'static-body'; - } - return null; - }, - - remove: function() { - if (this.bodyEl.parentNode) { - console.warn('removing shape component not currently supported'); - } - } -}; - -module.exports.definition = Shape; -module.exports.Component = AFRAME.registerComponent('shape', Shape); +/***/ }), -},{"cannon-es":5}],19:[function(require,module,exports){ -var CANNON = require('cannon-es'); - -module.exports = AFRAME.registerComponent('spring', { - - multiple: true, - - schema: { - // Target (other) body for the constraint. - target: {type: 'selector'}, - - // Length of the spring, when no force acts upon it. - restLength: {default: 1, min: 0}, - - // How much will the spring suppress the force. - stiffness: {default: 100, min: 0}, - - // Stretch factor of the spring. - damping: {default: 1, min: 0}, - - // Offsets. - localAnchorA: {type: 'vec3', default: {x: 0, y: 0, z: 0}}, - localAnchorB: {type: 'vec3', default: {x: 0, y: 0, z: 0}}, - }, - - init: function() { - this.system = this.el.sceneEl.systems.physics; - this.system.addComponent(this); - this.isActive = true; - this.spring = /* {CANNON.Spring} */ null; - }, - - update: function(oldData) { - var el = this.el; - var data = this.data; - - if (!data.target) { - console.warn('Spring: invalid target specified.'); - return; - } - - // wait until the CANNON bodies is created and attached - if (!el.body || !data.target.body) { - (el.body ? data.target : el).addEventListener('body-loaded', this.update.bind(this, {})); - return; - } - - // create the spring if necessary - this.createSpring(); - // apply new data to the spring - this.updateSpring(oldData); - }, - - updateSpring: function(oldData) { - if (!this.spring) { - console.warn('Spring: Component attempted to change spring before its created. No changes made.'); - return; - } - var data = this.data; - var spring = this.spring; - - // Cycle through the schema and check if an attribute has changed. - // if so, apply it to the spring - Object.keys(data).forEach(function(attr) { - if (data[attr] !== oldData[attr]) { - if (attr === 'target') { - // special case for the target selector - spring.bodyB = data.target.body; - return; - } - spring[attr] = data[attr]; - } - }) - }, - - createSpring: function() { - if (this.spring) return; // no need to create a new spring - this.spring = new CANNON.Spring(this.el.body); - }, - - // If the spring is valid, update the force each tick the physics are calculated - step: function(t, dt) { - return this.spring && this.isActive ? this.spring.applyForce() : void 0; - }, - - // resume updating the force when component upon calling play() - play: function() { - this.isActive = true; - }, - - // stop updating the force when component upon calling stop() - pause: function() { - this.isActive = false; - }, - - //remove the event listener + delete the spring - remove: function() { - if (this.spring) - delete this.spring; - this.spring = null; - } -}) +/***/ "./src/system.js": +/*!***********************!*\ + !*** ./src/system.js ***! + \***********************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { -},{"cannon-es":5}],20:[function(require,module,exports){ -module.exports = { - GRAVITY: -9.8, - MAX_INTERVAL: 4 / 60, - ITERATIONS: 10, - CONTACT_MATERIAL: { - friction: 0.01, - restitution: 0.3, - contactEquationStiffness: 1e8, - contactEquationRelaxation: 3, - frictionEquationStiffness: 1e8, - frictionEquationRegularization: 3 - }, - ACTIVATION_STATE: { - ACTIVE_TAG: "active", - ISLAND_SLEEPING: "islandSleeping", - WANTS_DEACTIVATION: "wantsDeactivation", - DISABLE_DEACTIVATION: "disableDeactivation", - DISABLE_SIMULATION: "disableSimulation" - }, - COLLISION_FLAG: { - STATIC_OBJECT: 1, - KINEMATIC_OBJECT: 2, - NO_CONTACT_RESPONSE: 4, - CUSTOM_MATERIAL_CALLBACK: 8, //this allows per-triangle material (friction/restitution) - CHARACTER_OBJECT: 16, - DISABLE_VISUALIZE_OBJECT: 32, //disable debug drawing - DISABLE_SPU_COLLISION_PROCESSING: 64 //disable parallel/SPU processing - }, - TYPE: { - STATIC: "static", - DYNAMIC: "dynamic", - KINEMATIC: "kinematic" - }, - SHAPE: { - BOX: "box", - CYLINDER: "cylinder", - SPHERE: "sphere", - CAPSULE: "capsule", - CONE: "cone", - HULL: "hull", - HACD: "hacd", - VHACD: "vhacd", - MESH: "mesh", - HEIGHTFIELD: "heightfield" - }, - FIT: { - ALL: "all", - MANUAL: "manual" - }, - CONSTRAINT: { - LOCK: "lock", - FIXED: "fixed", - SPRING: "spring", - SLIDER: "slider", - HINGE: "hinge", - CONE_TWIST: "coneTwist", - POINT_TO_POINT: "pointToPoint" - } -}; +eval("/* global THREE */\r\nvar CANNON = __webpack_require__(/*! cannon-es */ \"./node_modules/cannon-es/dist/cannon-es.js\"),\r\n CONSTANTS = __webpack_require__(/*! ./constants */ \"./src/constants.js\"),\r\n C_GRAV = CONSTANTS.GRAVITY,\r\n C_MAT = CONSTANTS.CONTACT_MATERIAL;\r\n\r\nconst { TYPE } = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\r\nvar LocalDriver = __webpack_require__(/*! ./drivers/local-driver */ \"./src/drivers/local-driver.js\"),\r\n WorkerDriver = __webpack_require__(/*! ./drivers/worker-driver */ \"./src/drivers/worker-driver.js\"),\r\n NetworkDriver = __webpack_require__(/*! ./drivers/network-driver */ \"./src/drivers/network-driver.js\"),\r\n AmmoDriver = __webpack_require__(/*! ./drivers/ammo-driver */ \"./src/drivers/ammo-driver.js\");\r\n__webpack_require__(/*! aframe-stats-panel */ \"./node_modules/aframe-stats-panel/index.js\")\r\n\r\n/**\r\n * Physics system.\r\n */\r\nmodule.exports = AFRAME.registerSystem('physics', {\r\n schema: {\r\n // CANNON.js driver type\r\n driver: { default: 'local', oneOf: ['local', 'worker', 'network', 'ammo'] },\r\n networkUrl: { default: '', if: {driver: 'network'} },\r\n workerFps: { default: 60, if: {driver: 'worker'} },\r\n workerInterpolate: { default: true, if: {driver: 'worker'} },\r\n workerInterpBufferSize: { default: 2, if: {driver: 'worker'} },\r\n workerEngine: { default: 'cannon', if: {driver: 'worker'}, oneOf: ['cannon'] },\r\n workerDebug: { default: false, if: {driver: 'worker'} },\r\n\r\n gravity: { default: C_GRAV },\r\n iterations: { default: CONSTANTS.ITERATIONS },\r\n friction: { default: C_MAT.friction },\r\n restitution: { default: C_MAT.restitution },\r\n contactEquationStiffness: { default: C_MAT.contactEquationStiffness },\r\n contactEquationRelaxation: { default: C_MAT.contactEquationRelaxation },\r\n frictionEquationStiffness: { default: C_MAT.frictionEquationStiffness },\r\n frictionEquationRegularization: { default: C_MAT.frictionEquationRegularization },\r\n\r\n // Never step more than four frames at once. Effectively pauses the scene\r\n // when out of focus, and prevents weird \"jumps\" when focus returns.\r\n maxInterval: { default: 4 / 60 },\r\n\r\n // If true, show wireframes around physics bodies.\r\n debug: { default: false },\r\n\r\n // If using ammo, set the default rendering mode for debug\r\n debugDrawMode: { default: THREE.AmmoDebugConstants.NoDebug },\r\n // If using ammo, set the max number of steps per frame \r\n maxSubSteps: { default: 4 },\r\n // If using ammo, set the framerate of the simulation\r\n fixedTimeStep: { default: 1 / 60 },\r\n // Whether to output stats, and how to output them. One or more of \"console\", \"events\", \"panel\"\r\n stats: {type: 'array', default: []}\r\n },\r\n\r\n /**\r\n * Initializes the physics system.\r\n */\r\n async init() {\r\n var data = this.data;\r\n\r\n // If true, show wireframes around physics bodies.\r\n this.debug = data.debug;\r\n this.initStats();\r\n\r\n this.callbacks = {beforeStep: [], step: [], afterStep: []};\r\n\r\n this.listeners = {};\r\n \r\n\r\n this.driver = null;\r\n switch (data.driver) {\r\n case 'local':\r\n this.driver = new LocalDriver();\r\n break;\r\n\r\n case 'ammo':\r\n this.driver = new AmmoDriver();\r\n break;\r\n\r\n case 'network':\r\n this.driver = new NetworkDriver(data.networkUrl);\r\n break;\r\n\r\n case 'worker':\r\n this.driver = new WorkerDriver({\r\n fps: data.workerFps,\r\n engine: data.workerEngine,\r\n interpolate: data.workerInterpolate,\r\n interpolationBufferSize: data.workerInterpBufferSize,\r\n debug: data.workerDebug\r\n });\r\n break;\r\n\r\n default:\r\n throw new Error('[physics] Driver not recognized: \"%s\".', data.driver);\r\n }\r\n\r\n if (data.driver !== 'ammo') {\r\n await this.driver.init({\r\n quatNormalizeSkip: 0,\r\n quatNormalizeFast: false,\r\n solverIterations: data.iterations,\r\n gravity: data.gravity,\r\n });\r\n this.driver.addMaterial({name: 'defaultMaterial'});\r\n this.driver.addMaterial({name: 'staticMaterial'});\r\n this.driver.addContactMaterial('defaultMaterial', 'defaultMaterial', {\r\n friction: data.friction,\r\n restitution: data.restitution,\r\n contactEquationStiffness: data.contactEquationStiffness,\r\n contactEquationRelaxation: data.contactEquationRelaxation,\r\n frictionEquationStiffness: data.frictionEquationStiffness,\r\n frictionEquationRegularization: data.frictionEquationRegularization\r\n });\r\n this.driver.addContactMaterial('staticMaterial', 'defaultMaterial', {\r\n friction: 1.0,\r\n restitution: 0.0,\r\n contactEquationStiffness: data.contactEquationStiffness,\r\n contactEquationRelaxation: data.contactEquationRelaxation,\r\n frictionEquationStiffness: data.frictionEquationStiffness,\r\n frictionEquationRegularization: data.frictionEquationRegularization\r\n });\r\n } else {\r\n await this.driver.init({\r\n gravity: data.gravity,\r\n debugDrawMode: data.debugDrawMode,\r\n solverIterations: data.iterations,\r\n maxSubSteps: data.maxSubSteps,\r\n fixedTimeStep: data.fixedTimeStep\r\n });\r\n }\r\n\r\n this.initialized = true;\r\n\r\n if (this.debug) {\r\n this.setDebug(true);\r\n }\r\n },\r\n\r\n initStats() {\r\n // Data used for performance monitoring.\r\n this.statsToConsole = this.data.stats.includes(\"console\")\r\n this.statsToEvents = this.data.stats.includes(\"events\")\r\n this.statsToPanel = this.data.stats.includes(\"panel\")\r\n\r\n if (this.statsToConsole || this.statsToEvents || this.statsToPanel) {\r\n this.trackPerf = true;\r\n this.tickCounter = 0;\r\n \r\n this.statsTickData = {};\r\n this.statsBodyData = {};\r\n\r\n this.countBodies = {\r\n \"ammo\": () => this.countBodiesAmmo(),\r\n \"local\": () => this.countBodiesCannon(false),\r\n \"worker\": () => this.countBodiesCannon(true)\r\n }\r\n\r\n this.bodyTypeToStatsPropertyMap = {\r\n \"ammo\": {\r\n [TYPE.STATIC] : \"staticBodies\",\r\n [TYPE.KINEMATIC] : \"kinematicBodies\",\r\n [TYPE.DYNAMIC] : \"dynamicBodies\",\r\n }, \r\n \"cannon\": {\r\n [CANNON.Body.STATIC] : \"staticBodies\",\r\n [CANNON.Body.DYNAMIC] : \"dynamicBodies\"\r\n }\r\n }\r\n \r\n const scene = this.el.sceneEl;\r\n scene.setAttribute(\"stats-collector\", `inEvent: physics-tick-data;\r\n properties: before, after, engine, total;\r\n outputFrequency: 100;\r\n outEvent: physics-tick-summary;\r\n outputs: percentile__50, percentile__90, max`);\r\n }\r\n\r\n if (this.statsToPanel) {\r\n const scene = this.el.sceneEl;\r\n const space = \"   \"\r\n \r\n scene.setAttribute(\"stats-panel\", \"\")\r\n scene.setAttribute(\"stats-group__bodies\", `label: Physics Bodies`)\r\n scene.setAttribute(\"stats-row__b1\", `group: bodies;\r\n event:physics-body-data;\r\n properties: staticBodies;\r\n label: Static`)\r\n scene.setAttribute(\"stats-row__b2\", `group: bodies;\r\n event:physics-body-data;\r\n properties: dynamicBodies;\r\n label: Dynamic`)\r\n if (this.data.driver === 'local' || this.data.driver === 'worker') {\r\n scene.setAttribute(\"stats-row__b3\", `group: bodies;\r\n event:physics-body-data;\r\n properties: contacts;\r\n label: Contacts`)\r\n }\r\n else if (this.data.driver === 'ammo') {\r\n scene.setAttribute(\"stats-row__b3\", `group: bodies;\r\n event:physics-body-data;\r\n properties: kinematicBodies;\r\n label: Kinematic`)\r\n scene.setAttribute(\"stats-row__b4\", `group: bodies;\r\n event: physics-body-data;\r\n properties: manifolds;\r\n label: Manifolds`)\r\n scene.setAttribute(\"stats-row__b5\", `group: bodies;\r\n event: physics-body-data;\r\n properties: manifoldContacts;\r\n label: Contacts`)\r\n scene.setAttribute(\"stats-row__b6\", `group: bodies;\r\n event: physics-body-data;\r\n properties: collisions;\r\n label: Collisions`)\r\n scene.setAttribute(\"stats-row__b7\", `group: bodies;\r\n event: physics-body-data;\r\n properties: collisionKeys;\r\n label: Coll Keys`)\r\n }\r\n\r\n scene.setAttribute(\"stats-group__tick\", `label: Physics Ticks: Median${space}90th%${space}99th%`)\r\n scene.setAttribute(\"stats-row__1\", `group: tick;\r\n event:physics-tick-summary;\r\n properties: before.percentile__50, \r\n before.percentile__90, \r\n before.max;\r\n label: Before`)\r\n scene.setAttribute(\"stats-row__2\", `group: tick;\r\n event:physics-tick-summary;\r\n properties: after.percentile__50, \r\n after.percentile__90, \r\n after.max; \r\n label: After`)\r\n scene.setAttribute(\"stats-row__3\", `group: tick; \r\n event:physics-tick-summary; \r\n properties: engine.percentile__50, \r\n engine.percentile__90, \r\n engine.max;\r\n label: Engine`)\r\n scene.setAttribute(\"stats-row__4\", `group: tick;\r\n event:physics-tick-summary;\r\n properties: total.percentile__50, \r\n total.percentile__90, \r\n total.max;\r\n label: Total`)\r\n }\r\n },\r\n\r\n /**\r\n * Updates the physics world on each tick of the A-Frame scene. It would be\r\n * entirely possible to separate the two – updating physics more or less\r\n * frequently than the scene – if greater precision or performance were\r\n * necessary.\r\n * @param {number} t\r\n * @param {number} dt\r\n */\r\n tick: function (t, dt) {\r\n if (!this.initialized || !dt) return;\r\n\r\n const beforeStartTime = performance.now();\r\n\r\n var i;\r\n var callbacks = this.callbacks;\r\n\r\n for (i = 0; i < this.callbacks.beforeStep.length; i++) {\r\n this.callbacks.beforeStep[i].beforeStep(t, dt);\r\n }\r\n\r\n const engineStartTime = performance.now();\r\n\r\n this.driver.step(Math.min(dt / 1000, this.data.maxInterval));\r\n\r\n const engineEndTime = performance.now();\r\n\r\n for (i = 0; i < callbacks.step.length; i++) {\r\n callbacks.step[i].step(t, dt);\r\n }\r\n\r\n for (i = 0; i < callbacks.afterStep.length; i++) {\r\n callbacks.afterStep[i].afterStep(t, dt);\r\n }\r\n\r\n if (this.trackPerf) {\r\n const afterEndTime = performance.now();\r\n\r\n this.statsTickData.before = engineStartTime - beforeStartTime\r\n this.statsTickData.engine = engineEndTime - engineStartTime\r\n this.statsTickData.after = afterEndTime - engineEndTime\r\n this.statsTickData.total = afterEndTime - beforeStartTime\r\n\r\n this.el.emit(\"physics-tick-data\", this.statsTickData)\r\n\r\n this.tickCounter++;\r\n\r\n if (this.tickCounter === 100) {\r\n\r\n this.countBodies[this.data.driver]()\r\n\r\n if (this.statsToConsole) {\r\n console.log(\"Physics body stats:\", this.statsBodyData)\r\n }\r\n\r\n if (this.statsToEvents || this.statsToPanel) {\r\n this.el.emit(\"physics-body-data\", this.statsBodyData)\r\n }\r\n this.tickCounter = 0;\r\n }\r\n }\r\n },\r\n\r\n countBodiesAmmo() {\r\n\r\n const statsData = this.statsBodyData\r\n statsData.manifolds = this.driver.dispatcher.getNumManifolds();\r\n statsData.manifoldContacts = 0;\r\n for (let i = 0; i < statsData.manifolds; i++) {\r\n const manifold = this.driver.dispatcher.getManifoldByIndexInternal(i);\r\n statsData.manifoldContacts += manifold.getNumContacts();\r\n }\r\n statsData.collisions = this.driver.collisions.size;\r\n statsData.collisionKeys = this.driver.collisionKeys.length;\r\n statsData.staticBodies = 0\r\n statsData.kinematicBodies = 0\r\n statsData.dynamicBodies = 0\r\n \r\n function type(el) {\r\n return el.components['ammo-body'].data.type\r\n }\r\n\r\n this.driver.els.forEach((el) => {\r\n const property = this.bodyTypeToStatsPropertyMap[\"ammo\"][type(el)]\r\n statsData[property]++\r\n })\r\n },\r\n\r\n countBodiesCannon(worker) {\r\n\r\n const statsData = this.statsBodyData\r\n statsData.contacts = worker ? this.driver.contacts.length : this.driver.world.contacts.length;\r\n statsData.staticBodies = 0\r\n statsData.dynamicBodies = 0\r\n\r\n const bodies = worker ? Object.values(this.driver.bodies) : this.driver.world.bodies\r\n\r\n bodies.forEach((body) => {\r\n const property = this.bodyTypeToStatsPropertyMap[\"cannon\"][body.type]\r\n statsData[property]++\r\n })\r\n },\r\n\r\n setDebug: function(debug) {\r\n this.debug = debug;\r\n if (this.data.driver === 'ammo' && this.initialized) {\r\n if (debug && !this.debugDrawer) {\r\n this.debugDrawer = this.driver.getDebugDrawer(this.el.object3D);\r\n this.debugDrawer.enable();\r\n } else if (this.debugDrawer) {\r\n this.debugDrawer.disable();\r\n this.debugDrawer = null;\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Adds a body to the scene, and binds proxied methods to the driver.\r\n * @param {CANNON.Body} body\r\n */\r\n addBody: function (body, group, mask) {\r\n var driver = this.driver;\r\n\r\n if (this.data.driver === 'local') {\r\n body.__applyImpulse = body.applyImpulse;\r\n body.applyImpulse = function () {\r\n driver.applyBodyMethod(body, 'applyImpulse', arguments);\r\n };\r\n\r\n body.__applyForce = body.applyForce;\r\n body.applyForce = function () {\r\n driver.applyBodyMethod(body, 'applyForce', arguments);\r\n };\r\n\r\n body.updateProperties = function () {\r\n driver.updateBodyProperties(body);\r\n };\r\n\r\n this.listeners[body.id] = function (e) { body.el.emit('collide', e); };\r\n body.addEventListener('collide', this.listeners[body.id]);\r\n }\r\n\r\n this.driver.addBody(body, group, mask);\r\n },\r\n\r\n /**\r\n * Removes a body and its proxied methods.\r\n * @param {CANNON.Body} body\r\n */\r\n removeBody: function (body) {\r\n this.driver.removeBody(body);\r\n\r\n if (this.data.driver === 'local' || this.data.driver === 'worker') {\r\n body.removeEventListener('collide', this.listeners[body.id]);\r\n delete this.listeners[body.id];\r\n\r\n body.applyImpulse = body.__applyImpulse;\r\n delete body.__applyImpulse;\r\n\r\n body.applyForce = body.__applyForce;\r\n delete body.__applyForce;\r\n\r\n delete body.updateProperties;\r\n }\r\n },\r\n\r\n /** @param {CANNON.Constraint or Ammo.btTypedConstraint} constraint */\r\n addConstraint: function (constraint) {\r\n this.driver.addConstraint(constraint);\r\n },\r\n\r\n /** @param {CANNON.Constraint or Ammo.btTypedConstraint} constraint */\r\n removeConstraint: function (constraint) {\r\n this.driver.removeConstraint(constraint);\r\n },\r\n\r\n /**\r\n * Adds a component instance to the system and schedules its update methods to be called\r\n * the given phase.\r\n * @param {Component} component\r\n * @param {string} phase\r\n */\r\n addComponent: function (component) {\r\n var callbacks = this.callbacks;\r\n if (component.beforeStep) callbacks.beforeStep.push(component);\r\n if (component.step) callbacks.step.push(component);\r\n if (component.afterStep) callbacks.afterStep.push(component);\r\n },\r\n\r\n /**\r\n * Removes a component instance from the system.\r\n * @param {Component} component\r\n * @param {string} phase\r\n */\r\n removeComponent: function (component) {\r\n var callbacks = this.callbacks;\r\n if (component.beforeStep) {\r\n callbacks.beforeStep.splice(callbacks.beforeStep.indexOf(component), 1);\r\n }\r\n if (component.step) {\r\n callbacks.step.splice(callbacks.step.indexOf(component), 1);\r\n }\r\n if (component.afterStep) {\r\n callbacks.afterStep.splice(callbacks.afterStep.indexOf(component), 1);\r\n }\r\n },\r\n\r\n /** @return {Array} */\r\n getContacts: function () {\r\n return this.driver.getContacts();\r\n },\r\n\r\n getMaterial: function (name) {\r\n return this.driver.getMaterial(name);\r\n }\r\n});\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/system.js?"); -},{}],21:[function(require,module,exports){ -/* global THREE */ -const Driver = require("./driver"); - -if (typeof window !== 'undefined') { - window.AmmoModule = window.Ammo; - window.Ammo = null; -} - -const EPS = 10e-6; - -function AmmoDriver() { - this.collisionConfiguration = null; - this.dispatcher = null; - this.broadphase = null; - this.solver = null; - this.physicsWorld = null; - this.debugDrawer = null; - - this.els = new Map(); - this.eventListeners = []; - this.collisions = new Map(); - this.collisionKeys = []; - this.currentCollisions = new Map(); -} - -AmmoDriver.prototype = new Driver(); -AmmoDriver.prototype.constructor = AmmoDriver; - -module.exports = AmmoDriver; - -/* @param {object} worldConfig */ -AmmoDriver.prototype.init = function(worldConfig) { - //Emscripten doesn't use real promises, just a .then() callback, so it necessary to wrap in a real promise. - return new Promise(resolve => { - AmmoModule().then(result => { - Ammo = result; - this.epsilon = worldConfig.epsilon || EPS; - this.debugDrawMode = worldConfig.debugDrawMode || THREE.AmmoDebugConstants.NoDebug; - this.maxSubSteps = worldConfig.maxSubSteps || 4; - this.fixedTimeStep = worldConfig.fixedTimeStep || 1 / 60; - this.collisionConfiguration = new Ammo.btDefaultCollisionConfiguration(); - this.dispatcher = new Ammo.btCollisionDispatcher(this.collisionConfiguration); - this.broadphase = new Ammo.btDbvtBroadphase(); - this.solver = new Ammo.btSequentialImpulseConstraintSolver(); - this.physicsWorld = new Ammo.btDiscreteDynamicsWorld( - this.dispatcher, - this.broadphase, - this.solver, - this.collisionConfiguration - ); - this.physicsWorld.setForceUpdateAllAabbs(false); - this.physicsWorld.setGravity( - new Ammo.btVector3(0, worldConfig.hasOwnProperty("gravity") ? worldConfig.gravity : -9.8, 0) - ); - this.physicsWorld.getSolverInfo().set_m_numIterations(worldConfig.solverIterations); - resolve(); - }); - }); -}; - -/* @param {Ammo.btCollisionObject} body */ -AmmoDriver.prototype.addBody = function(body, group, mask) { - this.physicsWorld.addRigidBody(body, group, mask); - this.els.set(Ammo.getPointer(body), body.el); -}; - -/* @param {Ammo.btCollisionObject} body */ -AmmoDriver.prototype.removeBody = function(body) { - this.physicsWorld.removeRigidBody(body); - this.removeEventListener(body); - const bodyptr = Ammo.getPointer(body); - this.els.delete(bodyptr); - this.collisions.delete(bodyptr); - this.collisionKeys.splice(this.collisionKeys.indexOf(bodyptr), 1); - this.currentCollisions.delete(bodyptr); -}; - -AmmoDriver.prototype.updateBody = function(body) { - if (this.els.has(Ammo.getPointer(body))) { - this.physicsWorld.updateSingleAabb(body); - } -}; - -/* @param {number} deltaTime */ -AmmoDriver.prototype.step = function(deltaTime) { - this.physicsWorld.stepSimulation(deltaTime, this.maxSubSteps, this.fixedTimeStep); - - const numManifolds = this.dispatcher.getNumManifolds(); - for (let i = 0; i < numManifolds; i++) { - const persistentManifold = this.dispatcher.getManifoldByIndexInternal(i); - const numContacts = persistentManifold.getNumContacts(); - const body0ptr = Ammo.getPointer(persistentManifold.getBody0()); - const body1ptr = Ammo.getPointer(persistentManifold.getBody1()); - let collided = false; - - for (let j = 0; j < numContacts; j++) { - const manifoldPoint = persistentManifold.getContactPoint(j); - const distance = manifoldPoint.getDistance(); - if (distance <= this.epsilon) { - collided = true; - break; - } - } - - if (collided) { - if (!this.collisions.has(body0ptr)) { - this.collisions.set(body0ptr, []); - this.collisionKeys.push(body0ptr); - } - if (this.collisions.get(body0ptr).indexOf(body1ptr) === -1) { - this.collisions.get(body0ptr).push(body1ptr); - if (this.eventListeners.indexOf(body0ptr) !== -1) { - this.els.get(body0ptr).emit("collidestart", { targetEl: this.els.get(body1ptr) }); - } - if (this.eventListeners.indexOf(body1ptr) !== -1) { - this.els.get(body1ptr).emit("collidestart", { targetEl: this.els.get(body0ptr) }); - } - } - if (!this.currentCollisions.has(body0ptr)) { - this.currentCollisions.set(body0ptr, new Set()); - } - this.currentCollisions.get(body0ptr).add(body1ptr); - } - } - - for (let i = 0; i < this.collisionKeys.length; i++) { - const body0ptr = this.collisionKeys[i]; - const body1ptrs = this.collisions.get(body0ptr); - for (let j = body1ptrs.length - 1; j >= 0; j--) { - const body1ptr = body1ptrs[j]; - if (this.currentCollisions.get(body0ptr).has(body1ptr)) { - continue; - } - if (this.eventListeners.indexOf(body0ptr) !== -1) { - this.els.get(body0ptr).emit("collideend", { targetEl: this.els.get(body1ptr) }); - } - if (this.eventListeners.indexOf(body1ptr) !== -1) { - this.els.get(body1ptr).emit("collideend", { targetEl: this.els.get(body0ptr) }); - } - body1ptrs.splice(j, 1); - } - this.currentCollisions.get(body0ptr).clear(); - } - - if (this.debugDrawer) { - this.debugDrawer.update(); - } -}; - -/* @param {?} constraint */ -AmmoDriver.prototype.addConstraint = function(constraint) { - this.physicsWorld.addConstraint(constraint, false); -}; - -/* @param {?} constraint */ -AmmoDriver.prototype.removeConstraint = function(constraint) { - this.physicsWorld.removeConstraint(constraint); -}; - -/* @param {Ammo.btCollisionObject} body */ -AmmoDriver.prototype.addEventListener = function(body) { - this.eventListeners.push(Ammo.getPointer(body)); -}; - -/* @param {Ammo.btCollisionObject} body */ -AmmoDriver.prototype.removeEventListener = function(body) { - const ptr = Ammo.getPointer(body); - if (this.eventListeners.indexOf(ptr) !== -1) { - this.eventListeners.splice(this.eventListeners.indexOf(ptr), 1); - } -}; - -AmmoDriver.prototype.destroy = function() { - Ammo.destroy(this.collisionConfiguration); - Ammo.destroy(this.dispatcher); - Ammo.destroy(this.broadphase); - Ammo.destroy(this.solver); - Ammo.destroy(this.physicsWorld); - Ammo.destroy(this.debugDrawer); -}; - -/** - * @param {THREE.Scene} scene - * @param {object} options - */ -AmmoDriver.prototype.getDebugDrawer = function(scene, options) { - if (!this.debugDrawer) { - options = options || {}; - options.debugDrawMode = options.debugDrawMode || this.debugDrawMode; - this.debugDrawer = new THREE.AmmoDebugDrawer(scene, this.physicsWorld, options); - } - return this.debugDrawer; -}; +/***/ }), -},{"./driver":22}],22:[function(require,module,exports){ -/** - * Driver - defines limited API to local and remote physics controllers. - */ - -function Driver () {} - -module.exports = Driver; - -/****************************************************************************** - * Lifecycle - */ - -/* @param {object} worldConfig */ -Driver.prototype.init = abstractMethod; - -/* @param {number} deltaMS */ -Driver.prototype.step = abstractMethod; - -Driver.prototype.destroy = abstractMethod; - -/****************************************************************************** - * Bodies - */ - -/* @param {CANNON.Body} body */ -Driver.prototype.addBody = abstractMethod; - -/* @param {CANNON.Body} body */ -Driver.prototype.removeBody = abstractMethod; - -/** - * @param {CANNON.Body} body - * @param {string} methodName - * @param {Array} args - */ -Driver.prototype.applyBodyMethod = abstractMethod; - -/** @param {CANNON.Body} body */ -Driver.prototype.updateBodyProperties = abstractMethod; - -/****************************************************************************** - * Materials - */ - -/** @param {object} materialConfig */ -Driver.prototype.addMaterial = abstractMethod; - -/** - * @param {string} materialName1 - * @param {string} materialName2 - * @param {object} contactMaterialConfig - */ -Driver.prototype.addContactMaterial = abstractMethod; - -/****************************************************************************** - * Constraints - */ - -/* @param {CANNON.Constraint} constraint */ -Driver.prototype.addConstraint = abstractMethod; - -/* @param {CANNON.Constraint} constraint */ -Driver.prototype.removeConstraint = abstractMethod; - -/****************************************************************************** - * Contacts - */ - -/** @return {Array} */ -Driver.prototype.getContacts = abstractMethod; - -/*****************************************************************************/ - -function abstractMethod () { - throw new Error('Method not implemented.'); -} +/***/ "./src/utils/math.js": +/*!***************************!*\ + !*** ./src/utils/math.js ***! + \***************************/ +/***/ ((module) => { -},{}],23:[function(require,module,exports){ -module.exports = { - INIT: 'init', - STEP: 'step', - - // Bodies. - ADD_BODY: 'add-body', - REMOVE_BODY: 'remove-body', - APPLY_BODY_METHOD: 'apply-body-method', - UPDATE_BODY_PROPERTIES: 'update-body-properties', - - // Materials. - ADD_MATERIAL: 'add-material', - ADD_CONTACT_MATERIAL: 'add-contact-material', - - // Constraints. - ADD_CONSTRAINT: 'add-constraint', - REMOVE_CONSTRAINT: 'remove-constraint', - - // Events. - COLLIDE: 'collide' -}; +eval("module.exports.slerp = function ( a, b, t ) {\r\n if ( t <= 0 ) return a;\r\n if ( t >= 1 ) return b;\r\n\r\n var x = a[0], y = a[1], z = a[2], w = a[3];\r\n\r\n // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/\r\n\r\n var cosHalfTheta = w * b[3] + x * b[0] + y * b[1] + z * b[2];\r\n\r\n if ( cosHalfTheta < 0 ) {\r\n\r\n a = a.slice();\r\n\r\n a[3] = - b[3];\r\n a[0] = - b[0];\r\n a[1] = - b[1];\r\n a[2] = - b[2];\r\n\r\n cosHalfTheta = - cosHalfTheta;\r\n\r\n } else {\r\n\r\n return b;\r\n\r\n }\r\n\r\n if ( cosHalfTheta >= 1.0 ) {\r\n\r\n a[3] = w;\r\n a[0] = x;\r\n a[1] = y;\r\n a[2] = z;\r\n\r\n return this;\r\n\r\n }\r\n\r\n var sinHalfTheta = Math.sqrt( 1.0 - cosHalfTheta * cosHalfTheta );\r\n\r\n if ( Math.abs( sinHalfTheta ) < 0.001 ) {\r\n\r\n a[3] = 0.5 * ( w + a[3] );\r\n a[0] = 0.5 * ( x + a[0] );\r\n a[1] = 0.5 * ( y + a[1] );\r\n a[2] = 0.5 * ( z + a[2] );\r\n\r\n return this;\r\n\r\n }\r\n\r\n var halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta );\r\n var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta;\r\n var ratioB = Math.sin( t * halfTheta ) / sinHalfTheta;\r\n\r\n a[3] = ( w * ratioA + a[3] * ratioB );\r\n a[0] = ( x * ratioA + a[0] * ratioB );\r\n a[1] = ( y * ratioA + a[1] * ratioB );\r\n a[2] = ( z * ratioA + a[2] * ratioB );\r\n\r\n return a;\r\n\r\n};\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/utils/math.js?"); -},{}],24:[function(require,module,exports){ -var CANNON = require('cannon-es'), - Driver = require('./driver'); - -function LocalDriver () { - this.world = null; - this.materials = {}; - this.contactMaterial = null; -} - -LocalDriver.prototype = new Driver(); -LocalDriver.prototype.constructor = LocalDriver; - -module.exports = LocalDriver; - -/****************************************************************************** - * Lifecycle - */ - -/* @param {object} worldConfig */ -LocalDriver.prototype.init = function (worldConfig) { - var world = new CANNON.World(); - world.quatNormalizeSkip = worldConfig.quatNormalizeSkip; - world.quatNormalizeFast = worldConfig.quatNormalizeFast; - world.solver.iterations = worldConfig.solverIterations; - world.gravity.set(0, worldConfig.gravity, 0); - world.broadphase = new CANNON.NaiveBroadphase(); - - this.world = world; -}; - -/* @param {number} deltaMS */ -LocalDriver.prototype.step = function (deltaMS) { - this.world.step(deltaMS); -}; - -LocalDriver.prototype.destroy = function () { - delete this.world; - delete this.contactMaterial; - this.materials = {}; -}; - -/****************************************************************************** - * Bodies - */ - -/* @param {CANNON.Body} body */ -LocalDriver.prototype.addBody = function (body) { - this.world.addBody(body); -}; - -/* @param {CANNON.Body} body */ -LocalDriver.prototype.removeBody = function (body) { - this.world.removeBody(body); -}; - -/** - * @param {CANNON.Body} body - * @param {string} methodName - * @param {Array} args - */ -LocalDriver.prototype.applyBodyMethod = function (body, methodName, args) { - body['__' + methodName].apply(body, args); -}; - -/** @param {CANNON.Body} body */ -LocalDriver.prototype.updateBodyProperties = function () {}; - -/****************************************************************************** - * Materials - */ - -/** - * @param {string} name - * @return {CANNON.Material} - */ -LocalDriver.prototype.getMaterial = function (name) { - return this.materials[name]; -}; - -/** @param {object} materialConfig */ -LocalDriver.prototype.addMaterial = function (materialConfig) { - this.materials[materialConfig.name] = new CANNON.Material(materialConfig); - this.materials[materialConfig.name].name = materialConfig.name; -}; - -/** - * @param {string} matName1 - * @param {string} matName2 - * @param {object} contactMaterialConfig - */ -LocalDriver.prototype.addContactMaterial = function (matName1, matName2, contactMaterialConfig) { - var mat1 = this.materials[matName1], - mat2 = this.materials[matName2]; - this.contactMaterial = new CANNON.ContactMaterial(mat1, mat2, contactMaterialConfig); - this.world.addContactMaterial(this.contactMaterial); -}; - -/****************************************************************************** - * Constraints - */ - -/* @param {CANNON.Constraint} constraint */ -LocalDriver.prototype.addConstraint = function (constraint) { - if (!constraint.type) { - if (constraint instanceof CANNON.LockConstraint) { - constraint.type = 'LockConstraint'; - } else if (constraint instanceof CANNON.DistanceConstraint) { - constraint.type = 'DistanceConstraint'; - } else if (constraint instanceof CANNON.HingeConstraint) { - constraint.type = 'HingeConstraint'; - } else if (constraint instanceof CANNON.ConeTwistConstraint) { - constraint.type = 'ConeTwistConstraint'; - } else if (constraint instanceof CANNON.PointToPointConstraint) { - constraint.type = 'PointToPointConstraint'; - } - } - this.world.addConstraint(constraint); -}; - -/* @param {CANNON.Constraint} constraint */ -LocalDriver.prototype.removeConstraint = function (constraint) { - this.world.removeConstraint(constraint); -}; - -/****************************************************************************** - * Contacts - */ - -/** @return {Array} */ -LocalDriver.prototype.getContacts = function () { - return this.world.contacts; -}; +/***/ }), -},{"./driver":22,"cannon-es":5}],25:[function(require,module,exports){ -var Driver = require('./driver'); - -function NetworkDriver () { - throw new Error('[NetworkDriver] Driver not implemented.'); -} - -NetworkDriver.prototype = new Driver(); -NetworkDriver.prototype.constructor = NetworkDriver; - -module.exports = NetworkDriver; +/***/ "./src/utils/protocol.js": +/*!*******************************!*\ + !*** ./src/utils/protocol.js ***! + \*******************************/ +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { -},{"./driver":22}],26:[function(require,module,exports){ -/** - * Stub version of webworkify, for debugging code outside of a webworker. - */ -function webworkifyDebug (worker) { - var targetA = new EventTarget(), - targetB = new EventTarget(); - - targetA.setTarget(targetB); - targetB.setTarget(targetA); - - worker(targetA); - return targetB; -} - -module.exports = webworkifyDebug; - -/****************************************************************************** - * EventTarget - */ - -function EventTarget () { - this.listeners = []; -} - -EventTarget.prototype.setTarget = function (target) { - this.target = target; -}; - -EventTarget.prototype.addEventListener = function (type, fn) { - this.listeners.push(fn); -}; - -EventTarget.prototype.dispatchEvent = function (type, event) { - for (var i = 0; i < this.listeners.length; i++) { - this.listeners[i](event); - } -}; - -EventTarget.prototype.postMessage = function (msg) { - this.target.dispatchEvent('message', {data: msg}); -}; +eval("var CANNON = __webpack_require__(/*! cannon-es */ \"./node_modules/cannon-es/dist/cannon-es.js\");\r\nvar mathUtils = __webpack_require__(/*! ./math */ \"./src/utils/math.js\");\r\n\r\n/******************************************************************************\r\n * IDs\r\n */\r\n\r\nvar ID = '__id';\r\nmodule.exports.ID = ID;\r\n\r\nvar nextID = {};\r\nmodule.exports.assignID = function (prefix, object) {\r\n if (object[ID]) return;\r\n nextID[prefix] = nextID[prefix] || 1;\r\n object[ID] = prefix + '_' + nextID[prefix]++;\r\n};\r\n\r\n/******************************************************************************\r\n * Bodies\r\n */\r\n\r\nmodule.exports.serializeBody = function (body) {\r\n var message = {\r\n // Shapes.\r\n shapes: body.shapes.map(serializeShape),\r\n shapeOffsets: body.shapeOffsets.map(serializeVec3),\r\n shapeOrientations: body.shapeOrientations.map(serializeQuaternion),\r\n\r\n // Vectors.\r\n position: serializeVec3(body.position),\r\n quaternion: body.quaternion.toArray(),\r\n velocity: serializeVec3(body.velocity),\r\n angularVelocity: serializeVec3(body.angularVelocity),\r\n\r\n // Properties.\r\n id: body[ID],\r\n mass: body.mass,\r\n linearDamping: body.linearDamping,\r\n angularDamping: body.angularDamping,\r\n fixedRotation: body.fixedRotation,\r\n allowSleep: body.allowSleep,\r\n sleepSpeedLimit: body.sleepSpeedLimit,\r\n sleepTimeLimit: body.sleepTimeLimit\r\n };\r\n\r\n return message;\r\n};\r\n\r\nmodule.exports.deserializeBodyUpdate = function (message, body) {\r\n body.position.set(message.position[0], message.position[1], message.position[2]);\r\n body.quaternion.set(message.quaternion[0], message.quaternion[1], message.quaternion[2], message.quaternion[3]);\r\n body.velocity.set(message.velocity[0], message.velocity[1], message.velocity[2]);\r\n body.angularVelocity.set(message.angularVelocity[0], message.angularVelocity[1], message.angularVelocity[2]);\r\n\r\n body.linearDamping = message.linearDamping;\r\n body.angularDamping = message.angularDamping;\r\n body.fixedRotation = message.fixedRotation;\r\n body.allowSleep = message.allowSleep;\r\n body.sleepSpeedLimit = message.sleepSpeedLimit;\r\n body.sleepTimeLimit = message.sleepTimeLimit;\r\n\r\n if (body.mass !== message.mass) {\r\n body.mass = message.mass;\r\n body.updateMassProperties();\r\n }\r\n\r\n return body;\r\n};\r\n\r\nmodule.exports.deserializeInterpBodyUpdate = function (message1, message2, body, mix) {\r\n var weight1 = 1 - mix;\r\n var weight2 = mix;\r\n\r\n body.position.set(\r\n message1.position[0] * weight1 + message2.position[0] * weight2,\r\n message1.position[1] * weight1 + message2.position[1] * weight2,\r\n message1.position[2] * weight1 + message2.position[2] * weight2\r\n );\r\n var quaternion = mathUtils.slerp(message1.quaternion, message2.quaternion, mix);\r\n body.quaternion.set(quaternion[0], quaternion[1], quaternion[2], quaternion[3]);\r\n body.velocity.set(\r\n message1.velocity[0] * weight1 + message2.velocity[0] * weight2,\r\n message1.velocity[1] * weight1 + message2.velocity[1] * weight2,\r\n message1.velocity[2] * weight1 + message2.velocity[2] * weight2\r\n );\r\n body.angularVelocity.set(\r\n message1.angularVelocity[0] * weight1 + message2.angularVelocity[0] * weight2,\r\n message1.angularVelocity[1] * weight1 + message2.angularVelocity[1] * weight2,\r\n message1.angularVelocity[2] * weight1 + message2.angularVelocity[2] * weight2\r\n );\r\n\r\n body.linearDamping = message2.linearDamping;\r\n body.angularDamping = message2.angularDamping;\r\n body.fixedRotation = message2.fixedRotation;\r\n body.allowSleep = message2.allowSleep;\r\n body.sleepSpeedLimit = message2.sleepSpeedLimit;\r\n body.sleepTimeLimit = message2.sleepTimeLimit;\r\n\r\n if (body.mass !== message2.mass) {\r\n body.mass = message2.mass;\r\n body.updateMassProperties();\r\n }\r\n\r\n return body;\r\n};\r\n\r\nmodule.exports.deserializeBody = function (message) {\r\n var body = new CANNON.Body({\r\n mass: message.mass,\r\n\r\n position: deserializeVec3(message.position),\r\n quaternion: deserializeQuaternion(message.quaternion),\r\n velocity: deserializeVec3(message.velocity),\r\n angularVelocity: deserializeVec3(message.angularVelocity),\r\n\r\n linearDamping: message.linearDamping,\r\n angularDamping: message.angularDamping,\r\n fixedRotation: message.fixedRotation,\r\n allowSleep: message.allowSleep,\r\n sleepSpeedLimit: message.sleepSpeedLimit,\r\n sleepTimeLimit: message.sleepTimeLimit\r\n });\r\n\r\n for (var shapeMsg, i = 0; (shapeMsg = message.shapes[i]); i++) {\r\n body.addShape(\r\n deserializeShape(shapeMsg),\r\n deserializeVec3(message.shapeOffsets[i]),\r\n deserializeQuaternion(message.shapeOrientations[i])\r\n );\r\n }\r\n\r\n body[ID] = message.id;\r\n\r\n return body;\r\n};\r\n\r\n/******************************************************************************\r\n * Shapes\r\n */\r\n\r\nmodule.exports.serializeShape = serializeShape;\r\nfunction serializeShape (shape) {\r\n var shapeMsg = {type: shape.type};\r\n if (shape.type === CANNON.Shape.types.BOX) {\r\n shapeMsg.halfExtents = serializeVec3(shape.halfExtents);\r\n\r\n } else if (shape.type === CANNON.Shape.types.SPHERE) {\r\n shapeMsg.radius = shape.radius;\r\n\r\n // Patch schteppe/cannon.js#329.\r\n } else if (shape._type === CANNON.Shape.types.CYLINDER) {\r\n shapeMsg.type = CANNON.Shape.types.CYLINDER;\r\n shapeMsg.radiusTop = shape.radiusTop;\r\n shapeMsg.radiusBottom = shape.radiusBottom;\r\n shapeMsg.height = shape.height;\r\n shapeMsg.numSegments = shape.numSegments;\r\n\r\n } else {\r\n // TODO(donmccurdy): Support for other shape types.\r\n throw new Error('Unimplemented shape type: %s', shape.type);\r\n }\r\n return shapeMsg;\r\n}\r\n\r\nmodule.exports.deserializeShape = deserializeShape;\r\nfunction deserializeShape (message) {\r\n var shape;\r\n\r\n if (message.type === CANNON.Shape.types.BOX) {\r\n shape = new CANNON.Box(deserializeVec3(message.halfExtents));\r\n\r\n } else if (message.type === CANNON.Shape.types.SPHERE) {\r\n shape = new CANNON.Sphere(message.radius);\r\n\r\n // Patch schteppe/cannon.js#329.\r\n } else if (message.type === CANNON.Shape.types.CYLINDER) {\r\n shape = new CANNON.Cylinder(message.radiusTop, message.radiusBottom, message.height, message.numSegments);\r\n shape._type = CANNON.Shape.types.CYLINDER;\r\n\r\n } else {\r\n // TODO(donmccurdy): Support for other shape types.\r\n throw new Error('Unimplemented shape type: %s', message.type);\r\n }\r\n\r\n return shape;\r\n}\r\n\r\n/******************************************************************************\r\n * Constraints\r\n */\r\n\r\nmodule.exports.serializeConstraint = function (constraint) {\r\n\r\n var message = {\r\n id: constraint[ID],\r\n type: constraint.type,\r\n maxForce: constraint.maxForce,\r\n bodyA: constraint.bodyA[ID],\r\n bodyB: constraint.bodyB[ID]\r\n };\r\n\r\n switch (constraint.type) {\r\n case 'LockConstraint':\r\n break;\r\n case 'DistanceConstraint':\r\n message.distance = constraint.distance;\r\n break;\r\n case 'HingeConstraint':\r\n case 'ConeTwistConstraint':\r\n message.axisA = serializeVec3(constraint.axisA);\r\n message.axisB = serializeVec3(constraint.axisB);\r\n message.pivotA = serializeVec3(constraint.pivotA);\r\n message.pivotB = serializeVec3(constraint.pivotB);\r\n break;\r\n case 'PointToPointConstraint':\r\n message.pivotA = serializeVec3(constraint.pivotA);\r\n message.pivotB = serializeVec3(constraint.pivotB);\r\n break;\r\n default:\r\n throw new Error(''\r\n + 'Unexpected constraint type: ' + constraint.type + '. '\r\n + 'You may need to manually set `constraint.type = \"FooConstraint\";`.'\r\n );\r\n }\r\n\r\n return message;\r\n};\r\n\r\nmodule.exports.deserializeConstraint = function (message, bodies) {\r\n var TypedConstraint = CANNON[message.type];\r\n var bodyA = bodies[message.bodyA];\r\n var bodyB = bodies[message.bodyB];\r\n\r\n var constraint;\r\n\r\n switch (message.type) {\r\n case 'LockConstraint':\r\n constraint = new CANNON.LockConstraint(bodyA, bodyB, message);\r\n break;\r\n\r\n case 'DistanceConstraint':\r\n constraint = new CANNON.DistanceConstraint(\r\n bodyA,\r\n bodyB,\r\n message.distance,\r\n message.maxForce\r\n );\r\n break;\r\n\r\n case 'HingeConstraint':\r\n case 'ConeTwistConstraint':\r\n constraint = new TypedConstraint(bodyA, bodyB, {\r\n pivotA: deserializeVec3(message.pivotA),\r\n pivotB: deserializeVec3(message.pivotB),\r\n axisA: deserializeVec3(message.axisA),\r\n axisB: deserializeVec3(message.axisB),\r\n maxForce: message.maxForce\r\n });\r\n break;\r\n\r\n case 'PointToPointConstraint':\r\n constraint = new CANNON.PointToPointConstraint(\r\n bodyA,\r\n deserializeVec3(message.pivotA),\r\n bodyB,\r\n deserializeVec3(message.pivotB),\r\n message.maxForce\r\n );\r\n break;\r\n\r\n default:\r\n throw new Error('Unexpected constraint type: ' + message.type);\r\n }\r\n\r\n constraint[ID] = message.id;\r\n return constraint;\r\n};\r\n\r\n/******************************************************************************\r\n * Contacts\r\n */\r\n\r\nmodule.exports.serializeContact = function (contact) {\r\n return {\r\n bi: contact.bi[ID],\r\n bj: contact.bj[ID],\r\n ni: serializeVec3(contact.ni),\r\n ri: serializeVec3(contact.ri),\r\n rj: serializeVec3(contact.rj)\r\n };\r\n};\r\n\r\nmodule.exports.deserializeContact = function (message, bodies) {\r\n return {\r\n bi: bodies[message.bi],\r\n bj: bodies[message.bj],\r\n ni: deserializeVec3(message.ni),\r\n ri: deserializeVec3(message.ri),\r\n rj: deserializeVec3(message.rj)\r\n };\r\n};\r\n\r\n/******************************************************************************\r\n * Math\r\n */\r\n\r\nmodule.exports.serializeVec3 = serializeVec3;\r\nfunction serializeVec3 (vec3) {\r\n return vec3.toArray();\r\n}\r\n\r\nmodule.exports.deserializeVec3 = deserializeVec3;\r\nfunction deserializeVec3 (message) {\r\n return new CANNON.Vec3(message[0], message[1], message[2]);\r\n}\r\n\r\nmodule.exports.serializeQuaternion = serializeQuaternion;\r\nfunction serializeQuaternion (quat) {\r\n return quat.toArray();\r\n}\r\n\r\nmodule.exports.deserializeQuaternion = deserializeQuaternion;\r\nfunction deserializeQuaternion (message) {\r\n return new CANNON.Quaternion(message[0], message[1], message[2], message[3]);\r\n}\r\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./src/utils/protocol.js?"); -},{}],27:[function(require,module,exports){ -/* global performance */ - -var webworkify = require('webworkify'), - webworkifyDebug = require('./webworkify-debug'), - Driver = require('./driver'), - Event = require('./event'), - worker = require('./worker'), - protocol = require('../utils/protocol'); - -var ID = protocol.ID; - -/****************************************************************************** - * Constructor - */ - -function WorkerDriver (options) { - this.fps = options.fps; - this.engine = options.engine; - this.interpolate = options.interpolate; - // Approximate number of physics steps to 'pad' rendering. - this.interpBufferSize = options.interpolationBufferSize; - this.debug = options.debug; - - this.bodies = {}; - this.contacts = []; - - // https://gafferongames.com/post/snapshot_interpolation/ - this.frameDelay = this.interpBufferSize * 1000 / this.fps; - this.frameBuffer = []; - - this.worker = this.debug - ? webworkifyDebug(worker) - : webworkify(worker); - this.worker.addEventListener('message', this._onMessage.bind(this)); -} - -WorkerDriver.prototype = new Driver(); -WorkerDriver.prototype.constructor = WorkerDriver; - -module.exports = WorkerDriver; - -/****************************************************************************** - * Lifecycle - */ - -/* @param {object} worldConfig */ -WorkerDriver.prototype.init = function (worldConfig) { - this.worker.postMessage({ - type: Event.INIT, - worldConfig: worldConfig, - fps: this.fps, - engine: this.engine - }); -}; - -/** - * Increments the physics world forward one step, if interpolation is enabled. - * If disabled, increments are performed as messages arrive. - * @param {number} deltaMS - */ -WorkerDriver.prototype.step = function () { - if (!this.interpolate) return; - - // Get the two oldest frames that haven't expired. Ideally we would use all - // available frames to keep things smooth, but lerping is easier and faster. - var prevFrame = this.frameBuffer[0]; - var nextFrame = this.frameBuffer[1]; - var timestamp = performance.now(); - while (prevFrame && nextFrame && timestamp - prevFrame.timestamp > this.frameDelay) { - this.frameBuffer.shift(); - prevFrame = this.frameBuffer[0]; - nextFrame = this.frameBuffer[1]; - } - - if (!prevFrame || !nextFrame) return; - - var mix = (timestamp - prevFrame.timestamp) / this.frameDelay; - mix = (mix - (1 - 1 / this.interpBufferSize)) * this.interpBufferSize; - - for (var id in prevFrame.bodies) { - if (prevFrame.bodies.hasOwnProperty(id) && nextFrame.bodies.hasOwnProperty(id)) { - protocol.deserializeInterpBodyUpdate( - prevFrame.bodies[id], - nextFrame.bodies[id], - this.bodies[id], - mix - ); - } - } -}; - -WorkerDriver.prototype.destroy = function () { - this.worker.terminate(); - delete this.worker; -}; - -/** {Event} event */ -WorkerDriver.prototype._onMessage = function (event) { - if (event.data.type === Event.STEP) { - var data = event.data, - bodies = data.bodies; - - this.contacts = event.data.contacts; - - // If interpolation is enabled, store the frame. If not, update all bodies - // immediately. - if (this.interpolate) { - this.frameBuffer.push({timestamp: performance.now(), bodies: bodies}); - } else { - for (var id in bodies) { - if (bodies.hasOwnProperty(id)) { - protocol.deserializeBodyUpdate(bodies[id], this.bodies[id]); - } - } - } - - } else if (event.data.type === Event.COLLIDE) { - var body = this.bodies[event.data.bodyID]; - var target = this.bodies[event.data.targetID]; - var contact = protocol.deserializeContact(event.data.contact, this.bodies); - if (!body._listeners || !body._listeners.collide) return; - for (var i = 0; i < body._listeners.collide.length; i++) { - body._listeners.collide[i]({target: target, body: body, contact: contact}); - } - - } else { - throw new Error('[WorkerDriver] Unexpected message type.'); - } -}; - -/****************************************************************************** - * Bodies - */ - -/* @param {CANNON.Body} body */ -WorkerDriver.prototype.addBody = function (body) { - protocol.assignID('body', body); - this.bodies[body[ID]] = body; - this.worker.postMessage({type: Event.ADD_BODY, body: protocol.serializeBody(body)}); -}; - -/* @param {CANNON.Body} body */ -WorkerDriver.prototype.removeBody = function (body) { - this.worker.postMessage({type: Event.REMOVE_BODY, bodyID: body[ID]}); - delete this.bodies[body[ID]]; -}; - -/** - * @param {CANNON.Body} body - * @param {string} methodName - * @param {Array} args - */ -WorkerDriver.prototype.applyBodyMethod = function (body, methodName, args) { - switch (methodName) { - case 'applyForce': - case 'applyImpulse': - this.worker.postMessage({ - type: Event.APPLY_BODY_METHOD, - bodyID: body[ID], - methodName: methodName, - args: [args[0].toArray(), args[1].toArray()] - }); - break; - default: - throw new Error('Unexpected methodName: %s', methodName); - } -}; - -/** @param {CANNON.Body} body */ -WorkerDriver.prototype.updateBodyProperties = function (body) { - this.worker.postMessage({ - type: Event.UPDATE_BODY_PROPERTIES, - body: protocol.serializeBody(body) - }); -}; - -/****************************************************************************** - * Materials - */ - -/** - * @param {string} name - * @return {CANNON.Material} - */ -WorkerDriver.prototype.getMaterial = function (name) { - // No access to materials here. Eventually we might return the name or ID, if - // multiple materials were selected, but for now there's only one and it's safe - // to assume the worker is already using it. - return undefined; -}; - -/** @param {object} materialConfig */ -WorkerDriver.prototype.addMaterial = function (materialConfig) { - this.worker.postMessage({type: Event.ADD_MATERIAL, materialConfig: materialConfig}); -}; - -/** - * @param {string} matName1 - * @param {string} matName2 - * @param {object} contactMaterialConfig - */ -WorkerDriver.prototype.addContactMaterial = function (matName1, matName2, contactMaterialConfig) { - this.worker.postMessage({ - type: Event.ADD_CONTACT_MATERIAL, - materialName1: matName1, - materialName2: matName2, - contactMaterialConfig: contactMaterialConfig - }); -}; - -/****************************************************************************** - * Constraints - */ - -/* @param {CANNON.Constraint} constraint */ -WorkerDriver.prototype.addConstraint = function (constraint) { - if (!constraint.type) { - if (constraint instanceof CANNON.LockConstraint) { - constraint.type = 'LockConstraint'; - } else if (constraint instanceof CANNON.DistanceConstraint) { - constraint.type = 'DistanceConstraint'; - } else if (constraint instanceof CANNON.HingeConstraint) { - constraint.type = 'HingeConstraint'; - } else if (constraint instanceof CANNON.ConeTwistConstraint) { - constraint.type = 'ConeTwistConstraint'; - } else if (constraint instanceof CANNON.PointToPointConstraint) { - constraint.type = 'PointToPointConstraint'; - } - } - protocol.assignID('constraint', constraint); - this.worker.postMessage({ - type: Event.ADD_CONSTRAINT, - constraint: protocol.serializeConstraint(constraint) - }); -}; - -/* @param {CANNON.Constraint} constraint */ -WorkerDriver.prototype.removeConstraint = function (constraint) { - this.worker.postMessage({ - type: Event.REMOVE_CONSTRAINT, - constraintID: constraint[ID] - }); -}; - -/****************************************************************************** - * Contacts - */ - -/** @return {Array} */ -WorkerDriver.prototype.getContacts = function () { - // TODO(donmccurdy): There's some wasted memory allocation here. - var bodies = this.bodies; - return this.contacts.map(function (message) { - return protocol.deserializeContact(message, bodies); - }); -}; +/***/ }), -},{"../utils/protocol":31,"./driver":22,"./event":23,"./webworkify-debug":26,"./worker":28,"webworkify":8}],28:[function(require,module,exports){ -var Event = require('./event'), - LocalDriver = require('./local-driver'), - AmmoDriver = require('./ammo-driver'), - protocol = require('../utils/protocol'); - -var ID = protocol.ID; - -module.exports = function (self) { - var driver = null; - var bodies = {}; - var constraints = {}; - var stepSize; - - self.addEventListener('message', function (event) { - var data = event.data; - - switch (data.type) { - // Lifecycle. - case Event.INIT: - driver = data.engine === 'cannon' - ? new LocalDriver() - : new AmmoDriver(); - driver.init(data.worldConfig); - stepSize = 1 / data.fps; - setInterval(step, 1000 / data.fps); - break; - - // Bodies. - case Event.ADD_BODY: - var body = protocol.deserializeBody(data.body); - body.material = driver.getMaterial( 'defaultMaterial' ); - bodies[body[ID]] = body; - - body.addEventListener('collide', function (evt) { - var message = { - type: Event.COLLIDE, - bodyID: evt.target[ID], // set the target as the body to be identical to the local driver - targetID: evt.body[ID], // set the body as the target to be identical to the local driver - contact: protocol.serializeContact(evt.contact) - } - self.postMessage(message); - }); - driver.addBody(body); - break; - case Event.REMOVE_BODY: - driver.removeBody(bodies[data.bodyID]); - delete bodies[data.bodyID]; - break; - case Event.APPLY_BODY_METHOD: - bodies[data.bodyID][data.methodName]( - protocol.deserializeVec3(data.args[0]), - protocol.deserializeVec3(data.args[1]) - ); - break; - case Event.UPDATE_BODY_PROPERTIES: - protocol.deserializeBodyUpdate(data.body, bodies[data.body.id]); - break; - - // Materials. - case Event.ADD_MATERIAL: - driver.addMaterial(data.materialConfig); - break; - case Event.ADD_CONTACT_MATERIAL: - driver.addContactMaterial( - data.materialName1, - data.materialName2, - data.contactMaterialConfig - ); - break; - - // Constraints. - case Event.ADD_CONSTRAINT: - var constraint = protocol.deserializeConstraint(data.constraint, bodies); - constraints[constraint[ID]] = constraint; - driver.addConstraint(constraint); - break; - case Event.REMOVE_CONSTRAINT: - driver.removeConstraint(constraints[data.constraintID]); - delete constraints[data.constraintID]; - break; - - default: - throw new Error('[Worker] Unexpected event type: %s', data.type); - - } - }); - - function step () { - driver.step(stepSize); - - var bodyMessages = {}; - Object.keys(bodies).forEach(function (id) { - bodyMessages[id] = protocol.serializeBody(bodies[id]); - }); - - self.postMessage({ - type: Event.STEP, - bodies: bodyMessages, - contacts: driver.getContacts().map(protocol.serializeContact) - }); - } -}; +/***/ "./node_modules/three-to-cannon/dist/three-to-cannon.cjs": +/*!***************************************************************!*\ + !*** ./node_modules/three-to-cannon/dist/three-to-cannon.cjs ***! + \***************************************************************/ +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { -},{"../utils/protocol":31,"./ammo-driver":21,"./event":23,"./local-driver":24}],29:[function(require,module,exports){ -/* global THREE */ -var CANNON = require('cannon-es'), - CONSTANTS = require('./constants'), - C_GRAV = CONSTANTS.GRAVITY, - C_MAT = CONSTANTS.CONTACT_MATERIAL; - -const { TYPE } = require('./constants'); -var LocalDriver = require('./drivers/local-driver'), - WorkerDriver = require('./drivers/worker-driver'), - NetworkDriver = require('./drivers/network-driver'), - AmmoDriver = require('./drivers/ammo-driver'); -require('aframe-stats-panel') - -/** - * Physics system. - */ -module.exports = AFRAME.registerSystem('physics', { - schema: { - // CANNON.js driver type - driver: { default: 'local', oneOf: ['local', 'worker', 'network', 'ammo'] }, - networkUrl: { default: '', if: {driver: 'network'} }, - workerFps: { default: 60, if: {driver: 'worker'} }, - workerInterpolate: { default: true, if: {driver: 'worker'} }, - workerInterpBufferSize: { default: 2, if: {driver: 'worker'} }, - workerEngine: { default: 'cannon', if: {driver: 'worker'}, oneOf: ['cannon'] }, - workerDebug: { default: false, if: {driver: 'worker'} }, - - gravity: { default: C_GRAV }, - iterations: { default: CONSTANTS.ITERATIONS }, - friction: { default: C_MAT.friction }, - restitution: { default: C_MAT.restitution }, - contactEquationStiffness: { default: C_MAT.contactEquationStiffness }, - contactEquationRelaxation: { default: C_MAT.contactEquationRelaxation }, - frictionEquationStiffness: { default: C_MAT.frictionEquationStiffness }, - frictionEquationRegularization: { default: C_MAT.frictionEquationRegularization }, - - // Never step more than four frames at once. Effectively pauses the scene - // when out of focus, and prevents weird "jumps" when focus returns. - maxInterval: { default: 4 / 60 }, - - // If true, show wireframes around physics bodies. - debug: { default: false }, - - // If using ammo, set the default rendering mode for debug - debugDrawMode: { default: THREE.AmmoDebugConstants.NoDebug }, - // If using ammo, set the max number of steps per frame - maxSubSteps: { default: 4 }, - // If using ammo, set the framerate of the simulation - fixedTimeStep: { default: 1 / 60 }, - // Whether to output stats, and how to output them. One or more of "console", "events", "panel" - stats: {type: 'array', default: []} - }, - - /** - * Initializes the physics system. - */ - async init() { - var data = this.data; - - // If true, show wireframes around physics bodies. - this.debug = data.debug; - this.initStats(); - - this.callbacks = {beforeStep: [], step: [], afterStep: []}; - - this.listeners = {}; - - - this.driver = null; - switch (data.driver) { - case 'local': - this.driver = new LocalDriver(); - break; - - case 'ammo': - this.driver = new AmmoDriver(); - break; - - case 'network': - this.driver = new NetworkDriver(data.networkUrl); - break; - - case 'worker': - this.driver = new WorkerDriver({ - fps: data.workerFps, - engine: data.workerEngine, - interpolate: data.workerInterpolate, - interpolationBufferSize: data.workerInterpBufferSize, - debug: data.workerDebug - }); - break; - - default: - throw new Error('[physics] Driver not recognized: "%s".', data.driver); - } - - if (data.driver !== 'ammo') { - await this.driver.init({ - quatNormalizeSkip: 0, - quatNormalizeFast: false, - solverIterations: data.iterations, - gravity: data.gravity, - }); - this.driver.addMaterial({name: 'defaultMaterial'}); - this.driver.addMaterial({name: 'staticMaterial'}); - this.driver.addContactMaterial('defaultMaterial', 'defaultMaterial', { - friction: data.friction, - restitution: data.restitution, - contactEquationStiffness: data.contactEquationStiffness, - contactEquationRelaxation: data.contactEquationRelaxation, - frictionEquationStiffness: data.frictionEquationStiffness, - frictionEquationRegularization: data.frictionEquationRegularization - }); - this.driver.addContactMaterial('staticMaterial', 'defaultMaterial', { - friction: 1.0, - restitution: 0.0, - contactEquationStiffness: data.contactEquationStiffness, - contactEquationRelaxation: data.contactEquationRelaxation, - frictionEquationStiffness: data.frictionEquationStiffness, - frictionEquationRegularization: data.frictionEquationRegularization - }); - } else { - await this.driver.init({ - gravity: data.gravity, - debugDrawMode: data.debugDrawMode, - solverIterations: data.iterations, - maxSubSteps: data.maxSubSteps, - fixedTimeStep: data.fixedTimeStep - }); - } - - this.initialized = true; - - if (this.debug) { - this.setDebug(true); - } - }, - - initStats() { - // Data used for performance monitoring. - this.statsToConsole = this.data.stats.includes("console") - this.statsToEvents = this.data.stats.includes("events") - this.statsToPanel = this.data.stats.includes("panel") - - if (this.statsToConsole || this.statsToEvents || this.statsToPanel) { - this.trackPerf = true; - this.tickCounter = 0; - - this.statsTickData = {}; - this.statsBodyData = {}; - - this.countBodies = { - "ammo": () => this.countBodiesAmmo(), - "local": () => this.countBodiesCannon(false), - "worker": () => this.countBodiesCannon(true) - } - - this.bodyTypeToStatsPropertyMap = { - "ammo": { - [TYPE.STATIC] : "staticBodies", - [TYPE.KINEMATIC] : "kinematicBodies", - [TYPE.DYNAMIC] : "dynamicBodies", - }, - "cannon": { - [CANNON.Body.STATIC] : "staticBodies", - [CANNON.Body.DYNAMIC] : "dynamicBodies" - } - } - - const scene = this.el.sceneEl; - scene.setAttribute("stats-collector", `inEvent: physics-tick-data; - properties: before, after, engine, total; - outputFrequency: 100; - outEvent: physics-tick-summary; - outputs: percentile__50, percentile__90, max`); - } - - if (this.statsToPanel) { - const scene = this.el.sceneEl; - const space = "   " - - scene.setAttribute("stats-panel", "") - scene.setAttribute("stats-group__bodies", `label: Physics Bodies`) - scene.setAttribute("stats-row__b1", `group: bodies; - event:physics-body-data; - properties: staticBodies; - label: Static`) - scene.setAttribute("stats-row__b2", `group: bodies; - event:physics-body-data; - properties: dynamicBodies; - label: Dynamic`) - if (this.data.driver === 'local' || this.data.driver === 'worker') { - scene.setAttribute("stats-row__b3", `group: bodies; - event:physics-body-data; - properties: contacts; - label: Contacts`) - } - else if (this.data.driver === 'ammo') { - scene.setAttribute("stats-row__b3", `group: bodies; - event:physics-body-data; - properties: kinematicBodies; - label: Kinematic`) - scene.setAttribute("stats-row__b4", `group: bodies; - event: physics-body-data; - properties: manifolds; - label: Manifolds`) - scene.setAttribute("stats-row__b5", `group: bodies; - event: physics-body-data; - properties: manifoldContacts; - label: Contacts`) - scene.setAttribute("stats-row__b6", `group: bodies; - event: physics-body-data; - properties: collisions; - label: Collisions`) - scene.setAttribute("stats-row__b7", `group: bodies; - event: physics-body-data; - properties: collisionKeys; - label: Coll Keys`) - } - - scene.setAttribute("stats-group__tick", `label: Physics Ticks: Median${space}90th%${space}99th%`) - scene.setAttribute("stats-row__1", `group: tick; - event:physics-tick-summary; - properties: before.percentile__50, - before.percentile__90, - before.max; - label: Before`) - scene.setAttribute("stats-row__2", `group: tick; - event:physics-tick-summary; - properties: after.percentile__50, - after.percentile__90, - after.max; - label: After`) - scene.setAttribute("stats-row__3", `group: tick; - event:physics-tick-summary; - properties: engine.percentile__50, - engine.percentile__90, - engine.max; - label: Engine`) - scene.setAttribute("stats-row__4", `group: tick; - event:physics-tick-summary; - properties: total.percentile__50, - total.percentile__90, - total.max; - label: Total`) - } - }, - - /** - * Updates the physics world on each tick of the A-Frame scene. It would be - * entirely possible to separate the two – updating physics more or less - * frequently than the scene – if greater precision or performance were - * necessary. - * @param {number} t - * @param {number} dt - */ - tick: function (t, dt) { - if (!this.initialized || !dt) return; - - const beforeStartTime = performance.now(); - - var i; - var callbacks = this.callbacks; - - for (i = 0; i < this.callbacks.beforeStep.length; i++) { - this.callbacks.beforeStep[i].beforeStep(t, dt); - } - - const engineStartTime = performance.now(); - - this.driver.step(Math.min(dt / 1000, this.data.maxInterval)); - - const engineEndTime = performance.now(); - - for (i = 0; i < callbacks.step.length; i++) { - callbacks.step[i].step(t, dt); - } - - for (i = 0; i < callbacks.afterStep.length; i++) { - callbacks.afterStep[i].afterStep(t, dt); - } - - if (this.trackPerf) { - const afterEndTime = performance.now(); - - this.statsTickData.before = engineStartTime - beforeStartTime - this.statsTickData.engine = engineEndTime - engineStartTime - this.statsTickData.after = afterEndTime - engineEndTime - this.statsTickData.total = afterEndTime - beforeStartTime - - this.el.emit("physics-tick-data", this.statsTickData) - - this.tickCounter++; - - if (this.tickCounter === 100) { - - this.countBodies[this.data.driver]() - - if (this.statsToConsole) { - console.log("Physics body stats:", this.statsBodyData) - } - - if (this.statsToEvents || this.statsToPanel) { - this.el.emit("physics-body-data", this.statsBodyData) - } - this.tickCounter = 0; - } - } - }, - - countBodiesAmmo() { - - const statsData = this.statsBodyData - statsData.manifolds = this.driver.dispatcher.getNumManifolds(); - statsData.manifoldContacts = 0; - for (let i = 0; i < statsData.manifolds; i++) { - const manifold = this.driver.dispatcher.getManifoldByIndexInternal(i); - statsData.manifoldContacts += manifold.getNumContacts(); - } - statsData.collisions = this.driver.collisions.size; - statsData.collisionKeys = this.driver.collisionKeys.length; - statsData.staticBodies = 0 - statsData.kinematicBodies = 0 - statsData.dynamicBodies = 0 - - function type(el) { - return el.components['ammo-body'].data.type - } - - this.driver.els.forEach((el) => { - const property = this.bodyTypeToStatsPropertyMap["ammo"][type(el)] - statsData[property]++ - }) - }, - - countBodiesCannon(worker) { - - const statsData = this.statsBodyData - statsData.contacts = worker ? this.driver.contacts.length : this.driver.world.contacts.length; - statsData.staticBodies = 0 - statsData.dynamicBodies = 0 - - const bodies = worker ? Object.values(this.driver.bodies) : this.driver.world.bodies - - bodies.forEach((body) => { - const property = this.bodyTypeToStatsPropertyMap["cannon"][body.type] - statsData[property]++ - }) - }, - - setDebug: function(debug) { - this.debug = debug; - if (this.data.driver === 'ammo' && this.initialized) { - if (debug && !this.debugDrawer) { - this.debugDrawer = this.driver.getDebugDrawer(this.el.object3D); - this.debugDrawer.enable(); - } else if (this.debugDrawer) { - this.debugDrawer.disable(); - this.debugDrawer = null; - } - } - }, - - /** - * Adds a body to the scene, and binds proxied methods to the driver. - * @param {CANNON.Body} body - */ - addBody: function (body, group, mask) { - var driver = this.driver; - - if (this.data.driver === 'local') { - body.__applyImpulse = body.applyImpulse; - body.applyImpulse = function () { - driver.applyBodyMethod(body, 'applyImpulse', arguments); - }; - - body.__applyForce = body.applyForce; - body.applyForce = function () { - driver.applyBodyMethod(body, 'applyForce', arguments); - }; - - body.updateProperties = function () { - driver.updateBodyProperties(body); - }; - - this.listeners[body.id] = function (e) { body.el.emit('collide', e); }; - body.addEventListener('collide', this.listeners[body.id]); - } - - this.driver.addBody(body, group, mask); - }, - - /** - * Removes a body and its proxied methods. - * @param {CANNON.Body} body - */ - removeBody: function (body) { - this.driver.removeBody(body); - - if (this.data.driver === 'local' || this.data.driver === 'worker') { - body.removeEventListener('collide', this.listeners[body.id]); - delete this.listeners[body.id]; - - body.applyImpulse = body.__applyImpulse; - delete body.__applyImpulse; - - body.applyForce = body.__applyForce; - delete body.__applyForce; - - delete body.updateProperties; - } - }, - - /** @param {CANNON.Constraint or Ammo.btTypedConstraint} constraint */ - addConstraint: function (constraint) { - this.driver.addConstraint(constraint); - }, - - /** @param {CANNON.Constraint or Ammo.btTypedConstraint} constraint */ - removeConstraint: function (constraint) { - this.driver.removeConstraint(constraint); - }, - - /** - * Adds a component instance to the system and schedules its update methods to be called - * the given phase. - * @param {Component} component - * @param {string} phase - */ - addComponent: function (component) { - var callbacks = this.callbacks; - if (component.beforeStep) callbacks.beforeStep.push(component); - if (component.step) callbacks.step.push(component); - if (component.afterStep) callbacks.afterStep.push(component); - }, - - /** - * Removes a component instance from the system. - * @param {Component} component - * @param {string} phase - */ - removeComponent: function (component) { - var callbacks = this.callbacks; - if (component.beforeStep) { - callbacks.beforeStep.splice(callbacks.beforeStep.indexOf(component), 1); - } - if (component.step) { - callbacks.step.splice(callbacks.step.indexOf(component), 1); - } - if (component.afterStep) { - callbacks.afterStep.splice(callbacks.afterStep.indexOf(component), 1); - } - }, - - /** @return {Array} */ - getContacts: function () { - return this.driver.getContacts(); - }, - - getMaterial: function (name) { - return this.driver.getMaterial(name); - } -}); +eval("var cannonEs = __webpack_require__(/*! cannon-es */ \"./node_modules/cannon-es/dist/cannon-es.js\");\nvar three = __webpack_require__(/*! three */ \"./node_modules/three/build/three.cjs\");\n\n/**\n * Ported from: https://github.com/maurizzzio/quickhull3d/ by Mauricio Poppe (https://github.com/maurizzzio)\n */\n\nvar ConvexHull = function () {\n var Visible = 0;\n var Deleted = 1;\n var v1 = new three.Vector3();\n\n function ConvexHull() {\n this.tolerance = -1;\n this.faces = []; // the generated faces of the convex hull\n\n this.newFaces = []; // this array holds the faces that are generated within a single iteration\n // the vertex lists work as follows:\n //\n // let 'a' and 'b' be 'Face' instances\n // let 'v' be points wrapped as instance of 'Vertex'\n //\n // [v, v, ..., v, v, v, ...]\n // ^ ^\n // | |\n // a.outside b.outside\n //\n\n this.assigned = new VertexList();\n this.unassigned = new VertexList();\n this.vertices = []; // vertices of the hull (internal representation of given geometry data)\n }\n\n Object.assign(ConvexHull.prototype, {\n setFromPoints: function (points) {\n if (Array.isArray(points) !== true) {\n console.error('THREE.ConvexHull: Points parameter is not an array.');\n }\n\n if (points.length < 4) {\n console.error('THREE.ConvexHull: The algorithm needs at least four points.');\n }\n\n this.makeEmpty();\n\n for (var i = 0, l = points.length; i < l; i++) {\n this.vertices.push(new VertexNode(points[i]));\n }\n\n this.compute();\n return this;\n },\n setFromObject: function (object) {\n var points = [];\n object.updateMatrixWorld(true);\n object.traverse(function (node) {\n var i, l, point;\n var geometry = node.geometry;\n if (geometry === undefined) return;\n\n if (geometry.isGeometry) {\n geometry = geometry.toBufferGeometry ? geometry.toBufferGeometry() : new three.BufferGeometry().fromGeometry(geometry);\n }\n\n if (geometry.isBufferGeometry) {\n var attribute = geometry.attributes.position;\n\n if (attribute !== undefined) {\n for (i = 0, l = attribute.count; i < l; i++) {\n point = new three.Vector3();\n point.fromBufferAttribute(attribute, i).applyMatrix4(node.matrixWorld);\n points.push(point);\n }\n }\n }\n });\n return this.setFromPoints(points);\n },\n containsPoint: function (point) {\n var faces = this.faces;\n\n for (var i = 0, l = faces.length; i < l; i++) {\n var face = faces[i]; // compute signed distance and check on what half space the point lies\n\n if (face.distanceToPoint(point) > this.tolerance) return false;\n }\n\n return true;\n },\n intersectRay: function (ray, target) {\n // based on \"Fast Ray-Convex Polyhedron Intersection\" by Eric Haines, GRAPHICS GEMS II\n var faces = this.faces;\n var tNear = -Infinity;\n var tFar = Infinity;\n\n for (var i = 0, l = faces.length; i < l; i++) {\n var face = faces[i]; // interpret faces as planes for the further computation\n\n var vN = face.distanceToPoint(ray.origin);\n var vD = face.normal.dot(ray.direction); // if the origin is on the positive side of a plane (so the plane can \"see\" the origin) and\n // the ray is turned away or parallel to the plane, there is no intersection\n\n if (vN > 0 && vD >= 0) return null; // compute the distance from the ray’s origin to the intersection with the plane\n\n var t = vD !== 0 ? -vN / vD : 0; // only proceed if the distance is positive. a negative distance means the intersection point\n // lies \"behind\" the origin\n\n if (t <= 0) continue; // now categorized plane as front-facing or back-facing\n\n if (vD > 0) {\n // plane faces away from the ray, so this plane is a back-face\n tFar = Math.min(t, tFar);\n } else {\n // front-face\n tNear = Math.max(t, tNear);\n }\n\n if (tNear > tFar) {\n // if tNear ever is greater than tFar, the ray must miss the convex hull\n return null;\n }\n } // evaluate intersection point\n // always try tNear first since its the closer intersection point\n\n\n if (tNear !== -Infinity) {\n ray.at(tNear, target);\n } else {\n ray.at(tFar, target);\n }\n\n return target;\n },\n intersectsRay: function (ray) {\n return this.intersectRay(ray, v1) !== null;\n },\n makeEmpty: function () {\n this.faces = [];\n this.vertices = [];\n return this;\n },\n // Adds a vertex to the 'assigned' list of vertices and assigns it to the given face\n addVertexToFace: function (vertex, face) {\n vertex.face = face;\n\n if (face.outside === null) {\n this.assigned.append(vertex);\n } else {\n this.assigned.insertBefore(face.outside, vertex);\n }\n\n face.outside = vertex;\n return this;\n },\n // Removes a vertex from the 'assigned' list of vertices and from the given face\n removeVertexFromFace: function (vertex, face) {\n if (vertex === face.outside) {\n // fix face.outside link\n if (vertex.next !== null && vertex.next.face === face) {\n // face has at least 2 outside vertices, move the 'outside' reference\n face.outside = vertex.next;\n } else {\n // vertex was the only outside vertex that face had\n face.outside = null;\n }\n }\n\n this.assigned.remove(vertex);\n return this;\n },\n // Removes all the visible vertices that a given face is able to see which are stored in the 'assigned' vertext list\n removeAllVerticesFromFace: function (face) {\n if (face.outside !== null) {\n // reference to the first and last vertex of this face\n var start = face.outside;\n var end = face.outside;\n\n while (end.next !== null && end.next.face === face) {\n end = end.next;\n }\n\n this.assigned.removeSubList(start, end); // fix references\n\n start.prev = end.next = null;\n face.outside = null;\n return start;\n }\n },\n // Removes all the visible vertices that 'face' is able to see\n deleteFaceVertices: function (face, absorbingFace) {\n var faceVertices = this.removeAllVerticesFromFace(face);\n\n if (faceVertices !== undefined) {\n if (absorbingFace === undefined) {\n // mark the vertices to be reassigned to some other face\n this.unassigned.appendChain(faceVertices);\n } else {\n // if there's an absorbing face try to assign as many vertices as possible to it\n var vertex = faceVertices;\n\n do {\n // we need to buffer the subsequent vertex at this point because the 'vertex.next' reference\n // will be changed by upcoming method calls\n var nextVertex = vertex.next;\n var distance = absorbingFace.distanceToPoint(vertex.point); // check if 'vertex' is able to see 'absorbingFace'\n\n if (distance > this.tolerance) {\n this.addVertexToFace(vertex, absorbingFace);\n } else {\n this.unassigned.append(vertex);\n } // now assign next vertex\n\n\n vertex = nextVertex;\n } while (vertex !== null);\n }\n }\n\n return this;\n },\n // Reassigns as many vertices as possible from the unassigned list to the new faces\n resolveUnassignedPoints: function (newFaces) {\n if (this.unassigned.isEmpty() === false) {\n var vertex = this.unassigned.first();\n\n do {\n // buffer 'next' reference, see .deleteFaceVertices()\n var nextVertex = vertex.next;\n var maxDistance = this.tolerance;\n var maxFace = null;\n\n for (var i = 0; i < newFaces.length; i++) {\n var face = newFaces[i];\n\n if (face.mark === Visible) {\n var distance = face.distanceToPoint(vertex.point);\n\n if (distance > maxDistance) {\n maxDistance = distance;\n maxFace = face;\n }\n\n if (maxDistance > 1000 * this.tolerance) break;\n }\n } // 'maxFace' can be null e.g. if there are identical vertices\n\n\n if (maxFace !== null) {\n this.addVertexToFace(vertex, maxFace);\n }\n\n vertex = nextVertex;\n } while (vertex !== null);\n }\n\n return this;\n },\n // Computes the extremes of a simplex which will be the initial hull\n computeExtremes: function () {\n var min = new three.Vector3();\n var max = new three.Vector3();\n var minVertices = [];\n var maxVertices = [];\n var i, l, j; // initially assume that the first vertex is the min/max\n\n for (i = 0; i < 3; i++) {\n minVertices[i] = maxVertices[i] = this.vertices[0];\n }\n\n min.copy(this.vertices[0].point);\n max.copy(this.vertices[0].point); // compute the min/max vertex on all six directions\n\n for (i = 0, l = this.vertices.length; i < l; i++) {\n var vertex = this.vertices[i];\n var point = vertex.point; // update the min coordinates\n\n for (j = 0; j < 3; j++) {\n if (point.getComponent(j) < min.getComponent(j)) {\n min.setComponent(j, point.getComponent(j));\n minVertices[j] = vertex;\n }\n } // update the max coordinates\n\n\n for (j = 0; j < 3; j++) {\n if (point.getComponent(j) > max.getComponent(j)) {\n max.setComponent(j, point.getComponent(j));\n maxVertices[j] = vertex;\n }\n }\n } // use min/max vectors to compute an optimal epsilon\n\n\n this.tolerance = 3 * Number.EPSILON * (Math.max(Math.abs(min.x), Math.abs(max.x)) + Math.max(Math.abs(min.y), Math.abs(max.y)) + Math.max(Math.abs(min.z), Math.abs(max.z)));\n return {\n min: minVertices,\n max: maxVertices\n };\n },\n // Computes the initial simplex assigning to its faces all the points\n // that are candidates to form part of the hull\n computeInitialHull: function () {\n var line3, plane, closestPoint;\n return function computeInitialHull() {\n if (line3 === undefined) {\n line3 = new three.Line3();\n plane = new three.Plane();\n closestPoint = new three.Vector3();\n }\n\n var vertex,\n vertices = this.vertices;\n var extremes = this.computeExtremes();\n var min = extremes.min;\n var max = extremes.max;\n var v0, v1, v2, v3;\n var i, l, j; // 1. Find the two vertices 'v0' and 'v1' with the greatest 1d separation\n // (max.x - min.x)\n // (max.y - min.y)\n // (max.z - min.z)\n\n var distance,\n maxDistance = 0;\n var index = 0;\n\n for (i = 0; i < 3; i++) {\n distance = max[i].point.getComponent(i) - min[i].point.getComponent(i);\n\n if (distance > maxDistance) {\n maxDistance = distance;\n index = i;\n }\n }\n\n v0 = min[index];\n v1 = max[index]; // 2. The next vertex 'v2' is the one farthest to the line formed by 'v0' and 'v1'\n\n maxDistance = 0;\n line3.set(v0.point, v1.point);\n\n for (i = 0, l = this.vertices.length; i < l; i++) {\n vertex = vertices[i];\n\n if (vertex !== v0 && vertex !== v1) {\n line3.closestPointToPoint(vertex.point, true, closestPoint);\n distance = closestPoint.distanceToSquared(vertex.point);\n\n if (distance > maxDistance) {\n maxDistance = distance;\n v2 = vertex;\n }\n }\n } // 3. The next vertex 'v3' is the one farthest to the plane 'v0', 'v1', 'v2'\n\n\n maxDistance = -1;\n plane.setFromCoplanarPoints(v0.point, v1.point, v2.point);\n\n for (i = 0, l = this.vertices.length; i < l; i++) {\n vertex = vertices[i];\n\n if (vertex !== v0 && vertex !== v1 && vertex !== v2) {\n distance = Math.abs(plane.distanceToPoint(vertex.point));\n\n if (distance > maxDistance) {\n maxDistance = distance;\n v3 = vertex;\n }\n }\n }\n\n var faces = [];\n\n if (plane.distanceToPoint(v3.point) < 0) {\n // the face is not able to see the point so 'plane.normal' is pointing outside the tetrahedron\n faces.push(Face.create(v0, v1, v2), Face.create(v3, v1, v0), Face.create(v3, v2, v1), Face.create(v3, v0, v2)); // set the twin edge\n\n for (i = 0; i < 3; i++) {\n j = (i + 1) % 3; // join face[ i ] i > 0, with the first face\n\n faces[i + 1].getEdge(2).setTwin(faces[0].getEdge(j)); // join face[ i ] with face[ i + 1 ], 1 <= i <= 3\n\n faces[i + 1].getEdge(1).setTwin(faces[j + 1].getEdge(0));\n }\n } else {\n // the face is able to see the point so 'plane.normal' is pointing inside the tetrahedron\n faces.push(Face.create(v0, v2, v1), Face.create(v3, v0, v1), Face.create(v3, v1, v2), Face.create(v3, v2, v0)); // set the twin edge\n\n for (i = 0; i < 3; i++) {\n j = (i + 1) % 3; // join face[ i ] i > 0, with the first face\n\n faces[i + 1].getEdge(2).setTwin(faces[0].getEdge((3 - i) % 3)); // join face[ i ] with face[ i + 1 ]\n\n faces[i + 1].getEdge(0).setTwin(faces[j + 1].getEdge(1));\n }\n } // the initial hull is the tetrahedron\n\n\n for (i = 0; i < 4; i++) {\n this.faces.push(faces[i]);\n } // initial assignment of vertices to the faces of the tetrahedron\n\n\n for (i = 0, l = vertices.length; i < l; i++) {\n vertex = vertices[i];\n\n if (vertex !== v0 && vertex !== v1 && vertex !== v2 && vertex !== v3) {\n maxDistance = this.tolerance;\n var maxFace = null;\n\n for (j = 0; j < 4; j++) {\n distance = this.faces[j].distanceToPoint(vertex.point);\n\n if (distance > maxDistance) {\n maxDistance = distance;\n maxFace = this.faces[j];\n }\n }\n\n if (maxFace !== null) {\n this.addVertexToFace(vertex, maxFace);\n }\n }\n }\n\n return this;\n };\n }(),\n // Removes inactive faces\n reindexFaces: function () {\n var activeFaces = [];\n\n for (var i = 0; i < this.faces.length; i++) {\n var face = this.faces[i];\n\n if (face.mark === Visible) {\n activeFaces.push(face);\n }\n }\n\n this.faces = activeFaces;\n return this;\n },\n // Finds the next vertex to create faces with the current hull\n nextVertexToAdd: function () {\n // if the 'assigned' list of vertices is empty, no vertices are left. return with 'undefined'\n if (this.assigned.isEmpty() === false) {\n var eyeVertex,\n maxDistance = 0; // grap the first available face and start with the first visible vertex of that face\n\n var eyeFace = this.assigned.first().face;\n var vertex = eyeFace.outside; // now calculate the farthest vertex that face can see\n\n do {\n var distance = eyeFace.distanceToPoint(vertex.point);\n\n if (distance > maxDistance) {\n maxDistance = distance;\n eyeVertex = vertex;\n }\n\n vertex = vertex.next;\n } while (vertex !== null && vertex.face === eyeFace);\n\n return eyeVertex;\n }\n },\n // Computes a chain of half edges in CCW order called the 'horizon'.\n // For an edge to be part of the horizon it must join a face that can see\n // 'eyePoint' and a face that cannot see 'eyePoint'.\n computeHorizon: function (eyePoint, crossEdge, face, horizon) {\n // moves face's vertices to the 'unassigned' vertex list\n this.deleteFaceVertices(face);\n face.mark = Deleted;\n var edge;\n\n if (crossEdge === null) {\n edge = crossEdge = face.getEdge(0);\n } else {\n // start from the next edge since 'crossEdge' was already analyzed\n // (actually 'crossEdge.twin' was the edge who called this method recursively)\n edge = crossEdge.next;\n }\n\n do {\n var twinEdge = edge.twin;\n var oppositeFace = twinEdge.face;\n\n if (oppositeFace.mark === Visible) {\n if (oppositeFace.distanceToPoint(eyePoint) > this.tolerance) {\n // the opposite face can see the vertex, so proceed with next edge\n this.computeHorizon(eyePoint, twinEdge, oppositeFace, horizon);\n } else {\n // the opposite face can't see the vertex, so this edge is part of the horizon\n horizon.push(edge);\n }\n }\n\n edge = edge.next;\n } while (edge !== crossEdge);\n\n return this;\n },\n // Creates a face with the vertices 'eyeVertex.point', 'horizonEdge.tail' and 'horizonEdge.head' in CCW order\n addAdjoiningFace: function (eyeVertex, horizonEdge) {\n // all the half edges are created in ccw order thus the face is always pointing outside the hull\n var face = Face.create(eyeVertex, horizonEdge.tail(), horizonEdge.head());\n this.faces.push(face); // join face.getEdge( - 1 ) with the horizon's opposite edge face.getEdge( - 1 ) = face.getEdge( 2 )\n\n face.getEdge(-1).setTwin(horizonEdge.twin);\n return face.getEdge(0); // the half edge whose vertex is the eyeVertex\n },\n // Adds 'horizon.length' faces to the hull, each face will be linked with the\n // horizon opposite face and the face on the left/right\n addNewFaces: function (eyeVertex, horizon) {\n this.newFaces = [];\n var firstSideEdge = null;\n var previousSideEdge = null;\n\n for (var i = 0; i < horizon.length; i++) {\n var horizonEdge = horizon[i]; // returns the right side edge\n\n var sideEdge = this.addAdjoiningFace(eyeVertex, horizonEdge);\n\n if (firstSideEdge === null) {\n firstSideEdge = sideEdge;\n } else {\n // joins face.getEdge( 1 ) with previousFace.getEdge( 0 )\n sideEdge.next.setTwin(previousSideEdge);\n }\n\n this.newFaces.push(sideEdge.face);\n previousSideEdge = sideEdge;\n } // perform final join of new faces\n\n\n firstSideEdge.next.setTwin(previousSideEdge);\n return this;\n },\n // Adds a vertex to the hull\n addVertexToHull: function (eyeVertex) {\n var horizon = [];\n this.unassigned.clear(); // remove 'eyeVertex' from 'eyeVertex.face' so that it can't be added to the 'unassigned' vertex list\n\n this.removeVertexFromFace(eyeVertex, eyeVertex.face);\n this.computeHorizon(eyeVertex.point, null, eyeVertex.face, horizon);\n this.addNewFaces(eyeVertex, horizon); // reassign 'unassigned' vertices to the new faces\n\n this.resolveUnassignedPoints(this.newFaces);\n return this;\n },\n cleanup: function () {\n this.assigned.clear();\n this.unassigned.clear();\n this.newFaces = [];\n return this;\n },\n compute: function () {\n var vertex;\n this.computeInitialHull(); // add all available vertices gradually to the hull\n\n while ((vertex = this.nextVertexToAdd()) !== undefined) {\n this.addVertexToHull(vertex);\n }\n\n this.reindexFaces();\n this.cleanup();\n return this;\n }\n }); //\n\n function Face() {\n this.normal = new three.Vector3();\n this.midpoint = new three.Vector3();\n this.area = 0;\n this.constant = 0; // signed distance from face to the origin\n\n this.outside = null; // reference to a vertex in a vertex list this face can see\n\n this.mark = Visible;\n this.edge = null;\n }\n\n Object.assign(Face, {\n create: function (a, b, c) {\n var face = new Face();\n var e0 = new HalfEdge(a, face);\n var e1 = new HalfEdge(b, face);\n var e2 = new HalfEdge(c, face); // join edges\n\n e0.next = e2.prev = e1;\n e1.next = e0.prev = e2;\n e2.next = e1.prev = e0; // main half edge reference\n\n face.edge = e0;\n return face.compute();\n }\n });\n Object.assign(Face.prototype, {\n getEdge: function (i) {\n var edge = this.edge;\n\n while (i > 0) {\n edge = edge.next;\n i--;\n }\n\n while (i < 0) {\n edge = edge.prev;\n i++;\n }\n\n return edge;\n },\n compute: function () {\n var triangle;\n return function compute() {\n if (triangle === undefined) triangle = new three.Triangle();\n var a = this.edge.tail();\n var b = this.edge.head();\n var c = this.edge.next.head();\n triangle.set(a.point, b.point, c.point);\n triangle.getNormal(this.normal);\n triangle.getMidpoint(this.midpoint);\n this.area = triangle.getArea();\n this.constant = this.normal.dot(this.midpoint);\n return this;\n };\n }(),\n distanceToPoint: function (point) {\n return this.normal.dot(point) - this.constant;\n }\n }); // Entity for a Doubly-Connected Edge List (DCEL).\n\n function HalfEdge(vertex, face) {\n this.vertex = vertex;\n this.prev = null;\n this.next = null;\n this.twin = null;\n this.face = face;\n }\n\n Object.assign(HalfEdge.prototype, {\n head: function () {\n return this.vertex;\n },\n tail: function () {\n return this.prev ? this.prev.vertex : null;\n },\n length: function () {\n var head = this.head();\n var tail = this.tail();\n\n if (tail !== null) {\n return tail.point.distanceTo(head.point);\n }\n\n return -1;\n },\n lengthSquared: function () {\n var head = this.head();\n var tail = this.tail();\n\n if (tail !== null) {\n return tail.point.distanceToSquared(head.point);\n }\n\n return -1;\n },\n setTwin: function (edge) {\n this.twin = edge;\n edge.twin = this;\n return this;\n }\n }); // A vertex as a double linked list node.\n\n function VertexNode(point) {\n this.point = point;\n this.prev = null;\n this.next = null;\n this.face = null; // the face that is able to see this vertex\n } // A double linked list that contains vertex nodes.\n\n\n function VertexList() {\n this.head = null;\n this.tail = null;\n }\n\n Object.assign(VertexList.prototype, {\n first: function () {\n return this.head;\n },\n last: function () {\n return this.tail;\n },\n clear: function () {\n this.head = this.tail = null;\n return this;\n },\n // Inserts a vertex before the target vertex\n insertBefore: function (target, vertex) {\n vertex.prev = target.prev;\n vertex.next = target;\n\n if (vertex.prev === null) {\n this.head = vertex;\n } else {\n vertex.prev.next = vertex;\n }\n\n target.prev = vertex;\n return this;\n },\n // Inserts a vertex after the target vertex\n insertAfter: function (target, vertex) {\n vertex.prev = target;\n vertex.next = target.next;\n\n if (vertex.next === null) {\n this.tail = vertex;\n } else {\n vertex.next.prev = vertex;\n }\n\n target.next = vertex;\n return this;\n },\n // Appends a vertex to the end of the linked list\n append: function (vertex) {\n if (this.head === null) {\n this.head = vertex;\n } else {\n this.tail.next = vertex;\n }\n\n vertex.prev = this.tail;\n vertex.next = null; // the tail has no subsequent vertex\n\n this.tail = vertex;\n return this;\n },\n // Appends a chain of vertices where 'vertex' is the head.\n appendChain: function (vertex) {\n if (this.head === null) {\n this.head = vertex;\n } else {\n this.tail.next = vertex;\n }\n\n vertex.prev = this.tail; // ensure that the 'tail' reference points to the last vertex of the chain\n\n while (vertex.next !== null) {\n vertex = vertex.next;\n }\n\n this.tail = vertex;\n return this;\n },\n // Removes a vertex from the linked list\n remove: function (vertex) {\n if (vertex.prev === null) {\n this.head = vertex.next;\n } else {\n vertex.prev.next = vertex.next;\n }\n\n if (vertex.next === null) {\n this.tail = vertex.prev;\n } else {\n vertex.next.prev = vertex.prev;\n }\n\n return this;\n },\n // Removes a list of vertices whose 'head' is 'a' and whose 'tail' is b\n removeSubList: function (a, b) {\n if (a.prev === null) {\n this.head = b.next;\n } else {\n a.prev.next = b.next;\n }\n\n if (b.next === null) {\n this.tail = a.prev;\n } else {\n b.next.prev = a.prev;\n }\n\n return this;\n },\n isEmpty: function () {\n return this.head === null;\n }\n });\n return ConvexHull;\n}();\n\nconst _v1 = new three.Vector3();\n\nconst _v2 = new three.Vector3();\n\nconst _q1 = new three.Quaternion();\n/**\r\n* Returns a single geometry for the given object. If the object is compound,\r\n* its geometries are automatically merged. Bake world scale into each\r\n* geometry, because we can't easily apply that to the cannonjs shapes later.\r\n*/\n\n\nfunction getGeometry(object) {\n const meshes = getMeshes(object);\n if (meshes.length === 0) return null; // Single mesh. Return, preserving original type.\n\n if (meshes.length === 1) {\n return normalizeGeometry(meshes[0]);\n } // Multiple meshes. Merge and return.\n\n\n let mesh;\n const geometries = [];\n\n while (mesh = meshes.pop()) {\n geometries.push(simplifyGeometry(normalizeGeometry(mesh)));\n }\n\n return mergeBufferGeometries(geometries);\n}\n\nfunction normalizeGeometry(mesh) {\n let geometry = mesh.geometry;\n\n if (geometry.toBufferGeometry) {\n geometry = geometry.toBufferGeometry();\n } else {\n // Preserve original type, e.g. CylinderBufferGeometry.\n geometry = geometry.clone();\n }\n\n mesh.updateMatrixWorld();\n mesh.matrixWorld.decompose(_v1, _q1, _v2);\n geometry.scale(_v2.x, _v2.y, _v2.z);\n return geometry;\n}\n/**\r\n * Greatly simplified version of BufferGeometryUtils.mergeBufferGeometries.\r\n * Because we only care about the vertex positions, and not the indices or\r\n * other attributes, we throw everything else away.\r\n */\n\n\nfunction mergeBufferGeometries(geometries) {\n let vertexCount = 0;\n\n for (let i = 0; i < geometries.length; i++) {\n const position = geometries[i].attributes.position;\n\n if (position && position.itemSize === 3) {\n vertexCount += position.count;\n }\n }\n\n const positionArray = new Float32Array(vertexCount * 3);\n let positionOffset = 0;\n\n for (let i = 0; i < geometries.length; i++) {\n const position = geometries[i].attributes.position;\n\n if (position && position.itemSize === 3) {\n for (let j = 0; j < position.count; j++) {\n positionArray[positionOffset++] = position.getX(j);\n positionArray[positionOffset++] = position.getY(j);\n positionArray[positionOffset++] = position.getZ(j);\n }\n }\n }\n\n return new three.BufferGeometry().setAttribute('position', new three.BufferAttribute(positionArray, 3));\n}\n\nfunction getVertices(geometry) {\n const position = geometry.attributes.position;\n const vertices = new Float32Array(position.count * 3);\n\n for (let i = 0; i < position.count; i++) {\n vertices[i * 3] = position.getX(i);\n vertices[i * 3 + 1] = position.getY(i);\n vertices[i * 3 + 2] = position.getZ(i);\n }\n\n return vertices;\n}\n/**\r\n* Returns a flat array of THREE.Mesh instances from the given object. If\r\n* nested transformations are found, they are applied to child meshes\r\n* as mesh.userData.matrix, so that each mesh has its position/rotation/scale\r\n* independently of all of its parents except the top-level object.\r\n*/\n\nfunction getMeshes(object) {\n const meshes = [];\n object.traverse(function (o) {\n if (o.isMesh) {\n meshes.push(o);\n }\n });\n return meshes;\n}\n\nfunction getComponent(v, component) {\n switch (component) {\n case 'x':\n return v.x;\n\n case 'y':\n return v.y;\n\n case 'z':\n return v.z;\n }\n\n throw new Error(\"Unexpected component \" + component);\n}\n/**\r\n* Modified version of BufferGeometryUtils.mergeVertices, ignoring vertex\r\n* attributes other than position.\r\n*\r\n* @param {THREE.BufferGeometry} geometry\r\n* @param {number} tolerance\r\n* @return {THREE.BufferGeometry>}\r\n*/\n\nfunction simplifyGeometry(geometry, tolerance = 1e-4) {\n tolerance = Math.max(tolerance, Number.EPSILON); // Generate an index buffer if the geometry doesn't have one, or optimize it\n // if it's already available.\n\n const hashToIndex = {};\n const indices = geometry.getIndex();\n const positions = geometry.getAttribute('position');\n const vertexCount = indices ? indices.count : positions.count; // Next value for triangle indices.\n\n let nextIndex = 0;\n const newIndices = [];\n const newPositions = []; // Convert the error tolerance to an amount of decimal places to truncate to.\n\n const decimalShift = Math.log10(1 / tolerance);\n const shiftMultiplier = Math.pow(10, decimalShift);\n\n for (let i = 0; i < vertexCount; i++) {\n const index = indices ? indices.getX(i) : i; // Generate a hash for the vertex attributes at the current index 'i'.\n\n let hash = ''; // Double tilde truncates the decimal value.\n\n hash += ~~(positions.getX(index) * shiftMultiplier) + \",\";\n hash += ~~(positions.getY(index) * shiftMultiplier) + \",\";\n hash += ~~(positions.getZ(index) * shiftMultiplier) + \",\"; // Add another reference to the vertex if it's already\n // used by another index.\n\n if (hash in hashToIndex) {\n newIndices.push(hashToIndex[hash]);\n } else {\n newPositions.push(positions.getX(index));\n newPositions.push(positions.getY(index));\n newPositions.push(positions.getZ(index));\n hashToIndex[hash] = nextIndex;\n newIndices.push(nextIndex);\n nextIndex++;\n }\n } // Construct merged BufferGeometry.\n\n\n const positionAttribute = new three.BufferAttribute(new Float32Array(newPositions), positions.itemSize, positions.normalized);\n const result = new three.BufferGeometry();\n result.setAttribute('position', positionAttribute);\n result.setIndex(newIndices);\n return result;\n}\n\nconst PI_2 = Math.PI / 2;\nexports.ShapeType = void 0;\n\n(function (ShapeType) {\n ShapeType[\"BOX\"] = \"Box\";\n ShapeType[\"CYLINDER\"] = \"Cylinder\";\n ShapeType[\"SPHERE\"] = \"Sphere\";\n ShapeType[\"HULL\"] = \"ConvexPolyhedron\";\n ShapeType[\"MESH\"] = \"Trimesh\";\n})(exports.ShapeType || (exports.ShapeType = {}));\n/**\r\n * Given a THREE.Object3D instance, creates parameters for a CANNON shape.\r\n */\n\n\nconst getShapeParameters = function (object, options = {}) {\n let geometry;\n\n if (options.type === exports.ShapeType.BOX) {\n return getBoundingBoxParameters(object);\n } else if (options.type === exports.ShapeType.CYLINDER) {\n return getBoundingCylinderParameters(object, options);\n } else if (options.type === exports.ShapeType.SPHERE) {\n return getBoundingSphereParameters(object, options);\n } else if (options.type === exports.ShapeType.HULL) {\n return getConvexPolyhedronParameters(object);\n } else if (options.type === exports.ShapeType.MESH) {\n geometry = getGeometry(object);\n return geometry ? getTrimeshParameters(geometry) : null;\n } else if (options.type) {\n throw new Error(\"[CANNON.getShapeParameters] Invalid type \\\"\" + options.type + \"\\\".\");\n }\n\n geometry = getGeometry(object);\n if (!geometry) return null;\n\n switch (geometry.type) {\n case 'BoxGeometry':\n case 'BoxBufferGeometry':\n return getBoxParameters(geometry);\n\n case 'CylinderGeometry':\n case 'CylinderBufferGeometry':\n return getCylinderParameters(geometry);\n\n case 'PlaneGeometry':\n case 'PlaneBufferGeometry':\n return getPlaneParameters(geometry);\n\n case 'SphereGeometry':\n case 'SphereBufferGeometry':\n return getSphereParameters(geometry);\n\n case 'TubeGeometry':\n case 'BufferGeometry':\n return getBoundingBoxParameters(object);\n\n default:\n console.warn('Unrecognized geometry: \"%s\". Using bounding box as shape.', geometry.type);\n return getBoxParameters(geometry);\n }\n};\n/**\r\n * Given a THREE.Object3D instance, creates a corresponding CANNON shape.\r\n */\n\nconst threeToCannon = function (object, options = {}) {\n const shapeParameters = getShapeParameters(object, options);\n\n if (!shapeParameters) {\n return null;\n }\n\n const {\n type,\n params,\n offset,\n orientation\n } = shapeParameters;\n let shape;\n\n if (type === exports.ShapeType.BOX) {\n shape = createBox(params);\n } else if (type === exports.ShapeType.CYLINDER) {\n shape = createCylinder(params);\n } else if (type === exports.ShapeType.SPHERE) {\n shape = createSphere(params);\n } else if (type === exports.ShapeType.HULL) {\n shape = createConvexPolyhedron(params);\n } else {\n shape = createTrimesh(params);\n }\n\n return {\n shape,\n offset,\n orientation\n };\n};\n/******************************************************************************\r\n * Shape construction\r\n */\n\nfunction createBox(params) {\n const {\n x,\n y,\n z\n } = params;\n const shape = new cannonEs.Box(new cannonEs.Vec3(x, y, z));\n return shape;\n}\n\nfunction createCylinder(params) {\n const {\n radiusTop,\n radiusBottom,\n height,\n segments\n } = params;\n const shape = new cannonEs.Cylinder(radiusTop, radiusBottom, height, segments); // Include metadata for serialization.\n // TODO(cleanup): Is this still necessary?\n\n shape.radiusTop = radiusBottom;\n shape.radiusBottom = radiusBottom;\n shape.height = height;\n shape.numSegments = segments;\n return shape;\n}\n\nfunction createSphere(params) {\n const shape = new cannonEs.Sphere(params.radius);\n return shape;\n}\n\nfunction createConvexPolyhedron(params) {\n const {\n faces,\n vertices: verticesArray\n } = params;\n const vertices = [];\n\n for (let i = 0; i < verticesArray.length; i += 3) {\n vertices.push(new cannonEs.Vec3(verticesArray[i], verticesArray[i + 1], verticesArray[i + 2]));\n }\n\n const shape = new cannonEs.ConvexPolyhedron({\n faces,\n vertices\n });\n return shape;\n}\n\nfunction createTrimesh(params) {\n const {\n vertices,\n indices\n } = params;\n const shape = new cannonEs.Trimesh(vertices, indices);\n return shape;\n}\n/******************************************************************************\r\n * Shape parameters\r\n */\n\n\nfunction getBoxParameters(geometry) {\n const vertices = getVertices(geometry);\n if (!vertices.length) return null;\n geometry.computeBoundingBox();\n const box = geometry.boundingBox;\n return {\n type: exports.ShapeType.BOX,\n params: {\n x: (box.max.x - box.min.x) / 2,\n y: (box.max.y - box.min.y) / 2,\n z: (box.max.z - box.min.z) / 2\n }\n };\n}\n/** Bounding box needs to be computed with the entire subtree, not just geometry. */\n\n\nfunction getBoundingBoxParameters(object) {\n const clone = object.clone();\n clone.quaternion.set(0, 0, 0, 1);\n clone.updateMatrixWorld();\n const box = new three.Box3().setFromObject(clone);\n if (!isFinite(box.min.lengthSq())) return null;\n const localPosition = box.translate(clone.position.negate()).getCenter(new three.Vector3());\n return {\n type: exports.ShapeType.BOX,\n params: {\n x: (box.max.x - box.min.x) / 2,\n y: (box.max.y - box.min.y) / 2,\n z: (box.max.z - box.min.z) / 2\n },\n offset: localPosition.lengthSq() ? new cannonEs.Vec3(localPosition.x, localPosition.y, localPosition.z) : undefined\n };\n}\n/** Computes 3D convex hull as a CANNON.ConvexPolyhedron. */\n\n\nfunction getConvexPolyhedronParameters(object) {\n const geometry = getGeometry(object);\n if (!geometry) return null; // Perturb.\n\n const eps = 1e-4;\n\n for (let i = 0; i < geometry.attributes.position.count; i++) {\n geometry.attributes.position.setXYZ(i, geometry.attributes.position.getX(i) + (Math.random() - 0.5) * eps, geometry.attributes.position.getY(i) + (Math.random() - 0.5) * eps, geometry.attributes.position.getZ(i) + (Math.random() - 0.5) * eps);\n } // Compute the 3D convex hull.\n\n\n const hull = new ConvexHull().setFromObject(new three.Mesh(geometry));\n const hullFaces = hull.faces;\n const vertices = [];\n const faces = [];\n let currentFaceVertex = 0;\n\n for (let i = 0; i < hullFaces.length; i++) {\n const hullFace = hullFaces[i];\n const face = [];\n faces.push(face);\n let edge = hullFace.edge;\n\n do {\n const point = edge.head().point;\n vertices.push(point.x, point.y, point.z);\n face.push(currentFaceVertex);\n currentFaceVertex++;\n edge = edge.next;\n } while (edge !== hullFace.edge);\n }\n\n const verticesTypedArray = new Float32Array(vertices.length);\n verticesTypedArray.set(vertices);\n return {\n type: exports.ShapeType.HULL,\n params: {\n vertices: verticesTypedArray,\n faces\n }\n };\n}\n\nfunction getCylinderParameters(geometry) {\n const params = geometry.parameters;\n return {\n type: exports.ShapeType.CYLINDER,\n params: {\n radiusTop: params.radiusTop,\n radiusBottom: params.radiusBottom,\n height: params.height,\n segments: params.radialSegments\n },\n orientation: new cannonEs.Quaternion().setFromEuler(three.MathUtils.degToRad(-90), 0, 0, 'XYZ').normalize()\n };\n}\n\nfunction getBoundingCylinderParameters(object, options) {\n const axes = ['x', 'y', 'z'];\n const majorAxis = options.cylinderAxis || 'y';\n const minorAxes = axes.splice(axes.indexOf(majorAxis), 1) && axes;\n const box = new three.Box3().setFromObject(object);\n if (!isFinite(box.min.lengthSq())) return null; // Compute cylinder dimensions.\n\n const height = box.max[majorAxis] - box.min[majorAxis];\n const radius = 0.5 * Math.max(getComponent(box.max, minorAxes[0]) - getComponent(box.min, minorAxes[0]), getComponent(box.max, minorAxes[1]) - getComponent(box.min, minorAxes[1]));\n const eulerX = majorAxis === 'y' ? PI_2 : 0;\n const eulerY = majorAxis === 'z' ? PI_2 : 0;\n return {\n type: exports.ShapeType.CYLINDER,\n params: {\n radiusTop: radius,\n radiusBottom: radius,\n height,\n segments: 12\n },\n orientation: new cannonEs.Quaternion().setFromEuler(eulerX, eulerY, 0, 'XYZ').normalize()\n };\n}\n\nfunction getPlaneParameters(geometry) {\n geometry.computeBoundingBox();\n const box = geometry.boundingBox;\n return {\n type: exports.ShapeType.BOX,\n params: {\n x: (box.max.x - box.min.x) / 2 || 0.1,\n y: (box.max.y - box.min.y) / 2 || 0.1,\n z: (box.max.z - box.min.z) / 2 || 0.1\n }\n };\n}\n\nfunction getSphereParameters(geometry) {\n return {\n type: exports.ShapeType.SPHERE,\n params: {\n radius: geometry.parameters.radius\n }\n };\n}\n\nfunction getBoundingSphereParameters(object, options) {\n if (options.sphereRadius) {\n return {\n type: exports.ShapeType.SPHERE,\n params: {\n radius: options.sphereRadius\n }\n };\n }\n\n const geometry = getGeometry(object);\n if (!geometry) return null;\n geometry.computeBoundingSphere();\n return {\n type: exports.ShapeType.SPHERE,\n params: {\n radius: geometry.boundingSphere.radius\n }\n };\n}\n\nfunction getTrimeshParameters(geometry) {\n const vertices = getVertices(geometry);\n if (!vertices.length) return null;\n const indices = new Uint32Array(vertices.length);\n\n for (let i = 0; i < vertices.length; i++) {\n indices[i] = i;\n }\n\n return {\n type: exports.ShapeType.MESH,\n params: {\n vertices,\n indices\n }\n };\n}\n\nexports.getShapeParameters = getShapeParameters;\nexports.threeToCannon = threeToCannon;\n//# sourceMappingURL=three-to-cannon.cjs.map\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./node_modules/three-to-cannon/dist/three-to-cannon.cjs?"); -},{"./constants":20,"./drivers/ammo-driver":21,"./drivers/local-driver":24,"./drivers/network-driver":25,"./drivers/worker-driver":27,"aframe-stats-panel":3,"cannon-es":5}],30:[function(require,module,exports){ -module.exports.slerp = function ( a, b, t ) { - if ( t <= 0 ) return a; - if ( t >= 1 ) return b; - - var x = a[0], y = a[1], z = a[2], w = a[3]; - - // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/ - - var cosHalfTheta = w * b[3] + x * b[0] + y * b[1] + z * b[2]; - - if ( cosHalfTheta < 0 ) { - - a = a.slice(); - - a[3] = - b[3]; - a[0] = - b[0]; - a[1] = - b[1]; - a[2] = - b[2]; - - cosHalfTheta = - cosHalfTheta; - - } else { - - return b; - - } - - if ( cosHalfTheta >= 1.0 ) { - - a[3] = w; - a[0] = x; - a[1] = y; - a[2] = z; - - return this; - - } - - var sinHalfTheta = Math.sqrt( 1.0 - cosHalfTheta * cosHalfTheta ); - - if ( Math.abs( sinHalfTheta ) < 0.001 ) { - - a[3] = 0.5 * ( w + a[3] ); - a[0] = 0.5 * ( x + a[0] ); - a[1] = 0.5 * ( y + a[1] ); - a[2] = 0.5 * ( z + a[2] ); - - return this; - - } - - var halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta ); - var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta; - var ratioB = Math.sin( t * halfTheta ) / sinHalfTheta; - - a[3] = ( w * ratioA + a[3] * ratioB ); - a[0] = ( x * ratioA + a[0] * ratioB ); - a[1] = ( y * ratioA + a[1] * ratioB ); - a[2] = ( z * ratioA + a[2] * ratioB ); - - return a; - -}; +/***/ }), -},{}],31:[function(require,module,exports){ -var CANNON = require('cannon-es'); -var mathUtils = require('./math'); - -/****************************************************************************** - * IDs - */ - -var ID = '__id'; -module.exports.ID = ID; - -var nextID = {}; -module.exports.assignID = function (prefix, object) { - if (object[ID]) return; - nextID[prefix] = nextID[prefix] || 1; - object[ID] = prefix + '_' + nextID[prefix]++; -}; - -/****************************************************************************** - * Bodies - */ - -module.exports.serializeBody = function (body) { - var message = { - // Shapes. - shapes: body.shapes.map(serializeShape), - shapeOffsets: body.shapeOffsets.map(serializeVec3), - shapeOrientations: body.shapeOrientations.map(serializeQuaternion), - - // Vectors. - position: serializeVec3(body.position), - quaternion: body.quaternion.toArray(), - velocity: serializeVec3(body.velocity), - angularVelocity: serializeVec3(body.angularVelocity), - - // Properties. - id: body[ID], - mass: body.mass, - linearDamping: body.linearDamping, - angularDamping: body.angularDamping, - fixedRotation: body.fixedRotation, - allowSleep: body.allowSleep, - sleepSpeedLimit: body.sleepSpeedLimit, - sleepTimeLimit: body.sleepTimeLimit - }; - - return message; -}; - -module.exports.deserializeBodyUpdate = function (message, body) { - body.position.set(message.position[0], message.position[1], message.position[2]); - body.quaternion.set(message.quaternion[0], message.quaternion[1], message.quaternion[2], message.quaternion[3]); - body.velocity.set(message.velocity[0], message.velocity[1], message.velocity[2]); - body.angularVelocity.set(message.angularVelocity[0], message.angularVelocity[1], message.angularVelocity[2]); - - body.linearDamping = message.linearDamping; - body.angularDamping = message.angularDamping; - body.fixedRotation = message.fixedRotation; - body.allowSleep = message.allowSleep; - body.sleepSpeedLimit = message.sleepSpeedLimit; - body.sleepTimeLimit = message.sleepTimeLimit; - - if (body.mass !== message.mass) { - body.mass = message.mass; - body.updateMassProperties(); - } - - return body; -}; - -module.exports.deserializeInterpBodyUpdate = function (message1, message2, body, mix) { - var weight1 = 1 - mix; - var weight2 = mix; - - body.position.set( - message1.position[0] * weight1 + message2.position[0] * weight2, - message1.position[1] * weight1 + message2.position[1] * weight2, - message1.position[2] * weight1 + message2.position[2] * weight2 - ); - var quaternion = mathUtils.slerp(message1.quaternion, message2.quaternion, mix); - body.quaternion.set(quaternion[0], quaternion[1], quaternion[2], quaternion[3]); - body.velocity.set( - message1.velocity[0] * weight1 + message2.velocity[0] * weight2, - message1.velocity[1] * weight1 + message2.velocity[1] * weight2, - message1.velocity[2] * weight1 + message2.velocity[2] * weight2 - ); - body.angularVelocity.set( - message1.angularVelocity[0] * weight1 + message2.angularVelocity[0] * weight2, - message1.angularVelocity[1] * weight1 + message2.angularVelocity[1] * weight2, - message1.angularVelocity[2] * weight1 + message2.angularVelocity[2] * weight2 - ); - - body.linearDamping = message2.linearDamping; - body.angularDamping = message2.angularDamping; - body.fixedRotation = message2.fixedRotation; - body.allowSleep = message2.allowSleep; - body.sleepSpeedLimit = message2.sleepSpeedLimit; - body.sleepTimeLimit = message2.sleepTimeLimit; - - if (body.mass !== message2.mass) { - body.mass = message2.mass; - body.updateMassProperties(); - } - - return body; -}; - -module.exports.deserializeBody = function (message) { - var body = new CANNON.Body({ - mass: message.mass, - - position: deserializeVec3(message.position), - quaternion: deserializeQuaternion(message.quaternion), - velocity: deserializeVec3(message.velocity), - angularVelocity: deserializeVec3(message.angularVelocity), - - linearDamping: message.linearDamping, - angularDamping: message.angularDamping, - fixedRotation: message.fixedRotation, - allowSleep: message.allowSleep, - sleepSpeedLimit: message.sleepSpeedLimit, - sleepTimeLimit: message.sleepTimeLimit - }); - - for (var shapeMsg, i = 0; (shapeMsg = message.shapes[i]); i++) { - body.addShape( - deserializeShape(shapeMsg), - deserializeVec3(message.shapeOffsets[i]), - deserializeQuaternion(message.shapeOrientations[i]) - ); - } - - body[ID] = message.id; - - return body; -}; - -/****************************************************************************** - * Shapes - */ - -module.exports.serializeShape = serializeShape; -function serializeShape (shape) { - var shapeMsg = {type: shape.type}; - if (shape.type === CANNON.Shape.types.BOX) { - shapeMsg.halfExtents = serializeVec3(shape.halfExtents); - - } else if (shape.type === CANNON.Shape.types.SPHERE) { - shapeMsg.radius = shape.radius; - - // Patch schteppe/cannon.js#329. - } else if (shape._type === CANNON.Shape.types.CYLINDER) { - shapeMsg.type = CANNON.Shape.types.CYLINDER; - shapeMsg.radiusTop = shape.radiusTop; - shapeMsg.radiusBottom = shape.radiusBottom; - shapeMsg.height = shape.height; - shapeMsg.numSegments = shape.numSegments; - - } else { - // TODO(donmccurdy): Support for other shape types. - throw new Error('Unimplemented shape type: %s', shape.type); - } - return shapeMsg; -} - -module.exports.deserializeShape = deserializeShape; -function deserializeShape (message) { - var shape; - - if (message.type === CANNON.Shape.types.BOX) { - shape = new CANNON.Box(deserializeVec3(message.halfExtents)); - - } else if (message.type === CANNON.Shape.types.SPHERE) { - shape = new CANNON.Sphere(message.radius); - - // Patch schteppe/cannon.js#329. - } else if (message.type === CANNON.Shape.types.CYLINDER) { - shape = new CANNON.Cylinder(message.radiusTop, message.radiusBottom, message.height, message.numSegments); - shape._type = CANNON.Shape.types.CYLINDER; - - } else { - // TODO(donmccurdy): Support for other shape types. - throw new Error('Unimplemented shape type: %s', message.type); - } - - return shape; -} - -/****************************************************************************** - * Constraints - */ - -module.exports.serializeConstraint = function (constraint) { - - var message = { - id: constraint[ID], - type: constraint.type, - maxForce: constraint.maxForce, - bodyA: constraint.bodyA[ID], - bodyB: constraint.bodyB[ID] - }; - - switch (constraint.type) { - case 'LockConstraint': - break; - case 'DistanceConstraint': - message.distance = constraint.distance; - break; - case 'HingeConstraint': - case 'ConeTwistConstraint': - message.axisA = serializeVec3(constraint.axisA); - message.axisB = serializeVec3(constraint.axisB); - message.pivotA = serializeVec3(constraint.pivotA); - message.pivotB = serializeVec3(constraint.pivotB); - break; - case 'PointToPointConstraint': - message.pivotA = serializeVec3(constraint.pivotA); - message.pivotB = serializeVec3(constraint.pivotB); - break; - default: - throw new Error('' - + 'Unexpected constraint type: ' + constraint.type + '. ' - + 'You may need to manually set `constraint.type = "FooConstraint";`.' - ); - } - - return message; -}; - -module.exports.deserializeConstraint = function (message, bodies) { - var TypedConstraint = CANNON[message.type]; - var bodyA = bodies[message.bodyA]; - var bodyB = bodies[message.bodyB]; - - var constraint; - - switch (message.type) { - case 'LockConstraint': - constraint = new CANNON.LockConstraint(bodyA, bodyB, message); - break; - - case 'DistanceConstraint': - constraint = new CANNON.DistanceConstraint( - bodyA, - bodyB, - message.distance, - message.maxForce - ); - break; - - case 'HingeConstraint': - case 'ConeTwistConstraint': - constraint = new TypedConstraint(bodyA, bodyB, { - pivotA: deserializeVec3(message.pivotA), - pivotB: deserializeVec3(message.pivotB), - axisA: deserializeVec3(message.axisA), - axisB: deserializeVec3(message.axisB), - maxForce: message.maxForce - }); - break; - - case 'PointToPointConstraint': - constraint = new CANNON.PointToPointConstraint( - bodyA, - deserializeVec3(message.pivotA), - bodyB, - deserializeVec3(message.pivotB), - message.maxForce - ); - break; - - default: - throw new Error('Unexpected constraint type: ' + message.type); - } - - constraint[ID] = message.id; - return constraint; -}; - -/****************************************************************************** - * Contacts - */ - -module.exports.serializeContact = function (contact) { - return { - bi: contact.bi[ID], - bj: contact.bj[ID], - ni: serializeVec3(contact.ni), - ri: serializeVec3(contact.ri), - rj: serializeVec3(contact.rj) - }; -}; - -module.exports.deserializeContact = function (message, bodies) { - return { - bi: bodies[message.bi], - bj: bodies[message.bj], - ni: deserializeVec3(message.ni), - ri: deserializeVec3(message.ri), - rj: deserializeVec3(message.rj) - }; -}; - -/****************************************************************************** - * Math - */ - -module.exports.serializeVec3 = serializeVec3; -function serializeVec3 (vec3) { - return vec3.toArray(); -} - -module.exports.deserializeVec3 = deserializeVec3; -function deserializeVec3 (message) { - return new CANNON.Vec3(message[0], message[1], message[2]); -} - -module.exports.serializeQuaternion = serializeQuaternion; -function serializeQuaternion (quat) { - return quat.toArray(); -} - -module.exports.deserializeQuaternion = deserializeQuaternion; -function deserializeQuaternion (message) { - return new CANNON.Quaternion(message[0], message[1], message[2], message[3]); -} +/***/ "./node_modules/three/build/three.cjs": +/*!********************************************!*\ + !*** ./node_modules/three/build/three.cjs ***! + \********************************************/ +/***/ ((__unused_webpack_module, exports) => { -},{"./math":30,"cannon-es":5}]},{},[1]); +"use strict"; +eval("/**\n * @license\n * Copyright 2010-2022 Three.js Authors\n * SPDX-License-Identifier: MIT\n */\n\n\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\n\nconst REVISION = '145';\nconst MOUSE = {\n\tLEFT: 0,\n\tMIDDLE: 1,\n\tRIGHT: 2,\n\tROTATE: 0,\n\tDOLLY: 1,\n\tPAN: 2\n};\nconst TOUCH = {\n\tROTATE: 0,\n\tPAN: 1,\n\tDOLLY_PAN: 2,\n\tDOLLY_ROTATE: 3\n};\nconst CullFaceNone = 0;\nconst CullFaceBack = 1;\nconst CullFaceFront = 2;\nconst CullFaceFrontBack = 3;\nconst BasicShadowMap = 0;\nconst PCFShadowMap = 1;\nconst PCFSoftShadowMap = 2;\nconst VSMShadowMap = 3;\nconst FrontSide = 0;\nconst BackSide = 1;\nconst DoubleSide = 2;\nconst NoBlending = 0;\nconst NormalBlending = 1;\nconst AdditiveBlending = 2;\nconst SubtractiveBlending = 3;\nconst MultiplyBlending = 4;\nconst CustomBlending = 5;\nconst AddEquation = 100;\nconst SubtractEquation = 101;\nconst ReverseSubtractEquation = 102;\nconst MinEquation = 103;\nconst MaxEquation = 104;\nconst ZeroFactor = 200;\nconst OneFactor = 201;\nconst SrcColorFactor = 202;\nconst OneMinusSrcColorFactor = 203;\nconst SrcAlphaFactor = 204;\nconst OneMinusSrcAlphaFactor = 205;\nconst DstAlphaFactor = 206;\nconst OneMinusDstAlphaFactor = 207;\nconst DstColorFactor = 208;\nconst OneMinusDstColorFactor = 209;\nconst SrcAlphaSaturateFactor = 210;\nconst NeverDepth = 0;\nconst AlwaysDepth = 1;\nconst LessDepth = 2;\nconst LessEqualDepth = 3;\nconst EqualDepth = 4;\nconst GreaterEqualDepth = 5;\nconst GreaterDepth = 6;\nconst NotEqualDepth = 7;\nconst MultiplyOperation = 0;\nconst MixOperation = 1;\nconst AddOperation = 2;\nconst NoToneMapping = 0;\nconst LinearToneMapping = 1;\nconst ReinhardToneMapping = 2;\nconst CineonToneMapping = 3;\nconst ACESFilmicToneMapping = 4;\nconst CustomToneMapping = 5;\nconst UVMapping = 300;\nconst CubeReflectionMapping = 301;\nconst CubeRefractionMapping = 302;\nconst EquirectangularReflectionMapping = 303;\nconst EquirectangularRefractionMapping = 304;\nconst CubeUVReflectionMapping = 306;\nconst RepeatWrapping = 1000;\nconst ClampToEdgeWrapping = 1001;\nconst MirroredRepeatWrapping = 1002;\nconst NearestFilter = 1003;\nconst NearestMipmapNearestFilter = 1004;\nconst NearestMipMapNearestFilter = 1004;\nconst NearestMipmapLinearFilter = 1005;\nconst NearestMipMapLinearFilter = 1005;\nconst LinearFilter = 1006;\nconst LinearMipmapNearestFilter = 1007;\nconst LinearMipMapNearestFilter = 1007;\nconst LinearMipmapLinearFilter = 1008;\nconst LinearMipMapLinearFilter = 1008;\nconst UnsignedByteType = 1009;\nconst ByteType = 1010;\nconst ShortType = 1011;\nconst UnsignedShortType = 1012;\nconst IntType = 1013;\nconst UnsignedIntType = 1014;\nconst FloatType = 1015;\nconst HalfFloatType = 1016;\nconst UnsignedShort4444Type = 1017;\nconst UnsignedShort5551Type = 1018;\nconst UnsignedInt248Type = 1020;\nconst AlphaFormat = 1021;\nconst RGBFormat = 1022; // @deprecated since r137\n\nconst RGBAFormat = 1023;\nconst LuminanceFormat = 1024;\nconst LuminanceAlphaFormat = 1025;\nconst DepthFormat = 1026;\nconst DepthStencilFormat = 1027;\nconst RedFormat = 1028;\nconst RedIntegerFormat = 1029;\nconst RGFormat = 1030;\nconst RGIntegerFormat = 1031;\nconst RGBAIntegerFormat = 1033;\nconst RGB_S3TC_DXT1_Format = 33776;\nconst RGBA_S3TC_DXT1_Format = 33777;\nconst RGBA_S3TC_DXT3_Format = 33778;\nconst RGBA_S3TC_DXT5_Format = 33779;\nconst RGB_PVRTC_4BPPV1_Format = 35840;\nconst RGB_PVRTC_2BPPV1_Format = 35841;\nconst RGBA_PVRTC_4BPPV1_Format = 35842;\nconst RGBA_PVRTC_2BPPV1_Format = 35843;\nconst RGB_ETC1_Format = 36196;\nconst RGB_ETC2_Format = 37492;\nconst RGBA_ETC2_EAC_Format = 37496;\nconst RGBA_ASTC_4x4_Format = 37808;\nconst RGBA_ASTC_5x4_Format = 37809;\nconst RGBA_ASTC_5x5_Format = 37810;\nconst RGBA_ASTC_6x5_Format = 37811;\nconst RGBA_ASTC_6x6_Format = 37812;\nconst RGBA_ASTC_8x5_Format = 37813;\nconst RGBA_ASTC_8x6_Format = 37814;\nconst RGBA_ASTC_8x8_Format = 37815;\nconst RGBA_ASTC_10x5_Format = 37816;\nconst RGBA_ASTC_10x6_Format = 37817;\nconst RGBA_ASTC_10x8_Format = 37818;\nconst RGBA_ASTC_10x10_Format = 37819;\nconst RGBA_ASTC_12x10_Format = 37820;\nconst RGBA_ASTC_12x12_Format = 37821;\nconst RGBA_BPTC_Format = 36492;\nconst LoopOnce = 2200;\nconst LoopRepeat = 2201;\nconst LoopPingPong = 2202;\nconst InterpolateDiscrete = 2300;\nconst InterpolateLinear = 2301;\nconst InterpolateSmooth = 2302;\nconst ZeroCurvatureEnding = 2400;\nconst ZeroSlopeEnding = 2401;\nconst WrapAroundEnding = 2402;\nconst NormalAnimationBlendMode = 2500;\nconst AdditiveAnimationBlendMode = 2501;\nconst TrianglesDrawMode = 0;\nconst TriangleStripDrawMode = 1;\nconst TriangleFanDrawMode = 2;\nconst LinearEncoding = 3000;\nconst sRGBEncoding = 3001;\nconst BasicDepthPacking = 3200;\nconst RGBADepthPacking = 3201;\nconst TangentSpaceNormalMap = 0;\nconst ObjectSpaceNormalMap = 1; // Color space string identifiers, matching CSS Color Module Level 4 and WebGPU names where available.\n\nconst NoColorSpace = '';\nconst SRGBColorSpace = 'srgb';\nconst LinearSRGBColorSpace = 'srgb-linear';\nconst ZeroStencilOp = 0;\nconst KeepStencilOp = 7680;\nconst ReplaceStencilOp = 7681;\nconst IncrementStencilOp = 7682;\nconst DecrementStencilOp = 7683;\nconst IncrementWrapStencilOp = 34055;\nconst DecrementWrapStencilOp = 34056;\nconst InvertStencilOp = 5386;\nconst NeverStencilFunc = 512;\nconst LessStencilFunc = 513;\nconst EqualStencilFunc = 514;\nconst LessEqualStencilFunc = 515;\nconst GreaterStencilFunc = 516;\nconst NotEqualStencilFunc = 517;\nconst GreaterEqualStencilFunc = 518;\nconst AlwaysStencilFunc = 519;\nconst StaticDrawUsage = 35044;\nconst DynamicDrawUsage = 35048;\nconst StreamDrawUsage = 35040;\nconst StaticReadUsage = 35045;\nconst DynamicReadUsage = 35049;\nconst StreamReadUsage = 35041;\nconst StaticCopyUsage = 35046;\nconst DynamicCopyUsage = 35050;\nconst StreamCopyUsage = 35042;\nconst GLSL1 = '100';\nconst GLSL3 = '300 es';\nconst _SRGBAFormat = 1035; // fallback for WebGL 1\n\n/**\n * https://github.com/mrdoob/eventdispatcher.js/\n */\nclass EventDispatcher {\n\taddEventListener(type, listener) {\n\t\tif (this._listeners === undefined) this._listeners = {};\n\t\tconst listeners = this._listeners;\n\n\t\tif (listeners[type] === undefined) {\n\t\t\tlisteners[type] = [];\n\t\t}\n\n\t\tif (listeners[type].indexOf(listener) === -1) {\n\t\t\tlisteners[type].push(listener);\n\t\t}\n\t}\n\n\thasEventListener(type, listener) {\n\t\tif (this._listeners === undefined) return false;\n\t\tconst listeners = this._listeners;\n\t\treturn listeners[type] !== undefined && listeners[type].indexOf(listener) !== -1;\n\t}\n\n\tremoveEventListener(type, listener) {\n\t\tif (this._listeners === undefined) return;\n\t\tconst listeners = this._listeners;\n\t\tconst listenerArray = listeners[type];\n\n\t\tif (listenerArray !== undefined) {\n\t\t\tconst index = listenerArray.indexOf(listener);\n\n\t\t\tif (index !== -1) {\n\t\t\t\tlistenerArray.splice(index, 1);\n\t\t\t}\n\t\t}\n\t}\n\n\tdispatchEvent(event) {\n\t\tif (this._listeners === undefined) return;\n\t\tconst listeners = this._listeners;\n\t\tconst listenerArray = listeners[event.type];\n\n\t\tif (listenerArray !== undefined) {\n\t\t\tevent.target = this; // Make a copy, in case listeners are removed while iterating.\n\n\t\t\tconst array = listenerArray.slice(0);\n\n\t\t\tfor (let i = 0, l = array.length; i < l; i++) {\n\t\t\t\tarray[i].call(this, event);\n\t\t\t}\n\n\t\t\tevent.target = null;\n\t\t}\n\t}\n\n}\n\nconst _lut = ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '0a', '0b', '0c', '0d', '0e', '0f', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '1a', '1b', '1c', '1d', '1e', '1f', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '2a', '2b', '2c', '2d', '2e', '2f', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '3a', '3b', '3c', '3d', '3e', '3f', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '4a', '4b', '4c', '4d', '4e', '4f', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '5a', '5b', '5c', '5d', '5e', '5f', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '6a', '6b', '6c', '6d', '6e', '6f', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '7a', '7b', '7c', '7d', '7e', '7f', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '8a', '8b', '8c', '8d', '8e', '8f', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '9a', '9b', '9c', '9d', '9e', '9f', 'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'aa', 'ab', 'ac', 'ad', 'ae', 'af', 'b0', 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', 'b9', 'ba', 'bb', 'bc', 'bd', 'be', 'bf', 'c0', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8', 'c9', 'ca', 'cb', 'cc', 'cd', 'ce', 'cf', 'd0', 'd1', 'd2', 'd3', 'd4', 'd5', 'd6', 'd7', 'd8', 'd9', 'da', 'db', 'dc', 'dd', 'de', 'df', 'e0', 'e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7', 'e8', 'e9', 'ea', 'eb', 'ec', 'ed', 'ee', 'ef', 'f0', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'fa', 'fb', 'fc', 'fd', 'fe', 'ff'];\nlet _seed = 1234567;\nconst DEG2RAD = Math.PI / 180;\nconst RAD2DEG = 180 / Math.PI; // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136\n\nfunction generateUUID() {\n\tconst d0 = Math.random() * 0xffffffff | 0;\n\tconst d1 = Math.random() * 0xffffffff | 0;\n\tconst d2 = Math.random() * 0xffffffff | 0;\n\tconst d3 = Math.random() * 0xffffffff | 0;\n\tconst uuid = _lut[d0 & 0xff] + _lut[d0 >> 8 & 0xff] + _lut[d0 >> 16 & 0xff] + _lut[d0 >> 24 & 0xff] + '-' + _lut[d1 & 0xff] + _lut[d1 >> 8 & 0xff] + '-' + _lut[d1 >> 16 & 0x0f | 0x40] + _lut[d1 >> 24 & 0xff] + '-' + _lut[d2 & 0x3f | 0x80] + _lut[d2 >> 8 & 0xff] + '-' + _lut[d2 >> 16 & 0xff] + _lut[d2 >> 24 & 0xff] + _lut[d3 & 0xff] + _lut[d3 >> 8 & 0xff] + _lut[d3 >> 16 & 0xff] + _lut[d3 >> 24 & 0xff]; // .toLowerCase() here flattens concatenated strings to save heap memory space.\n\n\treturn uuid.toLowerCase();\n}\n\nfunction clamp(value, min, max) {\n\treturn Math.max(min, Math.min(max, value));\n} // compute euclidean modulo of m % n\n// https://en.wikipedia.org/wiki/Modulo_operation\n\n\nfunction euclideanModulo(n, m) {\n\treturn (n % m + m) % m;\n} // Linear mapping from range to range \n\n\nfunction mapLinear(x, a1, a2, b1, b2) {\n\treturn b1 + (x - a1) * (b2 - b1) / (a2 - a1);\n} // https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/inverse-lerp-a-super-useful-yet-often-overlooked-function-r5230/\n\n\nfunction inverseLerp(x, y, value) {\n\tif (x !== y) {\n\t\treturn (value - x) / (y - x);\n\t} else {\n\t\treturn 0;\n\t}\n} // https://en.wikipedia.org/wiki/Linear_interpolation\n\n\nfunction lerp(x, y, t) {\n\treturn (1 - t) * x + t * y;\n} // http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/\n\n\nfunction damp(x, y, lambda, dt) {\n\treturn lerp(x, y, 1 - Math.exp(-lambda * dt));\n} // https://www.desmos.com/calculator/vcsjnyz7x4\n\n\nfunction pingpong(x, length = 1) {\n\treturn length - Math.abs(euclideanModulo(x, length * 2) - length);\n} // http://en.wikipedia.org/wiki/Smoothstep\n\n\nfunction smoothstep(x, min, max) {\n\tif (x <= min) return 0;\n\tif (x >= max) return 1;\n\tx = (x - min) / (max - min);\n\treturn x * x * (3 - 2 * x);\n}\n\nfunction smootherstep(x, min, max) {\n\tif (x <= min) return 0;\n\tif (x >= max) return 1;\n\tx = (x - min) / (max - min);\n\treturn x * x * x * (x * (x * 6 - 15) + 10);\n} // Random integer from interval\n\n\nfunction randInt(low, high) {\n\treturn low + Math.floor(Math.random() * (high - low + 1));\n} // Random float from interval\n\n\nfunction randFloat(low, high) {\n\treturn low + Math.random() * (high - low);\n} // Random float from <-range/2, range/2> interval\n\n\nfunction randFloatSpread(range) {\n\treturn range * (0.5 - Math.random());\n} // Deterministic pseudo-random float in the interval [ 0, 1 ]\n\n\nfunction seededRandom(s) {\n\tif (s !== undefined) _seed = s; // Mulberry32 generator\n\n\tlet t = _seed += 0x6D2B79F5;\n\tt = Math.imul(t ^ t >>> 15, t | 1);\n\tt ^= t + Math.imul(t ^ t >>> 7, t | 61);\n\treturn ((t ^ t >>> 14) >>> 0) / 4294967296;\n}\n\nfunction degToRad(degrees) {\n\treturn degrees * DEG2RAD;\n}\n\nfunction radToDeg(radians) {\n\treturn radians * RAD2DEG;\n}\n\nfunction isPowerOfTwo(value) {\n\treturn (value & value - 1) === 0 && value !== 0;\n}\n\nfunction ceilPowerOfTwo(value) {\n\treturn Math.pow(2, Math.ceil(Math.log(value) / Math.LN2));\n}\n\nfunction floorPowerOfTwo(value) {\n\treturn Math.pow(2, Math.floor(Math.log(value) / Math.LN2));\n}\n\nfunction setQuaternionFromProperEuler(q, a, b, c, order) {\n\t// Intrinsic Proper Euler Angles - see https://en.wikipedia.org/wiki/Euler_angles\n\t// rotations are applied to the axes in the order specified by 'order'\n\t// rotation by angle 'a' is applied first, then by angle 'b', then by angle 'c'\n\t// angles are in radians\n\tconst cos = Math.cos;\n\tconst sin = Math.sin;\n\tconst c2 = cos(b / 2);\n\tconst s2 = sin(b / 2);\n\tconst c13 = cos((a + c) / 2);\n\tconst s13 = sin((a + c) / 2);\n\tconst c1_3 = cos((a - c) / 2);\n\tconst s1_3 = sin((a - c) / 2);\n\tconst c3_1 = cos((c - a) / 2);\n\tconst s3_1 = sin((c - a) / 2);\n\n\tswitch (order) {\n\t\tcase 'XYX':\n\t\t\tq.set(c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13);\n\t\t\tbreak;\n\n\t\tcase 'YZY':\n\t\t\tq.set(s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13);\n\t\t\tbreak;\n\n\t\tcase 'ZXZ':\n\t\t\tq.set(s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13);\n\t\t\tbreak;\n\n\t\tcase 'XZX':\n\t\t\tq.set(c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13);\n\t\t\tbreak;\n\n\t\tcase 'YXY':\n\t\t\tq.set(s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13);\n\t\t\tbreak;\n\n\t\tcase 'ZYZ':\n\t\t\tq.set(s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13);\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tconsole.warn('THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + order);\n\t}\n}\n\nfunction denormalize(value, array) {\n\tswitch (array.constructor) {\n\t\tcase Float32Array:\n\t\t\treturn value;\n\n\t\tcase Uint16Array:\n\t\t\treturn value / 65535.0;\n\n\t\tcase Uint8Array:\n\t\t\treturn value / 255.0;\n\n\t\tcase Int16Array:\n\t\t\treturn Math.max(value / 32767.0, -1.0);\n\n\t\tcase Int8Array:\n\t\t\treturn Math.max(value / 127.0, -1.0);\n\n\t\tdefault:\n\t\t\tthrow new Error('Invalid component type.');\n\t}\n}\n\nfunction normalize(value, array) {\n\tswitch (array.constructor) {\n\t\tcase Float32Array:\n\t\t\treturn value;\n\n\t\tcase Uint16Array:\n\t\t\treturn Math.round(value * 65535.0);\n\n\t\tcase Uint8Array:\n\t\t\treturn Math.round(value * 255.0);\n\n\t\tcase Int16Array:\n\t\t\treturn Math.round(value * 32767.0);\n\n\t\tcase Int8Array:\n\t\t\treturn Math.round(value * 127.0);\n\n\t\tdefault:\n\t\t\tthrow new Error('Invalid component type.');\n\t}\n}\n\nvar MathUtils = /*#__PURE__*/Object.freeze({\n\t__proto__: null,\n\tDEG2RAD: DEG2RAD,\n\tRAD2DEG: RAD2DEG,\n\tgenerateUUID: generateUUID,\n\tclamp: clamp,\n\teuclideanModulo: euclideanModulo,\n\tmapLinear: mapLinear,\n\tinverseLerp: inverseLerp,\n\tlerp: lerp,\n\tdamp: damp,\n\tpingpong: pingpong,\n\tsmoothstep: smoothstep,\n\tsmootherstep: smootherstep,\n\trandInt: randInt,\n\trandFloat: randFloat,\n\trandFloatSpread: randFloatSpread,\n\tseededRandom: seededRandom,\n\tdegToRad: degToRad,\n\tradToDeg: radToDeg,\n\tisPowerOfTwo: isPowerOfTwo,\n\tceilPowerOfTwo: ceilPowerOfTwo,\n\tfloorPowerOfTwo: floorPowerOfTwo,\n\tsetQuaternionFromProperEuler: setQuaternionFromProperEuler,\n\tnormalize: normalize,\n\tdenormalize: denormalize\n});\n\nclass Vector2 {\n\tconstructor(x = 0, y = 0) {\n\t\tVector2.prototype.isVector2 = true;\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t}\n\n\tget width() {\n\t\treturn this.x;\n\t}\n\n\tset width(value) {\n\t\tthis.x = value;\n\t}\n\n\tget height() {\n\t\treturn this.y;\n\t}\n\n\tset height(value) {\n\t\tthis.y = value;\n\t}\n\n\tset(x, y) {\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\treturn this;\n\t}\n\n\tsetScalar(scalar) {\n\t\tthis.x = scalar;\n\t\tthis.y = scalar;\n\t\treturn this;\n\t}\n\n\tsetX(x) {\n\t\tthis.x = x;\n\t\treturn this;\n\t}\n\n\tsetY(y) {\n\t\tthis.y = y;\n\t\treturn this;\n\t}\n\n\tsetComponent(index, value) {\n\t\tswitch (index) {\n\t\t\tcase 0:\n\t\t\t\tthis.x = value;\n\t\t\t\tbreak;\n\n\t\t\tcase 1:\n\t\t\t\tthis.y = value;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error('index is out of range: ' + index);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tgetComponent(index) {\n\t\tswitch (index) {\n\t\t\tcase 0:\n\t\t\t\treturn this.x;\n\n\t\t\tcase 1:\n\t\t\t\treturn this.y;\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error('index is out of range: ' + index);\n\t\t}\n\t}\n\n\tclone() {\n\t\treturn new this.constructor(this.x, this.y);\n\t}\n\n\tcopy(v) {\n\t\tthis.x = v.x;\n\t\tthis.y = v.y;\n\t\treturn this;\n\t}\n\n\tadd(v) {\n\t\tthis.x += v.x;\n\t\tthis.y += v.y;\n\t\treturn this;\n\t}\n\n\taddScalar(s) {\n\t\tthis.x += s;\n\t\tthis.y += s;\n\t\treturn this;\n\t}\n\n\taddVectors(a, b) {\n\t\tthis.x = a.x + b.x;\n\t\tthis.y = a.y + b.y;\n\t\treturn this;\n\t}\n\n\taddScaledVector(v, s) {\n\t\tthis.x += v.x * s;\n\t\tthis.y += v.y * s;\n\t\treturn this;\n\t}\n\n\tsub(v) {\n\t\tthis.x -= v.x;\n\t\tthis.y -= v.y;\n\t\treturn this;\n\t}\n\n\tsubScalar(s) {\n\t\tthis.x -= s;\n\t\tthis.y -= s;\n\t\treturn this;\n\t}\n\n\tsubVectors(a, b) {\n\t\tthis.x = a.x - b.x;\n\t\tthis.y = a.y - b.y;\n\t\treturn this;\n\t}\n\n\tmultiply(v) {\n\t\tthis.x *= v.x;\n\t\tthis.y *= v.y;\n\t\treturn this;\n\t}\n\n\tmultiplyScalar(scalar) {\n\t\tthis.x *= scalar;\n\t\tthis.y *= scalar;\n\t\treturn this;\n\t}\n\n\tdivide(v) {\n\t\tthis.x /= v.x;\n\t\tthis.y /= v.y;\n\t\treturn this;\n\t}\n\n\tdivideScalar(scalar) {\n\t\treturn this.multiplyScalar(1 / scalar);\n\t}\n\n\tapplyMatrix3(m) {\n\t\tconst x = this.x,\n\t\t\t\t\ty = this.y;\n\t\tconst e = m.elements;\n\t\tthis.x = e[0] * x + e[3] * y + e[6];\n\t\tthis.y = e[1] * x + e[4] * y + e[7];\n\t\treturn this;\n\t}\n\n\tmin(v) {\n\t\tthis.x = Math.min(this.x, v.x);\n\t\tthis.y = Math.min(this.y, v.y);\n\t\treturn this;\n\t}\n\n\tmax(v) {\n\t\tthis.x = Math.max(this.x, v.x);\n\t\tthis.y = Math.max(this.y, v.y);\n\t\treturn this;\n\t}\n\n\tclamp(min, max) {\n\t\t// assumes min < max, componentwise\n\t\tthis.x = Math.max(min.x, Math.min(max.x, this.x));\n\t\tthis.y = Math.max(min.y, Math.min(max.y, this.y));\n\t\treturn this;\n\t}\n\n\tclampScalar(minVal, maxVal) {\n\t\tthis.x = Math.max(minVal, Math.min(maxVal, this.x));\n\t\tthis.y = Math.max(minVal, Math.min(maxVal, this.y));\n\t\treturn this;\n\t}\n\n\tclampLength(min, max) {\n\t\tconst length = this.length();\n\t\treturn this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));\n\t}\n\n\tfloor() {\n\t\tthis.x = Math.floor(this.x);\n\t\tthis.y = Math.floor(this.y);\n\t\treturn this;\n\t}\n\n\tceil() {\n\t\tthis.x = Math.ceil(this.x);\n\t\tthis.y = Math.ceil(this.y);\n\t\treturn this;\n\t}\n\n\tround() {\n\t\tthis.x = Math.round(this.x);\n\t\tthis.y = Math.round(this.y);\n\t\treturn this;\n\t}\n\n\troundToZero() {\n\t\tthis.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x);\n\t\tthis.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y);\n\t\treturn this;\n\t}\n\n\tnegate() {\n\t\tthis.x = -this.x;\n\t\tthis.y = -this.y;\n\t\treturn this;\n\t}\n\n\tdot(v) {\n\t\treturn this.x * v.x + this.y * v.y;\n\t}\n\n\tcross(v) {\n\t\treturn this.x * v.y - this.y * v.x;\n\t}\n\n\tlengthSq() {\n\t\treturn this.x * this.x + this.y * this.y;\n\t}\n\n\tlength() {\n\t\treturn Math.sqrt(this.x * this.x + this.y * this.y);\n\t}\n\n\tmanhattanLength() {\n\t\treturn Math.abs(this.x) + Math.abs(this.y);\n\t}\n\n\tnormalize() {\n\t\treturn this.divideScalar(this.length() || 1);\n\t}\n\n\tangle() {\n\t\t// computes the angle in radians with respect to the positive x-axis\n\t\tconst angle = Math.atan2(-this.y, -this.x) + Math.PI;\n\t\treturn angle;\n\t}\n\n\tdistanceTo(v) {\n\t\treturn Math.sqrt(this.distanceToSquared(v));\n\t}\n\n\tdistanceToSquared(v) {\n\t\tconst dx = this.x - v.x,\n\t\t\t\t\tdy = this.y - v.y;\n\t\treturn dx * dx + dy * dy;\n\t}\n\n\tmanhattanDistanceTo(v) {\n\t\treturn Math.abs(this.x - v.x) + Math.abs(this.y - v.y);\n\t}\n\n\tsetLength(length) {\n\t\treturn this.normalize().multiplyScalar(length);\n\t}\n\n\tlerp(v, alpha) {\n\t\tthis.x += (v.x - this.x) * alpha;\n\t\tthis.y += (v.y - this.y) * alpha;\n\t\treturn this;\n\t}\n\n\tlerpVectors(v1, v2, alpha) {\n\t\tthis.x = v1.x + (v2.x - v1.x) * alpha;\n\t\tthis.y = v1.y + (v2.y - v1.y) * alpha;\n\t\treturn this;\n\t}\n\n\tequals(v) {\n\t\treturn v.x === this.x && v.y === this.y;\n\t}\n\n\tfromArray(array, offset = 0) {\n\t\tthis.x = array[offset];\n\t\tthis.y = array[offset + 1];\n\t\treturn this;\n\t}\n\n\ttoArray(array = [], offset = 0) {\n\t\tarray[offset] = this.x;\n\t\tarray[offset + 1] = this.y;\n\t\treturn array;\n\t}\n\n\tfromBufferAttribute(attribute, index) {\n\t\tthis.x = attribute.getX(index);\n\t\tthis.y = attribute.getY(index);\n\t\treturn this;\n\t}\n\n\trotateAround(center, angle) {\n\t\tconst c = Math.cos(angle),\n\t\t\t\t\ts = Math.sin(angle);\n\t\tconst x = this.x - center.x;\n\t\tconst y = this.y - center.y;\n\t\tthis.x = x * c - y * s + center.x;\n\t\tthis.y = x * s + y * c + center.y;\n\t\treturn this;\n\t}\n\n\trandom() {\n\t\tthis.x = Math.random();\n\t\tthis.y = Math.random();\n\t\treturn this;\n\t}\n\n\t*[Symbol.iterator]() {\n\t\tyield this.x;\n\t\tyield this.y;\n\t}\n\n}\n\nclass Matrix3 {\n\tconstructor() {\n\t\tMatrix3.prototype.isMatrix3 = true;\n\t\tthis.elements = [1, 0, 0, 0, 1, 0, 0, 0, 1];\n\t}\n\n\tset(n11, n12, n13, n21, n22, n23, n31, n32, n33) {\n\t\tconst te = this.elements;\n\t\tte[0] = n11;\n\t\tte[1] = n21;\n\t\tte[2] = n31;\n\t\tte[3] = n12;\n\t\tte[4] = n22;\n\t\tte[5] = n32;\n\t\tte[6] = n13;\n\t\tte[7] = n23;\n\t\tte[8] = n33;\n\t\treturn this;\n\t}\n\n\tidentity() {\n\t\tthis.set(1, 0, 0, 0, 1, 0, 0, 0, 1);\n\t\treturn this;\n\t}\n\n\tcopy(m) {\n\t\tconst te = this.elements;\n\t\tconst me = m.elements;\n\t\tte[0] = me[0];\n\t\tte[1] = me[1];\n\t\tte[2] = me[2];\n\t\tte[3] = me[3];\n\t\tte[4] = me[4];\n\t\tte[5] = me[5];\n\t\tte[6] = me[6];\n\t\tte[7] = me[7];\n\t\tte[8] = me[8];\n\t\treturn this;\n\t}\n\n\textractBasis(xAxis, yAxis, zAxis) {\n\t\txAxis.setFromMatrix3Column(this, 0);\n\t\tyAxis.setFromMatrix3Column(this, 1);\n\t\tzAxis.setFromMatrix3Column(this, 2);\n\t\treturn this;\n\t}\n\n\tsetFromMatrix4(m) {\n\t\tconst me = m.elements;\n\t\tthis.set(me[0], me[4], me[8], me[1], me[5], me[9], me[2], me[6], me[10]);\n\t\treturn this;\n\t}\n\n\tmultiply(m) {\n\t\treturn this.multiplyMatrices(this, m);\n\t}\n\n\tpremultiply(m) {\n\t\treturn this.multiplyMatrices(m, this);\n\t}\n\n\tmultiplyMatrices(a, b) {\n\t\tconst ae = a.elements;\n\t\tconst be = b.elements;\n\t\tconst te = this.elements;\n\t\tconst a11 = ae[0],\n\t\t\t\t\ta12 = ae[3],\n\t\t\t\t\ta13 = ae[6];\n\t\tconst a21 = ae[1],\n\t\t\t\t\ta22 = ae[4],\n\t\t\t\t\ta23 = ae[7];\n\t\tconst a31 = ae[2],\n\t\t\t\t\ta32 = ae[5],\n\t\t\t\t\ta33 = ae[8];\n\t\tconst b11 = be[0],\n\t\t\t\t\tb12 = be[3],\n\t\t\t\t\tb13 = be[6];\n\t\tconst b21 = be[1],\n\t\t\t\t\tb22 = be[4],\n\t\t\t\t\tb23 = be[7];\n\t\tconst b31 = be[2],\n\t\t\t\t\tb32 = be[5],\n\t\t\t\t\tb33 = be[8];\n\t\tte[0] = a11 * b11 + a12 * b21 + a13 * b31;\n\t\tte[3] = a11 * b12 + a12 * b22 + a13 * b32;\n\t\tte[6] = a11 * b13 + a12 * b23 + a13 * b33;\n\t\tte[1] = a21 * b11 + a22 * b21 + a23 * b31;\n\t\tte[4] = a21 * b12 + a22 * b22 + a23 * b32;\n\t\tte[7] = a21 * b13 + a22 * b23 + a23 * b33;\n\t\tte[2] = a31 * b11 + a32 * b21 + a33 * b31;\n\t\tte[5] = a31 * b12 + a32 * b22 + a33 * b32;\n\t\tte[8] = a31 * b13 + a32 * b23 + a33 * b33;\n\t\treturn this;\n\t}\n\n\tmultiplyScalar(s) {\n\t\tconst te = this.elements;\n\t\tte[0] *= s;\n\t\tte[3] *= s;\n\t\tte[6] *= s;\n\t\tte[1] *= s;\n\t\tte[4] *= s;\n\t\tte[7] *= s;\n\t\tte[2] *= s;\n\t\tte[5] *= s;\n\t\tte[8] *= s;\n\t\treturn this;\n\t}\n\n\tdeterminant() {\n\t\tconst te = this.elements;\n\t\tconst a = te[0],\n\t\t\t\t\tb = te[1],\n\t\t\t\t\tc = te[2],\n\t\t\t\t\td = te[3],\n\t\t\t\t\te = te[4],\n\t\t\t\t\tf = te[5],\n\t\t\t\t\tg = te[6],\n\t\t\t\t\th = te[7],\n\t\t\t\t\ti = te[8];\n\t\treturn a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g;\n\t}\n\n\tinvert() {\n\t\tconst te = this.elements,\n\t\t\t\t\tn11 = te[0],\n\t\t\t\t\tn21 = te[1],\n\t\t\t\t\tn31 = te[2],\n\t\t\t\t\tn12 = te[3],\n\t\t\t\t\tn22 = te[4],\n\t\t\t\t\tn32 = te[5],\n\t\t\t\t\tn13 = te[6],\n\t\t\t\t\tn23 = te[7],\n\t\t\t\t\tn33 = te[8],\n\t\t\t\t\tt11 = n33 * n22 - n32 * n23,\n\t\t\t\t\tt12 = n32 * n13 - n33 * n12,\n\t\t\t\t\tt13 = n23 * n12 - n22 * n13,\n\t\t\t\t\tdet = n11 * t11 + n21 * t12 + n31 * t13;\n\t\tif (det === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);\n\t\tconst detInv = 1 / det;\n\t\tte[0] = t11 * detInv;\n\t\tte[1] = (n31 * n23 - n33 * n21) * detInv;\n\t\tte[2] = (n32 * n21 - n31 * n22) * detInv;\n\t\tte[3] = t12 * detInv;\n\t\tte[4] = (n33 * n11 - n31 * n13) * detInv;\n\t\tte[5] = (n31 * n12 - n32 * n11) * detInv;\n\t\tte[6] = t13 * detInv;\n\t\tte[7] = (n21 * n13 - n23 * n11) * detInv;\n\t\tte[8] = (n22 * n11 - n21 * n12) * detInv;\n\t\treturn this;\n\t}\n\n\ttranspose() {\n\t\tlet tmp;\n\t\tconst m = this.elements;\n\t\ttmp = m[1];\n\t\tm[1] = m[3];\n\t\tm[3] = tmp;\n\t\ttmp = m[2];\n\t\tm[2] = m[6];\n\t\tm[6] = tmp;\n\t\ttmp = m[5];\n\t\tm[5] = m[7];\n\t\tm[7] = tmp;\n\t\treturn this;\n\t}\n\n\tgetNormalMatrix(matrix4) {\n\t\treturn this.setFromMatrix4(matrix4).invert().transpose();\n\t}\n\n\ttransposeIntoArray(r) {\n\t\tconst m = this.elements;\n\t\tr[0] = m[0];\n\t\tr[1] = m[3];\n\t\tr[2] = m[6];\n\t\tr[3] = m[1];\n\t\tr[4] = m[4];\n\t\tr[5] = m[7];\n\t\tr[6] = m[2];\n\t\tr[7] = m[5];\n\t\tr[8] = m[8];\n\t\treturn this;\n\t}\n\n\tsetUvTransform(tx, ty, sx, sy, rotation, cx, cy) {\n\t\tconst c = Math.cos(rotation);\n\t\tconst s = Math.sin(rotation);\n\t\tthis.set(sx * c, sx * s, -sx * (c * cx + s * cy) + cx + tx, -sy * s, sy * c, -sy * (-s * cx + c * cy) + cy + ty, 0, 0, 1);\n\t\treturn this;\n\t}\n\n\tscale(sx, sy) {\n\t\tconst te = this.elements;\n\t\tte[0] *= sx;\n\t\tte[3] *= sx;\n\t\tte[6] *= sx;\n\t\tte[1] *= sy;\n\t\tte[4] *= sy;\n\t\tte[7] *= sy;\n\t\treturn this;\n\t}\n\n\trotate(theta) {\n\t\tconst c = Math.cos(theta);\n\t\tconst s = Math.sin(theta);\n\t\tconst te = this.elements;\n\t\tconst a11 = te[0],\n\t\t\t\t\ta12 = te[3],\n\t\t\t\t\ta13 = te[6];\n\t\tconst a21 = te[1],\n\t\t\t\t\ta22 = te[4],\n\t\t\t\t\ta23 = te[7];\n\t\tte[0] = c * a11 + s * a21;\n\t\tte[3] = c * a12 + s * a22;\n\t\tte[6] = c * a13 + s * a23;\n\t\tte[1] = -s * a11 + c * a21;\n\t\tte[4] = -s * a12 + c * a22;\n\t\tte[7] = -s * a13 + c * a23;\n\t\treturn this;\n\t}\n\n\ttranslate(tx, ty) {\n\t\tconst te = this.elements;\n\t\tte[0] += tx * te[2];\n\t\tte[3] += tx * te[5];\n\t\tte[6] += tx * te[8];\n\t\tte[1] += ty * te[2];\n\t\tte[4] += ty * te[5];\n\t\tte[7] += ty * te[8];\n\t\treturn this;\n\t}\n\n\tequals(matrix) {\n\t\tconst te = this.elements;\n\t\tconst me = matrix.elements;\n\n\t\tfor (let i = 0; i < 9; i++) {\n\t\t\tif (te[i] !== me[i]) return false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tfromArray(array, offset = 0) {\n\t\tfor (let i = 0; i < 9; i++) {\n\t\t\tthis.elements[i] = array[i + offset];\n\t\t}\n\n\t\treturn this;\n\t}\n\n\ttoArray(array = [], offset = 0) {\n\t\tconst te = this.elements;\n\t\tarray[offset] = te[0];\n\t\tarray[offset + 1] = te[1];\n\t\tarray[offset + 2] = te[2];\n\t\tarray[offset + 3] = te[3];\n\t\tarray[offset + 4] = te[4];\n\t\tarray[offset + 5] = te[5];\n\t\tarray[offset + 6] = te[6];\n\t\tarray[offset + 7] = te[7];\n\t\tarray[offset + 8] = te[8];\n\t\treturn array;\n\t}\n\n\tclone() {\n\t\treturn new this.constructor().fromArray(this.elements);\n\t}\n\n}\n\nfunction arrayNeedsUint32(array) {\n\t// assumes larger values usually on last\n\tfor (let i = array.length - 1; i >= 0; --i) {\n\t\tif (array[i] >= 65535) return true; // account for PRIMITIVE_RESTART_FIXED_INDEX, #24565\n\t}\n\n\treturn false;\n}\n\nconst TYPED_ARRAYS = {\n\tInt8Array: Int8Array,\n\tUint8Array: Uint8Array,\n\tUint8ClampedArray: Uint8ClampedArray,\n\tInt16Array: Int16Array,\n\tUint16Array: Uint16Array,\n\tInt32Array: Int32Array,\n\tUint32Array: Uint32Array,\n\tFloat32Array: Float32Array,\n\tFloat64Array: Float64Array\n};\n\nfunction getTypedArray(type, buffer) {\n\treturn new TYPED_ARRAYS[type](buffer);\n}\n\nfunction createElementNS(name) {\n\treturn document.createElementNS('http://www.w3.org/1999/xhtml', name);\n}\n\nfunction SRGBToLinear(c) {\n\treturn c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);\n}\nfunction LinearToSRGB(c) {\n\treturn c < 0.0031308 ? c * 12.92 : 1.055 * Math.pow(c, 0.41666) - 0.055;\n} // JavaScript RGB-to-RGB transforms, defined as\n// FN[InputColorSpace][OutputColorSpace] callback functions.\n\nconst FN = {\n\t[SRGBColorSpace]: {\n\t\t[LinearSRGBColorSpace]: SRGBToLinear\n\t},\n\t[LinearSRGBColorSpace]: {\n\t\t[SRGBColorSpace]: LinearToSRGB\n\t}\n};\nconst ColorManagement = {\n\tlegacyMode: true,\n\n\tget workingColorSpace() {\n\t\treturn LinearSRGBColorSpace;\n\t},\n\n\tset workingColorSpace(colorSpace) {\n\t\tconsole.warn('THREE.ColorManagement: .workingColorSpace is readonly.');\n\t},\n\n\tconvert: function (color, sourceColorSpace, targetColorSpace) {\n\t\tif (this.legacyMode || sourceColorSpace === targetColorSpace || !sourceColorSpace || !targetColorSpace) {\n\t\t\treturn color;\n\t\t}\n\n\t\tif (FN[sourceColorSpace] && FN[sourceColorSpace][targetColorSpace] !== undefined) {\n\t\t\tconst fn = FN[sourceColorSpace][targetColorSpace];\n\t\t\tcolor.r = fn(color.r);\n\t\t\tcolor.g = fn(color.g);\n\t\t\tcolor.b = fn(color.b);\n\t\t\treturn color;\n\t\t}\n\n\t\tthrow new Error('Unsupported color space conversion.');\n\t},\n\tfromWorkingColorSpace: function (color, targetColorSpace) {\n\t\treturn this.convert(color, this.workingColorSpace, targetColorSpace);\n\t},\n\ttoWorkingColorSpace: function (color, sourceColorSpace) {\n\t\treturn this.convert(color, sourceColorSpace, this.workingColorSpace);\n\t}\n};\n\nconst _colorKeywords = {\n\t'aliceblue': 0xF0F8FF,\n\t'antiquewhite': 0xFAEBD7,\n\t'aqua': 0x00FFFF,\n\t'aquamarine': 0x7FFFD4,\n\t'azure': 0xF0FFFF,\n\t'beige': 0xF5F5DC,\n\t'bisque': 0xFFE4C4,\n\t'black': 0x000000,\n\t'blanchedalmond': 0xFFEBCD,\n\t'blue': 0x0000FF,\n\t'blueviolet': 0x8A2BE2,\n\t'brown': 0xA52A2A,\n\t'burlywood': 0xDEB887,\n\t'cadetblue': 0x5F9EA0,\n\t'chartreuse': 0x7FFF00,\n\t'chocolate': 0xD2691E,\n\t'coral': 0xFF7F50,\n\t'cornflowerblue': 0x6495ED,\n\t'cornsilk': 0xFFF8DC,\n\t'crimson': 0xDC143C,\n\t'cyan': 0x00FFFF,\n\t'darkblue': 0x00008B,\n\t'darkcyan': 0x008B8B,\n\t'darkgoldenrod': 0xB8860B,\n\t'darkgray': 0xA9A9A9,\n\t'darkgreen': 0x006400,\n\t'darkgrey': 0xA9A9A9,\n\t'darkkhaki': 0xBDB76B,\n\t'darkmagenta': 0x8B008B,\n\t'darkolivegreen': 0x556B2F,\n\t'darkorange': 0xFF8C00,\n\t'darkorchid': 0x9932CC,\n\t'darkred': 0x8B0000,\n\t'darksalmon': 0xE9967A,\n\t'darkseagreen': 0x8FBC8F,\n\t'darkslateblue': 0x483D8B,\n\t'darkslategray': 0x2F4F4F,\n\t'darkslategrey': 0x2F4F4F,\n\t'darkturquoise': 0x00CED1,\n\t'darkviolet': 0x9400D3,\n\t'deeppink': 0xFF1493,\n\t'deepskyblue': 0x00BFFF,\n\t'dimgray': 0x696969,\n\t'dimgrey': 0x696969,\n\t'dodgerblue': 0x1E90FF,\n\t'firebrick': 0xB22222,\n\t'floralwhite': 0xFFFAF0,\n\t'forestgreen': 0x228B22,\n\t'fuchsia': 0xFF00FF,\n\t'gainsboro': 0xDCDCDC,\n\t'ghostwhite': 0xF8F8FF,\n\t'gold': 0xFFD700,\n\t'goldenrod': 0xDAA520,\n\t'gray': 0x808080,\n\t'green': 0x008000,\n\t'greenyellow': 0xADFF2F,\n\t'grey': 0x808080,\n\t'honeydew': 0xF0FFF0,\n\t'hotpink': 0xFF69B4,\n\t'indianred': 0xCD5C5C,\n\t'indigo': 0x4B0082,\n\t'ivory': 0xFFFFF0,\n\t'khaki': 0xF0E68C,\n\t'lavender': 0xE6E6FA,\n\t'lavenderblush': 0xFFF0F5,\n\t'lawngreen': 0x7CFC00,\n\t'lemonchiffon': 0xFFFACD,\n\t'lightblue': 0xADD8E6,\n\t'lightcoral': 0xF08080,\n\t'lightcyan': 0xE0FFFF,\n\t'lightgoldenrodyellow': 0xFAFAD2,\n\t'lightgray': 0xD3D3D3,\n\t'lightgreen': 0x90EE90,\n\t'lightgrey': 0xD3D3D3,\n\t'lightpink': 0xFFB6C1,\n\t'lightsalmon': 0xFFA07A,\n\t'lightseagreen': 0x20B2AA,\n\t'lightskyblue': 0x87CEFA,\n\t'lightslategray': 0x778899,\n\t'lightslategrey': 0x778899,\n\t'lightsteelblue': 0xB0C4DE,\n\t'lightyellow': 0xFFFFE0,\n\t'lime': 0x00FF00,\n\t'limegreen': 0x32CD32,\n\t'linen': 0xFAF0E6,\n\t'magenta': 0xFF00FF,\n\t'maroon': 0x800000,\n\t'mediumaquamarine': 0x66CDAA,\n\t'mediumblue': 0x0000CD,\n\t'mediumorchid': 0xBA55D3,\n\t'mediumpurple': 0x9370DB,\n\t'mediumseagreen': 0x3CB371,\n\t'mediumslateblue': 0x7B68EE,\n\t'mediumspringgreen': 0x00FA9A,\n\t'mediumturquoise': 0x48D1CC,\n\t'mediumvioletred': 0xC71585,\n\t'midnightblue': 0x191970,\n\t'mintcream': 0xF5FFFA,\n\t'mistyrose': 0xFFE4E1,\n\t'moccasin': 0xFFE4B5,\n\t'navajowhite': 0xFFDEAD,\n\t'navy': 0x000080,\n\t'oldlace': 0xFDF5E6,\n\t'olive': 0x808000,\n\t'olivedrab': 0x6B8E23,\n\t'orange': 0xFFA500,\n\t'orangered': 0xFF4500,\n\t'orchid': 0xDA70D6,\n\t'palegoldenrod': 0xEEE8AA,\n\t'palegreen': 0x98FB98,\n\t'paleturquoise': 0xAFEEEE,\n\t'palevioletred': 0xDB7093,\n\t'papayawhip': 0xFFEFD5,\n\t'peachpuff': 0xFFDAB9,\n\t'peru': 0xCD853F,\n\t'pink': 0xFFC0CB,\n\t'plum': 0xDDA0DD,\n\t'powderblue': 0xB0E0E6,\n\t'purple': 0x800080,\n\t'rebeccapurple': 0x663399,\n\t'red': 0xFF0000,\n\t'rosybrown': 0xBC8F8F,\n\t'royalblue': 0x4169E1,\n\t'saddlebrown': 0x8B4513,\n\t'salmon': 0xFA8072,\n\t'sandybrown': 0xF4A460,\n\t'seagreen': 0x2E8B57,\n\t'seashell': 0xFFF5EE,\n\t'sienna': 0xA0522D,\n\t'silver': 0xC0C0C0,\n\t'skyblue': 0x87CEEB,\n\t'slateblue': 0x6A5ACD,\n\t'slategray': 0x708090,\n\t'slategrey': 0x708090,\n\t'snow': 0xFFFAFA,\n\t'springgreen': 0x00FF7F,\n\t'steelblue': 0x4682B4,\n\t'tan': 0xD2B48C,\n\t'teal': 0x008080,\n\t'thistle': 0xD8BFD8,\n\t'tomato': 0xFF6347,\n\t'turquoise': 0x40E0D0,\n\t'violet': 0xEE82EE,\n\t'wheat': 0xF5DEB3,\n\t'white': 0xFFFFFF,\n\t'whitesmoke': 0xF5F5F5,\n\t'yellow': 0xFFFF00,\n\t'yellowgreen': 0x9ACD32\n};\nconst _rgb = {\n\tr: 0,\n\tg: 0,\n\tb: 0\n};\nconst _hslA = {\n\th: 0,\n\ts: 0,\n\tl: 0\n};\nconst _hslB = {\n\th: 0,\n\ts: 0,\n\tl: 0\n};\n\nfunction hue2rgb(p, q, t) {\n\tif (t < 0) t += 1;\n\tif (t > 1) t -= 1;\n\tif (t < 1 / 6) return p + (q - p) * 6 * t;\n\tif (t < 1 / 2) return q;\n\tif (t < 2 / 3) return p + (q - p) * 6 * (2 / 3 - t);\n\treturn p;\n}\n\nfunction toComponents(source, target) {\n\ttarget.r = source.r;\n\ttarget.g = source.g;\n\ttarget.b = source.b;\n\treturn target;\n}\n\nclass Color {\n\tconstructor(r, g, b) {\n\t\tthis.isColor = true;\n\t\tthis.r = 1;\n\t\tthis.g = 1;\n\t\tthis.b = 1;\n\n\t\tif (g === undefined && b === undefined) {\n\t\t\t// r is THREE.Color, hex or string\n\t\t\treturn this.set(r);\n\t\t}\n\n\t\treturn this.setRGB(r, g, b);\n\t}\n\n\tset(value) {\n\t\tif (value && value.isColor) {\n\t\t\tthis.copy(value);\n\t\t} else if (typeof value === 'number') {\n\t\t\tthis.setHex(value);\n\t\t} else if (typeof value === 'string') {\n\t\t\tthis.setStyle(value);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tsetScalar(scalar) {\n\t\tthis.r = scalar;\n\t\tthis.g = scalar;\n\t\tthis.b = scalar;\n\t\treturn this;\n\t}\n\n\tsetHex(hex, colorSpace = SRGBColorSpace) {\n\t\thex = Math.floor(hex);\n\t\tthis.r = (hex >> 16 & 255) / 255;\n\t\tthis.g = (hex >> 8 & 255) / 255;\n\t\tthis.b = (hex & 255) / 255;\n\t\tColorManagement.toWorkingColorSpace(this, colorSpace);\n\t\treturn this;\n\t}\n\n\tsetRGB(r, g, b, colorSpace = LinearSRGBColorSpace) {\n\t\tthis.r = r;\n\t\tthis.g = g;\n\t\tthis.b = b;\n\t\tColorManagement.toWorkingColorSpace(this, colorSpace);\n\t\treturn this;\n\t}\n\n\tsetHSL(h, s, l, colorSpace = LinearSRGBColorSpace) {\n\t\t// h,s,l ranges are in 0.0 - 1.0\n\t\th = euclideanModulo(h, 1);\n\t\ts = clamp(s, 0, 1);\n\t\tl = clamp(l, 0, 1);\n\n\t\tif (s === 0) {\n\t\t\tthis.r = this.g = this.b = l;\n\t\t} else {\n\t\t\tconst p = l <= 0.5 ? l * (1 + s) : l + s - l * s;\n\t\t\tconst q = 2 * l - p;\n\t\t\tthis.r = hue2rgb(q, p, h + 1 / 3);\n\t\t\tthis.g = hue2rgb(q, p, h);\n\t\t\tthis.b = hue2rgb(q, p, h - 1 / 3);\n\t\t}\n\n\t\tColorManagement.toWorkingColorSpace(this, colorSpace);\n\t\treturn this;\n\t}\n\n\tsetStyle(style, colorSpace = SRGBColorSpace) {\n\t\tfunction handleAlpha(string) {\n\t\t\tif (string === undefined) return;\n\n\t\t\tif (parseFloat(string) < 1) {\n\t\t\t\tconsole.warn('THREE.Color: Alpha component of ' + style + ' will be ignored.');\n\t\t\t}\n\t\t}\n\n\t\tlet m;\n\n\t\tif (m = /^((?:rgb|hsl)a?)\\(([^\\)]*)\\)/.exec(style)) {\n\t\t\t// rgb / hsl\n\t\t\tlet color;\n\t\t\tconst name = m[1];\n\t\t\tconst components = m[2];\n\n\t\t\tswitch (name) {\n\t\t\t\tcase 'rgb':\n\t\t\t\tcase 'rgba':\n\t\t\t\t\tif (color = /^\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(components)) {\n\t\t\t\t\t\t// rgb(255,0,0) rgba(255,0,0,0.5)\n\t\t\t\t\t\tthis.r = Math.min(255, parseInt(color[1], 10)) / 255;\n\t\t\t\t\t\tthis.g = Math.min(255, parseInt(color[2], 10)) / 255;\n\t\t\t\t\t\tthis.b = Math.min(255, parseInt(color[3], 10)) / 255;\n\t\t\t\t\t\tColorManagement.toWorkingColorSpace(this, colorSpace);\n\t\t\t\t\t\thandleAlpha(color[4]);\n\t\t\t\t\t\treturn this;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (color = /^\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(components)) {\n\t\t\t\t\t\t// rgb(100%,0%,0%) rgba(100%,0%,0%,0.5)\n\t\t\t\t\t\tthis.r = Math.min(100, parseInt(color[1], 10)) / 100;\n\t\t\t\t\t\tthis.g = Math.min(100, parseInt(color[2], 10)) / 100;\n\t\t\t\t\t\tthis.b = Math.min(100, parseInt(color[3], 10)) / 100;\n\t\t\t\t\t\tColorManagement.toWorkingColorSpace(this, colorSpace);\n\t\t\t\t\t\thandleAlpha(color[4]);\n\t\t\t\t\t\treturn this;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'hsl':\n\t\t\t\tcase 'hsla':\n\t\t\t\t\tif (color = /^\\s*(\\d*\\.?\\d+)\\s*,\\s*(\\d*\\.?\\d+)\\%\\s*,\\s*(\\d*\\.?\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(components)) {\n\t\t\t\t\t\t// hsl(120,50%,50%) hsla(120,50%,50%,0.5)\n\t\t\t\t\t\tconst h = parseFloat(color[1]) / 360;\n\t\t\t\t\t\tconst s = parseFloat(color[2]) / 100;\n\t\t\t\t\t\tconst l = parseFloat(color[3]) / 100;\n\t\t\t\t\t\thandleAlpha(color[4]);\n\t\t\t\t\t\treturn this.setHSL(h, s, l, colorSpace);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t} else if (m = /^\\#([A-Fa-f\\d]+)$/.exec(style)) {\n\t\t\t// hex color\n\t\t\tconst hex = m[1];\n\t\t\tconst size = hex.length;\n\n\t\t\tif (size === 3) {\n\t\t\t\t// #ff0\n\t\t\t\tthis.r = parseInt(hex.charAt(0) + hex.charAt(0), 16) / 255;\n\t\t\t\tthis.g = parseInt(hex.charAt(1) + hex.charAt(1), 16) / 255;\n\t\t\t\tthis.b = parseInt(hex.charAt(2) + hex.charAt(2), 16) / 255;\n\t\t\t\tColorManagement.toWorkingColorSpace(this, colorSpace);\n\t\t\t\treturn this;\n\t\t\t} else if (size === 6) {\n\t\t\t\t// #ff0000\n\t\t\t\tthis.r = parseInt(hex.charAt(0) + hex.charAt(1), 16) / 255;\n\t\t\t\tthis.g = parseInt(hex.charAt(2) + hex.charAt(3), 16) / 255;\n\t\t\t\tthis.b = parseInt(hex.charAt(4) + hex.charAt(5), 16) / 255;\n\t\t\t\tColorManagement.toWorkingColorSpace(this, colorSpace);\n\t\t\t\treturn this;\n\t\t\t}\n\t\t}\n\n\t\tif (style && style.length > 0) {\n\t\t\treturn this.setColorName(style, colorSpace);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tsetColorName(style, colorSpace = SRGBColorSpace) {\n\t\t// color keywords\n\t\tconst hex = _colorKeywords[style.toLowerCase()];\n\n\t\tif (hex !== undefined) {\n\t\t\t// red\n\t\t\tthis.setHex(hex, colorSpace);\n\t\t} else {\n\t\t\t// unknown color\n\t\t\tconsole.warn('THREE.Color: Unknown color ' + style);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\treturn new this.constructor(this.r, this.g, this.b);\n\t}\n\n\tcopy(color) {\n\t\tthis.r = color.r;\n\t\tthis.g = color.g;\n\t\tthis.b = color.b;\n\t\treturn this;\n\t}\n\n\tcopySRGBToLinear(color) {\n\t\tthis.r = SRGBToLinear(color.r);\n\t\tthis.g = SRGBToLinear(color.g);\n\t\tthis.b = SRGBToLinear(color.b);\n\t\treturn this;\n\t}\n\n\tcopyLinearToSRGB(color) {\n\t\tthis.r = LinearToSRGB(color.r);\n\t\tthis.g = LinearToSRGB(color.g);\n\t\tthis.b = LinearToSRGB(color.b);\n\t\treturn this;\n\t}\n\n\tconvertSRGBToLinear() {\n\t\tthis.copySRGBToLinear(this);\n\t\treturn this;\n\t}\n\n\tconvertLinearToSRGB() {\n\t\tthis.copyLinearToSRGB(this);\n\t\treturn this;\n\t}\n\n\tgetHex(colorSpace = SRGBColorSpace) {\n\t\tColorManagement.fromWorkingColorSpace(toComponents(this, _rgb), colorSpace);\n\t\treturn clamp(_rgb.r * 255, 0, 255) << 16 ^ clamp(_rgb.g * 255, 0, 255) << 8 ^ clamp(_rgb.b * 255, 0, 255) << 0;\n\t}\n\n\tgetHexString(colorSpace = SRGBColorSpace) {\n\t\treturn ('000000' + this.getHex(colorSpace).toString(16)).slice(-6);\n\t}\n\n\tgetHSL(target, colorSpace = LinearSRGBColorSpace) {\n\t\t// h,s,l ranges are in 0.0 - 1.0\n\t\tColorManagement.fromWorkingColorSpace(toComponents(this, _rgb), colorSpace);\n\t\tconst r = _rgb.r,\n\t\t\t\t\tg = _rgb.g,\n\t\t\t\t\tb = _rgb.b;\n\t\tconst max = Math.max(r, g, b);\n\t\tconst min = Math.min(r, g, b);\n\t\tlet hue, saturation;\n\t\tconst lightness = (min + max) / 2.0;\n\n\t\tif (min === max) {\n\t\t\thue = 0;\n\t\t\tsaturation = 0;\n\t\t} else {\n\t\t\tconst delta = max - min;\n\t\t\tsaturation = lightness <= 0.5 ? delta / (max + min) : delta / (2 - max - min);\n\n\t\t\tswitch (max) {\n\t\t\t\tcase r:\n\t\t\t\t\thue = (g - b) / delta + (g < b ? 6 : 0);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase g:\n\t\t\t\t\thue = (b - r) / delta + 2;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase b:\n\t\t\t\t\thue = (r - g) / delta + 4;\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\thue /= 6;\n\t\t}\n\n\t\ttarget.h = hue;\n\t\ttarget.s = saturation;\n\t\ttarget.l = lightness;\n\t\treturn target;\n\t}\n\n\tgetRGB(target, colorSpace = LinearSRGBColorSpace) {\n\t\tColorManagement.fromWorkingColorSpace(toComponents(this, _rgb), colorSpace);\n\t\ttarget.r = _rgb.r;\n\t\ttarget.g = _rgb.g;\n\t\ttarget.b = _rgb.b;\n\t\treturn target;\n\t}\n\n\tgetStyle(colorSpace = SRGBColorSpace) {\n\t\tColorManagement.fromWorkingColorSpace(toComponents(this, _rgb), colorSpace);\n\n\t\tif (colorSpace !== SRGBColorSpace) {\n\t\t\t// Requires CSS Color Module Level 4 (https://www.w3.org/TR/css-color-4/).\n\t\t\treturn `color(${colorSpace} ${_rgb.r} ${_rgb.g} ${_rgb.b})`;\n\t\t}\n\n\t\treturn `rgb(${_rgb.r * 255 | 0},${_rgb.g * 255 | 0},${_rgb.b * 255 | 0})`;\n\t}\n\n\toffsetHSL(h, s, l) {\n\t\tthis.getHSL(_hslA);\n\t\t_hslA.h += h;\n\t\t_hslA.s += s;\n\t\t_hslA.l += l;\n\t\tthis.setHSL(_hslA.h, _hslA.s, _hslA.l);\n\t\treturn this;\n\t}\n\n\tadd(color) {\n\t\tthis.r += color.r;\n\t\tthis.g += color.g;\n\t\tthis.b += color.b;\n\t\treturn this;\n\t}\n\n\taddColors(color1, color2) {\n\t\tthis.r = color1.r + color2.r;\n\t\tthis.g = color1.g + color2.g;\n\t\tthis.b = color1.b + color2.b;\n\t\treturn this;\n\t}\n\n\taddScalar(s) {\n\t\tthis.r += s;\n\t\tthis.g += s;\n\t\tthis.b += s;\n\t\treturn this;\n\t}\n\n\tsub(color) {\n\t\tthis.r = Math.max(0, this.r - color.r);\n\t\tthis.g = Math.max(0, this.g - color.g);\n\t\tthis.b = Math.max(0, this.b - color.b);\n\t\treturn this;\n\t}\n\n\tmultiply(color) {\n\t\tthis.r *= color.r;\n\t\tthis.g *= color.g;\n\t\tthis.b *= color.b;\n\t\treturn this;\n\t}\n\n\tmultiplyScalar(s) {\n\t\tthis.r *= s;\n\t\tthis.g *= s;\n\t\tthis.b *= s;\n\t\treturn this;\n\t}\n\n\tlerp(color, alpha) {\n\t\tthis.r += (color.r - this.r) * alpha;\n\t\tthis.g += (color.g - this.g) * alpha;\n\t\tthis.b += (color.b - this.b) * alpha;\n\t\treturn this;\n\t}\n\n\tlerpColors(color1, color2, alpha) {\n\t\tthis.r = color1.r + (color2.r - color1.r) * alpha;\n\t\tthis.g = color1.g + (color2.g - color1.g) * alpha;\n\t\tthis.b = color1.b + (color2.b - color1.b) * alpha;\n\t\treturn this;\n\t}\n\n\tlerpHSL(color, alpha) {\n\t\tthis.getHSL(_hslA);\n\t\tcolor.getHSL(_hslB);\n\t\tconst h = lerp(_hslA.h, _hslB.h, alpha);\n\t\tconst s = lerp(_hslA.s, _hslB.s, alpha);\n\t\tconst l = lerp(_hslA.l, _hslB.l, alpha);\n\t\tthis.setHSL(h, s, l);\n\t\treturn this;\n\t}\n\n\tequals(c) {\n\t\treturn c.r === this.r && c.g === this.g && c.b === this.b;\n\t}\n\n\tfromArray(array, offset = 0) {\n\t\tthis.r = array[offset];\n\t\tthis.g = array[offset + 1];\n\t\tthis.b = array[offset + 2];\n\t\treturn this;\n\t}\n\n\ttoArray(array = [], offset = 0) {\n\t\tarray[offset] = this.r;\n\t\tarray[offset + 1] = this.g;\n\t\tarray[offset + 2] = this.b;\n\t\treturn array;\n\t}\n\n\tfromBufferAttribute(attribute, index) {\n\t\tthis.r = attribute.getX(index);\n\t\tthis.g = attribute.getY(index);\n\t\tthis.b = attribute.getZ(index);\n\t\treturn this;\n\t}\n\n\ttoJSON() {\n\t\treturn this.getHex();\n\t}\n\n\t*[Symbol.iterator]() {\n\t\tyield this.r;\n\t\tyield this.g;\n\t\tyield this.b;\n\t}\n\n}\n\nColor.NAMES = _colorKeywords;\n\nlet _canvas;\n\nclass ImageUtils {\n\tstatic getDataURL(image) {\n\t\tif (/^data:/i.test(image.src)) {\n\t\t\treturn image.src;\n\t\t}\n\n\t\tif (typeof HTMLCanvasElement == 'undefined') {\n\t\t\treturn image.src;\n\t\t}\n\n\t\tlet canvas;\n\n\t\tif (image instanceof HTMLCanvasElement) {\n\t\t\tcanvas = image;\n\t\t} else {\n\t\t\tif (_canvas === undefined) _canvas = createElementNS('canvas');\n\t\t\t_canvas.width = image.width;\n\t\t\t_canvas.height = image.height;\n\n\t\t\tconst context = _canvas.getContext('2d');\n\n\t\t\tif (image instanceof ImageData) {\n\t\t\t\tcontext.putImageData(image, 0, 0);\n\t\t\t} else {\n\t\t\t\tcontext.drawImage(image, 0, 0, image.width, image.height);\n\t\t\t}\n\n\t\t\tcanvas = _canvas;\n\t\t}\n\n\t\tif (canvas.width > 2048 || canvas.height > 2048) {\n\t\t\tconsole.warn('THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons', image);\n\t\t\treturn canvas.toDataURL('image/jpeg', 0.6);\n\t\t} else {\n\t\t\treturn canvas.toDataURL('image/png');\n\t\t}\n\t}\n\n\tstatic sRGBToLinear(image) {\n\t\tif (typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement || typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement || typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap) {\n\t\t\tconst canvas = createElementNS('canvas');\n\t\t\tcanvas.width = image.width;\n\t\t\tcanvas.height = image.height;\n\t\t\tconst context = canvas.getContext('2d');\n\t\t\tcontext.drawImage(image, 0, 0, image.width, image.height);\n\t\t\tconst imageData = context.getImageData(0, 0, image.width, image.height);\n\t\t\tconst data = imageData.data;\n\n\t\t\tfor (let i = 0; i < data.length; i++) {\n\t\t\t\tdata[i] = SRGBToLinear(data[i] / 255) * 255;\n\t\t\t}\n\n\t\t\tcontext.putImageData(imageData, 0, 0);\n\t\t\treturn canvas;\n\t\t} else if (image.data) {\n\t\t\tconst data = image.data.slice(0);\n\n\t\t\tfor (let i = 0; i < data.length; i++) {\n\t\t\t\tif (data instanceof Uint8Array || data instanceof Uint8ClampedArray) {\n\t\t\t\t\tdata[i] = Math.floor(SRGBToLinear(data[i] / 255) * 255);\n\t\t\t\t} else {\n\t\t\t\t\t// assuming float\n\t\t\t\t\tdata[i] = SRGBToLinear(data[i]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tdata: data,\n\t\t\t\twidth: image.width,\n\t\t\t\theight: image.height\n\t\t\t};\n\t\t} else {\n\t\t\tconsole.warn('THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.');\n\t\t\treturn image;\n\t\t}\n\t}\n\n}\n\nclass Source {\n\tconstructor(data = null) {\n\t\tthis.isSource = true;\n\t\tthis.uuid = generateUUID();\n\t\tthis.data = data;\n\t\tthis.version = 0;\n\t}\n\n\tset needsUpdate(value) {\n\t\tif (value === true) this.version++;\n\t}\n\n\ttoJSON(meta) {\n\t\tconst isRootObject = meta === undefined || typeof meta === 'string';\n\n\t\tif (!isRootObject && meta.images[this.uuid] !== undefined) {\n\t\t\treturn meta.images[this.uuid];\n\t\t}\n\n\t\tconst output = {\n\t\t\tuuid: this.uuid,\n\t\t\turl: ''\n\t\t};\n\t\tconst data = this.data;\n\n\t\tif (data !== null) {\n\t\t\tlet url;\n\n\t\t\tif (Array.isArray(data)) {\n\t\t\t\t// cube texture\n\t\t\t\turl = [];\n\n\t\t\t\tfor (let i = 0, l = data.length; i < l; i++) {\n\t\t\t\t\tif (data[i].isDataTexture) {\n\t\t\t\t\t\turl.push(serializeImage(data[i].image));\n\t\t\t\t\t} else {\n\t\t\t\t\t\turl.push(serializeImage(data[i]));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// texture\n\t\t\t\turl = serializeImage(data);\n\t\t\t}\n\n\t\t\toutput.url = url;\n\t\t}\n\n\t\tif (!isRootObject) {\n\t\t\tmeta.images[this.uuid] = output;\n\t\t}\n\n\t\treturn output;\n\t}\n\n}\n\nfunction serializeImage(image) {\n\tif (typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement || typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement || typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap) {\n\t\t// default images\n\t\treturn ImageUtils.getDataURL(image);\n\t} else {\n\t\tif (image.data) {\n\t\t\t// images of DataTexture\n\t\t\treturn {\n\t\t\t\tdata: Array.from(image.data),\n\t\t\t\twidth: image.width,\n\t\t\t\theight: image.height,\n\t\t\t\ttype: image.data.constructor.name\n\t\t\t};\n\t\t} else {\n\t\t\tconsole.warn('THREE.Texture: Unable to serialize Texture.');\n\t\t\treturn {};\n\t\t}\n\t}\n}\n\nlet textureId = 0;\n\nclass Texture extends EventDispatcher {\n\tconstructor(image = Texture.DEFAULT_IMAGE, mapping = Texture.DEFAULT_MAPPING, wrapS = ClampToEdgeWrapping, wrapT = ClampToEdgeWrapping, magFilter = LinearFilter, minFilter = LinearMipmapLinearFilter, format = RGBAFormat, type = UnsignedByteType, anisotropy = 1, encoding = LinearEncoding) {\n\t\tsuper();\n\t\tthis.isTexture = true;\n\t\tObject.defineProperty(this, 'id', {\n\t\t\tvalue: textureId++\n\t\t});\n\t\tthis.uuid = generateUUID();\n\t\tthis.name = '';\n\t\tthis.source = new Source(image);\n\t\tthis.mipmaps = [];\n\t\tthis.mapping = mapping;\n\t\tthis.wrapS = wrapS;\n\t\tthis.wrapT = wrapT;\n\t\tthis.magFilter = magFilter;\n\t\tthis.minFilter = minFilter;\n\t\tthis.anisotropy = anisotropy;\n\t\tthis.format = format;\n\t\tthis.internalFormat = null;\n\t\tthis.type = type;\n\t\tthis.offset = new Vector2(0, 0);\n\t\tthis.repeat = new Vector2(1, 1);\n\t\tthis.center = new Vector2(0, 0);\n\t\tthis.rotation = 0;\n\t\tthis.matrixAutoUpdate = true;\n\t\tthis.matrix = new Matrix3();\n\t\tthis.generateMipmaps = true;\n\t\tthis.premultiplyAlpha = false;\n\t\tthis.flipY = true;\n\t\tthis.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)\n\t\t// Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap.\n\t\t//\n\t\t// Also changing the encoding after already used by a Material will not automatically make the Material\n\t\t// update. You need to explicitly call Material.needsUpdate to trigger it to recompile.\n\n\t\tthis.encoding = encoding;\n\t\tthis.userData = {};\n\t\tthis.version = 0;\n\t\tthis.onUpdate = null;\n\t\tthis.isRenderTargetTexture = false; // indicates whether a texture belongs to a render target or not\n\n\t\tthis.needsPMREMUpdate = false; // indicates whether this texture should be processed by PMREMGenerator or not (only relevant for render target textures)\n\t}\n\n\tget image() {\n\t\treturn this.source.data;\n\t}\n\n\tset image(value) {\n\t\tthis.source.data = value;\n\t}\n\n\tupdateMatrix() {\n\t\tthis.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y);\n\t}\n\n\tclone() {\n\t\treturn new this.constructor().copy(this);\n\t}\n\n\tcopy(source) {\n\t\tthis.name = source.name;\n\t\tthis.source = source.source;\n\t\tthis.mipmaps = source.mipmaps.slice(0);\n\t\tthis.mapping = source.mapping;\n\t\tthis.wrapS = source.wrapS;\n\t\tthis.wrapT = source.wrapT;\n\t\tthis.magFilter = source.magFilter;\n\t\tthis.minFilter = source.minFilter;\n\t\tthis.anisotropy = source.anisotropy;\n\t\tthis.format = source.format;\n\t\tthis.internalFormat = source.internalFormat;\n\t\tthis.type = source.type;\n\t\tthis.offset.copy(source.offset);\n\t\tthis.repeat.copy(source.repeat);\n\t\tthis.center.copy(source.center);\n\t\tthis.rotation = source.rotation;\n\t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\t\tthis.matrix.copy(source.matrix);\n\t\tthis.generateMipmaps = source.generateMipmaps;\n\t\tthis.premultiplyAlpha = source.premultiplyAlpha;\n\t\tthis.flipY = source.flipY;\n\t\tthis.unpackAlignment = source.unpackAlignment;\n\t\tthis.encoding = source.encoding;\n\t\tthis.userData = JSON.parse(JSON.stringify(source.userData));\n\t\tthis.needsUpdate = true;\n\t\treturn this;\n\t}\n\n\ttoJSON(meta) {\n\t\tconst isRootObject = meta === undefined || typeof meta === 'string';\n\n\t\tif (!isRootObject && meta.textures[this.uuid] !== undefined) {\n\t\t\treturn meta.textures[this.uuid];\n\t\t}\n\n\t\tconst output = {\n\t\t\tmetadata: {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'Texture',\n\t\t\t\tgenerator: 'Texture.toJSON'\n\t\t\t},\n\t\t\tuuid: this.uuid,\n\t\t\tname: this.name,\n\t\t\timage: this.source.toJSON(meta).uuid,\n\t\t\tmapping: this.mapping,\n\t\t\trepeat: [this.repeat.x, this.repeat.y],\n\t\t\toffset: [this.offset.x, this.offset.y],\n\t\t\tcenter: [this.center.x, this.center.y],\n\t\t\trotation: this.rotation,\n\t\t\twrap: [this.wrapS, this.wrapT],\n\t\t\tformat: this.format,\n\t\t\ttype: this.type,\n\t\t\tencoding: this.encoding,\n\t\t\tminFilter: this.minFilter,\n\t\t\tmagFilter: this.magFilter,\n\t\t\tanisotropy: this.anisotropy,\n\t\t\tflipY: this.flipY,\n\t\t\tpremultiplyAlpha: this.premultiplyAlpha,\n\t\t\tunpackAlignment: this.unpackAlignment\n\t\t};\n\t\tif (JSON.stringify(this.userData) !== '{}') output.userData = this.userData;\n\n\t\tif (!isRootObject) {\n\t\t\tmeta.textures[this.uuid] = output;\n\t\t}\n\n\t\treturn output;\n\t}\n\n\tdispose() {\n\t\tthis.dispatchEvent({\n\t\t\ttype: 'dispose'\n\t\t});\n\t}\n\n\ttransformUv(uv) {\n\t\tif (this.mapping !== UVMapping) return uv;\n\t\tuv.applyMatrix3(this.matrix);\n\n\t\tif (uv.x < 0 || uv.x > 1) {\n\t\t\tswitch (this.wrapS) {\n\t\t\t\tcase RepeatWrapping:\n\t\t\t\t\tuv.x = uv.x - Math.floor(uv.x);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase ClampToEdgeWrapping:\n\t\t\t\t\tuv.x = uv.x < 0 ? 0 : 1;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase MirroredRepeatWrapping:\n\t\t\t\t\tif (Math.abs(Math.floor(uv.x) % 2) === 1) {\n\t\t\t\t\t\tuv.x = Math.ceil(uv.x) - uv.x;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tuv.x = uv.x - Math.floor(uv.x);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (uv.y < 0 || uv.y > 1) {\n\t\t\tswitch (this.wrapT) {\n\t\t\t\tcase RepeatWrapping:\n\t\t\t\t\tuv.y = uv.y - Math.floor(uv.y);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase ClampToEdgeWrapping:\n\t\t\t\t\tuv.y = uv.y < 0 ? 0 : 1;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase MirroredRepeatWrapping:\n\t\t\t\t\tif (Math.abs(Math.floor(uv.y) % 2) === 1) {\n\t\t\t\t\t\tuv.y = Math.ceil(uv.y) - uv.y;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tuv.y = uv.y - Math.floor(uv.y);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (this.flipY) {\n\t\t\tuv.y = 1 - uv.y;\n\t\t}\n\n\t\treturn uv;\n\t}\n\n\tset needsUpdate(value) {\n\t\tif (value === true) {\n\t\t\tthis.version++;\n\t\t\tthis.source.needsUpdate = true;\n\t\t}\n\t}\n\n}\n\nTexture.DEFAULT_IMAGE = null;\nTexture.DEFAULT_MAPPING = UVMapping;\n\nclass Vector4 {\n\tconstructor(x = 0, y = 0, z = 0, w = 1) {\n\t\tVector4.prototype.isVector4 = true;\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.z = z;\n\t\tthis.w = w;\n\t}\n\n\tget width() {\n\t\treturn this.z;\n\t}\n\n\tset width(value) {\n\t\tthis.z = value;\n\t}\n\n\tget height() {\n\t\treturn this.w;\n\t}\n\n\tset height(value) {\n\t\tthis.w = value;\n\t}\n\n\tset(x, y, z, w) {\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.z = z;\n\t\tthis.w = w;\n\t\treturn this;\n\t}\n\n\tsetScalar(scalar) {\n\t\tthis.x = scalar;\n\t\tthis.y = scalar;\n\t\tthis.z = scalar;\n\t\tthis.w = scalar;\n\t\treturn this;\n\t}\n\n\tsetX(x) {\n\t\tthis.x = x;\n\t\treturn this;\n\t}\n\n\tsetY(y) {\n\t\tthis.y = y;\n\t\treturn this;\n\t}\n\n\tsetZ(z) {\n\t\tthis.z = z;\n\t\treturn this;\n\t}\n\n\tsetW(w) {\n\t\tthis.w = w;\n\t\treturn this;\n\t}\n\n\tsetComponent(index, value) {\n\t\tswitch (index) {\n\t\t\tcase 0:\n\t\t\t\tthis.x = value;\n\t\t\t\tbreak;\n\n\t\t\tcase 1:\n\t\t\t\tthis.y = value;\n\t\t\t\tbreak;\n\n\t\t\tcase 2:\n\t\t\t\tthis.z = value;\n\t\t\t\tbreak;\n\n\t\t\tcase 3:\n\t\t\t\tthis.w = value;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error('index is out of range: ' + index);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tgetComponent(index) {\n\t\tswitch (index) {\n\t\t\tcase 0:\n\t\t\t\treturn this.x;\n\n\t\t\tcase 1:\n\t\t\t\treturn this.y;\n\n\t\t\tcase 2:\n\t\t\t\treturn this.z;\n\n\t\t\tcase 3:\n\t\t\t\treturn this.w;\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error('index is out of range: ' + index);\n\t\t}\n\t}\n\n\tclone() {\n\t\treturn new this.constructor(this.x, this.y, this.z, this.w);\n\t}\n\n\tcopy(v) {\n\t\tthis.x = v.x;\n\t\tthis.y = v.y;\n\t\tthis.z = v.z;\n\t\tthis.w = v.w !== undefined ? v.w : 1;\n\t\treturn this;\n\t}\n\n\tadd(v) {\n\t\tthis.x += v.x;\n\t\tthis.y += v.y;\n\t\tthis.z += v.z;\n\t\tthis.w += v.w;\n\t\treturn this;\n\t}\n\n\taddScalar(s) {\n\t\tthis.x += s;\n\t\tthis.y += s;\n\t\tthis.z += s;\n\t\tthis.w += s;\n\t\treturn this;\n\t}\n\n\taddVectors(a, b) {\n\t\tthis.x = a.x + b.x;\n\t\tthis.y = a.y + b.y;\n\t\tthis.z = a.z + b.z;\n\t\tthis.w = a.w + b.w;\n\t\treturn this;\n\t}\n\n\taddScaledVector(v, s) {\n\t\tthis.x += v.x * s;\n\t\tthis.y += v.y * s;\n\t\tthis.z += v.z * s;\n\t\tthis.w += v.w * s;\n\t\treturn this;\n\t}\n\n\tsub(v) {\n\t\tthis.x -= v.x;\n\t\tthis.y -= v.y;\n\t\tthis.z -= v.z;\n\t\tthis.w -= v.w;\n\t\treturn this;\n\t}\n\n\tsubScalar(s) {\n\t\tthis.x -= s;\n\t\tthis.y -= s;\n\t\tthis.z -= s;\n\t\tthis.w -= s;\n\t\treturn this;\n\t}\n\n\tsubVectors(a, b) {\n\t\tthis.x = a.x - b.x;\n\t\tthis.y = a.y - b.y;\n\t\tthis.z = a.z - b.z;\n\t\tthis.w = a.w - b.w;\n\t\treturn this;\n\t}\n\n\tmultiply(v) {\n\t\tthis.x *= v.x;\n\t\tthis.y *= v.y;\n\t\tthis.z *= v.z;\n\t\tthis.w *= v.w;\n\t\treturn this;\n\t}\n\n\tmultiplyScalar(scalar) {\n\t\tthis.x *= scalar;\n\t\tthis.y *= scalar;\n\t\tthis.z *= scalar;\n\t\tthis.w *= scalar;\n\t\treturn this;\n\t}\n\n\tapplyMatrix4(m) {\n\t\tconst x = this.x,\n\t\t\t\t\ty = this.y,\n\t\t\t\t\tz = this.z,\n\t\t\t\t\tw = this.w;\n\t\tconst e = m.elements;\n\t\tthis.x = e[0] * x + e[4] * y + e[8] * z + e[12] * w;\n\t\tthis.y = e[1] * x + e[5] * y + e[9] * z + e[13] * w;\n\t\tthis.z = e[2] * x + e[6] * y + e[10] * z + e[14] * w;\n\t\tthis.w = e[3] * x + e[7] * y + e[11] * z + e[15] * w;\n\t\treturn this;\n\t}\n\n\tdivideScalar(scalar) {\n\t\treturn this.multiplyScalar(1 / scalar);\n\t}\n\n\tsetAxisAngleFromQuaternion(q) {\n\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm\n\t\t// q is assumed to be normalized\n\t\tthis.w = 2 * Math.acos(q.w);\n\t\tconst s = Math.sqrt(1 - q.w * q.w);\n\n\t\tif (s < 0.0001) {\n\t\t\tthis.x = 1;\n\t\t\tthis.y = 0;\n\t\t\tthis.z = 0;\n\t\t} else {\n\t\t\tthis.x = q.x / s;\n\t\t\tthis.y = q.y / s;\n\t\t\tthis.z = q.z / s;\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tsetAxisAngleFromRotationMatrix(m) {\n\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm\n\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\t\tlet angle, x, y, z; // variables for result\n\n\t\tconst epsilon = 0.01,\n\t\t\t\t\t// margin to allow for rounding errors\n\t\tepsilon2 = 0.1,\n\t\t\t\t\t// margin to distinguish between 0 and 180 degrees\n\t\tte = m.elements,\n\t\t\t\t\tm11 = te[0],\n\t\t\t\t\tm12 = te[4],\n\t\t\t\t\tm13 = te[8],\n\t\t\t\t\tm21 = te[1],\n\t\t\t\t\tm22 = te[5],\n\t\t\t\t\tm23 = te[9],\n\t\t\t\t\tm31 = te[2],\n\t\t\t\t\tm32 = te[6],\n\t\t\t\t\tm33 = te[10];\n\n\t\tif (Math.abs(m12 - m21) < epsilon && Math.abs(m13 - m31) < epsilon && Math.abs(m23 - m32) < epsilon) {\n\t\t\t// singularity found\n\t\t\t// first check for identity matrix which must have +1 for all terms\n\t\t\t// in leading diagonal and zero in other terms\n\t\t\tif (Math.abs(m12 + m21) < epsilon2 && Math.abs(m13 + m31) < epsilon2 && Math.abs(m23 + m32) < epsilon2 && Math.abs(m11 + m22 + m33 - 3) < epsilon2) {\n\t\t\t\t// this singularity is identity matrix so angle = 0\n\t\t\t\tthis.set(1, 0, 0, 0);\n\t\t\t\treturn this; // zero angle, arbitrary axis\n\t\t\t} // otherwise this singularity is angle = 180\n\n\n\t\t\tangle = Math.PI;\n\t\t\tconst xx = (m11 + 1) / 2;\n\t\t\tconst yy = (m22 + 1) / 2;\n\t\t\tconst zz = (m33 + 1) / 2;\n\t\t\tconst xy = (m12 + m21) / 4;\n\t\t\tconst xz = (m13 + m31) / 4;\n\t\t\tconst yz = (m23 + m32) / 4;\n\n\t\t\tif (xx > yy && xx > zz) {\n\t\t\t\t// m11 is the largest diagonal term\n\t\t\t\tif (xx < epsilon) {\n\t\t\t\t\tx = 0;\n\t\t\t\t\ty = 0.707106781;\n\t\t\t\t\tz = 0.707106781;\n\t\t\t\t} else {\n\t\t\t\t\tx = Math.sqrt(xx);\n\t\t\t\t\ty = xy / x;\n\t\t\t\t\tz = xz / x;\n\t\t\t\t}\n\t\t\t} else if (yy > zz) {\n\t\t\t\t// m22 is the largest diagonal term\n\t\t\t\tif (yy < epsilon) {\n\t\t\t\t\tx = 0.707106781;\n\t\t\t\t\ty = 0;\n\t\t\t\t\tz = 0.707106781;\n\t\t\t\t} else {\n\t\t\t\t\ty = Math.sqrt(yy);\n\t\t\t\t\tx = xy / y;\n\t\t\t\t\tz = yz / y;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// m33 is the largest diagonal term so base result on this\n\t\t\t\tif (zz < epsilon) {\n\t\t\t\t\tx = 0.707106781;\n\t\t\t\t\ty = 0.707106781;\n\t\t\t\t\tz = 0;\n\t\t\t\t} else {\n\t\t\t\t\tz = Math.sqrt(zz);\n\t\t\t\t\tx = xz / z;\n\t\t\t\t\ty = yz / z;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.set(x, y, z, angle);\n\t\t\treturn this; // return 180 deg rotation\n\t\t} // as we have reached here there are no singularities so we can handle normally\n\n\n\t\tlet s = Math.sqrt((m32 - m23) * (m32 - m23) + (m13 - m31) * (m13 - m31) + (m21 - m12) * (m21 - m12)); // used to normalize\n\n\t\tif (Math.abs(s) < 0.001) s = 1; // prevent divide by zero, should not happen if matrix is orthogonal and should be\n\t\t// caught by singularity test above, but I've left it in just in case\n\n\t\tthis.x = (m32 - m23) / s;\n\t\tthis.y = (m13 - m31) / s;\n\t\tthis.z = (m21 - m12) / s;\n\t\tthis.w = Math.acos((m11 + m22 + m33 - 1) / 2);\n\t\treturn this;\n\t}\n\n\tmin(v) {\n\t\tthis.x = Math.min(this.x, v.x);\n\t\tthis.y = Math.min(this.y, v.y);\n\t\tthis.z = Math.min(this.z, v.z);\n\t\tthis.w = Math.min(this.w, v.w);\n\t\treturn this;\n\t}\n\n\tmax(v) {\n\t\tthis.x = Math.max(this.x, v.x);\n\t\tthis.y = Math.max(this.y, v.y);\n\t\tthis.z = Math.max(this.z, v.z);\n\t\tthis.w = Math.max(this.w, v.w);\n\t\treturn this;\n\t}\n\n\tclamp(min, max) {\n\t\t// assumes min < max, componentwise\n\t\tthis.x = Math.max(min.x, Math.min(max.x, this.x));\n\t\tthis.y = Math.max(min.y, Math.min(max.y, this.y));\n\t\tthis.z = Math.max(min.z, Math.min(max.z, this.z));\n\t\tthis.w = Math.max(min.w, Math.min(max.w, this.w));\n\t\treturn this;\n\t}\n\n\tclampScalar(minVal, maxVal) {\n\t\tthis.x = Math.max(minVal, Math.min(maxVal, this.x));\n\t\tthis.y = Math.max(minVal, Math.min(maxVal, this.y));\n\t\tthis.z = Math.max(minVal, Math.min(maxVal, this.z));\n\t\tthis.w = Math.max(minVal, Math.min(maxVal, this.w));\n\t\treturn this;\n\t}\n\n\tclampLength(min, max) {\n\t\tconst length = this.length();\n\t\treturn this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));\n\t}\n\n\tfloor() {\n\t\tthis.x = Math.floor(this.x);\n\t\tthis.y = Math.floor(this.y);\n\t\tthis.z = Math.floor(this.z);\n\t\tthis.w = Math.floor(this.w);\n\t\treturn this;\n\t}\n\n\tceil() {\n\t\tthis.x = Math.ceil(this.x);\n\t\tthis.y = Math.ceil(this.y);\n\t\tthis.z = Math.ceil(this.z);\n\t\tthis.w = Math.ceil(this.w);\n\t\treturn this;\n\t}\n\n\tround() {\n\t\tthis.x = Math.round(this.x);\n\t\tthis.y = Math.round(this.y);\n\t\tthis.z = Math.round(this.z);\n\t\tthis.w = Math.round(this.w);\n\t\treturn this;\n\t}\n\n\troundToZero() {\n\t\tthis.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x);\n\t\tthis.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y);\n\t\tthis.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z);\n\t\tthis.w = this.w < 0 ? Math.ceil(this.w) : Math.floor(this.w);\n\t\treturn this;\n\t}\n\n\tnegate() {\n\t\tthis.x = -this.x;\n\t\tthis.y = -this.y;\n\t\tthis.z = -this.z;\n\t\tthis.w = -this.w;\n\t\treturn this;\n\t}\n\n\tdot(v) {\n\t\treturn this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;\n\t}\n\n\tlengthSq() {\n\t\treturn this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;\n\t}\n\n\tlength() {\n\t\treturn Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);\n\t}\n\n\tmanhattanLength() {\n\t\treturn Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w);\n\t}\n\n\tnormalize() {\n\t\treturn this.divideScalar(this.length() || 1);\n\t}\n\n\tsetLength(length) {\n\t\treturn this.normalize().multiplyScalar(length);\n\t}\n\n\tlerp(v, alpha) {\n\t\tthis.x += (v.x - this.x) * alpha;\n\t\tthis.y += (v.y - this.y) * alpha;\n\t\tthis.z += (v.z - this.z) * alpha;\n\t\tthis.w += (v.w - this.w) * alpha;\n\t\treturn this;\n\t}\n\n\tlerpVectors(v1, v2, alpha) {\n\t\tthis.x = v1.x + (v2.x - v1.x) * alpha;\n\t\tthis.y = v1.y + (v2.y - v1.y) * alpha;\n\t\tthis.z = v1.z + (v2.z - v1.z) * alpha;\n\t\tthis.w = v1.w + (v2.w - v1.w) * alpha;\n\t\treturn this;\n\t}\n\n\tequals(v) {\n\t\treturn v.x === this.x && v.y === this.y && v.z === this.z && v.w === this.w;\n\t}\n\n\tfromArray(array, offset = 0) {\n\t\tthis.x = array[offset];\n\t\tthis.y = array[offset + 1];\n\t\tthis.z = array[offset + 2];\n\t\tthis.w = array[offset + 3];\n\t\treturn this;\n\t}\n\n\ttoArray(array = [], offset = 0) {\n\t\tarray[offset] = this.x;\n\t\tarray[offset + 1] = this.y;\n\t\tarray[offset + 2] = this.z;\n\t\tarray[offset + 3] = this.w;\n\t\treturn array;\n\t}\n\n\tfromBufferAttribute(attribute, index) {\n\t\tthis.x = attribute.getX(index);\n\t\tthis.y = attribute.getY(index);\n\t\tthis.z = attribute.getZ(index);\n\t\tthis.w = attribute.getW(index);\n\t\treturn this;\n\t}\n\n\trandom() {\n\t\tthis.x = Math.random();\n\t\tthis.y = Math.random();\n\t\tthis.z = Math.random();\n\t\tthis.w = Math.random();\n\t\treturn this;\n\t}\n\n\t*[Symbol.iterator]() {\n\t\tyield this.x;\n\t\tyield this.y;\n\t\tyield this.z;\n\t\tyield this.w;\n\t}\n\n}\n\n/*\n In options, we can specify:\n * Texture parameters for an auto-generated target texture\n * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers\n*/\n\nclass WebGLRenderTarget extends EventDispatcher {\n\tconstructor(width, height, options = {}) {\n\t\tsuper();\n\t\tthis.isWebGLRenderTarget = true;\n\t\tthis.width = width;\n\t\tthis.height = height;\n\t\tthis.depth = 1;\n\t\tthis.scissor = new Vector4(0, 0, width, height);\n\t\tthis.scissorTest = false;\n\t\tthis.viewport = new Vector4(0, 0, width, height);\n\t\tconst image = {\n\t\t\twidth: width,\n\t\t\theight: height,\n\t\t\tdepth: 1\n\t\t};\n\t\tthis.texture = new Texture(image, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding);\n\t\tthis.texture.isRenderTargetTexture = true;\n\t\tthis.texture.flipY = false;\n\t\tthis.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;\n\t\tthis.texture.internalFormat = options.internalFormat !== undefined ? options.internalFormat : null;\n\t\tthis.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;\n\t\tthis.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;\n\t\tthis.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : false;\n\t\tthis.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;\n\t\tthis.samples = options.samples !== undefined ? options.samples : 0;\n\t}\n\n\tsetSize(width, height, depth = 1) {\n\t\tif (this.width !== width || this.height !== height || this.depth !== depth) {\n\t\t\tthis.width = width;\n\t\t\tthis.height = height;\n\t\t\tthis.depth = depth;\n\t\t\tthis.texture.image.width = width;\n\t\t\tthis.texture.image.height = height;\n\t\t\tthis.texture.image.depth = depth;\n\t\t\tthis.dispose();\n\t\t}\n\n\t\tthis.viewport.set(0, 0, width, height);\n\t\tthis.scissor.set(0, 0, width, height);\n\t}\n\n\tclone() {\n\t\treturn new this.constructor().copy(this);\n\t}\n\n\tcopy(source) {\n\t\tthis.width = source.width;\n\t\tthis.height = source.height;\n\t\tthis.depth = source.depth;\n\t\tthis.viewport.copy(source.viewport);\n\t\tthis.texture = source.texture.clone();\n\t\tthis.texture.isRenderTargetTexture = true; // ensure image object is not shared, see #20328\n\n\t\tconst image = Object.assign({}, source.texture.image);\n\t\tthis.texture.source = new Source(image);\n\t\tthis.depthBuffer = source.depthBuffer;\n\t\tthis.stencilBuffer = source.stencilBuffer;\n\t\tif (source.depthTexture !== null) this.depthTexture = source.depthTexture.clone();\n\t\tthis.samples = source.samples;\n\t\treturn this;\n\t}\n\n\tdispose() {\n\t\tthis.dispatchEvent({\n\t\t\ttype: 'dispose'\n\t\t});\n\t}\n\n}\n\nclass DataArrayTexture extends Texture {\n\tconstructor(data = null, width = 1, height = 1, depth = 1) {\n\t\tsuper(null);\n\t\tthis.isDataArrayTexture = true;\n\t\tthis.image = {\n\t\t\tdata,\n\t\t\twidth,\n\t\t\theight,\n\t\t\tdepth\n\t\t};\n\t\tthis.magFilter = NearestFilter;\n\t\tthis.minFilter = NearestFilter;\n\t\tthis.wrapR = ClampToEdgeWrapping;\n\t\tthis.generateMipmaps = false;\n\t\tthis.flipY = false;\n\t\tthis.unpackAlignment = 1;\n\t}\n\n}\n\nclass WebGLArrayRenderTarget extends WebGLRenderTarget {\n\tconstructor(width, height, depth) {\n\t\tsuper(width, height);\n\t\tthis.isWebGLArrayRenderTarget = true;\n\t\tthis.depth = depth;\n\t\tthis.texture = new DataArrayTexture(null, width, height, depth);\n\t\tthis.texture.isRenderTargetTexture = true;\n\t}\n\n}\n\nclass Data3DTexture extends Texture {\n\tconstructor(data = null, width = 1, height = 1, depth = 1) {\n\t\t// We're going to add .setXXX() methods for setting properties later.\n\t\t// Users can still set in DataTexture3D directly.\n\t\t//\n\t\t//\tconst texture = new THREE.DataTexture3D( data, width, height, depth );\n\t\t// \ttexture.anisotropy = 16;\n\t\t//\n\t\t// See #14839\n\t\tsuper(null);\n\t\tthis.isData3DTexture = true;\n\t\tthis.image = {\n\t\t\tdata,\n\t\t\twidth,\n\t\t\theight,\n\t\t\tdepth\n\t\t};\n\t\tthis.magFilter = NearestFilter;\n\t\tthis.minFilter = NearestFilter;\n\t\tthis.wrapR = ClampToEdgeWrapping;\n\t\tthis.generateMipmaps = false;\n\t\tthis.flipY = false;\n\t\tthis.unpackAlignment = 1;\n\t}\n\n}\n\nclass WebGL3DRenderTarget extends WebGLRenderTarget {\n\tconstructor(width, height, depth) {\n\t\tsuper(width, height);\n\t\tthis.isWebGL3DRenderTarget = true;\n\t\tthis.depth = depth;\n\t\tthis.texture = new Data3DTexture(null, width, height, depth);\n\t\tthis.texture.isRenderTargetTexture = true;\n\t}\n\n}\n\nclass WebGLMultipleRenderTargets extends WebGLRenderTarget {\n\tconstructor(width, height, count, options = {}) {\n\t\tsuper(width, height, options);\n\t\tthis.isWebGLMultipleRenderTargets = true;\n\t\tconst texture = this.texture;\n\t\tthis.texture = [];\n\n\t\tfor (let i = 0; i < count; i++) {\n\t\t\tthis.texture[i] = texture.clone();\n\t\t\tthis.texture[i].isRenderTargetTexture = true;\n\t\t}\n\t}\n\n\tsetSize(width, height, depth = 1) {\n\t\tif (this.width !== width || this.height !== height || this.depth !== depth) {\n\t\t\tthis.width = width;\n\t\t\tthis.height = height;\n\t\t\tthis.depth = depth;\n\n\t\t\tfor (let i = 0, il = this.texture.length; i < il; i++) {\n\t\t\t\tthis.texture[i].image.width = width;\n\t\t\t\tthis.texture[i].image.height = height;\n\t\t\t\tthis.texture[i].image.depth = depth;\n\t\t\t}\n\n\t\t\tthis.dispose();\n\t\t}\n\n\t\tthis.viewport.set(0, 0, width, height);\n\t\tthis.scissor.set(0, 0, width, height);\n\t\treturn this;\n\t}\n\n\tcopy(source) {\n\t\tthis.dispose();\n\t\tthis.width = source.width;\n\t\tthis.height = source.height;\n\t\tthis.depth = source.depth;\n\t\tthis.viewport.set(0, 0, this.width, this.height);\n\t\tthis.scissor.set(0, 0, this.width, this.height);\n\t\tthis.depthBuffer = source.depthBuffer;\n\t\tthis.stencilBuffer = source.stencilBuffer;\n\t\tif (source.depthTexture !== null) this.depthTexture = source.depthTexture.clone();\n\t\tthis.texture.length = 0;\n\n\t\tfor (let i = 0, il = source.texture.length; i < il; i++) {\n\t\t\tthis.texture[i] = source.texture[i].clone();\n\t\t\tthis.texture[i].isRenderTargetTexture = true;\n\t\t}\n\n\t\treturn this;\n\t}\n\n}\n\nclass Quaternion {\n\tconstructor(x = 0, y = 0, z = 0, w = 1) {\n\t\tthis.isQuaternion = true;\n\t\tthis._x = x;\n\t\tthis._y = y;\n\t\tthis._z = z;\n\t\tthis._w = w;\n\t}\n\n\tstatic slerpFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t) {\n\t\t// fuzz-free, array-based Quaternion SLERP operation\n\t\tlet x0 = src0[srcOffset0 + 0],\n\t\t\t\ty0 = src0[srcOffset0 + 1],\n\t\t\t\tz0 = src0[srcOffset0 + 2],\n\t\t\t\tw0 = src0[srcOffset0 + 3];\n\t\tconst x1 = src1[srcOffset1 + 0],\n\t\t\t\t\ty1 = src1[srcOffset1 + 1],\n\t\t\t\t\tz1 = src1[srcOffset1 + 2],\n\t\t\t\t\tw1 = src1[srcOffset1 + 3];\n\n\t\tif (t === 0) {\n\t\t\tdst[dstOffset + 0] = x0;\n\t\t\tdst[dstOffset + 1] = y0;\n\t\t\tdst[dstOffset + 2] = z0;\n\t\t\tdst[dstOffset + 3] = w0;\n\t\t\treturn;\n\t\t}\n\n\t\tif (t === 1) {\n\t\t\tdst[dstOffset + 0] = x1;\n\t\t\tdst[dstOffset + 1] = y1;\n\t\t\tdst[dstOffset + 2] = z1;\n\t\t\tdst[dstOffset + 3] = w1;\n\t\t\treturn;\n\t\t}\n\n\t\tif (w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1) {\n\t\t\tlet s = 1 - t;\n\t\t\tconst cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1,\n\t\t\t\t\t\tdir = cos >= 0 ? 1 : -1,\n\t\t\t\t\t\tsqrSin = 1 - cos * cos; // Skip the Slerp for tiny steps to avoid numeric problems:\n\n\t\t\tif (sqrSin > Number.EPSILON) {\n\t\t\t\tconst sin = Math.sqrt(sqrSin),\n\t\t\t\t\t\t\tlen = Math.atan2(sin, cos * dir);\n\t\t\t\ts = Math.sin(s * len) / sin;\n\t\t\t\tt = Math.sin(t * len) / sin;\n\t\t\t}\n\n\t\t\tconst tDir = t * dir;\n\t\t\tx0 = x0 * s + x1 * tDir;\n\t\t\ty0 = y0 * s + y1 * tDir;\n\t\t\tz0 = z0 * s + z1 * tDir;\n\t\t\tw0 = w0 * s + w1 * tDir; // Normalize in case we just did a lerp:\n\n\t\t\tif (s === 1 - t) {\n\t\t\t\tconst f = 1 / Math.sqrt(x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0);\n\t\t\t\tx0 *= f;\n\t\t\t\ty0 *= f;\n\t\t\t\tz0 *= f;\n\t\t\t\tw0 *= f;\n\t\t\t}\n\t\t}\n\n\t\tdst[dstOffset] = x0;\n\t\tdst[dstOffset + 1] = y0;\n\t\tdst[dstOffset + 2] = z0;\n\t\tdst[dstOffset + 3] = w0;\n\t}\n\n\tstatic multiplyQuaternionsFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1) {\n\t\tconst x0 = src0[srcOffset0];\n\t\tconst y0 = src0[srcOffset0 + 1];\n\t\tconst z0 = src0[srcOffset0 + 2];\n\t\tconst w0 = src0[srcOffset0 + 3];\n\t\tconst x1 = src1[srcOffset1];\n\t\tconst y1 = src1[srcOffset1 + 1];\n\t\tconst z1 = src1[srcOffset1 + 2];\n\t\tconst w1 = src1[srcOffset1 + 3];\n\t\tdst[dstOffset] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1;\n\t\tdst[dstOffset + 1] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1;\n\t\tdst[dstOffset + 2] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1;\n\t\tdst[dstOffset + 3] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1;\n\t\treturn dst;\n\t}\n\n\tget x() {\n\t\treturn this._x;\n\t}\n\n\tset x(value) {\n\t\tthis._x = value;\n\n\t\tthis._onChangeCallback();\n\t}\n\n\tget y() {\n\t\treturn this._y;\n\t}\n\n\tset y(value) {\n\t\tthis._y = value;\n\n\t\tthis._onChangeCallback();\n\t}\n\n\tget z() {\n\t\treturn this._z;\n\t}\n\n\tset z(value) {\n\t\tthis._z = value;\n\n\t\tthis._onChangeCallback();\n\t}\n\n\tget w() {\n\t\treturn this._w;\n\t}\n\n\tset w(value) {\n\t\tthis._w = value;\n\n\t\tthis._onChangeCallback();\n\t}\n\n\tset(x, y, z, w) {\n\t\tthis._x = x;\n\t\tthis._y = y;\n\t\tthis._z = z;\n\t\tthis._w = w;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\treturn new this.constructor(this._x, this._y, this._z, this._w);\n\t}\n\n\tcopy(quaternion) {\n\t\tthis._x = quaternion.x;\n\t\tthis._y = quaternion.y;\n\t\tthis._z = quaternion.z;\n\t\tthis._w = quaternion.w;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\t}\n\n\tsetFromEuler(euler, update) {\n\t\tconst x = euler._x,\n\t\t\t\t\ty = euler._y,\n\t\t\t\t\tz = euler._z,\n\t\t\t\t\torder = euler._order; // http://www.mathworks.com/matlabcentral/fileexchange/\n\t\t// \t20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/\n\t\t//\tcontent/SpinCalc.m\n\n\t\tconst cos = Math.cos;\n\t\tconst sin = Math.sin;\n\t\tconst c1 = cos(x / 2);\n\t\tconst c2 = cos(y / 2);\n\t\tconst c3 = cos(z / 2);\n\t\tconst s1 = sin(x / 2);\n\t\tconst s2 = sin(y / 2);\n\t\tconst s3 = sin(z / 2);\n\n\t\tswitch (order) {\n\t\t\tcase 'XYZ':\n\t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'YXZ':\n\t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZXY':\n\t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZYX':\n\t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'YZX':\n\t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'XZY':\n\t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tconsole.warn('THREE.Quaternion: .setFromEuler() encountered an unknown order: ' + order);\n\t\t}\n\n\t\tif (update !== false) this._onChangeCallback();\n\t\treturn this;\n\t}\n\n\tsetFromAxisAngle(axis, angle) {\n\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm\n\t\t// assumes axis is normalized\n\t\tconst halfAngle = angle / 2,\n\t\t\t\t\ts = Math.sin(halfAngle);\n\t\tthis._x = axis.x * s;\n\t\tthis._y = axis.y * s;\n\t\tthis._z = axis.z * s;\n\t\tthis._w = Math.cos(halfAngle);\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\t}\n\n\tsetFromRotationMatrix(m) {\n\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm\n\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\t\tconst te = m.elements,\n\t\t\t\t\tm11 = te[0],\n\t\t\t\t\tm12 = te[4],\n\t\t\t\t\tm13 = te[8],\n\t\t\t\t\tm21 = te[1],\n\t\t\t\t\tm22 = te[5],\n\t\t\t\t\tm23 = te[9],\n\t\t\t\t\tm31 = te[2],\n\t\t\t\t\tm32 = te[6],\n\t\t\t\t\tm33 = te[10],\n\t\t\t\t\ttrace = m11 + m22 + m33;\n\n\t\tif (trace > 0) {\n\t\t\tconst s = 0.5 / Math.sqrt(trace + 1.0);\n\t\t\tthis._w = 0.25 / s;\n\t\t\tthis._x = (m32 - m23) * s;\n\t\t\tthis._y = (m13 - m31) * s;\n\t\t\tthis._z = (m21 - m12) * s;\n\t\t} else if (m11 > m22 && m11 > m33) {\n\t\t\tconst s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);\n\t\t\tthis._w = (m32 - m23) / s;\n\t\t\tthis._x = 0.25 * s;\n\t\t\tthis._y = (m12 + m21) / s;\n\t\t\tthis._z = (m13 + m31) / s;\n\t\t} else if (m22 > m33) {\n\t\t\tconst s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);\n\t\t\tthis._w = (m13 - m31) / s;\n\t\t\tthis._x = (m12 + m21) / s;\n\t\t\tthis._y = 0.25 * s;\n\t\t\tthis._z = (m23 + m32) / s;\n\t\t} else {\n\t\t\tconst s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);\n\t\t\tthis._w = (m21 - m12) / s;\n\t\t\tthis._x = (m13 + m31) / s;\n\t\t\tthis._y = (m23 + m32) / s;\n\t\t\tthis._z = 0.25 * s;\n\t\t}\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\t}\n\n\tsetFromUnitVectors(vFrom, vTo) {\n\t\t// assumes direction vectors vFrom and vTo are normalized\n\t\tlet r = vFrom.dot(vTo) + 1;\n\n\t\tif (r < Number.EPSILON) {\n\t\t\t// vFrom and vTo point in opposite directions\n\t\t\tr = 0;\n\n\t\t\tif (Math.abs(vFrom.x) > Math.abs(vFrom.z)) {\n\t\t\t\tthis._x = -vFrom.y;\n\t\t\t\tthis._y = vFrom.x;\n\t\t\t\tthis._z = 0;\n\t\t\t\tthis._w = r;\n\t\t\t} else {\n\t\t\t\tthis._x = 0;\n\t\t\t\tthis._y = -vFrom.z;\n\t\t\t\tthis._z = vFrom.y;\n\t\t\t\tthis._w = r;\n\t\t\t}\n\t\t} else {\n\t\t\t// crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3\n\t\t\tthis._x = vFrom.y * vTo.z - vFrom.z * vTo.y;\n\t\t\tthis._y = vFrom.z * vTo.x - vFrom.x * vTo.z;\n\t\t\tthis._z = vFrom.x * vTo.y - vFrom.y * vTo.x;\n\t\t\tthis._w = r;\n\t\t}\n\n\t\treturn this.normalize();\n\t}\n\n\tangleTo(q) {\n\t\treturn 2 * Math.acos(Math.abs(clamp(this.dot(q), -1, 1)));\n\t}\n\n\trotateTowards(q, step) {\n\t\tconst angle = this.angleTo(q);\n\t\tif (angle === 0) return this;\n\t\tconst t = Math.min(1, step / angle);\n\t\tthis.slerp(q, t);\n\t\treturn this;\n\t}\n\n\tidentity() {\n\t\treturn this.set(0, 0, 0, 1);\n\t}\n\n\tinvert() {\n\t\t// quaternion is assumed to have unit length\n\t\treturn this.conjugate();\n\t}\n\n\tconjugate() {\n\t\tthis._x *= -1;\n\t\tthis._y *= -1;\n\t\tthis._z *= -1;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\t}\n\n\tdot(v) {\n\t\treturn this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;\n\t}\n\n\tlengthSq() {\n\t\treturn this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;\n\t}\n\n\tlength() {\n\t\treturn Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);\n\t}\n\n\tnormalize() {\n\t\tlet l = this.length();\n\n\t\tif (l === 0) {\n\t\t\tthis._x = 0;\n\t\t\tthis._y = 0;\n\t\t\tthis._z = 0;\n\t\t\tthis._w = 1;\n\t\t} else {\n\t\t\tl = 1 / l;\n\t\t\tthis._x = this._x * l;\n\t\t\tthis._y = this._y * l;\n\t\t\tthis._z = this._z * l;\n\t\t\tthis._w = this._w * l;\n\t\t}\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\t}\n\n\tmultiply(q) {\n\t\treturn this.multiplyQuaternions(this, q);\n\t}\n\n\tpremultiply(q) {\n\t\treturn this.multiplyQuaternions(q, this);\n\t}\n\n\tmultiplyQuaternions(a, b) {\n\t\t// from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm\n\t\tconst qax = a._x,\n\t\t\t\t\tqay = a._y,\n\t\t\t\t\tqaz = a._z,\n\t\t\t\t\tqaw = a._w;\n\t\tconst qbx = b._x,\n\t\t\t\t\tqby = b._y,\n\t\t\t\t\tqbz = b._z,\n\t\t\t\t\tqbw = b._w;\n\t\tthis._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;\n\t\tthis._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;\n\t\tthis._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;\n\t\tthis._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\t}\n\n\tslerp(qb, t) {\n\t\tif (t === 0) return this;\n\t\tif (t === 1) return this.copy(qb);\n\t\tconst x = this._x,\n\t\t\t\t\ty = this._y,\n\t\t\t\t\tz = this._z,\n\t\t\t\t\tw = this._w; // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/\n\n\t\tlet cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;\n\n\t\tif (cosHalfTheta < 0) {\n\t\t\tthis._w = -qb._w;\n\t\t\tthis._x = -qb._x;\n\t\t\tthis._y = -qb._y;\n\t\t\tthis._z = -qb._z;\n\t\t\tcosHalfTheta = -cosHalfTheta;\n\t\t} else {\n\t\t\tthis.copy(qb);\n\t\t}\n\n\t\tif (cosHalfTheta >= 1.0) {\n\t\t\tthis._w = w;\n\t\t\tthis._x = x;\n\t\t\tthis._y = y;\n\t\t\tthis._z = z;\n\t\t\treturn this;\n\t\t}\n\n\t\tconst sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta;\n\n\t\tif (sqrSinHalfTheta <= Number.EPSILON) {\n\t\t\tconst s = 1 - t;\n\t\t\tthis._w = s * w + t * this._w;\n\t\t\tthis._x = s * x + t * this._x;\n\t\t\tthis._y = s * y + t * this._y;\n\t\t\tthis._z = s * z + t * this._z;\n\t\t\tthis.normalize();\n\n\t\t\tthis._onChangeCallback();\n\n\t\t\treturn this;\n\t\t}\n\n\t\tconst sinHalfTheta = Math.sqrt(sqrSinHalfTheta);\n\t\tconst halfTheta = Math.atan2(sinHalfTheta, cosHalfTheta);\n\t\tconst ratioA = Math.sin((1 - t) * halfTheta) / sinHalfTheta,\n\t\t\t\t\tratioB = Math.sin(t * halfTheta) / sinHalfTheta;\n\t\tthis._w = w * ratioA + this._w * ratioB;\n\t\tthis._x = x * ratioA + this._x * ratioB;\n\t\tthis._y = y * ratioA + this._y * ratioB;\n\t\tthis._z = z * ratioA + this._z * ratioB;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\t}\n\n\tslerpQuaternions(qa, qb, t) {\n\t\treturn this.copy(qa).slerp(qb, t);\n\t}\n\n\trandom() {\n\t\t// Derived from http://planning.cs.uiuc.edu/node198.html\n\t\t// Note, this source uses w, x, y, z ordering,\n\t\t// so we swap the order below.\n\t\tconst u1 = Math.random();\n\t\tconst sqrt1u1 = Math.sqrt(1 - u1);\n\t\tconst sqrtu1 = Math.sqrt(u1);\n\t\tconst u2 = 2 * Math.PI * Math.random();\n\t\tconst u3 = 2 * Math.PI * Math.random();\n\t\treturn this.set(sqrt1u1 * Math.cos(u2), sqrtu1 * Math.sin(u3), sqrtu1 * Math.cos(u3), sqrt1u1 * Math.sin(u2));\n\t}\n\n\tequals(quaternion) {\n\t\treturn quaternion._x === this._x && quaternion._y === this._y && quaternion._z === this._z && quaternion._w === this._w;\n\t}\n\n\tfromArray(array, offset = 0) {\n\t\tthis._x = array[offset];\n\t\tthis._y = array[offset + 1];\n\t\tthis._z = array[offset + 2];\n\t\tthis._w = array[offset + 3];\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\t}\n\n\ttoArray(array = [], offset = 0) {\n\t\tarray[offset] = this._x;\n\t\tarray[offset + 1] = this._y;\n\t\tarray[offset + 2] = this._z;\n\t\tarray[offset + 3] = this._w;\n\t\treturn array;\n\t}\n\n\tfromBufferAttribute(attribute, index) {\n\t\tthis._x = attribute.getX(index);\n\t\tthis._y = attribute.getY(index);\n\t\tthis._z = attribute.getZ(index);\n\t\tthis._w = attribute.getW(index);\n\t\treturn this;\n\t}\n\n\t_onChange(callback) {\n\t\tthis._onChangeCallback = callback;\n\t\treturn this;\n\t}\n\n\t_onChangeCallback() {}\n\n\t*[Symbol.iterator]() {\n\t\tyield this._x;\n\t\tyield this._y;\n\t\tyield this._z;\n\t\tyield this._w;\n\t}\n\n}\n\nclass Vector3 {\n\tconstructor(x = 0, y = 0, z = 0) {\n\t\tVector3.prototype.isVector3 = true;\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.z = z;\n\t}\n\n\tset(x, y, z) {\n\t\tif (z === undefined) z = this.z; // sprite.scale.set(x,y)\n\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.z = z;\n\t\treturn this;\n\t}\n\n\tsetScalar(scalar) {\n\t\tthis.x = scalar;\n\t\tthis.y = scalar;\n\t\tthis.z = scalar;\n\t\treturn this;\n\t}\n\n\tsetX(x) {\n\t\tthis.x = x;\n\t\treturn this;\n\t}\n\n\tsetY(y) {\n\t\tthis.y = y;\n\t\treturn this;\n\t}\n\n\tsetZ(z) {\n\t\tthis.z = z;\n\t\treturn this;\n\t}\n\n\tsetComponent(index, value) {\n\t\tswitch (index) {\n\t\t\tcase 0:\n\t\t\t\tthis.x = value;\n\t\t\t\tbreak;\n\n\t\t\tcase 1:\n\t\t\t\tthis.y = value;\n\t\t\t\tbreak;\n\n\t\t\tcase 2:\n\t\t\t\tthis.z = value;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error('index is out of range: ' + index);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tgetComponent(index) {\n\t\tswitch (index) {\n\t\t\tcase 0:\n\t\t\t\treturn this.x;\n\n\t\t\tcase 1:\n\t\t\t\treturn this.y;\n\n\t\t\tcase 2:\n\t\t\t\treturn this.z;\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error('index is out of range: ' + index);\n\t\t}\n\t}\n\n\tclone() {\n\t\treturn new this.constructor(this.x, this.y, this.z);\n\t}\n\n\tcopy(v) {\n\t\tthis.x = v.x;\n\t\tthis.y = v.y;\n\t\tthis.z = v.z;\n\t\treturn this;\n\t}\n\n\tadd(v) {\n\t\tthis.x += v.x;\n\t\tthis.y += v.y;\n\t\tthis.z += v.z;\n\t\treturn this;\n\t}\n\n\taddScalar(s) {\n\t\tthis.x += s;\n\t\tthis.y += s;\n\t\tthis.z += s;\n\t\treturn this;\n\t}\n\n\taddVectors(a, b) {\n\t\tthis.x = a.x + b.x;\n\t\tthis.y = a.y + b.y;\n\t\tthis.z = a.z + b.z;\n\t\treturn this;\n\t}\n\n\taddScaledVector(v, s) {\n\t\tthis.x += v.x * s;\n\t\tthis.y += v.y * s;\n\t\tthis.z += v.z * s;\n\t\treturn this;\n\t}\n\n\tsub(v) {\n\t\tthis.x -= v.x;\n\t\tthis.y -= v.y;\n\t\tthis.z -= v.z;\n\t\treturn this;\n\t}\n\n\tsubScalar(s) {\n\t\tthis.x -= s;\n\t\tthis.y -= s;\n\t\tthis.z -= s;\n\t\treturn this;\n\t}\n\n\tsubVectors(a, b) {\n\t\tthis.x = a.x - b.x;\n\t\tthis.y = a.y - b.y;\n\t\tthis.z = a.z - b.z;\n\t\treturn this;\n\t}\n\n\tmultiply(v) {\n\t\tthis.x *= v.x;\n\t\tthis.y *= v.y;\n\t\tthis.z *= v.z;\n\t\treturn this;\n\t}\n\n\tmultiplyScalar(scalar) {\n\t\tthis.x *= scalar;\n\t\tthis.y *= scalar;\n\t\tthis.z *= scalar;\n\t\treturn this;\n\t}\n\n\tmultiplyVectors(a, b) {\n\t\tthis.x = a.x * b.x;\n\t\tthis.y = a.y * b.y;\n\t\tthis.z = a.z * b.z;\n\t\treturn this;\n\t}\n\n\tapplyEuler(euler) {\n\t\treturn this.applyQuaternion(_quaternion$4.setFromEuler(euler));\n\t}\n\n\tapplyAxisAngle(axis, angle) {\n\t\treturn this.applyQuaternion(_quaternion$4.setFromAxisAngle(axis, angle));\n\t}\n\n\tapplyMatrix3(m) {\n\t\tconst x = this.x,\n\t\t\t\t\ty = this.y,\n\t\t\t\t\tz = this.z;\n\t\tconst e = m.elements;\n\t\tthis.x = e[0] * x + e[3] * y + e[6] * z;\n\t\tthis.y = e[1] * x + e[4] * y + e[7] * z;\n\t\tthis.z = e[2] * x + e[5] * y + e[8] * z;\n\t\treturn this;\n\t}\n\n\tapplyNormalMatrix(m) {\n\t\treturn this.applyMatrix3(m).normalize();\n\t}\n\n\tapplyMatrix4(m) {\n\t\tconst x = this.x,\n\t\t\t\t\ty = this.y,\n\t\t\t\t\tz = this.z;\n\t\tconst e = m.elements;\n\t\tconst w = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]);\n\t\tthis.x = (e[0] * x + e[4] * y + e[8] * z + e[12]) * w;\n\t\tthis.y = (e[1] * x + e[5] * y + e[9] * z + e[13]) * w;\n\t\tthis.z = (e[2] * x + e[6] * y + e[10] * z + e[14]) * w;\n\t\treturn this;\n\t}\n\n\tapplyQuaternion(q) {\n\t\tconst x = this.x,\n\t\t\t\t\ty = this.y,\n\t\t\t\t\tz = this.z;\n\t\tconst qx = q.x,\n\t\t\t\t\tqy = q.y,\n\t\t\t\t\tqz = q.z,\n\t\t\t\t\tqw = q.w; // calculate quat * vector\n\n\t\tconst ix = qw * x + qy * z - qz * y;\n\t\tconst iy = qw * y + qz * x - qx * z;\n\t\tconst iz = qw * z + qx * y - qy * x;\n\t\tconst iw = -qx * x - qy * y - qz * z; // calculate result * inverse quat\n\n\t\tthis.x = ix * qw + iw * -qx + iy * -qz - iz * -qy;\n\t\tthis.y = iy * qw + iw * -qy + iz * -qx - ix * -qz;\n\t\tthis.z = iz * qw + iw * -qz + ix * -qy - iy * -qx;\n\t\treturn this;\n\t}\n\n\tproject(camera) {\n\t\treturn this.applyMatrix4(camera.matrixWorldInverse).applyMatrix4(camera.projectionMatrix);\n\t}\n\n\tunproject(camera) {\n\t\treturn this.applyMatrix4(camera.projectionMatrixInverse).applyMatrix4(camera.matrixWorld);\n\t}\n\n\ttransformDirection(m) {\n\t\t// input: THREE.Matrix4 affine matrix\n\t\t// vector interpreted as a direction\n\t\tconst x = this.x,\n\t\t\t\t\ty = this.y,\n\t\t\t\t\tz = this.z;\n\t\tconst e = m.elements;\n\t\tthis.x = e[0] * x + e[4] * y + e[8] * z;\n\t\tthis.y = e[1] * x + e[5] * y + e[9] * z;\n\t\tthis.z = e[2] * x + e[6] * y + e[10] * z;\n\t\treturn this.normalize();\n\t}\n\n\tdivide(v) {\n\t\tthis.x /= v.x;\n\t\tthis.y /= v.y;\n\t\tthis.z /= v.z;\n\t\treturn this;\n\t}\n\n\tdivideScalar(scalar) {\n\t\treturn this.multiplyScalar(1 / scalar);\n\t}\n\n\tmin(v) {\n\t\tthis.x = Math.min(this.x, v.x);\n\t\tthis.y = Math.min(this.y, v.y);\n\t\tthis.z = Math.min(this.z, v.z);\n\t\treturn this;\n\t}\n\n\tmax(v) {\n\t\tthis.x = Math.max(this.x, v.x);\n\t\tthis.y = Math.max(this.y, v.y);\n\t\tthis.z = Math.max(this.z, v.z);\n\t\treturn this;\n\t}\n\n\tclamp(min, max) {\n\t\t// assumes min < max, componentwise\n\t\tthis.x = Math.max(min.x, Math.min(max.x, this.x));\n\t\tthis.y = Math.max(min.y, Math.min(max.y, this.y));\n\t\tthis.z = Math.max(min.z, Math.min(max.z, this.z));\n\t\treturn this;\n\t}\n\n\tclampScalar(minVal, maxVal) {\n\t\tthis.x = Math.max(minVal, Math.min(maxVal, this.x));\n\t\tthis.y = Math.max(minVal, Math.min(maxVal, this.y));\n\t\tthis.z = Math.max(minVal, Math.min(maxVal, this.z));\n\t\treturn this;\n\t}\n\n\tclampLength(min, max) {\n\t\tconst length = this.length();\n\t\treturn this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));\n\t}\n\n\tfloor() {\n\t\tthis.x = Math.floor(this.x);\n\t\tthis.y = Math.floor(this.y);\n\t\tthis.z = Math.floor(this.z);\n\t\treturn this;\n\t}\n\n\tceil() {\n\t\tthis.x = Math.ceil(this.x);\n\t\tthis.y = Math.ceil(this.y);\n\t\tthis.z = Math.ceil(this.z);\n\t\treturn this;\n\t}\n\n\tround() {\n\t\tthis.x = Math.round(this.x);\n\t\tthis.y = Math.round(this.y);\n\t\tthis.z = Math.round(this.z);\n\t\treturn this;\n\t}\n\n\troundToZero() {\n\t\tthis.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x);\n\t\tthis.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y);\n\t\tthis.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z);\n\t\treturn this;\n\t}\n\n\tnegate() {\n\t\tthis.x = -this.x;\n\t\tthis.y = -this.y;\n\t\tthis.z = -this.z;\n\t\treturn this;\n\t}\n\n\tdot(v) {\n\t\treturn this.x * v.x + this.y * v.y + this.z * v.z;\n\t} // TODO lengthSquared?\n\n\n\tlengthSq() {\n\t\treturn this.x * this.x + this.y * this.y + this.z * this.z;\n\t}\n\n\tlength() {\n\t\treturn Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);\n\t}\n\n\tmanhattanLength() {\n\t\treturn Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);\n\t}\n\n\tnormalize() {\n\t\treturn this.divideScalar(this.length() || 1);\n\t}\n\n\tsetLength(length) {\n\t\treturn this.normalize().multiplyScalar(length);\n\t}\n\n\tlerp(v, alpha) {\n\t\tthis.x += (v.x - this.x) * alpha;\n\t\tthis.y += (v.y - this.y) * alpha;\n\t\tthis.z += (v.z - this.z) * alpha;\n\t\treturn this;\n\t}\n\n\tlerpVectors(v1, v2, alpha) {\n\t\tthis.x = v1.x + (v2.x - v1.x) * alpha;\n\t\tthis.y = v1.y + (v2.y - v1.y) * alpha;\n\t\tthis.z = v1.z + (v2.z - v1.z) * alpha;\n\t\treturn this;\n\t}\n\n\tcross(v) {\n\t\treturn this.crossVectors(this, v);\n\t}\n\n\tcrossVectors(a, b) {\n\t\tconst ax = a.x,\n\t\t\t\t\tay = a.y,\n\t\t\t\t\taz = a.z;\n\t\tconst bx = b.x,\n\t\t\t\t\tby = b.y,\n\t\t\t\t\tbz = b.z;\n\t\tthis.x = ay * bz - az * by;\n\t\tthis.y = az * bx - ax * bz;\n\t\tthis.z = ax * by - ay * bx;\n\t\treturn this;\n\t}\n\n\tprojectOnVector(v) {\n\t\tconst denominator = v.lengthSq();\n\t\tif (denominator === 0) return this.set(0, 0, 0);\n\t\tconst scalar = v.dot(this) / denominator;\n\t\treturn this.copy(v).multiplyScalar(scalar);\n\t}\n\n\tprojectOnPlane(planeNormal) {\n\t\t_vector$c.copy(this).projectOnVector(planeNormal);\n\n\t\treturn this.sub(_vector$c);\n\t}\n\n\treflect(normal) {\n\t\t// reflect incident vector off plane orthogonal to normal\n\t\t// normal is assumed to have unit length\n\t\treturn this.sub(_vector$c.copy(normal).multiplyScalar(2 * this.dot(normal)));\n\t}\n\n\tangleTo(v) {\n\t\tconst denominator = Math.sqrt(this.lengthSq() * v.lengthSq());\n\t\tif (denominator === 0) return Math.PI / 2;\n\t\tconst theta = this.dot(v) / denominator; // clamp, to handle numerical problems\n\n\t\treturn Math.acos(clamp(theta, -1, 1));\n\t}\n\n\tdistanceTo(v) {\n\t\treturn Math.sqrt(this.distanceToSquared(v));\n\t}\n\n\tdistanceToSquared(v) {\n\t\tconst dx = this.x - v.x,\n\t\t\t\t\tdy = this.y - v.y,\n\t\t\t\t\tdz = this.z - v.z;\n\t\treturn dx * dx + dy * dy + dz * dz;\n\t}\n\n\tmanhattanDistanceTo(v) {\n\t\treturn Math.abs(this.x - v.x) + Math.abs(this.y - v.y) + Math.abs(this.z - v.z);\n\t}\n\n\tsetFromSpherical(s) {\n\t\treturn this.setFromSphericalCoords(s.radius, s.phi, s.theta);\n\t}\n\n\tsetFromSphericalCoords(radius, phi, theta) {\n\t\tconst sinPhiRadius = Math.sin(phi) * radius;\n\t\tthis.x = sinPhiRadius * Math.sin(theta);\n\t\tthis.y = Math.cos(phi) * radius;\n\t\tthis.z = sinPhiRadius * Math.cos(theta);\n\t\treturn this;\n\t}\n\n\tsetFromCylindrical(c) {\n\t\treturn this.setFromCylindricalCoords(c.radius, c.theta, c.y);\n\t}\n\n\tsetFromCylindricalCoords(radius, theta, y) {\n\t\tthis.x = radius * Math.sin(theta);\n\t\tthis.y = y;\n\t\tthis.z = radius * Math.cos(theta);\n\t\treturn this;\n\t}\n\n\tsetFromMatrixPosition(m) {\n\t\tconst e = m.elements;\n\t\tthis.x = e[12];\n\t\tthis.y = e[13];\n\t\tthis.z = e[14];\n\t\treturn this;\n\t}\n\n\tsetFromMatrixScale(m) {\n\t\tconst sx = this.setFromMatrixColumn(m, 0).length();\n\t\tconst sy = this.setFromMatrixColumn(m, 1).length();\n\t\tconst sz = this.setFromMatrixColumn(m, 2).length();\n\t\tthis.x = sx;\n\t\tthis.y = sy;\n\t\tthis.z = sz;\n\t\treturn this;\n\t}\n\n\tsetFromMatrixColumn(m, index) {\n\t\treturn this.fromArray(m.elements, index * 4);\n\t}\n\n\tsetFromMatrix3Column(m, index) {\n\t\treturn this.fromArray(m.elements, index * 3);\n\t}\n\n\tsetFromEuler(e) {\n\t\tthis.x = e._x;\n\t\tthis.y = e._y;\n\t\tthis.z = e._z;\n\t\treturn this;\n\t}\n\n\tequals(v) {\n\t\treturn v.x === this.x && v.y === this.y && v.z === this.z;\n\t}\n\n\tfromArray(array, offset = 0) {\n\t\tthis.x = array[offset];\n\t\tthis.y = array[offset + 1];\n\t\tthis.z = array[offset + 2];\n\t\treturn this;\n\t}\n\n\ttoArray(array = [], offset = 0) {\n\t\tarray[offset] = this.x;\n\t\tarray[offset + 1] = this.y;\n\t\tarray[offset + 2] = this.z;\n\t\treturn array;\n\t}\n\n\tfromBufferAttribute(attribute, index) {\n\t\tthis.x = attribute.getX(index);\n\t\tthis.y = attribute.getY(index);\n\t\tthis.z = attribute.getZ(index);\n\t\treturn this;\n\t}\n\n\trandom() {\n\t\tthis.x = Math.random();\n\t\tthis.y = Math.random();\n\t\tthis.z = Math.random();\n\t\treturn this;\n\t}\n\n\trandomDirection() {\n\t\t// Derived from https://mathworld.wolfram.com/SpherePointPicking.html\n\t\tconst u = (Math.random() - 0.5) * 2;\n\t\tconst t = Math.random() * Math.PI * 2;\n\t\tconst f = Math.sqrt(1 - u ** 2);\n\t\tthis.x = f * Math.cos(t);\n\t\tthis.y = f * Math.sin(t);\n\t\tthis.z = u;\n\t\treturn this;\n\t}\n\n\t*[Symbol.iterator]() {\n\t\tyield this.x;\n\t\tyield this.y;\n\t\tyield this.z;\n\t}\n\n}\n\nconst _vector$c = /*@__PURE__*/new Vector3();\n\nconst _quaternion$4 = /*@__PURE__*/new Quaternion();\n\nclass Box3 {\n\tconstructor(min = new Vector3(+Infinity, +Infinity, +Infinity), max = new Vector3(-Infinity, -Infinity, -Infinity)) {\n\t\tthis.isBox3 = true;\n\t\tthis.min = min;\n\t\tthis.max = max;\n\t}\n\n\tset(min, max) {\n\t\tthis.min.copy(min);\n\t\tthis.max.copy(max);\n\t\treturn this;\n\t}\n\n\tsetFromArray(array) {\n\t\tlet minX = +Infinity;\n\t\tlet minY = +Infinity;\n\t\tlet minZ = +Infinity;\n\t\tlet maxX = -Infinity;\n\t\tlet maxY = -Infinity;\n\t\tlet maxZ = -Infinity;\n\n\t\tfor (let i = 0, l = array.length; i < l; i += 3) {\n\t\t\tconst x = array[i];\n\t\t\tconst y = array[i + 1];\n\t\t\tconst z = array[i + 2];\n\t\t\tif (x < minX) minX = x;\n\t\t\tif (y < minY) minY = y;\n\t\t\tif (z < minZ) minZ = z;\n\t\t\tif (x > maxX) maxX = x;\n\t\t\tif (y > maxY) maxY = y;\n\t\t\tif (z > maxZ) maxZ = z;\n\t\t}\n\n\t\tthis.min.set(minX, minY, minZ);\n\t\tthis.max.set(maxX, maxY, maxZ);\n\t\treturn this;\n\t}\n\n\tsetFromBufferAttribute(attribute) {\n\t\tlet minX = +Infinity;\n\t\tlet minY = +Infinity;\n\t\tlet minZ = +Infinity;\n\t\tlet maxX = -Infinity;\n\t\tlet maxY = -Infinity;\n\t\tlet maxZ = -Infinity;\n\n\t\tfor (let i = 0, l = attribute.count; i < l; i++) {\n\t\t\tconst x = attribute.getX(i);\n\t\t\tconst y = attribute.getY(i);\n\t\t\tconst z = attribute.getZ(i);\n\t\t\tif (x < minX) minX = x;\n\t\t\tif (y < minY) minY = y;\n\t\t\tif (z < minZ) minZ = z;\n\t\t\tif (x > maxX) maxX = x;\n\t\t\tif (y > maxY) maxY = y;\n\t\t\tif (z > maxZ) maxZ = z;\n\t\t}\n\n\t\tthis.min.set(minX, minY, minZ);\n\t\tthis.max.set(maxX, maxY, maxZ);\n\t\treturn this;\n\t}\n\n\tsetFromPoints(points) {\n\t\tthis.makeEmpty();\n\n\t\tfor (let i = 0, il = points.length; i < il; i++) {\n\t\t\tthis.expandByPoint(points[i]);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tsetFromCenterAndSize(center, size) {\n\t\tconst halfSize = _vector$b.copy(size).multiplyScalar(0.5);\n\n\t\tthis.min.copy(center).sub(halfSize);\n\t\tthis.max.copy(center).add(halfSize);\n\t\treturn this;\n\t}\n\n\tsetFromObject(object, precise = false) {\n\t\tthis.makeEmpty();\n\t\treturn this.expandByObject(object, precise);\n\t}\n\n\tclone() {\n\t\treturn new this.constructor().copy(this);\n\t}\n\n\tcopy(box) {\n\t\tthis.min.copy(box.min);\n\t\tthis.max.copy(box.max);\n\t\treturn this;\n\t}\n\n\tmakeEmpty() {\n\t\tthis.min.x = this.min.y = this.min.z = +Infinity;\n\t\tthis.max.x = this.max.y = this.max.z = -Infinity;\n\t\treturn this;\n\t}\n\n\tisEmpty() {\n\t\t// this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes\n\t\treturn this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z;\n\t}\n\n\tgetCenter(target) {\n\t\treturn this.isEmpty() ? target.set(0, 0, 0) : target.addVectors(this.min, this.max).multiplyScalar(0.5);\n\t}\n\n\tgetSize(target) {\n\t\treturn this.isEmpty() ? target.set(0, 0, 0) : target.subVectors(this.max, this.min);\n\t}\n\n\texpandByPoint(point) {\n\t\tthis.min.min(point);\n\t\tthis.max.max(point);\n\t\treturn this;\n\t}\n\n\texpandByVector(vector) {\n\t\tthis.min.sub(vector);\n\t\tthis.max.add(vector);\n\t\treturn this;\n\t}\n\n\texpandByScalar(scalar) {\n\t\tthis.min.addScalar(-scalar);\n\t\tthis.max.addScalar(scalar);\n\t\treturn this;\n\t}\n\n\texpandByObject(object, precise = false) {\n\t\t// Computes the world-axis-aligned bounding box of an object (including its children),\n\t\t// accounting for both the object's, and children's, world transforms\n\t\tobject.updateWorldMatrix(false, false);\n\t\tconst geometry = object.geometry;\n\n\t\tif (geometry !== undefined) {\n\t\t\tif (precise && geometry.attributes != undefined && geometry.attributes.position !== undefined) {\n\t\t\t\tconst position = geometry.attributes.position;\n\n\t\t\t\tfor (let i = 0, l = position.count; i < l; i++) {\n\t\t\t\t\t_vector$b.fromBufferAttribute(position, i).applyMatrix4(object.matrixWorld);\n\n\t\t\t\t\tthis.expandByPoint(_vector$b);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (geometry.boundingBox === null) {\n\t\t\t\t\tgeometry.computeBoundingBox();\n\t\t\t\t}\n\n\t\t\t\t_box$3.copy(geometry.boundingBox);\n\n\t\t\t\t_box$3.applyMatrix4(object.matrixWorld);\n\n\t\t\t\tthis.union(_box$3);\n\t\t\t}\n\t\t}\n\n\t\tconst children = object.children;\n\n\t\tfor (let i = 0, l = children.length; i < l; i++) {\n\t\t\tthis.expandByObject(children[i], precise);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tcontainsPoint(point) {\n\t\treturn point.x < this.min.x || point.x > this.max.x || point.y < this.min.y || point.y > this.max.y || point.z < this.min.z || point.z > this.max.z ? false : true;\n\t}\n\n\tcontainsBox(box) {\n\t\treturn this.min.x <= box.min.x && box.max.x <= this.max.x && this.min.y <= box.min.y && box.max.y <= this.max.y && this.min.z <= box.min.z && box.max.z <= this.max.z;\n\t}\n\n\tgetParameter(point, target) {\n\t\t// This can potentially have a divide by zero if the box\n\t\t// has a size dimension of 0.\n\t\treturn target.set((point.x - this.min.x) / (this.max.x - this.min.x), (point.y - this.min.y) / (this.max.y - this.min.y), (point.z - this.min.z) / (this.max.z - this.min.z));\n\t}\n\n\tintersectsBox(box) {\n\t\t// using 6 splitting planes to rule out intersections.\n\t\treturn box.max.x < this.min.x || box.min.x > this.max.x || box.max.y < this.min.y || box.min.y > this.max.y || box.max.z < this.min.z || box.min.z > this.max.z ? false : true;\n\t}\n\n\tintersectsSphere(sphere) {\n\t\t// Find the point on the AABB closest to the sphere center.\n\t\tthis.clampPoint(sphere.center, _vector$b); // If that point is inside the sphere, the AABB and sphere intersect.\n\n\t\treturn _vector$b.distanceToSquared(sphere.center) <= sphere.radius * sphere.radius;\n\t}\n\n\tintersectsPlane(plane) {\n\t\t// We compute the minimum and maximum dot product values. If those values\n\t\t// are on the same side (back or front) of the plane, then there is no intersection.\n\t\tlet min, max;\n\n\t\tif (plane.normal.x > 0) {\n\t\t\tmin = plane.normal.x * this.min.x;\n\t\t\tmax = plane.normal.x * this.max.x;\n\t\t} else {\n\t\t\tmin = plane.normal.x * this.max.x;\n\t\t\tmax = plane.normal.x * this.min.x;\n\t\t}\n\n\t\tif (plane.normal.y > 0) {\n\t\t\tmin += plane.normal.y * this.min.y;\n\t\t\tmax += plane.normal.y * this.max.y;\n\t\t} else {\n\t\t\tmin += plane.normal.y * this.max.y;\n\t\t\tmax += plane.normal.y * this.min.y;\n\t\t}\n\n\t\tif (plane.normal.z > 0) {\n\t\t\tmin += plane.normal.z * this.min.z;\n\t\t\tmax += plane.normal.z * this.max.z;\n\t\t} else {\n\t\t\tmin += plane.normal.z * this.max.z;\n\t\t\tmax += plane.normal.z * this.min.z;\n\t\t}\n\n\t\treturn min <= -plane.constant && max >= -plane.constant;\n\t}\n\n\tintersectsTriangle(triangle) {\n\t\tif (this.isEmpty()) {\n\t\t\treturn false;\n\t\t} // compute box center and extents\n\n\n\t\tthis.getCenter(_center);\n\n\t\t_extents.subVectors(this.max, _center); // translate triangle to aabb origin\n\n\n\t\t_v0$2.subVectors(triangle.a, _center);\n\n\t\t_v1$7.subVectors(triangle.b, _center);\n\n\t\t_v2$3.subVectors(triangle.c, _center); // compute edge vectors for triangle\n\n\n\t\t_f0.subVectors(_v1$7, _v0$2);\n\n\t\t_f1.subVectors(_v2$3, _v1$7);\n\n\t\t_f2.subVectors(_v0$2, _v2$3); // test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb\n\t\t// make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation\n\t\t// axis_ij = u_i x f_j (u0, u1, u2 = face normals of aabb = x,y,z axes vectors since aabb is axis aligned)\n\n\n\t\tlet axes = [0, -_f0.z, _f0.y, 0, -_f1.z, _f1.y, 0, -_f2.z, _f2.y, _f0.z, 0, -_f0.x, _f1.z, 0, -_f1.x, _f2.z, 0, -_f2.x, -_f0.y, _f0.x, 0, -_f1.y, _f1.x, 0, -_f2.y, _f2.x, 0];\n\n\t\tif (!satForAxes(axes, _v0$2, _v1$7, _v2$3, _extents)) {\n\t\t\treturn false;\n\t\t} // test 3 face normals from the aabb\n\n\n\t\taxes = [1, 0, 0, 0, 1, 0, 0, 0, 1];\n\n\t\tif (!satForAxes(axes, _v0$2, _v1$7, _v2$3, _extents)) {\n\t\t\treturn false;\n\t\t} // finally testing the face normal of the triangle\n\t\t// use already existing triangle edge vectors here\n\n\n\t\t_triangleNormal.crossVectors(_f0, _f1);\n\n\t\taxes = [_triangleNormal.x, _triangleNormal.y, _triangleNormal.z];\n\t\treturn satForAxes(axes, _v0$2, _v1$7, _v2$3, _extents);\n\t}\n\n\tclampPoint(point, target) {\n\t\treturn target.copy(point).clamp(this.min, this.max);\n\t}\n\n\tdistanceToPoint(point) {\n\t\tconst clampedPoint = _vector$b.copy(point).clamp(this.min, this.max);\n\n\t\treturn clampedPoint.sub(point).length();\n\t}\n\n\tgetBoundingSphere(target) {\n\t\tthis.getCenter(target.center);\n\t\ttarget.radius = this.getSize(_vector$b).length() * 0.5;\n\t\treturn target;\n\t}\n\n\tintersect(box) {\n\t\tthis.min.max(box.min);\n\t\tthis.max.min(box.max); // ensure that if there is no overlap, the result is fully empty, not slightly empty with non-inf/+inf values that will cause subsequence intersects to erroneously return valid values.\n\n\t\tif (this.isEmpty()) this.makeEmpty();\n\t\treturn this;\n\t}\n\n\tunion(box) {\n\t\tthis.min.min(box.min);\n\t\tthis.max.max(box.max);\n\t\treturn this;\n\t}\n\n\tapplyMatrix4(matrix) {\n\t\t// transform of empty box is an empty box.\n\t\tif (this.isEmpty()) return this; // NOTE: I am using a binary pattern to specify all 2^3 combinations below\n\n\t\t_points[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(matrix); // 000\n\n\n\t\t_points[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(matrix); // 001\n\n\n\t\t_points[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(matrix); // 010\n\n\n\t\t_points[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(matrix); // 011\n\n\n\t\t_points[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(matrix); // 100\n\n\n\t\t_points[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(matrix); // 101\n\n\n\t\t_points[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(matrix); // 110\n\n\n\t\t_points[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(matrix); // 111\n\n\n\t\tthis.setFromPoints(_points);\n\t\treturn this;\n\t}\n\n\ttranslate(offset) {\n\t\tthis.min.add(offset);\n\t\tthis.max.add(offset);\n\t\treturn this;\n\t}\n\n\tequals(box) {\n\t\treturn box.min.equals(this.min) && box.max.equals(this.max);\n\t}\n\n}\n\nconst _points = [/*@__PURE__*/new Vector3(), /*@__PURE__*/new Vector3(), /*@__PURE__*/new Vector3(), /*@__PURE__*/new Vector3(), /*@__PURE__*/new Vector3(), /*@__PURE__*/new Vector3(), /*@__PURE__*/new Vector3(), /*@__PURE__*/new Vector3()];\n\nconst _vector$b = /*@__PURE__*/new Vector3();\n\nconst _box$3 = /*@__PURE__*/new Box3(); // triangle centered vertices\n\n\nconst _v0$2 = /*@__PURE__*/new Vector3();\n\nconst _v1$7 = /*@__PURE__*/new Vector3();\n\nconst _v2$3 = /*@__PURE__*/new Vector3(); // triangle edge vectors\n\n\nconst _f0 = /*@__PURE__*/new Vector3();\n\nconst _f1 = /*@__PURE__*/new Vector3();\n\nconst _f2 = /*@__PURE__*/new Vector3();\n\nconst _center = /*@__PURE__*/new Vector3();\n\nconst _extents = /*@__PURE__*/new Vector3();\n\nconst _triangleNormal = /*@__PURE__*/new Vector3();\n\nconst _testAxis = /*@__PURE__*/new Vector3();\n\nfunction satForAxes(axes, v0, v1, v2, extents) {\n\tfor (let i = 0, j = axes.length - 3; i <= j; i += 3) {\n\t\t_testAxis.fromArray(axes, i); // project the aabb onto the separating axis\n\n\n\t\tconst r = extents.x * Math.abs(_testAxis.x) + extents.y * Math.abs(_testAxis.y) + extents.z * Math.abs(_testAxis.z); // project all 3 vertices of the triangle onto the separating axis\n\n\t\tconst p0 = v0.dot(_testAxis);\n\t\tconst p1 = v1.dot(_testAxis);\n\t\tconst p2 = v2.dot(_testAxis); // actual test, basically see if either of the most extreme of the triangle points intersects r\n\n\t\tif (Math.max(-Math.max(p0, p1, p2), Math.min(p0, p1, p2)) > r) {\n\t\t\t// points of the projected triangle are outside the projected half-length of the aabb\n\t\t\t// the axis is separating and we can exit\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\nconst _box$2 = /*@__PURE__*/new Box3();\n\nconst _v1$6 = /*@__PURE__*/new Vector3();\n\nconst _toFarthestPoint = /*@__PURE__*/new Vector3();\n\nconst _toPoint = /*@__PURE__*/new Vector3();\n\nclass Sphere {\n\tconstructor(center = new Vector3(), radius = -1) {\n\t\tthis.center = center;\n\t\tthis.radius = radius;\n\t}\n\n\tset(center, radius) {\n\t\tthis.center.copy(center);\n\t\tthis.radius = radius;\n\t\treturn this;\n\t}\n\n\tsetFromPoints(points, optionalCenter) {\n\t\tconst center = this.center;\n\n\t\tif (optionalCenter !== undefined) {\n\t\t\tcenter.copy(optionalCenter);\n\t\t} else {\n\t\t\t_box$2.setFromPoints(points).getCenter(center);\n\t\t}\n\n\t\tlet maxRadiusSq = 0;\n\n\t\tfor (let i = 0, il = points.length; i < il; i++) {\n\t\t\tmaxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(points[i]));\n\t\t}\n\n\t\tthis.radius = Math.sqrt(maxRadiusSq);\n\t\treturn this;\n\t}\n\n\tcopy(sphere) {\n\t\tthis.center.copy(sphere.center);\n\t\tthis.radius = sphere.radius;\n\t\treturn this;\n\t}\n\n\tisEmpty() {\n\t\treturn this.radius < 0;\n\t}\n\n\tmakeEmpty() {\n\t\tthis.center.set(0, 0, 0);\n\t\tthis.radius = -1;\n\t\treturn this;\n\t}\n\n\tcontainsPoint(point) {\n\t\treturn point.distanceToSquared(this.center) <= this.radius * this.radius;\n\t}\n\n\tdistanceToPoint(point) {\n\t\treturn point.distanceTo(this.center) - this.radius;\n\t}\n\n\tintersectsSphere(sphere) {\n\t\tconst radiusSum = this.radius + sphere.radius;\n\t\treturn sphere.center.distanceToSquared(this.center) <= radiusSum * radiusSum;\n\t}\n\n\tintersectsBox(box) {\n\t\treturn box.intersectsSphere(this);\n\t}\n\n\tintersectsPlane(plane) {\n\t\treturn Math.abs(plane.distanceToPoint(this.center)) <= this.radius;\n\t}\n\n\tclampPoint(point, target) {\n\t\tconst deltaLengthSq = this.center.distanceToSquared(point);\n\t\ttarget.copy(point);\n\n\t\tif (deltaLengthSq > this.radius * this.radius) {\n\t\t\ttarget.sub(this.center).normalize();\n\t\t\ttarget.multiplyScalar(this.radius).add(this.center);\n\t\t}\n\n\t\treturn target;\n\t}\n\n\tgetBoundingBox(target) {\n\t\tif (this.isEmpty()) {\n\t\t\t// Empty sphere produces empty bounding box\n\t\t\ttarget.makeEmpty();\n\t\t\treturn target;\n\t\t}\n\n\t\ttarget.set(this.center, this.center);\n\t\ttarget.expandByScalar(this.radius);\n\t\treturn target;\n\t}\n\n\tapplyMatrix4(matrix) {\n\t\tthis.center.applyMatrix4(matrix);\n\t\tthis.radius = this.radius * matrix.getMaxScaleOnAxis();\n\t\treturn this;\n\t}\n\n\ttranslate(offset) {\n\t\tthis.center.add(offset);\n\t\treturn this;\n\t}\n\n\texpandByPoint(point) {\n\t\tif (this.isEmpty()) {\n\t\t\tthis.center.copy(point);\n\t\t\tthis.radius = 0;\n\t\t\treturn this;\n\t\t} // from https://github.com/juj/MathGeoLib/blob/2940b99b99cfe575dd45103ef20f4019dee15b54/src/Geometry/Sphere.cpp#L649-L671\n\n\n\t\t_toPoint.subVectors(point, this.center);\n\n\t\tconst lengthSq = _toPoint.lengthSq();\n\n\t\tif (lengthSq > this.radius * this.radius) {\n\t\t\tconst length = Math.sqrt(lengthSq);\n\t\t\tconst missingRadiusHalf = (length - this.radius) * 0.5; // Nudge this sphere towards the target point. Add half the missing distance to radius,\n\t\t\t// and the other half to position. This gives a tighter enclosure, instead of if\n\t\t\t// the whole missing distance were just added to radius.\n\n\t\t\tthis.center.add(_toPoint.multiplyScalar(missingRadiusHalf / length));\n\t\t\tthis.radius += missingRadiusHalf;\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tunion(sphere) {\n\t\t// handle empty sphere cases\n\t\tif (sphere.isEmpty()) {\n\t\t\treturn this;\n\t\t} else if (this.isEmpty()) {\n\t\t\tthis.copy(sphere);\n\t\t\treturn this;\n\t\t} // from https://github.com/juj/MathGeoLib/blob/2940b99b99cfe575dd45103ef20f4019dee15b54/src/Geometry/Sphere.cpp#L759-L769\n\t\t// To enclose another sphere into this sphere, we only need to enclose two points:\n\t\t// 1) Enclose the farthest point on the other sphere into this sphere.\n\t\t// 2) Enclose the opposite point of the farthest point into this sphere.\n\n\n\t\tif (this.center.equals(sphere.center) === true) {\n\t\t\t_toFarthestPoint.set(0, 0, 1).multiplyScalar(sphere.radius);\n\t\t} else {\n\t\t\t_toFarthestPoint.subVectors(sphere.center, this.center).normalize().multiplyScalar(sphere.radius);\n\t\t}\n\n\t\tthis.expandByPoint(_v1$6.copy(sphere.center).add(_toFarthestPoint));\n\t\tthis.expandByPoint(_v1$6.copy(sphere.center).sub(_toFarthestPoint));\n\t\treturn this;\n\t}\n\n\tequals(sphere) {\n\t\treturn sphere.center.equals(this.center) && sphere.radius === this.radius;\n\t}\n\n\tclone() {\n\t\treturn new this.constructor().copy(this);\n\t}\n\n}\n\nconst _vector$a = /*@__PURE__*/new Vector3();\n\nconst _segCenter = /*@__PURE__*/new Vector3();\n\nconst _segDir = /*@__PURE__*/new Vector3();\n\nconst _diff = /*@__PURE__*/new Vector3();\n\nconst _edge1 = /*@__PURE__*/new Vector3();\n\nconst _edge2 = /*@__PURE__*/new Vector3();\n\nconst _normal$1 = /*@__PURE__*/new Vector3();\n\nclass Ray {\n\tconstructor(origin = new Vector3(), direction = new Vector3(0, 0, -1)) {\n\t\tthis.origin = origin;\n\t\tthis.direction = direction;\n\t}\n\n\tset(origin, direction) {\n\t\tthis.origin.copy(origin);\n\t\tthis.direction.copy(direction);\n\t\treturn this;\n\t}\n\n\tcopy(ray) {\n\t\tthis.origin.copy(ray.origin);\n\t\tthis.direction.copy(ray.direction);\n\t\treturn this;\n\t}\n\n\tat(t, target) {\n\t\treturn target.copy(this.direction).multiplyScalar(t).add(this.origin);\n\t}\n\n\tlookAt(v) {\n\t\tthis.direction.copy(v).sub(this.origin).normalize();\n\t\treturn this;\n\t}\n\n\trecast(t) {\n\t\tthis.origin.copy(this.at(t, _vector$a));\n\t\treturn this;\n\t}\n\n\tclosestPointToPoint(point, target) {\n\t\ttarget.subVectors(point, this.origin);\n\t\tconst directionDistance = target.dot(this.direction);\n\n\t\tif (directionDistance < 0) {\n\t\t\treturn target.copy(this.origin);\n\t\t}\n\n\t\treturn target.copy(this.direction).multiplyScalar(directionDistance).add(this.origin);\n\t}\n\n\tdistanceToPoint(point) {\n\t\treturn Math.sqrt(this.distanceSqToPoint(point));\n\t}\n\n\tdistanceSqToPoint(point) {\n\t\tconst directionDistance = _vector$a.subVectors(point, this.origin).dot(this.direction); // point behind the ray\n\n\n\t\tif (directionDistance < 0) {\n\t\t\treturn this.origin.distanceToSquared(point);\n\t\t}\n\n\t\t_vector$a.copy(this.direction).multiplyScalar(directionDistance).add(this.origin);\n\n\t\treturn _vector$a.distanceToSquared(point);\n\t}\n\n\tdistanceSqToSegment(v0, v1, optionalPointOnRay, optionalPointOnSegment) {\n\t\t// from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteDistRaySegment.h\n\t\t// It returns the min distance between the ray and the segment\n\t\t// defined by v0 and v1\n\t\t// It can also set two optional targets :\n\t\t// - The closest point on the ray\n\t\t// - The closest point on the segment\n\t\t_segCenter.copy(v0).add(v1).multiplyScalar(0.5);\n\n\t\t_segDir.copy(v1).sub(v0).normalize();\n\n\t\t_diff.copy(this.origin).sub(_segCenter);\n\n\t\tconst segExtent = v0.distanceTo(v1) * 0.5;\n\t\tconst a01 = -this.direction.dot(_segDir);\n\n\t\tconst b0 = _diff.dot(this.direction);\n\n\t\tconst b1 = -_diff.dot(_segDir);\n\n\t\tconst c = _diff.lengthSq();\n\n\t\tconst det = Math.abs(1 - a01 * a01);\n\t\tlet s0, s1, sqrDist, extDet;\n\n\t\tif (det > 0) {\n\t\t\t// The ray and segment are not parallel.\n\t\t\ts0 = a01 * b1 - b0;\n\t\t\ts1 = a01 * b0 - b1;\n\t\t\textDet = segExtent * det;\n\n\t\t\tif (s0 >= 0) {\n\t\t\t\tif (s1 >= -extDet) {\n\t\t\t\t\tif (s1 <= extDet) {\n\t\t\t\t\t\t// region 0\n\t\t\t\t\t\t// Minimum at interior points of ray and segment.\n\t\t\t\t\t\tconst invDet = 1 / det;\n\t\t\t\t\t\ts0 *= invDet;\n\t\t\t\t\t\ts1 *= invDet;\n\t\t\t\t\t\tsqrDist = s0 * (s0 + a01 * s1 + 2 * b0) + s1 * (a01 * s0 + s1 + 2 * b1) + c;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// region 1\n\t\t\t\t\t\ts1 = segExtent;\n\t\t\t\t\t\ts0 = Math.max(0, -(a01 * s1 + b0));\n\t\t\t\t\t\tsqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// region 5\n\t\t\t\t\ts1 = -segExtent;\n\t\t\t\t\ts0 = Math.max(0, -(a01 * s1 + b0));\n\t\t\t\t\tsqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (s1 <= -extDet) {\n\t\t\t\t\t// region 4\n\t\t\t\t\ts0 = Math.max(0, -(-a01 * segExtent + b0));\n\t\t\t\t\ts1 = s0 > 0 ? -segExtent : Math.min(Math.max(-segExtent, -b1), segExtent);\n\t\t\t\t\tsqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;\n\t\t\t\t} else if (s1 <= extDet) {\n\t\t\t\t\t// region 3\n\t\t\t\t\ts0 = 0;\n\t\t\t\t\ts1 = Math.min(Math.max(-segExtent, -b1), segExtent);\n\t\t\t\t\tsqrDist = s1 * (s1 + 2 * b1) + c;\n\t\t\t\t} else {\n\t\t\t\t\t// region 2\n\t\t\t\t\ts0 = Math.max(0, -(a01 * segExtent + b0));\n\t\t\t\t\ts1 = s0 > 0 ? segExtent : Math.min(Math.max(-segExtent, -b1), segExtent);\n\t\t\t\t\tsqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Ray and segment are parallel.\n\t\t\ts1 = a01 > 0 ? -segExtent : segExtent;\n\t\t\ts0 = Math.max(0, -(a01 * s1 + b0));\n\t\t\tsqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;\n\t\t}\n\n\t\tif (optionalPointOnRay) {\n\t\t\toptionalPointOnRay.copy(this.direction).multiplyScalar(s0).add(this.origin);\n\t\t}\n\n\t\tif (optionalPointOnSegment) {\n\t\t\toptionalPointOnSegment.copy(_segDir).multiplyScalar(s1).add(_segCenter);\n\t\t}\n\n\t\treturn sqrDist;\n\t}\n\n\tintersectSphere(sphere, target) {\n\t\t_vector$a.subVectors(sphere.center, this.origin);\n\n\t\tconst tca = _vector$a.dot(this.direction);\n\n\t\tconst d2 = _vector$a.dot(_vector$a) - tca * tca;\n\t\tconst radius2 = sphere.radius * sphere.radius;\n\t\tif (d2 > radius2) return null;\n\t\tconst thc = Math.sqrt(radius2 - d2); // t0 = first intersect point - entrance on front of sphere\n\n\t\tconst t0 = tca - thc; // t1 = second intersect point - exit point on back of sphere\n\n\t\tconst t1 = tca + thc; // test to see if both t0 and t1 are behind the ray - if so, return null\n\n\t\tif (t0 < 0 && t1 < 0) return null; // test to see if t0 is behind the ray:\n\t\t// if it is, the ray is inside the sphere, so return the second exit point scaled by t1,\n\t\t// in order to always return an intersect point that is in front of the ray.\n\n\t\tif (t0 < 0) return this.at(t1, target); // else t0 is in front of the ray, so return the first collision point scaled by t0\n\n\t\treturn this.at(t0, target);\n\t}\n\n\tintersectsSphere(sphere) {\n\t\treturn this.distanceSqToPoint(sphere.center) <= sphere.radius * sphere.radius;\n\t}\n\n\tdistanceToPlane(plane) {\n\t\tconst denominator = plane.normal.dot(this.direction);\n\n\t\tif (denominator === 0) {\n\t\t\t// line is coplanar, return origin\n\t\t\tif (plane.distanceToPoint(this.origin) === 0) {\n\t\t\t\treturn 0;\n\t\t\t} // Null is preferable to undefined since undefined means.... it is undefined\n\n\n\t\t\treturn null;\n\t\t}\n\n\t\tconst t = -(this.origin.dot(plane.normal) + plane.constant) / denominator; // Return if the ray never intersects the plane\n\n\t\treturn t >= 0 ? t : null;\n\t}\n\n\tintersectPlane(plane, target) {\n\t\tconst t = this.distanceToPlane(plane);\n\n\t\tif (t === null) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn this.at(t, target);\n\t}\n\n\tintersectsPlane(plane) {\n\t\t// check if the ray lies on the plane first\n\t\tconst distToPoint = plane.distanceToPoint(this.origin);\n\n\t\tif (distToPoint === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst denominator = plane.normal.dot(this.direction);\n\n\t\tif (denominator * distToPoint < 0) {\n\t\t\treturn true;\n\t\t} // ray origin is behind the plane (and is pointing behind it)\n\n\n\t\treturn false;\n\t}\n\n\tintersectBox(box, target) {\n\t\tlet tmin, tmax, tymin, tymax, tzmin, tzmax;\n\t\tconst invdirx = 1 / this.direction.x,\n\t\t\t\t\tinvdiry = 1 / this.direction.y,\n\t\t\t\t\tinvdirz = 1 / this.direction.z;\n\t\tconst origin = this.origin;\n\n\t\tif (invdirx >= 0) {\n\t\t\ttmin = (box.min.x - origin.x) * invdirx;\n\t\t\ttmax = (box.max.x - origin.x) * invdirx;\n\t\t} else {\n\t\t\ttmin = (box.max.x - origin.x) * invdirx;\n\t\t\ttmax = (box.min.x - origin.x) * invdirx;\n\t\t}\n\n\t\tif (invdiry >= 0) {\n\t\t\ttymin = (box.min.y - origin.y) * invdiry;\n\t\t\ttymax = (box.max.y - origin.y) * invdiry;\n\t\t} else {\n\t\t\ttymin = (box.max.y - origin.y) * invdiry;\n\t\t\ttymax = (box.min.y - origin.y) * invdiry;\n\t\t}\n\n\t\tif (tmin > tymax || tymin > tmax) return null; // These lines also handle the case where tmin or tmax is NaN\n\t\t// (result of 0 * Infinity). x !== x returns true if x is NaN\n\n\t\tif (tymin > tmin || tmin !== tmin) tmin = tymin;\n\t\tif (tymax < tmax || tmax !== tmax) tmax = tymax;\n\n\t\tif (invdirz >= 0) {\n\t\t\ttzmin = (box.min.z - origin.z) * invdirz;\n\t\t\ttzmax = (box.max.z - origin.z) * invdirz;\n\t\t} else {\n\t\t\ttzmin = (box.max.z - origin.z) * invdirz;\n\t\t\ttzmax = (box.min.z - origin.z) * invdirz;\n\t\t}\n\n\t\tif (tmin > tzmax || tzmin > tmax) return null;\n\t\tif (tzmin > tmin || tmin !== tmin) tmin = tzmin;\n\t\tif (tzmax < tmax || tmax !== tmax) tmax = tzmax; //return point closest to the ray (positive side)\n\n\t\tif (tmax < 0) return null;\n\t\treturn this.at(tmin >= 0 ? tmin : tmax, target);\n\t}\n\n\tintersectsBox(box) {\n\t\treturn this.intersectBox(box, _vector$a) !== null;\n\t}\n\n\tintersectTriangle(a, b, c, backfaceCulling, target) {\n\t\t// Compute the offset origin, edges, and normal.\n\t\t// from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h\n\t\t_edge1.subVectors(b, a);\n\n\t\t_edge2.subVectors(c, a);\n\n\t\t_normal$1.crossVectors(_edge1, _edge2); // Solve Q + t*D = b1*E1 + b2*E2 (Q = kDiff, D = ray direction,\n\t\t// E1 = kEdge1, E2 = kEdge2, N = Cross(E1,E2)) by\n\t\t//\t |Dot(D,N)|*b1 = sign(Dot(D,N))*Dot(D,Cross(Q,E2))\n\t\t//\t |Dot(D,N)|*b2 = sign(Dot(D,N))*Dot(D,Cross(E1,Q))\n\t\t//\t |Dot(D,N)|*t = -sign(Dot(D,N))*Dot(Q,N)\n\n\n\t\tlet DdN = this.direction.dot(_normal$1);\n\t\tlet sign;\n\n\t\tif (DdN > 0) {\n\t\t\tif (backfaceCulling) return null;\n\t\t\tsign = 1;\n\t\t} else if (DdN < 0) {\n\t\t\tsign = -1;\n\t\t\tDdN = -DdN;\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\n\t\t_diff.subVectors(this.origin, a);\n\n\t\tconst DdQxE2 = sign * this.direction.dot(_edge2.crossVectors(_diff, _edge2)); // b1 < 0, no intersection\n\n\t\tif (DdQxE2 < 0) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst DdE1xQ = sign * this.direction.dot(_edge1.cross(_diff)); // b2 < 0, no intersection\n\n\t\tif (DdE1xQ < 0) {\n\t\t\treturn null;\n\t\t} // b1+b2 > 1, no intersection\n\n\n\t\tif (DdQxE2 + DdE1xQ > DdN) {\n\t\t\treturn null;\n\t\t} // Line intersects triangle, check if ray does.\n\n\n\t\tconst QdN = -sign * _diff.dot(_normal$1); // t < 0, no intersection\n\n\n\t\tif (QdN < 0) {\n\t\t\treturn null;\n\t\t} // Ray intersects triangle.\n\n\n\t\treturn this.at(QdN / DdN, target);\n\t}\n\n\tapplyMatrix4(matrix4) {\n\t\tthis.origin.applyMatrix4(matrix4);\n\t\tthis.direction.transformDirection(matrix4);\n\t\treturn this;\n\t}\n\n\tequals(ray) {\n\t\treturn ray.origin.equals(this.origin) && ray.direction.equals(this.direction);\n\t}\n\n\tclone() {\n\t\treturn new this.constructor().copy(this);\n\t}\n\n}\n\nclass Matrix4 {\n\tconstructor() {\n\t\tMatrix4.prototype.isMatrix4 = true;\n\t\tthis.elements = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n\t}\n\n\tset(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {\n\t\tconst te = this.elements;\n\t\tte[0] = n11;\n\t\tte[4] = n12;\n\t\tte[8] = n13;\n\t\tte[12] = n14;\n\t\tte[1] = n21;\n\t\tte[5] = n22;\n\t\tte[9] = n23;\n\t\tte[13] = n24;\n\t\tte[2] = n31;\n\t\tte[6] = n32;\n\t\tte[10] = n33;\n\t\tte[14] = n34;\n\t\tte[3] = n41;\n\t\tte[7] = n42;\n\t\tte[11] = n43;\n\t\tte[15] = n44;\n\t\treturn this;\n\t}\n\n\tidentity() {\n\t\tthis.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\treturn new Matrix4().fromArray(this.elements);\n\t}\n\n\tcopy(m) {\n\t\tconst te = this.elements;\n\t\tconst me = m.elements;\n\t\tte[0] = me[0];\n\t\tte[1] = me[1];\n\t\tte[2] = me[2];\n\t\tte[3] = me[3];\n\t\tte[4] = me[4];\n\t\tte[5] = me[5];\n\t\tte[6] = me[6];\n\t\tte[7] = me[7];\n\t\tte[8] = me[8];\n\t\tte[9] = me[9];\n\t\tte[10] = me[10];\n\t\tte[11] = me[11];\n\t\tte[12] = me[12];\n\t\tte[13] = me[13];\n\t\tte[14] = me[14];\n\t\tte[15] = me[15];\n\t\treturn this;\n\t}\n\n\tcopyPosition(m) {\n\t\tconst te = this.elements,\n\t\t\t\t\tme = m.elements;\n\t\tte[12] = me[12];\n\t\tte[13] = me[13];\n\t\tte[14] = me[14];\n\t\treturn this;\n\t}\n\n\tsetFromMatrix3(m) {\n\t\tconst me = m.elements;\n\t\tthis.set(me[0], me[3], me[6], 0, me[1], me[4], me[7], 0, me[2], me[5], me[8], 0, 0, 0, 0, 1);\n\t\treturn this;\n\t}\n\n\textractBasis(xAxis, yAxis, zAxis) {\n\t\txAxis.setFromMatrixColumn(this, 0);\n\t\tyAxis.setFromMatrixColumn(this, 1);\n\t\tzAxis.setFromMatrixColumn(this, 2);\n\t\treturn this;\n\t}\n\n\tmakeBasis(xAxis, yAxis, zAxis) {\n\t\tthis.set(xAxis.x, yAxis.x, zAxis.x, 0, xAxis.y, yAxis.y, zAxis.y, 0, xAxis.z, yAxis.z, zAxis.z, 0, 0, 0, 0, 1);\n\t\treturn this;\n\t}\n\n\textractRotation(m) {\n\t\t// this method does not support reflection matrices\n\t\tconst te = this.elements;\n\t\tconst me = m.elements;\n\n\t\tconst scaleX = 1 / _v1$5.setFromMatrixColumn(m, 0).length();\n\n\t\tconst scaleY = 1 / _v1$5.setFromMatrixColumn(m, 1).length();\n\n\t\tconst scaleZ = 1 / _v1$5.setFromMatrixColumn(m, 2).length();\n\n\t\tte[0] = me[0] * scaleX;\n\t\tte[1] = me[1] * scaleX;\n\t\tte[2] = me[2] * scaleX;\n\t\tte[3] = 0;\n\t\tte[4] = me[4] * scaleY;\n\t\tte[5] = me[5] * scaleY;\n\t\tte[6] = me[6] * scaleY;\n\t\tte[7] = 0;\n\t\tte[8] = me[8] * scaleZ;\n\t\tte[9] = me[9] * scaleZ;\n\t\tte[10] = me[10] * scaleZ;\n\t\tte[11] = 0;\n\t\tte[12] = 0;\n\t\tte[13] = 0;\n\t\tte[14] = 0;\n\t\tte[15] = 1;\n\t\treturn this;\n\t}\n\n\tmakeRotationFromEuler(euler) {\n\t\tconst te = this.elements;\n\t\tconst x = euler.x,\n\t\t\t\t\ty = euler.y,\n\t\t\t\t\tz = euler.z;\n\t\tconst a = Math.cos(x),\n\t\t\t\t\tb = Math.sin(x);\n\t\tconst c = Math.cos(y),\n\t\t\t\t\td = Math.sin(y);\n\t\tconst e = Math.cos(z),\n\t\t\t\t\tf = Math.sin(z);\n\n\t\tif (euler.order === 'XYZ') {\n\t\t\tconst ae = a * e,\n\t\t\t\t\t\taf = a * f,\n\t\t\t\t\t\tbe = b * e,\n\t\t\t\t\t\tbf = b * f;\n\t\t\tte[0] = c * e;\n\t\t\tte[4] = -c * f;\n\t\t\tte[8] = d;\n\t\t\tte[1] = af + be * d;\n\t\t\tte[5] = ae - bf * d;\n\t\t\tte[9] = -b * c;\n\t\t\tte[2] = bf - ae * d;\n\t\t\tte[6] = be + af * d;\n\t\t\tte[10] = a * c;\n\t\t} else if (euler.order === 'YXZ') {\n\t\t\tconst ce = c * e,\n\t\t\t\t\t\tcf = c * f,\n\t\t\t\t\t\tde = d * e,\n\t\t\t\t\t\tdf = d * f;\n\t\t\tte[0] = ce + df * b;\n\t\t\tte[4] = de * b - cf;\n\t\t\tte[8] = a * d;\n\t\t\tte[1] = a * f;\n\t\t\tte[5] = a * e;\n\t\t\tte[9] = -b;\n\t\t\tte[2] = cf * b - de;\n\t\t\tte[6] = df + ce * b;\n\t\t\tte[10] = a * c;\n\t\t} else if (euler.order === 'ZXY') {\n\t\t\tconst ce = c * e,\n\t\t\t\t\t\tcf = c * f,\n\t\t\t\t\t\tde = d * e,\n\t\t\t\t\t\tdf = d * f;\n\t\t\tte[0] = ce - df * b;\n\t\t\tte[4] = -a * f;\n\t\t\tte[8] = de + cf * b;\n\t\t\tte[1] = cf + de * b;\n\t\t\tte[5] = a * e;\n\t\t\tte[9] = df - ce * b;\n\t\t\tte[2] = -a * d;\n\t\t\tte[6] = b;\n\t\t\tte[10] = a * c;\n\t\t} else if (euler.order === 'ZYX') {\n\t\t\tconst ae = a * e,\n\t\t\t\t\t\taf = a * f,\n\t\t\t\t\t\tbe = b * e,\n\t\t\t\t\t\tbf = b * f;\n\t\t\tte[0] = c * e;\n\t\t\tte[4] = be * d - af;\n\t\t\tte[8] = ae * d + bf;\n\t\t\tte[1] = c * f;\n\t\t\tte[5] = bf * d + ae;\n\t\t\tte[9] = af * d - be;\n\t\t\tte[2] = -d;\n\t\t\tte[6] = b * c;\n\t\t\tte[10] = a * c;\n\t\t} else if (euler.order === 'YZX') {\n\t\t\tconst ac = a * c,\n\t\t\t\t\t\tad = a * d,\n\t\t\t\t\t\tbc = b * c,\n\t\t\t\t\t\tbd = b * d;\n\t\t\tte[0] = c * e;\n\t\t\tte[4] = bd - ac * f;\n\t\t\tte[8] = bc * f + ad;\n\t\t\tte[1] = f;\n\t\t\tte[5] = a * e;\n\t\t\tte[9] = -b * e;\n\t\t\tte[2] = -d * e;\n\t\t\tte[6] = ad * f + bc;\n\t\t\tte[10] = ac - bd * f;\n\t\t} else if (euler.order === 'XZY') {\n\t\t\tconst ac = a * c,\n\t\t\t\t\t\tad = a * d,\n\t\t\t\t\t\tbc = b * c,\n\t\t\t\t\t\tbd = b * d;\n\t\t\tte[0] = c * e;\n\t\t\tte[4] = -f;\n\t\t\tte[8] = d * e;\n\t\t\tte[1] = ac * f + bd;\n\t\t\tte[5] = a * e;\n\t\t\tte[9] = ad * f - bc;\n\t\t\tte[2] = bc * f - ad;\n\t\t\tte[6] = b * e;\n\t\t\tte[10] = bd * f + ac;\n\t\t} // bottom row\n\n\n\t\tte[3] = 0;\n\t\tte[7] = 0;\n\t\tte[11] = 0; // last column\n\n\t\tte[12] = 0;\n\t\tte[13] = 0;\n\t\tte[14] = 0;\n\t\tte[15] = 1;\n\t\treturn this;\n\t}\n\n\tmakeRotationFromQuaternion(q) {\n\t\treturn this.compose(_zero, q, _one);\n\t}\n\n\tlookAt(eye, target, up) {\n\t\tconst te = this.elements;\n\n\t\t_z.subVectors(eye, target);\n\n\t\tif (_z.lengthSq() === 0) {\n\t\t\t// eye and target are in the same position\n\t\t\t_z.z = 1;\n\t\t}\n\n\t\t_z.normalize();\n\n\t\t_x.crossVectors(up, _z);\n\n\t\tif (_x.lengthSq() === 0) {\n\t\t\t// up and z are parallel\n\t\t\tif (Math.abs(up.z) === 1) {\n\t\t\t\t_z.x += 0.0001;\n\t\t\t} else {\n\t\t\t\t_z.z += 0.0001;\n\t\t\t}\n\n\t\t\t_z.normalize();\n\n\t\t\t_x.crossVectors(up, _z);\n\t\t}\n\n\t\t_x.normalize();\n\n\t\t_y.crossVectors(_z, _x);\n\n\t\tte[0] = _x.x;\n\t\tte[4] = _y.x;\n\t\tte[8] = _z.x;\n\t\tte[1] = _x.y;\n\t\tte[5] = _y.y;\n\t\tte[9] = _z.y;\n\t\tte[2] = _x.z;\n\t\tte[6] = _y.z;\n\t\tte[10] = _z.z;\n\t\treturn this;\n\t}\n\n\tmultiply(m) {\n\t\treturn this.multiplyMatrices(this, m);\n\t}\n\n\tpremultiply(m) {\n\t\treturn this.multiplyMatrices(m, this);\n\t}\n\n\tmultiplyMatrices(a, b) {\n\t\tconst ae = a.elements;\n\t\tconst be = b.elements;\n\t\tconst te = this.elements;\n\t\tconst a11 = ae[0],\n\t\t\t\t\ta12 = ae[4],\n\t\t\t\t\ta13 = ae[8],\n\t\t\t\t\ta14 = ae[12];\n\t\tconst a21 = ae[1],\n\t\t\t\t\ta22 = ae[5],\n\t\t\t\t\ta23 = ae[9],\n\t\t\t\t\ta24 = ae[13];\n\t\tconst a31 = ae[2],\n\t\t\t\t\ta32 = ae[6],\n\t\t\t\t\ta33 = ae[10],\n\t\t\t\t\ta34 = ae[14];\n\t\tconst a41 = ae[3],\n\t\t\t\t\ta42 = ae[7],\n\t\t\t\t\ta43 = ae[11],\n\t\t\t\t\ta44 = ae[15];\n\t\tconst b11 = be[0],\n\t\t\t\t\tb12 = be[4],\n\t\t\t\t\tb13 = be[8],\n\t\t\t\t\tb14 = be[12];\n\t\tconst b21 = be[1],\n\t\t\t\t\tb22 = be[5],\n\t\t\t\t\tb23 = be[9],\n\t\t\t\t\tb24 = be[13];\n\t\tconst b31 = be[2],\n\t\t\t\t\tb32 = be[6],\n\t\t\t\t\tb33 = be[10],\n\t\t\t\t\tb34 = be[14];\n\t\tconst b41 = be[3],\n\t\t\t\t\tb42 = be[7],\n\t\t\t\t\tb43 = be[11],\n\t\t\t\t\tb44 = be[15];\n\t\tte[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;\n\t\tte[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;\n\t\tte[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;\n\t\tte[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;\n\t\tte[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;\n\t\tte[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;\n\t\tte[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;\n\t\tte[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;\n\t\tte[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;\n\t\tte[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;\n\t\tte[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;\n\t\tte[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;\n\t\tte[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;\n\t\tte[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;\n\t\tte[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;\n\t\tte[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;\n\t\treturn this;\n\t}\n\n\tmultiplyScalar(s) {\n\t\tconst te = this.elements;\n\t\tte[0] *= s;\n\t\tte[4] *= s;\n\t\tte[8] *= s;\n\t\tte[12] *= s;\n\t\tte[1] *= s;\n\t\tte[5] *= s;\n\t\tte[9] *= s;\n\t\tte[13] *= s;\n\t\tte[2] *= s;\n\t\tte[6] *= s;\n\t\tte[10] *= s;\n\t\tte[14] *= s;\n\t\tte[3] *= s;\n\t\tte[7] *= s;\n\t\tte[11] *= s;\n\t\tte[15] *= s;\n\t\treturn this;\n\t}\n\n\tdeterminant() {\n\t\tconst te = this.elements;\n\t\tconst n11 = te[0],\n\t\t\t\t\tn12 = te[4],\n\t\t\t\t\tn13 = te[8],\n\t\t\t\t\tn14 = te[12];\n\t\tconst n21 = te[1],\n\t\t\t\t\tn22 = te[5],\n\t\t\t\t\tn23 = te[9],\n\t\t\t\t\tn24 = te[13];\n\t\tconst n31 = te[2],\n\t\t\t\t\tn32 = te[6],\n\t\t\t\t\tn33 = te[10],\n\t\t\t\t\tn34 = te[14];\n\t\tconst n41 = te[3],\n\t\t\t\t\tn42 = te[7],\n\t\t\t\t\tn43 = te[11],\n\t\t\t\t\tn44 = te[15]; //TODO: make this more efficient\n\t\t//( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm )\n\n\t\treturn n41 * (+n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34) + n42 * (+n11 * n23 * n34 - n11 * n24 * n33 + n14 * n21 * n33 - n13 * n21 * n34 + n13 * n24 * n31 - n14 * n23 * n31) + n43 * (+n11 * n24 * n32 - n11 * n22 * n34 - n14 * n21 * n32 + n12 * n21 * n34 + n14 * n22 * n31 - n12 * n24 * n31) + n44 * (-n13 * n22 * n31 - n11 * n23 * n32 + n11 * n22 * n33 + n13 * n21 * n32 - n12 * n21 * n33 + n12 * n23 * n31);\n\t}\n\n\ttranspose() {\n\t\tconst te = this.elements;\n\t\tlet tmp;\n\t\ttmp = te[1];\n\t\tte[1] = te[4];\n\t\tte[4] = tmp;\n\t\ttmp = te[2];\n\t\tte[2] = te[8];\n\t\tte[8] = tmp;\n\t\ttmp = te[6];\n\t\tte[6] = te[9];\n\t\tte[9] = tmp;\n\t\ttmp = te[3];\n\t\tte[3] = te[12];\n\t\tte[12] = tmp;\n\t\ttmp = te[7];\n\t\tte[7] = te[13];\n\t\tte[13] = tmp;\n\t\ttmp = te[11];\n\t\tte[11] = te[14];\n\t\tte[14] = tmp;\n\t\treturn this;\n\t}\n\n\tsetPosition(x, y, z) {\n\t\tconst te = this.elements;\n\n\t\tif (x.isVector3) {\n\t\t\tte[12] = x.x;\n\t\t\tte[13] = x.y;\n\t\t\tte[14] = x.z;\n\t\t} else {\n\t\t\tte[12] = x;\n\t\t\tte[13] = y;\n\t\t\tte[14] = z;\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tinvert() {\n\t\t// based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm\n\t\tconst te = this.elements,\n\t\t\t\t\tn11 = te[0],\n\t\t\t\t\tn21 = te[1],\n\t\t\t\t\tn31 = te[2],\n\t\t\t\t\tn41 = te[3],\n\t\t\t\t\tn12 = te[4],\n\t\t\t\t\tn22 = te[5],\n\t\t\t\t\tn32 = te[6],\n\t\t\t\t\tn42 = te[7],\n\t\t\t\t\tn13 = te[8],\n\t\t\t\t\tn23 = te[9],\n\t\t\t\t\tn33 = te[10],\n\t\t\t\t\tn43 = te[11],\n\t\t\t\t\tn14 = te[12],\n\t\t\t\t\tn24 = te[13],\n\t\t\t\t\tn34 = te[14],\n\t\t\t\t\tn44 = te[15],\n\t\t\t\t\tt11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44,\n\t\t\t\t\tt12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44,\n\t\t\t\t\tt13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44,\n\t\t\t\t\tt14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;\n\t\tconst det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;\n\t\tif (det === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);\n\t\tconst detInv = 1 / det;\n\t\tte[0] = t11 * detInv;\n\t\tte[1] = (n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44) * detInv;\n\t\tte[2] = (n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44) * detInv;\n\t\tte[3] = (n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43) * detInv;\n\t\tte[4] = t12 * detInv;\n\t\tte[5] = (n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44) * detInv;\n\t\tte[6] = (n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44) * detInv;\n\t\tte[7] = (n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43) * detInv;\n\t\tte[8] = t13 * detInv;\n\t\tte[9] = (n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44) * detInv;\n\t\tte[10] = (n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44) * detInv;\n\t\tte[11] = (n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43) * detInv;\n\t\tte[12] = t14 * detInv;\n\t\tte[13] = (n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34) * detInv;\n\t\tte[14] = (n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34) * detInv;\n\t\tte[15] = (n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33) * detInv;\n\t\treturn this;\n\t}\n\n\tscale(v) {\n\t\tconst te = this.elements;\n\t\tconst x = v.x,\n\t\t\t\t\ty = v.y,\n\t\t\t\t\tz = v.z;\n\t\tte[0] *= x;\n\t\tte[4] *= y;\n\t\tte[8] *= z;\n\t\tte[1] *= x;\n\t\tte[5] *= y;\n\t\tte[9] *= z;\n\t\tte[2] *= x;\n\t\tte[6] *= y;\n\t\tte[10] *= z;\n\t\tte[3] *= x;\n\t\tte[7] *= y;\n\t\tte[11] *= z;\n\t\treturn this;\n\t}\n\n\tgetMaxScaleOnAxis() {\n\t\tconst te = this.elements;\n\t\tconst scaleXSq = te[0] * te[0] + te[1] * te[1] + te[2] * te[2];\n\t\tconst scaleYSq = te[4] * te[4] + te[5] * te[5] + te[6] * te[6];\n\t\tconst scaleZSq = te[8] * te[8] + te[9] * te[9] + te[10] * te[10];\n\t\treturn Math.sqrt(Math.max(scaleXSq, scaleYSq, scaleZSq));\n\t}\n\n\tmakeTranslation(x, y, z) {\n\t\tthis.set(1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, z, 0, 0, 0, 1);\n\t\treturn this;\n\t}\n\n\tmakeRotationX(theta) {\n\t\tconst c = Math.cos(theta),\n\t\t\t\t\ts = Math.sin(theta);\n\t\tthis.set(1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1);\n\t\treturn this;\n\t}\n\n\tmakeRotationY(theta) {\n\t\tconst c = Math.cos(theta),\n\t\t\t\t\ts = Math.sin(theta);\n\t\tthis.set(c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1);\n\t\treturn this;\n\t}\n\n\tmakeRotationZ(theta) {\n\t\tconst c = Math.cos(theta),\n\t\t\t\t\ts = Math.sin(theta);\n\t\tthis.set(c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);\n\t\treturn this;\n\t}\n\n\tmakeRotationAxis(axis, angle) {\n\t\t// Based on http://www.gamedev.net/reference/articles/article1199.asp\n\t\tconst c = Math.cos(angle);\n\t\tconst s = Math.sin(angle);\n\t\tconst t = 1 - c;\n\t\tconst x = axis.x,\n\t\t\t\t\ty = axis.y,\n\t\t\t\t\tz = axis.z;\n\t\tconst tx = t * x,\n\t\t\t\t\tty = t * y;\n\t\tthis.set(tx * x + c, tx * y - s * z, tx * z + s * y, 0, tx * y + s * z, ty * y + c, ty * z - s * x, 0, tx * z - s * y, ty * z + s * x, t * z * z + c, 0, 0, 0, 0, 1);\n\t\treturn this;\n\t}\n\n\tmakeScale(x, y, z) {\n\t\tthis.set(x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, 0, 0, 0, 1);\n\t\treturn this;\n\t}\n\n\tmakeShear(xy, xz, yx, yz, zx, zy) {\n\t\tthis.set(1, yx, zx, 0, xy, 1, zy, 0, xz, yz, 1, 0, 0, 0, 0, 1);\n\t\treturn this;\n\t}\n\n\tcompose(position, quaternion, scale) {\n\t\tconst te = this.elements;\n\t\tconst x = quaternion._x,\n\t\t\t\t\ty = quaternion._y,\n\t\t\t\t\tz = quaternion._z,\n\t\t\t\t\tw = quaternion._w;\n\t\tconst x2 = x + x,\n\t\t\t\t\ty2 = y + y,\n\t\t\t\t\tz2 = z + z;\n\t\tconst xx = x * x2,\n\t\t\t\t\txy = x * y2,\n\t\t\t\t\txz = x * z2;\n\t\tconst yy = y * y2,\n\t\t\t\t\tyz = y * z2,\n\t\t\t\t\tzz = z * z2;\n\t\tconst wx = w * x2,\n\t\t\t\t\twy = w * y2,\n\t\t\t\t\twz = w * z2;\n\t\tconst sx = scale.x,\n\t\t\t\t\tsy = scale.y,\n\t\t\t\t\tsz = scale.z;\n\t\tte[0] = (1 - (yy + zz)) * sx;\n\t\tte[1] = (xy + wz) * sx;\n\t\tte[2] = (xz - wy) * sx;\n\t\tte[3] = 0;\n\t\tte[4] = (xy - wz) * sy;\n\t\tte[5] = (1 - (xx + zz)) * sy;\n\t\tte[6] = (yz + wx) * sy;\n\t\tte[7] = 0;\n\t\tte[8] = (xz + wy) * sz;\n\t\tte[9] = (yz - wx) * sz;\n\t\tte[10] = (1 - (xx + yy)) * sz;\n\t\tte[11] = 0;\n\t\tte[12] = position.x;\n\t\tte[13] = position.y;\n\t\tte[14] = position.z;\n\t\tte[15] = 1;\n\t\treturn this;\n\t}\n\n\tdecompose(position, quaternion, scale) {\n\t\tconst te = this.elements;\n\n\t\tlet sx = _v1$5.set(te[0], te[1], te[2]).length();\n\n\t\tconst sy = _v1$5.set(te[4], te[5], te[6]).length();\n\n\t\tconst sz = _v1$5.set(te[8], te[9], te[10]).length(); // if determine is negative, we need to invert one scale\n\n\n\t\tconst det = this.determinant();\n\t\tif (det < 0) sx = -sx;\n\t\tposition.x = te[12];\n\t\tposition.y = te[13];\n\t\tposition.z = te[14]; // scale the rotation part\n\n\t\t_m1$2.copy(this);\n\n\t\tconst invSX = 1 / sx;\n\t\tconst invSY = 1 / sy;\n\t\tconst invSZ = 1 / sz;\n\t\t_m1$2.elements[0] *= invSX;\n\t\t_m1$2.elements[1] *= invSX;\n\t\t_m1$2.elements[2] *= invSX;\n\t\t_m1$2.elements[4] *= invSY;\n\t\t_m1$2.elements[5] *= invSY;\n\t\t_m1$2.elements[6] *= invSY;\n\t\t_m1$2.elements[8] *= invSZ;\n\t\t_m1$2.elements[9] *= invSZ;\n\t\t_m1$2.elements[10] *= invSZ;\n\t\tquaternion.setFromRotationMatrix(_m1$2);\n\t\tscale.x = sx;\n\t\tscale.y = sy;\n\t\tscale.z = sz;\n\t\treturn this;\n\t}\n\n\tmakePerspective(left, right, top, bottom, near, far) {\n\t\tconst te = this.elements;\n\t\tconst x = 2 * near / (right - left);\n\t\tconst y = 2 * near / (top - bottom);\n\t\tconst a = (right + left) / (right - left);\n\t\tconst b = (top + bottom) / (top - bottom);\n\t\tconst c = -(far + near) / (far - near);\n\t\tconst d = -2 * far * near / (far - near);\n\t\tte[0] = x;\n\t\tte[4] = 0;\n\t\tte[8] = a;\n\t\tte[12] = 0;\n\t\tte[1] = 0;\n\t\tte[5] = y;\n\t\tte[9] = b;\n\t\tte[13] = 0;\n\t\tte[2] = 0;\n\t\tte[6] = 0;\n\t\tte[10] = c;\n\t\tte[14] = d;\n\t\tte[3] = 0;\n\t\tte[7] = 0;\n\t\tte[11] = -1;\n\t\tte[15] = 0;\n\t\treturn this;\n\t}\n\n\tmakeOrthographic(left, right, top, bottom, near, far) {\n\t\tconst te = this.elements;\n\t\tconst w = 1.0 / (right - left);\n\t\tconst h = 1.0 / (top - bottom);\n\t\tconst p = 1.0 / (far - near);\n\t\tconst x = (right + left) * w;\n\t\tconst y = (top + bottom) * h;\n\t\tconst z = (far + near) * p;\n\t\tte[0] = 2 * w;\n\t\tte[4] = 0;\n\t\tte[8] = 0;\n\t\tte[12] = -x;\n\t\tte[1] = 0;\n\t\tte[5] = 2 * h;\n\t\tte[9] = 0;\n\t\tte[13] = -y;\n\t\tte[2] = 0;\n\t\tte[6] = 0;\n\t\tte[10] = -2 * p;\n\t\tte[14] = -z;\n\t\tte[3] = 0;\n\t\tte[7] = 0;\n\t\tte[11] = 0;\n\t\tte[15] = 1;\n\t\treturn this;\n\t}\n\n\tequals(matrix) {\n\t\tconst te = this.elements;\n\t\tconst me = matrix.elements;\n\n\t\tfor (let i = 0; i < 16; i++) {\n\t\t\tif (te[i] !== me[i]) return false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tfromArray(array, offset = 0) {\n\t\tfor (let i = 0; i < 16; i++) {\n\t\t\tthis.elements[i] = array[i + offset];\n\t\t}\n\n\t\treturn this;\n\t}\n\n\ttoArray(array = [], offset = 0) {\n\t\tconst te = this.elements;\n\t\tarray[offset] = te[0];\n\t\tarray[offset + 1] = te[1];\n\t\tarray[offset + 2] = te[2];\n\t\tarray[offset + 3] = te[3];\n\t\tarray[offset + 4] = te[4];\n\t\tarray[offset + 5] = te[5];\n\t\tarray[offset + 6] = te[6];\n\t\tarray[offset + 7] = te[7];\n\t\tarray[offset + 8] = te[8];\n\t\tarray[offset + 9] = te[9];\n\t\tarray[offset + 10] = te[10];\n\t\tarray[offset + 11] = te[11];\n\t\tarray[offset + 12] = te[12];\n\t\tarray[offset + 13] = te[13];\n\t\tarray[offset + 14] = te[14];\n\t\tarray[offset + 15] = te[15];\n\t\treturn array;\n\t}\n\n}\n\nconst _v1$5 = /*@__PURE__*/new Vector3();\n\nconst _m1$2 = /*@__PURE__*/new Matrix4();\n\nconst _zero = /*@__PURE__*/new Vector3(0, 0, 0);\n\nconst _one = /*@__PURE__*/new Vector3(1, 1, 1);\n\nconst _x = /*@__PURE__*/new Vector3();\n\nconst _y = /*@__PURE__*/new Vector3();\n\nconst _z = /*@__PURE__*/new Vector3();\n\nconst _matrix$1 = /*@__PURE__*/new Matrix4();\n\nconst _quaternion$3 = /*@__PURE__*/new Quaternion();\n\nclass Euler {\n\tconstructor(x = 0, y = 0, z = 0, order = Euler.DefaultOrder) {\n\t\tthis.isEuler = true;\n\t\tthis._x = x;\n\t\tthis._y = y;\n\t\tthis._z = z;\n\t\tthis._order = order;\n\t}\n\n\tget x() {\n\t\treturn this._x;\n\t}\n\n\tset x(value) {\n\t\tthis._x = value;\n\n\t\tthis._onChangeCallback();\n\t}\n\n\tget y() {\n\t\treturn this._y;\n\t}\n\n\tset y(value) {\n\t\tthis._y = value;\n\n\t\tthis._onChangeCallback();\n\t}\n\n\tget z() {\n\t\treturn this._z;\n\t}\n\n\tset z(value) {\n\t\tthis._z = value;\n\n\t\tthis._onChangeCallback();\n\t}\n\n\tget order() {\n\t\treturn this._order;\n\t}\n\n\tset order(value) {\n\t\tthis._order = value;\n\n\t\tthis._onChangeCallback();\n\t}\n\n\tset(x, y, z, order = this._order) {\n\t\tthis._x = x;\n\t\tthis._y = y;\n\t\tthis._z = z;\n\t\tthis._order = order;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\treturn new this.constructor(this._x, this._y, this._z, this._order);\n\t}\n\n\tcopy(euler) {\n\t\tthis._x = euler._x;\n\t\tthis._y = euler._y;\n\t\tthis._z = euler._z;\n\t\tthis._order = euler._order;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\t}\n\n\tsetFromRotationMatrix(m, order = this._order, update = true) {\n\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\t\tconst te = m.elements;\n\t\tconst m11 = te[0],\n\t\t\t\t\tm12 = te[4],\n\t\t\t\t\tm13 = te[8];\n\t\tconst m21 = te[1],\n\t\t\t\t\tm22 = te[5],\n\t\t\t\t\tm23 = te[9];\n\t\tconst m31 = te[2],\n\t\t\t\t\tm32 = te[6],\n\t\t\t\t\tm33 = te[10];\n\n\t\tswitch (order) {\n\t\t\tcase 'XYZ':\n\t\t\t\tthis._y = Math.asin(clamp(m13, -1, 1));\n\n\t\t\t\tif (Math.abs(m13) < 0.9999999) {\n\t\t\t\t\tthis._x = Math.atan2(-m23, m33);\n\t\t\t\t\tthis._z = Math.atan2(-m12, m11);\n\t\t\t\t} else {\n\t\t\t\t\tthis._x = Math.atan2(m32, m22);\n\t\t\t\t\tthis._z = 0;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'YXZ':\n\t\t\t\tthis._x = Math.asin(-clamp(m23, -1, 1));\n\n\t\t\t\tif (Math.abs(m23) < 0.9999999) {\n\t\t\t\t\tthis._y = Math.atan2(m13, m33);\n\t\t\t\t\tthis._z = Math.atan2(m21, m22);\n\t\t\t\t} else {\n\t\t\t\t\tthis._y = Math.atan2(-m31, m11);\n\t\t\t\t\tthis._z = 0;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZXY':\n\t\t\t\tthis._x = Math.asin(clamp(m32, -1, 1));\n\n\t\t\t\tif (Math.abs(m32) < 0.9999999) {\n\t\t\t\t\tthis._y = Math.atan2(-m31, m33);\n\t\t\t\t\tthis._z = Math.atan2(-m12, m22);\n\t\t\t\t} else {\n\t\t\t\t\tthis._y = 0;\n\t\t\t\t\tthis._z = Math.atan2(m21, m11);\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZYX':\n\t\t\t\tthis._y = Math.asin(-clamp(m31, -1, 1));\n\n\t\t\t\tif (Math.abs(m31) < 0.9999999) {\n\t\t\t\t\tthis._x = Math.atan2(m32, m33);\n\t\t\t\t\tthis._z = Math.atan2(m21, m11);\n\t\t\t\t} else {\n\t\t\t\t\tthis._x = 0;\n\t\t\t\t\tthis._z = Math.atan2(-m12, m22);\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'YZX':\n\t\t\t\tthis._z = Math.asin(clamp(m21, -1, 1));\n\n\t\t\t\tif (Math.abs(m21) < 0.9999999) {\n\t\t\t\t\tthis._x = Math.atan2(-m23, m22);\n\t\t\t\t\tthis._y = Math.atan2(-m31, m11);\n\t\t\t\t} else {\n\t\t\t\t\tthis._x = 0;\n\t\t\t\t\tthis._y = Math.atan2(m13, m33);\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'XZY':\n\t\t\t\tthis._z = Math.asin(-clamp(m12, -1, 1));\n\n\t\t\t\tif (Math.abs(m12) < 0.9999999) {\n\t\t\t\t\tthis._x = Math.atan2(m32, m22);\n\t\t\t\t\tthis._y = Math.atan2(m13, m11);\n\t\t\t\t} else {\n\t\t\t\t\tthis._x = Math.atan2(-m23, m33);\n\t\t\t\t\tthis._y = 0;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tconsole.warn('THREE.Euler: .setFromRotationMatrix() encountered an unknown order: ' + order);\n\t\t}\n\n\t\tthis._order = order;\n\t\tif (update === true) this._onChangeCallback();\n\t\treturn this;\n\t}\n\n\tsetFromQuaternion(q, order, update) {\n\t\t_matrix$1.makeRotationFromQuaternion(q);\n\n\t\treturn this.setFromRotationMatrix(_matrix$1, order, update);\n\t}\n\n\tsetFromVector3(v, order = this._order) {\n\t\treturn this.set(v.x, v.y, v.z, order);\n\t}\n\n\treorder(newOrder) {\n\t\t// WARNING: this discards revolution information -bhouston\n\t\t_quaternion$3.setFromEuler(this);\n\n\t\treturn this.setFromQuaternion(_quaternion$3, newOrder);\n\t}\n\n\tequals(euler) {\n\t\treturn euler._x === this._x && euler._y === this._y && euler._z === this._z && euler._order === this._order;\n\t}\n\n\tfromArray(array) {\n\t\tthis._x = array[0];\n\t\tthis._y = array[1];\n\t\tthis._z = array[2];\n\t\tif (array[3] !== undefined) this._order = array[3];\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\t}\n\n\ttoArray(array = [], offset = 0) {\n\t\tarray[offset] = this._x;\n\t\tarray[offset + 1] = this._y;\n\t\tarray[offset + 2] = this._z;\n\t\tarray[offset + 3] = this._order;\n\t\treturn array;\n\t}\n\n\t_onChange(callback) {\n\t\tthis._onChangeCallback = callback;\n\t\treturn this;\n\t}\n\n\t_onChangeCallback() {}\n\n\t*[Symbol.iterator]() {\n\t\tyield this._x;\n\t\tyield this._y;\n\t\tyield this._z;\n\t\tyield this._order;\n\t} // @deprecated since r138, 02cf0df1cb4575d5842fef9c85bb5a89fe020d53\n\n\n\ttoVector3() {\n\t\tconsole.error('THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead');\n\t}\n\n}\n\nEuler.DefaultOrder = 'XYZ';\nEuler.RotationOrders = ['XYZ', 'YZX', 'ZXY', 'XZY', 'YXZ', 'ZYX'];\n\nclass Layers {\n\tconstructor() {\n\t\tthis.mask = 1 | 0;\n\t}\n\n\tset(channel) {\n\t\tthis.mask = (1 << channel | 0) >>> 0;\n\t}\n\n\tenable(channel) {\n\t\tthis.mask |= 1 << channel | 0;\n\t}\n\n\tenableAll() {\n\t\tthis.mask = 0xffffffff | 0;\n\t}\n\n\ttoggle(channel) {\n\t\tthis.mask ^= 1 << channel | 0;\n\t}\n\n\tdisable(channel) {\n\t\tthis.mask &= ~(1 << channel | 0);\n\t}\n\n\tdisableAll() {\n\t\tthis.mask = 0;\n\t}\n\n\ttest(layers) {\n\t\treturn (this.mask & layers.mask) !== 0;\n\t}\n\n\tisEnabled(channel) {\n\t\treturn (this.mask & (1 << channel | 0)) !== 0;\n\t}\n\n}\n\nlet _object3DId = 0;\n\nconst _v1$4 = /*@__PURE__*/new Vector3();\n\nconst _q1 = /*@__PURE__*/new Quaternion();\n\nconst _m1$1 = /*@__PURE__*/new Matrix4();\n\nconst _target = /*@__PURE__*/new Vector3();\n\nconst _position$3 = /*@__PURE__*/new Vector3();\n\nconst _scale$2 = /*@__PURE__*/new Vector3();\n\nconst _quaternion$2 = /*@__PURE__*/new Quaternion();\n\nconst _xAxis = /*@__PURE__*/new Vector3(1, 0, 0);\n\nconst _yAxis = /*@__PURE__*/new Vector3(0, 1, 0);\n\nconst _zAxis = /*@__PURE__*/new Vector3(0, 0, 1);\n\nconst _addedEvent = {\n\ttype: 'added'\n};\nconst _removedEvent = {\n\ttype: 'removed'\n};\n\nclass Object3D extends EventDispatcher {\n\tconstructor() {\n\t\tsuper();\n\t\tthis.isObject3D = true;\n\t\tObject.defineProperty(this, 'id', {\n\t\t\tvalue: _object3DId++\n\t\t});\n\t\tthis.uuid = generateUUID();\n\t\tthis.name = '';\n\t\tthis.type = 'Object3D';\n\t\tthis.parent = null;\n\t\tthis.children = [];\n\t\tthis.up = Object3D.DefaultUp.clone();\n\t\tconst position = new Vector3();\n\t\tconst rotation = new Euler();\n\t\tconst quaternion = new Quaternion();\n\t\tconst scale = new Vector3(1, 1, 1);\n\n\t\tfunction onRotationChange() {\n\t\t\tquaternion.setFromEuler(rotation, false);\n\t\t}\n\n\t\tfunction onQuaternionChange() {\n\t\t\trotation.setFromQuaternion(quaternion, undefined, false);\n\t\t}\n\n\t\trotation._onChange(onRotationChange);\n\n\t\tquaternion._onChange(onQuaternionChange);\n\n\t\tObject.defineProperties(this, {\n\t\t\tposition: {\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tvalue: position\n\t\t\t},\n\t\t\trotation: {\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tvalue: rotation\n\t\t\t},\n\t\t\tquaternion: {\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tvalue: quaternion\n\t\t\t},\n\t\t\tscale: {\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tvalue: scale\n\t\t\t},\n\t\t\tmodelViewMatrix: {\n\t\t\t\tvalue: new Matrix4()\n\t\t\t},\n\t\t\tnormalMatrix: {\n\t\t\t\tvalue: new Matrix3()\n\t\t\t}\n\t\t});\n\t\tthis.matrix = new Matrix4();\n\t\tthis.matrixWorld = new Matrix4();\n\t\tthis.matrixAutoUpdate = Object3D.DefaultMatrixAutoUpdate;\n\t\tthis.matrixWorldNeedsUpdate = false;\n\t\tthis.matrixWorldAutoUpdate = Object3D.DefaultMatrixWorldAutoUpdate; // checked by the renderer\n\n\t\tthis.layers = new Layers();\n\t\tthis.visible = true;\n\t\tthis.castShadow = false;\n\t\tthis.receiveShadow = false;\n\t\tthis.frustumCulled = true;\n\t\tthis.renderOrder = 0;\n\t\tthis.animations = [];\n\t\tthis.userData = {};\n\t}\n\n\tonBeforeRender() {}\n\n\tonAfterRender() {}\n\n\tapplyMatrix4(matrix) {\n\t\tif (this.matrixAutoUpdate) this.updateMatrix();\n\t\tthis.matrix.premultiply(matrix);\n\t\tthis.matrix.decompose(this.position, this.quaternion, this.scale);\n\t}\n\n\tapplyQuaternion(q) {\n\t\tthis.quaternion.premultiply(q);\n\t\treturn this;\n\t}\n\n\tsetRotationFromAxisAngle(axis, angle) {\n\t\t// assumes axis is normalized\n\t\tthis.quaternion.setFromAxisAngle(axis, angle);\n\t}\n\n\tsetRotationFromEuler(euler) {\n\t\tthis.quaternion.setFromEuler(euler, true);\n\t}\n\n\tsetRotationFromMatrix(m) {\n\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\t\tthis.quaternion.setFromRotationMatrix(m);\n\t}\n\n\tsetRotationFromQuaternion(q) {\n\t\t// assumes q is normalized\n\t\tthis.quaternion.copy(q);\n\t}\n\n\trotateOnAxis(axis, angle) {\n\t\t// rotate object on axis in object space\n\t\t// axis is assumed to be normalized\n\t\t_q1.setFromAxisAngle(axis, angle);\n\n\t\tthis.quaternion.multiply(_q1);\n\t\treturn this;\n\t}\n\n\trotateOnWorldAxis(axis, angle) {\n\t\t// rotate object on axis in world space\n\t\t// axis is assumed to be normalized\n\t\t// method assumes no rotated parent\n\t\t_q1.setFromAxisAngle(axis, angle);\n\n\t\tthis.quaternion.premultiply(_q1);\n\t\treturn this;\n\t}\n\n\trotateX(angle) {\n\t\treturn this.rotateOnAxis(_xAxis, angle);\n\t}\n\n\trotateY(angle) {\n\t\treturn this.rotateOnAxis(_yAxis, angle);\n\t}\n\n\trotateZ(angle) {\n\t\treturn this.rotateOnAxis(_zAxis, angle);\n\t}\n\n\ttranslateOnAxis(axis, distance) {\n\t\t// translate object by distance along axis in object space\n\t\t// axis is assumed to be normalized\n\t\t_v1$4.copy(axis).applyQuaternion(this.quaternion);\n\n\t\tthis.position.add(_v1$4.multiplyScalar(distance));\n\t\treturn this;\n\t}\n\n\ttranslateX(distance) {\n\t\treturn this.translateOnAxis(_xAxis, distance);\n\t}\n\n\ttranslateY(distance) {\n\t\treturn this.translateOnAxis(_yAxis, distance);\n\t}\n\n\ttranslateZ(distance) {\n\t\treturn this.translateOnAxis(_zAxis, distance);\n\t}\n\n\tlocalToWorld(vector) {\n\t\treturn vector.applyMatrix4(this.matrixWorld);\n\t}\n\n\tworldToLocal(vector) {\n\t\treturn vector.applyMatrix4(_m1$1.copy(this.matrixWorld).invert());\n\t}\n\n\tlookAt(x, y, z) {\n\t\t// This method does not support objects having non-uniformly-scaled parent(s)\n\t\tif (x.isVector3) {\n\t\t\t_target.copy(x);\n\t\t} else {\n\t\t\t_target.set(x, y, z);\n\t\t}\n\n\t\tconst parent = this.parent;\n\t\tthis.updateWorldMatrix(true, false);\n\n\t\t_position$3.setFromMatrixPosition(this.matrixWorld);\n\n\t\tif (this.isCamera || this.isLight) {\n\t\t\t_m1$1.lookAt(_position$3, _target, this.up);\n\t\t} else {\n\t\t\t_m1$1.lookAt(_target, _position$3, this.up);\n\t\t}\n\n\t\tthis.quaternion.setFromRotationMatrix(_m1$1);\n\n\t\tif (parent) {\n\t\t\t_m1$1.extractRotation(parent.matrixWorld);\n\n\t\t\t_q1.setFromRotationMatrix(_m1$1);\n\n\t\t\tthis.quaternion.premultiply(_q1.invert());\n\t\t}\n\t}\n\n\tadd(object) {\n\t\tif (arguments.length > 1) {\n\t\t\tfor (let i = 0; i < arguments.length; i++) {\n\t\t\t\tthis.add(arguments[i]);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t}\n\n\t\tif (object === this) {\n\t\t\tconsole.error('THREE.Object3D.add: object can\\'t be added as a child of itself.', object);\n\t\t\treturn this;\n\t\t}\n\n\t\tif (object && object.isObject3D) {\n\t\t\tif (object.parent !== null) {\n\t\t\t\tobject.parent.remove(object);\n\t\t\t}\n\n\t\t\tobject.parent = this;\n\t\t\tthis.children.push(object);\n\t\t\tobject.dispatchEvent(_addedEvent);\n\t\t} else {\n\t\t\tconsole.error('THREE.Object3D.add: object not an instance of THREE.Object3D.', object);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tremove(object) {\n\t\tif (arguments.length > 1) {\n\t\t\tfor (let i = 0; i < arguments.length; i++) {\n\t\t\t\tthis.remove(arguments[i]);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t}\n\n\t\tconst index = this.children.indexOf(object);\n\n\t\tif (index !== -1) {\n\t\t\tobject.parent = null;\n\t\t\tthis.children.splice(index, 1);\n\t\t\tobject.dispatchEvent(_removedEvent);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tremoveFromParent() {\n\t\tconst parent = this.parent;\n\n\t\tif (parent !== null) {\n\t\t\tparent.remove(this);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tclear() {\n\t\tfor (let i = 0; i < this.children.length; i++) {\n\t\t\tconst object = this.children[i];\n\t\t\tobject.parent = null;\n\t\t\tobject.dispatchEvent(_removedEvent);\n\t\t}\n\n\t\tthis.children.length = 0;\n\t\treturn this;\n\t}\n\n\tattach(object) {\n\t\t// adds object as a child of this, while maintaining the object's world transform\n\t\t// Note: This method does not support scene graphs having non-uniformly-scaled nodes(s)\n\t\tthis.updateWorldMatrix(true, false);\n\n\t\t_m1$1.copy(this.matrixWorld).invert();\n\n\t\tif (object.parent !== null) {\n\t\t\tobject.parent.updateWorldMatrix(true, false);\n\n\t\t\t_m1$1.multiply(object.parent.matrixWorld);\n\t\t}\n\n\t\tobject.applyMatrix4(_m1$1);\n\t\tthis.add(object);\n\t\tobject.updateWorldMatrix(false, true);\n\t\treturn this;\n\t}\n\n\tgetObjectById(id) {\n\t\treturn this.getObjectByProperty('id', id);\n\t}\n\n\tgetObjectByName(name) {\n\t\treturn this.getObjectByProperty('name', name);\n\t}\n\n\tgetObjectByProperty(name, value) {\n\t\tif (this[name] === value) return this;\n\n\t\tfor (let i = 0, l = this.children.length; i < l; i++) {\n\t\t\tconst child = this.children[i];\n\t\t\tconst object = child.getObjectByProperty(name, value);\n\n\t\t\tif (object !== undefined) {\n\t\t\t\treturn object;\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tgetWorldPosition(target) {\n\t\tthis.updateWorldMatrix(true, false);\n\t\treturn target.setFromMatrixPosition(this.matrixWorld);\n\t}\n\n\tgetWorldQuaternion(target) {\n\t\tthis.updateWorldMatrix(true, false);\n\t\tthis.matrixWorld.decompose(_position$3, target, _scale$2);\n\t\treturn target;\n\t}\n\n\tgetWorldScale(target) {\n\t\tthis.updateWorldMatrix(true, false);\n\t\tthis.matrixWorld.decompose(_position$3, _quaternion$2, target);\n\t\treturn target;\n\t}\n\n\tgetWorldDirection(target) {\n\t\tthis.updateWorldMatrix(true, false);\n\t\tconst e = this.matrixWorld.elements;\n\t\treturn target.set(e[8], e[9], e[10]).normalize();\n\t}\n\n\traycast() {}\n\n\ttraverse(callback) {\n\t\tcallback(this);\n\t\tconst children = this.children;\n\n\t\tfor (let i = 0, l = children.length; i < l; i++) {\n\t\t\tchildren[i].traverse(callback);\n\t\t}\n\t}\n\n\ttraverseVisible(callback) {\n\t\tif (this.visible === false) return;\n\t\tcallback(this);\n\t\tconst children = this.children;\n\n\t\tfor (let i = 0, l = children.length; i < l; i++) {\n\t\t\tchildren[i].traverseVisible(callback);\n\t\t}\n\t}\n\n\ttraverseAncestors(callback) {\n\t\tconst parent = this.parent;\n\n\t\tif (parent !== null) {\n\t\t\tcallback(parent);\n\t\t\tparent.traverseAncestors(callback);\n\t\t}\n\t}\n\n\tupdateMatrix() {\n\t\tthis.matrix.compose(this.position, this.quaternion, this.scale);\n\t\tthis.matrixWorldNeedsUpdate = true;\n\t}\n\n\tupdateMatrixWorld(force) {\n\t\tif (this.matrixAutoUpdate) this.updateMatrix();\n\n\t\tif (this.matrixWorldNeedsUpdate || force) {\n\t\t\tif (this.parent === null) {\n\t\t\t\tthis.matrixWorld.copy(this.matrix);\n\t\t\t} else {\n\t\t\t\tthis.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix);\n\t\t\t}\n\n\t\t\tthis.matrixWorldNeedsUpdate = false;\n\t\t\tforce = true;\n\t\t} // update children\n\n\n\t\tconst children = this.children;\n\n\t\tfor (let i = 0, l = children.length; i < l; i++) {\n\t\t\tconst child = children[i];\n\n\t\t\tif (child.matrixWorldAutoUpdate === true || force === true) {\n\t\t\t\tchild.updateMatrixWorld(force);\n\t\t\t}\n\t\t}\n\t}\n\n\tupdateWorldMatrix(updateParents, updateChildren) {\n\t\tconst parent = this.parent;\n\n\t\tif (updateParents === true && parent !== null && parent.matrixWorldAutoUpdate === true) {\n\t\t\tparent.updateWorldMatrix(true, false);\n\t\t}\n\n\t\tif (this.matrixAutoUpdate) this.updateMatrix();\n\n\t\tif (this.parent === null) {\n\t\t\tthis.matrixWorld.copy(this.matrix);\n\t\t} else {\n\t\t\tthis.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix);\n\t\t} // update children\n\n\n\t\tif (updateChildren === true) {\n\t\t\tconst children = this.children;\n\n\t\t\tfor (let i = 0, l = children.length; i < l; i++) {\n\t\t\t\tconst child = children[i];\n\n\t\t\t\tif (child.matrixWorldAutoUpdate === true) {\n\t\t\t\t\tchild.updateWorldMatrix(false, true);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\ttoJSON(meta) {\n\t\t// meta is a string when called from JSON.stringify\n\t\tconst isRootObject = meta === undefined || typeof meta === 'string';\n\t\tconst output = {}; // meta is a hash used to collect geometries, materials.\n\t\t// not providing it implies that this is the root object\n\t\t// being serialized.\n\n\t\tif (isRootObject) {\n\t\t\t// initialize meta obj\n\t\t\tmeta = {\n\t\t\t\tgeometries: {},\n\t\t\t\tmaterials: {},\n\t\t\t\ttextures: {},\n\t\t\t\timages: {},\n\t\t\t\tshapes: {},\n\t\t\t\tskeletons: {},\n\t\t\t\tanimations: {},\n\t\t\t\tnodes: {}\n\t\t\t};\n\t\t\toutput.metadata = {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'Object',\n\t\t\t\tgenerator: 'Object3D.toJSON'\n\t\t\t};\n\t\t} // standard Object3D serialization\n\n\n\t\tconst object = {};\n\t\tobject.uuid = this.uuid;\n\t\tobject.type = this.type;\n\t\tif (this.name !== '') object.name = this.name;\n\t\tif (this.castShadow === true) object.castShadow = true;\n\t\tif (this.receiveShadow === true) object.receiveShadow = true;\n\t\tif (this.visible === false) object.visible = false;\n\t\tif (this.frustumCulled === false) object.frustumCulled = false;\n\t\tif (this.renderOrder !== 0) object.renderOrder = this.renderOrder;\n\t\tif (JSON.stringify(this.userData) !== '{}') object.userData = this.userData;\n\t\tobject.layers = this.layers.mask;\n\t\tobject.matrix = this.matrix.toArray();\n\t\tif (this.matrixAutoUpdate === false) object.matrixAutoUpdate = false; // object specific properties\n\n\t\tif (this.isInstancedMesh) {\n\t\t\tobject.type = 'InstancedMesh';\n\t\t\tobject.count = this.count;\n\t\t\tobject.instanceMatrix = this.instanceMatrix.toJSON();\n\t\t\tif (this.instanceColor !== null) object.instanceColor = this.instanceColor.toJSON();\n\t\t} //\n\n\n\t\tfunction serialize(library, element) {\n\t\t\tif (library[element.uuid] === undefined) {\n\t\t\t\tlibrary[element.uuid] = element.toJSON(meta);\n\t\t\t}\n\n\t\t\treturn element.uuid;\n\t\t}\n\n\t\tif (this.isScene) {\n\t\t\tif (this.background) {\n\t\t\t\tif (this.background.isColor) {\n\t\t\t\t\tobject.background = this.background.toJSON();\n\t\t\t\t} else if (this.background.isTexture) {\n\t\t\t\t\tobject.background = this.background.toJSON(meta).uuid;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.environment && this.environment.isTexture && this.environment.isRenderTargetTexture !== true) {\n\t\t\t\tobject.environment = this.environment.toJSON(meta).uuid;\n\t\t\t}\n\t\t} else if (this.isMesh || this.isLine || this.isPoints) {\n\t\t\tobject.geometry = serialize(meta.geometries, this.geometry);\n\t\t\tconst parameters = this.geometry.parameters;\n\n\t\t\tif (parameters !== undefined && parameters.shapes !== undefined) {\n\t\t\t\tconst shapes = parameters.shapes;\n\n\t\t\t\tif (Array.isArray(shapes)) {\n\t\t\t\t\tfor (let i = 0, l = shapes.length; i < l; i++) {\n\t\t\t\t\t\tconst shape = shapes[i];\n\t\t\t\t\t\tserialize(meta.shapes, shape);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tserialize(meta.shapes, shapes);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (this.isSkinnedMesh) {\n\t\t\tobject.bindMode = this.bindMode;\n\t\t\tobject.bindMatrix = this.bindMatrix.toArray();\n\n\t\t\tif (this.skeleton !== undefined) {\n\t\t\t\tserialize(meta.skeletons, this.skeleton);\n\t\t\t\tobject.skeleton = this.skeleton.uuid;\n\t\t\t}\n\t\t}\n\n\t\tif (this.material !== undefined) {\n\t\t\tif (Array.isArray(this.material)) {\n\t\t\t\tconst uuids = [];\n\n\t\t\t\tfor (let i = 0, l = this.material.length; i < l; i++) {\n\t\t\t\t\tuuids.push(serialize(meta.materials, this.material[i]));\n\t\t\t\t}\n\n\t\t\t\tobject.material = uuids;\n\t\t\t} else {\n\t\t\t\tobject.material = serialize(meta.materials, this.material);\n\t\t\t}\n\t\t} //\n\n\n\t\tif (this.children.length > 0) {\n\t\t\tobject.children = [];\n\n\t\t\tfor (let i = 0; i < this.children.length; i++) {\n\t\t\t\tobject.children.push(this.children[i].toJSON(meta).object);\n\t\t\t}\n\t\t} //\n\n\n\t\tif (this.animations.length > 0) {\n\t\t\tobject.animations = [];\n\n\t\t\tfor (let i = 0; i < this.animations.length; i++) {\n\t\t\t\tconst animation = this.animations[i];\n\t\t\t\tobject.animations.push(serialize(meta.animations, animation));\n\t\t\t}\n\t\t}\n\n\t\tif (isRootObject) {\n\t\t\tconst geometries = extractFromCache(meta.geometries);\n\t\t\tconst materials = extractFromCache(meta.materials);\n\t\t\tconst textures = extractFromCache(meta.textures);\n\t\t\tconst images = extractFromCache(meta.images);\n\t\t\tconst shapes = extractFromCache(meta.shapes);\n\t\t\tconst skeletons = extractFromCache(meta.skeletons);\n\t\t\tconst animations = extractFromCache(meta.animations);\n\t\t\tconst nodes = extractFromCache(meta.nodes);\n\t\t\tif (geometries.length > 0) output.geometries = geometries;\n\t\t\tif (materials.length > 0) output.materials = materials;\n\t\t\tif (textures.length > 0) output.textures = textures;\n\t\t\tif (images.length > 0) output.images = images;\n\t\t\tif (shapes.length > 0) output.shapes = shapes;\n\t\t\tif (skeletons.length > 0) output.skeletons = skeletons;\n\t\t\tif (animations.length > 0) output.animations = animations;\n\t\t\tif (nodes.length > 0) output.nodes = nodes;\n\t\t}\n\n\t\toutput.object = object;\n\t\treturn output; // extract data from the cache hash\n\t\t// remove metadata on each item\n\t\t// and return as array\n\n\t\tfunction extractFromCache(cache) {\n\t\t\tconst values = [];\n\n\t\t\tfor (const key in cache) {\n\t\t\t\tconst data = cache[key];\n\t\t\t\tdelete data.metadata;\n\t\t\t\tvalues.push(data);\n\t\t\t}\n\n\t\t\treturn values;\n\t\t}\n\t}\n\n\tclone(recursive) {\n\t\treturn new this.constructor().copy(this, recursive);\n\t}\n\n\tcopy(source, recursive = true) {\n\t\tthis.name = source.name;\n\t\tthis.up.copy(source.up);\n\t\tthis.position.copy(source.position);\n\t\tthis.rotation.order = source.rotation.order;\n\t\tthis.quaternion.copy(source.quaternion);\n\t\tthis.scale.copy(source.scale);\n\t\tthis.matrix.copy(source.matrix);\n\t\tthis.matrixWorld.copy(source.matrixWorld);\n\t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\t\tthis.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;\n\t\tthis.matrixWorldAutoUpdate = source.matrixWorldAutoUpdate;\n\t\tthis.layers.mask = source.layers.mask;\n\t\tthis.visible = source.visible;\n\t\tthis.castShadow = source.castShadow;\n\t\tthis.receiveShadow = source.receiveShadow;\n\t\tthis.frustumCulled = source.frustumCulled;\n\t\tthis.renderOrder = source.renderOrder;\n\t\tthis.userData = JSON.parse(JSON.stringify(source.userData));\n\n\t\tif (recursive === true) {\n\t\t\tfor (let i = 0; i < source.children.length; i++) {\n\t\t\t\tconst child = source.children[i];\n\t\t\t\tthis.add(child.clone());\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n\n}\n\nObject3D.DefaultUp = /*@__PURE__*/new Vector3(0, 1, 0);\nObject3D.DefaultMatrixAutoUpdate = true;\nObject3D.DefaultMatrixWorldAutoUpdate = true;\n\nconst _v0$1 = /*@__PURE__*/new Vector3();\n\nconst _v1$3 = /*@__PURE__*/new Vector3();\n\nconst _v2$2 = /*@__PURE__*/new Vector3();\n\nconst _v3$1 = /*@__PURE__*/new Vector3();\n\nconst _vab = /*@__PURE__*/new Vector3();\n\nconst _vac = /*@__PURE__*/new Vector3();\n\nconst _vbc = /*@__PURE__*/new Vector3();\n\nconst _vap = /*@__PURE__*/new Vector3();\n\nconst _vbp = /*@__PURE__*/new Vector3();\n\nconst _vcp = /*@__PURE__*/new Vector3();\n\nclass Triangle {\n\tconstructor(a = new Vector3(), b = new Vector3(), c = new Vector3()) {\n\t\tthis.a = a;\n\t\tthis.b = b;\n\t\tthis.c = c;\n\t}\n\n\tstatic getNormal(a, b, c, target) {\n\t\ttarget.subVectors(c, b);\n\n\t\t_v0$1.subVectors(a, b);\n\n\t\ttarget.cross(_v0$1);\n\t\tconst targetLengthSq = target.lengthSq();\n\n\t\tif (targetLengthSq > 0) {\n\t\t\treturn target.multiplyScalar(1 / Math.sqrt(targetLengthSq));\n\t\t}\n\n\t\treturn target.set(0, 0, 0);\n\t} // static/instance method to calculate barycentric coordinates\n\t// based on: http://www.blackpawn.com/texts/pointinpoly/default.html\n\n\n\tstatic getBarycoord(point, a, b, c, target) {\n\t\t_v0$1.subVectors(c, a);\n\n\t\t_v1$3.subVectors(b, a);\n\n\t\t_v2$2.subVectors(point, a);\n\n\t\tconst dot00 = _v0$1.dot(_v0$1);\n\n\t\tconst dot01 = _v0$1.dot(_v1$3);\n\n\t\tconst dot02 = _v0$1.dot(_v2$2);\n\n\t\tconst dot11 = _v1$3.dot(_v1$3);\n\n\t\tconst dot12 = _v1$3.dot(_v2$2);\n\n\t\tconst denom = dot00 * dot11 - dot01 * dot01; // collinear or singular triangle\n\n\t\tif (denom === 0) {\n\t\t\t// arbitrary location outside of triangle?\n\t\t\t// not sure if this is the best idea, maybe should be returning undefined\n\t\t\treturn target.set(-2, -1, -1);\n\t\t}\n\n\t\tconst invDenom = 1 / denom;\n\t\tconst u = (dot11 * dot02 - dot01 * dot12) * invDenom;\n\t\tconst v = (dot00 * dot12 - dot01 * dot02) * invDenom; // barycentric coordinates must always sum to 1\n\n\t\treturn target.set(1 - u - v, v, u);\n\t}\n\n\tstatic containsPoint(point, a, b, c) {\n\t\tthis.getBarycoord(point, a, b, c, _v3$1);\n\t\treturn _v3$1.x >= 0 && _v3$1.y >= 0 && _v3$1.x + _v3$1.y <= 1;\n\t}\n\n\tstatic getUV(point, p1, p2, p3, uv1, uv2, uv3, target) {\n\t\tthis.getBarycoord(point, p1, p2, p3, _v3$1);\n\t\ttarget.set(0, 0);\n\t\ttarget.addScaledVector(uv1, _v3$1.x);\n\t\ttarget.addScaledVector(uv2, _v3$1.y);\n\t\ttarget.addScaledVector(uv3, _v3$1.z);\n\t\treturn target;\n\t}\n\n\tstatic isFrontFacing(a, b, c, direction) {\n\t\t_v0$1.subVectors(c, b);\n\n\t\t_v1$3.subVectors(a, b); // strictly front facing\n\n\n\t\treturn _v0$1.cross(_v1$3).dot(direction) < 0 ? true : false;\n\t}\n\n\tset(a, b, c) {\n\t\tthis.a.copy(a);\n\t\tthis.b.copy(b);\n\t\tthis.c.copy(c);\n\t\treturn this;\n\t}\n\n\tsetFromPointsAndIndices(points, i0, i1, i2) {\n\t\tthis.a.copy(points[i0]);\n\t\tthis.b.copy(points[i1]);\n\t\tthis.c.copy(points[i2]);\n\t\treturn this;\n\t}\n\n\tsetFromAttributeAndIndices(attribute, i0, i1, i2) {\n\t\tthis.a.fromBufferAttribute(attribute, i0);\n\t\tthis.b.fromBufferAttribute(attribute, i1);\n\t\tthis.c.fromBufferAttribute(attribute, i2);\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\treturn new this.constructor().copy(this);\n\t}\n\n\tcopy(triangle) {\n\t\tthis.a.copy(triangle.a);\n\t\tthis.b.copy(triangle.b);\n\t\tthis.c.copy(triangle.c);\n\t\treturn this;\n\t}\n\n\tgetArea() {\n\t\t_v0$1.subVectors(this.c, this.b);\n\n\t\t_v1$3.subVectors(this.a, this.b);\n\n\t\treturn _v0$1.cross(_v1$3).length() * 0.5;\n\t}\n\n\tgetMidpoint(target) {\n\t\treturn target.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3);\n\t}\n\n\tgetNormal(target) {\n\t\treturn Triangle.getNormal(this.a, this.b, this.c, target);\n\t}\n\n\tgetPlane(target) {\n\t\treturn target.setFromCoplanarPoints(this.a, this.b, this.c);\n\t}\n\n\tgetBarycoord(point, target) {\n\t\treturn Triangle.getBarycoord(point, this.a, this.b, this.c, target);\n\t}\n\n\tgetUV(point, uv1, uv2, uv3, target) {\n\t\treturn Triangle.getUV(point, this.a, this.b, this.c, uv1, uv2, uv3, target);\n\t}\n\n\tcontainsPoint(point) {\n\t\treturn Triangle.containsPoint(point, this.a, this.b, this.c);\n\t}\n\n\tisFrontFacing(direction) {\n\t\treturn Triangle.isFrontFacing(this.a, this.b, this.c, direction);\n\t}\n\n\tintersectsBox(box) {\n\t\treturn box.intersectsTriangle(this);\n\t}\n\n\tclosestPointToPoint(p, target) {\n\t\tconst a = this.a,\n\t\t\t\t\tb = this.b,\n\t\t\t\t\tc = this.c;\n\t\tlet v, w; // algorithm thanks to Real-Time Collision Detection by Christer Ericson,\n\t\t// published by Morgan Kaufmann Publishers, (c) 2005 Elsevier Inc.,\n\t\t// under the accompanying license; see chapter 5.1.5 for detailed explanation.\n\t\t// basically, we're distinguishing which of the voronoi regions of the triangle\n\t\t// the point lies in with the minimum amount of redundant computation.\n\n\t\t_vab.subVectors(b, a);\n\n\t\t_vac.subVectors(c, a);\n\n\t\t_vap.subVectors(p, a);\n\n\t\tconst d1 = _vab.dot(_vap);\n\n\t\tconst d2 = _vac.dot(_vap);\n\n\t\tif (d1 <= 0 && d2 <= 0) {\n\t\t\t// vertex region of A; barycentric coords (1, 0, 0)\n\t\t\treturn target.copy(a);\n\t\t}\n\n\t\t_vbp.subVectors(p, b);\n\n\t\tconst d3 = _vab.dot(_vbp);\n\n\t\tconst d4 = _vac.dot(_vbp);\n\n\t\tif (d3 >= 0 && d4 <= d3) {\n\t\t\t// vertex region of B; barycentric coords (0, 1, 0)\n\t\t\treturn target.copy(b);\n\t\t}\n\n\t\tconst vc = d1 * d4 - d3 * d2;\n\n\t\tif (vc <= 0 && d1 >= 0 && d3 <= 0) {\n\t\t\tv = d1 / (d1 - d3); // edge region of AB; barycentric coords (1-v, v, 0)\n\n\t\t\treturn target.copy(a).addScaledVector(_vab, v);\n\t\t}\n\n\t\t_vcp.subVectors(p, c);\n\n\t\tconst d5 = _vab.dot(_vcp);\n\n\t\tconst d6 = _vac.dot(_vcp);\n\n\t\tif (d6 >= 0 && d5 <= d6) {\n\t\t\t// vertex region of C; barycentric coords (0, 0, 1)\n\t\t\treturn target.copy(c);\n\t\t}\n\n\t\tconst vb = d5 * d2 - d1 * d6;\n\n\t\tif (vb <= 0 && d2 >= 0 && d6 <= 0) {\n\t\t\tw = d2 / (d2 - d6); // edge region of AC; barycentric coords (1-w, 0, w)\n\n\t\t\treturn target.copy(a).addScaledVector(_vac, w);\n\t\t}\n\n\t\tconst va = d3 * d6 - d5 * d4;\n\n\t\tif (va <= 0 && d4 - d3 >= 0 && d5 - d6 >= 0) {\n\t\t\t_vbc.subVectors(c, b);\n\n\t\t\tw = (d4 - d3) / (d4 - d3 + (d5 - d6)); // edge region of BC; barycentric coords (0, 1-w, w)\n\n\t\t\treturn target.copy(b).addScaledVector(_vbc, w); // edge region of BC\n\t\t} // face region\n\n\n\t\tconst denom = 1 / (va + vb + vc); // u = va * denom\n\n\t\tv = vb * denom;\n\t\tw = vc * denom;\n\t\treturn target.copy(a).addScaledVector(_vab, v).addScaledVector(_vac, w);\n\t}\n\n\tequals(triangle) {\n\t\treturn triangle.a.equals(this.a) && triangle.b.equals(this.b) && triangle.c.equals(this.c);\n\t}\n\n}\n\nlet materialId = 0;\n\nclass Material extends EventDispatcher {\n\tconstructor() {\n\t\tsuper();\n\t\tthis.isMaterial = true;\n\t\tObject.defineProperty(this, 'id', {\n\t\t\tvalue: materialId++\n\t\t});\n\t\tthis.uuid = generateUUID();\n\t\tthis.name = '';\n\t\tthis.type = 'Material';\n\t\tthis.blending = NormalBlending;\n\t\tthis.side = FrontSide;\n\t\tthis.vertexColors = false;\n\t\tthis.opacity = 1;\n\t\tthis.transparent = false;\n\t\tthis.blendSrc = SrcAlphaFactor;\n\t\tthis.blendDst = OneMinusSrcAlphaFactor;\n\t\tthis.blendEquation = AddEquation;\n\t\tthis.blendSrcAlpha = null;\n\t\tthis.blendDstAlpha = null;\n\t\tthis.blendEquationAlpha = null;\n\t\tthis.depthFunc = LessEqualDepth;\n\t\tthis.depthTest = true;\n\t\tthis.depthWrite = true;\n\t\tthis.stencilWriteMask = 0xff;\n\t\tthis.stencilFunc = AlwaysStencilFunc;\n\t\tthis.stencilRef = 0;\n\t\tthis.stencilFuncMask = 0xff;\n\t\tthis.stencilFail = KeepStencilOp;\n\t\tthis.stencilZFail = KeepStencilOp;\n\t\tthis.stencilZPass = KeepStencilOp;\n\t\tthis.stencilWrite = false;\n\t\tthis.clippingPlanes = null;\n\t\tthis.clipIntersection = false;\n\t\tthis.clipShadows = false;\n\t\tthis.shadowSide = null;\n\t\tthis.colorWrite = true;\n\t\tthis.precision = null; // override the renderer's default precision for this material\n\n\t\tthis.polygonOffset = false;\n\t\tthis.polygonOffsetFactor = 0;\n\t\tthis.polygonOffsetUnits = 0;\n\t\tthis.dithering = false;\n\t\tthis.alphaToCoverage = false;\n\t\tthis.premultipliedAlpha = false;\n\t\tthis.visible = true;\n\t\tthis.toneMapped = true;\n\t\tthis.userData = {};\n\t\tthis.version = 0;\n\t\tthis._alphaTest = 0;\n\t}\n\n\tget alphaTest() {\n\t\treturn this._alphaTest;\n\t}\n\n\tset alphaTest(value) {\n\t\tif (this._alphaTest > 0 !== value > 0) {\n\t\t\tthis.version++;\n\t\t}\n\n\t\tthis._alphaTest = value;\n\t}\n\n\tonBuild() {}\n\n\tonBeforeRender() {}\n\n\tonBeforeCompile() {}\n\n\tcustomProgramCacheKey() {\n\t\treturn this.onBeforeCompile.toString();\n\t}\n\n\tsetValues(values) {\n\t\tif (values === undefined) return;\n\n\t\tfor (const key in values) {\n\t\t\tconst newValue = values[key];\n\n\t\t\tif (newValue === undefined) {\n\t\t\t\tconsole.warn('THREE.Material: \\'' + key + '\\' parameter is undefined.');\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst currentValue = this[key];\n\n\t\t\tif (currentValue === undefined) {\n\t\t\t\tconsole.warn('THREE.' + this.type + ': \\'' + key + '\\' is not a property of this material.');\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (currentValue && currentValue.isColor) {\n\t\t\t\tcurrentValue.set(newValue);\n\t\t\t} else if (currentValue && currentValue.isVector3 && newValue && newValue.isVector3) {\n\t\t\t\tcurrentValue.copy(newValue);\n\t\t\t} else {\n\t\t\t\tthis[key] = newValue;\n\t\t\t}\n\t\t}\n\t}\n\n\ttoJSON(meta) {\n\t\tconst isRootObject = meta === undefined || typeof meta === 'string';\n\n\t\tif (isRootObject) {\n\t\t\tmeta = {\n\t\t\t\ttextures: {},\n\t\t\t\timages: {}\n\t\t\t};\n\t\t}\n\n\t\tconst data = {\n\t\t\tmetadata: {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'Material',\n\t\t\t\tgenerator: 'Material.toJSON'\n\t\t\t}\n\t\t}; // standard Material serialization\n\n\t\tdata.uuid = this.uuid;\n\t\tdata.type = this.type;\n\t\tif (this.name !== '') data.name = this.name;\n\t\tif (this.color && this.color.isColor) data.color = this.color.getHex();\n\t\tif (this.roughness !== undefined) data.roughness = this.roughness;\n\t\tif (this.metalness !== undefined) data.metalness = this.metalness;\n\t\tif (this.sheen !== undefined) data.sheen = this.sheen;\n\t\tif (this.sheenColor && this.sheenColor.isColor) data.sheenColor = this.sheenColor.getHex();\n\t\tif (this.sheenRoughness !== undefined) data.sheenRoughness = this.sheenRoughness;\n\t\tif (this.emissive && this.emissive.isColor) data.emissive = this.emissive.getHex();\n\t\tif (this.emissiveIntensity && this.emissiveIntensity !== 1) data.emissiveIntensity = this.emissiveIntensity;\n\t\tif (this.specular && this.specular.isColor) data.specular = this.specular.getHex();\n\t\tif (this.specularIntensity !== undefined) data.specularIntensity = this.specularIntensity;\n\t\tif (this.specularColor && this.specularColor.isColor) data.specularColor = this.specularColor.getHex();\n\t\tif (this.shininess !== undefined) data.shininess = this.shininess;\n\t\tif (this.clearcoat !== undefined) data.clearcoat = this.clearcoat;\n\t\tif (this.clearcoatRoughness !== undefined) data.clearcoatRoughness = this.clearcoatRoughness;\n\n\t\tif (this.clearcoatMap && this.clearcoatMap.isTexture) {\n\t\t\tdata.clearcoatMap = this.clearcoatMap.toJSON(meta).uuid;\n\t\t}\n\n\t\tif (this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture) {\n\t\t\tdata.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON(meta).uuid;\n\t\t}\n\n\t\tif (this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture) {\n\t\t\tdata.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(meta).uuid;\n\t\t\tdata.clearcoatNormalScale = this.clearcoatNormalScale.toArray();\n\t\t}\n\n\t\tif (this.iridescence !== undefined) data.iridescence = this.iridescence;\n\t\tif (this.iridescenceIOR !== undefined) data.iridescenceIOR = this.iridescenceIOR;\n\t\tif (this.iridescenceThicknessRange !== undefined) data.iridescenceThicknessRange = this.iridescenceThicknessRange;\n\n\t\tif (this.iridescenceMap && this.iridescenceMap.isTexture) {\n\t\t\tdata.iridescenceMap = this.iridescenceMap.toJSON(meta).uuid;\n\t\t}\n\n\t\tif (this.iridescenceThicknessMap && this.iridescenceThicknessMap.isTexture) {\n\t\t\tdata.iridescenceThicknessMap = this.iridescenceThicknessMap.toJSON(meta).uuid;\n\t\t}\n\n\t\tif (this.map && this.map.isTexture) data.map = this.map.toJSON(meta).uuid;\n\t\tif (this.matcap && this.matcap.isTexture) data.matcap = this.matcap.toJSON(meta).uuid;\n\t\tif (this.alphaMap && this.alphaMap.isTexture) data.alphaMap = this.alphaMap.toJSON(meta).uuid;\n\n\t\tif (this.lightMap && this.lightMap.isTexture) {\n\t\t\tdata.lightMap = this.lightMap.toJSON(meta).uuid;\n\t\t\tdata.lightMapIntensity = this.lightMapIntensity;\n\t\t}\n\n\t\tif (this.aoMap && this.aoMap.isTexture) {\n\t\t\tdata.aoMap = this.aoMap.toJSON(meta).uuid;\n\t\t\tdata.aoMapIntensity = this.aoMapIntensity;\n\t\t}\n\n\t\tif (this.bumpMap && this.bumpMap.isTexture) {\n\t\t\tdata.bumpMap = this.bumpMap.toJSON(meta).uuid;\n\t\t\tdata.bumpScale = this.bumpScale;\n\t\t}\n\n\t\tif (this.normalMap && this.normalMap.isTexture) {\n\t\t\tdata.normalMap = this.normalMap.toJSON(meta).uuid;\n\t\t\tdata.normalMapType = this.normalMapType;\n\t\t\tdata.normalScale = this.normalScale.toArray();\n\t\t}\n\n\t\tif (this.displacementMap && this.displacementMap.isTexture) {\n\t\t\tdata.displacementMap = this.displacementMap.toJSON(meta).uuid;\n\t\t\tdata.displacementScale = this.displacementScale;\n\t\t\tdata.displacementBias = this.displacementBias;\n\t\t}\n\n\t\tif (this.roughnessMap && this.roughnessMap.isTexture) data.roughnessMap = this.roughnessMap.toJSON(meta).uuid;\n\t\tif (this.metalnessMap && this.metalnessMap.isTexture) data.metalnessMap = this.metalnessMap.toJSON(meta).uuid;\n\t\tif (this.emissiveMap && this.emissiveMap.isTexture) data.emissiveMap = this.emissiveMap.toJSON(meta).uuid;\n\t\tif (this.specularMap && this.specularMap.isTexture) data.specularMap = this.specularMap.toJSON(meta).uuid;\n\t\tif (this.specularIntensityMap && this.specularIntensityMap.isTexture) data.specularIntensityMap = this.specularIntensityMap.toJSON(meta).uuid;\n\t\tif (this.specularColorMap && this.specularColorMap.isTexture) data.specularColorMap = this.specularColorMap.toJSON(meta).uuid;\n\n\t\tif (this.envMap && this.envMap.isTexture) {\n\t\t\tdata.envMap = this.envMap.toJSON(meta).uuid;\n\t\t\tif (this.combine !== undefined) data.combine = this.combine;\n\t\t}\n\n\t\tif (this.envMapIntensity !== undefined) data.envMapIntensity = this.envMapIntensity;\n\t\tif (this.reflectivity !== undefined) data.reflectivity = this.reflectivity;\n\t\tif (this.refractionRatio !== undefined) data.refractionRatio = this.refractionRatio;\n\n\t\tif (this.gradientMap && this.gradientMap.isTexture) {\n\t\t\tdata.gradientMap = this.gradientMap.toJSON(meta).uuid;\n\t\t}\n\n\t\tif (this.transmission !== undefined) data.transmission = this.transmission;\n\t\tif (this.transmissionMap && this.transmissionMap.isTexture) data.transmissionMap = this.transmissionMap.toJSON(meta).uuid;\n\t\tif (this.thickness !== undefined) data.thickness = this.thickness;\n\t\tif (this.thicknessMap && this.thicknessMap.isTexture) data.thicknessMap = this.thicknessMap.toJSON(meta).uuid;\n\t\tif (this.attenuationDistance !== undefined) data.attenuationDistance = this.attenuationDistance;\n\t\tif (this.attenuationColor !== undefined) data.attenuationColor = this.attenuationColor.getHex();\n\t\tif (this.size !== undefined) data.size = this.size;\n\t\tif (this.shadowSide !== null) data.shadowSide = this.shadowSide;\n\t\tif (this.sizeAttenuation !== undefined) data.sizeAttenuation = this.sizeAttenuation;\n\t\tif (this.blending !== NormalBlending) data.blending = this.blending;\n\t\tif (this.side !== FrontSide) data.side = this.side;\n\t\tif (this.vertexColors) data.vertexColors = true;\n\t\tif (this.opacity < 1) data.opacity = this.opacity;\n\t\tif (this.transparent === true) data.transparent = this.transparent;\n\t\tdata.depthFunc = this.depthFunc;\n\t\tdata.depthTest = this.depthTest;\n\t\tdata.depthWrite = this.depthWrite;\n\t\tdata.colorWrite = this.colorWrite;\n\t\tdata.stencilWrite = this.stencilWrite;\n\t\tdata.stencilWriteMask = this.stencilWriteMask;\n\t\tdata.stencilFunc = this.stencilFunc;\n\t\tdata.stencilRef = this.stencilRef;\n\t\tdata.stencilFuncMask = this.stencilFuncMask;\n\t\tdata.stencilFail = this.stencilFail;\n\t\tdata.stencilZFail = this.stencilZFail;\n\t\tdata.stencilZPass = this.stencilZPass; // rotation (SpriteMaterial)\n\n\t\tif (this.rotation !== undefined && this.rotation !== 0) data.rotation = this.rotation;\n\t\tif (this.polygonOffset === true) data.polygonOffset = true;\n\t\tif (this.polygonOffsetFactor !== 0) data.polygonOffsetFactor = this.polygonOffsetFactor;\n\t\tif (this.polygonOffsetUnits !== 0) data.polygonOffsetUnits = this.polygonOffsetUnits;\n\t\tif (this.linewidth !== undefined && this.linewidth !== 1) data.linewidth = this.linewidth;\n\t\tif (this.dashSize !== undefined) data.dashSize = this.dashSize;\n\t\tif (this.gapSize !== undefined) data.gapSize = this.gapSize;\n\t\tif (this.scale !== undefined) data.scale = this.scale;\n\t\tif (this.dithering === true) data.dithering = true;\n\t\tif (this.alphaTest > 0) data.alphaTest = this.alphaTest;\n\t\tif (this.alphaToCoverage === true) data.alphaToCoverage = this.alphaToCoverage;\n\t\tif (this.premultipliedAlpha === true) data.premultipliedAlpha = this.premultipliedAlpha;\n\t\tif (this.wireframe === true) data.wireframe = this.wireframe;\n\t\tif (this.wireframeLinewidth > 1) data.wireframeLinewidth = this.wireframeLinewidth;\n\t\tif (this.wireframeLinecap !== 'round') data.wireframeLinecap = this.wireframeLinecap;\n\t\tif (this.wireframeLinejoin !== 'round') data.wireframeLinejoin = this.wireframeLinejoin;\n\t\tif (this.flatShading === true) data.flatShading = this.flatShading;\n\t\tif (this.visible === false) data.visible = false;\n\t\tif (this.toneMapped === false) data.toneMapped = false;\n\t\tif (this.fog === false) data.fog = false;\n\t\tif (JSON.stringify(this.userData) !== '{}') data.userData = this.userData; // TODO: Copied from Object3D.toJSON\n\n\t\tfunction extractFromCache(cache) {\n\t\t\tconst values = [];\n\n\t\t\tfor (const key in cache) {\n\t\t\t\tconst data = cache[key];\n\t\t\t\tdelete data.metadata;\n\t\t\t\tvalues.push(data);\n\t\t\t}\n\n\t\t\treturn values;\n\t\t}\n\n\t\tif (isRootObject) {\n\t\t\tconst textures = extractFromCache(meta.textures);\n\t\t\tconst images = extractFromCache(meta.images);\n\t\t\tif (textures.length > 0) data.textures = textures;\n\t\t\tif (images.length > 0) data.images = images;\n\t\t}\n\n\t\treturn data;\n\t}\n\n\tclone() {\n\t\treturn new this.constructor().copy(this);\n\t}\n\n\tcopy(source) {\n\t\tthis.name = source.name;\n\t\tthis.blending = source.blending;\n\t\tthis.side = source.side;\n\t\tthis.vertexColors = source.vertexColors;\n\t\tthis.opacity = source.opacity;\n\t\tthis.transparent = source.transparent;\n\t\tthis.blendSrc = source.blendSrc;\n\t\tthis.blendDst = source.blendDst;\n\t\tthis.blendEquation = source.blendEquation;\n\t\tthis.blendSrcAlpha = source.blendSrcAlpha;\n\t\tthis.blendDstAlpha = source.blendDstAlpha;\n\t\tthis.blendEquationAlpha = source.blendEquationAlpha;\n\t\tthis.depthFunc = source.depthFunc;\n\t\tthis.depthTest = source.depthTest;\n\t\tthis.depthWrite = source.depthWrite;\n\t\tthis.stencilWriteMask = source.stencilWriteMask;\n\t\tthis.stencilFunc = source.stencilFunc;\n\t\tthis.stencilRef = source.stencilRef;\n\t\tthis.stencilFuncMask = source.stencilFuncMask;\n\t\tthis.stencilFail = source.stencilFail;\n\t\tthis.stencilZFail = source.stencilZFail;\n\t\tthis.stencilZPass = source.stencilZPass;\n\t\tthis.stencilWrite = source.stencilWrite;\n\t\tconst srcPlanes = source.clippingPlanes;\n\t\tlet dstPlanes = null;\n\n\t\tif (srcPlanes !== null) {\n\t\t\tconst n = srcPlanes.length;\n\t\t\tdstPlanes = new Array(n);\n\n\t\t\tfor (let i = 0; i !== n; ++i) {\n\t\t\t\tdstPlanes[i] = srcPlanes[i].clone();\n\t\t\t}\n\t\t}\n\n\t\tthis.clippingPlanes = dstPlanes;\n\t\tthis.clipIntersection = source.clipIntersection;\n\t\tthis.clipShadows = source.clipShadows;\n\t\tthis.shadowSide = source.shadowSide;\n\t\tthis.colorWrite = source.colorWrite;\n\t\tthis.precision = source.precision;\n\t\tthis.polygonOffset = source.polygonOffset;\n\t\tthis.polygonOffsetFactor = source.polygonOffsetFactor;\n\t\tthis.polygonOffsetUnits = source.polygonOffsetUnits;\n\t\tthis.dithering = source.dithering;\n\t\tthis.alphaTest = source.alphaTest;\n\t\tthis.alphaToCoverage = source.alphaToCoverage;\n\t\tthis.premultipliedAlpha = source.premultipliedAlpha;\n\t\tthis.visible = source.visible;\n\t\tthis.toneMapped = source.toneMapped;\n\t\tthis.userData = JSON.parse(JSON.stringify(source.userData));\n\t\treturn this;\n\t}\n\n\tdispose() {\n\t\tthis.dispatchEvent({\n\t\t\ttype: 'dispose'\n\t\t});\n\t}\n\n\tset needsUpdate(value) {\n\t\tif (value === true) this.version++;\n\t}\n\n}\n\nclass MeshBasicMaterial extends Material {\n\tconstructor(parameters) {\n\t\tsuper();\n\t\tthis.isMeshBasicMaterial = true;\n\t\tthis.type = 'MeshBasicMaterial';\n\t\tthis.color = new Color(0xffffff); // emissive\n\n\t\tthis.map = null;\n\t\tthis.lightMap = null;\n\t\tthis.lightMapIntensity = 1.0;\n\t\tthis.aoMap = null;\n\t\tthis.aoMapIntensity = 1.0;\n\t\tthis.specularMap = null;\n\t\tthis.alphaMap = null;\n\t\tthis.envMap = null;\n\t\tthis.combine = MultiplyOperation;\n\t\tthis.reflectivity = 1;\n\t\tthis.refractionRatio = 0.98;\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\t\tthis.wireframeLinecap = 'round';\n\t\tthis.wireframeLinejoin = 'round';\n\t\tthis.fog = true;\n\t\tthis.setValues(parameters);\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.color.copy(source.color);\n\t\tthis.map = source.map;\n\t\tthis.lightMap = source.lightMap;\n\t\tthis.lightMapIntensity = source.lightMapIntensity;\n\t\tthis.aoMap = source.aoMap;\n\t\tthis.aoMapIntensity = source.aoMapIntensity;\n\t\tthis.specularMap = source.specularMap;\n\t\tthis.alphaMap = source.alphaMap;\n\t\tthis.envMap = source.envMap;\n\t\tthis.combine = source.combine;\n\t\tthis.reflectivity = source.reflectivity;\n\t\tthis.refractionRatio = source.refractionRatio;\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\t\tthis.wireframeLinecap = source.wireframeLinecap;\n\t\tthis.wireframeLinejoin = source.wireframeLinejoin;\n\t\tthis.fog = source.fog;\n\t\treturn this;\n\t}\n\n}\n\nconst _vector$9 = /*@__PURE__*/new Vector3();\n\nconst _vector2$1 = /*@__PURE__*/new Vector2();\n\nclass BufferAttribute {\n\tconstructor(array, itemSize, normalized) {\n\t\tif (Array.isArray(array)) {\n\t\t\tthrow new TypeError('THREE.BufferAttribute: array should be a Typed Array.');\n\t\t}\n\n\t\tthis.isBufferAttribute = true;\n\t\tthis.name = '';\n\t\tthis.array = array;\n\t\tthis.itemSize = itemSize;\n\t\tthis.count = array !== undefined ? array.length / itemSize : 0;\n\t\tthis.normalized = normalized === true;\n\t\tthis.usage = StaticDrawUsage;\n\t\tthis.updateRange = {\n\t\t\toffset: 0,\n\t\t\tcount: -1\n\t\t};\n\t\tthis.version = 0;\n\t}\n\n\tonUploadCallback() {}\n\n\tset needsUpdate(value) {\n\t\tif (value === true) this.version++;\n\t}\n\n\tsetUsage(value) {\n\t\tthis.usage = value;\n\t\treturn this;\n\t}\n\n\tcopy(source) {\n\t\tthis.name = source.name;\n\t\tthis.array = new source.array.constructor(source.array);\n\t\tthis.itemSize = source.itemSize;\n\t\tthis.count = source.count;\n\t\tthis.normalized = source.normalized;\n\t\tthis.usage = source.usage;\n\t\treturn this;\n\t}\n\n\tcopyAt(index1, attribute, index2) {\n\t\tindex1 *= this.itemSize;\n\t\tindex2 *= attribute.itemSize;\n\n\t\tfor (let i = 0, l = this.itemSize; i < l; i++) {\n\t\t\tthis.array[index1 + i] = attribute.array[index2 + i];\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tcopyArray(array) {\n\t\tthis.array.set(array);\n\t\treturn this;\n\t}\n\n\tapplyMatrix3(m) {\n\t\tif (this.itemSize === 2) {\n\t\t\tfor (let i = 0, l = this.count; i < l; i++) {\n\t\t\t\t_vector2$1.fromBufferAttribute(this, i);\n\n\t\t\t\t_vector2$1.applyMatrix3(m);\n\n\t\t\t\tthis.setXY(i, _vector2$1.x, _vector2$1.y);\n\t\t\t}\n\t\t} else if (this.itemSize === 3) {\n\t\t\tfor (let i = 0, l = this.count; i < l; i++) {\n\t\t\t\t_vector$9.fromBufferAttribute(this, i);\n\n\t\t\t\t_vector$9.applyMatrix3(m);\n\n\t\t\t\tthis.setXYZ(i, _vector$9.x, _vector$9.y, _vector$9.z);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tapplyMatrix4(m) {\n\t\tfor (let i = 0, l = this.count; i < l; i++) {\n\t\t\t_vector$9.fromBufferAttribute(this, i);\n\n\t\t\t_vector$9.applyMatrix4(m);\n\n\t\t\tthis.setXYZ(i, _vector$9.x, _vector$9.y, _vector$9.z);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tapplyNormalMatrix(m) {\n\t\tfor (let i = 0, l = this.count; i < l; i++) {\n\t\t\t_vector$9.fromBufferAttribute(this, i);\n\n\t\t\t_vector$9.applyNormalMatrix(m);\n\n\t\t\tthis.setXYZ(i, _vector$9.x, _vector$9.y, _vector$9.z);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\ttransformDirection(m) {\n\t\tfor (let i = 0, l = this.count; i < l; i++) {\n\t\t\t_vector$9.fromBufferAttribute(this, i);\n\n\t\t\t_vector$9.transformDirection(m);\n\n\t\t\tthis.setXYZ(i, _vector$9.x, _vector$9.y, _vector$9.z);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tset(value, offset = 0) {\n\t\t// Matching BufferAttribute constructor, do not normalize the array.\n\t\tthis.array.set(value, offset);\n\t\treturn this;\n\t}\n\n\tgetX(index) {\n\t\tlet x = this.array[index * this.itemSize];\n\t\tif (this.normalized) x = denormalize(x, this.array);\n\t\treturn x;\n\t}\n\n\tsetX(index, x) {\n\t\tif (this.normalized) x = normalize(x, this.array);\n\t\tthis.array[index * this.itemSize] = x;\n\t\treturn this;\n\t}\n\n\tgetY(index) {\n\t\tlet y = this.array[index * this.itemSize + 1];\n\t\tif (this.normalized) y = denormalize(y, this.array);\n\t\treturn y;\n\t}\n\n\tsetY(index, y) {\n\t\tif (this.normalized) y = normalize(y, this.array);\n\t\tthis.array[index * this.itemSize + 1] = y;\n\t\treturn this;\n\t}\n\n\tgetZ(index) {\n\t\tlet z = this.array[index * this.itemSize + 2];\n\t\tif (this.normalized) z = denormalize(z, this.array);\n\t\treturn z;\n\t}\n\n\tsetZ(index, z) {\n\t\tif (this.normalized) z = normalize(z, this.array);\n\t\tthis.array[index * this.itemSize + 2] = z;\n\t\treturn this;\n\t}\n\n\tgetW(index) {\n\t\tlet w = this.array[index * this.itemSize + 3];\n\t\tif (this.normalized) w = denormalize(w, this.array);\n\t\treturn w;\n\t}\n\n\tsetW(index, w) {\n\t\tif (this.normalized) w = normalize(w, this.array);\n\t\tthis.array[index * this.itemSize + 3] = w;\n\t\treturn this;\n\t}\n\n\tsetXY(index, x, y) {\n\t\tindex *= this.itemSize;\n\n\t\tif (this.normalized) {\n\t\t\tx = normalize(x, this.array);\n\t\t\ty = normalize(y, this.array);\n\t\t}\n\n\t\tthis.array[index + 0] = x;\n\t\tthis.array[index + 1] = y;\n\t\treturn this;\n\t}\n\n\tsetXYZ(index, x, y, z) {\n\t\tindex *= this.itemSize;\n\n\t\tif (this.normalized) {\n\t\t\tx = normalize(x, this.array);\n\t\t\ty = normalize(y, this.array);\n\t\t\tz = normalize(z, this.array);\n\t\t}\n\n\t\tthis.array[index + 0] = x;\n\t\tthis.array[index + 1] = y;\n\t\tthis.array[index + 2] = z;\n\t\treturn this;\n\t}\n\n\tsetXYZW(index, x, y, z, w) {\n\t\tindex *= this.itemSize;\n\n\t\tif (this.normalized) {\n\t\t\tx = normalize(x, this.array);\n\t\t\ty = normalize(y, this.array);\n\t\t\tz = normalize(z, this.array);\n\t\t\tw = normalize(w, this.array);\n\t\t}\n\n\t\tthis.array[index + 0] = x;\n\t\tthis.array[index + 1] = y;\n\t\tthis.array[index + 2] = z;\n\t\tthis.array[index + 3] = w;\n\t\treturn this;\n\t}\n\n\tonUpload(callback) {\n\t\tthis.onUploadCallback = callback;\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\treturn new this.constructor(this.array, this.itemSize).copy(this);\n\t}\n\n\ttoJSON() {\n\t\tconst data = {\n\t\t\titemSize: this.itemSize,\n\t\t\ttype: this.array.constructor.name,\n\t\t\tarray: Array.from(this.array),\n\t\t\tnormalized: this.normalized\n\t\t};\n\t\tif (this.name !== '') data.name = this.name;\n\t\tif (this.usage !== StaticDrawUsage) data.usage = this.usage;\n\t\tif (this.updateRange.offset !== 0 || this.updateRange.count !== -1) data.updateRange = this.updateRange;\n\t\treturn data;\n\t} // @deprecated\n\n\n\tcopyColorsArray() {\n\t\tconsole.error('THREE.BufferAttribute: copyColorsArray() was removed in r144.');\n\t}\n\n\tcopyVector2sArray() {\n\t\tconsole.error('THREE.BufferAttribute: copyVector2sArray() was removed in r144.');\n\t}\n\n\tcopyVector3sArray() {\n\t\tconsole.error('THREE.BufferAttribute: copyVector3sArray() was removed in r144.');\n\t}\n\n\tcopyVector4sArray() {\n\t\tconsole.error('THREE.BufferAttribute: copyVector4sArray() was removed in r144.');\n\t}\n\n} //\n\n\nclass Int8BufferAttribute extends BufferAttribute {\n\tconstructor(array, itemSize, normalized) {\n\t\tsuper(new Int8Array(array), itemSize, normalized);\n\t}\n\n}\n\nclass Uint8BufferAttribute extends BufferAttribute {\n\tconstructor(array, itemSize, normalized) {\n\t\tsuper(new Uint8Array(array), itemSize, normalized);\n\t}\n\n}\n\nclass Uint8ClampedBufferAttribute extends BufferAttribute {\n\tconstructor(array, itemSize, normalized) {\n\t\tsuper(new Uint8ClampedArray(array), itemSize, normalized);\n\t}\n\n}\n\nclass Int16BufferAttribute extends BufferAttribute {\n\tconstructor(array, itemSize, normalized) {\n\t\tsuper(new Int16Array(array), itemSize, normalized);\n\t}\n\n}\n\nclass Uint16BufferAttribute extends BufferAttribute {\n\tconstructor(array, itemSize, normalized) {\n\t\tsuper(new Uint16Array(array), itemSize, normalized);\n\t}\n\n}\n\nclass Int32BufferAttribute extends BufferAttribute {\n\tconstructor(array, itemSize, normalized) {\n\t\tsuper(new Int32Array(array), itemSize, normalized);\n\t}\n\n}\n\nclass Uint32BufferAttribute extends BufferAttribute {\n\tconstructor(array, itemSize, normalized) {\n\t\tsuper(new Uint32Array(array), itemSize, normalized);\n\t}\n\n}\n\nclass Float16BufferAttribute extends BufferAttribute {\n\tconstructor(array, itemSize, normalized) {\n\t\tsuper(new Uint16Array(array), itemSize, normalized);\n\t\tthis.isFloat16BufferAttribute = true;\n\t}\n\n}\n\nclass Float32BufferAttribute extends BufferAttribute {\n\tconstructor(array, itemSize, normalized) {\n\t\tsuper(new Float32Array(array), itemSize, normalized);\n\t}\n\n}\n\nclass Float64BufferAttribute extends BufferAttribute {\n\tconstructor(array, itemSize, normalized) {\n\t\tsuper(new Float64Array(array), itemSize, normalized);\n\t}\n\n} //\n\nlet _id$1 = 0;\n\nconst _m1 = /*@__PURE__*/new Matrix4();\n\nconst _obj = /*@__PURE__*/new Object3D();\n\nconst _offset = /*@__PURE__*/new Vector3();\n\nconst _box$1 = /*@__PURE__*/new Box3();\n\nconst _boxMorphTargets = /*@__PURE__*/new Box3();\n\nconst _vector$8 = /*@__PURE__*/new Vector3();\n\nclass BufferGeometry extends EventDispatcher {\n\tconstructor() {\n\t\tsuper();\n\t\tthis.isBufferGeometry = true;\n\t\tObject.defineProperty(this, 'id', {\n\t\t\tvalue: _id$1++\n\t\t});\n\t\tthis.uuid = generateUUID();\n\t\tthis.name = '';\n\t\tthis.type = 'BufferGeometry';\n\t\tthis.index = null;\n\t\tthis.attributes = {};\n\t\tthis.morphAttributes = {};\n\t\tthis.morphTargetsRelative = false;\n\t\tthis.groups = [];\n\t\tthis.boundingBox = null;\n\t\tthis.boundingSphere = null;\n\t\tthis.drawRange = {\n\t\t\tstart: 0,\n\t\t\tcount: Infinity\n\t\t};\n\t\tthis.userData = {};\n\t}\n\n\tgetIndex() {\n\t\treturn this.index;\n\t}\n\n\tsetIndex(index) {\n\t\tif (Array.isArray(index)) {\n\t\t\tthis.index = new (arrayNeedsUint32(index) ? Uint32BufferAttribute : Uint16BufferAttribute)(index, 1);\n\t\t} else {\n\t\t\tthis.index = index;\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tgetAttribute(name) {\n\t\treturn this.attributes[name];\n\t}\n\n\tsetAttribute(name, attribute) {\n\t\tthis.attributes[name] = attribute;\n\t\treturn this;\n\t}\n\n\tdeleteAttribute(name) {\n\t\tdelete this.attributes[name];\n\t\treturn this;\n\t}\n\n\thasAttribute(name) {\n\t\treturn this.attributes[name] !== undefined;\n\t}\n\n\taddGroup(start, count, materialIndex = 0) {\n\t\tthis.groups.push({\n\t\t\tstart: start,\n\t\t\tcount: count,\n\t\t\tmaterialIndex: materialIndex\n\t\t});\n\t}\n\n\tclearGroups() {\n\t\tthis.groups = [];\n\t}\n\n\tsetDrawRange(start, count) {\n\t\tthis.drawRange.start = start;\n\t\tthis.drawRange.count = count;\n\t}\n\n\tapplyMatrix4(matrix) {\n\t\tconst position = this.attributes.position;\n\n\t\tif (position !== undefined) {\n\t\t\tposition.applyMatrix4(matrix);\n\t\t\tposition.needsUpdate = true;\n\t\t}\n\n\t\tconst normal = this.attributes.normal;\n\n\t\tif (normal !== undefined) {\n\t\t\tconst normalMatrix = new Matrix3().getNormalMatrix(matrix);\n\t\t\tnormal.applyNormalMatrix(normalMatrix);\n\t\t\tnormal.needsUpdate = true;\n\t\t}\n\n\t\tconst tangent = this.attributes.tangent;\n\n\t\tif (tangent !== undefined) {\n\t\t\ttangent.transformDirection(matrix);\n\t\t\ttangent.needsUpdate = true;\n\t\t}\n\n\t\tif (this.boundingBox !== null) {\n\t\t\tthis.computeBoundingBox();\n\t\t}\n\n\t\tif (this.boundingSphere !== null) {\n\t\t\tthis.computeBoundingSphere();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tapplyQuaternion(q) {\n\t\t_m1.makeRotationFromQuaternion(q);\n\n\t\tthis.applyMatrix4(_m1);\n\t\treturn this;\n\t}\n\n\trotateX(angle) {\n\t\t// rotate geometry around world x-axis\n\t\t_m1.makeRotationX(angle);\n\n\t\tthis.applyMatrix4(_m1);\n\t\treturn this;\n\t}\n\n\trotateY(angle) {\n\t\t// rotate geometry around world y-axis\n\t\t_m1.makeRotationY(angle);\n\n\t\tthis.applyMatrix4(_m1);\n\t\treturn this;\n\t}\n\n\trotateZ(angle) {\n\t\t// rotate geometry around world z-axis\n\t\t_m1.makeRotationZ(angle);\n\n\t\tthis.applyMatrix4(_m1);\n\t\treturn this;\n\t}\n\n\ttranslate(x, y, z) {\n\t\t// translate geometry\n\t\t_m1.makeTranslation(x, y, z);\n\n\t\tthis.applyMatrix4(_m1);\n\t\treturn this;\n\t}\n\n\tscale(x, y, z) {\n\t\t// scale geometry\n\t\t_m1.makeScale(x, y, z);\n\n\t\tthis.applyMatrix4(_m1);\n\t\treturn this;\n\t}\n\n\tlookAt(vector) {\n\t\t_obj.lookAt(vector);\n\n\t\t_obj.updateMatrix();\n\n\t\tthis.applyMatrix4(_obj.matrix);\n\t\treturn this;\n\t}\n\n\tcenter() {\n\t\tthis.computeBoundingBox();\n\t\tthis.boundingBox.getCenter(_offset).negate();\n\t\tthis.translate(_offset.x, _offset.y, _offset.z);\n\t\treturn this;\n\t}\n\n\tsetFromPoints(points) {\n\t\tconst position = [];\n\n\t\tfor (let i = 0, l = points.length; i < l; i++) {\n\t\t\tconst point = points[i];\n\t\t\tposition.push(point.x, point.y, point.z || 0);\n\t\t}\n\n\t\tthis.setAttribute('position', new Float32BufferAttribute(position, 3));\n\t\treturn this;\n\t}\n\n\tcomputeBoundingBox() {\n\t\tif (this.boundingBox === null) {\n\t\t\tthis.boundingBox = new Box3();\n\t\t}\n\n\t\tconst position = this.attributes.position;\n\t\tconst morphAttributesPosition = this.morphAttributes.position;\n\n\t\tif (position && position.isGLBufferAttribute) {\n\t\t\tconsole.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set \"mesh.frustumCulled\" to \"false\".', this);\n\t\t\tthis.boundingBox.set(new Vector3(-Infinity, -Infinity, -Infinity), new Vector3(+Infinity, +Infinity, +Infinity));\n\t\t\treturn;\n\t\t}\n\n\t\tif (position !== undefined) {\n\t\t\tthis.boundingBox.setFromBufferAttribute(position); // process morph attributes if present\n\n\t\t\tif (morphAttributesPosition) {\n\t\t\t\tfor (let i = 0, il = morphAttributesPosition.length; i < il; i++) {\n\t\t\t\t\tconst morphAttribute = morphAttributesPosition[i];\n\n\t\t\t\t\t_box$1.setFromBufferAttribute(morphAttribute);\n\n\t\t\t\t\tif (this.morphTargetsRelative) {\n\t\t\t\t\t\t_vector$8.addVectors(this.boundingBox.min, _box$1.min);\n\n\t\t\t\t\t\tthis.boundingBox.expandByPoint(_vector$8);\n\n\t\t\t\t\t\t_vector$8.addVectors(this.boundingBox.max, _box$1.max);\n\n\t\t\t\t\t\tthis.boundingBox.expandByPoint(_vector$8);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.boundingBox.expandByPoint(_box$1.min);\n\t\t\t\t\t\tthis.boundingBox.expandByPoint(_box$1.max);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthis.boundingBox.makeEmpty();\n\t\t}\n\n\t\tif (isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) {\n\t\t\tconsole.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The \"position\" attribute is likely to have NaN values.', this);\n\t\t}\n\t}\n\n\tcomputeBoundingSphere() {\n\t\tif (this.boundingSphere === null) {\n\t\t\tthis.boundingSphere = new Sphere();\n\t\t}\n\n\t\tconst position = this.attributes.position;\n\t\tconst morphAttributesPosition = this.morphAttributes.position;\n\n\t\tif (position && position.isGLBufferAttribute) {\n\t\t\tconsole.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set \"mesh.frustumCulled\" to \"false\".', this);\n\t\t\tthis.boundingSphere.set(new Vector3(), Infinity);\n\t\t\treturn;\n\t\t}\n\n\t\tif (position) {\n\t\t\t// first, find the center of the bounding sphere\n\t\t\tconst center = this.boundingSphere.center;\n\n\t\t\t_box$1.setFromBufferAttribute(position); // process morph attributes if present\n\n\n\t\t\tif (morphAttributesPosition) {\n\t\t\t\tfor (let i = 0, il = morphAttributesPosition.length; i < il; i++) {\n\t\t\t\t\tconst morphAttribute = morphAttributesPosition[i];\n\n\t\t\t\t\t_boxMorphTargets.setFromBufferAttribute(morphAttribute);\n\n\t\t\t\t\tif (this.morphTargetsRelative) {\n\t\t\t\t\t\t_vector$8.addVectors(_box$1.min, _boxMorphTargets.min);\n\n\t\t\t\t\t\t_box$1.expandByPoint(_vector$8);\n\n\t\t\t\t\t\t_vector$8.addVectors(_box$1.max, _boxMorphTargets.max);\n\n\t\t\t\t\t\t_box$1.expandByPoint(_vector$8);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t_box$1.expandByPoint(_boxMorphTargets.min);\n\n\t\t\t\t\t\t_box$1.expandByPoint(_boxMorphTargets.max);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t_box$1.getCenter(center); // second, try to find a boundingSphere with a radius smaller than the\n\t\t\t// boundingSphere of the boundingBox: sqrt(3) smaller in the best case\n\n\n\t\t\tlet maxRadiusSq = 0;\n\n\t\t\tfor (let i = 0, il = position.count; i < il; i++) {\n\t\t\t\t_vector$8.fromBufferAttribute(position, i);\n\n\t\t\t\tmaxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(_vector$8));\n\t\t\t} // process morph attributes if present\n\n\n\t\t\tif (morphAttributesPosition) {\n\t\t\t\tfor (let i = 0, il = morphAttributesPosition.length; i < il; i++) {\n\t\t\t\t\tconst morphAttribute = morphAttributesPosition[i];\n\t\t\t\t\tconst morphTargetsRelative = this.morphTargetsRelative;\n\n\t\t\t\t\tfor (let j = 0, jl = morphAttribute.count; j < jl; j++) {\n\t\t\t\t\t\t_vector$8.fromBufferAttribute(morphAttribute, j);\n\n\t\t\t\t\t\tif (morphTargetsRelative) {\n\t\t\t\t\t\t\t_offset.fromBufferAttribute(position, j);\n\n\t\t\t\t\t\t\t_vector$8.add(_offset);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tmaxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(_vector$8));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.boundingSphere.radius = Math.sqrt(maxRadiusSq);\n\n\t\t\tif (isNaN(this.boundingSphere.radius)) {\n\t\t\t\tconsole.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The \"position\" attribute is likely to have NaN values.', this);\n\t\t\t}\n\t\t}\n\t}\n\n\tcomputeTangents() {\n\t\tconst index = this.index;\n\t\tconst attributes = this.attributes; // based on http://www.terathon.com/code/tangent.html\n\t\t// (per vertex tangents)\n\n\t\tif (index === null || attributes.position === undefined || attributes.normal === undefined || attributes.uv === undefined) {\n\t\t\tconsole.error('THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)');\n\t\t\treturn;\n\t\t}\n\n\t\tconst indices = index.array;\n\t\tconst positions = attributes.position.array;\n\t\tconst normals = attributes.normal.array;\n\t\tconst uvs = attributes.uv.array;\n\t\tconst nVertices = positions.length / 3;\n\n\t\tif (this.hasAttribute('tangent') === false) {\n\t\t\tthis.setAttribute('tangent', new BufferAttribute(new Float32Array(4 * nVertices), 4));\n\t\t}\n\n\t\tconst tangents = this.getAttribute('tangent').array;\n\t\tconst tan1 = [],\n\t\t\t\t\ttan2 = [];\n\n\t\tfor (let i = 0; i < nVertices; i++) {\n\t\t\ttan1[i] = new Vector3();\n\t\t\ttan2[i] = new Vector3();\n\t\t}\n\n\t\tconst vA = new Vector3(),\n\t\t\t\t\tvB = new Vector3(),\n\t\t\t\t\tvC = new Vector3(),\n\t\t\t\t\tuvA = new Vector2(),\n\t\t\t\t\tuvB = new Vector2(),\n\t\t\t\t\tuvC = new Vector2(),\n\t\t\t\t\tsdir = new Vector3(),\n\t\t\t\t\ttdir = new Vector3();\n\n\t\tfunction handleTriangle(a, b, c) {\n\t\t\tvA.fromArray(positions, a * 3);\n\t\t\tvB.fromArray(positions, b * 3);\n\t\t\tvC.fromArray(positions, c * 3);\n\t\t\tuvA.fromArray(uvs, a * 2);\n\t\t\tuvB.fromArray(uvs, b * 2);\n\t\t\tuvC.fromArray(uvs, c * 2);\n\t\t\tvB.sub(vA);\n\t\t\tvC.sub(vA);\n\t\t\tuvB.sub(uvA);\n\t\t\tuvC.sub(uvA);\n\t\t\tconst r = 1.0 / (uvB.x * uvC.y - uvC.x * uvB.y); // silently ignore degenerate uv triangles having coincident or colinear vertices\n\n\t\t\tif (!isFinite(r)) return;\n\t\t\tsdir.copy(vB).multiplyScalar(uvC.y).addScaledVector(vC, -uvB.y).multiplyScalar(r);\n\t\t\ttdir.copy(vC).multiplyScalar(uvB.x).addScaledVector(vB, -uvC.x).multiplyScalar(r);\n\t\t\ttan1[a].add(sdir);\n\t\t\ttan1[b].add(sdir);\n\t\t\ttan1[c].add(sdir);\n\t\t\ttan2[a].add(tdir);\n\t\t\ttan2[b].add(tdir);\n\t\t\ttan2[c].add(tdir);\n\t\t}\n\n\t\tlet groups = this.groups;\n\n\t\tif (groups.length === 0) {\n\t\t\tgroups = [{\n\t\t\t\tstart: 0,\n\t\t\t\tcount: indices.length\n\t\t\t}];\n\t\t}\n\n\t\tfor (let i = 0, il = groups.length; i < il; ++i) {\n\t\t\tconst group = groups[i];\n\t\t\tconst start = group.start;\n\t\t\tconst count = group.count;\n\n\t\t\tfor (let j = start, jl = start + count; j < jl; j += 3) {\n\t\t\t\thandleTriangle(indices[j + 0], indices[j + 1], indices[j + 2]);\n\t\t\t}\n\t\t}\n\n\t\tconst tmp = new Vector3(),\n\t\t\t\t\ttmp2 = new Vector3();\n\t\tconst n = new Vector3(),\n\t\t\t\t\tn2 = new Vector3();\n\n\t\tfunction handleVertex(v) {\n\t\t\tn.fromArray(normals, v * 3);\n\t\t\tn2.copy(n);\n\t\t\tconst t = tan1[v]; // Gram-Schmidt orthogonalize\n\n\t\t\ttmp.copy(t);\n\t\t\ttmp.sub(n.multiplyScalar(n.dot(t))).normalize(); // Calculate handedness\n\n\t\t\ttmp2.crossVectors(n2, t);\n\t\t\tconst test = tmp2.dot(tan2[v]);\n\t\t\tconst w = test < 0.0 ? -1.0 : 1.0;\n\t\t\ttangents[v * 4] = tmp.x;\n\t\t\ttangents[v * 4 + 1] = tmp.y;\n\t\t\ttangents[v * 4 + 2] = tmp.z;\n\t\t\ttangents[v * 4 + 3] = w;\n\t\t}\n\n\t\tfor (let i = 0, il = groups.length; i < il; ++i) {\n\t\t\tconst group = groups[i];\n\t\t\tconst start = group.start;\n\t\t\tconst count = group.count;\n\n\t\t\tfor (let j = start, jl = start + count; j < jl; j += 3) {\n\t\t\t\thandleVertex(indices[j + 0]);\n\t\t\t\thandleVertex(indices[j + 1]);\n\t\t\t\thandleVertex(indices[j + 2]);\n\t\t\t}\n\t\t}\n\t}\n\n\tcomputeVertexNormals() {\n\t\tconst index = this.index;\n\t\tconst positionAttribute = this.getAttribute('position');\n\n\t\tif (positionAttribute !== undefined) {\n\t\t\tlet normalAttribute = this.getAttribute('normal');\n\n\t\t\tif (normalAttribute === undefined) {\n\t\t\t\tnormalAttribute = new BufferAttribute(new Float32Array(positionAttribute.count * 3), 3);\n\t\t\t\tthis.setAttribute('normal', normalAttribute);\n\t\t\t} else {\n\t\t\t\t// reset existing normals to zero\n\t\t\t\tfor (let i = 0, il = normalAttribute.count; i < il; i++) {\n\t\t\t\t\tnormalAttribute.setXYZ(i, 0, 0, 0);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst pA = new Vector3(),\n\t\t\t\t\t\tpB = new Vector3(),\n\t\t\t\t\t\tpC = new Vector3();\n\t\t\tconst nA = new Vector3(),\n\t\t\t\t\t\tnB = new Vector3(),\n\t\t\t\t\t\tnC = new Vector3();\n\t\t\tconst cb = new Vector3(),\n\t\t\t\t\t\tab = new Vector3(); // indexed elements\n\n\t\t\tif (index) {\n\t\t\t\tfor (let i = 0, il = index.count; i < il; i += 3) {\n\t\t\t\t\tconst vA = index.getX(i + 0);\n\t\t\t\t\tconst vB = index.getX(i + 1);\n\t\t\t\t\tconst vC = index.getX(i + 2);\n\t\t\t\t\tpA.fromBufferAttribute(positionAttribute, vA);\n\t\t\t\t\tpB.fromBufferAttribute(positionAttribute, vB);\n\t\t\t\t\tpC.fromBufferAttribute(positionAttribute, vC);\n\t\t\t\t\tcb.subVectors(pC, pB);\n\t\t\t\t\tab.subVectors(pA, pB);\n\t\t\t\t\tcb.cross(ab);\n\t\t\t\t\tnA.fromBufferAttribute(normalAttribute, vA);\n\t\t\t\t\tnB.fromBufferAttribute(normalAttribute, vB);\n\t\t\t\t\tnC.fromBufferAttribute(normalAttribute, vC);\n\t\t\t\t\tnA.add(cb);\n\t\t\t\t\tnB.add(cb);\n\t\t\t\t\tnC.add(cb);\n\t\t\t\t\tnormalAttribute.setXYZ(vA, nA.x, nA.y, nA.z);\n\t\t\t\t\tnormalAttribute.setXYZ(vB, nB.x, nB.y, nB.z);\n\t\t\t\t\tnormalAttribute.setXYZ(vC, nC.x, nC.y, nC.z);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// non-indexed elements (unconnected triangle soup)\n\t\t\t\tfor (let i = 0, il = positionAttribute.count; i < il; i += 3) {\n\t\t\t\t\tpA.fromBufferAttribute(positionAttribute, i + 0);\n\t\t\t\t\tpB.fromBufferAttribute(positionAttribute, i + 1);\n\t\t\t\t\tpC.fromBufferAttribute(positionAttribute, i + 2);\n\t\t\t\t\tcb.subVectors(pC, pB);\n\t\t\t\t\tab.subVectors(pA, pB);\n\t\t\t\t\tcb.cross(ab);\n\t\t\t\t\tnormalAttribute.setXYZ(i + 0, cb.x, cb.y, cb.z);\n\t\t\t\t\tnormalAttribute.setXYZ(i + 1, cb.x, cb.y, cb.z);\n\t\t\t\t\tnormalAttribute.setXYZ(i + 2, cb.x, cb.y, cb.z);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.normalizeNormals();\n\t\t\tnormalAttribute.needsUpdate = true;\n\t\t}\n\t} // @deprecated since r144\n\n\n\tmerge() {\n\t\tconsole.error('THREE.BufferGeometry.merge() has been removed. Use THREE.BufferGeometryUtils.mergeBufferGeometries() instead.');\n\t\treturn this;\n\t}\n\n\tnormalizeNormals() {\n\t\tconst normals = this.attributes.normal;\n\n\t\tfor (let i = 0, il = normals.count; i < il; i++) {\n\t\t\t_vector$8.fromBufferAttribute(normals, i);\n\n\t\t\t_vector$8.normalize();\n\n\t\t\tnormals.setXYZ(i, _vector$8.x, _vector$8.y, _vector$8.z);\n\t\t}\n\t}\n\n\ttoNonIndexed() {\n\t\tfunction convertBufferAttribute(attribute, indices) {\n\t\t\tconst array = attribute.array;\n\t\t\tconst itemSize = attribute.itemSize;\n\t\t\tconst normalized = attribute.normalized;\n\t\t\tconst array2 = new array.constructor(indices.length * itemSize);\n\t\t\tlet index = 0,\n\t\t\t\t\tindex2 = 0;\n\n\t\t\tfor (let i = 0, l = indices.length; i < l; i++) {\n\t\t\t\tif (attribute.isInterleavedBufferAttribute) {\n\t\t\t\t\tindex = indices[i] * attribute.data.stride + attribute.offset;\n\t\t\t\t} else {\n\t\t\t\t\tindex = indices[i] * itemSize;\n\t\t\t\t}\n\n\t\t\t\tfor (let j = 0; j < itemSize; j++) {\n\t\t\t\t\tarray2[index2++] = array[index++];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn new BufferAttribute(array2, itemSize, normalized);\n\t\t} //\n\n\n\t\tif (this.index === null) {\n\t\t\tconsole.warn('THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.');\n\t\t\treturn this;\n\t\t}\n\n\t\tconst geometry2 = new BufferGeometry();\n\t\tconst indices = this.index.array;\n\t\tconst attributes = this.attributes; // attributes\n\n\t\tfor (const name in attributes) {\n\t\t\tconst attribute = attributes[name];\n\t\t\tconst newAttribute = convertBufferAttribute(attribute, indices);\n\t\t\tgeometry2.setAttribute(name, newAttribute);\n\t\t} // morph attributes\n\n\n\t\tconst morphAttributes = this.morphAttributes;\n\n\t\tfor (const name in morphAttributes) {\n\t\t\tconst morphArray = [];\n\t\t\tconst morphAttribute = morphAttributes[name]; // morphAttribute: array of Float32BufferAttributes\n\n\t\t\tfor (let i = 0, il = morphAttribute.length; i < il; i++) {\n\t\t\t\tconst attribute = morphAttribute[i];\n\t\t\t\tconst newAttribute = convertBufferAttribute(attribute, indices);\n\t\t\t\tmorphArray.push(newAttribute);\n\t\t\t}\n\n\t\t\tgeometry2.morphAttributes[name] = morphArray;\n\t\t}\n\n\t\tgeometry2.morphTargetsRelative = this.morphTargetsRelative; // groups\n\n\t\tconst groups = this.groups;\n\n\t\tfor (let i = 0, l = groups.length; i < l; i++) {\n\t\t\tconst group = groups[i];\n\t\t\tgeometry2.addGroup(group.start, group.count, group.materialIndex);\n\t\t}\n\n\t\treturn geometry2;\n\t}\n\n\ttoJSON() {\n\t\tconst data = {\n\t\t\tmetadata: {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'BufferGeometry',\n\t\t\t\tgenerator: 'BufferGeometry.toJSON'\n\t\t\t}\n\t\t}; // standard BufferGeometry serialization\n\n\t\tdata.uuid = this.uuid;\n\t\tdata.type = this.type;\n\t\tif (this.name !== '') data.name = this.name;\n\t\tif (Object.keys(this.userData).length > 0) data.userData = this.userData;\n\n\t\tif (this.parameters !== undefined) {\n\t\t\tconst parameters = this.parameters;\n\n\t\t\tfor (const key in parameters) {\n\t\t\t\tif (parameters[key] !== undefined) data[key] = parameters[key];\n\t\t\t}\n\n\t\t\treturn data;\n\t\t} // for simplicity the code assumes attributes are not shared across geometries, see #15811\n\n\n\t\tdata.data = {\n\t\t\tattributes: {}\n\t\t};\n\t\tconst index = this.index;\n\n\t\tif (index !== null) {\n\t\t\tdata.data.index = {\n\t\t\t\ttype: index.array.constructor.name,\n\t\t\t\tarray: Array.prototype.slice.call(index.array)\n\t\t\t};\n\t\t}\n\n\t\tconst attributes = this.attributes;\n\n\t\tfor (const key in attributes) {\n\t\t\tconst attribute = attributes[key];\n\t\t\tdata.data.attributes[key] = attribute.toJSON(data.data);\n\t\t}\n\n\t\tconst morphAttributes = {};\n\t\tlet hasMorphAttributes = false;\n\n\t\tfor (const key in this.morphAttributes) {\n\t\t\tconst attributeArray = this.morphAttributes[key];\n\t\t\tconst array = [];\n\n\t\t\tfor (let i = 0, il = attributeArray.length; i < il; i++) {\n\t\t\t\tconst attribute = attributeArray[i];\n\t\t\t\tarray.push(attribute.toJSON(data.data));\n\t\t\t}\n\n\t\t\tif (array.length > 0) {\n\t\t\t\tmorphAttributes[key] = array;\n\t\t\t\thasMorphAttributes = true;\n\t\t\t}\n\t\t}\n\n\t\tif (hasMorphAttributes) {\n\t\t\tdata.data.morphAttributes = morphAttributes;\n\t\t\tdata.data.morphTargetsRelative = this.morphTargetsRelative;\n\t\t}\n\n\t\tconst groups = this.groups;\n\n\t\tif (groups.length > 0) {\n\t\t\tdata.data.groups = JSON.parse(JSON.stringify(groups));\n\t\t}\n\n\t\tconst boundingSphere = this.boundingSphere;\n\n\t\tif (boundingSphere !== null) {\n\t\t\tdata.data.boundingSphere = {\n\t\t\t\tcenter: boundingSphere.center.toArray(),\n\t\t\t\tradius: boundingSphere.radius\n\t\t\t};\n\t\t}\n\n\t\treturn data;\n\t}\n\n\tclone() {\n\t\treturn new this.constructor().copy(this);\n\t}\n\n\tcopy(source) {\n\t\t// reset\n\t\tthis.index = null;\n\t\tthis.attributes = {};\n\t\tthis.morphAttributes = {};\n\t\tthis.groups = [];\n\t\tthis.boundingBox = null;\n\t\tthis.boundingSphere = null; // used for storing cloned, shared data\n\n\t\tconst data = {}; // name\n\n\t\tthis.name = source.name; // index\n\n\t\tconst index = source.index;\n\n\t\tif (index !== null) {\n\t\t\tthis.setIndex(index.clone(data));\n\t\t} // attributes\n\n\n\t\tconst attributes = source.attributes;\n\n\t\tfor (const name in attributes) {\n\t\t\tconst attribute = attributes[name];\n\t\t\tthis.setAttribute(name, attribute.clone(data));\n\t\t} // morph attributes\n\n\n\t\tconst morphAttributes = source.morphAttributes;\n\n\t\tfor (const name in morphAttributes) {\n\t\t\tconst array = [];\n\t\t\tconst morphAttribute = morphAttributes[name]; // morphAttribute: array of Float32BufferAttributes\n\n\t\t\tfor (let i = 0, l = morphAttribute.length; i < l; i++) {\n\t\t\t\tarray.push(morphAttribute[i].clone(data));\n\t\t\t}\n\n\t\t\tthis.morphAttributes[name] = array;\n\t\t}\n\n\t\tthis.morphTargetsRelative = source.morphTargetsRelative; // groups\n\n\t\tconst groups = source.groups;\n\n\t\tfor (let i = 0, l = groups.length; i < l; i++) {\n\t\t\tconst group = groups[i];\n\t\t\tthis.addGroup(group.start, group.count, group.materialIndex);\n\t\t} // bounding box\n\n\n\t\tconst boundingBox = source.boundingBox;\n\n\t\tif (boundingBox !== null) {\n\t\t\tthis.boundingBox = boundingBox.clone();\n\t\t} // bounding sphere\n\n\n\t\tconst boundingSphere = source.boundingSphere;\n\n\t\tif (boundingSphere !== null) {\n\t\t\tthis.boundingSphere = boundingSphere.clone();\n\t\t} // draw range\n\n\n\t\tthis.drawRange.start = source.drawRange.start;\n\t\tthis.drawRange.count = source.drawRange.count; // user data\n\n\t\tthis.userData = source.userData; // geometry generator parameters\n\n\t\tif (source.parameters !== undefined) this.parameters = Object.assign({}, source.parameters);\n\t\treturn this;\n\t}\n\n\tdispose() {\n\t\tthis.dispatchEvent({\n\t\t\ttype: 'dispose'\n\t\t});\n\t}\n\n}\n\nconst _inverseMatrix$2 = /*@__PURE__*/new Matrix4();\n\nconst _ray$2 = /*@__PURE__*/new Ray();\n\nconst _sphere$3 = /*@__PURE__*/new Sphere();\n\nconst _vA$1 = /*@__PURE__*/new Vector3();\n\nconst _vB$1 = /*@__PURE__*/new Vector3();\n\nconst _vC$1 = /*@__PURE__*/new Vector3();\n\nconst _tempA = /*@__PURE__*/new Vector3();\n\nconst _tempB = /*@__PURE__*/new Vector3();\n\nconst _tempC = /*@__PURE__*/new Vector3();\n\nconst _morphA = /*@__PURE__*/new Vector3();\n\nconst _morphB = /*@__PURE__*/new Vector3();\n\nconst _morphC = /*@__PURE__*/new Vector3();\n\nconst _uvA$1 = /*@__PURE__*/new Vector2();\n\nconst _uvB$1 = /*@__PURE__*/new Vector2();\n\nconst _uvC$1 = /*@__PURE__*/new Vector2();\n\nconst _intersectionPoint = /*@__PURE__*/new Vector3();\n\nconst _intersectionPointWorld = /*@__PURE__*/new Vector3();\n\nclass Mesh extends Object3D {\n\tconstructor(geometry = new BufferGeometry(), material = new MeshBasicMaterial()) {\n\t\tsuper();\n\t\tthis.isMesh = true;\n\t\tthis.type = 'Mesh';\n\t\tthis.geometry = geometry;\n\t\tthis.material = material;\n\t\tthis.updateMorphTargets();\n\t}\n\n\tcopy(source, recursive) {\n\t\tsuper.copy(source, recursive);\n\n\t\tif (source.morphTargetInfluences !== undefined) {\n\t\t\tthis.morphTargetInfluences = source.morphTargetInfluences.slice();\n\t\t}\n\n\t\tif (source.morphTargetDictionary !== undefined) {\n\t\t\tthis.morphTargetDictionary = Object.assign({}, source.morphTargetDictionary);\n\t\t}\n\n\t\tthis.material = source.material;\n\t\tthis.geometry = source.geometry;\n\t\treturn this;\n\t}\n\n\tupdateMorphTargets() {\n\t\tconst geometry = this.geometry;\n\t\tconst morphAttributes = geometry.morphAttributes;\n\t\tconst keys = Object.keys(morphAttributes);\n\n\t\tif (keys.length > 0) {\n\t\t\tconst morphAttribute = morphAttributes[keys[0]];\n\n\t\t\tif (morphAttribute !== undefined) {\n\t\t\t\tthis.morphTargetInfluences = [];\n\t\t\t\tthis.morphTargetDictionary = {};\n\n\t\t\t\tfor (let m = 0, ml = morphAttribute.length; m < ml; m++) {\n\t\t\t\t\tconst name = morphAttribute[m].name || String(m);\n\t\t\t\t\tthis.morphTargetInfluences.push(0);\n\t\t\t\t\tthis.morphTargetDictionary[name] = m;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\traycast(raycaster, intersects) {\n\t\tconst geometry = this.geometry;\n\t\tconst material = this.material;\n\t\tconst matrixWorld = this.matrixWorld;\n\t\tif (material === undefined) return; // Checking boundingSphere distance to ray\n\n\t\tif (geometry.boundingSphere === null) geometry.computeBoundingSphere();\n\n\t\t_sphere$3.copy(geometry.boundingSphere);\n\n\t\t_sphere$3.applyMatrix4(matrixWorld);\n\n\t\tif (raycaster.ray.intersectsSphere(_sphere$3) === false) return; //\n\n\t\t_inverseMatrix$2.copy(matrixWorld).invert();\n\n\t\t_ray$2.copy(raycaster.ray).applyMatrix4(_inverseMatrix$2); // Check boundingBox before continuing\n\n\n\t\tif (geometry.boundingBox !== null) {\n\t\t\tif (_ray$2.intersectsBox(geometry.boundingBox) === false) return;\n\t\t}\n\n\t\tlet intersection;\n\t\tconst index = geometry.index;\n\t\tconst position = geometry.attributes.position;\n\t\tconst morphPosition = geometry.morphAttributes.position;\n\t\tconst morphTargetsRelative = geometry.morphTargetsRelative;\n\t\tconst uv = geometry.attributes.uv;\n\t\tconst uv2 = geometry.attributes.uv2;\n\t\tconst groups = geometry.groups;\n\t\tconst drawRange = geometry.drawRange;\n\n\t\tif (index !== null) {\n\t\t\t// indexed buffer geometry\n\t\t\tif (Array.isArray(material)) {\n\t\t\t\tfor (let i = 0, il = groups.length; i < il; i++) {\n\t\t\t\t\tconst group = groups[i];\n\t\t\t\t\tconst groupMaterial = material[group.materialIndex];\n\t\t\t\t\tconst start = Math.max(group.start, drawRange.start);\n\t\t\t\t\tconst end = Math.min(index.count, Math.min(group.start + group.count, drawRange.start + drawRange.count));\n\n\t\t\t\t\tfor (let j = start, jl = end; j < jl; j += 3) {\n\t\t\t\t\t\tconst a = index.getX(j);\n\t\t\t\t\t\tconst b = index.getX(j + 1);\n\t\t\t\t\t\tconst c = index.getX(j + 2);\n\t\t\t\t\t\tintersection = checkBufferGeometryIntersection(this, groupMaterial, raycaster, _ray$2, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c);\n\n\t\t\t\t\t\tif (intersection) {\n\t\t\t\t\t\t\tintersection.faceIndex = Math.floor(j / 3); // triangle number in indexed buffer semantics\n\n\t\t\t\t\t\t\tintersection.face.materialIndex = group.materialIndex;\n\t\t\t\t\t\t\tintersects.push(intersection);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst start = Math.max(0, drawRange.start);\n\t\t\t\tconst end = Math.min(index.count, drawRange.start + drawRange.count);\n\n\t\t\t\tfor (let i = start, il = end; i < il; i += 3) {\n\t\t\t\t\tconst a = index.getX(i);\n\t\t\t\t\tconst b = index.getX(i + 1);\n\t\t\t\t\tconst c = index.getX(i + 2);\n\t\t\t\t\tintersection = checkBufferGeometryIntersection(this, material, raycaster, _ray$2, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c);\n\n\t\t\t\t\tif (intersection) {\n\t\t\t\t\t\tintersection.faceIndex = Math.floor(i / 3); // triangle number in indexed buffer semantics\n\n\t\t\t\t\t\tintersects.push(intersection);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (position !== undefined) {\n\t\t\t// non-indexed buffer geometry\n\t\t\tif (Array.isArray(material)) {\n\t\t\t\tfor (let i = 0, il = groups.length; i < il; i++) {\n\t\t\t\t\tconst group = groups[i];\n\t\t\t\t\tconst groupMaterial = material[group.materialIndex];\n\t\t\t\t\tconst start = Math.max(group.start, drawRange.start);\n\t\t\t\t\tconst end = Math.min(position.count, Math.min(group.start + group.count, drawRange.start + drawRange.count));\n\n\t\t\t\t\tfor (let j = start, jl = end; j < jl; j += 3) {\n\t\t\t\t\t\tconst a = j;\n\t\t\t\t\t\tconst b = j + 1;\n\t\t\t\t\t\tconst c = j + 2;\n\t\t\t\t\t\tintersection = checkBufferGeometryIntersection(this, groupMaterial, raycaster, _ray$2, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c);\n\n\t\t\t\t\t\tif (intersection) {\n\t\t\t\t\t\t\tintersection.faceIndex = Math.floor(j / 3); // triangle number in non-indexed buffer semantics\n\n\t\t\t\t\t\t\tintersection.face.materialIndex = group.materialIndex;\n\t\t\t\t\t\t\tintersects.push(intersection);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst start = Math.max(0, drawRange.start);\n\t\t\t\tconst end = Math.min(position.count, drawRange.start + drawRange.count);\n\n\t\t\t\tfor (let i = start, il = end; i < il; i += 3) {\n\t\t\t\t\tconst a = i;\n\t\t\t\t\tconst b = i + 1;\n\t\t\t\t\tconst c = i + 2;\n\t\t\t\t\tintersection = checkBufferGeometryIntersection(this, material, raycaster, _ray$2, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c);\n\n\t\t\t\t\tif (intersection) {\n\t\t\t\t\t\tintersection.faceIndex = Math.floor(i / 3); // triangle number in non-indexed buffer semantics\n\n\t\t\t\t\t\tintersects.push(intersection);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n}\n\nfunction checkIntersection(object, material, raycaster, ray, pA, pB, pC, point) {\n\tlet intersect;\n\n\tif (material.side === BackSide) {\n\t\tintersect = ray.intersectTriangle(pC, pB, pA, true, point);\n\t} else {\n\t\tintersect = ray.intersectTriangle(pA, pB, pC, material.side !== DoubleSide, point);\n\t}\n\n\tif (intersect === null) return null;\n\n\t_intersectionPointWorld.copy(point);\n\n\t_intersectionPointWorld.applyMatrix4(object.matrixWorld);\n\n\tconst distance = raycaster.ray.origin.distanceTo(_intersectionPointWorld);\n\tif (distance < raycaster.near || distance > raycaster.far) return null;\n\treturn {\n\t\tdistance: distance,\n\t\tpoint: _intersectionPointWorld.clone(),\n\t\tobject: object\n\t};\n}\n\nfunction checkBufferGeometryIntersection(object, material, raycaster, ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c) {\n\t_vA$1.fromBufferAttribute(position, a);\n\n\t_vB$1.fromBufferAttribute(position, b);\n\n\t_vC$1.fromBufferAttribute(position, c);\n\n\tconst morphInfluences = object.morphTargetInfluences;\n\n\tif (morphPosition && morphInfluences) {\n\t\t_morphA.set(0, 0, 0);\n\n\t\t_morphB.set(0, 0, 0);\n\n\t\t_morphC.set(0, 0, 0);\n\n\t\tfor (let i = 0, il = morphPosition.length; i < il; i++) {\n\t\t\tconst influence = morphInfluences[i];\n\t\t\tconst morphAttribute = morphPosition[i];\n\t\t\tif (influence === 0) continue;\n\n\t\t\t_tempA.fromBufferAttribute(morphAttribute, a);\n\n\t\t\t_tempB.fromBufferAttribute(morphAttribute, b);\n\n\t\t\t_tempC.fromBufferAttribute(morphAttribute, c);\n\n\t\t\tif (morphTargetsRelative) {\n\t\t\t\t_morphA.addScaledVector(_tempA, influence);\n\n\t\t\t\t_morphB.addScaledVector(_tempB, influence);\n\n\t\t\t\t_morphC.addScaledVector(_tempC, influence);\n\t\t\t} else {\n\t\t\t\t_morphA.addScaledVector(_tempA.sub(_vA$1), influence);\n\n\t\t\t\t_morphB.addScaledVector(_tempB.sub(_vB$1), influence);\n\n\t\t\t\t_morphC.addScaledVector(_tempC.sub(_vC$1), influence);\n\t\t\t}\n\t\t}\n\n\t\t_vA$1.add(_morphA);\n\n\t\t_vB$1.add(_morphB);\n\n\t\t_vC$1.add(_morphC);\n\t}\n\n\tif (object.isSkinnedMesh) {\n\t\tobject.boneTransform(a, _vA$1);\n\t\tobject.boneTransform(b, _vB$1);\n\t\tobject.boneTransform(c, _vC$1);\n\t}\n\n\tconst intersection = checkIntersection(object, material, raycaster, ray, _vA$1, _vB$1, _vC$1, _intersectionPoint);\n\n\tif (intersection) {\n\t\tif (uv) {\n\t\t\t_uvA$1.fromBufferAttribute(uv, a);\n\n\t\t\t_uvB$1.fromBufferAttribute(uv, b);\n\n\t\t\t_uvC$1.fromBufferAttribute(uv, c);\n\n\t\t\tintersection.uv = Triangle.getUV(_intersectionPoint, _vA$1, _vB$1, _vC$1, _uvA$1, _uvB$1, _uvC$1, new Vector2());\n\t\t}\n\n\t\tif (uv2) {\n\t\t\t_uvA$1.fromBufferAttribute(uv2, a);\n\n\t\t\t_uvB$1.fromBufferAttribute(uv2, b);\n\n\t\t\t_uvC$1.fromBufferAttribute(uv2, c);\n\n\t\t\tintersection.uv2 = Triangle.getUV(_intersectionPoint, _vA$1, _vB$1, _vC$1, _uvA$1, _uvB$1, _uvC$1, new Vector2());\n\t\t}\n\n\t\tconst face = {\n\t\t\ta: a,\n\t\t\tb: b,\n\t\t\tc: c,\n\t\t\tnormal: new Vector3(),\n\t\t\tmaterialIndex: 0\n\t\t};\n\t\tTriangle.getNormal(_vA$1, _vB$1, _vC$1, face.normal);\n\t\tintersection.face = face;\n\t}\n\n\treturn intersection;\n}\n\nclass BoxGeometry extends BufferGeometry {\n\tconstructor(width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1) {\n\t\tsuper();\n\t\tthis.type = 'BoxGeometry';\n\t\tthis.parameters = {\n\t\t\twidth: width,\n\t\t\theight: height,\n\t\t\tdepth: depth,\n\t\t\twidthSegments: widthSegments,\n\t\t\theightSegments: heightSegments,\n\t\t\tdepthSegments: depthSegments\n\t\t};\n\t\tconst scope = this; // segments\n\n\t\twidthSegments = Math.floor(widthSegments);\n\t\theightSegments = Math.floor(heightSegments);\n\t\tdepthSegments = Math.floor(depthSegments); // buffers\n\n\t\tconst indices = [];\n\t\tconst vertices = [];\n\t\tconst normals = [];\n\t\tconst uvs = []; // helper variables\n\n\t\tlet numberOfVertices = 0;\n\t\tlet groupStart = 0; // build each side of the box geometry\n\n\t\tbuildPlane('z', 'y', 'x', -1, -1, depth, height, width, depthSegments, heightSegments, 0); // px\n\n\t\tbuildPlane('z', 'y', 'x', 1, -1, depth, height, -width, depthSegments, heightSegments, 1); // nx\n\n\t\tbuildPlane('x', 'z', 'y', 1, 1, width, depth, height, widthSegments, depthSegments, 2); // py\n\n\t\tbuildPlane('x', 'z', 'y', 1, -1, width, depth, -height, widthSegments, depthSegments, 3); // ny\n\n\t\tbuildPlane('x', 'y', 'z', 1, -1, width, height, depth, widthSegments, heightSegments, 4); // pz\n\n\t\tbuildPlane('x', 'y', 'z', -1, -1, width, height, -depth, widthSegments, heightSegments, 5); // nz\n\t\t// build geometry\n\n\t\tthis.setIndex(indices);\n\t\tthis.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\tthis.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\t\tthis.setAttribute('uv', new Float32BufferAttribute(uvs, 2));\n\n\t\tfunction buildPlane(u, v, w, udir, vdir, width, height, depth, gridX, gridY, materialIndex) {\n\t\t\tconst segmentWidth = width / gridX;\n\t\t\tconst segmentHeight = height / gridY;\n\t\t\tconst widthHalf = width / 2;\n\t\t\tconst heightHalf = height / 2;\n\t\t\tconst depthHalf = depth / 2;\n\t\t\tconst gridX1 = gridX + 1;\n\t\t\tconst gridY1 = gridY + 1;\n\t\t\tlet vertexCounter = 0;\n\t\t\tlet groupCount = 0;\n\t\t\tconst vector = new Vector3(); // generate vertices, normals and uvs\n\n\t\t\tfor (let iy = 0; iy < gridY1; iy++) {\n\t\t\t\tconst y = iy * segmentHeight - heightHalf;\n\n\t\t\t\tfor (let ix = 0; ix < gridX1; ix++) {\n\t\t\t\t\tconst x = ix * segmentWidth - widthHalf; // set values to correct vector component\n\n\t\t\t\t\tvector[u] = x * udir;\n\t\t\t\t\tvector[v] = y * vdir;\n\t\t\t\t\tvector[w] = depthHalf; // now apply vector to vertex buffer\n\n\t\t\t\t\tvertices.push(vector.x, vector.y, vector.z); // set values to correct vector component\n\n\t\t\t\t\tvector[u] = 0;\n\t\t\t\t\tvector[v] = 0;\n\t\t\t\t\tvector[w] = depth > 0 ? 1 : -1; // now apply vector to normal buffer\n\n\t\t\t\t\tnormals.push(vector.x, vector.y, vector.z); // uvs\n\n\t\t\t\t\tuvs.push(ix / gridX);\n\t\t\t\t\tuvs.push(1 - iy / gridY); // counters\n\n\t\t\t\t\tvertexCounter += 1;\n\t\t\t\t}\n\t\t\t} // indices\n\t\t\t// 1. you need three indices to draw a single face\n\t\t\t// 2. a single segment consists of two faces\n\t\t\t// 3. so we need to generate six (2*3) indices per segment\n\n\n\t\t\tfor (let iy = 0; iy < gridY; iy++) {\n\t\t\t\tfor (let ix = 0; ix < gridX; ix++) {\n\t\t\t\t\tconst a = numberOfVertices + ix + gridX1 * iy;\n\t\t\t\t\tconst b = numberOfVertices + ix + gridX1 * (iy + 1);\n\t\t\t\t\tconst c = numberOfVertices + (ix + 1) + gridX1 * (iy + 1);\n\t\t\t\t\tconst d = numberOfVertices + (ix + 1) + gridX1 * iy; // faces\n\n\t\t\t\t\tindices.push(a, b, d);\n\t\t\t\t\tindices.push(b, c, d); // increase counter\n\n\t\t\t\t\tgroupCount += 6;\n\t\t\t\t}\n\t\t\t} // add a group to the geometry. this will ensure multi material support\n\n\n\t\t\tscope.addGroup(groupStart, groupCount, materialIndex); // calculate new start value for groups\n\n\t\t\tgroupStart += groupCount; // update total number of vertices\n\n\t\t\tnumberOfVertices += vertexCounter;\n\t\t}\n\t}\n\n\tstatic fromJSON(data) {\n\t\treturn new BoxGeometry(data.width, data.height, data.depth, data.widthSegments, data.heightSegments, data.depthSegments);\n\t}\n\n}\n\n/**\n * Uniform Utilities\n */\nfunction cloneUniforms(src) {\n\tconst dst = {};\n\n\tfor (const u in src) {\n\t\tdst[u] = {};\n\n\t\tfor (const p in src[u]) {\n\t\t\tconst property = src[u][p];\n\n\t\t\tif (property && (property.isColor || property.isMatrix3 || property.isMatrix4 || property.isVector2 || property.isVector3 || property.isVector4 || property.isTexture || property.isQuaternion)) {\n\t\t\t\tdst[u][p] = property.clone();\n\t\t\t} else if (Array.isArray(property)) {\n\t\t\t\tdst[u][p] = property.slice();\n\t\t\t} else {\n\t\t\t\tdst[u][p] = property;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn dst;\n}\nfunction mergeUniforms(uniforms) {\n\tconst merged = {};\n\n\tfor (let u = 0; u < uniforms.length; u++) {\n\t\tconst tmp = cloneUniforms(uniforms[u]);\n\n\t\tfor (const p in tmp) {\n\t\t\tmerged[p] = tmp[p];\n\t\t}\n\t}\n\n\treturn merged;\n}\nfunction cloneUniformsGroups(src) {\n\tconst dst = [];\n\n\tfor (let u = 0; u < src.length; u++) {\n\t\tdst.push(src[u].clone());\n\t}\n\n\treturn dst;\n} // Legacy\n\nconst UniformsUtils = {\n\tclone: cloneUniforms,\n\tmerge: mergeUniforms\n};\n\nvar default_vertex = \"void main() {\\n\\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\\n}\";\n\nvar default_fragment = \"void main() {\\n\\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\\n}\";\n\nclass ShaderMaterial extends Material {\n\tconstructor(parameters) {\n\t\tsuper();\n\t\tthis.isShaderMaterial = true;\n\t\tthis.type = 'ShaderMaterial';\n\t\tthis.defines = {};\n\t\tthis.uniforms = {};\n\t\tthis.uniformsGroups = [];\n\t\tthis.vertexShader = default_vertex;\n\t\tthis.fragmentShader = default_fragment;\n\t\tthis.linewidth = 1;\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\t\tthis.fog = false; // set to use scene fog\n\n\t\tthis.lights = false; // set to use scene lights\n\n\t\tthis.clipping = false; // set to use user-defined clipping planes\n\n\t\tthis.extensions = {\n\t\t\tderivatives: false,\n\t\t\t// set to use derivatives\n\t\t\tfragDepth: false,\n\t\t\t// set to use fragment depth values\n\t\t\tdrawBuffers: false,\n\t\t\t// set to use draw buffers\n\t\t\tshaderTextureLOD: false // set to use shader texture LOD\n\n\t\t}; // When rendered geometry doesn't include these attributes but the material does,\n\t\t// use these default values in WebGL. This avoids errors when buffer data is missing.\n\n\t\tthis.defaultAttributeValues = {\n\t\t\t'color': [1, 1, 1],\n\t\t\t'uv': [0, 0],\n\t\t\t'uv2': [0, 0]\n\t\t};\n\t\tthis.index0AttributeName = undefined;\n\t\tthis.uniformsNeedUpdate = false;\n\t\tthis.glslVersion = null;\n\n\t\tif (parameters !== undefined) {\n\t\t\tthis.setValues(parameters);\n\t\t}\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.fragmentShader = source.fragmentShader;\n\t\tthis.vertexShader = source.vertexShader;\n\t\tthis.uniforms = cloneUniforms(source.uniforms);\n\t\tthis.uniformsGroups = cloneUniformsGroups(source.uniformsGroups);\n\t\tthis.defines = Object.assign({}, source.defines);\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\t\tthis.fog = source.fog;\n\t\tthis.lights = source.lights;\n\t\tthis.clipping = source.clipping;\n\t\tthis.extensions = Object.assign({}, source.extensions);\n\t\tthis.glslVersion = source.glslVersion;\n\t\treturn this;\n\t}\n\n\ttoJSON(meta) {\n\t\tconst data = super.toJSON(meta);\n\t\tdata.glslVersion = this.glslVersion;\n\t\tdata.uniforms = {};\n\n\t\tfor (const name in this.uniforms) {\n\t\t\tconst uniform = this.uniforms[name];\n\t\t\tconst value = uniform.value;\n\n\t\t\tif (value && value.isTexture) {\n\t\t\t\tdata.uniforms[name] = {\n\t\t\t\t\ttype: 't',\n\t\t\t\t\tvalue: value.toJSON(meta).uuid\n\t\t\t\t};\n\t\t\t} else if (value && value.isColor) {\n\t\t\t\tdata.uniforms[name] = {\n\t\t\t\t\ttype: 'c',\n\t\t\t\t\tvalue: value.getHex()\n\t\t\t\t};\n\t\t\t} else if (value && value.isVector2) {\n\t\t\t\tdata.uniforms[name] = {\n\t\t\t\t\ttype: 'v2',\n\t\t\t\t\tvalue: value.toArray()\n\t\t\t\t};\n\t\t\t} else if (value && value.isVector3) {\n\t\t\t\tdata.uniforms[name] = {\n\t\t\t\t\ttype: 'v3',\n\t\t\t\t\tvalue: value.toArray()\n\t\t\t\t};\n\t\t\t} else if (value && value.isVector4) {\n\t\t\t\tdata.uniforms[name] = {\n\t\t\t\t\ttype: 'v4',\n\t\t\t\t\tvalue: value.toArray()\n\t\t\t\t};\n\t\t\t} else if (value && value.isMatrix3) {\n\t\t\t\tdata.uniforms[name] = {\n\t\t\t\t\ttype: 'm3',\n\t\t\t\t\tvalue: value.toArray()\n\t\t\t\t};\n\t\t\t} else if (value && value.isMatrix4) {\n\t\t\t\tdata.uniforms[name] = {\n\t\t\t\t\ttype: 'm4',\n\t\t\t\t\tvalue: value.toArray()\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tdata.uniforms[name] = {\n\t\t\t\t\tvalue: value\n\t\t\t\t}; // note: the array variants v2v, v3v, v4v, m4v and tv are not supported so far\n\t\t\t}\n\t\t}\n\n\t\tif (Object.keys(this.defines).length > 0) data.defines = this.defines;\n\t\tdata.vertexShader = this.vertexShader;\n\t\tdata.fragmentShader = this.fragmentShader;\n\t\tconst extensions = {};\n\n\t\tfor (const key in this.extensions) {\n\t\t\tif (this.extensions[key] === true) extensions[key] = true;\n\t\t}\n\n\t\tif (Object.keys(extensions).length > 0) data.extensions = extensions;\n\t\treturn data;\n\t}\n\n}\n\nclass Camera extends Object3D {\n\tconstructor() {\n\t\tsuper();\n\t\tthis.isCamera = true;\n\t\tthis.type = 'Camera';\n\t\tthis.matrixWorldInverse = new Matrix4();\n\t\tthis.projectionMatrix = new Matrix4();\n\t\tthis.projectionMatrixInverse = new Matrix4();\n\t}\n\n\tcopy(source, recursive) {\n\t\tsuper.copy(source, recursive);\n\t\tthis.matrixWorldInverse.copy(source.matrixWorldInverse);\n\t\tthis.projectionMatrix.copy(source.projectionMatrix);\n\t\tthis.projectionMatrixInverse.copy(source.projectionMatrixInverse);\n\t\treturn this;\n\t}\n\n\tgetWorldDirection(target) {\n\t\tthis.updateWorldMatrix(true, false);\n\t\tconst e = this.matrixWorld.elements;\n\t\treturn target.set(-e[8], -e[9], -e[10]).normalize();\n\t}\n\n\tupdateMatrixWorld(force) {\n\t\tsuper.updateMatrixWorld(force);\n\t\tthis.matrixWorldInverse.copy(this.matrixWorld).invert();\n\t}\n\n\tupdateWorldMatrix(updateParents, updateChildren) {\n\t\tsuper.updateWorldMatrix(updateParents, updateChildren);\n\t\tthis.matrixWorldInverse.copy(this.matrixWorld).invert();\n\t}\n\n\tclone() {\n\t\treturn new this.constructor().copy(this);\n\t}\n\n}\n\nclass PerspectiveCamera extends Camera {\n\tconstructor(fov = 50, aspect = 1, near = 0.1, far = 2000) {\n\t\tsuper();\n\t\tthis.isPerspectiveCamera = true;\n\t\tthis.type = 'PerspectiveCamera';\n\t\tthis.fov = fov;\n\t\tthis.zoom = 1;\n\t\tthis.near = near;\n\t\tthis.far = far;\n\t\tthis.focus = 10;\n\t\tthis.aspect = aspect;\n\t\tthis.view = null;\n\t\tthis.filmGauge = 35; // width of the film (default in millimeters)\n\n\t\tthis.filmOffset = 0; // horizontal film offset (same unit as gauge)\n\n\t\tthis.updateProjectionMatrix();\n\t}\n\n\tcopy(source, recursive) {\n\t\tsuper.copy(source, recursive);\n\t\tthis.fov = source.fov;\n\t\tthis.zoom = source.zoom;\n\t\tthis.near = source.near;\n\t\tthis.far = source.far;\n\t\tthis.focus = source.focus;\n\t\tthis.aspect = source.aspect;\n\t\tthis.view = source.view === null ? null : Object.assign({}, source.view);\n\t\tthis.filmGauge = source.filmGauge;\n\t\tthis.filmOffset = source.filmOffset;\n\t\treturn this;\n\t}\n\t/**\n\t * Sets the FOV by focal length in respect to the current .filmGauge.\n\t *\n\t * The default film gauge is 35, so that the focal length can be specified for\n\t * a 35mm (full frame) camera.\n\t *\n\t * Values for focal length and film gauge must have the same unit.\n\t */\n\n\n\tsetFocalLength(focalLength) {\n\t\t/** see {@link http://www.bobatkins.com/photography/technical/field_of_view.html} */\n\t\tconst vExtentSlope = 0.5 * this.getFilmHeight() / focalLength;\n\t\tthis.fov = RAD2DEG * 2 * Math.atan(vExtentSlope);\n\t\tthis.updateProjectionMatrix();\n\t}\n\t/**\n\t * Calculates the focal length from the current .fov and .filmGauge.\n\t */\n\n\n\tgetFocalLength() {\n\t\tconst vExtentSlope = Math.tan(DEG2RAD * 0.5 * this.fov);\n\t\treturn 0.5 * this.getFilmHeight() / vExtentSlope;\n\t}\n\n\tgetEffectiveFOV() {\n\t\treturn RAD2DEG * 2 * Math.atan(Math.tan(DEG2RAD * 0.5 * this.fov) / this.zoom);\n\t}\n\n\tgetFilmWidth() {\n\t\t// film not completely covered in portrait format (aspect < 1)\n\t\treturn this.filmGauge * Math.min(this.aspect, 1);\n\t}\n\n\tgetFilmHeight() {\n\t\t// film not completely covered in landscape format (aspect > 1)\n\t\treturn this.filmGauge / Math.max(this.aspect, 1);\n\t}\n\t/**\n\t * Sets an offset in a larger frustum. This is useful for multi-window or\n\t * multi-monitor/multi-machine setups.\n\t *\n\t * For example, if you have 3x2 monitors and each monitor is 1920x1080 and\n\t * the monitors are in grid like this\n\t *\n\t *\t +---+---+---+\n\t *\t | A | B | C |\n\t *\t +---+---+---+\n\t *\t | D | E | F |\n\t *\t +---+---+---+\n\t *\n\t * then for each monitor you would call it like this\n\t *\n\t *\t const w = 1920;\n\t *\t const h = 1080;\n\t *\t const fullWidth = w * 3;\n\t *\t const fullHeight = h * 2;\n\t *\n\t *\t --A--\n\t *\t camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );\n\t *\t --B--\n\t *\t camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );\n\t *\t --C--\n\t *\t camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );\n\t *\t --D--\n\t *\t camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );\n\t *\t --E--\n\t *\t camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );\n\t *\t --F--\n\t *\t camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );\n\t *\n\t *\t Note there is no reason monitors have to be the same size or in a grid.\n\t */\n\n\n\tsetViewOffset(fullWidth, fullHeight, x, y, width, height) {\n\t\tthis.aspect = fullWidth / fullHeight;\n\n\t\tif (this.view === null) {\n\t\t\tthis.view = {\n\t\t\t\tenabled: true,\n\t\t\t\tfullWidth: 1,\n\t\t\t\tfullHeight: 1,\n\t\t\t\toffsetX: 0,\n\t\t\t\toffsetY: 0,\n\t\t\t\twidth: 1,\n\t\t\t\theight: 1\n\t\t\t};\n\t\t}\n\n\t\tthis.view.enabled = true;\n\t\tthis.view.fullWidth = fullWidth;\n\t\tthis.view.fullHeight = fullHeight;\n\t\tthis.view.offsetX = x;\n\t\tthis.view.offsetY = y;\n\t\tthis.view.width = width;\n\t\tthis.view.height = height;\n\t\tthis.updateProjectionMatrix();\n\t}\n\n\tclearViewOffset() {\n\t\tif (this.view !== null) {\n\t\t\tthis.view.enabled = false;\n\t\t}\n\n\t\tthis.updateProjectionMatrix();\n\t}\n\n\tupdateProjectionMatrix() {\n\t\tconst near = this.near;\n\t\tlet top = near * Math.tan(DEG2RAD * 0.5 * this.fov) / this.zoom;\n\t\tlet height = 2 * top;\n\t\tlet width = this.aspect * height;\n\t\tlet left = -0.5 * width;\n\t\tconst view = this.view;\n\n\t\tif (this.view !== null && this.view.enabled) {\n\t\t\tconst fullWidth = view.fullWidth,\n\t\t\t\t\t\tfullHeight = view.fullHeight;\n\t\t\tleft += view.offsetX * width / fullWidth;\n\t\t\ttop -= view.offsetY * height / fullHeight;\n\t\t\twidth *= view.width / fullWidth;\n\t\t\theight *= view.height / fullHeight;\n\t\t}\n\n\t\tconst skew = this.filmOffset;\n\t\tif (skew !== 0) left += near * skew / this.getFilmWidth();\n\t\tthis.projectionMatrix.makePerspective(left, left + width, top, top - height, near, this.far);\n\t\tthis.projectionMatrixInverse.copy(this.projectionMatrix).invert();\n\t}\n\n\ttoJSON(meta) {\n\t\tconst data = super.toJSON(meta);\n\t\tdata.object.fov = this.fov;\n\t\tdata.object.zoom = this.zoom;\n\t\tdata.object.near = this.near;\n\t\tdata.object.far = this.far;\n\t\tdata.object.focus = this.focus;\n\t\tdata.object.aspect = this.aspect;\n\t\tif (this.view !== null) data.object.view = Object.assign({}, this.view);\n\t\tdata.object.filmGauge = this.filmGauge;\n\t\tdata.object.filmOffset = this.filmOffset;\n\t\treturn data;\n\t}\n\n}\n\nconst fov = 90,\n\t\t\taspect = 1;\n\nclass CubeCamera extends Object3D {\n\tconstructor(near, far, renderTarget) {\n\t\tsuper();\n\t\tthis.type = 'CubeCamera';\n\t\tthis.renderTarget = renderTarget;\n\t\tconst cameraPX = new PerspectiveCamera(fov, aspect, near, far);\n\t\tcameraPX.layers = this.layers;\n\t\tcameraPX.up.set(0, -1, 0);\n\t\tcameraPX.lookAt(new Vector3(1, 0, 0));\n\t\tthis.add(cameraPX);\n\t\tconst cameraNX = new PerspectiveCamera(fov, aspect, near, far);\n\t\tcameraNX.layers = this.layers;\n\t\tcameraNX.up.set(0, -1, 0);\n\t\tcameraNX.lookAt(new Vector3(-1, 0, 0));\n\t\tthis.add(cameraNX);\n\t\tconst cameraPY = new PerspectiveCamera(fov, aspect, near, far);\n\t\tcameraPY.layers = this.layers;\n\t\tcameraPY.up.set(0, 0, 1);\n\t\tcameraPY.lookAt(new Vector3(0, 1, 0));\n\t\tthis.add(cameraPY);\n\t\tconst cameraNY = new PerspectiveCamera(fov, aspect, near, far);\n\t\tcameraNY.layers = this.layers;\n\t\tcameraNY.up.set(0, 0, -1);\n\t\tcameraNY.lookAt(new Vector3(0, -1, 0));\n\t\tthis.add(cameraNY);\n\t\tconst cameraPZ = new PerspectiveCamera(fov, aspect, near, far);\n\t\tcameraPZ.layers = this.layers;\n\t\tcameraPZ.up.set(0, -1, 0);\n\t\tcameraPZ.lookAt(new Vector3(0, 0, 1));\n\t\tthis.add(cameraPZ);\n\t\tconst cameraNZ = new PerspectiveCamera(fov, aspect, near, far);\n\t\tcameraNZ.layers = this.layers;\n\t\tcameraNZ.up.set(0, -1, 0);\n\t\tcameraNZ.lookAt(new Vector3(0, 0, -1));\n\t\tthis.add(cameraNZ);\n\t}\n\n\tupdate(renderer, scene) {\n\t\tif (this.parent === null) this.updateMatrixWorld();\n\t\tconst renderTarget = this.renderTarget;\n\t\tconst [cameraPX, cameraNX, cameraPY, cameraNY, cameraPZ, cameraNZ] = this.children;\n\t\tconst currentRenderTarget = renderer.getRenderTarget();\n\t\tconst currentToneMapping = renderer.toneMapping;\n\t\tconst currentXrEnabled = renderer.xr.enabled;\n\t\trenderer.toneMapping = NoToneMapping;\n\t\trenderer.xr.enabled = false;\n\t\tconst generateMipmaps = renderTarget.texture.generateMipmaps;\n\t\trenderTarget.texture.generateMipmaps = false;\n\t\trenderer.setRenderTarget(renderTarget, 0);\n\t\trenderer.render(scene, cameraPX);\n\t\trenderer.setRenderTarget(renderTarget, 1);\n\t\trenderer.render(scene, cameraNX);\n\t\trenderer.setRenderTarget(renderTarget, 2);\n\t\trenderer.render(scene, cameraPY);\n\t\trenderer.setRenderTarget(renderTarget, 3);\n\t\trenderer.render(scene, cameraNY);\n\t\trenderer.setRenderTarget(renderTarget, 4);\n\t\trenderer.render(scene, cameraPZ);\n\t\trenderTarget.texture.generateMipmaps = generateMipmaps;\n\t\trenderer.setRenderTarget(renderTarget, 5);\n\t\trenderer.render(scene, cameraNZ);\n\t\trenderer.setRenderTarget(currentRenderTarget);\n\t\trenderer.toneMapping = currentToneMapping;\n\t\trenderer.xr.enabled = currentXrEnabled;\n\t\trenderTarget.texture.needsPMREMUpdate = true;\n\t}\n\n}\n\nclass CubeTexture extends Texture {\n\tconstructor(images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding) {\n\t\timages = images !== undefined ? images : [];\n\t\tmapping = mapping !== undefined ? mapping : CubeReflectionMapping;\n\t\tsuper(images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding);\n\t\tthis.isCubeTexture = true;\n\t\tthis.flipY = false;\n\t}\n\n\tget images() {\n\t\treturn this.image;\n\t}\n\n\tset images(value) {\n\t\tthis.image = value;\n\t}\n\n}\n\nclass WebGLCubeRenderTarget extends WebGLRenderTarget {\n\tconstructor(size, options = {}) {\n\t\tsuper(size, size, options);\n\t\tthis.isWebGLCubeRenderTarget = true;\n\t\tconst image = {\n\t\t\twidth: size,\n\t\t\theight: size,\n\t\t\tdepth: 1\n\t\t};\n\t\tconst images = [image, image, image, image, image, image];\n\t\tthis.texture = new CubeTexture(images, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding); // By convention -- likely based on the RenderMan spec from the 1990's -- cube maps are specified by WebGL (and three.js)\n\t\t// in a coordinate system in which positive-x is to the right when looking up the positive-z axis -- in other words,\n\t\t// in a left-handed coordinate system. By continuing this convention, preexisting cube maps continued to render correctly.\n\t\t// three.js uses a right-handed coordinate system. So environment maps used in three.js appear to have px and nx swapped\n\t\t// and the flag isRenderTargetTexture controls this conversion. The flip is not required when using WebGLCubeRenderTarget.texture\n\t\t// as a cube texture (this is detected when isRenderTargetTexture is set to true for cube textures).\n\n\t\tthis.texture.isRenderTargetTexture = true;\n\t\tthis.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;\n\t\tthis.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;\n\t}\n\n\tfromEquirectangularTexture(renderer, texture) {\n\t\tthis.texture.type = texture.type;\n\t\tthis.texture.encoding = texture.encoding;\n\t\tthis.texture.generateMipmaps = texture.generateMipmaps;\n\t\tthis.texture.minFilter = texture.minFilter;\n\t\tthis.texture.magFilter = texture.magFilter;\n\t\tconst shader = {\n\t\t\tuniforms: {\n\t\t\t\ttEquirect: {\n\t\t\t\t\tvalue: null\n\t\t\t\t}\n\t\t\t},\n\t\t\tvertexShader:\n\t\t\t/* glsl */\n\t\t\t`\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`,\n\t\t\tfragmentShader:\n\t\t\t/* glsl */\n\t\t\t`\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`\n\t\t};\n\t\tconst geometry = new BoxGeometry(5, 5, 5);\n\t\tconst material = new ShaderMaterial({\n\t\t\tname: 'CubemapFromEquirect',\n\t\t\tuniforms: cloneUniforms(shader.uniforms),\n\t\t\tvertexShader: shader.vertexShader,\n\t\t\tfragmentShader: shader.fragmentShader,\n\t\t\tside: BackSide,\n\t\t\tblending: NoBlending\n\t\t});\n\t\tmaterial.uniforms.tEquirect.value = texture;\n\t\tconst mesh = new Mesh(geometry, material);\n\t\tconst currentMinFilter = texture.minFilter; // Avoid blurred poles\n\n\t\tif (texture.minFilter === LinearMipmapLinearFilter) texture.minFilter = LinearFilter;\n\t\tconst camera = new CubeCamera(1, 10, this);\n\t\tcamera.update(renderer, mesh);\n\t\ttexture.minFilter = currentMinFilter;\n\t\tmesh.geometry.dispose();\n\t\tmesh.material.dispose();\n\t\treturn this;\n\t}\n\n\tclear(renderer, color, depth, stencil) {\n\t\tconst currentRenderTarget = renderer.getRenderTarget();\n\n\t\tfor (let i = 0; i < 6; i++) {\n\t\t\trenderer.setRenderTarget(this, i);\n\t\t\trenderer.clear(color, depth, stencil);\n\t\t}\n\n\t\trenderer.setRenderTarget(currentRenderTarget);\n\t}\n\n}\n\nconst _vector1 = /*@__PURE__*/new Vector3();\n\nconst _vector2 = /*@__PURE__*/new Vector3();\n\nconst _normalMatrix = /*@__PURE__*/new Matrix3();\n\nclass Plane {\n\tconstructor(normal = new Vector3(1, 0, 0), constant = 0) {\n\t\tthis.isPlane = true; // normal is assumed to be normalized\n\n\t\tthis.normal = normal;\n\t\tthis.constant = constant;\n\t}\n\n\tset(normal, constant) {\n\t\tthis.normal.copy(normal);\n\t\tthis.constant = constant;\n\t\treturn this;\n\t}\n\n\tsetComponents(x, y, z, w) {\n\t\tthis.normal.set(x, y, z);\n\t\tthis.constant = w;\n\t\treturn this;\n\t}\n\n\tsetFromNormalAndCoplanarPoint(normal, point) {\n\t\tthis.normal.copy(normal);\n\t\tthis.constant = -point.dot(this.normal);\n\t\treturn this;\n\t}\n\n\tsetFromCoplanarPoints(a, b, c) {\n\t\tconst normal = _vector1.subVectors(c, b).cross(_vector2.subVectors(a, b)).normalize(); // Q: should an error be thrown if normal is zero (e.g. degenerate plane)?\n\n\n\t\tthis.setFromNormalAndCoplanarPoint(normal, a);\n\t\treturn this;\n\t}\n\n\tcopy(plane) {\n\t\tthis.normal.copy(plane.normal);\n\t\tthis.constant = plane.constant;\n\t\treturn this;\n\t}\n\n\tnormalize() {\n\t\t// Note: will lead to a divide by zero if the plane is invalid.\n\t\tconst inverseNormalLength = 1.0 / this.normal.length();\n\t\tthis.normal.multiplyScalar(inverseNormalLength);\n\t\tthis.constant *= inverseNormalLength;\n\t\treturn this;\n\t}\n\n\tnegate() {\n\t\tthis.constant *= -1;\n\t\tthis.normal.negate();\n\t\treturn this;\n\t}\n\n\tdistanceToPoint(point) {\n\t\treturn this.normal.dot(point) + this.constant;\n\t}\n\n\tdistanceToSphere(sphere) {\n\t\treturn this.distanceToPoint(sphere.center) - sphere.radius;\n\t}\n\n\tprojectPoint(point, target) {\n\t\treturn target.copy(this.normal).multiplyScalar(-this.distanceToPoint(point)).add(point);\n\t}\n\n\tintersectLine(line, target) {\n\t\tconst direction = line.delta(_vector1);\n\t\tconst denominator = this.normal.dot(direction);\n\n\t\tif (denominator === 0) {\n\t\t\t// line is coplanar, return origin\n\t\t\tif (this.distanceToPoint(line.start) === 0) {\n\t\t\t\treturn target.copy(line.start);\n\t\t\t} // Unsure if this is the correct method to handle this case.\n\n\n\t\t\treturn null;\n\t\t}\n\n\t\tconst t = -(line.start.dot(this.normal) + this.constant) / denominator;\n\n\t\tif (t < 0 || t > 1) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn target.copy(direction).multiplyScalar(t).add(line.start);\n\t}\n\n\tintersectsLine(line) {\n\t\t// Note: this tests if a line intersects the plane, not whether it (or its end-points) are coplanar with it.\n\t\tconst startSign = this.distanceToPoint(line.start);\n\t\tconst endSign = this.distanceToPoint(line.end);\n\t\treturn startSign < 0 && endSign > 0 || endSign < 0 && startSign > 0;\n\t}\n\n\tintersectsBox(box) {\n\t\treturn box.intersectsPlane(this);\n\t}\n\n\tintersectsSphere(sphere) {\n\t\treturn sphere.intersectsPlane(this);\n\t}\n\n\tcoplanarPoint(target) {\n\t\treturn target.copy(this.normal).multiplyScalar(-this.constant);\n\t}\n\n\tapplyMatrix4(matrix, optionalNormalMatrix) {\n\t\tconst normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix(matrix);\n\n\t\tconst referencePoint = this.coplanarPoint(_vector1).applyMatrix4(matrix);\n\t\tconst normal = this.normal.applyMatrix3(normalMatrix).normalize();\n\t\tthis.constant = -referencePoint.dot(normal);\n\t\treturn this;\n\t}\n\n\ttranslate(offset) {\n\t\tthis.constant -= offset.dot(this.normal);\n\t\treturn this;\n\t}\n\n\tequals(plane) {\n\t\treturn plane.normal.equals(this.normal) && plane.constant === this.constant;\n\t}\n\n\tclone() {\n\t\treturn new this.constructor().copy(this);\n\t}\n\n}\n\nconst _sphere$2 = /*@__PURE__*/new Sphere();\n\nconst _vector$7 = /*@__PURE__*/new Vector3();\n\nclass Frustum {\n\tconstructor(p0 = new Plane(), p1 = new Plane(), p2 = new Plane(), p3 = new Plane(), p4 = new Plane(), p5 = new Plane()) {\n\t\tthis.planes = [p0, p1, p2, p3, p4, p5];\n\t}\n\n\tset(p0, p1, p2, p3, p4, p5) {\n\t\tconst planes = this.planes;\n\t\tplanes[0].copy(p0);\n\t\tplanes[1].copy(p1);\n\t\tplanes[2].copy(p2);\n\t\tplanes[3].copy(p3);\n\t\tplanes[4].copy(p4);\n\t\tplanes[5].copy(p5);\n\t\treturn this;\n\t}\n\n\tcopy(frustum) {\n\t\tconst planes = this.planes;\n\n\t\tfor (let i = 0; i < 6; i++) {\n\t\t\tplanes[i].copy(frustum.planes[i]);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tsetFromProjectionMatrix(m) {\n\t\tconst planes = this.planes;\n\t\tconst me = m.elements;\n\t\tconst me0 = me[0],\n\t\t\t\t\tme1 = me[1],\n\t\t\t\t\tme2 = me[2],\n\t\t\t\t\tme3 = me[3];\n\t\tconst me4 = me[4],\n\t\t\t\t\tme5 = me[5],\n\t\t\t\t\tme6 = me[6],\n\t\t\t\t\tme7 = me[7];\n\t\tconst me8 = me[8],\n\t\t\t\t\tme9 = me[9],\n\t\t\t\t\tme10 = me[10],\n\t\t\t\t\tme11 = me[11];\n\t\tconst me12 = me[12],\n\t\t\t\t\tme13 = me[13],\n\t\t\t\t\tme14 = me[14],\n\t\t\t\t\tme15 = me[15];\n\t\tplanes[0].setComponents(me3 - me0, me7 - me4, me11 - me8, me15 - me12).normalize();\n\t\tplanes[1].setComponents(me3 + me0, me7 + me4, me11 + me8, me15 + me12).normalize();\n\t\tplanes[2].setComponents(me3 + me1, me7 + me5, me11 + me9, me15 + me13).normalize();\n\t\tplanes[3].setComponents(me3 - me1, me7 - me5, me11 - me9, me15 - me13).normalize();\n\t\tplanes[4].setComponents(me3 - me2, me7 - me6, me11 - me10, me15 - me14).normalize();\n\t\tplanes[5].setComponents(me3 + me2, me7 + me6, me11 + me10, me15 + me14).normalize();\n\t\treturn this;\n\t}\n\n\tintersectsObject(object) {\n\t\tconst geometry = object.geometry;\n\t\tif (geometry.boundingSphere === null) geometry.computeBoundingSphere();\n\n\t\t_sphere$2.copy(geometry.boundingSphere).applyMatrix4(object.matrixWorld);\n\n\t\treturn this.intersectsSphere(_sphere$2);\n\t}\n\n\tintersectsSprite(sprite) {\n\t\t_sphere$2.center.set(0, 0, 0);\n\n\t\t_sphere$2.radius = 0.7071067811865476;\n\n\t\t_sphere$2.applyMatrix4(sprite.matrixWorld);\n\n\t\treturn this.intersectsSphere(_sphere$2);\n\t}\n\n\tintersectsSphere(sphere) {\n\t\tconst planes = this.planes;\n\t\tconst center = sphere.center;\n\t\tconst negRadius = -sphere.radius;\n\n\t\tfor (let i = 0; i < 6; i++) {\n\t\t\tconst distance = planes[i].distanceToPoint(center);\n\n\t\t\tif (distance < negRadius) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tintersectsBox(box) {\n\t\tconst planes = this.planes;\n\n\t\tfor (let i = 0; i < 6; i++) {\n\t\t\tconst plane = planes[i]; // corner at max distance\n\n\t\t\t_vector$7.x = plane.normal.x > 0 ? box.max.x : box.min.x;\n\t\t\t_vector$7.y = plane.normal.y > 0 ? box.max.y : box.min.y;\n\t\t\t_vector$7.z = plane.normal.z > 0 ? box.max.z : box.min.z;\n\n\t\t\tif (plane.distanceToPoint(_vector$7) < 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tcontainsPoint(point) {\n\t\tconst planes = this.planes;\n\n\t\tfor (let i = 0; i < 6; i++) {\n\t\t\tif (planes[i].distanceToPoint(point) < 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tclone() {\n\t\treturn new this.constructor().copy(this);\n\t}\n\n}\n\nfunction WebGLAnimation() {\n\tlet context = null;\n\tlet isAnimating = false;\n\tlet animationLoop = null;\n\tlet requestId = null;\n\n\tfunction onAnimationFrame(time, frame) {\n\t\tanimationLoop(time, frame);\n\t\trequestId = context.requestAnimationFrame(onAnimationFrame);\n\t}\n\n\treturn {\n\t\tstart: function () {\n\t\t\tif (isAnimating === true) return;\n\t\t\tif (animationLoop === null) return;\n\t\t\trequestId = context.requestAnimationFrame(onAnimationFrame);\n\t\t\tisAnimating = true;\n\t\t},\n\t\tstop: function () {\n\t\t\tcontext.cancelAnimationFrame(requestId);\n\t\t\tisAnimating = false;\n\t\t},\n\t\tsetAnimationLoop: function (callback) {\n\t\t\tanimationLoop = callback;\n\t\t},\n\t\tsetContext: function (value) {\n\t\t\tcontext = value;\n\t\t}\n\t};\n}\n\nfunction WebGLAttributes(gl, capabilities) {\n\tconst isWebGL2 = capabilities.isWebGL2;\n\tconst buffers = new WeakMap();\n\n\tfunction createBuffer(attribute, bufferType) {\n\t\tconst array = attribute.array;\n\t\tconst usage = attribute.usage;\n\t\tconst buffer = gl.createBuffer();\n\t\tgl.bindBuffer(bufferType, buffer);\n\t\tgl.bufferData(bufferType, array, usage);\n\t\tattribute.onUploadCallback();\n\t\tlet type;\n\n\t\tif (array instanceof Float32Array) {\n\t\t\ttype = gl.FLOAT;\n\t\t} else if (array instanceof Uint16Array) {\n\t\t\tif (attribute.isFloat16BufferAttribute) {\n\t\t\t\tif (isWebGL2) {\n\t\t\t\t\ttype = gl.HALF_FLOAT;\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error('THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.');\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttype = gl.UNSIGNED_SHORT;\n\t\t\t}\n\t\t} else if (array instanceof Int16Array) {\n\t\t\ttype = gl.SHORT;\n\t\t} else if (array instanceof Uint32Array) {\n\t\t\ttype = gl.UNSIGNED_INT;\n\t\t} else if (array instanceof Int32Array) {\n\t\t\ttype = gl.INT;\n\t\t} else if (array instanceof Int8Array) {\n\t\t\ttype = gl.BYTE;\n\t\t} else if (array instanceof Uint8Array) {\n\t\t\ttype = gl.UNSIGNED_BYTE;\n\t\t} else if (array instanceof Uint8ClampedArray) {\n\t\t\ttype = gl.UNSIGNED_BYTE;\n\t\t} else {\n\t\t\tthrow new Error('THREE.WebGLAttributes: Unsupported buffer data format: ' + array);\n\t\t}\n\n\t\treturn {\n\t\t\tbuffer: buffer,\n\t\t\ttype: type,\n\t\t\tbytesPerElement: array.BYTES_PER_ELEMENT,\n\t\t\tversion: attribute.version\n\t\t};\n\t}\n\n\tfunction updateBuffer(buffer, attribute, bufferType) {\n\t\tconst array = attribute.array;\n\t\tconst updateRange = attribute.updateRange;\n\t\tgl.bindBuffer(bufferType, buffer);\n\n\t\tif (updateRange.count === -1) {\n\t\t\t// Not using update ranges\n\t\t\tgl.bufferSubData(bufferType, 0, array);\n\t\t} else {\n\t\t\tif (isWebGL2) {\n\t\t\t\tgl.bufferSubData(bufferType, updateRange.offset * array.BYTES_PER_ELEMENT, array, updateRange.offset, updateRange.count);\n\t\t\t} else {\n\t\t\t\tgl.bufferSubData(bufferType, updateRange.offset * array.BYTES_PER_ELEMENT, array.subarray(updateRange.offset, updateRange.offset + updateRange.count));\n\t\t\t}\n\n\t\t\tupdateRange.count = -1; // reset range\n\t\t}\n\t} //\n\n\n\tfunction get(attribute) {\n\t\tif (attribute.isInterleavedBufferAttribute) attribute = attribute.data;\n\t\treturn buffers.get(attribute);\n\t}\n\n\tfunction remove(attribute) {\n\t\tif (attribute.isInterleavedBufferAttribute) attribute = attribute.data;\n\t\tconst data = buffers.get(attribute);\n\n\t\tif (data) {\n\t\t\tgl.deleteBuffer(data.buffer);\n\t\t\tbuffers.delete(attribute);\n\t\t}\n\t}\n\n\tfunction update(attribute, bufferType) {\n\t\tif (attribute.isGLBufferAttribute) {\n\t\t\tconst cached = buffers.get(attribute);\n\n\t\t\tif (!cached || cached.version < attribute.version) {\n\t\t\t\tbuffers.set(attribute, {\n\t\t\t\t\tbuffer: attribute.buffer,\n\t\t\t\t\ttype: attribute.type,\n\t\t\t\t\tbytesPerElement: attribute.elementSize,\n\t\t\t\t\tversion: attribute.version\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (attribute.isInterleavedBufferAttribute) attribute = attribute.data;\n\t\tconst data = buffers.get(attribute);\n\n\t\tif (data === undefined) {\n\t\t\tbuffers.set(attribute, createBuffer(attribute, bufferType));\n\t\t} else if (data.version < attribute.version) {\n\t\t\tupdateBuffer(data.buffer, attribute, bufferType);\n\t\t\tdata.version = attribute.version;\n\t\t}\n\t}\n\n\treturn {\n\t\tget: get,\n\t\tremove: remove,\n\t\tupdate: update\n\t};\n}\n\nclass PlaneGeometry extends BufferGeometry {\n\tconstructor(width = 1, height = 1, widthSegments = 1, heightSegments = 1) {\n\t\tsuper();\n\t\tthis.type = 'PlaneGeometry';\n\t\tthis.parameters = {\n\t\t\twidth: width,\n\t\t\theight: height,\n\t\t\twidthSegments: widthSegments,\n\t\t\theightSegments: heightSegments\n\t\t};\n\t\tconst width_half = width / 2;\n\t\tconst height_half = height / 2;\n\t\tconst gridX = Math.floor(widthSegments);\n\t\tconst gridY = Math.floor(heightSegments);\n\t\tconst gridX1 = gridX + 1;\n\t\tconst gridY1 = gridY + 1;\n\t\tconst segment_width = width / gridX;\n\t\tconst segment_height = height / gridY; //\n\n\t\tconst indices = [];\n\t\tconst vertices = [];\n\t\tconst normals = [];\n\t\tconst uvs = [];\n\n\t\tfor (let iy = 0; iy < gridY1; iy++) {\n\t\t\tconst y = iy * segment_height - height_half;\n\n\t\t\tfor (let ix = 0; ix < gridX1; ix++) {\n\t\t\t\tconst x = ix * segment_width - width_half;\n\t\t\t\tvertices.push(x, -y, 0);\n\t\t\t\tnormals.push(0, 0, 1);\n\t\t\t\tuvs.push(ix / gridX);\n\t\t\t\tuvs.push(1 - iy / gridY);\n\t\t\t}\n\t\t}\n\n\t\tfor (let iy = 0; iy < gridY; iy++) {\n\t\t\tfor (let ix = 0; ix < gridX; ix++) {\n\t\t\t\tconst a = ix + gridX1 * iy;\n\t\t\t\tconst b = ix + gridX1 * (iy + 1);\n\t\t\t\tconst c = ix + 1 + gridX1 * (iy + 1);\n\t\t\t\tconst d = ix + 1 + gridX1 * iy;\n\t\t\t\tindices.push(a, b, d);\n\t\t\t\tindices.push(b, c, d);\n\t\t\t}\n\t\t}\n\n\t\tthis.setIndex(indices);\n\t\tthis.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\tthis.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\t\tthis.setAttribute('uv', new Float32BufferAttribute(uvs, 2));\n\t}\n\n\tstatic fromJSON(data) {\n\t\treturn new PlaneGeometry(data.width, data.height, data.widthSegments, data.heightSegments);\n\t}\n\n}\n\nvar alphamap_fragment = \"#ifdef USE_ALPHAMAP\\n\\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\\n#endif\";\n\nvar alphamap_pars_fragment = \"#ifdef USE_ALPHAMAP\\n\\tuniform sampler2D alphaMap;\\n#endif\";\n\nvar alphatest_fragment = \"#ifdef USE_ALPHATEST\\n\\tif ( diffuseColor.a < alphaTest ) discard;\\n#endif\";\n\nvar alphatest_pars_fragment = \"#ifdef USE_ALPHATEST\\n\\tuniform float alphaTest;\\n#endif\";\n\nvar aomap_fragment = \"#ifdef USE_AOMAP\\n\\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\\n\\treflectedLight.indirectDiffuse *= ambientOcclusion;\\n\\t#if defined( USE_ENVMAP ) && defined( STANDARD )\\n\\t\\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\\n\\t\\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\\n\\t#endif\\n#endif\";\n\nvar aomap_pars_fragment = \"#ifdef USE_AOMAP\\n\\tuniform sampler2D aoMap;\\n\\tuniform float aoMapIntensity;\\n#endif\";\n\nvar begin_vertex = \"vec3 transformed = vec3( position );\";\n\nvar beginnormal_vertex = \"vec3 objectNormal = vec3( normal );\\n#ifdef USE_TANGENT\\n\\tvec3 objectTangent = vec3( tangent.xyz );\\n#endif\";\n\nvar bsdfs = \"vec3 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}\\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\\n\t\tfloat x = clamp( 1.0 - dotVH, 0.0, 1.0 );\\n\t\tfloat x2 = x * x;\\n\t\tfloat x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\\n\t\treturn ( 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}\\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float 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\\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\\n\\tfloat D = D_GGX( alpha, dotNH );\\n\\treturn F * ( V * D );\\n}\\n#ifdef USE_IRIDESCENCE\\n\\tvec3 BRDF_GGX_Iridescence( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float roughness ) {\\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 = mix( F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence );\\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\\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}\\nfloat G_BlinnPhong_Implicit( ) {\\n\\treturn 0.25;\\n}\\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\\n\\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\\n}\\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\\n\\tvec3 halfDir = normalize( lightDir + viewDir );\\n\\tfloat dotNH = saturate( dot( normal, halfDir ) );\\n\\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\\n\\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\\n\\tfloat G = G_BlinnPhong_Implicit( );\\n\\tfloat D = D_BlinnPhong( shininess, dotNH );\\n\\treturn F * ( G * D );\\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\";\n\nvar iridescence_fragment = \"#ifdef USE_IRIDESCENCE\\n\\tconst mat3 XYZ_TO_REC709 = mat3(\\n\\t\\t 3.2404542, -0.9692660,\t0.0556434,\\n\\t\\t-1.5371385,\t1.8760108, -0.2040259,\\n\\t\\t-0.4985314,\t0.0415560,\t1.0572252\\n\\t);\\n\\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\\n\\t\\tvec3 sqrtF0 = sqrt( fresnel0 );\\n\\t\\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\\n\\t}\\n\\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\\n\\t\\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\\n\\t}\\n\\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\\n\\t\\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\\n\\t}\\n\\tvec3 evalSensitivity( float OPD, vec3 shift ) {\\n\\t\\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\\n\\t\\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\\n\\t\\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\\n\\t\\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\\n\\t\\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\\n\\t\\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\\n\\t\\txyz /= 1.0685e-7;\\n\\t\\tvec3 rgb = XYZ_TO_REC709 * xyz;\\n\\t\\treturn rgb;\\n\\t}\\n\\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\\n\\t\\tvec3 I;\\n\\t\\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\\n\\t\\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\\n\\t\\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\\n\\t\\tif ( cosTheta2Sq < 0.0 ) {\\n\\t\\t\\t return vec3( 1.0 );\\n\\t\\t}\\n\\t\\tfloat cosTheta2 = sqrt( cosTheta2Sq );\\n\\t\\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\\n\\t\\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\\n\\t\\tfloat R21 = R12;\\n\\t\\tfloat T121 = 1.0 - R12;\\n\\t\\tfloat phi12 = 0.0;\\n\\t\\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\\n\\t\\tfloat phi21 = PI - phi12;\\n\\t\\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\\t\\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\\n\\t\\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\\n\\t\\tvec3 phi23 = vec3( 0.0 );\\n\\t\\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\\n\\t\\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\\n\\t\\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\\n\\t\\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\\n\\t\\tvec3 phi = vec3( phi21 ) + phi23;\\n\\t\\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\\n\\t\\tvec3 r123 = sqrt( R123 );\\n\\t\\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\\n\\t\\tvec3 C0 = R12 + Rs;\\n\\t\\tI = C0;\\n\\t\\tvec3 Cm = Rs - T121;\\n\\t\\tfor ( int m = 1; m <= 2; ++ m ) {\\n\\t\\t\\tCm *= r123;\\n\\t\\t\\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\\n\\t\\t\\tI += Cm * Sm;\\n\\t\\t}\\n\\t\\treturn max( I, vec3( 0.0 ) );\\n\\t}\\n#endif\";\n\nvar bumpmap_pars_fragment = \"#ifdef USE_BUMPMAP\\n\\tuniform sampler2D bumpMap;\\n\\tuniform float bumpScale;\\n\\tvec2 dHdxy_fwd() {\\n\\t\\tvec2 dSTdx = dFdx( vUv );\\n\\t\\tvec2 dSTdy = dFdy( vUv );\\n\\t\\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\\n\\t\\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\\n\\t\\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\\n\\t\\treturn vec2( dBx, dBy );\\n\\t}\\n\\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\\n\\t\\tvec3 vSigmaX = dFdx( surf_pos.xyz );\\n\\t\\tvec3 vSigmaY = dFdy( surf_pos.xyz );\\n\\t\\tvec3 vN = surf_norm;\\n\\t\\tvec3 R1 = cross( vSigmaY, vN );\\n\\t\\tvec3 R2 = cross( vN, vSigmaX );\\n\\t\\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\\n\\t\\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\\n\\t\\treturn normalize( abs( fDet ) * surf_norm - vGrad );\\n\\t}\\n#endif\";\n\nvar clipping_planes_fragment = \"#if NUM_CLIPPING_PLANES > 0\\n\\tvec4 plane;\\n\\t#pragma unroll_loop_start\\n\\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\\n\\t\\tplane = clippingPlanes[ i ];\\n\\t\\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\\n\\t}\\n\\t#pragma unroll_loop_end\\n\\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\\n\\t\\tbool clipped = true;\\n\\t\\t#pragma unroll_loop_start\\n\\t\\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\\n\\t\\t\\tplane = clippingPlanes[ i ];\\n\\t\\t\\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\\n\\t\\t}\\n\\t\\t#pragma unroll_loop_end\\n\\t\\tif ( clipped ) discard;\\n\\t#endif\\n#endif\";\n\nvar clipping_planes_pars_fragment = \"#if NUM_CLIPPING_PLANES > 0\\n\\tvarying vec3 vClipPosition;\\n\\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\\n#endif\";\n\nvar clipping_planes_pars_vertex = \"#if NUM_CLIPPING_PLANES > 0\\n\\tvarying vec3 vClipPosition;\\n#endif\";\n\nvar clipping_planes_vertex = \"#if NUM_CLIPPING_PLANES > 0\\n\\tvClipPosition = - mvPosition.xyz;\\n#endif\";\n\nvar color_fragment = \"#if defined( USE_COLOR_ALPHA )\\n\\tdiffuseColor *= vColor;\\n#elif defined( USE_COLOR )\\n\\tdiffuseColor.rgb *= vColor;\\n#endif\";\n\nvar color_pars_fragment = \"#if defined( USE_COLOR_ALPHA )\\n\\tvarying vec4 vColor;\\n#elif defined( USE_COLOR )\\n\\tvarying vec3 vColor;\\n#endif\";\n\nvar color_pars_vertex = \"#if defined( USE_COLOR_ALPHA )\\n\\tvarying vec4 vColor;\\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\\n\\tvarying vec3 vColor;\\n#endif\";\n\nvar color_vertex = \"#if defined( USE_COLOR_ALPHA )\\n\\tvColor = vec4( 1.0 );\\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_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\nvar 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};\\nstruct GeometricContext {\\n\\tvec3 position;\\n\\tvec3 normal;\\n\\tvec3 viewDir;\\n#ifdef USE_CLEARCOAT\\n\\tvec3 clearcoatNormal;\\n#endif\\n};\\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\\n\\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\\n}\\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\\n\\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\\n}\\nmat3 transposeMat3( const in mat3 m ) {\\n\\tmat3 tmp;\\n\\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\\n\\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\\n\\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\\n\\treturn tmp;\\n}\\nfloat luminance( const in vec3 rgb ) {\\n\\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\\n\\treturn dot( weights, rgb );\\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}\";\n\nvar 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\\tvec2 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_v0 0.339\\n\\t#define cubeUV_m0 - 2.0\\n\\t#define cubeUV_r1 0.8\\n\\t#define cubeUV_v1 0.276\\n\\t#define cubeUV_m1 - 1.0\\n\\t#define cubeUV_r4 0.4\\n\\t#define cubeUV_v4 0.046\\n\\t#define cubeUV_m4 2.0\\n\\t#define cubeUV_r5 0.305\\n\\t#define cubeUV_v5 0.016\\n\\t#define cubeUV_m5 3.0\\n\\t#define cubeUV_r6 0.21\\n\\t#define cubeUV_v6 0.0038\\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\";\n\nvar defaultnormal_vertex = \"vec3 transformedNormal = objectNormal;\\n#ifdef USE_INSTANCING\\n\\tmat3 m = mat3( instanceMatrix );\\n\\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\\n\\ttransformedNormal = m * transformedNormal;\\n#endif\\ntransformedNormal = normalMatrix * transformedNormal;\\n#ifdef FLIP_SIDED\\n\\ttransformedNormal = - transformedNormal;\\n#endif\\n#ifdef USE_TANGENT\\n\\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\\n\\t#ifdef FLIP_SIDED\\n\\t\\ttransformedTangent = - transformedTangent;\\n\\t#endif\\n#endif\";\n\nvar displacementmap_pars_vertex = \"#ifdef USE_DISPLACEMENTMAP\\n\\tuniform sampler2D displacementMap;\\n\\tuniform float displacementScale;\\n\\tuniform float displacementBias;\\n#endif\";\n\nvar displacementmap_vertex = \"#ifdef USE_DISPLACEMENTMAP\\n\\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\\n#endif\";\n\nvar emissivemap_fragment = \"#ifdef USE_EMISSIVEMAP\\n\\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\\n\\ttotalEmissiveRadiance *= emissiveColor.rgb;\\n#endif\";\n\nvar emissivemap_pars_fragment = \"#ifdef USE_EMISSIVEMAP\\n\\tuniform sampler2D emissiveMap;\\n#endif\";\n\nvar encodings_fragment = \"gl_FragColor = linearToOutputTexel( gl_FragColor );\";\n\nvar encodings_pars_fragment = \"vec4 LinearToLinear( in vec4 value ) {\\n\\treturn value;\\n}\\nvec4 LinearTosRGB( in vec4 value ) {\\n\\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\\n}\";\n\nvar 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, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\\n\\t#elif defined( ENVMAP_TYPE_CUBE_UV )\\n\\t\\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\\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\";\n\nvar envmap_common_pars_fragment = \"#ifdef USE_ENVMAP\\n\\tuniform float envMapIntensity;\\n\\tuniform float flipEnvMap;\\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\";\n\nvar 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\";\n\nvar 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\";\n\nvar 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\";\n\nvar fog_vertex = \"#ifdef USE_FOG\\n\\tvFogDepth = - mvPosition.z;\\n#endif\";\n\nvar fog_pars_vertex = \"#ifdef USE_FOG\\n\\tvarying float vFogDepth;\\n#endif\";\n\nvar 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\";\n\nvar 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\";\n\nvar 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}\";\n\nvar lightmap_fragment = \"#ifdef USE_LIGHTMAP\\n\\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\\n\\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\\n\\treflectedLight.indirectDiffuse += lightMapIrradiance;\\n#endif\";\n\nvar lightmap_pars_fragment = \"#ifdef USE_LIGHTMAP\\n\\tuniform sampler2D lightMap;\\n\\tuniform float lightMapIntensity;\\n#endif\";\n\nvar lights_lambert_fragment = \"LambertMaterial material;\\nmaterial.diffuseColor = diffuseColor.rgb;\\nmaterial.specularStrength = specularStrength;\";\n\nvar 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 GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\\n\\tfloat dotNL = saturate( dot( geometry.normal, 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 GeometricContext geometry, 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\\n#define Material_LightProbeLOD( material )\\t(0)\";\n\nvar lights_pars_begin = \"uniform bool receiveShadow;\\nuniform vec3 ambientLightColor;\\nuniform vec3 lightProbe[ 9 ];\\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\\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\\n\\t\\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\\n\\t\\tif ( cutoffDistance > 0.0 ) {\\n\\t\\t\\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\\n\\t\\t}\\n\\t\\treturn distanceFalloff;\\n\\t#else\\n\\t\\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\\n\\t\\t\\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\\n\\t\\t}\\n\\t\\treturn 1.0;\\n\\t#endif\\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, const in GeometricContext geometry, 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 GeometricContext geometry, out IncidentLight light ) {\\n\\t\\tvec3 lVector = pointLight.position - geometry.position;\\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 GeometricContext geometry, out IncidentLight light ) {\\n\\t\\tvec3 lVector = spotLight.position - geometry.position;\\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\";\n\nvar envmap_physical_pars_fragment = \"#if defined( USE_ENVMAP )\\n\\tvec3 getIBLIrradiance( const in vec3 normal ) {\\n\\t\\t#if defined( ENVMAP_TYPE_CUBE_UV )\\n\\t\\t\\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\\n\\t\\t\\tvec4 envMapColor = textureCubeUV( envMap, 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#if defined( 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, 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#endif\";\n\nvar lights_toon_fragment = \"ToonMaterial material;\\nmaterial.diffuseColor = diffuseColor.rgb;\";\n\nvar lights_toon_pars_fragment = \"varying vec3 vViewPosition;\\nstruct ToonMaterial {\\n\\tvec3 diffuseColor;\\n};\\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\\n\\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\\n\\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\\n}\\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, 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\\n#define Material_LightProbeLOD( material )\\t(0)\";\n\nvar lights_phong_fragment = \"BlinnPhongMaterial material;\\nmaterial.diffuseColor = diffuseColor.rgb;\\nmaterial.specularColor = specular;\\nmaterial.specularShininess = shininess;\\nmaterial.specularStrength = specularStrength;\";\n\nvar 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 GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\\n\\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\\n\\tvec3 irradiance = dotNL * directLight.color;\\n\\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\\n\\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\\n}\\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\\n\\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\\n}\\n#define RE_Direct\\t\\t\\t\\tRE_Direct_BlinnPhong\\n#define RE_IndirectDiffuse\\t\\tRE_IndirectDiffuse_BlinnPhong\\n#define Material_LightProbeLOD( material )\\t(0)\";\n\nvar lights_physical_fragment = \"PhysicalMaterial material;\\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\\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 SPECULAR\\n\\t\\tfloat specularIntensityFactor = specularIntensity;\\n\\t\\tvec3 specularColorFactor = specularColor;\\n\\t\\t#ifdef USE_SPECULARINTENSITYMAP\\n\\t\\t\\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\\n\\t\\t#endif\\n\\t\\t#ifdef USE_SPECULARCOLORMAP\\n\\t\\t\\tspecularColorFactor *= texture2D( specularColorMap, vUv ).rgb;\\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, vUv ).x;\\n\\t#endif\\n\\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\\n\\t\\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).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_IRIDESCENCE\\n\\tmaterial.iridescence = iridescence;\\n\\tmaterial.iridescenceIOR = iridescenceIOR;\\n\\t#ifdef USE_IRIDESCENCEMAP\\n\\t\\tmaterial.iridescence *= texture2D( iridescenceMap, vUv ).r;\\n\\t#endif\\n\\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\\n\\t\\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).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_SHEENCOLORMAP\\n\\t\\tmaterial.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;\\n\\t#endif\\n\\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\\n\\t#ifdef USE_SHEENROUGHNESSMAP\\n\\t\\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;\\n\\t#endif\\n#endif\";\n\nvar lights_physical_pars_fragment = \"struct PhysicalMaterial {\\n\\tvec3 diffuseColor;\\n\\tfloat roughness;\\n\\tvec3 specularColor;\\n\\tfloat specularF90;\\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};\\nvec3 clearcoatSpecular = vec3( 0.0 );\\nvec3 sheenSpecular = vec3( 0.0 );\\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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\\n\\t\\tvec3 normal = geometry.normal;\\n\\t\\tvec3 viewDir = geometry.viewDir;\\n\\t\\tvec3 position = geometry.position;\\n\\t\\tvec3 lightPos = rectAreaLight.position;\\n\\t\\tvec3 halfWidth = rectAreaLight.halfWidth;\\n\\t\\tvec3 halfHeight = rectAreaLight.halfHeight;\\n\\t\\tvec3 lightColor = rectAreaLight.color;\\n\\t\\tfloat roughness = material.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(\t\t0, 1,\t\t0 ),\\n\\t\\t\\tvec3( t1.z, 0, t1.w )\\n\\t\\t);\\n\\t\\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\\n\\t\\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\\n\\t\\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\\n\\t}\\n#endif\\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\\n\\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\\n\\tvec3 irradiance = dotNL * directLight.color;\\n\\t#ifdef USE_CLEARCOAT\\n\\t\\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\\n\\t\\tvec3 ccIrradiance = dotNLcc * directLight.color;\\n\\t\\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\\n\\t#endif\\n\\t#ifdef USE_SHEEN\\n\\t\\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\\n\\t#endif\\n\\t#ifdef USE_IRIDESCENCE\\n\\t\\treflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness );\\n\\t#else\\n\\t\\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\\n\\t#endif\\n\\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\\n}\\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\\n\\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\\n}\\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\\n\\t#ifdef USE_CLEARCOAT\\n\\t\\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\\n\\t#endif\\n\\t#ifdef USE_SHEEN\\n\\t\\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, 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( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\\n\\t#else\\n\\t\\tcomputeMultiscattering( geometry.normal, geometry.viewDir, 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}\";\n\nvar lights_fragment_begin = \"\\nGeometricContext geometry;\\ngeometry.position = - vViewPosition;\\ngeometry.normal = normal;\\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\\n#ifdef USE_CLEARCOAT\\n\\tgeometry.clearcoatNormal = clearcoatNormal;\\n#endif\\n#ifdef USE_IRIDESCENCE\\n\\tfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\\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, geometry, directLight );\\n\\t\\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\\n\\t\\tpointLightShadow = pointLightShadows[ i ];\\n\\t\\tdirectLight.color *= all( bvec2( 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\\t\\tRE_Direct( directLight, geometry, 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, geometry, 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 *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\\n\\t\\t#endif\\n\\t\\tRE_Direct( directLight, geometry, 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, geometry, directLight );\\n\\t\\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\\n\\t\\tdirectionalLightShadow = directionalLightShadows[ i ];\\n\\t\\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\\n\\t\\t#endif\\n\\t\\tRE_Direct( directLight, geometry, 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, geometry, 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\\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\\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 ], geometry.normal );\\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\";\n\nvar lights_fragment_maps = \"#if defined( RE_IndirectDiffuse )\\n\\t#ifdef USE_LIGHTMAP\\n\\t\\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\\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( geometry.normal );\\n\\t#endif\\n#endif\\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\\n\\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\\n\\t#ifdef USE_CLEARCOAT\\n\\t\\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\\n\\t#endif\\n#endif\";\n\nvar lights_fragment_end = \"#if defined( RE_IndirectDiffuse )\\n\\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\\n#endif\\n#if defined( RE_IndirectSpecular )\\n\\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\\n#endif\";\n\nvar logdepthbuf_fragment = \"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\\n\\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\\n#endif\";\n\nvar logdepthbuf_pars_fragment = \"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\\n\\tuniform float logDepthBufFC;\\n\\tvarying float vFragDepth;\\n\\tvarying float vIsPerspective;\\n#endif\";\n\nvar logdepthbuf_pars_vertex = \"#ifdef USE_LOGDEPTHBUF\\n\\t#ifdef USE_LOGDEPTHBUF_EXT\\n\\t\\tvarying float vFragDepth;\\n\\t\\tvarying float vIsPerspective;\\n\\t#else\\n\\t\\tuniform float logDepthBufFC;\\n\\t#endif\\n#endif\";\n\nvar logdepthbuf_vertex = \"#ifdef USE_LOGDEPTHBUF\\n\\t#ifdef USE_LOGDEPTHBUF_EXT\\n\\t\\tvFragDepth = 1.0 + gl_Position.w;\\n\\t\\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\\n\\t#else\\n\\t\\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\\n\\t\\t\\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\\n\\t\\t\\tgl_Position.z *= gl_Position.w;\\n\\t\\t}\\n\\t#endif\\n#endif\";\n\nvar map_fragment = \"#ifdef USE_MAP\\n\\tvec4 sampledDiffuseColor = texture2D( map, vUv );\\n\\t#ifdef DECODE_VIDEO_TEXTURE\\n\\t\\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\\n\\t#endif\\n\\tdiffuseColor *= sampledDiffuseColor;\\n#endif\";\n\nvar map_pars_fragment = \"#ifdef USE_MAP\\n\\tuniform sampler2D map;\\n#endif\";\n\nvar map_particle_fragment = \"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\\n\\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\\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\";\n\nvar map_particle_pars_fragment = \"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\\n\\tuniform mat3 uvTransform;\\n#endif\\n#ifdef USE_MAP\\n\\tuniform sampler2D map;\\n#endif\\n#ifdef USE_ALPHAMAP\\n\\tuniform sampler2D alphaMap;\\n#endif\";\n\nvar metalnessmap_fragment = \"float metalnessFactor = metalness;\\n#ifdef USE_METALNESSMAP\\n\\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\\n\\tmetalnessFactor *= texelMetalness.b;\\n#endif\";\n\nvar metalnessmap_pars_fragment = \"#ifdef USE_METALNESSMAP\\n\\tuniform sampler2D metalnessMap;\\n#endif\";\n\nvar morphcolor_vertex = \"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\\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\";\n\nvar morphnormal_vertex = \"#ifdef USE_MORPHNORMALS\\n\\tobjectNormal *= morphTargetBaseInfluence;\\n\\t#ifdef MORPHTARGETS_TEXTURE\\n\\t\\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\\n\\t\\t\\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\\n\\t\\t}\\n\\t#else\\n\\t\\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\\n\\t\\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\\n\\t\\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\\n\\t\\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\\n\\t#endif\\n#endif\";\n\nvar morphtarget_pars_vertex = \"#ifdef USE_MORPHTARGETS\\n\\tuniform float morphTargetBaseInfluence;\\n\\t#ifdef MORPHTARGETS_TEXTURE\\n\\t\\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\\n\\t\\tuniform sampler2DArray morphTargetsTexture;\\n\\t\\tuniform ivec2 morphTargetsTextureSize;\\n\\t\\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\\n\\t\\t\\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\\n\\t\\t\\tint y = texelIndex / morphTargetsTextureSize.x;\\n\\t\\t\\tint x = texelIndex - y * morphTargetsTextureSize.x;\\n\\t\\t\\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\\n\\t\\t\\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\\n\\t\\t}\\n\\t#else\\n\\t\\t#ifndef USE_MORPHNORMALS\\n\\t\\t\\tuniform float morphTargetInfluences[ 8 ];\\n\\t\\t#else\\n\\t\\t\\tuniform float morphTargetInfluences[ 4 ];\\n\\t\\t#endif\\n\\t#endif\\n#endif\";\n\nvar morphtarget_vertex = \"#ifdef USE_MORPHTARGETS\\n\\ttransformed *= morphTargetBaseInfluence;\\n\\t#ifdef MORPHTARGETS_TEXTURE\\n\\t\\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\\n\\t\\t\\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\\n\\t\\t}\\n\\t#else\\n\\t\\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\\n\\t\\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\\n\\t\\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\\n\\t\\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\\n\\t\\t#ifndef USE_MORPHNORMALS\\n\\t\\t\\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\\n\\t\\t\\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\\n\\t\\t\\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\\n\\t\\t\\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\\n\\t\\t#endif\\n\\t#endif\\n#endif\";\n\nvar 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 = normal * faceDirection;\\n\\t#endif\\n\\t#ifdef USE_TANGENT\\n\\t\\tvec3 tangent = normalize( vTangent );\\n\\t\\tvec3 bitangent = normalize( vBitangent );\\n\\t\\t#ifdef DOUBLE_SIDED\\n\\t\\t\\ttangent = tangent * faceDirection;\\n\\t\\t\\tbitangent = bitangent * faceDirection;\\n\\t\\t#endif\\n\\t\\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\\n\\t\\t\\tmat3 vTBN = mat3( tangent, bitangent, normal );\\n\\t\\t#endif\\n\\t#endif\\n#endif\\nvec3 geometryNormal = normal;\";\n\nvar normal_fragment_maps = \"#ifdef OBJECTSPACE_NORMALMAP\\n\\tnormal = texture2D( normalMap, vUv ).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( TANGENTSPACE_NORMALMAP )\\n\\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\\n\\tmapN.xy *= normalScale;\\n\\t#ifdef USE_TANGENT\\n\\t\\tnormal = normalize( vTBN * mapN );\\n\\t#else\\n\\t\\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\\n\\t#endif\\n#elif defined( USE_BUMPMAP )\\n\\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\\n#endif\";\n\nvar 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\";\n\nvar 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\";\n\nvar 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\";\n\nvar normalmap_pars_fragment = \"#ifdef USE_NORMALMAP\\n\\tuniform sampler2D normalMap;\\n\\tuniform vec2 normalScale;\\n#endif\\n#ifdef OBJECTSPACE_NORMALMAP\\n\\tuniform mat3 normalMatrix;\\n#endif\\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\\n\\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\\n\\t\\tvec3 q0 = dFdx( eye_pos.xyz );\\n\\t\\tvec3 q1 = dFdy( eye_pos.xyz );\\n\\t\\tvec2 st0 = dFdx( vUv.st );\\n\\t\\tvec2 st1 = dFdy( vUv.st );\\n\\t\\tvec3 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 : faceDirection * inversesqrt( det );\\n\\t\\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\\n\\t}\\n#endif\";\n\nvar clearcoat_normal_fragment_begin = \"#ifdef USE_CLEARCOAT\\n\\tvec3 clearcoatNormal = geometryNormal;\\n#endif\";\n\nvar clearcoat_normal_fragment_maps = \"#ifdef USE_CLEARCOAT_NORMALMAP\\n\\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\\n\\tclearcoatMapN.xy *= clearcoatNormalScale;\\n\\t#ifdef USE_TANGENT\\n\\t\\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\\n\\t#else\\n\\t\\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\\n\\t#endif\\n#endif\";\n\nvar clearcoat_pars_fragment = \"#ifdef USE_CLEARCOATMAP\\n\\tuniform sampler2D clearcoatMap;\\n#endif\\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\\n\\tuniform sampler2D clearcoatRoughnessMap;\\n#endif\\n#ifdef USE_CLEARCOAT_NORMALMAP\\n\\tuniform sampler2D clearcoatNormalMap;\\n\\tuniform vec2 clearcoatNormalScale;\\n#endif\";\n\nvar iridescence_pars_fragment = \"#ifdef USE_IRIDESCENCEMAP\\n\\tuniform sampler2D iridescenceMap;\\n#endif\\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\\n\\tuniform sampler2D iridescenceThicknessMap;\\n#endif\";\n\nvar output_fragment = \"#ifdef OPAQUE\\ndiffuseColor.a = 1.0;\\n#endif\\n#ifdef USE_TRANSMISSION\\ndiffuseColor.a *= material.transmissionAlpha + 0.1;\\n#endif\\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\";\n\nvar packing = \"vec3 packNormalToRGB( const in vec3 normal ) {\\n\\treturn normalize( normal ) * 0.5 + 0.5;\\n}\\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\\n\\treturn 2.0 * rgb.xyz - 1.0;\\n}\\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\\nconst float ShiftRight8 = 1. / 256.;\\nvec4 packDepthToRGBA( const in float v ) {\\n\\tvec4 r = vec4( fract( v * PackFactors ), v );\\n\\tr.yzw -= r.xyz * ShiftRight8;\\treturn r * PackUpscale;\\n}\\nfloat unpackRGBAToDepth( const in vec4 v ) {\\n\\treturn dot( v, UnpackFactors );\\n}\\nvec4 pack2HalfToRGBA( 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( 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 linearClipZ, const in float near, const in float far ) {\\n\\treturn linearClipZ * ( near - far ) - near;\\n}\\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\\n\\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\\n}\\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\\n\\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\\n}\";\n\nvar premultiplied_alpha_fragment = \"#ifdef PREMULTIPLIED_ALPHA\\n\\tgl_FragColor.rgb *= gl_FragColor.a;\\n#endif\";\n\nvar project_vertex = \"vec4 mvPosition = vec4( transformed, 1.0 );\\n#ifdef USE_INSTANCING\\n\\tmvPosition = instanceMatrix * mvPosition;\\n#endif\\nmvPosition = modelViewMatrix * mvPosition;\\ngl_Position = projectionMatrix * mvPosition;\";\n\nvar dithering_fragment = \"#ifdef DITHERING\\n\\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\\n#endif\";\n\nvar 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\";\n\nvar roughnessmap_fragment = \"float roughnessFactor = roughness;\\n#ifdef USE_ROUGHNESSMAP\\n\\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\\n\\troughnessFactor *= texelRoughness.g;\\n#endif\";\n\nvar roughnessmap_pars_fragment = \"#ifdef USE_ROUGHNESSMAP\\n\\tuniform sampler2D roughnessMap;\\n#endif\";\n\nvar 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 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 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 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 shadowBias, float shadowRadius, vec4 shadowCoord ) {\\n\\t\\tfloat shadow = 1.0;\\n\\t\\tshadowCoord.xyz /= shadowCoord.w;\\n\\t\\tshadowCoord.z += shadowBias;\\n\\t\\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\\n\\t\\tbool inFrustum = all( inFrustumVec );\\n\\t\\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\\n\\t\\tbool frustumTest = all( frustumTestVec );\\n\\t\\tif ( frustumTest ) {\\n\\t\\t#if defined( SHADOWMAP_TYPE_PCF )\\n\\t\\t\\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\\n\\t\\t\\tfloat dx0 = - texelSize.x * shadowRadius;\\n\\t\\t\\tfloat dy0 = - texelSize.y * shadowRadius;\\n\\t\\t\\tfloat dx1 = + texelSize.x * shadowRadius;\\n\\t\\t\\tfloat dy1 = + texelSize.y * shadowRadius;\\n\\t\\t\\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\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\\n\\t\\t\\t\\t\\t\\t\tf.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\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\\n\\t\\t\\t\\t\\t\\t\tf.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 shadow;\\n\\t}\\n\\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\\n\\t\\tvec3 absV = abs( v );\\n\\t\\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\\n\\t\\tabsV *= scaleToCube;\\n\\t\\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\\n\\t\\tvec2 planar = v.xy;\\n\\t\\tfloat almostATexel = 1.5 * texelSizeY;\\n\\t\\tfloat almostOne = 1.0 - almostATexel;\\n\\t\\tif ( absV.z >= almostOne ) {\\n\\t\\t\\tif ( v.z > 0.0 )\\n\\t\\t\\t\\tplanar.x = 4.0 - v.x;\\n\\t\\t} else if ( absV.x >= almostOne ) {\\n\\t\\t\\tfloat signX = sign( v.x );\\n\\t\\t\\tplanar.x = v.z * signX + 2.0 * signX;\\n\\t\\t} else if ( absV.y >= almostOne ) {\\n\\t\\t\\tfloat signY = sign( v.y );\\n\\t\\t\\tplanar.x = v.x + 2.0 * signY + 2.0;\\n\\t\\t\\tplanar.y = v.z * signY - 2.0;\\n\\t\\t}\\n\\t\\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\\n\\t}\\n\\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\\n\\t\\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\\n\\t\\tvec3 lightToPosition = shadowCoord.xyz;\\n\\t\\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\\t\\tdp += shadowBias;\\n\\t\\tvec3 bd3D = normalize( lightToPosition );\\n\\t\\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\\n\\t\\t\\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\\n\\t\\t\\treturn (\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\\n\\t\\t\\t) * ( 1.0 / 9.0 );\\n\\t\\t#else\\n\\t\\t\\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\\n\\t\\t#endif\\n\\t}\\n#endif\";\n\nvar 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 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 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 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\";\n\nvar shadowmap_vertex = \"#if defined( USE_SHADOWMAP ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\\n\\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_COORDS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\\n\\t\\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\\n\\t\\tvec4 shadowWorldPosition;\\n\\t#endif\\n\\t#if NUM_DIR_LIGHT_SHADOWS > 0\\n\\t#pragma unroll_loop_start\\n\\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\\n\\t\\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\\n\\t\\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\\n\\t}\\n\\t#pragma unroll_loop_end\\n\\t#endif\\n\\t#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\\t#endif\\n\\t#if NUM_POINT_LIGHT_SHADOWS > 0\\n\\t#pragma unroll_loop_start\\n\\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\\n\\t\\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\\n\\t\\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\\n\\t}\\n\\t#pragma unroll_loop_end\\n\\t#endif\\n#endif\";\n\nvar 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.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.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.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}\";\n\nvar 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\";\n\nvar skinning_pars_vertex = \"#ifdef USE_SKINNING\\n\\tuniform mat4 bindMatrix;\\n\\tuniform mat4 bindMatrixInverse;\\n\\tuniform highp sampler2D boneTexture;\\n\\tuniform int boneTextureSize;\\n\\tmat4 getBoneMatrix( const in float i ) {\\n\\t\\tfloat j = i * 4.0;\\n\\t\\tfloat x = mod( j, float( boneTextureSize ) );\\n\\t\\tfloat y = floor( j / float( boneTextureSize ) );\\n\\t\\tfloat dx = 1.0 / float( boneTextureSize );\\n\\t\\tfloat dy = 1.0 / float( boneTextureSize );\\n\\t\\ty = dy * ( y + 0.5 );\\n\\t\\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\\n\\t\\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\\n\\t\\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\\n\\t\\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\\n\\t\\tmat4 bone = mat4( v1, v2, v3, v4 );\\n\\t\\treturn bone;\\n\\t}\\n#endif\";\n\nvar skinning_vertex = \"#ifdef USE_SKINNING\\n\\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\\n\\tvec4 skinned = vec4( 0.0 );\\n\\tskinned += boneMatX * skinVertex * skinWeight.x;\\n\\tskinned += boneMatY * skinVertex * skinWeight.y;\\n\\tskinned += boneMatZ * skinVertex * skinWeight.z;\\n\\tskinned += boneMatW * skinVertex * skinWeight.w;\\n\\ttransformed = ( bindMatrixInverse * skinned ).xyz;\\n#endif\";\n\nvar 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\";\n\nvar specularmap_fragment = \"float specularStrength;\\n#ifdef USE_SPECULARMAP\\n\\tvec4 texelSpecular = texture2D( specularMap, vUv );\\n\\tspecularStrength = texelSpecular.r;\\n#else\\n\\tspecularStrength = 1.0;\\n#endif\";\n\nvar specularmap_pars_fragment = \"#ifdef USE_SPECULARMAP\\n\\tuniform sampler2D specularMap;\\n#endif\";\n\nvar tonemapping_fragment = \"#if defined( TONE_MAPPING )\\n\\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\\n#endif\";\n\nvar 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 toneMappingExposure * color;\\n}\\nvec3 ReinhardToneMapping( vec3 color ) {\\n\\tcolor *= toneMappingExposure;\\n\\treturn saturate( color / ( vec3( 1.0 ) + color ) );\\n}\\nvec3 OptimizedCineonToneMapping( vec3 color ) {\\n\\tcolor *= toneMappingExposure;\\n\\tcolor = max( vec3( 0.0 ), color - 0.004 );\\n\\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\\n}\\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(\t1.60475, -0.10208, -0.00327 ),\\t\\tvec3( -0.53108,\t1.10813, -0.07276 ),\\n\\t\\tvec3( -0.07367, -0.00605,\t1.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}\\nvec3 CustomToneMapping( vec3 color ) { return color; }\";\n\nvar 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, vUv ).r;\\n\\t#endif\\n\\t#ifdef USE_THICKNESSMAP\\n\\t\\tmaterial.thickness *= texture2D( thicknessMap, vUv ).g;\\n\\t#endif\\n\\tvec3 pos = vWorldPosition;\\n\\tvec3 v = normalize( cameraPosition - pos );\\n\\tvec3 n = inverseTransformDirection( normal, viewMatrix );\\n\\tvec4 transmission = getIBLVolumeRefraction(\\n\\t\\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\\n\\t\\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\\n\\t\\tmaterial.attenuationColor, material.attenuationDistance );\\n\\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission );\\n\\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission );\\n#endif\";\n\nvar 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\\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 framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\\n\\t\\t#ifdef texture2DLodEXT\\n\\t\\t\\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\\n\\t\\t#else\\n\\t\\t\\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\\n\\t\\t#endif\\n\\t}\\n\\tvec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\\n\\t\\tif ( isinf( attenuationDistance ) ) {\\n\\t\\t\\treturn radiance;\\n\\t\\t} else {\\n\\t\\t\\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\\n\\t\\t\\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\\t\\t\\treturn transmittance * radiance;\\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 ior, const in float thickness,\\n\\t\\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\\n\\t\\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\\n\\t\\tvec3 refractedRayExit = position + transmissionRay;\\n\\t\\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\\n\\t\\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\\n\\t\\trefractionCoords += 1.0;\\n\\t\\trefractionCoords /= 2.0;\\n\\t\\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\\n\\t\\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\\n\\t\\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\\n\\t\\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\\n\\t}\\n#endif\";\n\nvar uv_pars_fragment = \"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\\n\\tvarying vec2 vUv;\\n#endif\";\n\nvar uv_pars_vertex = \"#ifdef USE_UV\\n\\t#ifdef UVS_VERTEX_ONLY\\n\\t\\tvec2 vUv;\\n\\t#else\\n\\t\\tvarying vec2 vUv;\\n\\t#endif\\n\\tuniform mat3 uvTransform;\\n#endif\";\n\nvar uv_vertex = \"#ifdef USE_UV\\n\\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\\n#endif\";\n\nvar uv2_pars_fragment = \"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\\n\\tvarying vec2 vUv2;\\n#endif\";\n\nvar uv2_pars_vertex = \"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\\n\\tattribute vec2 uv2;\\n\\tvarying vec2 vUv2;\\n\\tuniform mat3 uv2Transform;\\n#endif\";\n\nvar uv2_vertex = \"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\\n\\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\\n#endif\";\n\nvar 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_INSTANCING\\n\\t\\tworldPosition = instanceMatrix * worldPosition;\\n\\t#endif\\n\\tworldPosition = modelMatrix * worldPosition;\\n#endif\";\n\nconst vertex$g = \"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}\";\nconst fragment$g = \"uniform sampler2D t2D;\\nvarying vec2 vUv;\\nvoid main() {\\n\\tgl_FragColor = texture2D( t2D, vUv );\\n\\t#ifdef DECODE_VIDEO_TEXTURE\\n\\t\\tgl_FragColor = vec4( mix( pow( gl_FragColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), gl_FragColor.rgb * 0.0773993808, vec3( lessThanEqual( gl_FragColor.rgb, vec3( 0.04045 ) ) ) ), gl_FragColor.w );\\n\\t#endif\\n\\t#include \\n\\t#include \\n}\";\n\nconst vertex$f = \"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}\";\nconst fragment$f = \"#include \\nuniform float opacity;\\nvarying vec3 vWorldDirection;\\n#include \\nvoid main() {\\n\\tvec3 vReflect = vWorldDirection;\\n\\t#include \\n\\tgl_FragColor = envColor;\\n\\tgl_FragColor.a *= opacity;\\n\\t#include \\n\\t#include \\n}\";\n\nconst vertex$e = \"#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#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}\";\nconst fragment$e = \"#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 \\nvarying vec2 vHighPrecisionZW;\\nvoid main() {\\n\\t#include \\n\\tvec4 diffuseColor = vec4( 1.0 );\\n\\t#if DEPTH_PACKING == 3200\\n\\t\\tdiffuseColor.a = opacity;\\n\\t#endif\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\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#endif\\n}\";\n\nconst vertex$d = \"#define DISTANCE\\nvarying vec3 vWorldPosition;\\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\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}\";\nconst fragment$d = \"#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 \\nvoid main () {\\n\\t#include \\n\\tvec4 diffuseColor = vec4( 1.0 );\\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}\";\n\nconst vertex$c = \"varying vec3 vWorldDirection;\\n#include \\nvoid main() {\\n\\tvWorldDirection = transformDirection( position, modelMatrix );\\n\\t#include \\n\\t#include \\n}\";\nconst fragment$c = \"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}\";\n\nconst vertex$b = \"uniform float scale;\\nattribute float lineDistance;\\nvarying float vLineDistance;\\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}\";\nconst fragment$b = \"uniform vec3 diffuse;\\nuniform float opacity;\\nuniform float dashSize;\\nuniform float totalSize;\\nvarying float vLineDistance;\\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\t#include \\n\\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\\n\\t\\tdiscard;\\n\\t}\\n\\tvec3 outgoingLight = vec3( 0.0 );\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\t#include \\n\\t#include \\n\\toutgoingLight = diffuseColor.rgb;\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n}\";\n\nconst vertex$a = \"#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#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}\";\nconst fragment$a = \"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\\t#include \\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\\n\\t#ifdef USE_LIGHTMAP\\n\\t\\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\\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}\";\n\nconst vertex$9 = \"#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\\tvViewPosition = - mvPosition.xyz;\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n}\";\nconst fragment$9 = \"#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\\t#include \\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\\n\\tvec3 totalEmissiveRadiance = emissive;\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n}\";\n\nconst vertex$8 = \"#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 \\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\\tvViewPosition = - mvPosition.xyz;\\n}\";\nconst fragment$8 = \"#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 \\nvoid main() {\\n\\t#include \\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\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}\";\n\nconst vertex$7 = \"#define NORMAL\\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\\n\\tvarying vec3 vViewPosition;\\n#endif\\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#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\\n\\tvViewPosition = - mvPosition.xyz;\\n#endif\\n}\";\nconst fragment$7 = \"#define NORMAL\\nuniform float opacity;\\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\\n\\tvarying vec3 vViewPosition;\\n#endif\\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\\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\\n\\t#ifdef OPAQUE\\n\\t\\tgl_FragColor.a = 1.0;\\n\\t#endif\\n}\";\n\nconst vertex$6 = \"#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\\tvViewPosition = - mvPosition.xyz;\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n}\";\nconst fragment$6 = \"#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\\t#include \\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\\n\\tvec3 totalEmissiveRadiance = emissive;\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n}\";\n\nconst vertex$5 = \"#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\\tvViewPosition = - mvPosition.xyz;\\n\\t#include \\n\\t#include \\n\\t#include \\n#ifdef USE_TRANSMISSION\\n\\tvWorldPosition = worldPosition.xyz;\\n#endif\\n}\";\nconst fragment$5 = \"#define STANDARD\\n#ifdef PHYSICAL\\n\\t#define IOR\\n\\t#define 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 SPECULAR\\n\\tuniform float specularIntensity;\\n\\tuniform vec3 specularColor;\\n\\t#ifdef USE_SPECULARINTENSITYMAP\\n\\t\\tuniform sampler2D specularIntensityMap;\\n\\t#endif\\n\\t#ifdef USE_SPECULARCOLORMAP\\n\\t\\tuniform sampler2D specularColorMap;\\n\\t#endif\\n#endif\\n#ifdef USE_CLEARCOAT\\n\\tuniform float clearcoat;\\n\\tuniform float clearcoatRoughness;\\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_SHEENCOLORMAP\\n\\t\\tuniform sampler2D sheenColorMap;\\n\\t#endif\\n\\t#ifdef USE_SHEENROUGHNESSMAP\\n\\t\\tuniform sampler2D sheenRoughnessMap;\\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 \\n#include \\nvoid main() {\\n\\t#include \\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\\n\\tvec3 totalEmissiveRadiance = emissive;\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\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 + sheenSpecular;\\n\\t#endif\\n\\t#ifdef USE_CLEARCOAT\\n\\t\\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\\n\\t\\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\\n\\t\\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\\n\\t#endif\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n}\";\n\nconst vertex$4 = \"#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\\tvViewPosition = - mvPosition.xyz;\\n\\t#include \\n\\t#include \\n\\t#include \\n}\";\nconst fragment$4 = \"#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\\t#include \\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\\n\\tvec3 totalEmissiveRadiance = emissive;\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\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}\";\n\nconst vertex$3 = \"uniform float size;\\nuniform float scale;\\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#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}\";\nconst fragment$3 = \"uniform vec3 diffuse;\\nuniform float opacity;\\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\t#include \\n\\tvec3 outgoingLight = vec3( 0.0 );\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\toutgoingLight = diffuseColor.rgb;\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n}\";\n\nconst vertex$2 = \"#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}\";\nconst fragment$2 = \"uniform vec3 color;\\nuniform float opacity;\\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\\n\\t#include \\n\\t#include \\n\\t#include \\n}\";\n\nconst vertex$1 = \"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 * vec4( 0.0, 0.0, 0.0, 1.0 );\\n\\tvec2 scale;\\n\\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\\n\\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\\n\\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}\";\nconst fragment$1 = \"uniform vec3 diffuse;\\nuniform float opacity;\\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\n#include \\nvoid main() {\\n\\t#include \\n\\tvec3 outgoingLight = vec3( 0.0 );\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n\\toutgoingLight = diffuseColor.rgb;\\n\\t#include \\n\\t#include \\n\\t#include \\n\\t#include \\n}\";\n\nconst ShaderChunk = {\n\talphamap_fragment: alphamap_fragment,\n\talphamap_pars_fragment: alphamap_pars_fragment,\n\talphatest_fragment: alphatest_fragment,\n\talphatest_pars_fragment: alphatest_pars_fragment,\n\taomap_fragment: aomap_fragment,\n\taomap_pars_fragment: aomap_pars_fragment,\n\tbegin_vertex: begin_vertex,\n\tbeginnormal_vertex: beginnormal_vertex,\n\tbsdfs: bsdfs,\n\tiridescence_fragment: iridescence_fragment,\n\tbumpmap_pars_fragment: bumpmap_pars_fragment,\n\tclipping_planes_fragment: clipping_planes_fragment,\n\tclipping_planes_pars_fragment: clipping_planes_pars_fragment,\n\tclipping_planes_pars_vertex: clipping_planes_pars_vertex,\n\tclipping_planes_vertex: clipping_planes_vertex,\n\tcolor_fragment: color_fragment,\n\tcolor_pars_fragment: color_pars_fragment,\n\tcolor_pars_vertex: color_pars_vertex,\n\tcolor_vertex: color_vertex,\n\tcommon: common,\n\tcube_uv_reflection_fragment: cube_uv_reflection_fragment,\n\tdefaultnormal_vertex: defaultnormal_vertex,\n\tdisplacementmap_pars_vertex: displacementmap_pars_vertex,\n\tdisplacementmap_vertex: displacementmap_vertex,\n\temissivemap_fragment: emissivemap_fragment,\n\temissivemap_pars_fragment: emissivemap_pars_fragment,\n\tencodings_fragment: encodings_fragment,\n\tencodings_pars_fragment: encodings_pars_fragment,\n\tenvmap_fragment: envmap_fragment,\n\tenvmap_common_pars_fragment: envmap_common_pars_fragment,\n\tenvmap_pars_fragment: envmap_pars_fragment,\n\tenvmap_pars_vertex: envmap_pars_vertex,\n\tenvmap_physical_pars_fragment: envmap_physical_pars_fragment,\n\tenvmap_vertex: envmap_vertex,\n\tfog_vertex: fog_vertex,\n\tfog_pars_vertex: fog_pars_vertex,\n\tfog_fragment: fog_fragment,\n\tfog_pars_fragment: fog_pars_fragment,\n\tgradientmap_pars_fragment: gradientmap_pars_fragment,\n\tlightmap_fragment: lightmap_fragment,\n\tlightmap_pars_fragment: lightmap_pars_fragment,\n\tlights_lambert_fragment: lights_lambert_fragment,\n\tlights_lambert_pars_fragment: lights_lambert_pars_fragment,\n\tlights_pars_begin: lights_pars_begin,\n\tlights_toon_fragment: lights_toon_fragment,\n\tlights_toon_pars_fragment: lights_toon_pars_fragment,\n\tlights_phong_fragment: lights_phong_fragment,\n\tlights_phong_pars_fragment: lights_phong_pars_fragment,\n\tlights_physical_fragment: lights_physical_fragment,\n\tlights_physical_pars_fragment: lights_physical_pars_fragment,\n\tlights_fragment_begin: lights_fragment_begin,\n\tlights_fragment_maps: lights_fragment_maps,\n\tlights_fragment_end: lights_fragment_end,\n\tlogdepthbuf_fragment: logdepthbuf_fragment,\n\tlogdepthbuf_pars_fragment: logdepthbuf_pars_fragment,\n\tlogdepthbuf_pars_vertex: logdepthbuf_pars_vertex,\n\tlogdepthbuf_vertex: logdepthbuf_vertex,\n\tmap_fragment: map_fragment,\n\tmap_pars_fragment: map_pars_fragment,\n\tmap_particle_fragment: map_particle_fragment,\n\tmap_particle_pars_fragment: map_particle_pars_fragment,\n\tmetalnessmap_fragment: metalnessmap_fragment,\n\tmetalnessmap_pars_fragment: metalnessmap_pars_fragment,\n\tmorphcolor_vertex: morphcolor_vertex,\n\tmorphnormal_vertex: morphnormal_vertex,\n\tmorphtarget_pars_vertex: morphtarget_pars_vertex,\n\tmorphtarget_vertex: morphtarget_vertex,\n\tnormal_fragment_begin: normal_fragment_begin,\n\tnormal_fragment_maps: normal_fragment_maps,\n\tnormal_pars_fragment: normal_pars_fragment,\n\tnormal_pars_vertex: normal_pars_vertex,\n\tnormal_vertex: normal_vertex,\n\tnormalmap_pars_fragment: normalmap_pars_fragment,\n\tclearcoat_normal_fragment_begin: clearcoat_normal_fragment_begin,\n\tclearcoat_normal_fragment_maps: clearcoat_normal_fragment_maps,\n\tclearcoat_pars_fragment: clearcoat_pars_fragment,\n\tiridescence_pars_fragment: iridescence_pars_fragment,\n\toutput_fragment: output_fragment,\n\tpacking: packing,\n\tpremultiplied_alpha_fragment: premultiplied_alpha_fragment,\n\tproject_vertex: project_vertex,\n\tdithering_fragment: dithering_fragment,\n\tdithering_pars_fragment: dithering_pars_fragment,\n\troughnessmap_fragment: roughnessmap_fragment,\n\troughnessmap_pars_fragment: roughnessmap_pars_fragment,\n\tshadowmap_pars_fragment: shadowmap_pars_fragment,\n\tshadowmap_pars_vertex: shadowmap_pars_vertex,\n\tshadowmap_vertex: shadowmap_vertex,\n\tshadowmask_pars_fragment: shadowmask_pars_fragment,\n\tskinbase_vertex: skinbase_vertex,\n\tskinning_pars_vertex: skinning_pars_vertex,\n\tskinning_vertex: skinning_vertex,\n\tskinnormal_vertex: skinnormal_vertex,\n\tspecularmap_fragment: specularmap_fragment,\n\tspecularmap_pars_fragment: specularmap_pars_fragment,\n\ttonemapping_fragment: tonemapping_fragment,\n\ttonemapping_pars_fragment: tonemapping_pars_fragment,\n\ttransmission_fragment: transmission_fragment,\n\ttransmission_pars_fragment: transmission_pars_fragment,\n\tuv_pars_fragment: uv_pars_fragment,\n\tuv_pars_vertex: uv_pars_vertex,\n\tuv_vertex: uv_vertex,\n\tuv2_pars_fragment: uv2_pars_fragment,\n\tuv2_pars_vertex: uv2_pars_vertex,\n\tuv2_vertex: uv2_vertex,\n\tworldpos_vertex: worldpos_vertex,\n\tbackground_vert: vertex$g,\n\tbackground_frag: fragment$g,\n\tcube_vert: vertex$f,\n\tcube_frag: fragment$f,\n\tdepth_vert: vertex$e,\n\tdepth_frag: fragment$e,\n\tdistanceRGBA_vert: vertex$d,\n\tdistanceRGBA_frag: fragment$d,\n\tequirect_vert: vertex$c,\n\tequirect_frag: fragment$c,\n\tlinedashed_vert: vertex$b,\n\tlinedashed_frag: fragment$b,\n\tmeshbasic_vert: vertex$a,\n\tmeshbasic_frag: fragment$a,\n\tmeshlambert_vert: vertex$9,\n\tmeshlambert_frag: fragment$9,\n\tmeshmatcap_vert: vertex$8,\n\tmeshmatcap_frag: fragment$8,\n\tmeshnormal_vert: vertex$7,\n\tmeshnormal_frag: fragment$7,\n\tmeshphong_vert: vertex$6,\n\tmeshphong_frag: fragment$6,\n\tmeshphysical_vert: vertex$5,\n\tmeshphysical_frag: fragment$5,\n\tmeshtoon_vert: vertex$4,\n\tmeshtoon_frag: fragment$4,\n\tpoints_vert: vertex$3,\n\tpoints_frag: fragment$3,\n\tshadow_vert: vertex$2,\n\tshadow_frag: fragment$2,\n\tsprite_vert: vertex$1,\n\tsprite_frag: fragment$1\n};\n\n/**\n * Uniforms library for shared webgl shaders\n */\n\nconst UniformsLib = {\n\tcommon: {\n\t\tdiffuse: {\n\t\t\tvalue: /*@__PURE__*/new Color(0xffffff)\n\t\t},\n\t\topacity: {\n\t\t\tvalue: 1.0\n\t\t},\n\t\tmap: {\n\t\t\tvalue: null\n\t\t},\n\t\tuvTransform: {\n\t\t\tvalue: /*@__PURE__*/new Matrix3()\n\t\t},\n\t\tuv2Transform: {\n\t\t\tvalue: /*@__PURE__*/new Matrix3()\n\t\t},\n\t\talphaMap: {\n\t\t\tvalue: null\n\t\t},\n\t\talphaTest: {\n\t\t\tvalue: 0\n\t\t}\n\t},\n\tspecularmap: {\n\t\tspecularMap: {\n\t\t\tvalue: null\n\t\t}\n\t},\n\tenvmap: {\n\t\tenvMap: {\n\t\t\tvalue: null\n\t\t},\n\t\tflipEnvMap: {\n\t\t\tvalue: -1\n\t\t},\n\t\treflectivity: {\n\t\t\tvalue: 1.0\n\t\t},\n\t\t// basic, lambert, phong\n\t\tior: {\n\t\t\tvalue: 1.5\n\t\t},\n\t\t// physical\n\t\trefractionRatio: {\n\t\t\tvalue: 0.98\n\t\t} // basic, lambert, phong\n\n\t},\n\taomap: {\n\t\taoMap: {\n\t\t\tvalue: null\n\t\t},\n\t\taoMapIntensity: {\n\t\t\tvalue: 1\n\t\t}\n\t},\n\tlightmap: {\n\t\tlightMap: {\n\t\t\tvalue: null\n\t\t},\n\t\tlightMapIntensity: {\n\t\t\tvalue: 1\n\t\t}\n\t},\n\temissivemap: {\n\t\temissiveMap: {\n\t\t\tvalue: null\n\t\t}\n\t},\n\tbumpmap: {\n\t\tbumpMap: {\n\t\t\tvalue: null\n\t\t},\n\t\tbumpScale: {\n\t\t\tvalue: 1\n\t\t}\n\t},\n\tnormalmap: {\n\t\tnormalMap: {\n\t\t\tvalue: null\n\t\t},\n\t\tnormalScale: {\n\t\t\tvalue: /*@__PURE__*/new Vector2(1, 1)\n\t\t}\n\t},\n\tdisplacementmap: {\n\t\tdisplacementMap: {\n\t\t\tvalue: null\n\t\t},\n\t\tdisplacementScale: {\n\t\t\tvalue: 1\n\t\t},\n\t\tdisplacementBias: {\n\t\t\tvalue: 0\n\t\t}\n\t},\n\troughnessmap: {\n\t\troughnessMap: {\n\t\t\tvalue: null\n\t\t}\n\t},\n\tmetalnessmap: {\n\t\tmetalnessMap: {\n\t\t\tvalue: null\n\t\t}\n\t},\n\tgradientmap: {\n\t\tgradientMap: {\n\t\t\tvalue: null\n\t\t}\n\t},\n\tfog: {\n\t\tfogDensity: {\n\t\t\tvalue: 0.00025\n\t\t},\n\t\tfogNear: {\n\t\t\tvalue: 1\n\t\t},\n\t\tfogFar: {\n\t\t\tvalue: 2000\n\t\t},\n\t\tfogColor: {\n\t\t\tvalue: /*@__PURE__*/new Color(0xffffff)\n\t\t}\n\t},\n\tlights: {\n\t\tambientLightColor: {\n\t\t\tvalue: []\n\t\t},\n\t\tlightProbe: {\n\t\t\tvalue: []\n\t\t},\n\t\tdirectionalLights: {\n\t\t\tvalue: [],\n\t\t\tproperties: {\n\t\t\t\tdirection: {},\n\t\t\t\tcolor: {}\n\t\t\t}\n\t\t},\n\t\tdirectionalLightShadows: {\n\t\t\tvalue: [],\n\t\t\tproperties: {\n\t\t\t\tshadowBias: {},\n\t\t\t\tshadowNormalBias: {},\n\t\t\t\tshadowRadius: {},\n\t\t\t\tshadowMapSize: {}\n\t\t\t}\n\t\t},\n\t\tdirectionalShadowMap: {\n\t\t\tvalue: []\n\t\t},\n\t\tdirectionalShadowMatrix: {\n\t\t\tvalue: []\n\t\t},\n\t\tspotLights: {\n\t\t\tvalue: [],\n\t\t\tproperties: {\n\t\t\t\tcolor: {},\n\t\t\t\tposition: {},\n\t\t\t\tdirection: {},\n\t\t\t\tdistance: {},\n\t\t\t\tconeCos: {},\n\t\t\t\tpenumbraCos: {},\n\t\t\t\tdecay: {}\n\t\t\t}\n\t\t},\n\t\tspotLightShadows: {\n\t\t\tvalue: [],\n\t\t\tproperties: {\n\t\t\t\tshadowBias: {},\n\t\t\t\tshadowNormalBias: {},\n\t\t\t\tshadowRadius: {},\n\t\t\t\tshadowMapSize: {}\n\t\t\t}\n\t\t},\n\t\tspotLightMap: {\n\t\t\tvalue: []\n\t\t},\n\t\tspotShadowMap: {\n\t\t\tvalue: []\n\t\t},\n\t\tspotLightMatrix: {\n\t\t\tvalue: []\n\t\t},\n\t\tpointLights: {\n\t\t\tvalue: [],\n\t\t\tproperties: {\n\t\t\t\tcolor: {},\n\t\t\t\tposition: {},\n\t\t\t\tdecay: {},\n\t\t\t\tdistance: {}\n\t\t\t}\n\t\t},\n\t\tpointLightShadows: {\n\t\t\tvalue: [],\n\t\t\tproperties: {\n\t\t\t\tshadowBias: {},\n\t\t\t\tshadowNormalBias: {},\n\t\t\t\tshadowRadius: {},\n\t\t\t\tshadowMapSize: {},\n\t\t\t\tshadowCameraNear: {},\n\t\t\t\tshadowCameraFar: {}\n\t\t\t}\n\t\t},\n\t\tpointShadowMap: {\n\t\t\tvalue: []\n\t\t},\n\t\tpointShadowMatrix: {\n\t\t\tvalue: []\n\t\t},\n\t\themisphereLights: {\n\t\t\tvalue: [],\n\t\t\tproperties: {\n\t\t\t\tdirection: {},\n\t\t\t\tskyColor: {},\n\t\t\t\tgroundColor: {}\n\t\t\t}\n\t\t},\n\t\t// TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src\n\t\trectAreaLights: {\n\t\t\tvalue: [],\n\t\t\tproperties: {\n\t\t\t\tcolor: {},\n\t\t\t\tposition: {},\n\t\t\t\twidth: {},\n\t\t\t\theight: {}\n\t\t\t}\n\t\t},\n\t\tltc_1: {\n\t\t\tvalue: null\n\t\t},\n\t\tltc_2: {\n\t\t\tvalue: null\n\t\t}\n\t},\n\tpoints: {\n\t\tdiffuse: {\n\t\t\tvalue: /*@__PURE__*/new Color(0xffffff)\n\t\t},\n\t\topacity: {\n\t\t\tvalue: 1.0\n\t\t},\n\t\tsize: {\n\t\t\tvalue: 1.0\n\t\t},\n\t\tscale: {\n\t\t\tvalue: 1.0\n\t\t},\n\t\tmap: {\n\t\t\tvalue: null\n\t\t},\n\t\talphaMap: {\n\t\t\tvalue: null\n\t\t},\n\t\talphaTest: {\n\t\t\tvalue: 0\n\t\t},\n\t\tuvTransform: {\n\t\t\tvalue: /*@__PURE__*/new Matrix3()\n\t\t}\n\t},\n\tsprite: {\n\t\tdiffuse: {\n\t\t\tvalue: /*@__PURE__*/new Color(0xffffff)\n\t\t},\n\t\topacity: {\n\t\t\tvalue: 1.0\n\t\t},\n\t\tcenter: {\n\t\t\tvalue: /*@__PURE__*/new Vector2(0.5, 0.5)\n\t\t},\n\t\trotation: {\n\t\t\tvalue: 0.0\n\t\t},\n\t\tmap: {\n\t\t\tvalue: null\n\t\t},\n\t\talphaMap: {\n\t\t\tvalue: null\n\t\t},\n\t\talphaTest: {\n\t\t\tvalue: 0\n\t\t},\n\t\tuvTransform: {\n\t\t\tvalue: /*@__PURE__*/new Matrix3()\n\t\t}\n\t}\n};\n\nconst ShaderLib = {\n\tbasic: {\n\t\tuniforms: /*@__PURE__*/mergeUniforms([UniformsLib.common, UniformsLib.specularmap, UniformsLib.envmap, UniformsLib.aomap, UniformsLib.lightmap, UniformsLib.fog]),\n\t\tvertexShader: ShaderChunk.meshbasic_vert,\n\t\tfragmentShader: ShaderChunk.meshbasic_frag\n\t},\n\tlambert: {\n\t\tuniforms: /*@__PURE__*/mergeUniforms([UniformsLib.common, UniformsLib.specularmap, UniformsLib.envmap, UniformsLib.aomap, UniformsLib.lightmap, UniformsLib.emissivemap, UniformsLib.bumpmap, UniformsLib.normalmap, UniformsLib.displacementmap, UniformsLib.fog, UniformsLib.lights, {\n\t\t\temissive: {\n\t\t\t\tvalue: /*@__PURE__*/new Color(0x000000)\n\t\t\t}\n\t\t}]),\n\t\tvertexShader: ShaderChunk.meshlambert_vert,\n\t\tfragmentShader: ShaderChunk.meshlambert_frag\n\t},\n\tphong: {\n\t\tuniforms: /*@__PURE__*/mergeUniforms([UniformsLib.common, UniformsLib.specularmap, UniformsLib.envmap, UniformsLib.aomap, UniformsLib.lightmap, UniformsLib.emissivemap, UniformsLib.bumpmap, UniformsLib.normalmap, UniformsLib.displacementmap, UniformsLib.fog, UniformsLib.lights, {\n\t\t\temissive: {\n\t\t\t\tvalue: /*@__PURE__*/new Color(0x000000)\n\t\t\t},\n\t\t\tspecular: {\n\t\t\t\tvalue: /*@__PURE__*/new Color(0x111111)\n\t\t\t},\n\t\t\tshininess: {\n\t\t\t\tvalue: 30\n\t\t\t}\n\t\t}]),\n\t\tvertexShader: ShaderChunk.meshphong_vert,\n\t\tfragmentShader: ShaderChunk.meshphong_frag\n\t},\n\tstandard: {\n\t\tuniforms: /*@__PURE__*/mergeUniforms([UniformsLib.common, UniformsLib.envmap, UniformsLib.aomap, UniformsLib.lightmap, UniformsLib.emissivemap, UniformsLib.bumpmap, UniformsLib.normalmap, UniformsLib.displacementmap, UniformsLib.roughnessmap, UniformsLib.metalnessmap, UniformsLib.fog, UniformsLib.lights, {\n\t\t\temissive: {\n\t\t\t\tvalue: /*@__PURE__*/new Color(0x000000)\n\t\t\t},\n\t\t\troughness: {\n\t\t\t\tvalue: 1.0\n\t\t\t},\n\t\t\tmetalness: {\n\t\t\t\tvalue: 0.0\n\t\t\t},\n\t\t\tenvMapIntensity: {\n\t\t\t\tvalue: 1\n\t\t\t} // temporary\n\n\t\t}]),\n\t\tvertexShader: ShaderChunk.meshphysical_vert,\n\t\tfragmentShader: ShaderChunk.meshphysical_frag\n\t},\n\ttoon: {\n\t\tuniforms: /*@__PURE__*/mergeUniforms([UniformsLib.common, UniformsLib.aomap, UniformsLib.lightmap, UniformsLib.emissivemap, UniformsLib.bumpmap, UniformsLib.normalmap, UniformsLib.displacementmap, UniformsLib.gradientmap, UniformsLib.fog, UniformsLib.lights, {\n\t\t\temissive: {\n\t\t\t\tvalue: /*@__PURE__*/new Color(0x000000)\n\t\t\t}\n\t\t}]),\n\t\tvertexShader: ShaderChunk.meshtoon_vert,\n\t\tfragmentShader: ShaderChunk.meshtoon_frag\n\t},\n\tmatcap: {\n\t\tuniforms: /*@__PURE__*/mergeUniforms([UniformsLib.common, UniformsLib.bumpmap, UniformsLib.normalmap, UniformsLib.displacementmap, UniformsLib.fog, {\n\t\t\tmatcap: {\n\t\t\t\tvalue: null\n\t\t\t}\n\t\t}]),\n\t\tvertexShader: ShaderChunk.meshmatcap_vert,\n\t\tfragmentShader: ShaderChunk.meshmatcap_frag\n\t},\n\tpoints: {\n\t\tuniforms: /*@__PURE__*/mergeUniforms([UniformsLib.points, UniformsLib.fog]),\n\t\tvertexShader: ShaderChunk.points_vert,\n\t\tfragmentShader: ShaderChunk.points_frag\n\t},\n\tdashed: {\n\t\tuniforms: /*@__PURE__*/mergeUniforms([UniformsLib.common, UniformsLib.fog, {\n\t\t\tscale: {\n\t\t\t\tvalue: 1\n\t\t\t},\n\t\t\tdashSize: {\n\t\t\t\tvalue: 1\n\t\t\t},\n\t\t\ttotalSize: {\n\t\t\t\tvalue: 2\n\t\t\t}\n\t\t}]),\n\t\tvertexShader: ShaderChunk.linedashed_vert,\n\t\tfragmentShader: ShaderChunk.linedashed_frag\n\t},\n\tdepth: {\n\t\tuniforms: /*@__PURE__*/mergeUniforms([UniformsLib.common, UniformsLib.displacementmap]),\n\t\tvertexShader: ShaderChunk.depth_vert,\n\t\tfragmentShader: ShaderChunk.depth_frag\n\t},\n\tnormal: {\n\t\tuniforms: /*@__PURE__*/mergeUniforms([UniformsLib.common, UniformsLib.bumpmap, UniformsLib.normalmap, UniformsLib.displacementmap, {\n\t\t\topacity: {\n\t\t\t\tvalue: 1.0\n\t\t\t}\n\t\t}]),\n\t\tvertexShader: ShaderChunk.meshnormal_vert,\n\t\tfragmentShader: ShaderChunk.meshnormal_frag\n\t},\n\tsprite: {\n\t\tuniforms: /*@__PURE__*/mergeUniforms([UniformsLib.sprite, UniformsLib.fog]),\n\t\tvertexShader: ShaderChunk.sprite_vert,\n\t\tfragmentShader: ShaderChunk.sprite_frag\n\t},\n\tbackground: {\n\t\tuniforms: {\n\t\t\tuvTransform: {\n\t\t\t\tvalue: /*@__PURE__*/new Matrix3()\n\t\t\t},\n\t\t\tt2D: {\n\t\t\t\tvalue: null\n\t\t\t}\n\t\t},\n\t\tvertexShader: ShaderChunk.background_vert,\n\t\tfragmentShader: ShaderChunk.background_frag\n\t},\n\tcube: {\n\t\tuniforms: /*@__PURE__*/mergeUniforms([UniformsLib.envmap, {\n\t\t\topacity: {\n\t\t\t\tvalue: 1.0\n\t\t\t}\n\t\t}]),\n\t\tvertexShader: ShaderChunk.cube_vert,\n\t\tfragmentShader: ShaderChunk.cube_frag\n\t},\n\tequirect: {\n\t\tuniforms: {\n\t\t\ttEquirect: {\n\t\t\t\tvalue: null\n\t\t\t}\n\t\t},\n\t\tvertexShader: ShaderChunk.equirect_vert,\n\t\tfragmentShader: ShaderChunk.equirect_frag\n\t},\n\tdistanceRGBA: {\n\t\tuniforms: /*@__PURE__*/mergeUniforms([UniformsLib.common, UniformsLib.displacementmap, {\n\t\t\treferencePosition: {\n\t\t\t\tvalue: /*@__PURE__*/new Vector3()\n\t\t\t},\n\t\t\tnearDistance: {\n\t\t\t\tvalue: 1\n\t\t\t},\n\t\t\tfarDistance: {\n\t\t\t\tvalue: 1000\n\t\t\t}\n\t\t}]),\n\t\tvertexShader: ShaderChunk.distanceRGBA_vert,\n\t\tfragmentShader: ShaderChunk.distanceRGBA_frag\n\t},\n\tshadow: {\n\t\tuniforms: /*@__PURE__*/mergeUniforms([UniformsLib.lights, UniformsLib.fog, {\n\t\t\tcolor: {\n\t\t\t\tvalue: /*@__PURE__*/new Color(0x00000)\n\t\t\t},\n\t\t\topacity: {\n\t\t\t\tvalue: 1.0\n\t\t\t}\n\t\t}]),\n\t\tvertexShader: ShaderChunk.shadow_vert,\n\t\tfragmentShader: ShaderChunk.shadow_frag\n\t}\n};\nShaderLib.physical = {\n\tuniforms: /*@__PURE__*/mergeUniforms([ShaderLib.standard.uniforms, {\n\t\tclearcoat: {\n\t\t\tvalue: 0\n\t\t},\n\t\tclearcoatMap: {\n\t\t\tvalue: null\n\t\t},\n\t\tclearcoatRoughness: {\n\t\t\tvalue: 0\n\t\t},\n\t\tclearcoatRoughnessMap: {\n\t\t\tvalue: null\n\t\t},\n\t\tclearcoatNormalScale: {\n\t\t\tvalue: /*@__PURE__*/new Vector2(1, 1)\n\t\t},\n\t\tclearcoatNormalMap: {\n\t\t\tvalue: null\n\t\t},\n\t\tiridescence: {\n\t\t\tvalue: 0\n\t\t},\n\t\tiridescenceMap: {\n\t\t\tvalue: null\n\t\t},\n\t\tiridescenceIOR: {\n\t\t\tvalue: 1.3\n\t\t},\n\t\tiridescenceThicknessMinimum: {\n\t\t\tvalue: 100\n\t\t},\n\t\tiridescenceThicknessMaximum: {\n\t\t\tvalue: 400\n\t\t},\n\t\tiridescenceThicknessMap: {\n\t\t\tvalue: null\n\t\t},\n\t\tsheen: {\n\t\t\tvalue: 0\n\t\t},\n\t\tsheenColor: {\n\t\t\tvalue: /*@__PURE__*/new Color(0x000000)\n\t\t},\n\t\tsheenColorMap: {\n\t\t\tvalue: null\n\t\t},\n\t\tsheenRoughness: {\n\t\t\tvalue: 1\n\t\t},\n\t\tsheenRoughnessMap: {\n\t\t\tvalue: null\n\t\t},\n\t\ttransmission: {\n\t\t\tvalue: 0\n\t\t},\n\t\ttransmissionMap: {\n\t\t\tvalue: null\n\t\t},\n\t\ttransmissionSamplerSize: {\n\t\t\tvalue: /*@__PURE__*/new Vector2()\n\t\t},\n\t\ttransmissionSamplerMap: {\n\t\t\tvalue: null\n\t\t},\n\t\tthickness: {\n\t\t\tvalue: 0\n\t\t},\n\t\tthicknessMap: {\n\t\t\tvalue: null\n\t\t},\n\t\tattenuationDistance: {\n\t\t\tvalue: 0\n\t\t},\n\t\tattenuationColor: {\n\t\t\tvalue: /*@__PURE__*/new Color(0x000000)\n\t\t},\n\t\tspecularIntensity: {\n\t\t\tvalue: 1\n\t\t},\n\t\tspecularIntensityMap: {\n\t\t\tvalue: null\n\t\t},\n\t\tspecularColor: {\n\t\t\tvalue: /*@__PURE__*/new Color(1, 1, 1)\n\t\t},\n\t\tspecularColorMap: {\n\t\t\tvalue: null\n\t\t}\n\t}]),\n\tvertexShader: ShaderChunk.meshphysical_vert,\n\tfragmentShader: ShaderChunk.meshphysical_frag\n};\n\nfunction WebGLBackground(renderer, cubemaps, state, objects, alpha, premultipliedAlpha) {\n\tconst clearColor = new Color(0x000000);\n\tlet clearAlpha = alpha === true ? 0 : 1;\n\tlet planeMesh;\n\tlet boxMesh;\n\tlet currentBackground = null;\n\tlet currentBackgroundVersion = 0;\n\tlet currentTonemapping = null;\n\n\tfunction render(renderList, scene) {\n\t\tlet forceClear = false;\n\t\tlet background = scene.isScene === true ? scene.background : null;\n\n\t\tif (background && background.isTexture) {\n\t\t\tbackground = cubemaps.get(background);\n\t\t} // Ignore background in AR\n\t\t// TODO: Reconsider this.\n\n\n\t\tconst xr = renderer.xr;\n\t\tconst session = xr.getSession && xr.getSession();\n\n\t\tif (session && session.environmentBlendMode === 'additive') {\n\t\t\tbackground = null;\n\t\t}\n\n\t\tif (background === null) {\n\t\t\tsetClear(clearColor, clearAlpha);\n\t\t} else if (background && background.isColor) {\n\t\t\tsetClear(background, 1);\n\t\t\tforceClear = true;\n\t\t}\n\n\t\tif (renderer.autoClear || forceClear) {\n\t\t\trenderer.clear(renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil);\n\t\t}\n\n\t\tif (background && (background.isCubeTexture || background.mapping === CubeUVReflectionMapping)) {\n\t\t\tif (boxMesh === undefined) {\n\t\t\t\tboxMesh = new Mesh(new BoxGeometry(1, 1, 1), new ShaderMaterial({\n\t\t\t\t\tname: 'BackgroundCubeMaterial',\n\t\t\t\t\tuniforms: cloneUniforms(ShaderLib.cube.uniforms),\n\t\t\t\t\tvertexShader: ShaderLib.cube.vertexShader,\n\t\t\t\t\tfragmentShader: ShaderLib.cube.fragmentShader,\n\t\t\t\t\tside: BackSide,\n\t\t\t\t\tdepthTest: false,\n\t\t\t\t\tdepthWrite: false,\n\t\t\t\t\tfog: false\n\t\t\t\t}));\n\t\t\t\tboxMesh.geometry.deleteAttribute('normal');\n\t\t\t\tboxMesh.geometry.deleteAttribute('uv');\n\n\t\t\t\tboxMesh.onBeforeRender = function (renderer, scene, camera) {\n\t\t\t\t\tthis.matrixWorld.copyPosition(camera.matrixWorld);\n\t\t\t\t}; // add \"envMap\" material property so the renderer can evaluate it like for built-in materials\n\n\n\t\t\t\tObject.defineProperty(boxMesh.material, 'envMap', {\n\t\t\t\t\tget: function () {\n\t\t\t\t\t\treturn this.uniforms.envMap.value;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tobjects.update(boxMesh);\n\t\t\t}\n\n\t\t\tboxMesh.material.uniforms.envMap.value = background;\n\t\t\tboxMesh.material.uniforms.flipEnvMap.value = background.isCubeTexture && background.isRenderTargetTexture === false ? -1 : 1;\n\n\t\t\tif (currentBackground !== background || currentBackgroundVersion !== background.version || currentTonemapping !== renderer.toneMapping) {\n\t\t\t\tboxMesh.material.needsUpdate = true;\n\t\t\t\tcurrentBackground = background;\n\t\t\t\tcurrentBackgroundVersion = background.version;\n\t\t\t\tcurrentTonemapping = renderer.toneMapping;\n\t\t\t}\n\n\t\t\tboxMesh.layers.enableAll(); // push to the pre-sorted opaque render list\n\n\t\t\trenderList.unshift(boxMesh, boxMesh.geometry, boxMesh.material, 0, 0, null);\n\t\t} else if (background && background.isTexture) {\n\t\t\tif (planeMesh === undefined) {\n\t\t\t\tplaneMesh = new Mesh(new PlaneGeometry(2, 2), new ShaderMaterial({\n\t\t\t\t\tname: 'BackgroundMaterial',\n\t\t\t\t\tuniforms: cloneUniforms(ShaderLib.background.uniforms),\n\t\t\t\t\tvertexShader: ShaderLib.background.vertexShader,\n\t\t\t\t\tfragmentShader: ShaderLib.background.fragmentShader,\n\t\t\t\t\tside: FrontSide,\n\t\t\t\t\tdepthTest: false,\n\t\t\t\t\tdepthWrite: false,\n\t\t\t\t\tfog: false\n\t\t\t\t}));\n\t\t\t\tplaneMesh.geometry.deleteAttribute('normal'); // add \"map\" material property so the renderer can evaluate it like for built-in materials\n\n\t\t\t\tObject.defineProperty(planeMesh.material, 'map', {\n\t\t\t\t\tget: function () {\n\t\t\t\t\t\treturn this.uniforms.t2D.value;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tobjects.update(planeMesh);\n\t\t\t}\n\n\t\t\tplaneMesh.material.uniforms.t2D.value = background;\n\n\t\t\tif (background.matrixAutoUpdate === true) {\n\t\t\t\tbackground.updateMatrix();\n\t\t\t}\n\n\t\t\tplaneMesh.material.uniforms.uvTransform.value.copy(background.matrix);\n\n\t\t\tif (currentBackground !== background || currentBackgroundVersion !== background.version || currentTonemapping !== renderer.toneMapping) {\n\t\t\t\tplaneMesh.material.needsUpdate = true;\n\t\t\t\tcurrentBackground = background;\n\t\t\t\tcurrentBackgroundVersion = background.version;\n\t\t\t\tcurrentTonemapping = renderer.toneMapping;\n\t\t\t}\n\n\t\t\tplaneMesh.layers.enableAll(); // push to the pre-sorted opaque render list\n\n\t\t\trenderList.unshift(planeMesh, planeMesh.geometry, planeMesh.material, 0, 0, null);\n\t\t}\n\t}\n\n\tfunction setClear(color, alpha) {\n\t\tstate.buffers.color.setClear(color.r, color.g, color.b, alpha, premultipliedAlpha);\n\t}\n\n\treturn {\n\t\tgetClearColor: function () {\n\t\t\treturn clearColor;\n\t\t},\n\t\tsetClearColor: function (color, alpha = 1) {\n\t\t\tclearColor.set(color);\n\t\t\tclearAlpha = alpha;\n\t\t\tsetClear(clearColor, clearAlpha);\n\t\t},\n\t\tgetClearAlpha: function () {\n\t\t\treturn clearAlpha;\n\t\t},\n\t\tsetClearAlpha: function (alpha) {\n\t\t\tclearAlpha = alpha;\n\t\t\tsetClear(clearColor, clearAlpha);\n\t\t},\n\t\trender: render\n\t};\n}\n\nfunction WebGLBindingStates(gl, extensions, attributes, capabilities) {\n\tconst maxVertexAttributes = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);\n\tconst extension = capabilities.isWebGL2 ? null : extensions.get('OES_vertex_array_object');\n\tconst vaoAvailable = capabilities.isWebGL2 || extension !== null;\n\tconst bindingStates = {};\n\tconst defaultState = createBindingState(null);\n\tlet currentState = defaultState;\n\tlet forceUpdate = false;\n\n\tfunction setup(object, material, program, geometry, index) {\n\t\tlet updateBuffers = false;\n\n\t\tif (vaoAvailable) {\n\t\t\tconst state = getBindingState(geometry, program, material);\n\n\t\t\tif (currentState !== state) {\n\t\t\t\tcurrentState = state;\n\t\t\t\tbindVertexArrayObject(currentState.object);\n\t\t\t}\n\n\t\t\tupdateBuffers = needsUpdate(object, geometry, program, index);\n\t\t\tif (updateBuffers) saveCache(object, geometry, program, index);\n\t\t} else {\n\t\t\tconst wireframe = material.wireframe === true;\n\n\t\t\tif (currentState.geometry !== geometry.id || currentState.program !== program.id || currentState.wireframe !== wireframe) {\n\t\t\t\tcurrentState.geometry = geometry.id;\n\t\t\t\tcurrentState.program = program.id;\n\t\t\t\tcurrentState.wireframe = wireframe;\n\t\t\t\tupdateBuffers = true;\n\t\t\t}\n\t\t}\n\n\t\tif (index !== null) {\n\t\t\tattributes.update(index, gl.ELEMENT_ARRAY_BUFFER);\n\t\t}\n\n\t\tif (updateBuffers || forceUpdate) {\n\t\t\tforceUpdate = false;\n\t\t\tsetupVertexAttributes(object, material, program, geometry);\n\n\t\t\tif (index !== null) {\n\t\t\t\tgl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, attributes.get(index).buffer);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction createVertexArrayObject() {\n\t\tif (capabilities.isWebGL2) return gl.createVertexArray();\n\t\treturn extension.createVertexArrayOES();\n\t}\n\n\tfunction bindVertexArrayObject(vao) {\n\t\tif (capabilities.isWebGL2) return gl.bindVertexArray(vao);\n\t\treturn extension.bindVertexArrayOES(vao);\n\t}\n\n\tfunction deleteVertexArrayObject(vao) {\n\t\tif (capabilities.isWebGL2) return gl.deleteVertexArray(vao);\n\t\treturn extension.deleteVertexArrayOES(vao);\n\t}\n\n\tfunction getBindingState(geometry, program, material) {\n\t\tconst wireframe = material.wireframe === true;\n\t\tlet programMap = bindingStates[geometry.id];\n\n\t\tif (programMap === undefined) {\n\t\t\tprogramMap = {};\n\t\t\tbindingStates[geometry.id] = programMap;\n\t\t}\n\n\t\tlet stateMap = programMap[program.id];\n\n\t\tif (stateMap === undefined) {\n\t\t\tstateMap = {};\n\t\t\tprogramMap[program.id] = stateMap;\n\t\t}\n\n\t\tlet state = stateMap[wireframe];\n\n\t\tif (state === undefined) {\n\t\t\tstate = createBindingState(createVertexArrayObject());\n\t\t\tstateMap[wireframe] = state;\n\t\t}\n\n\t\treturn state;\n\t}\n\n\tfunction createBindingState(vao) {\n\t\tconst newAttributes = [];\n\t\tconst enabledAttributes = [];\n\t\tconst attributeDivisors = [];\n\n\t\tfor (let i = 0; i < maxVertexAttributes; i++) {\n\t\t\tnewAttributes[i] = 0;\n\t\t\tenabledAttributes[i] = 0;\n\t\t\tattributeDivisors[i] = 0;\n\t\t}\n\n\t\treturn {\n\t\t\t// for backward compatibility on non-VAO support browser\n\t\t\tgeometry: null,\n\t\t\tprogram: null,\n\t\t\twireframe: false,\n\t\t\tnewAttributes: newAttributes,\n\t\t\tenabledAttributes: enabledAttributes,\n\t\t\tattributeDivisors: attributeDivisors,\n\t\t\tobject: vao,\n\t\t\tattributes: {},\n\t\t\tindex: null\n\t\t};\n\t}\n\n\tfunction needsUpdate(object, geometry, program, index) {\n\t\tconst cachedAttributes = currentState.attributes;\n\t\tconst geometryAttributes = geometry.attributes;\n\t\tlet attributesNum = 0;\n\t\tconst programAttributes = program.getAttributes();\n\n\t\tfor (const name in programAttributes) {\n\t\t\tconst programAttribute = programAttributes[name];\n\n\t\t\tif (programAttribute.location >= 0) {\n\t\t\t\tconst cachedAttribute = cachedAttributes[name];\n\t\t\t\tlet geometryAttribute = geometryAttributes[name];\n\n\t\t\t\tif (geometryAttribute === undefined) {\n\t\t\t\t\tif (name === 'instanceMatrix' && object.instanceMatrix) geometryAttribute = object.instanceMatrix;\n\t\t\t\t\tif (name === 'instanceColor' && object.instanceColor) geometryAttribute = object.instanceColor;\n\t\t\t\t}\n\n\t\t\t\tif (cachedAttribute === undefined) return true;\n\t\t\t\tif (cachedAttribute.attribute !== geometryAttribute) return true;\n\t\t\t\tif (geometryAttribute && cachedAttribute.data !== geometryAttribute.data) return true;\n\t\t\t\tattributesNum++;\n\t\t\t}\n\t\t}\n\n\t\tif (currentState.attributesNum !== attributesNum) return true;\n\t\tif (currentState.index !== index) return true;\n\t\treturn false;\n\t}\n\n\tfunction saveCache(object, geometry, program, index) {\n\t\tconst cache = {};\n\t\tconst attributes = geometry.attributes;\n\t\tlet attributesNum = 0;\n\t\tconst programAttributes = program.getAttributes();\n\n\t\tfor (const name in programAttributes) {\n\t\t\tconst programAttribute = programAttributes[name];\n\n\t\t\tif (programAttribute.location >= 0) {\n\t\t\t\tlet attribute = attributes[name];\n\n\t\t\t\tif (attribute === undefined) {\n\t\t\t\t\tif (name === 'instanceMatrix' && object.instanceMatrix) attribute = object.instanceMatrix;\n\t\t\t\t\tif (name === 'instanceColor' && object.instanceColor) attribute = object.instanceColor;\n\t\t\t\t}\n\n\t\t\t\tconst data = {};\n\t\t\t\tdata.attribute = attribute;\n\n\t\t\t\tif (attribute && attribute.data) {\n\t\t\t\t\tdata.data = attribute.data;\n\t\t\t\t}\n\n\t\t\t\tcache[name] = data;\n\t\t\t\tattributesNum++;\n\t\t\t}\n\t\t}\n\n\t\tcurrentState.attributes = cache;\n\t\tcurrentState.attributesNum = attributesNum;\n\t\tcurrentState.index = index;\n\t}\n\n\tfunction initAttributes() {\n\t\tconst newAttributes = currentState.newAttributes;\n\n\t\tfor (let i = 0, il = newAttributes.length; i < il; i++) {\n\t\t\tnewAttributes[i] = 0;\n\t\t}\n\t}\n\n\tfunction enableAttribute(attribute) {\n\t\tenableAttributeAndDivisor(attribute, 0);\n\t}\n\n\tfunction enableAttributeAndDivisor(attribute, meshPerAttribute) {\n\t\tconst newAttributes = currentState.newAttributes;\n\t\tconst enabledAttributes = currentState.enabledAttributes;\n\t\tconst attributeDivisors = currentState.attributeDivisors;\n\t\tnewAttributes[attribute] = 1;\n\n\t\tif (enabledAttributes[attribute] === 0) {\n\t\t\tgl.enableVertexAttribArray(attribute);\n\t\t\tenabledAttributes[attribute] = 1;\n\t\t}\n\n\t\tif (attributeDivisors[attribute] !== meshPerAttribute) {\n\t\t\tconst extension = capabilities.isWebGL2 ? gl : extensions.get('ANGLE_instanced_arrays');\n\t\t\textension[capabilities.isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE'](attribute, meshPerAttribute);\n\t\t\tattributeDivisors[attribute] = meshPerAttribute;\n\t\t}\n\t}\n\n\tfunction disableUnusedAttributes() {\n\t\tconst newAttributes = currentState.newAttributes;\n\t\tconst enabledAttributes = currentState.enabledAttributes;\n\n\t\tfor (let i = 0, il = enabledAttributes.length; i < il; i++) {\n\t\t\tif (enabledAttributes[i] !== newAttributes[i]) {\n\t\t\t\tgl.disableVertexAttribArray(i);\n\t\t\t\tenabledAttributes[i] = 0;\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction vertexAttribPointer(index, size, type, normalized, stride, offset) {\n\t\tif (capabilities.isWebGL2 === true && (type === gl.INT || type === gl.UNSIGNED_INT)) {\n\t\t\tgl.vertexAttribIPointer(index, size, type, stride, offset);\n\t\t} else {\n\t\t\tgl.vertexAttribPointer(index, size, type, normalized, stride, offset);\n\t\t}\n\t}\n\n\tfunction setupVertexAttributes(object, material, program, geometry) {\n\t\tif (capabilities.isWebGL2 === false && (object.isInstancedMesh || geometry.isInstancedBufferGeometry)) {\n\t\t\tif (extensions.get('ANGLE_instanced_arrays') === null) return;\n\t\t}\n\n\t\tinitAttributes();\n\t\tconst geometryAttributes = geometry.attributes;\n\t\tconst programAttributes = program.getAttributes();\n\t\tconst materialDefaultAttributeValues = material.defaultAttributeValues;\n\n\t\tfor (const name in programAttributes) {\n\t\t\tconst programAttribute = programAttributes[name];\n\n\t\t\tif (programAttribute.location >= 0) {\n\t\t\t\tlet geometryAttribute = geometryAttributes[name];\n\n\t\t\t\tif (geometryAttribute === undefined) {\n\t\t\t\t\tif (name === 'instanceMatrix' && object.instanceMatrix) geometryAttribute = object.instanceMatrix;\n\t\t\t\t\tif (name === 'instanceColor' && object.instanceColor) geometryAttribute = object.instanceColor;\n\t\t\t\t}\n\n\t\t\t\tif (geometryAttribute !== undefined) {\n\t\t\t\t\tconst normalized = geometryAttribute.normalized;\n\t\t\t\t\tconst size = geometryAttribute.itemSize;\n\t\t\t\t\tconst attribute = attributes.get(geometryAttribute); // TODO Attribute may not be available on context restore\n\n\t\t\t\t\tif (attribute === undefined) continue;\n\t\t\t\t\tconst buffer = attribute.buffer;\n\t\t\t\t\tconst type = attribute.type;\n\t\t\t\t\tconst bytesPerElement = attribute.bytesPerElement;\n\n\t\t\t\t\tif (geometryAttribute.isInterleavedBufferAttribute) {\n\t\t\t\t\t\tconst data = geometryAttribute.data;\n\t\t\t\t\t\tconst stride = data.stride;\n\t\t\t\t\t\tconst offset = geometryAttribute.offset;\n\n\t\t\t\t\t\tif (data.isInstancedInterleavedBuffer) {\n\t\t\t\t\t\t\tfor (let i = 0; i < programAttribute.locationSize; i++) {\n\t\t\t\t\t\t\t\tenableAttributeAndDivisor(programAttribute.location + i, data.meshPerAttribute);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (object.isInstancedMesh !== true && geometry._maxInstanceCount === undefined) {\n\t\t\t\t\t\t\t\tgeometry._maxInstanceCount = data.meshPerAttribute * data.count;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tfor (let i = 0; i < programAttribute.locationSize; i++) {\n\t\t\t\t\t\t\t\tenableAttribute(programAttribute.location + i);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tgl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n\n\t\t\t\t\t\tfor (let i = 0; i < programAttribute.locationSize; i++) {\n\t\t\t\t\t\t\tvertexAttribPointer(programAttribute.location + i, size / programAttribute.locationSize, type, normalized, stride * bytesPerElement, (offset + size / programAttribute.locationSize * i) * bytesPerElement);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (geometryAttribute.isInstancedBufferAttribute) {\n\t\t\t\t\t\t\tfor (let i = 0; i < programAttribute.locationSize; i++) {\n\t\t\t\t\t\t\t\tenableAttributeAndDivisor(programAttribute.location + i, geometryAttribute.meshPerAttribute);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (object.isInstancedMesh !== true && geometry._maxInstanceCount === undefined) {\n\t\t\t\t\t\t\t\tgeometry._maxInstanceCount = geometryAttribute.meshPerAttribute * geometryAttribute.count;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tfor (let i = 0; i < programAttribute.locationSize; i++) {\n\t\t\t\t\t\t\t\tenableAttribute(programAttribute.location + i);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tgl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n\n\t\t\t\t\t\tfor (let i = 0; i < programAttribute.locationSize; i++) {\n\t\t\t\t\t\t\tvertexAttribPointer(programAttribute.location + i, size / programAttribute.locationSize, type, normalized, size * bytesPerElement, size / programAttribute.locationSize * i * bytesPerElement);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (materialDefaultAttributeValues !== undefined) {\n\t\t\t\t\tconst value = materialDefaultAttributeValues[name];\n\n\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\tswitch (value.length) {\n\t\t\t\t\t\t\tcase 2:\n\t\t\t\t\t\t\t\tgl.vertexAttrib2fv(programAttribute.location, value);\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase 3:\n\t\t\t\t\t\t\t\tgl.vertexAttrib3fv(programAttribute.location, value);\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase 4:\n\t\t\t\t\t\t\t\tgl.vertexAttrib4fv(programAttribute.location, value);\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tgl.vertexAttrib1fv(programAttribute.location, value);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tdisableUnusedAttributes();\n\t}\n\n\tfunction dispose() {\n\t\treset();\n\n\t\tfor (const geometryId in bindingStates) {\n\t\t\tconst programMap = bindingStates[geometryId];\n\n\t\t\tfor (const programId in programMap) {\n\t\t\t\tconst stateMap = programMap[programId];\n\n\t\t\t\tfor (const wireframe in stateMap) {\n\t\t\t\t\tdeleteVertexArrayObject(stateMap[wireframe].object);\n\t\t\t\t\tdelete stateMap[wireframe];\n\t\t\t\t}\n\n\t\t\t\tdelete programMap[programId];\n\t\t\t}\n\n\t\t\tdelete bindingStates[geometryId];\n\t\t}\n\t}\n\n\tfunction releaseStatesOfGeometry(geometry) {\n\t\tif (bindingStates[geometry.id] === undefined) return;\n\t\tconst programMap = bindingStates[geometry.id];\n\n\t\tfor (const programId in programMap) {\n\t\t\tconst stateMap = programMap[programId];\n\n\t\t\tfor (const wireframe in stateMap) {\n\t\t\t\tdeleteVertexArrayObject(stateMap[wireframe].object);\n\t\t\t\tdelete stateMap[wireframe];\n\t\t\t}\n\n\t\t\tdelete programMap[programId];\n\t\t}\n\n\t\tdelete bindingStates[geometry.id];\n\t}\n\n\tfunction releaseStatesOfProgram(program) {\n\t\tfor (const geometryId in bindingStates) {\n\t\t\tconst programMap = bindingStates[geometryId];\n\t\t\tif (programMap[program.id] === undefined) continue;\n\t\t\tconst stateMap = programMap[program.id];\n\n\t\t\tfor (const wireframe in stateMap) {\n\t\t\t\tdeleteVertexArrayObject(stateMap[wireframe].object);\n\t\t\t\tdelete stateMap[wireframe];\n\t\t\t}\n\n\t\t\tdelete programMap[program.id];\n\t\t}\n\t}\n\n\tfunction reset() {\n\t\tresetDefaultState();\n\t\tforceUpdate = true;\n\t\tif (currentState === defaultState) return;\n\t\tcurrentState = defaultState;\n\t\tbindVertexArrayObject(currentState.object);\n\t} // for backward-compatibility\n\n\n\tfunction resetDefaultState() {\n\t\tdefaultState.geometry = null;\n\t\tdefaultState.program = null;\n\t\tdefaultState.wireframe = false;\n\t}\n\n\treturn {\n\t\tsetup: setup,\n\t\treset: reset,\n\t\tresetDefaultState: resetDefaultState,\n\t\tdispose: dispose,\n\t\treleaseStatesOfGeometry: releaseStatesOfGeometry,\n\t\treleaseStatesOfProgram: releaseStatesOfProgram,\n\t\tinitAttributes: initAttributes,\n\t\tenableAttribute: enableAttribute,\n\t\tdisableUnusedAttributes: disableUnusedAttributes\n\t};\n}\n\nfunction WebGLBufferRenderer(gl, extensions, info, capabilities) {\n\tconst isWebGL2 = capabilities.isWebGL2;\n\tlet mode;\n\n\tfunction setMode(value) {\n\t\tmode = value;\n\t}\n\n\tfunction render(start, count) {\n\t\tgl.drawArrays(mode, start, count);\n\t\tinfo.update(count, mode, 1);\n\t}\n\n\tfunction renderInstances(start, count, primcount) {\n\t\tif (primcount === 0) return;\n\t\tlet extension, methodName;\n\n\t\tif (isWebGL2) {\n\t\t\textension = gl;\n\t\t\tmethodName = 'drawArraysInstanced';\n\t\t} else {\n\t\t\textension = extensions.get('ANGLE_instanced_arrays');\n\t\t\tmethodName = 'drawArraysInstancedANGLE';\n\n\t\t\tif (extension === null) {\n\t\t\t\tconsole.error('THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.');\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\textension[methodName](mode, start, count, primcount);\n\t\tinfo.update(count, mode, primcount);\n\t} //\n\n\n\tthis.setMode = setMode;\n\tthis.render = render;\n\tthis.renderInstances = renderInstances;\n}\n\nfunction WebGLCapabilities(gl, extensions, parameters) {\n\tlet maxAnisotropy;\n\n\tfunction getMaxAnisotropy() {\n\t\tif (maxAnisotropy !== undefined) return maxAnisotropy;\n\n\t\tif (extensions.has('EXT_texture_filter_anisotropic') === true) {\n\t\t\tconst extension = extensions.get('EXT_texture_filter_anisotropic');\n\t\t\tmaxAnisotropy = gl.getParameter(extension.MAX_TEXTURE_MAX_ANISOTROPY_EXT);\n\t\t} else {\n\t\t\tmaxAnisotropy = 0;\n\t\t}\n\n\t\treturn maxAnisotropy;\n\t}\n\n\tfunction getMaxPrecision(precision) {\n\t\tif (precision === 'highp') {\n\t\t\tif (gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT).precision > 0 && gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT).precision > 0) {\n\t\t\t\treturn 'highp';\n\t\t\t}\n\n\t\t\tprecision = 'mediump';\n\t\t}\n\n\t\tif (precision === 'mediump') {\n\t\t\tif (gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT).precision > 0 && gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT).precision > 0) {\n\t\t\t\treturn 'mediump';\n\t\t\t}\n\t\t}\n\n\t\treturn 'lowp';\n\t}\n\n\tconst isWebGL2 = typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext || typeof WebGL2ComputeRenderingContext !== 'undefined' && gl instanceof WebGL2ComputeRenderingContext;\n\tlet precision = parameters.precision !== undefined ? parameters.precision : 'highp';\n\tconst maxPrecision = getMaxPrecision(precision);\n\n\tif (maxPrecision !== precision) {\n\t\tconsole.warn('THREE.WebGLRenderer:', precision, 'not supported, using', maxPrecision, 'instead.');\n\t\tprecision = maxPrecision;\n\t}\n\n\tconst drawBuffers = isWebGL2 || extensions.has('WEBGL_draw_buffers');\n\tconst logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;\n\tconst maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);\n\tconst maxVertexTextures = gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);\n\tconst maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);\n\tconst maxCubemapSize = gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE);\n\tconst maxAttributes = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);\n\tconst maxVertexUniforms = gl.getParameter(gl.MAX_VERTEX_UNIFORM_VECTORS);\n\tconst maxVaryings = gl.getParameter(gl.MAX_VARYING_VECTORS);\n\tconst maxFragmentUniforms = gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS);\n\tconst vertexTextures = maxVertexTextures > 0;\n\tconst floatFragmentTextures = isWebGL2 || extensions.has('OES_texture_float');\n\tconst floatVertexTextures = vertexTextures && floatFragmentTextures;\n\tconst maxSamples = isWebGL2 ? gl.getParameter(gl.MAX_SAMPLES) : 0;\n\treturn {\n\t\tisWebGL2: isWebGL2,\n\t\tdrawBuffers: drawBuffers,\n\t\tgetMaxAnisotropy: getMaxAnisotropy,\n\t\tgetMaxPrecision: getMaxPrecision,\n\t\tprecision: precision,\n\t\tlogarithmicDepthBuffer: logarithmicDepthBuffer,\n\t\tmaxTextures: maxTextures,\n\t\tmaxVertexTextures: maxVertexTextures,\n\t\tmaxTextureSize: maxTextureSize,\n\t\tmaxCubemapSize: maxCubemapSize,\n\t\tmaxAttributes: maxAttributes,\n\t\tmaxVertexUniforms: maxVertexUniforms,\n\t\tmaxVaryings: maxVaryings,\n\t\tmaxFragmentUniforms: maxFragmentUniforms,\n\t\tvertexTextures: vertexTextures,\n\t\tfloatFragmentTextures: floatFragmentTextures,\n\t\tfloatVertexTextures: floatVertexTextures,\n\t\tmaxSamples: maxSamples\n\t};\n}\n\nfunction WebGLClipping(properties) {\n\tconst scope = this;\n\tlet globalState = null,\n\t\t\tnumGlobalPlanes = 0,\n\t\t\tlocalClippingEnabled = false,\n\t\t\trenderingShadows = false;\n\tconst plane = new Plane(),\n\t\t\t\tviewNormalMatrix = new Matrix3(),\n\t\t\t\tuniform = {\n\t\tvalue: null,\n\t\tneedsUpdate: false\n\t};\n\tthis.uniform = uniform;\n\tthis.numPlanes = 0;\n\tthis.numIntersection = 0;\n\n\tthis.init = function (planes, enableLocalClipping, camera) {\n\t\tconst enabled = planes.length !== 0 || enableLocalClipping || // enable state of previous frame - the clipping code has to\n\t\t// run another frame in order to reset the state:\n\t\tnumGlobalPlanes !== 0 || localClippingEnabled;\n\t\tlocalClippingEnabled = enableLocalClipping;\n\t\tglobalState = projectPlanes(planes, camera, 0);\n\t\tnumGlobalPlanes = planes.length;\n\t\treturn enabled;\n\t};\n\n\tthis.beginShadows = function () {\n\t\trenderingShadows = true;\n\t\tprojectPlanes(null);\n\t};\n\n\tthis.endShadows = function () {\n\t\trenderingShadows = false;\n\t\tresetGlobalState();\n\t};\n\n\tthis.setState = function (material, camera, useCache) {\n\t\tconst planes = material.clippingPlanes,\n\t\t\t\t\tclipIntersection = material.clipIntersection,\n\t\t\t\t\tclipShadows = material.clipShadows;\n\t\tconst materialProperties = properties.get(material);\n\n\t\tif (!localClippingEnabled || planes === null || planes.length === 0 || renderingShadows && !clipShadows) {\n\t\t\t// there's no local clipping\n\t\t\tif (renderingShadows) {\n\t\t\t\t// there's no global clipping\n\t\t\t\tprojectPlanes(null);\n\t\t\t} else {\n\t\t\t\tresetGlobalState();\n\t\t\t}\n\t\t} else {\n\t\t\tconst nGlobal = renderingShadows ? 0 : numGlobalPlanes,\n\t\t\t\t\t\tlGlobal = nGlobal * 4;\n\t\t\tlet dstArray = materialProperties.clippingState || null;\n\t\t\tuniform.value = dstArray; // ensure unique state\n\n\t\t\tdstArray = projectPlanes(planes, camera, lGlobal, useCache);\n\n\t\t\tfor (let i = 0; i !== lGlobal; ++i) {\n\t\t\t\tdstArray[i] = globalState[i];\n\t\t\t}\n\n\t\t\tmaterialProperties.clippingState = dstArray;\n\t\t\tthis.numIntersection = clipIntersection ? this.numPlanes : 0;\n\t\t\tthis.numPlanes += nGlobal;\n\t\t}\n\t};\n\n\tfunction resetGlobalState() {\n\t\tif (uniform.value !== globalState) {\n\t\t\tuniform.value = globalState;\n\t\t\tuniform.needsUpdate = numGlobalPlanes > 0;\n\t\t}\n\n\t\tscope.numPlanes = numGlobalPlanes;\n\t\tscope.numIntersection = 0;\n\t}\n\n\tfunction projectPlanes(planes, camera, dstOffset, skipTransform) {\n\t\tconst nPlanes = planes !== null ? planes.length : 0;\n\t\tlet dstArray = null;\n\n\t\tif (nPlanes !== 0) {\n\t\t\tdstArray = uniform.value;\n\n\t\t\tif (skipTransform !== true || dstArray === null) {\n\t\t\t\tconst flatSize = dstOffset + nPlanes * 4,\n\t\t\t\t\t\t\tviewMatrix = camera.matrixWorldInverse;\n\t\t\t\tviewNormalMatrix.getNormalMatrix(viewMatrix);\n\n\t\t\t\tif (dstArray === null || dstArray.length < flatSize) {\n\t\t\t\t\tdstArray = new Float32Array(flatSize);\n\t\t\t\t}\n\n\t\t\t\tfor (let i = 0, i4 = dstOffset; i !== nPlanes; ++i, i4 += 4) {\n\t\t\t\t\tplane.copy(planes[i]).applyMatrix4(viewMatrix, viewNormalMatrix);\n\t\t\t\t\tplane.normal.toArray(dstArray, i4);\n\t\t\t\t\tdstArray[i4 + 3] = plane.constant;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tuniform.value = dstArray;\n\t\t\tuniform.needsUpdate = true;\n\t\t}\n\n\t\tscope.numPlanes = nPlanes;\n\t\tscope.numIntersection = 0;\n\t\treturn dstArray;\n\t}\n}\n\nfunction WebGLCubeMaps(renderer) {\n\tlet cubemaps = new WeakMap();\n\n\tfunction mapTextureMapping(texture, mapping) {\n\t\tif (mapping === EquirectangularReflectionMapping) {\n\t\t\ttexture.mapping = CubeReflectionMapping;\n\t\t} else if (mapping === EquirectangularRefractionMapping) {\n\t\t\ttexture.mapping = CubeRefractionMapping;\n\t\t}\n\n\t\treturn texture;\n\t}\n\n\tfunction get(texture) {\n\t\tif (texture && texture.isTexture && texture.isRenderTargetTexture === false) {\n\t\t\tconst mapping = texture.mapping;\n\n\t\t\tif (mapping === EquirectangularReflectionMapping || mapping === EquirectangularRefractionMapping) {\n\t\t\t\tif (cubemaps.has(texture)) {\n\t\t\t\t\tconst cubemap = cubemaps.get(texture).texture;\n\t\t\t\t\treturn mapTextureMapping(cubemap, texture.mapping);\n\t\t\t\t} else {\n\t\t\t\t\tconst image = texture.image;\n\n\t\t\t\t\tif (image && image.height > 0) {\n\t\t\t\t\t\tconst renderTarget = new WebGLCubeRenderTarget(image.height / 2);\n\t\t\t\t\t\trenderTarget.fromEquirectangularTexture(renderer, texture);\n\t\t\t\t\t\tcubemaps.set(texture, renderTarget);\n\t\t\t\t\t\ttexture.addEventListener('dispose', onTextureDispose);\n\t\t\t\t\t\treturn mapTextureMapping(renderTarget.texture, texture.mapping);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// image not yet ready. try the conversion next frame\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn texture;\n\t}\n\n\tfunction onTextureDispose(event) {\n\t\tconst texture = event.target;\n\t\ttexture.removeEventListener('dispose', onTextureDispose);\n\t\tconst cubemap = cubemaps.get(texture);\n\n\t\tif (cubemap !== undefined) {\n\t\t\tcubemaps.delete(texture);\n\t\t\tcubemap.dispose();\n\t\t}\n\t}\n\n\tfunction dispose() {\n\t\tcubemaps = new WeakMap();\n\t}\n\n\treturn {\n\t\tget: get,\n\t\tdispose: dispose\n\t};\n}\n\nclass OrthographicCamera extends Camera {\n\tconstructor(left = -1, right = 1, top = 1, bottom = -1, near = 0.1, far = 2000) {\n\t\tsuper();\n\t\tthis.isOrthographicCamera = true;\n\t\tthis.type = 'OrthographicCamera';\n\t\tthis.zoom = 1;\n\t\tthis.view = null;\n\t\tthis.left = left;\n\t\tthis.right = right;\n\t\tthis.top = top;\n\t\tthis.bottom = bottom;\n\t\tthis.near = near;\n\t\tthis.far = far;\n\t\tthis.updateProjectionMatrix();\n\t}\n\n\tcopy(source, recursive) {\n\t\tsuper.copy(source, recursive);\n\t\tthis.left = source.left;\n\t\tthis.right = source.right;\n\t\tthis.top = source.top;\n\t\tthis.bottom = source.bottom;\n\t\tthis.near = source.near;\n\t\tthis.far = source.far;\n\t\tthis.zoom = source.zoom;\n\t\tthis.view = source.view === null ? null : Object.assign({}, source.view);\n\t\treturn this;\n\t}\n\n\tsetViewOffset(fullWidth, fullHeight, x, y, width, height) {\n\t\tif (this.view === null) {\n\t\t\tthis.view = {\n\t\t\t\tenabled: true,\n\t\t\t\tfullWidth: 1,\n\t\t\t\tfullHeight: 1,\n\t\t\t\toffsetX: 0,\n\t\t\t\toffsetY: 0,\n\t\t\t\twidth: 1,\n\t\t\t\theight: 1\n\t\t\t};\n\t\t}\n\n\t\tthis.view.enabled = true;\n\t\tthis.view.fullWidth = fullWidth;\n\t\tthis.view.fullHeight = fullHeight;\n\t\tthis.view.offsetX = x;\n\t\tthis.view.offsetY = y;\n\t\tthis.view.width = width;\n\t\tthis.view.height = height;\n\t\tthis.updateProjectionMatrix();\n\t}\n\n\tclearViewOffset() {\n\t\tif (this.view !== null) {\n\t\t\tthis.view.enabled = false;\n\t\t}\n\n\t\tthis.updateProjectionMatrix();\n\t}\n\n\tupdateProjectionMatrix() {\n\t\tconst dx = (this.right - this.left) / (2 * this.zoom);\n\t\tconst dy = (this.top - this.bottom) / (2 * this.zoom);\n\t\tconst cx = (this.right + this.left) / 2;\n\t\tconst cy = (this.top + this.bottom) / 2;\n\t\tlet left = cx - dx;\n\t\tlet right = cx + dx;\n\t\tlet top = cy + dy;\n\t\tlet bottom = cy - dy;\n\n\t\tif (this.view !== null && this.view.enabled) {\n\t\t\tconst scaleW = (this.right - this.left) / this.view.fullWidth / this.zoom;\n\t\t\tconst scaleH = (this.top - this.bottom) / this.view.fullHeight / this.zoom;\n\t\t\tleft += scaleW * this.view.offsetX;\n\t\t\tright = left + scaleW * this.view.width;\n\t\t\ttop -= scaleH * this.view.offsetY;\n\t\t\tbottom = top - scaleH * this.view.height;\n\t\t}\n\n\t\tthis.projectionMatrix.makeOrthographic(left, right, top, bottom, this.near, this.far);\n\t\tthis.projectionMatrixInverse.copy(this.projectionMatrix).invert();\n\t}\n\n\ttoJSON(meta) {\n\t\tconst data = super.toJSON(meta);\n\t\tdata.object.zoom = this.zoom;\n\t\tdata.object.left = this.left;\n\t\tdata.object.right = this.right;\n\t\tdata.object.top = this.top;\n\t\tdata.object.bottom = this.bottom;\n\t\tdata.object.near = this.near;\n\t\tdata.object.far = this.far;\n\t\tif (this.view !== null) data.object.view = Object.assign({}, this.view);\n\t\treturn data;\n\t}\n\n}\n\nconst LOD_MIN = 4; // The standard deviations (radians) associated with the extra mips. These are\n// chosen to approximate a Trowbridge-Reitz distribution function times the\n// geometric shadowing function. These sigma values squared must match the\n// variance #defines in cube_uv_reflection_fragment.glsl.js.\n\nconst EXTRA_LOD_SIGMA = [0.125, 0.215, 0.35, 0.446, 0.526, 0.582]; // The maximum length of the blur for loop. Smaller sigmas will use fewer\n// samples and exit early, but not recompile the shader.\n\nconst MAX_SAMPLES = 20;\n\nconst _flatCamera = /*@__PURE__*/new OrthographicCamera();\n\nconst _clearColor = /*@__PURE__*/new Color();\n\nlet _oldTarget = null; // Golden Ratio\n\nconst PHI = (1 + Math.sqrt(5)) / 2;\nconst INV_PHI = 1 / PHI; // Vertices of a dodecahedron (except the opposites, which represent the\n// same axis), used as axis directions evenly spread on a sphere.\n\nconst _axisDirections = [/*@__PURE__*/new Vector3(1, 1, 1), /*@__PURE__*/new Vector3(-1, 1, 1), /*@__PURE__*/new Vector3(1, 1, -1), /*@__PURE__*/new Vector3(-1, 1, -1), /*@__PURE__*/new Vector3(0, PHI, INV_PHI), /*@__PURE__*/new Vector3(0, PHI, -INV_PHI), /*@__PURE__*/new Vector3(INV_PHI, 0, PHI), /*@__PURE__*/new Vector3(-INV_PHI, 0, PHI), /*@__PURE__*/new Vector3(PHI, INV_PHI, 0), /*@__PURE__*/new Vector3(-PHI, INV_PHI, 0)];\n/**\n * This class generates a Prefiltered, Mipmapped Radiance Environment Map\n * (PMREM) from a cubeMap environment texture. This allows different levels of\n * blur to be quickly accessed based on material roughness. It is packed into a\n * special CubeUV format that allows us to perform custom interpolation so that\n * we can support nonlinear formats such as RGBE. Unlike a traditional mipmap\n * chain, it only goes down to the LOD_MIN level (above), and then creates extra\n * even more filtered 'mips' at the same LOD_MIN resolution, associated with\n * higher roughness levels. In this way we maintain resolution to smoothly\n * interpolate diffuse lighting while limiting sampling computation.\n *\n * Paper: Fast, Accurate Image-Based Lighting\n * https://drive.google.com/file/d/15y8r_UpKlU9SvV4ILb0C3qCPecS8pvLz/view\n*/\n\nclass PMREMGenerator {\n\tconstructor(renderer) {\n\t\tthis._renderer = renderer;\n\t\tthis._pingPongRenderTarget = null;\n\t\tthis._lodMax = 0;\n\t\tthis._cubeSize = 0;\n\t\tthis._lodPlanes = [];\n\t\tthis._sizeLods = [];\n\t\tthis._sigmas = [];\n\t\tthis._blurMaterial = null;\n\t\tthis._cubemapMaterial = null;\n\t\tthis._equirectMaterial = null;\n\n\t\tthis._compileMaterial(this._blurMaterial);\n\t}\n\t/**\n\t * Generates a PMREM from a supplied Scene, which can be faster than using an\n\t * image if networking bandwidth is low. Optional sigma specifies a blur radius\n\t * in radians to be applied to the scene before PMREM generation. Optional near\n\t * and far planes ensure the scene is rendered in its entirety (the cubeCamera\n\t * is placed at the origin).\n\t */\n\n\n\tfromScene(scene, sigma = 0, near = 0.1, far = 100) {\n\t\t_oldTarget = this._renderer.getRenderTarget();\n\n\t\tthis._setSize(256);\n\n\t\tconst cubeUVRenderTarget = this._allocateTargets();\n\n\t\tcubeUVRenderTarget.depthBuffer = true;\n\n\t\tthis._sceneToCubeUV(scene, near, far, cubeUVRenderTarget);\n\n\t\tif (sigma > 0) {\n\t\t\tthis._blur(cubeUVRenderTarget, 0, 0, sigma);\n\t\t}\n\n\t\tthis._applyPMREM(cubeUVRenderTarget);\n\n\t\tthis._cleanup(cubeUVRenderTarget);\n\n\t\treturn cubeUVRenderTarget;\n\t}\n\t/**\n\t * Generates a PMREM from an equirectangular texture, which can be either LDR\n\t * or HDR. The ideal input image size is 1k (1024 x 512),\n\t * as this matches best with the 256 x 256 cubemap output.\n\t */\n\n\n\tfromEquirectangular(equirectangular, renderTarget = null) {\n\t\treturn this._fromTexture(equirectangular, renderTarget);\n\t}\n\t/**\n\t * Generates a PMREM from an cubemap texture, which can be either LDR\n\t * or HDR. The ideal input cube size is 256 x 256,\n\t * as this matches best with the 256 x 256 cubemap output.\n\t */\n\n\n\tfromCubemap(cubemap, renderTarget = null) {\n\t\treturn this._fromTexture(cubemap, renderTarget);\n\t}\n\t/**\n\t * Pre-compiles the cubemap shader. You can get faster start-up by invoking this method during\n\t * your texture's network fetch for increased concurrency.\n\t */\n\n\n\tcompileCubemapShader() {\n\t\tif (this._cubemapMaterial === null) {\n\t\t\tthis._cubemapMaterial = _getCubemapMaterial();\n\n\t\t\tthis._compileMaterial(this._cubemapMaterial);\n\t\t}\n\t}\n\t/**\n\t * Pre-compiles the equirectangular shader. You can get faster start-up by invoking this method during\n\t * your texture's network fetch for increased concurrency.\n\t */\n\n\n\tcompileEquirectangularShader() {\n\t\tif (this._equirectMaterial === null) {\n\t\t\tthis._equirectMaterial = _getEquirectMaterial();\n\n\t\t\tthis._compileMaterial(this._equirectMaterial);\n\t\t}\n\t}\n\t/**\n\t * Disposes of the PMREMGenerator's internal memory. Note that PMREMGenerator is a static class,\n\t * so you should not need more than one PMREMGenerator object. If you do, calling dispose() on\n\t * one of them will cause any others to also become unusable.\n\t */\n\n\n\tdispose() {\n\t\tthis._dispose();\n\n\t\tif (this._cubemapMaterial !== null) this._cubemapMaterial.dispose();\n\t\tif (this._equirectMaterial !== null) this._equirectMaterial.dispose();\n\t} // private interface\n\n\n\t_setSize(cubeSize) {\n\t\tthis._lodMax = Math.floor(Math.log2(cubeSize));\n\t\tthis._cubeSize = Math.pow(2, this._lodMax);\n\t}\n\n\t_dispose() {\n\t\tif (this._blurMaterial !== null) this._blurMaterial.dispose();\n\t\tif (this._pingPongRenderTarget !== null) this._pingPongRenderTarget.dispose();\n\n\t\tfor (let i = 0; i < this._lodPlanes.length; i++) {\n\t\t\tthis._lodPlanes[i].dispose();\n\t\t}\n\t}\n\n\t_cleanup(outputTarget) {\n\t\tthis._renderer.setRenderTarget(_oldTarget);\n\n\t\toutputTarget.scissorTest = false;\n\n\t\t_setViewport(outputTarget, 0, 0, outputTarget.width, outputTarget.height);\n\t}\n\n\t_fromTexture(texture, renderTarget) {\n\t\tif (texture.mapping === CubeReflectionMapping || texture.mapping === CubeRefractionMapping) {\n\t\t\tthis._setSize(texture.image.length === 0 ? 16 : texture.image[0].width || texture.image[0].image.width);\n\t\t} else {\n\t\t\t// Equirectangular\n\t\t\tthis._setSize(texture.image.width / 4);\n\t\t}\n\n\t\t_oldTarget = this._renderer.getRenderTarget();\n\n\t\tconst cubeUVRenderTarget = renderTarget || this._allocateTargets();\n\n\t\tthis._textureToCubeUV(texture, cubeUVRenderTarget);\n\n\t\tthis._applyPMREM(cubeUVRenderTarget);\n\n\t\tthis._cleanup(cubeUVRenderTarget);\n\n\t\treturn cubeUVRenderTarget;\n\t}\n\n\t_allocateTargets() {\n\t\tconst width = 3 * Math.max(this._cubeSize, 16 * 7);\n\t\tconst height = 4 * this._cubeSize;\n\t\tconst params = {\n\t\t\tmagFilter: LinearFilter,\n\t\t\tminFilter: LinearFilter,\n\t\t\tgenerateMipmaps: false,\n\t\t\ttype: HalfFloatType,\n\t\t\tformat: RGBAFormat,\n\t\t\tencoding: LinearEncoding,\n\t\t\tdepthBuffer: false\n\t\t};\n\n\t\tconst cubeUVRenderTarget = _createRenderTarget(width, height, params);\n\n\t\tif (this._pingPongRenderTarget === null || this._pingPongRenderTarget.width !== width) {\n\t\t\tif (this._pingPongRenderTarget !== null) {\n\t\t\t\tthis._dispose();\n\t\t\t}\n\n\t\t\tthis._pingPongRenderTarget = _createRenderTarget(width, height, params);\n\t\t\tconst {\n\t\t\t\t_lodMax\n\t\t\t} = this;\n\t\t\t({\n\t\t\t\tsizeLods: this._sizeLods,\n\t\t\t\tlodPlanes: this._lodPlanes,\n\t\t\t\tsigmas: this._sigmas\n\t\t\t} = _createPlanes(_lodMax));\n\t\t\tthis._blurMaterial = _getBlurShader(_lodMax, width, height);\n\t\t}\n\n\t\treturn cubeUVRenderTarget;\n\t}\n\n\t_compileMaterial(material) {\n\t\tconst tmpMesh = new Mesh(this._lodPlanes[0], material);\n\n\t\tthis._renderer.compile(tmpMesh, _flatCamera);\n\t}\n\n\t_sceneToCubeUV(scene, near, far, cubeUVRenderTarget) {\n\t\tconst fov = 90;\n\t\tconst aspect = 1;\n\t\tconst cubeCamera = new PerspectiveCamera(fov, aspect, near, far);\n\t\tconst upSign = [1, -1, 1, 1, 1, 1];\n\t\tconst forwardSign = [1, 1, 1, -1, -1, -1];\n\t\tconst renderer = this._renderer;\n\t\tconst originalAutoClear = renderer.autoClear;\n\t\tconst toneMapping = renderer.toneMapping;\n\t\trenderer.getClearColor(_clearColor);\n\t\trenderer.toneMapping = NoToneMapping;\n\t\trenderer.autoClear = false;\n\t\tconst backgroundMaterial = new MeshBasicMaterial({\n\t\t\tname: 'PMREM.Background',\n\t\t\tside: BackSide,\n\t\t\tdepthWrite: false,\n\t\t\tdepthTest: false\n\t\t});\n\t\tconst backgroundBox = new Mesh(new BoxGeometry(), backgroundMaterial);\n\t\tlet useSolidColor = false;\n\t\tconst background = scene.background;\n\n\t\tif (background) {\n\t\t\tif (background.isColor) {\n\t\t\t\tbackgroundMaterial.color.copy(background);\n\t\t\t\tscene.background = null;\n\t\t\t\tuseSolidColor = true;\n\t\t\t}\n\t\t} else {\n\t\t\tbackgroundMaterial.color.copy(_clearColor);\n\t\t\tuseSolidColor = true;\n\t\t}\n\n\t\tfor (let i = 0; i < 6; i++) {\n\t\t\tconst col = i % 3;\n\n\t\t\tif (col === 0) {\n\t\t\t\tcubeCamera.up.set(0, upSign[i], 0);\n\t\t\t\tcubeCamera.lookAt(forwardSign[i], 0, 0);\n\t\t\t} else if (col === 1) {\n\t\t\t\tcubeCamera.up.set(0, 0, upSign[i]);\n\t\t\t\tcubeCamera.lookAt(0, forwardSign[i], 0);\n\t\t\t} else {\n\t\t\t\tcubeCamera.up.set(0, upSign[i], 0);\n\t\t\t\tcubeCamera.lookAt(0, 0, forwardSign[i]);\n\t\t\t}\n\n\t\t\tconst size = this._cubeSize;\n\n\t\t\t_setViewport(cubeUVRenderTarget, col * size, i > 2 ? size : 0, size, size);\n\n\t\t\trenderer.setRenderTarget(cubeUVRenderTarget);\n\n\t\t\tif (useSolidColor) {\n\t\t\t\trenderer.render(backgroundBox, cubeCamera);\n\t\t\t}\n\n\t\t\trenderer.render(scene, cubeCamera);\n\t\t}\n\n\t\tbackgroundBox.geometry.dispose();\n\t\tbackgroundBox.material.dispose();\n\t\trenderer.toneMapping = toneMapping;\n\t\trenderer.autoClear = originalAutoClear;\n\t\tscene.background = background;\n\t}\n\n\t_textureToCubeUV(texture, cubeUVRenderTarget) {\n\t\tconst renderer = this._renderer;\n\t\tconst isCubeTexture = texture.mapping === CubeReflectionMapping || texture.mapping === CubeRefractionMapping;\n\n\t\tif (isCubeTexture) {\n\t\t\tif (this._cubemapMaterial === null) {\n\t\t\t\tthis._cubemapMaterial = _getCubemapMaterial();\n\t\t\t}\n\n\t\t\tthis._cubemapMaterial.uniforms.flipEnvMap.value = texture.isRenderTargetTexture === false ? -1 : 1;\n\t\t} else {\n\t\t\tif (this._equirectMaterial === null) {\n\t\t\t\tthis._equirectMaterial = _getEquirectMaterial();\n\t\t\t}\n\t\t}\n\n\t\tconst material = isCubeTexture ? this._cubemapMaterial : this._equirectMaterial;\n\t\tconst mesh = new Mesh(this._lodPlanes[0], material);\n\t\tconst uniforms = material.uniforms;\n\t\tuniforms['envMap'].value = texture;\n\t\tconst size = this._cubeSize;\n\n\t\t_setViewport(cubeUVRenderTarget, 0, 0, 3 * size, 2 * size);\n\n\t\trenderer.setRenderTarget(cubeUVRenderTarget);\n\t\trenderer.render(mesh, _flatCamera);\n\t}\n\n\t_applyPMREM(cubeUVRenderTarget) {\n\t\tconst renderer = this._renderer;\n\t\tconst autoClear = renderer.autoClear;\n\t\trenderer.autoClear = false;\n\n\t\tfor (let i = 1; i < this._lodPlanes.length; i++) {\n\t\t\tconst sigma = Math.sqrt(this._sigmas[i] * this._sigmas[i] - this._sigmas[i - 1] * this._sigmas[i - 1]);\n\t\t\tconst poleAxis = _axisDirections[(i - 1) % _axisDirections.length];\n\n\t\t\tthis._blur(cubeUVRenderTarget, i - 1, i, sigma, poleAxis);\n\t\t}\n\n\t\trenderer.autoClear = autoClear;\n\t}\n\t/**\n\t * This is a two-pass Gaussian blur for a cubemap. Normally this is done\n\t * vertically and horizontally, but this breaks down on a cube. Here we apply\n\t * the blur latitudinally (around the poles), and then longitudinally (towards\n\t * the poles) to approximate the orthogonally-separable blur. It is least\n\t * accurate at the poles, but still does a decent job.\n\t */\n\n\n\t_blur(cubeUVRenderTarget, lodIn, lodOut, sigma, poleAxis) {\n\t\tconst pingPongRenderTarget = this._pingPongRenderTarget;\n\n\t\tthis._halfBlur(cubeUVRenderTarget, pingPongRenderTarget, lodIn, lodOut, sigma, 'latitudinal', poleAxis);\n\n\t\tthis._halfBlur(pingPongRenderTarget, cubeUVRenderTarget, lodOut, lodOut, sigma, 'longitudinal', poleAxis);\n\t}\n\n\t_halfBlur(targetIn, targetOut, lodIn, lodOut, sigmaRadians, direction, poleAxis) {\n\t\tconst renderer = this._renderer;\n\t\tconst blurMaterial = this._blurMaterial;\n\n\t\tif (direction !== 'latitudinal' && direction !== 'longitudinal') {\n\t\t\tconsole.error('blur direction must be either latitudinal or longitudinal!');\n\t\t} // Number of standard deviations at which to cut off the discrete approximation.\n\n\n\t\tconst STANDARD_DEVIATIONS = 3;\n\t\tconst blurMesh = new Mesh(this._lodPlanes[lodOut], blurMaterial);\n\t\tconst blurUniforms = blurMaterial.uniforms;\n\t\tconst pixels = this._sizeLods[lodIn] - 1;\n\t\tconst radiansPerPixel = isFinite(sigmaRadians) ? Math.PI / (2 * pixels) : 2 * Math.PI / (2 * MAX_SAMPLES - 1);\n\t\tconst sigmaPixels = sigmaRadians / radiansPerPixel;\n\t\tconst samples = isFinite(sigmaRadians) ? 1 + Math.floor(STANDARD_DEVIATIONS * sigmaPixels) : MAX_SAMPLES;\n\n\t\tif (samples > MAX_SAMPLES) {\n\t\t\tconsole.warn(`sigmaRadians, ${sigmaRadians}, is too large and will clip, as it requested ${samples} samples when the maximum is set to ${MAX_SAMPLES}`);\n\t\t}\n\n\t\tconst weights = [];\n\t\tlet sum = 0;\n\n\t\tfor (let i = 0; i < MAX_SAMPLES; ++i) {\n\t\t\tconst x = i / sigmaPixels;\n\t\t\tconst weight = Math.exp(-x * x / 2);\n\t\t\tweights.push(weight);\n\n\t\t\tif (i === 0) {\n\t\t\t\tsum += weight;\n\t\t\t} else if (i < samples) {\n\t\t\t\tsum += 2 * weight;\n\t\t\t}\n\t\t}\n\n\t\tfor (let i = 0; i < weights.length; i++) {\n\t\t\tweights[i] = weights[i] / sum;\n\t\t}\n\n\t\tblurUniforms['envMap'].value = targetIn.texture;\n\t\tblurUniforms['samples'].value = samples;\n\t\tblurUniforms['weights'].value = weights;\n\t\tblurUniforms['latitudinal'].value = direction === 'latitudinal';\n\n\t\tif (poleAxis) {\n\t\t\tblurUniforms['poleAxis'].value = poleAxis;\n\t\t}\n\n\t\tconst {\n\t\t\t_lodMax\n\t\t} = this;\n\t\tblurUniforms['dTheta'].value = radiansPerPixel;\n\t\tblurUniforms['mipInt'].value = _lodMax - lodIn;\n\t\tconst outputSize = this._sizeLods[lodOut];\n\t\tconst x = 3 * outputSize * (lodOut > _lodMax - LOD_MIN ? lodOut - _lodMax + LOD_MIN : 0);\n\t\tconst y = 4 * (this._cubeSize - outputSize);\n\n\t\t_setViewport(targetOut, x, y, 3 * outputSize, 2 * outputSize);\n\n\t\trenderer.setRenderTarget(targetOut);\n\t\trenderer.render(blurMesh, _flatCamera);\n\t}\n\n}\n\nfunction _createPlanes(lodMax) {\n\tconst lodPlanes = [];\n\tconst sizeLods = [];\n\tconst sigmas = [];\n\tlet lod = lodMax;\n\tconst totalLods = lodMax - LOD_MIN + 1 + EXTRA_LOD_SIGMA.length;\n\n\tfor (let i = 0; i < totalLods; i++) {\n\t\tconst sizeLod = Math.pow(2, lod);\n\t\tsizeLods.push(sizeLod);\n\t\tlet sigma = 1.0 / sizeLod;\n\n\t\tif (i > lodMax - LOD_MIN) {\n\t\t\tsigma = EXTRA_LOD_SIGMA[i - lodMax + LOD_MIN - 1];\n\t\t} else if (i === 0) {\n\t\t\tsigma = 0;\n\t\t}\n\n\t\tsigmas.push(sigma);\n\t\tconst texelSize = 1.0 / (sizeLod - 2);\n\t\tconst min = -texelSize;\n\t\tconst max = 1 + texelSize;\n\t\tconst uv1 = [min, min, max, min, max, max, min, min, max, max, min, max];\n\t\tconst cubeFaces = 6;\n\t\tconst vertices = 6;\n\t\tconst positionSize = 3;\n\t\tconst uvSize = 2;\n\t\tconst faceIndexSize = 1;\n\t\tconst position = new Float32Array(positionSize * vertices * cubeFaces);\n\t\tconst uv = new Float32Array(uvSize * vertices * cubeFaces);\n\t\tconst faceIndex = new Float32Array(faceIndexSize * vertices * cubeFaces);\n\n\t\tfor (let face = 0; face < cubeFaces; face++) {\n\t\t\tconst x = face % 3 * 2 / 3 - 1;\n\t\t\tconst y = face > 2 ? 0 : -1;\n\t\t\tconst coordinates = [x, y, 0, x + 2 / 3, y, 0, x + 2 / 3, y + 1, 0, x, y, 0, x + 2 / 3, y + 1, 0, x, y + 1, 0];\n\t\t\tposition.set(coordinates, positionSize * vertices * face);\n\t\t\tuv.set(uv1, uvSize * vertices * face);\n\t\t\tconst fill = [face, face, face, face, face, face];\n\t\t\tfaceIndex.set(fill, faceIndexSize * vertices * face);\n\t\t}\n\n\t\tconst planes = new BufferGeometry();\n\t\tplanes.setAttribute('position', new BufferAttribute(position, positionSize));\n\t\tplanes.setAttribute('uv', new BufferAttribute(uv, uvSize));\n\t\tplanes.setAttribute('faceIndex', new BufferAttribute(faceIndex, faceIndexSize));\n\t\tlodPlanes.push(planes);\n\n\t\tif (lod > LOD_MIN) {\n\t\t\tlod--;\n\t\t}\n\t}\n\n\treturn {\n\t\tlodPlanes,\n\t\tsizeLods,\n\t\tsigmas\n\t};\n}\n\nfunction _createRenderTarget(width, height, params) {\n\tconst cubeUVRenderTarget = new WebGLRenderTarget(width, height, params);\n\tcubeUVRenderTarget.texture.mapping = CubeUVReflectionMapping;\n\tcubeUVRenderTarget.texture.name = 'PMREM.cubeUv';\n\tcubeUVRenderTarget.scissorTest = true;\n\treturn cubeUVRenderTarget;\n}\n\nfunction _setViewport(target, x, y, width, height) {\n\ttarget.viewport.set(x, y, width, height);\n\ttarget.scissor.set(x, y, width, height);\n}\n\nfunction _getBlurShader(lodMax, width, height) {\n\tconst weights = new Float32Array(MAX_SAMPLES);\n\tconst poleAxis = new Vector3(0, 1, 0);\n\tconst shaderMaterial = new ShaderMaterial({\n\t\tname: 'SphericalGaussianBlur',\n\t\tdefines: {\n\t\t\t'n': MAX_SAMPLES,\n\t\t\t'CUBEUV_TEXEL_WIDTH': 1.0 / width,\n\t\t\t'CUBEUV_TEXEL_HEIGHT': 1.0 / height,\n\t\t\t'CUBEUV_MAX_MIP': `${lodMax}.0`\n\t\t},\n\t\tuniforms: {\n\t\t\t'envMap': {\n\t\t\t\tvalue: null\n\t\t\t},\n\t\t\t'samples': {\n\t\t\t\tvalue: 1\n\t\t\t},\n\t\t\t'weights': {\n\t\t\t\tvalue: weights\n\t\t\t},\n\t\t\t'latitudinal': {\n\t\t\t\tvalue: false\n\t\t\t},\n\t\t\t'dTheta': {\n\t\t\t\tvalue: 0\n\t\t\t},\n\t\t\t'mipInt': {\n\t\t\t\tvalue: 0\n\t\t\t},\n\t\t\t'poleAxis': {\n\t\t\t\tvalue: poleAxis\n\t\t\t}\n\t\t},\n\t\tvertexShader: _getCommonVertexShader(),\n\t\tfragmentShader:\n\t\t/* glsl */\n\t\t`\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`,\n\t\tblending: NoBlending,\n\t\tdepthTest: false,\n\t\tdepthWrite: false\n\t});\n\treturn shaderMaterial;\n}\n\nfunction _getEquirectMaterial() {\n\treturn new ShaderMaterial({\n\t\tname: 'EquirectangularToCubeUV',\n\t\tuniforms: {\n\t\t\t'envMap': {\n\t\t\t\tvalue: null\n\t\t\t}\n\t\t},\n\t\tvertexShader: _getCommonVertexShader(),\n\t\tfragmentShader:\n\t\t/* glsl */\n\t\t`\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`,\n\t\tblending: NoBlending,\n\t\tdepthTest: false,\n\t\tdepthWrite: false\n\t});\n}\n\nfunction _getCubemapMaterial() {\n\treturn new ShaderMaterial({\n\t\tname: 'CubemapToCubeUV',\n\t\tuniforms: {\n\t\t\t'envMap': {\n\t\t\t\tvalue: null\n\t\t\t},\n\t\t\t'flipEnvMap': {\n\t\t\t\tvalue: -1\n\t\t\t}\n\t\t},\n\t\tvertexShader: _getCommonVertexShader(),\n\t\tfragmentShader:\n\t\t/* glsl */\n\t\t`\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`,\n\t\tblending: NoBlending,\n\t\tdepthTest: false,\n\t\tdepthWrite: false\n\t});\n}\n\nfunction _getCommonVertexShader() {\n\treturn (\n\t\t/* glsl */\n\t\t`\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`\n\t);\n}\n\nfunction WebGLCubeUVMaps(renderer) {\n\tlet cubeUVmaps = new WeakMap();\n\tlet pmremGenerator = null;\n\n\tfunction get(texture) {\n\t\tif (texture && texture.isTexture) {\n\t\t\tconst mapping = texture.mapping;\n\t\t\tconst isEquirectMap = mapping === EquirectangularReflectionMapping || mapping === EquirectangularRefractionMapping;\n\t\t\tconst isCubeMap = mapping === CubeReflectionMapping || mapping === CubeRefractionMapping; // equirect/cube map to cubeUV conversion\n\n\t\t\tif (isEquirectMap || isCubeMap) {\n\t\t\t\tif (texture.isRenderTargetTexture && texture.needsPMREMUpdate === true) {\n\t\t\t\t\ttexture.needsPMREMUpdate = false;\n\t\t\t\t\tlet renderTarget = cubeUVmaps.get(texture);\n\t\t\t\t\tif (pmremGenerator === null) pmremGenerator = new PMREMGenerator(renderer);\n\t\t\t\t\trenderTarget = isEquirectMap ? pmremGenerator.fromEquirectangular(texture, renderTarget) : pmremGenerator.fromCubemap(texture, renderTarget);\n\t\t\t\t\tcubeUVmaps.set(texture, renderTarget);\n\t\t\t\t\treturn renderTarget.texture;\n\t\t\t\t} else {\n\t\t\t\t\tif (cubeUVmaps.has(texture)) {\n\t\t\t\t\t\treturn cubeUVmaps.get(texture).texture;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst image = texture.image;\n\n\t\t\t\t\t\tif (isEquirectMap && image && image.height > 0 || isCubeMap && image && isCubeTextureComplete(image)) {\n\t\t\t\t\t\t\tif (pmremGenerator === null) pmremGenerator = new PMREMGenerator(renderer);\n\t\t\t\t\t\t\tconst renderTarget = isEquirectMap ? pmremGenerator.fromEquirectangular(texture) : pmremGenerator.fromCubemap(texture);\n\t\t\t\t\t\t\tcubeUVmaps.set(texture, renderTarget);\n\t\t\t\t\t\t\ttexture.addEventListener('dispose', onTextureDispose);\n\t\t\t\t\t\t\treturn renderTarget.texture;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// image not yet ready. try the conversion next frame\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn texture;\n\t}\n\n\tfunction isCubeTextureComplete(image) {\n\t\tlet count = 0;\n\t\tconst length = 6;\n\n\t\tfor (let i = 0; i < length; i++) {\n\t\t\tif (image[i] !== undefined) count++;\n\t\t}\n\n\t\treturn count === length;\n\t}\n\n\tfunction onTextureDispose(event) {\n\t\tconst texture = event.target;\n\t\ttexture.removeEventListener('dispose', onTextureDispose);\n\t\tconst cubemapUV = cubeUVmaps.get(texture);\n\n\t\tif (cubemapUV !== undefined) {\n\t\t\tcubeUVmaps.delete(texture);\n\t\t\tcubemapUV.dispose();\n\t\t}\n\t}\n\n\tfunction dispose() {\n\t\tcubeUVmaps = new WeakMap();\n\n\t\tif (pmremGenerator !== null) {\n\t\t\tpmremGenerator.dispose();\n\t\t\tpmremGenerator = null;\n\t\t}\n\t}\n\n\treturn {\n\t\tget: get,\n\t\tdispose: dispose\n\t};\n}\n\nfunction WebGLExtensions(gl) {\n\tconst extensions = {};\n\n\tfunction getExtension(name) {\n\t\tif (extensions[name] !== undefined) {\n\t\t\treturn extensions[name];\n\t\t}\n\n\t\tlet extension;\n\n\t\tswitch (name) {\n\t\t\tcase 'WEBGL_depth_texture':\n\t\t\t\textension = gl.getExtension('WEBGL_depth_texture') || gl.getExtension('MOZ_WEBGL_depth_texture') || gl.getExtension('WEBKIT_WEBGL_depth_texture');\n\t\t\t\tbreak;\n\n\t\t\tcase 'EXT_texture_filter_anisotropic':\n\t\t\t\textension = gl.getExtension('EXT_texture_filter_anisotropic') || gl.getExtension('MOZ_EXT_texture_filter_anisotropic') || gl.getExtension('WEBKIT_EXT_texture_filter_anisotropic');\n\t\t\t\tbreak;\n\n\t\t\tcase 'WEBGL_compressed_texture_s3tc':\n\t\t\t\textension = gl.getExtension('WEBGL_compressed_texture_s3tc') || gl.getExtension('MOZ_WEBGL_compressed_texture_s3tc') || gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');\n\t\t\t\tbreak;\n\n\t\t\tcase 'WEBGL_compressed_texture_pvrtc':\n\t\t\t\textension = gl.getExtension('WEBGL_compressed_texture_pvrtc') || gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\textension = gl.getExtension(name);\n\t\t}\n\n\t\textensions[name] = extension;\n\t\treturn extension;\n\t}\n\n\treturn {\n\t\thas: function (name) {\n\t\t\treturn getExtension(name) !== null;\n\t\t},\n\t\tinit: function (capabilities) {\n\t\t\tif (capabilities.isWebGL2) {\n\t\t\t\tgetExtension('EXT_color_buffer_float');\n\t\t\t} else {\n\t\t\t\tgetExtension('WEBGL_depth_texture');\n\t\t\t\tgetExtension('OES_texture_float');\n\t\t\t\tgetExtension('OES_texture_half_float');\n\t\t\t\tgetExtension('OES_texture_half_float_linear');\n\t\t\t\tgetExtension('OES_standard_derivatives');\n\t\t\t\tgetExtension('OES_element_index_uint');\n\t\t\t\tgetExtension('OES_vertex_array_object');\n\t\t\t\tgetExtension('ANGLE_instanced_arrays');\n\t\t\t}\n\n\t\t\tgetExtension('OES_texture_float_linear');\n\t\t\tgetExtension('EXT_color_buffer_half_float');\n\t\t\tgetExtension('WEBGL_multisampled_render_to_texture');\n\t\t},\n\t\tget: function (name) {\n\t\t\tconst extension = getExtension(name);\n\n\t\t\tif (extension === null) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: ' + name + ' extension not supported.');\n\t\t\t}\n\n\t\t\treturn extension;\n\t\t}\n\t};\n}\n\nfunction WebGLGeometries(gl, attributes, info, bindingStates) {\n\tconst geometries = {};\n\tconst wireframeAttributes = new WeakMap();\n\n\tfunction onGeometryDispose(event) {\n\t\tconst geometry = event.target;\n\n\t\tif (geometry.index !== null) {\n\t\t\tattributes.remove(geometry.index);\n\t\t}\n\n\t\tfor (const name in geometry.attributes) {\n\t\t\tattributes.remove(geometry.attributes[name]);\n\t\t}\n\n\t\tgeometry.removeEventListener('dispose', onGeometryDispose);\n\t\tdelete geometries[geometry.id];\n\t\tconst attribute = wireframeAttributes.get(geometry);\n\n\t\tif (attribute) {\n\t\t\tattributes.remove(attribute);\n\t\t\twireframeAttributes.delete(geometry);\n\t\t}\n\n\t\tbindingStates.releaseStatesOfGeometry(geometry);\n\n\t\tif (geometry.isInstancedBufferGeometry === true) {\n\t\t\tdelete geometry._maxInstanceCount;\n\t\t} //\n\n\n\t\tinfo.memory.geometries--;\n\t}\n\n\tfunction get(object, geometry) {\n\t\tif (geometries[geometry.id] === true) return geometry;\n\t\tgeometry.addEventListener('dispose', onGeometryDispose);\n\t\tgeometries[geometry.id] = true;\n\t\tinfo.memory.geometries++;\n\t\treturn geometry;\n\t}\n\n\tfunction update(geometry) {\n\t\tconst geometryAttributes = geometry.attributes; // Updating index buffer in VAO now. See WebGLBindingStates.\n\n\t\tfor (const name in geometryAttributes) {\n\t\t\tattributes.update(geometryAttributes[name], gl.ARRAY_BUFFER);\n\t\t} // morph targets\n\n\n\t\tconst morphAttributes = geometry.morphAttributes;\n\n\t\tfor (const name in morphAttributes) {\n\t\t\tconst array = morphAttributes[name];\n\n\t\t\tfor (let i = 0, l = array.length; i < l; i++) {\n\t\t\t\tattributes.update(array[i], gl.ARRAY_BUFFER);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction updateWireframeAttribute(geometry) {\n\t\tconst indices = [];\n\t\tconst geometryIndex = geometry.index;\n\t\tconst geometryPosition = geometry.attributes.position;\n\t\tlet version = 0;\n\n\t\tif (geometryIndex !== null) {\n\t\t\tconst array = geometryIndex.array;\n\t\t\tversion = geometryIndex.version;\n\n\t\t\tfor (let i = 0, l = array.length; i < l; i += 3) {\n\t\t\t\tconst a = array[i + 0];\n\t\t\t\tconst b = array[i + 1];\n\t\t\t\tconst c = array[i + 2];\n\t\t\t\tindices.push(a, b, b, c, c, a);\n\t\t\t}\n\t\t} else {\n\t\t\tconst array = geometryPosition.array;\n\t\t\tversion = geometryPosition.version;\n\n\t\t\tfor (let i = 0, l = array.length / 3 - 1; i < l; i += 3) {\n\t\t\t\tconst a = i + 0;\n\t\t\t\tconst b = i + 1;\n\t\t\t\tconst c = i + 2;\n\t\t\t\tindices.push(a, b, b, c, c, a);\n\t\t\t}\n\t\t}\n\n\t\tconst attribute = new (arrayNeedsUint32(indices) ? Uint32BufferAttribute : Uint16BufferAttribute)(indices, 1);\n\t\tattribute.version = version; // Updating index buffer in VAO now. See WebGLBindingStates\n\t\t//\n\n\t\tconst previousAttribute = wireframeAttributes.get(geometry);\n\t\tif (previousAttribute) attributes.remove(previousAttribute); //\n\n\t\twireframeAttributes.set(geometry, attribute);\n\t}\n\n\tfunction getWireframeAttribute(geometry) {\n\t\tconst currentAttribute = wireframeAttributes.get(geometry);\n\n\t\tif (currentAttribute) {\n\t\t\tconst geometryIndex = geometry.index;\n\n\t\t\tif (geometryIndex !== null) {\n\t\t\t\t// if the attribute is obsolete, create a new one\n\t\t\t\tif (currentAttribute.version < geometryIndex.version) {\n\t\t\t\t\tupdateWireframeAttribute(geometry);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tupdateWireframeAttribute(geometry);\n\t\t}\n\n\t\treturn wireframeAttributes.get(geometry);\n\t}\n\n\treturn {\n\t\tget: get,\n\t\tupdate: update,\n\t\tgetWireframeAttribute: getWireframeAttribute\n\t};\n}\n\nfunction WebGLIndexedBufferRenderer(gl, extensions, info, capabilities) {\n\tconst isWebGL2 = capabilities.isWebGL2;\n\tlet mode;\n\n\tfunction setMode(value) {\n\t\tmode = value;\n\t}\n\n\tlet type, bytesPerElement;\n\n\tfunction setIndex(value) {\n\t\ttype = value.type;\n\t\tbytesPerElement = value.bytesPerElement;\n\t}\n\n\tfunction render(start, count) {\n\t\tgl.drawElements(mode, count, type, start * bytesPerElement);\n\t\tinfo.update(count, mode, 1);\n\t}\n\n\tfunction renderInstances(start, count, primcount) {\n\t\tif (primcount === 0) return;\n\t\tlet extension, methodName;\n\n\t\tif (isWebGL2) {\n\t\t\textension = gl;\n\t\t\tmethodName = 'drawElementsInstanced';\n\t\t} else {\n\t\t\textension = extensions.get('ANGLE_instanced_arrays');\n\t\t\tmethodName = 'drawElementsInstancedANGLE';\n\n\t\t\tif (extension === null) {\n\t\t\t\tconsole.error('THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.');\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\textension[methodName](mode, count, type, start * bytesPerElement, primcount);\n\t\tinfo.update(count, mode, primcount);\n\t} //\n\n\n\tthis.setMode = setMode;\n\tthis.setIndex = setIndex;\n\tthis.render = render;\n\tthis.renderInstances = renderInstances;\n}\n\nfunction WebGLInfo(gl) {\n\tconst memory = {\n\t\tgeometries: 0,\n\t\ttextures: 0\n\t};\n\tconst render = {\n\t\tframe: 0,\n\t\tcalls: 0,\n\t\ttriangles: 0,\n\t\tpoints: 0,\n\t\tlines: 0\n\t};\n\n\tfunction update(count, mode, instanceCount) {\n\t\trender.calls++;\n\n\t\tswitch (mode) {\n\t\t\tcase gl.TRIANGLES:\n\t\t\t\trender.triangles += instanceCount * (count / 3);\n\t\t\t\tbreak;\n\n\t\t\tcase gl.LINES:\n\t\t\t\trender.lines += instanceCount * (count / 2);\n\t\t\t\tbreak;\n\n\t\t\tcase gl.LINE_STRIP:\n\t\t\t\trender.lines += instanceCount * (count - 1);\n\t\t\t\tbreak;\n\n\t\t\tcase gl.LINE_LOOP:\n\t\t\t\trender.lines += instanceCount * count;\n\t\t\t\tbreak;\n\n\t\t\tcase gl.POINTS:\n\t\t\t\trender.points += instanceCount * count;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tconsole.error('THREE.WebGLInfo: Unknown draw mode:', mode);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tfunction reset() {\n\t\trender.frame++;\n\t\trender.calls = 0;\n\t\trender.triangles = 0;\n\t\trender.points = 0;\n\t\trender.lines = 0;\n\t}\n\n\treturn {\n\t\tmemory: memory,\n\t\trender: render,\n\t\tprograms: null,\n\t\tautoReset: true,\n\t\treset: reset,\n\t\tupdate: update\n\t};\n}\n\nfunction numericalSort(a, b) {\n\treturn a[0] - b[0];\n}\n\nfunction absNumericalSort(a, b) {\n\treturn Math.abs(b[1]) - Math.abs(a[1]);\n}\n\nfunction WebGLMorphtargets(gl, capabilities, textures) {\n\tconst influencesList = {};\n\tconst morphInfluences = new Float32Array(8);\n\tconst morphTextures = new WeakMap();\n\tconst morph = new Vector4();\n\tconst workInfluences = [];\n\n\tfor (let i = 0; i < 8; i++) {\n\t\tworkInfluences[i] = [i, 0];\n\t}\n\n\tfunction update(object, geometry, material, program) {\n\t\tconst objectInfluences = object.morphTargetInfluences;\n\n\t\tif (capabilities.isWebGL2 === true) {\n\t\t\t// instead of using attributes, the WebGL 2 code path encodes morph targets\n\t\t\t// into an array of data textures. Each layer represents a single morph target.\n\t\t\tconst morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;\n\t\t\tconst morphTargetsCount = morphAttribute !== undefined ? morphAttribute.length : 0;\n\t\t\tlet entry = morphTextures.get(geometry);\n\n\t\t\tif (entry === undefined || entry.count !== morphTargetsCount) {\n\t\t\t\tif (entry !== undefined) entry.texture.dispose();\n\t\t\t\tconst hasMorphPosition = geometry.morphAttributes.position !== undefined;\n\t\t\t\tconst hasMorphNormals = geometry.morphAttributes.normal !== undefined;\n\t\t\t\tconst hasMorphColors = geometry.morphAttributes.color !== undefined;\n\t\t\t\tconst morphTargets = geometry.morphAttributes.position || [];\n\t\t\t\tconst morphNormals = geometry.morphAttributes.normal || [];\n\t\t\t\tconst morphColors = geometry.morphAttributes.color || [];\n\t\t\t\tlet vertexDataCount = 0;\n\t\t\t\tif (hasMorphPosition === true) vertexDataCount = 1;\n\t\t\t\tif (hasMorphNormals === true) vertexDataCount = 2;\n\t\t\t\tif (hasMorphColors === true) vertexDataCount = 3;\n\t\t\t\tlet width = geometry.attributes.position.count * vertexDataCount;\n\t\t\t\tlet height = 1;\n\n\t\t\t\tif (width > capabilities.maxTextureSize) {\n\t\t\t\t\theight = Math.ceil(width / capabilities.maxTextureSize);\n\t\t\t\t\twidth = capabilities.maxTextureSize;\n\t\t\t\t}\n\n\t\t\t\tconst buffer = new Float32Array(width * height * 4 * morphTargetsCount);\n\t\t\t\tconst texture = new DataArrayTexture(buffer, width, height, morphTargetsCount);\n\t\t\t\ttexture.type = FloatType;\n\t\t\t\ttexture.needsUpdate = true; // fill buffer\n\n\t\t\t\tconst vertexDataStride = vertexDataCount * 4;\n\n\t\t\t\tfor (let i = 0; i < morphTargetsCount; i++) {\n\t\t\t\t\tconst morphTarget = morphTargets[i];\n\t\t\t\t\tconst morphNormal = morphNormals[i];\n\t\t\t\t\tconst morphColor = morphColors[i];\n\t\t\t\t\tconst offset = width * height * 4 * i;\n\n\t\t\t\t\tfor (let j = 0; j < morphTarget.count; j++) {\n\t\t\t\t\t\tconst stride = j * vertexDataStride;\n\n\t\t\t\t\t\tif (hasMorphPosition === true) {\n\t\t\t\t\t\t\tmorph.fromBufferAttribute(morphTarget, j);\n\t\t\t\t\t\t\tbuffer[offset + stride + 0] = morph.x;\n\t\t\t\t\t\t\tbuffer[offset + stride + 1] = morph.y;\n\t\t\t\t\t\t\tbuffer[offset + stride + 2] = morph.z;\n\t\t\t\t\t\t\tbuffer[offset + stride + 3] = 0;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (hasMorphNormals === true) {\n\t\t\t\t\t\t\tmorph.fromBufferAttribute(morphNormal, j);\n\t\t\t\t\t\t\tbuffer[offset + stride + 4] = morph.x;\n\t\t\t\t\t\t\tbuffer[offset + stride + 5] = morph.y;\n\t\t\t\t\t\t\tbuffer[offset + stride + 6] = morph.z;\n\t\t\t\t\t\t\tbuffer[offset + stride + 7] = 0;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (hasMorphColors === true) {\n\t\t\t\t\t\t\tmorph.fromBufferAttribute(morphColor, j);\n\t\t\t\t\t\t\tbuffer[offset + stride + 8] = morph.x;\n\t\t\t\t\t\t\tbuffer[offset + stride + 9] = morph.y;\n\t\t\t\t\t\t\tbuffer[offset + stride + 10] = morph.z;\n\t\t\t\t\t\t\tbuffer[offset + stride + 11] = morphColor.itemSize === 4 ? morph.w : 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tentry = {\n\t\t\t\t\tcount: morphTargetsCount,\n\t\t\t\t\ttexture: texture,\n\t\t\t\t\tsize: new Vector2(width, height)\n\t\t\t\t};\n\t\t\t\tmorphTextures.set(geometry, entry);\n\n\t\t\t\tfunction disposeTexture() {\n\t\t\t\t\ttexture.dispose();\n\t\t\t\t\tmorphTextures.delete(geometry);\n\t\t\t\t\tgeometry.removeEventListener('dispose', disposeTexture);\n\t\t\t\t}\n\n\t\t\t\tgeometry.addEventListener('dispose', disposeTexture);\n\t\t\t} //\n\n\n\t\t\tlet morphInfluencesSum = 0;\n\n\t\t\tfor (let i = 0; i < objectInfluences.length; i++) {\n\t\t\t\tmorphInfluencesSum += objectInfluences[i];\n\t\t\t}\n\n\t\t\tconst morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum;\n\t\t\tprogram.getUniforms().setValue(gl, 'morphTargetBaseInfluence', morphBaseInfluence);\n\t\t\tprogram.getUniforms().setValue(gl, 'morphTargetInfluences', objectInfluences);\n\t\t\tprogram.getUniforms().setValue(gl, 'morphTargetsTexture', entry.texture, textures);\n\t\t\tprogram.getUniforms().setValue(gl, 'morphTargetsTextureSize', entry.size);\n\t\t} else {\n\t\t\t// When object doesn't have morph target influences defined, we treat it as a 0-length array\n\t\t\t// This is important to make sure we set up morphTargetBaseInfluence / morphTargetInfluences\n\t\t\tconst length = objectInfluences === undefined ? 0 : objectInfluences.length;\n\t\t\tlet influences = influencesList[geometry.id];\n\n\t\t\tif (influences === undefined || influences.length !== length) {\n\t\t\t\t// initialise list\n\t\t\t\tinfluences = [];\n\n\t\t\t\tfor (let i = 0; i < length; i++) {\n\t\t\t\t\tinfluences[i] = [i, 0];\n\t\t\t\t}\n\n\t\t\t\tinfluencesList[geometry.id] = influences;\n\t\t\t} // Collect influences\n\n\n\t\t\tfor (let i = 0; i < length; i++) {\n\t\t\t\tconst influence = influences[i];\n\t\t\t\tinfluence[0] = i;\n\t\t\t\tinfluence[1] = objectInfluences[i];\n\t\t\t}\n\n\t\t\tinfluences.sort(absNumericalSort);\n\n\t\t\tfor (let i = 0; i < 8; i++) {\n\t\t\t\tif (i < length && influences[i][1]) {\n\t\t\t\t\tworkInfluences[i][0] = influences[i][0];\n\t\t\t\t\tworkInfluences[i][1] = influences[i][1];\n\t\t\t\t} else {\n\t\t\t\t\tworkInfluences[i][0] = Number.MAX_SAFE_INTEGER;\n\t\t\t\t\tworkInfluences[i][1] = 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tworkInfluences.sort(numericalSort);\n\t\t\tconst morphTargets = geometry.morphAttributes.position;\n\t\t\tconst morphNormals = geometry.morphAttributes.normal;\n\t\t\tlet morphInfluencesSum = 0;\n\n\t\t\tfor (let i = 0; i < 8; i++) {\n\t\t\t\tconst influence = workInfluences[i];\n\t\t\t\tconst index = influence[0];\n\t\t\t\tconst value = influence[1];\n\n\t\t\t\tif (index !== Number.MAX_SAFE_INTEGER && value) {\n\t\t\t\t\tif (morphTargets && geometry.getAttribute('morphTarget' + i) !== morphTargets[index]) {\n\t\t\t\t\t\tgeometry.setAttribute('morphTarget' + i, morphTargets[index]);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (morphNormals && geometry.getAttribute('morphNormal' + i) !== morphNormals[index]) {\n\t\t\t\t\t\tgeometry.setAttribute('morphNormal' + i, morphNormals[index]);\n\t\t\t\t\t}\n\n\t\t\t\t\tmorphInfluences[i] = value;\n\t\t\t\t\tmorphInfluencesSum += value;\n\t\t\t\t} else {\n\t\t\t\t\tif (morphTargets && geometry.hasAttribute('morphTarget' + i) === true) {\n\t\t\t\t\t\tgeometry.deleteAttribute('morphTarget' + i);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (morphNormals && geometry.hasAttribute('morphNormal' + i) === true) {\n\t\t\t\t\t\tgeometry.deleteAttribute('morphNormal' + i);\n\t\t\t\t\t}\n\n\t\t\t\t\tmorphInfluences[i] = 0;\n\t\t\t\t}\n\t\t\t} // GLSL shader uses formula baseinfluence * base + sum(target * influence)\n\t\t\t// This allows us to switch between absolute morphs and relative morphs without changing shader code\n\t\t\t// When baseinfluence = 1 - sum(influence), the above is equivalent to sum((target - base) * influence)\n\n\n\t\t\tconst morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum;\n\t\t\tprogram.getUniforms().setValue(gl, 'morphTargetBaseInfluence', morphBaseInfluence);\n\t\t\tprogram.getUniforms().setValue(gl, 'morphTargetInfluences', morphInfluences);\n\t\t}\n\t}\n\n\treturn {\n\t\tupdate: update\n\t};\n}\n\nfunction WebGLObjects(gl, geometries, attributes, info) {\n\tlet updateMap = new WeakMap();\n\n\tfunction update(object) {\n\t\tconst frame = info.render.frame;\n\t\tconst geometry = object.geometry;\n\t\tconst buffergeometry = geometries.get(object, geometry); // Update once per frame\n\n\t\tif (updateMap.get(buffergeometry) !== frame) {\n\t\t\tgeometries.update(buffergeometry);\n\t\t\tupdateMap.set(buffergeometry, frame);\n\t\t}\n\n\t\tif (object.isInstancedMesh) {\n\t\t\tif (object.hasEventListener('dispose', onInstancedMeshDispose) === false) {\n\t\t\t\tobject.addEventListener('dispose', onInstancedMeshDispose);\n\t\t\t}\n\n\t\t\tattributes.update(object.instanceMatrix, gl.ARRAY_BUFFER);\n\n\t\t\tif (object.instanceColor !== null) {\n\t\t\t\tattributes.update(object.instanceColor, gl.ARRAY_BUFFER);\n\t\t\t}\n\t\t}\n\n\t\treturn buffergeometry;\n\t}\n\n\tfunction dispose() {\n\t\tupdateMap = new WeakMap();\n\t}\n\n\tfunction onInstancedMeshDispose(event) {\n\t\tconst instancedMesh = event.target;\n\t\tinstancedMesh.removeEventListener('dispose', onInstancedMeshDispose);\n\t\tattributes.remove(instancedMesh.instanceMatrix);\n\t\tif (instancedMesh.instanceColor !== null) attributes.remove(instancedMesh.instanceColor);\n\t}\n\n\treturn {\n\t\tupdate: update,\n\t\tdispose: dispose\n\t};\n}\n\n/**\n * Uniforms of a program.\n * Those form a tree structure with a special top-level container for the root,\n * which you get by calling 'new WebGLUniforms( gl, program )'.\n *\n *\n * Properties of inner nodes including the top-level container:\n *\n * .seq - array of nested uniforms\n * .map - nested uniforms by name\n *\n *\n * Methods of all nodes except the top-level container:\n *\n * .setValue( gl, value, [textures] )\n *\n * \t\tuploads a uniform value(s)\n *\t\tthe 'textures' parameter is needed for sampler uniforms\n *\n *\n * Static methods of the top-level container (textures factorizations):\n *\n * .upload( gl, seq, values, textures )\n *\n * \t\tsets uniforms in 'seq' to 'values[id].value'\n *\n * .seqWithValue( seq, values ) : filteredSeq\n *\n * \t\tfilters 'seq' entries with corresponding entry in values\n *\n *\n * Methods of the top-level container (textures factorizations):\n *\n * .setValue( gl, name, value, textures )\n *\n * \t\tsets uniform with\tname 'name' to 'value'\n *\n * .setOptional( gl, obj, prop )\n *\n * \t\tlike .set for an optional property of the object\n *\n */\nconst emptyTexture = /*@__PURE__*/new Texture();\nconst emptyArrayTexture = /*@__PURE__*/new DataArrayTexture();\nconst empty3dTexture = /*@__PURE__*/new Data3DTexture();\nconst emptyCubeTexture = /*@__PURE__*/new CubeTexture(); // --- Utilities ---\n// Array Caches (provide typed arrays for temporary by size)\n\nconst arrayCacheF32 = [];\nconst arrayCacheI32 = []; // Float32Array caches used for uploading Matrix uniforms\n\nconst mat4array = new Float32Array(16);\nconst mat3array = new Float32Array(9);\nconst mat2array = new Float32Array(4); // Flattening for arrays of vectors and matrices\n\nfunction flatten(array, nBlocks, blockSize) {\n\tconst firstElem = array[0];\n\tif (firstElem <= 0 || firstElem > 0) return array; // unoptimized: ! isNaN( firstElem )\n\t// see http://jacksondunstan.com/articles/983\n\n\tconst n = nBlocks * blockSize;\n\tlet r = arrayCacheF32[n];\n\n\tif (r === undefined) {\n\t\tr = new Float32Array(n);\n\t\tarrayCacheF32[n] = r;\n\t}\n\n\tif (nBlocks !== 0) {\n\t\tfirstElem.toArray(r, 0);\n\n\t\tfor (let i = 1, offset = 0; i !== nBlocks; ++i) {\n\t\t\toffset += blockSize;\n\t\t\tarray[i].toArray(r, offset);\n\t\t}\n\t}\n\n\treturn r;\n}\n\nfunction arraysEqual(a, b) {\n\tif (a.length !== b.length) return false;\n\n\tfor (let i = 0, l = a.length; i < l; i++) {\n\t\tif (a[i] !== b[i]) return false;\n\t}\n\n\treturn true;\n}\n\nfunction copyArray(a, b) {\n\tfor (let i = 0, l = b.length; i < l; i++) {\n\t\ta[i] = b[i];\n\t}\n} // Texture unit allocation\n\n\nfunction allocTexUnits(textures, n) {\n\tlet r = arrayCacheI32[n];\n\n\tif (r === undefined) {\n\t\tr = new Int32Array(n);\n\t\tarrayCacheI32[n] = r;\n\t}\n\n\tfor (let i = 0; i !== n; ++i) {\n\t\tr[i] = textures.allocateTextureUnit();\n\t}\n\n\treturn r;\n} // --- Setters ---\n// Note: Defining these methods externally, because they come in a bunch\n// and this way their names minify.\n// Single scalar\n\n\nfunction setValueV1f(gl, v) {\n\tconst cache = this.cache;\n\tif (cache[0] === v) return;\n\tgl.uniform1f(this.addr, v);\n\tcache[0] = v;\n} // Single float vector (from flat array or THREE.VectorN)\n\n\nfunction setValueV2f(gl, v) {\n\tconst cache = this.cache;\n\n\tif (v.x !== undefined) {\n\t\tif (cache[0] !== v.x || cache[1] !== v.y) {\n\t\t\tgl.uniform2f(this.addr, v.x, v.y);\n\t\t\tcache[0] = v.x;\n\t\t\tcache[1] = v.y;\n\t\t}\n\t} else {\n\t\tif (arraysEqual(cache, v)) return;\n\t\tgl.uniform2fv(this.addr, v);\n\t\tcopyArray(cache, v);\n\t}\n}\n\nfunction setValueV3f(gl, v) {\n\tconst cache = this.cache;\n\n\tif (v.x !== undefined) {\n\t\tif (cache[0] !== v.x || cache[1] !== v.y || cache[2] !== v.z) {\n\t\t\tgl.uniform3f(this.addr, v.x, v.y, v.z);\n\t\t\tcache[0] = v.x;\n\t\t\tcache[1] = v.y;\n\t\t\tcache[2] = v.z;\n\t\t}\n\t} else if (v.r !== undefined) {\n\t\tif (cache[0] !== v.r || cache[1] !== v.g || cache[2] !== v.b) {\n\t\t\tgl.uniform3f(this.addr, v.r, v.g, v.b);\n\t\t\tcache[0] = v.r;\n\t\t\tcache[1] = v.g;\n\t\t\tcache[2] = v.b;\n\t\t}\n\t} else {\n\t\tif (arraysEqual(cache, v)) return;\n\t\tgl.uniform3fv(this.addr, v);\n\t\tcopyArray(cache, v);\n\t}\n}\n\nfunction setValueV4f(gl, v) {\n\tconst cache = this.cache;\n\n\tif (v.x !== undefined) {\n\t\tif (cache[0] !== v.x || cache[1] !== v.y || cache[2] !== v.z || cache[3] !== v.w) {\n\t\t\tgl.uniform4f(this.addr, v.x, v.y, v.z, v.w);\n\t\t\tcache[0] = v.x;\n\t\t\tcache[1] = v.y;\n\t\t\tcache[2] = v.z;\n\t\t\tcache[3] = v.w;\n\t\t}\n\t} else {\n\t\tif (arraysEqual(cache, v)) return;\n\t\tgl.uniform4fv(this.addr, v);\n\t\tcopyArray(cache, v);\n\t}\n} // Single matrix (from flat array or THREE.MatrixN)\n\n\nfunction setValueM2(gl, v) {\n\tconst cache = this.cache;\n\tconst elements = v.elements;\n\n\tif (elements === undefined) {\n\t\tif (arraysEqual(cache, v)) return;\n\t\tgl.uniformMatrix2fv(this.addr, false, v);\n\t\tcopyArray(cache, v);\n\t} else {\n\t\tif (arraysEqual(cache, elements)) return;\n\t\tmat2array.set(elements);\n\t\tgl.uniformMatrix2fv(this.addr, false, mat2array);\n\t\tcopyArray(cache, elements);\n\t}\n}\n\nfunction setValueM3(gl, v) {\n\tconst cache = this.cache;\n\tconst elements = v.elements;\n\n\tif (elements === undefined) {\n\t\tif (arraysEqual(cache, v)) return;\n\t\tgl.uniformMatrix3fv(this.addr, false, v);\n\t\tcopyArray(cache, v);\n\t} else {\n\t\tif (arraysEqual(cache, elements)) return;\n\t\tmat3array.set(elements);\n\t\tgl.uniformMatrix3fv(this.addr, false, mat3array);\n\t\tcopyArray(cache, elements);\n\t}\n}\n\nfunction setValueM4(gl, v) {\n\tconst cache = this.cache;\n\tconst elements = v.elements;\n\n\tif (elements === undefined) {\n\t\tif (arraysEqual(cache, v)) return;\n\t\tgl.uniformMatrix4fv(this.addr, false, v);\n\t\tcopyArray(cache, v);\n\t} else {\n\t\tif (arraysEqual(cache, elements)) return;\n\t\tmat4array.set(elements);\n\t\tgl.uniformMatrix4fv(this.addr, false, mat4array);\n\t\tcopyArray(cache, elements);\n\t}\n} // Single integer / boolean\n\n\nfunction setValueV1i(gl, v) {\n\tconst cache = this.cache;\n\tif (cache[0] === v) return;\n\tgl.uniform1i(this.addr, v);\n\tcache[0] = v;\n} // Single integer / boolean vector (from flat array)\n\n\nfunction setValueV2i(gl, v) {\n\tconst cache = this.cache;\n\tif (arraysEqual(cache, v)) return;\n\tgl.uniform2iv(this.addr, v);\n\tcopyArray(cache, v);\n}\n\nfunction setValueV3i(gl, v) {\n\tconst cache = this.cache;\n\tif (arraysEqual(cache, v)) return;\n\tgl.uniform3iv(this.addr, v);\n\tcopyArray(cache, v);\n}\n\nfunction setValueV4i(gl, v) {\n\tconst cache = this.cache;\n\tif (arraysEqual(cache, v)) return;\n\tgl.uniform4iv(this.addr, v);\n\tcopyArray(cache, v);\n} // Single unsigned integer\n\n\nfunction setValueV1ui(gl, v) {\n\tconst cache = this.cache;\n\tif (cache[0] === v) return;\n\tgl.uniform1ui(this.addr, v);\n\tcache[0] = v;\n} // Single unsigned integer vector (from flat array)\n\n\nfunction setValueV2ui(gl, v) {\n\tconst cache = this.cache;\n\tif (arraysEqual(cache, v)) return;\n\tgl.uniform2uiv(this.addr, v);\n\tcopyArray(cache, v);\n}\n\nfunction setValueV3ui(gl, v) {\n\tconst cache = this.cache;\n\tif (arraysEqual(cache, v)) return;\n\tgl.uniform3uiv(this.addr, v);\n\tcopyArray(cache, v);\n}\n\nfunction setValueV4ui(gl, v) {\n\tconst cache = this.cache;\n\tif (arraysEqual(cache, v)) return;\n\tgl.uniform4uiv(this.addr, v);\n\tcopyArray(cache, v);\n} // Single texture (2D / Cube)\n\n\nfunction setValueT1(gl, v, textures) {\n\tconst cache = this.cache;\n\tconst unit = textures.allocateTextureUnit();\n\n\tif (cache[0] !== unit) {\n\t\tgl.uniform1i(this.addr, unit);\n\t\tcache[0] = unit;\n\t}\n\n\ttextures.setTexture2D(v || emptyTexture, unit);\n}\n\nfunction setValueT3D1(gl, v, textures) {\n\tconst cache = this.cache;\n\tconst unit = textures.allocateTextureUnit();\n\n\tif (cache[0] !== unit) {\n\t\tgl.uniform1i(this.addr, unit);\n\t\tcache[0] = unit;\n\t}\n\n\ttextures.setTexture3D(v || empty3dTexture, unit);\n}\n\nfunction setValueT6(gl, v, textures) {\n\tconst cache = this.cache;\n\tconst unit = textures.allocateTextureUnit();\n\n\tif (cache[0] !== unit) {\n\t\tgl.uniform1i(this.addr, unit);\n\t\tcache[0] = unit;\n\t}\n\n\ttextures.setTextureCube(v || emptyCubeTexture, unit);\n}\n\nfunction setValueT2DArray1(gl, v, textures) {\n\tconst cache = this.cache;\n\tconst unit = textures.allocateTextureUnit();\n\n\tif (cache[0] !== unit) {\n\t\tgl.uniform1i(this.addr, unit);\n\t\tcache[0] = unit;\n\t}\n\n\ttextures.setTexture2DArray(v || emptyArrayTexture, unit);\n} // Helper to pick the right setter for the singular case\n\n\nfunction getSingularSetter(type) {\n\tswitch (type) {\n\t\tcase 0x1406:\n\t\t\treturn setValueV1f;\n\t\t// FLOAT\n\n\t\tcase 0x8b50:\n\t\t\treturn setValueV2f;\n\t\t// _VEC2\n\n\t\tcase 0x8b51:\n\t\t\treturn setValueV3f;\n\t\t// _VEC3\n\n\t\tcase 0x8b52:\n\t\t\treturn setValueV4f;\n\t\t// _VEC4\n\n\t\tcase 0x8b5a:\n\t\t\treturn setValueM2;\n\t\t// _MAT2\n\n\t\tcase 0x8b5b:\n\t\t\treturn setValueM3;\n\t\t// _MAT3\n\n\t\tcase 0x8b5c:\n\t\t\treturn setValueM4;\n\t\t// _MAT4\n\n\t\tcase 0x1404:\n\t\tcase 0x8b56:\n\t\t\treturn setValueV1i;\n\t\t// INT, BOOL\n\n\t\tcase 0x8b53:\n\t\tcase 0x8b57:\n\t\t\treturn setValueV2i;\n\t\t// _VEC2\n\n\t\tcase 0x8b54:\n\t\tcase 0x8b58:\n\t\t\treturn setValueV3i;\n\t\t// _VEC3\n\n\t\tcase 0x8b55:\n\t\tcase 0x8b59:\n\t\t\treturn setValueV4i;\n\t\t// _VEC4\n\n\t\tcase 0x1405:\n\t\t\treturn setValueV1ui;\n\t\t// UINT\n\n\t\tcase 0x8dc6:\n\t\t\treturn setValueV2ui;\n\t\t// _VEC2\n\n\t\tcase 0x8dc7:\n\t\t\treturn setValueV3ui;\n\t\t// _VEC3\n\n\t\tcase 0x8dc8:\n\t\t\treturn setValueV4ui;\n\t\t// _VEC4\n\n\t\tcase 0x8b5e: // SAMPLER_2D\n\n\t\tcase 0x8d66: // SAMPLER_EXTERNAL_OES\n\n\t\tcase 0x8dca: // INT_SAMPLER_2D\n\n\t\tcase 0x8dd2: // UNSIGNED_INT_SAMPLER_2D\n\n\t\tcase 0x8b62:\n\t\t\t// SAMPLER_2D_SHADOW\n\t\t\treturn setValueT1;\n\n\t\tcase 0x8b5f: // SAMPLER_3D\n\n\t\tcase 0x8dcb: // INT_SAMPLER_3D\n\n\t\tcase 0x8dd3:\n\t\t\t// UNSIGNED_INT_SAMPLER_3D\n\t\t\treturn setValueT3D1;\n\n\t\tcase 0x8b60: // SAMPLER_CUBE\n\n\t\tcase 0x8dcc: // INT_SAMPLER_CUBE\n\n\t\tcase 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE\n\n\t\tcase 0x8dc5:\n\t\t\t// SAMPLER_CUBE_SHADOW\n\t\t\treturn setValueT6;\n\n\t\tcase 0x8dc1: // SAMPLER_2D_ARRAY\n\n\t\tcase 0x8dcf: // INT_SAMPLER_2D_ARRAY\n\n\t\tcase 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY\n\n\t\tcase 0x8dc4:\n\t\t\t// SAMPLER_2D_ARRAY_SHADOW\n\t\t\treturn setValueT2DArray1;\n\t}\n} // Array of scalars\n\n\nfunction setValueV1fArray(gl, v) {\n\tgl.uniform1fv(this.addr, v);\n} // Array of vectors (from flat array or array of THREE.VectorN)\n\n\nfunction setValueV2fArray(gl, v) {\n\tconst data = flatten(v, this.size, 2);\n\tgl.uniform2fv(this.addr, data);\n}\n\nfunction setValueV3fArray(gl, v) {\n\tconst data = flatten(v, this.size, 3);\n\tgl.uniform3fv(this.addr, data);\n}\n\nfunction setValueV4fArray(gl, v) {\n\tconst data = flatten(v, this.size, 4);\n\tgl.uniform4fv(this.addr, data);\n} // Array of matrices (from flat array or array of THREE.MatrixN)\n\n\nfunction setValueM2Array(gl, v) {\n\tconst data = flatten(v, this.size, 4);\n\tgl.uniformMatrix2fv(this.addr, false, data);\n}\n\nfunction setValueM3Array(gl, v) {\n\tconst data = flatten(v, this.size, 9);\n\tgl.uniformMatrix3fv(this.addr, false, data);\n}\n\nfunction setValueM4Array(gl, v) {\n\tconst data = flatten(v, this.size, 16);\n\tgl.uniformMatrix4fv(this.addr, false, data);\n} // Array of integer / boolean\n\n\nfunction setValueV1iArray(gl, v) {\n\tgl.uniform1iv(this.addr, v);\n} // Array of integer / boolean vectors (from flat array)\n\n\nfunction setValueV2iArray(gl, v) {\n\tgl.uniform2iv(this.addr, v);\n}\n\nfunction setValueV3iArray(gl, v) {\n\tgl.uniform3iv(this.addr, v);\n}\n\nfunction setValueV4iArray(gl, v) {\n\tgl.uniform4iv(this.addr, v);\n} // Array of unsigned integer\n\n\nfunction setValueV1uiArray(gl, v) {\n\tgl.uniform1uiv(this.addr, v);\n} // Array of unsigned integer vectors (from flat array)\n\n\nfunction setValueV2uiArray(gl, v) {\n\tgl.uniform2uiv(this.addr, v);\n}\n\nfunction setValueV3uiArray(gl, v) {\n\tgl.uniform3uiv(this.addr, v);\n}\n\nfunction setValueV4uiArray(gl, v) {\n\tgl.uniform4uiv(this.addr, v);\n} // Array of textures (2D / 3D / Cube / 2DArray)\n\n\nfunction setValueT1Array(gl, v, textures) {\n\tconst cache = this.cache;\n\tconst n = v.length;\n\tconst units = allocTexUnits(textures, n);\n\n\tif (!arraysEqual(cache, units)) {\n\t\tgl.uniform1iv(this.addr, units);\n\t\tcopyArray(cache, units);\n\t}\n\n\tfor (let i = 0; i !== n; ++i) {\n\t\ttextures.setTexture2D(v[i] || emptyTexture, units[i]);\n\t}\n}\n\nfunction setValueT3DArray(gl, v, textures) {\n\tconst cache = this.cache;\n\tconst n = v.length;\n\tconst units = allocTexUnits(textures, n);\n\n\tif (!arraysEqual(cache, units)) {\n\t\tgl.uniform1iv(this.addr, units);\n\t\tcopyArray(cache, units);\n\t}\n\n\tfor (let i = 0; i !== n; ++i) {\n\t\ttextures.setTexture3D(v[i] || empty3dTexture, units[i]);\n\t}\n}\n\nfunction setValueT6Array(gl, v, textures) {\n\tconst cache = this.cache;\n\tconst n = v.length;\n\tconst units = allocTexUnits(textures, n);\n\n\tif (!arraysEqual(cache, units)) {\n\t\tgl.uniform1iv(this.addr, units);\n\t\tcopyArray(cache, units);\n\t}\n\n\tfor (let i = 0; i !== n; ++i) {\n\t\ttextures.setTextureCube(v[i] || emptyCubeTexture, units[i]);\n\t}\n}\n\nfunction setValueT2DArrayArray(gl, v, textures) {\n\tconst cache = this.cache;\n\tconst n = v.length;\n\tconst units = allocTexUnits(textures, n);\n\n\tif (!arraysEqual(cache, units)) {\n\t\tgl.uniform1iv(this.addr, units);\n\t\tcopyArray(cache, units);\n\t}\n\n\tfor (let i = 0; i !== n; ++i) {\n\t\ttextures.setTexture2DArray(v[i] || emptyArrayTexture, units[i]);\n\t}\n} // Helper to pick the right setter for a pure (bottom-level) array\n\n\nfunction getPureArraySetter(type) {\n\tswitch (type) {\n\t\tcase 0x1406:\n\t\t\treturn setValueV1fArray;\n\t\t// FLOAT\n\n\t\tcase 0x8b50:\n\t\t\treturn setValueV2fArray;\n\t\t// _VEC2\n\n\t\tcase 0x8b51:\n\t\t\treturn setValueV3fArray;\n\t\t// _VEC3\n\n\t\tcase 0x8b52:\n\t\t\treturn setValueV4fArray;\n\t\t// _VEC4\n\n\t\tcase 0x8b5a:\n\t\t\treturn setValueM2Array;\n\t\t// _MAT2\n\n\t\tcase 0x8b5b:\n\t\t\treturn setValueM3Array;\n\t\t// _MAT3\n\n\t\tcase 0x8b5c:\n\t\t\treturn setValueM4Array;\n\t\t// _MAT4\n\n\t\tcase 0x1404:\n\t\tcase 0x8b56:\n\t\t\treturn setValueV1iArray;\n\t\t// INT, BOOL\n\n\t\tcase 0x8b53:\n\t\tcase 0x8b57:\n\t\t\treturn setValueV2iArray;\n\t\t// _VEC2\n\n\t\tcase 0x8b54:\n\t\tcase 0x8b58:\n\t\t\treturn setValueV3iArray;\n\t\t// _VEC3\n\n\t\tcase 0x8b55:\n\t\tcase 0x8b59:\n\t\t\treturn setValueV4iArray;\n\t\t// _VEC4\n\n\t\tcase 0x1405:\n\t\t\treturn setValueV1uiArray;\n\t\t// UINT\n\n\t\tcase 0x8dc6:\n\t\t\treturn setValueV2uiArray;\n\t\t// _VEC2\n\n\t\tcase 0x8dc7:\n\t\t\treturn setValueV3uiArray;\n\t\t// _VEC3\n\n\t\tcase 0x8dc8:\n\t\t\treturn setValueV4uiArray;\n\t\t// _VEC4\n\n\t\tcase 0x8b5e: // SAMPLER_2D\n\n\t\tcase 0x8d66: // SAMPLER_EXTERNAL_OES\n\n\t\tcase 0x8dca: // INT_SAMPLER_2D\n\n\t\tcase 0x8dd2: // UNSIGNED_INT_SAMPLER_2D\n\n\t\tcase 0x8b62:\n\t\t\t// SAMPLER_2D_SHADOW\n\t\t\treturn setValueT1Array;\n\n\t\tcase 0x8b5f: // SAMPLER_3D\n\n\t\tcase 0x8dcb: // INT_SAMPLER_3D\n\n\t\tcase 0x8dd3:\n\t\t\t// UNSIGNED_INT_SAMPLER_3D\n\t\t\treturn setValueT3DArray;\n\n\t\tcase 0x8b60: // SAMPLER_CUBE\n\n\t\tcase 0x8dcc: // INT_SAMPLER_CUBE\n\n\t\tcase 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE\n\n\t\tcase 0x8dc5:\n\t\t\t// SAMPLER_CUBE_SHADOW\n\t\t\treturn setValueT6Array;\n\n\t\tcase 0x8dc1: // SAMPLER_2D_ARRAY\n\n\t\tcase 0x8dcf: // INT_SAMPLER_2D_ARRAY\n\n\t\tcase 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY\n\n\t\tcase 0x8dc4:\n\t\t\t// SAMPLER_2D_ARRAY_SHADOW\n\t\t\treturn setValueT2DArrayArray;\n\t}\n} // --- Uniform Classes ---\n\n\nclass SingleUniform {\n\tconstructor(id, activeInfo, addr) {\n\t\tthis.id = id;\n\t\tthis.addr = addr;\n\t\tthis.cache = [];\n\t\tthis.setValue = getSingularSetter(activeInfo.type); // this.path = activeInfo.name; // DEBUG\n\t}\n\n}\n\nclass PureArrayUniform {\n\tconstructor(id, activeInfo, addr) {\n\t\tthis.id = id;\n\t\tthis.addr = addr;\n\t\tthis.cache = [];\n\t\tthis.size = activeInfo.size;\n\t\tthis.setValue = getPureArraySetter(activeInfo.type); // this.path = activeInfo.name; // DEBUG\n\t}\n\n}\n\nclass StructuredUniform {\n\tconstructor(id) {\n\t\tthis.id = id;\n\t\tthis.seq = [];\n\t\tthis.map = {};\n\t}\n\n\tsetValue(gl, value, textures) {\n\t\tconst seq = this.seq;\n\n\t\tfor (let i = 0, n = seq.length; i !== n; ++i) {\n\t\t\tconst u = seq[i];\n\t\t\tu.setValue(gl, value[u.id], textures);\n\t\t}\n\t}\n\n} // --- Top-level ---\n// Parser - builds up the property tree from the path strings\n\n\nconst RePathPart = /(\\w+)(\\])?(\\[|\\.)?/g; // extracts\n// \t- the identifier (member name or array index)\n//\t- followed by an optional right bracket (found when array index)\n//\t- followed by an optional left bracket or dot (type of subscript)\n//\n// Note: These portions can be read in a non-overlapping fashion and\n// allow straightforward parsing of the hierarchy that WebGL encodes\n// in the uniform names.\n\nfunction addUniform(container, uniformObject) {\n\tcontainer.seq.push(uniformObject);\n\tcontainer.map[uniformObject.id] = uniformObject;\n}\n\nfunction parseUniform(activeInfo, addr, container) {\n\tconst path = activeInfo.name,\n\t\t\t\tpathLength = path.length; // reset RegExp object, because of the early exit of a previous run\n\n\tRePathPart.lastIndex = 0;\n\n\twhile (true) {\n\t\tconst match = RePathPart.exec(path),\n\t\t\t\t\tmatchEnd = RePathPart.lastIndex;\n\t\tlet id = match[1];\n\t\tconst idIsIndex = match[2] === ']',\n\t\t\t\t\tsubscript = match[3];\n\t\tif (idIsIndex) id = id | 0; // convert to integer\n\n\t\tif (subscript === undefined || subscript === '[' && matchEnd + 2 === pathLength) {\n\t\t\t// bare name or \"pure\" bottom-level array \"[0]\" suffix\n\t\t\taddUniform(container, subscript === undefined ? new SingleUniform(id, activeInfo, addr) : new PureArrayUniform(id, activeInfo, addr));\n\t\t\tbreak;\n\t\t} else {\n\t\t\t// step into inner node / create it in case it doesn't exist\n\t\t\tconst map = container.map;\n\t\t\tlet next = map[id];\n\n\t\t\tif (next === undefined) {\n\t\t\t\tnext = new StructuredUniform(id);\n\t\t\t\taddUniform(container, next);\n\t\t\t}\n\n\t\t\tcontainer = next;\n\t\t}\n\t}\n} // Root Container\n\n\nclass WebGLUniforms {\n\tconstructor(gl, program) {\n\t\tthis.seq = [];\n\t\tthis.map = {};\n\t\tconst n = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);\n\n\t\tfor (let i = 0; i < n; ++i) {\n\t\t\tconst info = gl.getActiveUniform(program, i),\n\t\t\t\t\t\taddr = gl.getUniformLocation(program, info.name);\n\t\t\tparseUniform(info, addr, this);\n\t\t}\n\t}\n\n\tsetValue(gl, name, value, textures) {\n\t\tconst u = this.map[name];\n\t\tif (u !== undefined) u.setValue(gl, value, textures);\n\t}\n\n\tsetOptional(gl, object, name) {\n\t\tconst v = object[name];\n\t\tif (v !== undefined) this.setValue(gl, name, v);\n\t}\n\n\tstatic upload(gl, seq, values, textures) {\n\t\tfor (let i = 0, n = seq.length; i !== n; ++i) {\n\t\t\tconst u = seq[i],\n\t\t\t\t\t\tv = values[u.id];\n\n\t\t\tif (v.needsUpdate !== false) {\n\t\t\t\t// note: always updating when .needsUpdate is undefined\n\t\t\t\tu.setValue(gl, v.value, textures);\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic seqWithValue(seq, values) {\n\t\tconst r = [];\n\n\t\tfor (let i = 0, n = seq.length; i !== n; ++i) {\n\t\t\tconst u = seq[i];\n\t\t\tif (u.id in values) r.push(u);\n\t\t}\n\n\t\treturn r;\n\t}\n\n}\n\nfunction WebGLShader(gl, type, string) {\n\tconst shader = gl.createShader(type);\n\tgl.shaderSource(shader, string);\n\tgl.compileShader(shader);\n\treturn shader;\n}\n\nlet programIdCount = 0;\n\nfunction handleSource(string, errorLine) {\n\tconst lines = string.split('\\n');\n\tconst lines2 = [];\n\tconst from = Math.max(errorLine - 6, 0);\n\tconst to = Math.min(errorLine + 6, lines.length);\n\n\tfor (let i = from; i < to; i++) {\n\t\tconst line = i + 1;\n\t\tlines2.push(`${line === errorLine ? '>' : ' '} ${line}: ${lines[i]}`);\n\t}\n\n\treturn lines2.join('\\n');\n}\n\nfunction getEncodingComponents(encoding) {\n\tswitch (encoding) {\n\t\tcase LinearEncoding:\n\t\t\treturn ['Linear', '( value )'];\n\n\t\tcase sRGBEncoding:\n\t\t\treturn ['sRGB', '( value )'];\n\n\t\tdefault:\n\t\t\tconsole.warn('THREE.WebGLProgram: Unsupported encoding:', encoding);\n\t\t\treturn ['Linear', '( value )'];\n\t}\n}\n\nfunction getShaderErrors(gl, shader, type) {\n\tconst status = gl.getShaderParameter(shader, gl.COMPILE_STATUS);\n\tconst errors = gl.getShaderInfoLog(shader).trim();\n\tif (status && errors === '') return '';\n\tconst errorMatches = /ERROR: 0:(\\d+)/.exec(errors);\n\n\tif (errorMatches) {\n\t\t// --enable-privileged-webgl-extension\n\t\t// console.log( '**' + type + '**', gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) );\n\t\tconst errorLine = parseInt(errorMatches[1]);\n\t\treturn type.toUpperCase() + '\\n\\n' + errors + '\\n\\n' + handleSource(gl.getShaderSource(shader), errorLine);\n\t} else {\n\t\treturn errors;\n\t}\n}\n\nfunction getTexelEncodingFunction(functionName, encoding) {\n\tconst components = getEncodingComponents(encoding);\n\treturn 'vec4 ' + functionName + '( vec4 value ) { return LinearTo' + components[0] + components[1] + '; }';\n}\n\nfunction getToneMappingFunction(functionName, toneMapping) {\n\tlet toneMappingName;\n\n\tswitch (toneMapping) {\n\t\tcase LinearToneMapping:\n\t\t\ttoneMappingName = 'Linear';\n\t\t\tbreak;\n\n\t\tcase ReinhardToneMapping:\n\t\t\ttoneMappingName = 'Reinhard';\n\t\t\tbreak;\n\n\t\tcase CineonToneMapping:\n\t\t\ttoneMappingName = 'OptimizedCineon';\n\t\t\tbreak;\n\n\t\tcase ACESFilmicToneMapping:\n\t\t\ttoneMappingName = 'ACESFilmic';\n\t\t\tbreak;\n\n\t\tcase CustomToneMapping:\n\t\t\ttoneMappingName = 'Custom';\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tconsole.warn('THREE.WebGLProgram: Unsupported toneMapping:', toneMapping);\n\t\t\ttoneMappingName = 'Linear';\n\t}\n\n\treturn 'vec3 ' + functionName + '( vec3 color ) { return ' + toneMappingName + 'ToneMapping( color ); }';\n}\n\nfunction generateExtensions(parameters) {\n\tconst chunks = [parameters.extensionDerivatives || !!parameters.envMapCubeUVHeight || parameters.bumpMap || parameters.tangentSpaceNormalMap || parameters.clearcoatNormalMap || parameters.flatShading || parameters.shaderID === 'physical' ? '#extension GL_OES_standard_derivatives : enable' : '', (parameters.extensionFragDepth || parameters.logarithmicDepthBuffer) && parameters.rendererExtensionFragDepth ? '#extension GL_EXT_frag_depth : enable' : '', parameters.extensionDrawBuffers && parameters.rendererExtensionDrawBuffers ? '#extension GL_EXT_draw_buffers : require' : '', (parameters.extensionShaderTextureLOD || parameters.envMap || parameters.transmission) && parameters.rendererExtensionShaderTextureLod ? '#extension GL_EXT_shader_texture_lod : enable' : ''];\n\treturn chunks.filter(filterEmptyLine).join('\\n');\n}\n\nfunction generateDefines(defines) {\n\tconst chunks = [];\n\n\tfor (const name in defines) {\n\t\tconst value = defines[name];\n\t\tif (value === false) continue;\n\t\tchunks.push('#define ' + name + ' ' + value);\n\t}\n\n\treturn chunks.join('\\n');\n}\n\nfunction fetchAttributeLocations(gl, program) {\n\tconst attributes = {};\n\tconst n = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);\n\n\tfor (let i = 0; i < n; i++) {\n\t\tconst info = gl.getActiveAttrib(program, i);\n\t\tconst name = info.name;\n\t\tlet locationSize = 1;\n\t\tif (info.type === gl.FLOAT_MAT2) locationSize = 2;\n\t\tif (info.type === gl.FLOAT_MAT3) locationSize = 3;\n\t\tif (info.type === gl.FLOAT_MAT4) locationSize = 4; // console.log( 'THREE.WebGLProgram: ACTIVE VERTEX ATTRIBUTE:', name, i );\n\n\t\tattributes[name] = {\n\t\t\ttype: info.type,\n\t\t\tlocation: gl.getAttribLocation(program, name),\n\t\t\tlocationSize: locationSize\n\t\t};\n\t}\n\n\treturn attributes;\n}\n\nfunction filterEmptyLine(string) {\n\treturn string !== '';\n}\n\nfunction replaceLightNums(string, parameters) {\n\tconst numSpotLightCoords = parameters.numSpotLightShadows + parameters.numSpotLightMaps - parameters.numSpotLightShadowsWithMaps;\n\treturn string.replace(/NUM_DIR_LIGHTS/g, parameters.numDirLights).replace(/NUM_SPOT_LIGHTS/g, parameters.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g, parameters.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g, numSpotLightCoords).replace(/NUM_RECT_AREA_LIGHTS/g, parameters.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g, parameters.numPointLights).replace(/NUM_HEMI_LIGHTS/g, parameters.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g, parameters.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g, parameters.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g, parameters.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g, parameters.numPointLightShadows);\n}\n\nfunction replaceClippingPlaneNums(string, parameters) {\n\treturn string.replace(/NUM_CLIPPING_PLANES/g, parameters.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, parameters.numClippingPlanes - parameters.numClipIntersection);\n} // Resolve Includes\n\n\nconst includePattern = /^[ \\t]*#include +<([\\w\\d./]+)>/gm;\n\nfunction resolveIncludes(string) {\n\treturn string.replace(includePattern, includeReplacer);\n}\n\nfunction includeReplacer(match, include) {\n\tconst string = ShaderChunk[include];\n\n\tif (string === undefined) {\n\t\tthrow new Error('Can not resolve #include <' + include + '>');\n\t}\n\n\treturn resolveIncludes(string);\n} // Unroll Loops\n\n\nconst unrollLoopPattern = /#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;\n\nfunction unrollLoops(string) {\n\treturn string.replace(unrollLoopPattern, loopReplacer);\n}\n\nfunction loopReplacer(match, start, end, snippet) {\n\tlet string = '';\n\n\tfor (let i = parseInt(start); i < parseInt(end); i++) {\n\t\tstring += snippet.replace(/\\[\\s*i\\s*\\]/g, '[ ' + i + ' ]').replace(/UNROLLED_LOOP_INDEX/g, i);\n\t}\n\n\treturn string;\n} //\n\n\nfunction generatePrecision(parameters) {\n\tlet precisionstring = 'precision ' + parameters.precision + ' float;\\nprecision ' + parameters.precision + ' int;';\n\n\tif (parameters.precision === 'highp') {\n\t\tprecisionstring += '\\n#define HIGH_PRECISION';\n\t} else if (parameters.precision === 'mediump') {\n\t\tprecisionstring += '\\n#define MEDIUM_PRECISION';\n\t} else if (parameters.precision === 'lowp') {\n\t\tprecisionstring += '\\n#define LOW_PRECISION';\n\t}\n\n\treturn precisionstring;\n}\n\nfunction generateShadowMapTypeDefine(parameters) {\n\tlet shadowMapTypeDefine = 'SHADOWMAP_TYPE_BASIC';\n\n\tif (parameters.shadowMapType === PCFShadowMap) {\n\t\tshadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF';\n\t} else if (parameters.shadowMapType === PCFSoftShadowMap) {\n\t\tshadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF_SOFT';\n\t} else if (parameters.shadowMapType === VSMShadowMap) {\n\t\tshadowMapTypeDefine = 'SHADOWMAP_TYPE_VSM';\n\t}\n\n\treturn shadowMapTypeDefine;\n}\n\nfunction generateEnvMapTypeDefine(parameters) {\n\tlet envMapTypeDefine = 'ENVMAP_TYPE_CUBE';\n\n\tif (parameters.envMap) {\n\t\tswitch (parameters.envMapMode) {\n\t\t\tcase CubeReflectionMapping:\n\t\t\tcase CubeRefractionMapping:\n\t\t\t\tenvMapTypeDefine = 'ENVMAP_TYPE_CUBE';\n\t\t\t\tbreak;\n\n\t\t\tcase CubeUVReflectionMapping:\n\t\t\t\tenvMapTypeDefine = 'ENVMAP_TYPE_CUBE_UV';\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn envMapTypeDefine;\n}\n\nfunction generateEnvMapModeDefine(parameters) {\n\tlet envMapModeDefine = 'ENVMAP_MODE_REFLECTION';\n\n\tif (parameters.envMap) {\n\t\tswitch (parameters.envMapMode) {\n\t\t\tcase CubeRefractionMapping:\n\t\t\t\tenvMapModeDefine = 'ENVMAP_MODE_REFRACTION';\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn envMapModeDefine;\n}\n\nfunction generateEnvMapBlendingDefine(parameters) {\n\tlet envMapBlendingDefine = 'ENVMAP_BLENDING_NONE';\n\n\tif (parameters.envMap) {\n\t\tswitch (parameters.combine) {\n\t\t\tcase MultiplyOperation:\n\t\t\t\tenvMapBlendingDefine = 'ENVMAP_BLENDING_MULTIPLY';\n\t\t\t\tbreak;\n\n\t\t\tcase MixOperation:\n\t\t\t\tenvMapBlendingDefine = 'ENVMAP_BLENDING_MIX';\n\t\t\t\tbreak;\n\n\t\t\tcase AddOperation:\n\t\t\t\tenvMapBlendingDefine = 'ENVMAP_BLENDING_ADD';\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn envMapBlendingDefine;\n}\n\nfunction generateCubeUVSize(parameters) {\n\tconst imageHeight = parameters.envMapCubeUVHeight;\n\tif (imageHeight === null) return null;\n\tconst maxMip = Math.log2(imageHeight) - 2;\n\tconst texelHeight = 1.0 / imageHeight;\n\tconst texelWidth = 1.0 / (3 * Math.max(Math.pow(2, maxMip), 7 * 16));\n\treturn {\n\t\ttexelWidth,\n\t\ttexelHeight,\n\t\tmaxMip\n\t};\n}\n\nfunction WebGLProgram(renderer, cacheKey, parameters, bindingStates) {\n\t// TODO Send this event to Three.js DevTools\n\t// console.log( 'WebGLProgram', cacheKey );\n\tconst gl = renderer.getContext();\n\tconst defines = parameters.defines;\n\tlet vertexShader = parameters.vertexShader;\n\tlet fragmentShader = parameters.fragmentShader;\n\tconst shadowMapTypeDefine = generateShadowMapTypeDefine(parameters);\n\tconst envMapTypeDefine = generateEnvMapTypeDefine(parameters);\n\tconst envMapModeDefine = generateEnvMapModeDefine(parameters);\n\tconst envMapBlendingDefine = generateEnvMapBlendingDefine(parameters);\n\tconst envMapCubeUVSize = generateCubeUVSize(parameters);\n\tconst customExtensions = parameters.isWebGL2 ? '' : generateExtensions(parameters);\n\tconst customDefines = generateDefines(defines);\n\tconst program = gl.createProgram();\n\tlet prefixVertex, prefixFragment;\n\tlet versionString = parameters.glslVersion ? '#version ' + parameters.glslVersion + '\\n' : '';\n\n\tif (parameters.isRawShaderMaterial) {\n\t\tprefixVertex = [customDefines].filter(filterEmptyLine).join('\\n');\n\n\t\tif (prefixVertex.length > 0) {\n\t\t\tprefixVertex += '\\n';\n\t\t}\n\n\t\tprefixFragment = [customExtensions, customDefines].filter(filterEmptyLine).join('\\n');\n\n\t\tif (prefixFragment.length > 0) {\n\t\t\tprefixFragment += '\\n';\n\t\t}\n\t} else {\n\t\tprefixVertex = [generatePrecision(parameters), '#define SHADER_NAME ' + parameters.shaderName, customDefines, parameters.instancing ? '#define USE_INSTANCING' : '', parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '', parameters.supportsVertexTextures ? '#define VERTEX_TEXTURES' : '', parameters.useFog && parameters.fog ? '#define USE_FOG' : '', parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.envMap ? '#define USE_ENVMAP' : '', parameters.envMap ? '#define ' + envMapModeDefine : '', parameters.lightMap ? '#define USE_LIGHTMAP' : '', parameters.aoMap ? '#define USE_AOMAP' : '', parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', parameters.bumpMap ? '#define USE_BUMPMAP' : '', parameters.normalMap ? '#define USE_NORMALMAP' : '', parameters.normalMap && parameters.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '', parameters.normalMap && parameters.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '', parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', parameters.iridescenceMap ? '#define USE_IRIDESCENCEMAP' : '', parameters.iridescenceThicknessMap ? '#define USE_IRIDESCENCE_THICKNESSMAP' : '', parameters.displacementMap && parameters.supportsVertexTextures ? '#define USE_DISPLACEMENTMAP' : '', parameters.specularMap ? '#define USE_SPECULARMAP' : '', parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', parameters.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '', parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', parameters.alphaMap ? '#define USE_ALPHAMAP' : '', parameters.transmission ? '#define USE_TRANSMISSION' : '', parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '', parameters.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '', parameters.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '', parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors ? '#define USE_COLOR' : '', parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', parameters.vertexUvs ? '#define USE_UV' : '', parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', parameters.flatShading ? '#define FLAT_SHADED' : '', parameters.skinning ? '#define USE_SKINNING' : '', parameters.morphTargets ? '#define USE_MORPHTARGETS' : '', parameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '', parameters.morphColors && parameters.isWebGL2 ? '#define USE_MORPHCOLORS' : '', parameters.morphTargetsCount > 0 && parameters.isWebGL2 ? '#define MORPHTARGETS_TEXTURE' : '', parameters.morphTargetsCount > 0 && parameters.isWebGL2 ? '#define MORPHTARGETS_TEXTURE_STRIDE ' + parameters.morphTextureStride : '', parameters.morphTargetsCount > 0 && parameters.isWebGL2 ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '', parameters.doubleSided ? '#define DOUBLE_SIDED' : '', parameters.flipSided ? '#define FLIP_SIDED' : '', parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', parameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '', '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', 'attribute vec3 position;', 'attribute vec3 normal;', 'attribute vec2 uv;', '#ifdef USE_TANGENT', '\tattribute vec4 tangent;', '#endif', '#if defined( USE_COLOR_ALPHA )', '\tattribute vec4 color;', '#elif defined( USE_COLOR )', '\tattribute vec3 color;', '#endif', '#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )', '\tattribute vec3 morphTarget0;', '\tattribute vec3 morphTarget1;', '\tattribute vec3 morphTarget2;', '\tattribute vec3 morphTarget3;', '\t#ifdef USE_MORPHNORMALS', '\t\tattribute vec3 morphNormal0;', '\t\tattribute vec3 morphNormal1;', '\t\tattribute vec3 morphNormal2;', '\t\tattribute vec3 morphNormal3;', '\t#else', '\t\tattribute vec3 morphTarget4;', '\t\tattribute vec3 morphTarget5;', '\t\tattribute vec3 morphTarget6;', '\t\tattribute vec3 morphTarget7;', '\t#endif', '#endif', '#ifdef USE_SKINNING', '\tattribute vec4 skinIndex;', '\tattribute vec4 skinWeight;', '#endif', '\\n'].filter(filterEmptyLine).join('\\n');\n\t\tprefixFragment = [customExtensions, generatePrecision(parameters), '#define SHADER_NAME ' + parameters.shaderName, customDefines, parameters.useFog && parameters.fog ? '#define USE_FOG' : '', parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.matcap ? '#define USE_MATCAP' : '', parameters.envMap ? '#define USE_ENVMAP' : '', parameters.envMap ? '#define ' + envMapTypeDefine : '', parameters.envMap ? '#define ' + envMapModeDefine : '', parameters.envMap ? '#define ' + envMapBlendingDefine : '', envMapCubeUVSize ? '#define CUBEUV_TEXEL_WIDTH ' + envMapCubeUVSize.texelWidth : '', envMapCubeUVSize ? '#define CUBEUV_TEXEL_HEIGHT ' + envMapCubeUVSize.texelHeight : '', envMapCubeUVSize ? '#define CUBEUV_MAX_MIP ' + envMapCubeUVSize.maxMip + '.0' : '', parameters.lightMap ? '#define USE_LIGHTMAP' : '', parameters.aoMap ? '#define USE_AOMAP' : '', parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', parameters.bumpMap ? '#define USE_BUMPMAP' : '', parameters.normalMap ? '#define USE_NORMALMAP' : '', parameters.normalMap && parameters.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '', parameters.normalMap && parameters.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '', parameters.clearcoat ? '#define USE_CLEARCOAT' : '', parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', parameters.iridescence ? '#define USE_IRIDESCENCE' : '', parameters.iridescenceMap ? '#define USE_IRIDESCENCEMAP' : '', parameters.iridescenceThicknessMap ? '#define USE_IRIDESCENCE_THICKNESSMAP' : '', parameters.specularMap ? '#define USE_SPECULARMAP' : '', parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', parameters.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '', parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', parameters.alphaMap ? '#define USE_ALPHAMAP' : '', parameters.alphaTest ? '#define USE_ALPHATEST' : '', parameters.sheen ? '#define USE_SHEEN' : '', parameters.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '', parameters.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '', parameters.transmission ? '#define USE_TRANSMISSION' : '', parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '', parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '', parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors || parameters.instancingColor ? '#define USE_COLOR' : '', parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', parameters.vertexUvs ? '#define USE_UV' : '', parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', parameters.gradientMap ? '#define USE_GRADIENTMAP' : '', parameters.flatShading ? '#define FLAT_SHADED' : '', parameters.doubleSided ? '#define DOUBLE_SIDED' : '', parameters.flipSided ? '#define FLIP_SIDED' : '', parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', parameters.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '', parameters.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '', 'uniform mat4 viewMatrix;', 'uniform vec3 cameraPosition;', 'uniform bool isOrthographic;', parameters.toneMapping !== NoToneMapping ? '#define TONE_MAPPING' : '', parameters.toneMapping !== NoToneMapping ? ShaderChunk['tonemapping_pars_fragment'] : '', // this code is required here because it is used by the toneMapping() function defined below\n\t\tparameters.toneMapping !== NoToneMapping ? getToneMappingFunction('toneMapping', parameters.toneMapping) : '', parameters.dithering ? '#define DITHERING' : '', parameters.opaque ? '#define OPAQUE' : '', ShaderChunk['encodings_pars_fragment'], // this code is required here because it is used by the various encoding/decoding function defined below\n\t\tgetTexelEncodingFunction('linearToOutputTexel', parameters.outputEncoding), parameters.useDepthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '', '\\n'].filter(filterEmptyLine).join('\\n');\n\t}\n\n\tvertexShader = resolveIncludes(vertexShader);\n\tvertexShader = replaceLightNums(vertexShader, parameters);\n\tvertexShader = replaceClippingPlaneNums(vertexShader, parameters);\n\tfragmentShader = resolveIncludes(fragmentShader);\n\tfragmentShader = replaceLightNums(fragmentShader, parameters);\n\tfragmentShader = replaceClippingPlaneNums(fragmentShader, parameters);\n\tvertexShader = unrollLoops(vertexShader);\n\tfragmentShader = unrollLoops(fragmentShader);\n\n\tif (parameters.isWebGL2 && parameters.isRawShaderMaterial !== true) {\n\t\t// GLSL 3.0 conversion for built-in materials and ShaderMaterial\n\t\tversionString = '#version 300 es\\n';\n\t\tprefixVertex = ['precision mediump sampler2DArray;', '#define attribute in', '#define varying out', '#define texture2D texture'].join('\\n') + '\\n' + prefixVertex;\n\t\tprefixFragment = ['#define varying in', parameters.glslVersion === GLSL3 ? '' : 'layout(location = 0) out highp vec4 pc_fragColor;', parameters.glslVersion === GLSL3 ? '' : '#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' + prefixFragment;\n\t}\n\n\tconst vertexGlsl = versionString + prefixVertex + vertexShader;\n\tconst fragmentGlsl = versionString + prefixFragment + fragmentShader; // console.log( '*VERTEX*', vertexGlsl );\n\t// console.log( '*FRAGMENT*', fragmentGlsl );\n\n\tconst glVertexShader = WebGLShader(gl, gl.VERTEX_SHADER, vertexGlsl);\n\tconst glFragmentShader = WebGLShader(gl, gl.FRAGMENT_SHADER, fragmentGlsl);\n\tgl.attachShader(program, glVertexShader);\n\tgl.attachShader(program, glFragmentShader); // Force a particular attribute to index 0.\n\n\tif (parameters.index0AttributeName !== undefined) {\n\t\tgl.bindAttribLocation(program, 0, parameters.index0AttributeName);\n\t} else if (parameters.morphTargets === true) {\n\t\t// programs with morphTargets displace position out of attribute 0\n\t\tgl.bindAttribLocation(program, 0, 'position');\n\t}\n\n\tgl.linkProgram(program); // check for link errors\n\n\tif (renderer.debug.checkShaderErrors) {\n\t\tconst programLog = gl.getProgramInfoLog(program).trim();\n\t\tconst vertexLog = gl.getShaderInfoLog(glVertexShader).trim();\n\t\tconst fragmentLog = gl.getShaderInfoLog(glFragmentShader).trim();\n\t\tlet runnable = true;\n\t\tlet haveDiagnostics = true;\n\n\t\tif (gl.getProgramParameter(program, gl.LINK_STATUS) === false) {\n\t\t\trunnable = false;\n\t\t\tconst vertexErrors = getShaderErrors(gl, glVertexShader, 'vertex');\n\t\t\tconst fragmentErrors = getShaderErrors(gl, glFragmentShader, 'fragment');\n\t\t\tconsole.error('THREE.WebGLProgram: Shader Error ' + gl.getError() + ' - ' + 'VALIDATE_STATUS ' + gl.getProgramParameter(program, gl.VALIDATE_STATUS) + '\\n\\n' + 'Program Info Log: ' + programLog + '\\n' + vertexErrors + '\\n' + fragmentErrors);\n\t\t} else if (programLog !== '') {\n\t\t\tconsole.warn('THREE.WebGLProgram: Program Info Log:', programLog);\n\t\t} else if (vertexLog === '' || fragmentLog === '') {\n\t\t\thaveDiagnostics = false;\n\t\t}\n\n\t\tif (haveDiagnostics) {\n\t\t\tthis.diagnostics = {\n\t\t\t\trunnable: runnable,\n\t\t\t\tprogramLog: programLog,\n\t\t\t\tvertexShader: {\n\t\t\t\t\tlog: vertexLog,\n\t\t\t\t\tprefix: prefixVertex\n\t\t\t\t},\n\t\t\t\tfragmentShader: {\n\t\t\t\t\tlog: fragmentLog,\n\t\t\t\t\tprefix: prefixFragment\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t} // Clean up\n\t// Crashes in iOS9 and iOS10. #18402\n\t// gl.detachShader( program, glVertexShader );\n\t// gl.detachShader( program, glFragmentShader );\n\n\n\tgl.deleteShader(glVertexShader);\n\tgl.deleteShader(glFragmentShader); // set up caching for uniform locations\n\n\tlet cachedUniforms;\n\n\tthis.getUniforms = function () {\n\t\tif (cachedUniforms === undefined) {\n\t\t\tcachedUniforms = new WebGLUniforms(gl, program);\n\t\t}\n\n\t\treturn cachedUniforms;\n\t}; // set up caching for attribute locations\n\n\n\tlet cachedAttributes;\n\n\tthis.getAttributes = function () {\n\t\tif (cachedAttributes === undefined) {\n\t\t\tcachedAttributes = fetchAttributeLocations(gl, program);\n\t\t}\n\n\t\treturn cachedAttributes;\n\t}; // free resource\n\n\n\tthis.destroy = function () {\n\t\tbindingStates.releaseStatesOfProgram(this);\n\t\tgl.deleteProgram(program);\n\t\tthis.program = undefined;\n\t}; //\n\n\n\tthis.name = parameters.shaderName;\n\tthis.id = programIdCount++;\n\tthis.cacheKey = cacheKey;\n\tthis.usedTimes = 1;\n\tthis.program = program;\n\tthis.vertexShader = glVertexShader;\n\tthis.fragmentShader = glFragmentShader;\n\treturn this;\n}\n\nlet _id = 0;\n\nclass WebGLShaderCache {\n\tconstructor() {\n\t\tthis.shaderCache = new Map();\n\t\tthis.materialCache = new Map();\n\t}\n\n\tupdate(material) {\n\t\tconst vertexShader = material.vertexShader;\n\t\tconst fragmentShader = material.fragmentShader;\n\n\t\tconst vertexShaderStage = this._getShaderStage(vertexShader);\n\n\t\tconst fragmentShaderStage = this._getShaderStage(fragmentShader);\n\n\t\tconst materialShaders = this._getShaderCacheForMaterial(material);\n\n\t\tif (materialShaders.has(vertexShaderStage) === false) {\n\t\t\tmaterialShaders.add(vertexShaderStage);\n\t\t\tvertexShaderStage.usedTimes++;\n\t\t}\n\n\t\tif (materialShaders.has(fragmentShaderStage) === false) {\n\t\t\tmaterialShaders.add(fragmentShaderStage);\n\t\t\tfragmentShaderStage.usedTimes++;\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tremove(material) {\n\t\tconst materialShaders = this.materialCache.get(material);\n\n\t\tfor (const shaderStage of materialShaders) {\n\t\t\tshaderStage.usedTimes--;\n\t\t\tif (shaderStage.usedTimes === 0) this.shaderCache.delete(shaderStage.code);\n\t\t}\n\n\t\tthis.materialCache.delete(material);\n\t\treturn this;\n\t}\n\n\tgetVertexShaderID(material) {\n\t\treturn this._getShaderStage(material.vertexShader).id;\n\t}\n\n\tgetFragmentShaderID(material) {\n\t\treturn this._getShaderStage(material.fragmentShader).id;\n\t}\n\n\tdispose() {\n\t\tthis.shaderCache.clear();\n\t\tthis.materialCache.clear();\n\t}\n\n\t_getShaderCacheForMaterial(material) {\n\t\tconst cache = this.materialCache;\n\t\tlet set = cache.get(material);\n\n\t\tif (set === undefined) {\n\t\t\tset = new Set();\n\t\t\tcache.set(material, set);\n\t\t}\n\n\t\treturn set;\n\t}\n\n\t_getShaderStage(code) {\n\t\tconst cache = this.shaderCache;\n\t\tlet stage = cache.get(code);\n\n\t\tif (stage === undefined) {\n\t\t\tstage = new WebGLShaderStage(code);\n\t\t\tcache.set(code, stage);\n\t\t}\n\n\t\treturn stage;\n\t}\n\n}\n\nclass WebGLShaderStage {\n\tconstructor(code) {\n\t\tthis.id = _id++;\n\t\tthis.code = code;\n\t\tthis.usedTimes = 0;\n\t}\n\n}\n\nfunction WebGLPrograms(renderer, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping) {\n\tconst _programLayers = new Layers();\n\n\tconst _customShaders = new WebGLShaderCache();\n\n\tconst programs = [];\n\tconst isWebGL2 = capabilities.isWebGL2;\n\tconst logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;\n\tconst vertexTextures = capabilities.vertexTextures;\n\tlet precision = capabilities.precision;\n\tconst shaderIDs = {\n\t\tMeshDepthMaterial: 'depth',\n\t\tMeshDistanceMaterial: 'distanceRGBA',\n\t\tMeshNormalMaterial: 'normal',\n\t\tMeshBasicMaterial: 'basic',\n\t\tMeshLambertMaterial: 'lambert',\n\t\tMeshPhongMaterial: 'phong',\n\t\tMeshToonMaterial: 'toon',\n\t\tMeshStandardMaterial: 'physical',\n\t\tMeshPhysicalMaterial: 'physical',\n\t\tMeshMatcapMaterial: 'matcap',\n\t\tLineBasicMaterial: 'basic',\n\t\tLineDashedMaterial: 'dashed',\n\t\tPointsMaterial: 'points',\n\t\tShadowMaterial: 'shadow',\n\t\tSpriteMaterial: 'sprite'\n\t};\n\n\tfunction getParameters(material, lights, shadows, scene, object) {\n\t\tconst fog = scene.fog;\n\t\tconst geometry = object.geometry;\n\t\tconst environment = material.isMeshStandardMaterial ? scene.environment : null;\n\t\tconst envMap = (material.isMeshStandardMaterial ? cubeuvmaps : cubemaps).get(material.envMap || environment);\n\t\tconst envMapCubeUVHeight = !!envMap && envMap.mapping === CubeUVReflectionMapping ? envMap.image.height : null;\n\t\tconst shaderID = shaderIDs[material.type]; // heuristics to create shader parameters according to lights in the scene\n\t\t// (not to blow over maxLights budget)\n\n\t\tif (material.precision !== null) {\n\t\t\tprecision = capabilities.getMaxPrecision(material.precision);\n\n\t\t\tif (precision !== material.precision) {\n\t\t\t\tconsole.warn('THREE.WebGLProgram.getParameters:', material.precision, 'not supported, using', precision, 'instead.');\n\t\t\t}\n\t\t} //\n\n\n\t\tconst morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;\n\t\tconst morphTargetsCount = morphAttribute !== undefined ? morphAttribute.length : 0;\n\t\tlet morphTextureStride = 0;\n\t\tif (geometry.morphAttributes.position !== undefined) morphTextureStride = 1;\n\t\tif (geometry.morphAttributes.normal !== undefined) morphTextureStride = 2;\n\t\tif (geometry.morphAttributes.color !== undefined) morphTextureStride = 3; //\n\n\t\tlet vertexShader, fragmentShader;\n\t\tlet customVertexShaderID, customFragmentShaderID;\n\n\t\tif (shaderID) {\n\t\t\tconst shader = ShaderLib[shaderID];\n\t\t\tvertexShader = shader.vertexShader;\n\t\t\tfragmentShader = shader.fragmentShader;\n\t\t} else {\n\t\t\tvertexShader = material.vertexShader;\n\t\t\tfragmentShader = material.fragmentShader;\n\n\t\t\t_customShaders.update(material);\n\n\t\t\tcustomVertexShaderID = _customShaders.getVertexShaderID(material);\n\t\t\tcustomFragmentShaderID = _customShaders.getFragmentShaderID(material);\n\t\t}\n\n\t\tconst currentRenderTarget = renderer.getRenderTarget();\n\t\tconst useAlphaTest = material.alphaTest > 0;\n\t\tconst useClearcoat = material.clearcoat > 0;\n\t\tconst useIridescence = material.iridescence > 0;\n\t\tconst parameters = {\n\t\t\tisWebGL2: isWebGL2,\n\t\t\tshaderID: shaderID,\n\t\t\tshaderName: material.type,\n\t\t\tvertexShader: vertexShader,\n\t\t\tfragmentShader: fragmentShader,\n\t\t\tdefines: material.defines,\n\t\t\tcustomVertexShaderID: customVertexShaderID,\n\t\t\tcustomFragmentShaderID: customFragmentShaderID,\n\t\t\tisRawShaderMaterial: material.isRawShaderMaterial === true,\n\t\t\tglslVersion: material.glslVersion,\n\t\t\tprecision: precision,\n\t\t\tinstancing: object.isInstancedMesh === true,\n\t\t\tinstancingColor: object.isInstancedMesh === true && object.instanceColor !== null,\n\t\t\tsupportsVertexTextures: vertexTextures,\n\t\t\toutputEncoding: currentRenderTarget === null ? renderer.outputEncoding : currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.encoding : LinearEncoding,\n\t\t\tmap: !!material.map,\n\t\t\tmatcap: !!material.matcap,\n\t\t\tenvMap: !!envMap,\n\t\t\tenvMapMode: envMap && envMap.mapping,\n\t\t\tenvMapCubeUVHeight: envMapCubeUVHeight,\n\t\t\tlightMap: !!material.lightMap,\n\t\t\taoMap: !!material.aoMap,\n\t\t\temissiveMap: !!material.emissiveMap,\n\t\t\tbumpMap: !!material.bumpMap,\n\t\t\tnormalMap: !!material.normalMap,\n\t\t\tobjectSpaceNormalMap: material.normalMapType === ObjectSpaceNormalMap,\n\t\t\ttangentSpaceNormalMap: material.normalMapType === TangentSpaceNormalMap,\n\t\t\tdecodeVideoTexture: !!material.map && material.map.isVideoTexture === true && material.map.encoding === sRGBEncoding,\n\t\t\tclearcoat: useClearcoat,\n\t\t\tclearcoatMap: useClearcoat && !!material.clearcoatMap,\n\t\t\tclearcoatRoughnessMap: useClearcoat && !!material.clearcoatRoughnessMap,\n\t\t\tclearcoatNormalMap: useClearcoat && !!material.clearcoatNormalMap,\n\t\t\tiridescence: useIridescence,\n\t\t\tiridescenceMap: useIridescence && !!material.iridescenceMap,\n\t\t\tiridescenceThicknessMap: useIridescence && !!material.iridescenceThicknessMap,\n\t\t\tdisplacementMap: !!material.displacementMap,\n\t\t\troughnessMap: !!material.roughnessMap,\n\t\t\tmetalnessMap: !!material.metalnessMap,\n\t\t\tspecularMap: !!material.specularMap,\n\t\t\tspecularIntensityMap: !!material.specularIntensityMap,\n\t\t\tspecularColorMap: !!material.specularColorMap,\n\t\t\topaque: material.transparent === false && material.blending === NormalBlending,\n\t\t\talphaMap: !!material.alphaMap,\n\t\t\talphaTest: useAlphaTest,\n\t\t\tgradientMap: !!material.gradientMap,\n\t\t\tsheen: material.sheen > 0,\n\t\t\tsheenColorMap: !!material.sheenColorMap,\n\t\t\tsheenRoughnessMap: !!material.sheenRoughnessMap,\n\t\t\ttransmission: material.transmission > 0,\n\t\t\ttransmissionMap: !!material.transmissionMap,\n\t\t\tthicknessMap: !!material.thicknessMap,\n\t\t\tcombine: material.combine,\n\t\t\tvertexTangents: !!material.normalMap && !!geometry.attributes.tangent,\n\t\t\tvertexColors: material.vertexColors,\n\t\t\tvertexAlphas: material.vertexColors === true && !!geometry.attributes.color && geometry.attributes.color.itemSize === 4,\n\t\t\tvertexUvs: !!material.map || !!material.bumpMap || !!material.normalMap || !!material.specularMap || !!material.alphaMap || !!material.emissiveMap || !!material.roughnessMap || !!material.metalnessMap || !!material.clearcoatMap || !!material.clearcoatRoughnessMap || !!material.clearcoatNormalMap || !!material.iridescenceMap || !!material.iridescenceThicknessMap || !!material.displacementMap || !!material.transmissionMap || !!material.thicknessMap || !!material.specularIntensityMap || !!material.specularColorMap || !!material.sheenColorMap || !!material.sheenRoughnessMap,\n\t\t\tuvsVertexOnly: !(!!material.map || !!material.bumpMap || !!material.normalMap || !!material.specularMap || !!material.alphaMap || !!material.emissiveMap || !!material.roughnessMap || !!material.metalnessMap || !!material.clearcoatNormalMap || !!material.iridescenceMap || !!material.iridescenceThicknessMap || material.transmission > 0 || !!material.transmissionMap || !!material.thicknessMap || !!material.specularIntensityMap || !!material.specularColorMap || material.sheen > 0 || !!material.sheenColorMap || !!material.sheenRoughnessMap) && !!material.displacementMap,\n\t\t\tfog: !!fog,\n\t\t\tuseFog: material.fog === true,\n\t\t\tfogExp2: fog && fog.isFogExp2,\n\t\t\tflatShading: !!material.flatShading,\n\t\t\tsizeAttenuation: material.sizeAttenuation,\n\t\t\tlogarithmicDepthBuffer: logarithmicDepthBuffer,\n\t\t\tskinning: object.isSkinnedMesh === true,\n\t\t\tmorphTargets: geometry.morphAttributes.position !== undefined,\n\t\t\tmorphNormals: geometry.morphAttributes.normal !== undefined,\n\t\t\tmorphColors: geometry.morphAttributes.color !== undefined,\n\t\t\tmorphTargetsCount: morphTargetsCount,\n\t\t\tmorphTextureStride: morphTextureStride,\n\t\t\tnumDirLights: lights.directional.length,\n\t\t\tnumPointLights: lights.point.length,\n\t\t\tnumSpotLights: lights.spot.length,\n\t\t\tnumSpotLightMaps: lights.spotLightMap.length,\n\t\t\tnumRectAreaLights: lights.rectArea.length,\n\t\t\tnumHemiLights: lights.hemi.length,\n\t\t\tnumDirLightShadows: lights.directionalShadowMap.length,\n\t\t\tnumPointLightShadows: lights.pointShadowMap.length,\n\t\t\tnumSpotLightShadows: lights.spotShadowMap.length,\n\t\t\tnumSpotLightShadowsWithMaps: lights.numSpotLightShadowsWithMaps,\n\t\t\tnumClippingPlanes: clipping.numPlanes,\n\t\t\tnumClipIntersection: clipping.numIntersection,\n\t\t\tdithering: material.dithering,\n\t\t\tshadowMapEnabled: renderer.shadowMap.enabled && shadows.length > 0,\n\t\t\tshadowMapType: renderer.shadowMap.type,\n\t\t\ttoneMapping: material.toneMapped ? renderer.toneMapping : NoToneMapping,\n\t\t\tphysicallyCorrectLights: renderer.physicallyCorrectLights,\n\t\t\tpremultipliedAlpha: material.premultipliedAlpha,\n\t\t\tdoubleSided: material.side === DoubleSide,\n\t\t\tflipSided: material.side === BackSide,\n\t\t\tuseDepthPacking: !!material.depthPacking,\n\t\t\tdepthPacking: material.depthPacking || 0,\n\t\t\tindex0AttributeName: material.index0AttributeName,\n\t\t\textensionDerivatives: material.extensions && material.extensions.derivatives,\n\t\t\textensionFragDepth: material.extensions && material.extensions.fragDepth,\n\t\t\textensionDrawBuffers: material.extensions && material.extensions.drawBuffers,\n\t\t\textensionShaderTextureLOD: material.extensions && material.extensions.shaderTextureLOD,\n\t\t\trendererExtensionFragDepth: isWebGL2 || extensions.has('EXT_frag_depth'),\n\t\t\trendererExtensionDrawBuffers: isWebGL2 || extensions.has('WEBGL_draw_buffers'),\n\t\t\trendererExtensionShaderTextureLod: isWebGL2 || extensions.has('EXT_shader_texture_lod'),\n\t\t\tcustomProgramCacheKey: material.customProgramCacheKey()\n\t\t};\n\t\treturn parameters;\n\t}\n\n\tfunction getProgramCacheKey(parameters) {\n\t\tconst array = [];\n\n\t\tif (parameters.shaderID) {\n\t\t\tarray.push(parameters.shaderID);\n\t\t} else {\n\t\t\tarray.push(parameters.customVertexShaderID);\n\t\t\tarray.push(parameters.customFragmentShaderID);\n\t\t}\n\n\t\tif (parameters.defines !== undefined) {\n\t\t\tfor (const name in parameters.defines) {\n\t\t\t\tarray.push(name);\n\t\t\t\tarray.push(parameters.defines[name]);\n\t\t\t}\n\t\t}\n\n\t\tif (parameters.isRawShaderMaterial === false) {\n\t\t\tgetProgramCacheKeyParameters(array, parameters);\n\t\t\tgetProgramCacheKeyBooleans(array, parameters);\n\t\t\tarray.push(renderer.outputEncoding);\n\t\t}\n\n\t\tarray.push(parameters.customProgramCacheKey);\n\t\treturn array.join();\n\t}\n\n\tfunction getProgramCacheKeyParameters(array, parameters) {\n\t\tarray.push(parameters.precision);\n\t\tarray.push(parameters.outputEncoding);\n\t\tarray.push(parameters.envMapMode);\n\t\tarray.push(parameters.envMapCubeUVHeight);\n\t\tarray.push(parameters.combine);\n\t\tarray.push(parameters.vertexUvs);\n\t\tarray.push(parameters.fogExp2);\n\t\tarray.push(parameters.sizeAttenuation);\n\t\tarray.push(parameters.morphTargetsCount);\n\t\tarray.push(parameters.morphAttributeCount);\n\t\tarray.push(parameters.numDirLights);\n\t\tarray.push(parameters.numPointLights);\n\t\tarray.push(parameters.numSpotLights);\n\t\tarray.push(parameters.numSpotLightMaps);\n\t\tarray.push(parameters.numHemiLights);\n\t\tarray.push(parameters.numRectAreaLights);\n\t\tarray.push(parameters.numDirLightShadows);\n\t\tarray.push(parameters.numPointLightShadows);\n\t\tarray.push(parameters.numSpotLightShadows);\n\t\tarray.push(parameters.numSpotLightShadowsWithMaps);\n\t\tarray.push(parameters.shadowMapType);\n\t\tarray.push(parameters.toneMapping);\n\t\tarray.push(parameters.numClippingPlanes);\n\t\tarray.push(parameters.numClipIntersection);\n\t\tarray.push(parameters.depthPacking);\n\t}\n\n\tfunction getProgramCacheKeyBooleans(array, parameters) {\n\t\t_programLayers.disableAll();\n\n\t\tif (parameters.isWebGL2) _programLayers.enable(0);\n\t\tif (parameters.supportsVertexTextures) _programLayers.enable(1);\n\t\tif (parameters.instancing) _programLayers.enable(2);\n\t\tif (parameters.instancingColor) _programLayers.enable(3);\n\t\tif (parameters.map) _programLayers.enable(4);\n\t\tif (parameters.matcap) _programLayers.enable(5);\n\t\tif (parameters.envMap) _programLayers.enable(6);\n\t\tif (parameters.lightMap) _programLayers.enable(7);\n\t\tif (parameters.aoMap) _programLayers.enable(8);\n\t\tif (parameters.emissiveMap) _programLayers.enable(9);\n\t\tif (parameters.bumpMap) _programLayers.enable(10);\n\t\tif (parameters.normalMap) _programLayers.enable(11);\n\t\tif (parameters.objectSpaceNormalMap) _programLayers.enable(12);\n\t\tif (parameters.tangentSpaceNormalMap) _programLayers.enable(13);\n\t\tif (parameters.clearcoat) _programLayers.enable(14);\n\t\tif (parameters.clearcoatMap) _programLayers.enable(15);\n\t\tif (parameters.clearcoatRoughnessMap) _programLayers.enable(16);\n\t\tif (parameters.clearcoatNormalMap) _programLayers.enable(17);\n\t\tif (parameters.iridescence) _programLayers.enable(18);\n\t\tif (parameters.iridescenceMap) _programLayers.enable(19);\n\t\tif (parameters.iridescenceThicknessMap) _programLayers.enable(20);\n\t\tif (parameters.displacementMap) _programLayers.enable(21);\n\t\tif (parameters.specularMap) _programLayers.enable(22);\n\t\tif (parameters.roughnessMap) _programLayers.enable(23);\n\t\tif (parameters.metalnessMap) _programLayers.enable(24);\n\t\tif (parameters.gradientMap) _programLayers.enable(25);\n\t\tif (parameters.alphaMap) _programLayers.enable(26);\n\t\tif (parameters.alphaTest) _programLayers.enable(27);\n\t\tif (parameters.vertexColors) _programLayers.enable(28);\n\t\tif (parameters.vertexAlphas) _programLayers.enable(29);\n\t\tif (parameters.vertexUvs) _programLayers.enable(30);\n\t\tif (parameters.vertexTangents) _programLayers.enable(31);\n\t\tif (parameters.uvsVertexOnly) _programLayers.enable(32);\n\t\tarray.push(_programLayers.mask);\n\n\t\t_programLayers.disableAll();\n\n\t\tif (parameters.fog) _programLayers.enable(0);\n\t\tif (parameters.useFog) _programLayers.enable(1);\n\t\tif (parameters.flatShading) _programLayers.enable(2);\n\t\tif (parameters.logarithmicDepthBuffer) _programLayers.enable(3);\n\t\tif (parameters.skinning) _programLayers.enable(4);\n\t\tif (parameters.morphTargets) _programLayers.enable(5);\n\t\tif (parameters.morphNormals) _programLayers.enable(6);\n\t\tif (parameters.morphColors) _programLayers.enable(7);\n\t\tif (parameters.premultipliedAlpha) _programLayers.enable(8);\n\t\tif (parameters.shadowMapEnabled) _programLayers.enable(9);\n\t\tif (parameters.physicallyCorrectLights) _programLayers.enable(10);\n\t\tif (parameters.doubleSided) _programLayers.enable(11);\n\t\tif (parameters.flipSided) _programLayers.enable(12);\n\t\tif (parameters.useDepthPacking) _programLayers.enable(13);\n\t\tif (parameters.dithering) _programLayers.enable(14);\n\t\tif (parameters.specularIntensityMap) _programLayers.enable(15);\n\t\tif (parameters.specularColorMap) _programLayers.enable(16);\n\t\tif (parameters.transmission) _programLayers.enable(17);\n\t\tif (parameters.transmissionMap) _programLayers.enable(18);\n\t\tif (parameters.thicknessMap) _programLayers.enable(19);\n\t\tif (parameters.sheen) _programLayers.enable(20);\n\t\tif (parameters.sheenColorMap) _programLayers.enable(21);\n\t\tif (parameters.sheenRoughnessMap) _programLayers.enable(22);\n\t\tif (parameters.decodeVideoTexture) _programLayers.enable(23);\n\t\tif (parameters.opaque) _programLayers.enable(24);\n\t\tarray.push(_programLayers.mask);\n\t}\n\n\tfunction getUniforms(material) {\n\t\tconst shaderID = shaderIDs[material.type];\n\t\tlet uniforms;\n\n\t\tif (shaderID) {\n\t\t\tconst shader = ShaderLib[shaderID];\n\t\t\tuniforms = UniformsUtils.clone(shader.uniforms);\n\t\t} else {\n\t\t\tuniforms = material.uniforms;\n\t\t}\n\n\t\treturn uniforms;\n\t}\n\n\tfunction acquireProgram(parameters, cacheKey) {\n\t\tlet program; // Check if code has been already compiled\n\n\t\tfor (let p = 0, pl = programs.length; p < pl; p++) {\n\t\t\tconst preexistingProgram = programs[p];\n\n\t\t\tif (preexistingProgram.cacheKey === cacheKey) {\n\t\t\t\tprogram = preexistingProgram;\n\t\t\t\t++program.usedTimes;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (program === undefined) {\n\t\t\tprogram = new WebGLProgram(renderer, cacheKey, parameters, bindingStates);\n\t\t\tprograms.push(program);\n\t\t}\n\n\t\treturn program;\n\t}\n\n\tfunction releaseProgram(program) {\n\t\tif (--program.usedTimes === 0) {\n\t\t\t// Remove from unordered set\n\t\t\tconst i = programs.indexOf(program);\n\t\t\tprograms[i] = programs[programs.length - 1];\n\t\t\tprograms.pop(); // Free WebGL resources\n\n\t\t\tprogram.destroy();\n\t\t}\n\t}\n\n\tfunction releaseShaderCache(material) {\n\t\t_customShaders.remove(material);\n\t}\n\n\tfunction dispose() {\n\t\t_customShaders.dispose();\n\t}\n\n\treturn {\n\t\tgetParameters: getParameters,\n\t\tgetProgramCacheKey: getProgramCacheKey,\n\t\tgetUniforms: getUniforms,\n\t\tacquireProgram: acquireProgram,\n\t\treleaseProgram: releaseProgram,\n\t\treleaseShaderCache: releaseShaderCache,\n\t\t// Exposed for resource monitoring & error feedback via renderer.info:\n\t\tprograms: programs,\n\t\tdispose: dispose\n\t};\n}\n\nfunction WebGLProperties() {\n\tlet properties = new WeakMap();\n\n\tfunction get(object) {\n\t\tlet map = properties.get(object);\n\n\t\tif (map === undefined) {\n\t\t\tmap = {};\n\t\t\tproperties.set(object, map);\n\t\t}\n\n\t\treturn map;\n\t}\n\n\tfunction remove(object) {\n\t\tproperties.delete(object);\n\t}\n\n\tfunction update(object, key, value) {\n\t\tproperties.get(object)[key] = value;\n\t}\n\n\tfunction dispose() {\n\t\tproperties = new WeakMap();\n\t}\n\n\treturn {\n\t\tget: get,\n\t\tremove: remove,\n\t\tupdate: update,\n\t\tdispose: dispose\n\t};\n}\n\nfunction painterSortStable(a, b) {\n\tif (a.groupOrder !== b.groupOrder) {\n\t\treturn a.groupOrder - b.groupOrder;\n\t} else if (a.renderOrder !== b.renderOrder) {\n\t\treturn a.renderOrder - b.renderOrder;\n\t} else if (a.material.id !== b.material.id) {\n\t\treturn a.material.id - b.material.id;\n\t} else if (a.z !== b.z) {\n\t\treturn a.z - b.z;\n\t} else {\n\t\treturn a.id - b.id;\n\t}\n}\n\nfunction reversePainterSortStable(a, b) {\n\tif (a.groupOrder !== b.groupOrder) {\n\t\treturn a.groupOrder - b.groupOrder;\n\t} else if (a.renderOrder !== b.renderOrder) {\n\t\treturn a.renderOrder - b.renderOrder;\n\t} else if (a.z !== b.z) {\n\t\treturn b.z - a.z;\n\t} else {\n\t\treturn a.id - b.id;\n\t}\n}\n\nfunction WebGLRenderList() {\n\tconst renderItems = [];\n\tlet renderItemsIndex = 0;\n\tconst opaque = [];\n\tconst transmissive = [];\n\tconst transparent = [];\n\n\tfunction init() {\n\t\trenderItemsIndex = 0;\n\t\topaque.length = 0;\n\t\ttransmissive.length = 0;\n\t\ttransparent.length = 0;\n\t}\n\n\tfunction getNextRenderItem(object, geometry, material, groupOrder, z, group) {\n\t\tlet renderItem = renderItems[renderItemsIndex];\n\n\t\tif (renderItem === undefined) {\n\t\t\trenderItem = {\n\t\t\t\tid: object.id,\n\t\t\t\tobject: object,\n\t\t\t\tgeometry: geometry,\n\t\t\t\tmaterial: material,\n\t\t\t\tgroupOrder: groupOrder,\n\t\t\t\trenderOrder: object.renderOrder,\n\t\t\t\tz: z,\n\t\t\t\tgroup: group\n\t\t\t};\n\t\t\trenderItems[renderItemsIndex] = renderItem;\n\t\t} else {\n\t\t\trenderItem.id = object.id;\n\t\t\trenderItem.object = object;\n\t\t\trenderItem.geometry = geometry;\n\t\t\trenderItem.material = material;\n\t\t\trenderItem.groupOrder = groupOrder;\n\t\t\trenderItem.renderOrder = object.renderOrder;\n\t\t\trenderItem.z = z;\n\t\t\trenderItem.group = group;\n\t\t}\n\n\t\trenderItemsIndex++;\n\t\treturn renderItem;\n\t}\n\n\tfunction push(object, geometry, material, groupOrder, z, group) {\n\t\tconst renderItem = getNextRenderItem(object, geometry, material, groupOrder, z, group);\n\n\t\tif (material.transmission > 0.0) {\n\t\t\ttransmissive.push(renderItem);\n\t\t} else if (material.transparent === true) {\n\t\t\ttransparent.push(renderItem);\n\t\t} else {\n\t\t\topaque.push(renderItem);\n\t\t}\n\t}\n\n\tfunction unshift(object, geometry, material, groupOrder, z, group) {\n\t\tconst renderItem = getNextRenderItem(object, geometry, material, groupOrder, z, group);\n\n\t\tif (material.transmission > 0.0) {\n\t\t\ttransmissive.unshift(renderItem);\n\t\t} else if (material.transparent === true) {\n\t\t\ttransparent.unshift(renderItem);\n\t\t} else {\n\t\t\topaque.unshift(renderItem);\n\t\t}\n\t}\n\n\tfunction sort(customOpaqueSort, customTransparentSort) {\n\t\tif (opaque.length > 1) opaque.sort(customOpaqueSort || painterSortStable);\n\t\tif (transmissive.length > 1) transmissive.sort(customTransparentSort || reversePainterSortStable);\n\t\tif (transparent.length > 1) transparent.sort(customTransparentSort || reversePainterSortStable);\n\t}\n\n\tfunction finish() {\n\t\t// Clear references from inactive renderItems in the list\n\t\tfor (let i = renderItemsIndex, il = renderItems.length; i < il; i++) {\n\t\t\tconst renderItem = renderItems[i];\n\t\t\tif (renderItem.id === null) break;\n\t\t\trenderItem.id = null;\n\t\t\trenderItem.object = null;\n\t\t\trenderItem.geometry = null;\n\t\t\trenderItem.material = null;\n\t\t\trenderItem.group = null;\n\t\t}\n\t}\n\n\treturn {\n\t\topaque: opaque,\n\t\ttransmissive: transmissive,\n\t\ttransparent: transparent,\n\t\tinit: init,\n\t\tpush: push,\n\t\tunshift: unshift,\n\t\tfinish: finish,\n\t\tsort: sort\n\t};\n}\n\nfunction WebGLRenderLists() {\n\tlet lists = new WeakMap();\n\n\tfunction get(scene, renderCallDepth) {\n\t\tconst listArray = lists.get(scene);\n\t\tlet list;\n\n\t\tif (listArray === undefined) {\n\t\t\tlist = new WebGLRenderList();\n\t\t\tlists.set(scene, [list]);\n\t\t} else {\n\t\t\tif (renderCallDepth >= listArray.length) {\n\t\t\t\tlist = new WebGLRenderList();\n\t\t\t\tlistArray.push(list);\n\t\t\t} else {\n\t\t\t\tlist = listArray[renderCallDepth];\n\t\t\t}\n\t\t}\n\n\t\treturn list;\n\t}\n\n\tfunction dispose() {\n\t\tlists = new WeakMap();\n\t}\n\n\treturn {\n\t\tget: get,\n\t\tdispose: dispose\n\t};\n}\n\nfunction UniformsCache() {\n\tconst lights = {};\n\treturn {\n\t\tget: function (light) {\n\t\t\tif (lights[light.id] !== undefined) {\n\t\t\t\treturn lights[light.id];\n\t\t\t}\n\n\t\t\tlet uniforms;\n\n\t\t\tswitch (light.type) {\n\t\t\t\tcase 'DirectionalLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tdirection: new Vector3(),\n\t\t\t\t\t\tcolor: new Color()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'SpotLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tposition: new Vector3(),\n\t\t\t\t\t\tdirection: new Vector3(),\n\t\t\t\t\t\tcolor: new Color(),\n\t\t\t\t\t\tdistance: 0,\n\t\t\t\t\t\tconeCos: 0,\n\t\t\t\t\t\tpenumbraCos: 0,\n\t\t\t\t\t\tdecay: 0\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'PointLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tposition: new Vector3(),\n\t\t\t\t\t\tcolor: new Color(),\n\t\t\t\t\t\tdistance: 0,\n\t\t\t\t\t\tdecay: 0\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'HemisphereLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tdirection: new Vector3(),\n\t\t\t\t\t\tskyColor: new Color(),\n\t\t\t\t\t\tgroundColor: new Color()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'RectAreaLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tcolor: new Color(),\n\t\t\t\t\t\tposition: new Vector3(),\n\t\t\t\t\t\thalfWidth: new Vector3(),\n\t\t\t\t\t\thalfHeight: new Vector3()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tlights[light.id] = uniforms;\n\t\t\treturn uniforms;\n\t\t}\n\t};\n}\n\nfunction ShadowUniformsCache() {\n\tconst lights = {};\n\treturn {\n\t\tget: function (light) {\n\t\t\tif (lights[light.id] !== undefined) {\n\t\t\t\treturn lights[light.id];\n\t\t\t}\n\n\t\t\tlet uniforms;\n\n\t\t\tswitch (light.type) {\n\t\t\t\tcase 'DirectionalLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tshadowBias: 0,\n\t\t\t\t\t\tshadowNormalBias: 0,\n\t\t\t\t\t\tshadowRadius: 1,\n\t\t\t\t\t\tshadowMapSize: new Vector2()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'SpotLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tshadowBias: 0,\n\t\t\t\t\t\tshadowNormalBias: 0,\n\t\t\t\t\t\tshadowRadius: 1,\n\t\t\t\t\t\tshadowMapSize: new Vector2()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'PointLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tshadowBias: 0,\n\t\t\t\t\t\tshadowNormalBias: 0,\n\t\t\t\t\t\tshadowRadius: 1,\n\t\t\t\t\t\tshadowMapSize: new Vector2(),\n\t\t\t\t\t\tshadowCameraNear: 1,\n\t\t\t\t\t\tshadowCameraFar: 1000\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\t\t\t\t// TODO (abelnation): set RectAreaLight shadow uniforms\n\t\t\t}\n\n\t\t\tlights[light.id] = uniforms;\n\t\t\treturn uniforms;\n\t\t}\n\t};\n}\n\nlet nextVersion = 0;\n\nfunction shadowCastingAndTexturingLightsFirst(lightA, lightB) {\n\treturn (lightB.castShadow ? 2 : 0) - (lightA.castShadow ? 2 : 0) + (lightB.map ? 1 : 0) - (lightA.map ? 1 : 0);\n}\n\nfunction WebGLLights(extensions, capabilities) {\n\tconst cache = new UniformsCache();\n\tconst shadowCache = ShadowUniformsCache();\n\tconst state = {\n\t\tversion: 0,\n\t\thash: {\n\t\t\tdirectionalLength: -1,\n\t\t\tpointLength: -1,\n\t\t\tspotLength: -1,\n\t\t\trectAreaLength: -1,\n\t\t\themiLength: -1,\n\t\t\tnumDirectionalShadows: -1,\n\t\t\tnumPointShadows: -1,\n\t\t\tnumSpotShadows: -1,\n\t\t\tnumSpotMaps: -1\n\t\t},\n\t\tambient: [0, 0, 0],\n\t\tprobe: [],\n\t\tdirectional: [],\n\t\tdirectionalShadow: [],\n\t\tdirectionalShadowMap: [],\n\t\tdirectionalShadowMatrix: [],\n\t\tspot: [],\n\t\tspotLightMap: [],\n\t\tspotShadow: [],\n\t\tspotShadowMap: [],\n\t\tspotLightMatrix: [],\n\t\trectArea: [],\n\t\trectAreaLTC1: null,\n\t\trectAreaLTC2: null,\n\t\tpoint: [],\n\t\tpointShadow: [],\n\t\tpointShadowMap: [],\n\t\tpointShadowMatrix: [],\n\t\themi: [],\n\t\tnumSpotLightShadowsWithMaps: 0\n\t};\n\n\tfor (let i = 0; i < 9; i++) state.probe.push(new Vector3());\n\n\tconst vector3 = new Vector3();\n\tconst matrix4 = new Matrix4();\n\tconst matrix42 = new Matrix4();\n\n\tfunction setup(lights, physicallyCorrectLights) {\n\t\tlet r = 0,\n\t\t\t\tg = 0,\n\t\t\t\tb = 0;\n\n\t\tfor (let i = 0; i < 9; i++) state.probe[i].set(0, 0, 0);\n\n\t\tlet directionalLength = 0;\n\t\tlet pointLength = 0;\n\t\tlet spotLength = 0;\n\t\tlet rectAreaLength = 0;\n\t\tlet hemiLength = 0;\n\t\tlet numDirectionalShadows = 0;\n\t\tlet numPointShadows = 0;\n\t\tlet numSpotShadows = 0;\n\t\tlet numSpotMaps = 0;\n\t\tlet numSpotShadowsWithMaps = 0; // ordering : [shadow casting + map texturing, map texturing, shadow casting, none ]\n\n\t\tlights.sort(shadowCastingAndTexturingLightsFirst); // artist-friendly light intensity scaling factor\n\n\t\tconst scaleFactor = physicallyCorrectLights !== true ? Math.PI : 1;\n\n\t\tfor (let i = 0, l = lights.length; i < l; i++) {\n\t\t\tconst light = lights[i];\n\t\t\tconst color = light.color;\n\t\t\tconst intensity = light.intensity;\n\t\t\tconst distance = light.distance;\n\t\t\tconst shadowMap = light.shadow && light.shadow.map ? light.shadow.map.texture : null;\n\n\t\t\tif (light.isAmbientLight) {\n\t\t\t\tr += color.r * intensity * scaleFactor;\n\t\t\t\tg += color.g * intensity * scaleFactor;\n\t\t\t\tb += color.b * intensity * scaleFactor;\n\t\t\t} else if (light.isLightProbe) {\n\t\t\t\tfor (let j = 0; j < 9; j++) {\n\t\t\t\t\tstate.probe[j].addScaledVector(light.sh.coefficients[j], intensity);\n\t\t\t\t}\n\t\t\t} else if (light.isDirectionalLight) {\n\t\t\t\tconst uniforms = cache.get(light);\n\t\t\t\tuniforms.color.copy(light.color).multiplyScalar(light.intensity * scaleFactor);\n\n\t\t\t\tif (light.castShadow) {\n\t\t\t\t\tconst shadow = light.shadow;\n\t\t\t\t\tconst shadowUniforms = shadowCache.get(light);\n\t\t\t\t\tshadowUniforms.shadowBias = shadow.bias;\n\t\t\t\t\tshadowUniforms.shadowNormalBias = shadow.normalBias;\n\t\t\t\t\tshadowUniforms.shadowRadius = shadow.radius;\n\t\t\t\t\tshadowUniforms.shadowMapSize = shadow.mapSize;\n\t\t\t\t\tstate.directionalShadow[directionalLength] = shadowUniforms;\n\t\t\t\t\tstate.directionalShadowMap[directionalLength] = shadowMap;\n\t\t\t\t\tstate.directionalShadowMatrix[directionalLength] = light.shadow.matrix;\n\t\t\t\t\tnumDirectionalShadows++;\n\t\t\t\t}\n\n\t\t\t\tstate.directional[directionalLength] = uniforms;\n\t\t\t\tdirectionalLength++;\n\t\t\t} else if (light.isSpotLight) {\n\t\t\t\tconst uniforms = cache.get(light);\n\t\t\t\tuniforms.position.setFromMatrixPosition(light.matrixWorld);\n\t\t\t\tuniforms.color.copy(color).multiplyScalar(intensity * scaleFactor);\n\t\t\t\tuniforms.distance = distance;\n\t\t\t\tuniforms.coneCos = Math.cos(light.angle);\n\t\t\t\tuniforms.penumbraCos = Math.cos(light.angle * (1 - light.penumbra));\n\t\t\t\tuniforms.decay = light.decay;\n\t\t\t\tstate.spot[spotLength] = uniforms;\n\t\t\t\tconst shadow = light.shadow;\n\n\t\t\t\tif (light.map) {\n\t\t\t\t\tstate.spotLightMap[numSpotMaps] = light.map;\n\t\t\t\t\tnumSpotMaps++; // make sure the lightMatrix is up to date\n\t\t\t\t\t// TODO : do it if required only\n\n\t\t\t\t\tshadow.updateMatrices(light);\n\t\t\t\t\tif (light.castShadow) numSpotShadowsWithMaps++;\n\t\t\t\t}\n\n\t\t\t\tstate.spotLightMatrix[spotLength] = shadow.matrix;\n\n\t\t\t\tif (light.castShadow) {\n\t\t\t\t\tconst shadowUniforms = shadowCache.get(light);\n\t\t\t\t\tshadowUniforms.shadowBias = shadow.bias;\n\t\t\t\t\tshadowUniforms.shadowNormalBias = shadow.normalBias;\n\t\t\t\t\tshadowUniforms.shadowRadius = shadow.radius;\n\t\t\t\t\tshadowUniforms.shadowMapSize = shadow.mapSize;\n\t\t\t\t\tstate.spotShadow[spotLength] = shadowUniforms;\n\t\t\t\t\tstate.spotShadowMap[spotLength] = shadowMap;\n\t\t\t\t\tnumSpotShadows++;\n\t\t\t\t}\n\n\t\t\t\tspotLength++;\n\t\t\t} else if (light.isRectAreaLight) {\n\t\t\t\tconst uniforms = cache.get(light); // (a) intensity is the total visible light emitted\n\t\t\t\t//uniforms.color.copy( color ).multiplyScalar( intensity / ( light.width * light.height * Math.PI ) );\n\t\t\t\t// (b) intensity is the brightness of the light\n\n\t\t\t\tuniforms.color.copy(color).multiplyScalar(intensity);\n\t\t\t\tuniforms.halfWidth.set(light.width * 0.5, 0.0, 0.0);\n\t\t\t\tuniforms.halfHeight.set(0.0, light.height * 0.5, 0.0);\n\t\t\t\tstate.rectArea[rectAreaLength] = uniforms;\n\t\t\t\trectAreaLength++;\n\t\t\t} else if (light.isPointLight) {\n\t\t\t\tconst uniforms = cache.get(light);\n\t\t\t\tuniforms.color.copy(light.color).multiplyScalar(light.intensity * scaleFactor);\n\t\t\t\tuniforms.distance = light.distance;\n\t\t\t\tuniforms.decay = light.decay;\n\n\t\t\t\tif (light.castShadow) {\n\t\t\t\t\tconst shadow = light.shadow;\n\t\t\t\t\tconst shadowUniforms = shadowCache.get(light);\n\t\t\t\t\tshadowUniforms.shadowBias = shadow.bias;\n\t\t\t\t\tshadowUniforms.shadowNormalBias = shadow.normalBias;\n\t\t\t\t\tshadowUniforms.shadowRadius = shadow.radius;\n\t\t\t\t\tshadowUniforms.shadowMapSize = shadow.mapSize;\n\t\t\t\t\tshadowUniforms.shadowCameraNear = shadow.camera.near;\n\t\t\t\t\tshadowUniforms.shadowCameraFar = shadow.camera.far;\n\t\t\t\t\tstate.pointShadow[pointLength] = shadowUniforms;\n\t\t\t\t\tstate.pointShadowMap[pointLength] = shadowMap;\n\t\t\t\t\tstate.pointShadowMatrix[pointLength] = light.shadow.matrix;\n\t\t\t\t\tnumPointShadows++;\n\t\t\t\t}\n\n\t\t\t\tstate.point[pointLength] = uniforms;\n\t\t\t\tpointLength++;\n\t\t\t} else if (light.isHemisphereLight) {\n\t\t\t\tconst uniforms = cache.get(light);\n\t\t\t\tuniforms.skyColor.copy(light.color).multiplyScalar(intensity * scaleFactor);\n\t\t\t\tuniforms.groundColor.copy(light.groundColor).multiplyScalar(intensity * scaleFactor);\n\t\t\t\tstate.hemi[hemiLength] = uniforms;\n\t\t\t\themiLength++;\n\t\t\t}\n\t\t}\n\n\t\tif (rectAreaLength > 0) {\n\t\t\tif (capabilities.isWebGL2) {\n\t\t\t\t// WebGL 2\n\t\t\t\tstate.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1;\n\t\t\t\tstate.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2;\n\t\t\t} else {\n\t\t\t\t// WebGL 1\n\t\t\t\tif (extensions.has('OES_texture_float_linear') === true) {\n\t\t\t\t\tstate.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1;\n\t\t\t\t\tstate.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2;\n\t\t\t\t} else if (extensions.has('OES_texture_half_float_linear') === true) {\n\t\t\t\t\tstate.rectAreaLTC1 = UniformsLib.LTC_HALF_1;\n\t\t\t\t\tstate.rectAreaLTC2 = UniformsLib.LTC_HALF_2;\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error('THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tstate.ambient[0] = r;\n\t\tstate.ambient[1] = g;\n\t\tstate.ambient[2] = b;\n\t\tconst hash = state.hash;\n\n\t\tif (hash.directionalLength !== directionalLength || hash.pointLength !== pointLength || hash.spotLength !== spotLength || hash.rectAreaLength !== rectAreaLength || hash.hemiLength !== hemiLength || hash.numDirectionalShadows !== numDirectionalShadows || hash.numPointShadows !== numPointShadows || hash.numSpotShadows !== numSpotShadows || hash.numSpotMaps !== numSpotMaps) {\n\t\t\tstate.directional.length = directionalLength;\n\t\t\tstate.spot.length = spotLength;\n\t\t\tstate.rectArea.length = rectAreaLength;\n\t\t\tstate.point.length = pointLength;\n\t\t\tstate.hemi.length = hemiLength;\n\t\t\tstate.directionalShadow.length = numDirectionalShadows;\n\t\t\tstate.directionalShadowMap.length = numDirectionalShadows;\n\t\t\tstate.pointShadow.length = numPointShadows;\n\t\t\tstate.pointShadowMap.length = numPointShadows;\n\t\t\tstate.spotShadow.length = numSpotShadows;\n\t\t\tstate.spotShadowMap.length = numSpotShadows;\n\t\t\tstate.directionalShadowMatrix.length = numDirectionalShadows;\n\t\t\tstate.pointShadowMatrix.length = numPointShadows;\n\t\t\tstate.spotLightMatrix.length = numSpotShadows + numSpotMaps - numSpotShadowsWithMaps;\n\t\t\tstate.spotLightMap.length = numSpotMaps;\n\t\t\tstate.numSpotLightShadowsWithMaps = numSpotShadowsWithMaps;\n\t\t\thash.directionalLength = directionalLength;\n\t\t\thash.pointLength = pointLength;\n\t\t\thash.spotLength = spotLength;\n\t\t\thash.rectAreaLength = rectAreaLength;\n\t\t\thash.hemiLength = hemiLength;\n\t\t\thash.numDirectionalShadows = numDirectionalShadows;\n\t\t\thash.numPointShadows = numPointShadows;\n\t\t\thash.numSpotShadows = numSpotShadows;\n\t\t\thash.numSpotMaps = numSpotMaps;\n\t\t\tstate.version = nextVersion++;\n\t\t}\n\t}\n\n\tfunction setupView(lights, camera) {\n\t\tlet directionalLength = 0;\n\t\tlet pointLength = 0;\n\t\tlet spotLength = 0;\n\t\tlet rectAreaLength = 0;\n\t\tlet hemiLength = 0;\n\t\tconst viewMatrix = camera.matrixWorldInverse;\n\n\t\tfor (let i = 0, l = lights.length; i < l; i++) {\n\t\t\tconst light = lights[i];\n\n\t\t\tif (light.isDirectionalLight) {\n\t\t\t\tconst uniforms = state.directional[directionalLength];\n\t\t\t\tuniforms.direction.setFromMatrixPosition(light.matrixWorld);\n\t\t\t\tvector3.setFromMatrixPosition(light.target.matrixWorld);\n\t\t\t\tuniforms.direction.sub(vector3);\n\t\t\t\tuniforms.direction.transformDirection(viewMatrix);\n\t\t\t\tdirectionalLength++;\n\t\t\t} else if (light.isSpotLight) {\n\t\t\t\tconst uniforms = state.spot[spotLength];\n\t\t\t\tuniforms.position.setFromMatrixPosition(light.matrixWorld);\n\t\t\t\tuniforms.position.applyMatrix4(viewMatrix);\n\t\t\t\tuniforms.direction.setFromMatrixPosition(light.matrixWorld);\n\t\t\t\tvector3.setFromMatrixPosition(light.target.matrixWorld);\n\t\t\t\tuniforms.direction.sub(vector3);\n\t\t\t\tuniforms.direction.transformDirection(viewMatrix);\n\t\t\t\tspotLength++;\n\t\t\t} else if (light.isRectAreaLight) {\n\t\t\t\tconst uniforms = state.rectArea[rectAreaLength];\n\t\t\t\tuniforms.position.setFromMatrixPosition(light.matrixWorld);\n\t\t\t\tuniforms.position.applyMatrix4(viewMatrix); // extract local rotation of light to derive width/height half vectors\n\n\t\t\t\tmatrix42.identity();\n\t\t\t\tmatrix4.copy(light.matrixWorld);\n\t\t\t\tmatrix4.premultiply(viewMatrix);\n\t\t\t\tmatrix42.extractRotation(matrix4);\n\t\t\t\tuniforms.halfWidth.set(light.width * 0.5, 0.0, 0.0);\n\t\t\t\tuniforms.halfHeight.set(0.0, light.height * 0.5, 0.0);\n\t\t\t\tuniforms.halfWidth.applyMatrix4(matrix42);\n\t\t\t\tuniforms.halfHeight.applyMatrix4(matrix42);\n\t\t\t\trectAreaLength++;\n\t\t\t} else if (light.isPointLight) {\n\t\t\t\tconst uniforms = state.point[pointLength];\n\t\t\t\tuniforms.position.setFromMatrixPosition(light.matrixWorld);\n\t\t\t\tuniforms.position.applyMatrix4(viewMatrix);\n\t\t\t\tpointLength++;\n\t\t\t} else if (light.isHemisphereLight) {\n\t\t\t\tconst uniforms = state.hemi[hemiLength];\n\t\t\t\tuniforms.direction.setFromMatrixPosition(light.matrixWorld);\n\t\t\t\tuniforms.direction.transformDirection(viewMatrix);\n\t\t\t\themiLength++;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tsetup: setup,\n\t\tsetupView: setupView,\n\t\tstate: state\n\t};\n}\n\nfunction WebGLRenderState(extensions, capabilities) {\n\tconst lights = new WebGLLights(extensions, capabilities);\n\tconst lightsArray = [];\n\tconst shadowsArray = [];\n\n\tfunction init() {\n\t\tlightsArray.length = 0;\n\t\tshadowsArray.length = 0;\n\t}\n\n\tfunction pushLight(light) {\n\t\tlightsArray.push(light);\n\t}\n\n\tfunction pushShadow(shadowLight) {\n\t\tshadowsArray.push(shadowLight);\n\t}\n\n\tfunction setupLights(physicallyCorrectLights) {\n\t\tlights.setup(lightsArray, physicallyCorrectLights);\n\t}\n\n\tfunction setupLightsView(camera) {\n\t\tlights.setupView(lightsArray, camera);\n\t}\n\n\tconst state = {\n\t\tlightsArray: lightsArray,\n\t\tshadowsArray: shadowsArray,\n\t\tlights: lights\n\t};\n\treturn {\n\t\tinit: init,\n\t\tstate: state,\n\t\tsetupLights: setupLights,\n\t\tsetupLightsView: setupLightsView,\n\t\tpushLight: pushLight,\n\t\tpushShadow: pushShadow\n\t};\n}\n\nfunction WebGLRenderStates(extensions, capabilities) {\n\tlet renderStates = new WeakMap();\n\n\tfunction get(scene, renderCallDepth = 0) {\n\t\tconst renderStateArray = renderStates.get(scene);\n\t\tlet renderState;\n\n\t\tif (renderStateArray === undefined) {\n\t\t\trenderState = new WebGLRenderState(extensions, capabilities);\n\t\t\trenderStates.set(scene, [renderState]);\n\t\t} else {\n\t\t\tif (renderCallDepth >= renderStateArray.length) {\n\t\t\t\trenderState = new WebGLRenderState(extensions, capabilities);\n\t\t\t\trenderStateArray.push(renderState);\n\t\t\t} else {\n\t\t\t\trenderState = renderStateArray[renderCallDepth];\n\t\t\t}\n\t\t}\n\n\t\treturn renderState;\n\t}\n\n\tfunction dispose() {\n\t\trenderStates = new WeakMap();\n\t}\n\n\treturn {\n\t\tget: get,\n\t\tdispose: dispose\n\t};\n}\n\nclass MeshDepthMaterial extends Material {\n\tconstructor(parameters) {\n\t\tsuper();\n\t\tthis.isMeshDepthMaterial = true;\n\t\tthis.type = 'MeshDepthMaterial';\n\t\tthis.depthPacking = BasicDepthPacking;\n\t\tthis.map = null;\n\t\tthis.alphaMap = null;\n\t\tthis.displacementMap = null;\n\t\tthis.displacementScale = 1;\n\t\tthis.displacementBias = 0;\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\t\tthis.setValues(parameters);\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.depthPacking = source.depthPacking;\n\t\tthis.map = source.map;\n\t\tthis.alphaMap = source.alphaMap;\n\t\tthis.displacementMap = source.displacementMap;\n\t\tthis.displacementScale = source.displacementScale;\n\t\tthis.displacementBias = source.displacementBias;\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\t\treturn this;\n\t}\n\n}\n\nclass MeshDistanceMaterial extends Material {\n\tconstructor(parameters) {\n\t\tsuper();\n\t\tthis.isMeshDistanceMaterial = true;\n\t\tthis.type = 'MeshDistanceMaterial';\n\t\tthis.referencePosition = new Vector3();\n\t\tthis.nearDistance = 1;\n\t\tthis.farDistance = 1000;\n\t\tthis.map = null;\n\t\tthis.alphaMap = null;\n\t\tthis.displacementMap = null;\n\t\tthis.displacementScale = 1;\n\t\tthis.displacementBias = 0;\n\t\tthis.setValues(parameters);\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.referencePosition.copy(source.referencePosition);\n\t\tthis.nearDistance = source.nearDistance;\n\t\tthis.farDistance = source.farDistance;\n\t\tthis.map = source.map;\n\t\tthis.alphaMap = source.alphaMap;\n\t\tthis.displacementMap = source.displacementMap;\n\t\tthis.displacementScale = source.displacementScale;\n\t\tthis.displacementBias = source.displacementBias;\n\t\treturn this;\n\t}\n\n}\n\nconst vertex = \"void main() {\\n\\tgl_Position = vec4( position, 1.0 );\\n}\";\nconst fragment = \"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}\";\n\nfunction WebGLShadowMap(_renderer, _objects, _capabilities) {\n\tlet _frustum = new Frustum();\n\n\tconst _shadowMapSize = new Vector2(),\n\t\t\t\t_viewportSize = new Vector2(),\n\t\t\t\t_viewport = new Vector4(),\n\t\t\t\t_depthMaterial = new MeshDepthMaterial({\n\t\tdepthPacking: RGBADepthPacking\n\t}),\n\t\t\t\t_distanceMaterial = new MeshDistanceMaterial(),\n\t\t\t\t_materialCache = {},\n\t\t\t\t_maxTextureSize = _capabilities.maxTextureSize;\n\n\tconst shadowSide = {\n\t\t0: BackSide,\n\t\t1: FrontSide,\n\t\t2: DoubleSide\n\t};\n\tconst shadowMaterialVertical = new ShaderMaterial({\n\t\tdefines: {\n\t\t\tVSM_SAMPLES: 8\n\t\t},\n\t\tuniforms: {\n\t\t\tshadow_pass: {\n\t\t\t\tvalue: null\n\t\t\t},\n\t\t\tresolution: {\n\t\t\t\tvalue: new Vector2()\n\t\t\t},\n\t\t\tradius: {\n\t\t\t\tvalue: 4.0\n\t\t\t}\n\t\t},\n\t\tvertexShader: vertex,\n\t\tfragmentShader: fragment\n\t});\n\tconst shadowMaterialHorizontal = shadowMaterialVertical.clone();\n\tshadowMaterialHorizontal.defines.HORIZONTAL_PASS = 1;\n\tconst fullScreenTri = new BufferGeometry();\n\tfullScreenTri.setAttribute('position', new BufferAttribute(new Float32Array([-1, -1, 0.5, 3, -1, 0.5, -1, 3, 0.5]), 3));\n\tconst fullScreenMesh = new Mesh(fullScreenTri, shadowMaterialVertical);\n\tconst scope = this;\n\tthis.enabled = false;\n\tthis.autoUpdate = true;\n\tthis.needsUpdate = false;\n\tthis.type = PCFShadowMap;\n\n\tthis.render = function (lights, scene, camera) {\n\t\tif (scope.enabled === false) return;\n\t\tif (scope.autoUpdate === false && scope.needsUpdate === false) return;\n\t\tif (lights.length === 0) return;\n\n\t\tconst currentRenderTarget = _renderer.getRenderTarget();\n\n\t\tconst activeCubeFace = _renderer.getActiveCubeFace();\n\n\t\tconst activeMipmapLevel = _renderer.getActiveMipmapLevel();\n\n\t\tconst _state = _renderer.state; // Set GL state for depth map.\n\n\t\t_state.setBlending(NoBlending);\n\n\t\t_state.buffers.color.setClear(1, 1, 1, 1);\n\n\t\t_state.buffers.depth.setTest(true);\n\n\t\t_state.setScissorTest(false); // render depth map\n\n\n\t\tfor (let i = 0, il = lights.length; i < il; i++) {\n\t\t\tconst light = lights[i];\n\t\t\tconst shadow = light.shadow;\n\n\t\t\tif (shadow === undefined) {\n\t\t\t\tconsole.warn('THREE.WebGLShadowMap:', light, 'has no shadow.');\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (shadow.autoUpdate === false && shadow.needsUpdate === false) continue;\n\n\t\t\t_shadowMapSize.copy(shadow.mapSize);\n\n\t\t\tconst shadowFrameExtents = shadow.getFrameExtents();\n\n\t\t\t_shadowMapSize.multiply(shadowFrameExtents);\n\n\t\t\t_viewportSize.copy(shadow.mapSize);\n\n\t\t\tif (_shadowMapSize.x > _maxTextureSize || _shadowMapSize.y > _maxTextureSize) {\n\t\t\t\tif (_shadowMapSize.x > _maxTextureSize) {\n\t\t\t\t\t_viewportSize.x = Math.floor(_maxTextureSize / shadowFrameExtents.x);\n\t\t\t\t\t_shadowMapSize.x = _viewportSize.x * shadowFrameExtents.x;\n\t\t\t\t\tshadow.mapSize.x = _viewportSize.x;\n\t\t\t\t}\n\n\t\t\t\tif (_shadowMapSize.y > _maxTextureSize) {\n\t\t\t\t\t_viewportSize.y = Math.floor(_maxTextureSize / shadowFrameExtents.y);\n\t\t\t\t\t_shadowMapSize.y = _viewportSize.y * shadowFrameExtents.y;\n\t\t\t\t\tshadow.mapSize.y = _viewportSize.y;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (shadow.map === null) {\n\t\t\t\tconst pars = this.type !== VSMShadowMap ? {\n\t\t\t\t\tminFilter: NearestFilter,\n\t\t\t\t\tmagFilter: NearestFilter\n\t\t\t\t} : {};\n\t\t\t\tshadow.map = new WebGLRenderTarget(_shadowMapSize.x, _shadowMapSize.y, pars);\n\t\t\t\tshadow.map.texture.name = light.name + '.shadowMap';\n\t\t\t\tshadow.camera.updateProjectionMatrix();\n\t\t\t}\n\n\t\t\t_renderer.setRenderTarget(shadow.map);\n\n\t\t\t_renderer.clear();\n\n\t\t\tconst viewportCount = shadow.getViewportCount();\n\n\t\t\tfor (let vp = 0; vp < viewportCount; vp++) {\n\t\t\t\tconst viewport = shadow.getViewport(vp);\n\n\t\t\t\t_viewport.set(_viewportSize.x * viewport.x, _viewportSize.y * viewport.y, _viewportSize.x * viewport.z, _viewportSize.y * viewport.w);\n\n\t\t\t\t_state.viewport(_viewport);\n\n\t\t\t\tshadow.updateMatrices(light, vp);\n\t\t\t\t_frustum = shadow.getFrustum();\n\t\t\t\trenderObject(scene, camera, shadow.camera, light, this.type);\n\t\t\t} // do blur pass for VSM\n\n\n\t\t\tif (shadow.isPointLightShadow !== true && this.type === VSMShadowMap) {\n\t\t\t\tVSMPass(shadow, camera);\n\t\t\t}\n\n\t\t\tshadow.needsUpdate = false;\n\t\t}\n\n\t\tscope.needsUpdate = false;\n\n\t\t_renderer.setRenderTarget(currentRenderTarget, activeCubeFace, activeMipmapLevel);\n\t};\n\n\tfunction VSMPass(shadow, camera) {\n\t\tconst geometry = _objects.update(fullScreenMesh);\n\n\t\tif (shadowMaterialVertical.defines.VSM_SAMPLES !== shadow.blurSamples) {\n\t\t\tshadowMaterialVertical.defines.VSM_SAMPLES = shadow.blurSamples;\n\t\t\tshadowMaterialHorizontal.defines.VSM_SAMPLES = shadow.blurSamples;\n\t\t\tshadowMaterialVertical.needsUpdate = true;\n\t\t\tshadowMaterialHorizontal.needsUpdate = true;\n\t\t}\n\n\t\tif (shadow.mapPass === null) {\n\t\t\tshadow.mapPass = new WebGLRenderTarget(_shadowMapSize.x, _shadowMapSize.y);\n\t\t} // vertical pass\n\n\n\t\tshadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.texture;\n\t\tshadowMaterialVertical.uniforms.resolution.value = shadow.mapSize;\n\t\tshadowMaterialVertical.uniforms.radius.value = shadow.radius;\n\n\t\t_renderer.setRenderTarget(shadow.mapPass);\n\n\t\t_renderer.clear();\n\n\t\t_renderer.renderBufferDirect(camera, null, geometry, shadowMaterialVertical, fullScreenMesh, null); // horizontal pass\n\n\n\t\tshadowMaterialHorizontal.uniforms.shadow_pass.value = shadow.mapPass.texture;\n\t\tshadowMaterialHorizontal.uniforms.resolution.value = shadow.mapSize;\n\t\tshadowMaterialHorizontal.uniforms.radius.value = shadow.radius;\n\n\t\t_renderer.setRenderTarget(shadow.map);\n\n\t\t_renderer.clear();\n\n\t\t_renderer.renderBufferDirect(camera, null, geometry, shadowMaterialHorizontal, fullScreenMesh, null);\n\t}\n\n\tfunction getDepthMaterial(object, material, light, shadowCameraNear, shadowCameraFar, type) {\n\t\tlet result = null;\n\t\tconst customMaterial = light.isPointLight === true ? object.customDistanceMaterial : object.customDepthMaterial;\n\n\t\tif (customMaterial !== undefined) {\n\t\t\tresult = customMaterial;\n\t\t} else {\n\t\t\tresult = light.isPointLight === true ? _distanceMaterial : _depthMaterial;\n\t\t}\n\n\t\tif (_renderer.localClippingEnabled && material.clipShadows === true && Array.isArray(material.clippingPlanes) && material.clippingPlanes.length !== 0 || material.displacementMap && material.displacementScale !== 0 || material.alphaMap && material.alphaTest > 0) {\n\t\t\t// in this case we need a unique material instance reflecting the\n\t\t\t// appropriate state\n\t\t\tconst keyA = result.uuid,\n\t\t\t\t\t\tkeyB = material.uuid;\n\t\t\tlet materialsForVariant = _materialCache[keyA];\n\n\t\t\tif (materialsForVariant === undefined) {\n\t\t\t\tmaterialsForVariant = {};\n\t\t\t\t_materialCache[keyA] = materialsForVariant;\n\t\t\t}\n\n\t\t\tlet cachedMaterial = materialsForVariant[keyB];\n\n\t\t\tif (cachedMaterial === undefined) {\n\t\t\t\tcachedMaterial = result.clone();\n\t\t\t\tmaterialsForVariant[keyB] = cachedMaterial;\n\t\t\t}\n\n\t\t\tresult = cachedMaterial;\n\t\t}\n\n\t\tresult.visible = material.visible;\n\t\tresult.wireframe = material.wireframe;\n\n\t\tif (type === VSMShadowMap) {\n\t\t\tresult.side = material.shadowSide !== null ? material.shadowSide : material.side;\n\t\t} else {\n\t\t\tresult.side = material.shadowSide !== null ? material.shadowSide : shadowSide[material.side];\n\t\t}\n\n\t\tresult.alphaMap = material.alphaMap;\n\t\tresult.alphaTest = material.alphaTest;\n\t\tresult.clipShadows = material.clipShadows;\n\t\tresult.clippingPlanes = material.clippingPlanes;\n\t\tresult.clipIntersection = material.clipIntersection;\n\t\tresult.displacementMap = material.displacementMap;\n\t\tresult.displacementScale = material.displacementScale;\n\t\tresult.displacementBias = material.displacementBias;\n\t\tresult.wireframeLinewidth = material.wireframeLinewidth;\n\t\tresult.linewidth = material.linewidth;\n\n\t\tif (light.isPointLight === true && result.isMeshDistanceMaterial === true) {\n\t\t\tresult.referencePosition.setFromMatrixPosition(light.matrixWorld);\n\t\t\tresult.nearDistance = shadowCameraNear;\n\t\t\tresult.farDistance = shadowCameraFar;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tfunction renderObject(object, camera, shadowCamera, light, type) {\n\t\tif (object.visible === false) return;\n\t\tconst visible = object.layers.test(camera.layers);\n\n\t\tif (visible && (object.isMesh || object.isLine || object.isPoints)) {\n\t\t\tif ((object.castShadow || object.receiveShadow && type === VSMShadowMap) && (!object.frustumCulled || _frustum.intersectsObject(object))) {\n\t\t\t\tobject.modelViewMatrix.multiplyMatrices(shadowCamera.matrixWorldInverse, object.matrixWorld);\n\n\t\t\t\tconst geometry = _objects.update(object);\n\n\t\t\t\tconst material = object.material;\n\n\t\t\t\tif (Array.isArray(material)) {\n\t\t\t\t\tconst groups = geometry.groups;\n\n\t\t\t\t\tfor (let k = 0, kl = groups.length; k < kl; k++) {\n\t\t\t\t\t\tconst group = groups[k];\n\t\t\t\t\t\tconst groupMaterial = material[group.materialIndex];\n\n\t\t\t\t\t\tif (groupMaterial && groupMaterial.visible) {\n\t\t\t\t\t\t\tconst depthMaterial = getDepthMaterial(object, groupMaterial, light, shadowCamera.near, shadowCamera.far, type);\n\n\t\t\t\t\t\t\t_renderer.renderBufferDirect(shadowCamera, null, geometry, depthMaterial, object, group);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (material.visible) {\n\t\t\t\t\tconst depthMaterial = getDepthMaterial(object, material, light, shadowCamera.near, shadowCamera.far, type);\n\n\t\t\t\t\t_renderer.renderBufferDirect(shadowCamera, null, geometry, depthMaterial, object, null);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst children = object.children;\n\n\t\tfor (let i = 0, l = children.length; i < l; i++) {\n\t\t\trenderObject(children[i], camera, shadowCamera, light, type);\n\t\t}\n\t}\n}\n\nfunction WebGLState(gl, extensions, capabilities) {\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tfunction ColorBuffer() {\n\t\tlet locked = false;\n\t\tconst color = new Vector4();\n\t\tlet currentColorMask = null;\n\t\tconst currentColorClear = new Vector4(0, 0, 0, 0);\n\t\treturn {\n\t\t\tsetMask: function (colorMask) {\n\t\t\t\tif (currentColorMask !== colorMask && !locked) {\n\t\t\t\t\tgl.colorMask(colorMask, colorMask, colorMask, colorMask);\n\t\t\t\t\tcurrentColorMask = colorMask;\n\t\t\t\t}\n\t\t\t},\n\t\t\tsetLocked: function (lock) {\n\t\t\t\tlocked = lock;\n\t\t\t},\n\t\t\tsetClear: function (r, g, b, a, premultipliedAlpha) {\n\t\t\t\tif (premultipliedAlpha === true) {\n\t\t\t\t\tr *= a;\n\t\t\t\t\tg *= a;\n\t\t\t\t\tb *= a;\n\t\t\t\t}\n\n\t\t\t\tcolor.set(r, g, b, a);\n\n\t\t\t\tif (currentColorClear.equals(color) === false) {\n\t\t\t\t\tgl.clearColor(r, g, b, a);\n\t\t\t\t\tcurrentColorClear.copy(color);\n\t\t\t\t}\n\t\t\t},\n\t\t\treset: function () {\n\t\t\t\tlocked = false;\n\t\t\t\tcurrentColorMask = null;\n\t\t\t\tcurrentColorClear.set(-1, 0, 0, 0); // set to invalid state\n\t\t\t}\n\t\t};\n\t}\n\n\tfunction DepthBuffer() {\n\t\tlet locked = false;\n\t\tlet currentDepthMask = null;\n\t\tlet currentDepthFunc = null;\n\t\tlet currentDepthClear = null;\n\t\treturn {\n\t\t\tsetTest: function (depthTest) {\n\t\t\t\tif (depthTest) {\n\t\t\t\t\tenable(gl.DEPTH_TEST);\n\t\t\t\t} else {\n\t\t\t\t\tdisable(gl.DEPTH_TEST);\n\t\t\t\t}\n\t\t\t},\n\t\t\tsetMask: function (depthMask) {\n\t\t\t\tif (currentDepthMask !== depthMask && !locked) {\n\t\t\t\t\tgl.depthMask(depthMask);\n\t\t\t\t\tcurrentDepthMask = depthMask;\n\t\t\t\t}\n\t\t\t},\n\t\t\tsetFunc: function (depthFunc) {\n\t\t\t\tif (currentDepthFunc !== depthFunc) {\n\t\t\t\t\tswitch (depthFunc) {\n\t\t\t\t\t\tcase NeverDepth:\n\t\t\t\t\t\t\tgl.depthFunc(gl.NEVER);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase AlwaysDepth:\n\t\t\t\t\t\t\tgl.depthFunc(gl.ALWAYS);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase LessDepth:\n\t\t\t\t\t\t\tgl.depthFunc(gl.LESS);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase LessEqualDepth:\n\t\t\t\t\t\t\tgl.depthFunc(gl.LEQUAL);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase EqualDepth:\n\t\t\t\t\t\t\tgl.depthFunc(gl.EQUAL);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase GreaterEqualDepth:\n\t\t\t\t\t\t\tgl.depthFunc(gl.GEQUAL);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase GreaterDepth:\n\t\t\t\t\t\t\tgl.depthFunc(gl.GREATER);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase NotEqualDepth:\n\t\t\t\t\t\t\tgl.depthFunc(gl.NOTEQUAL);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tgl.depthFunc(gl.LEQUAL);\n\t\t\t\t\t}\n\n\t\t\t\t\tcurrentDepthFunc = depthFunc;\n\t\t\t\t}\n\t\t\t},\n\t\t\tsetLocked: function (lock) {\n\t\t\t\tlocked = lock;\n\t\t\t},\n\t\t\tsetClear: function (depth) {\n\t\t\t\tif (currentDepthClear !== depth) {\n\t\t\t\t\tgl.clearDepth(depth);\n\t\t\t\t\tcurrentDepthClear = depth;\n\t\t\t\t}\n\t\t\t},\n\t\t\treset: function () {\n\t\t\t\tlocked = false;\n\t\t\t\tcurrentDepthMask = null;\n\t\t\t\tcurrentDepthFunc = null;\n\t\t\t\tcurrentDepthClear = null;\n\t\t\t}\n\t\t};\n\t}\n\n\tfunction StencilBuffer() {\n\t\tlet locked = false;\n\t\tlet currentStencilMask = null;\n\t\tlet currentStencilFunc = null;\n\t\tlet currentStencilRef = null;\n\t\tlet currentStencilFuncMask = null;\n\t\tlet currentStencilFail = null;\n\t\tlet currentStencilZFail = null;\n\t\tlet currentStencilZPass = null;\n\t\tlet currentStencilClear = null;\n\t\treturn {\n\t\t\tsetTest: function (stencilTest) {\n\t\t\t\tif (!locked) {\n\t\t\t\t\tif (stencilTest) {\n\t\t\t\t\t\tenable(gl.STENCIL_TEST);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdisable(gl.STENCIL_TEST);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tsetMask: function (stencilMask) {\n\t\t\t\tif (currentStencilMask !== stencilMask && !locked) {\n\t\t\t\t\tgl.stencilMask(stencilMask);\n\t\t\t\t\tcurrentStencilMask = stencilMask;\n\t\t\t\t}\n\t\t\t},\n\t\t\tsetFunc: function (stencilFunc, stencilRef, stencilMask) {\n\t\t\t\tif (currentStencilFunc !== stencilFunc || currentStencilRef !== stencilRef || currentStencilFuncMask !== stencilMask) {\n\t\t\t\t\tgl.stencilFunc(stencilFunc, stencilRef, stencilMask);\n\t\t\t\t\tcurrentStencilFunc = stencilFunc;\n\t\t\t\t\tcurrentStencilRef = stencilRef;\n\t\t\t\t\tcurrentStencilFuncMask = stencilMask;\n\t\t\t\t}\n\t\t\t},\n\t\t\tsetOp: function (stencilFail, stencilZFail, stencilZPass) {\n\t\t\t\tif (currentStencilFail !== stencilFail || currentStencilZFail !== stencilZFail || currentStencilZPass !== stencilZPass) {\n\t\t\t\t\tgl.stencilOp(stencilFail, stencilZFail, stencilZPass);\n\t\t\t\t\tcurrentStencilFail = stencilFail;\n\t\t\t\t\tcurrentStencilZFail = stencilZFail;\n\t\t\t\t\tcurrentStencilZPass = stencilZPass;\n\t\t\t\t}\n\t\t\t},\n\t\t\tsetLocked: function (lock) {\n\t\t\t\tlocked = lock;\n\t\t\t},\n\t\t\tsetClear: function (stencil) {\n\t\t\t\tif (currentStencilClear !== stencil) {\n\t\t\t\t\tgl.clearStencil(stencil);\n\t\t\t\t\tcurrentStencilClear = stencil;\n\t\t\t\t}\n\t\t\t},\n\t\t\treset: function () {\n\t\t\t\tlocked = false;\n\t\t\t\tcurrentStencilMask = null;\n\t\t\t\tcurrentStencilFunc = null;\n\t\t\t\tcurrentStencilRef = null;\n\t\t\t\tcurrentStencilFuncMask = null;\n\t\t\t\tcurrentStencilFail = null;\n\t\t\t\tcurrentStencilZFail = null;\n\t\t\t\tcurrentStencilZPass = null;\n\t\t\t\tcurrentStencilClear = null;\n\t\t\t}\n\t\t};\n\t} //\n\n\n\tconst colorBuffer = new ColorBuffer();\n\tconst depthBuffer = new DepthBuffer();\n\tconst stencilBuffer = new StencilBuffer();\n\tconst uboBindings = new WeakMap();\n\tconst uboProgamMap = new WeakMap();\n\tlet enabledCapabilities = {};\n\tlet currentBoundFramebuffers = {};\n\tlet currentDrawbuffers = new WeakMap();\n\tlet defaultDrawbuffers = [];\n\tlet currentProgram = null;\n\tlet currentBlendingEnabled = false;\n\tlet currentBlending = null;\n\tlet currentBlendEquation = null;\n\tlet currentBlendSrc = null;\n\tlet currentBlendDst = null;\n\tlet currentBlendEquationAlpha = null;\n\tlet currentBlendSrcAlpha = null;\n\tlet currentBlendDstAlpha = null;\n\tlet currentPremultipledAlpha = false;\n\tlet currentFlipSided = null;\n\tlet currentCullFace = null;\n\tlet currentLineWidth = null;\n\tlet currentPolygonOffsetFactor = null;\n\tlet currentPolygonOffsetUnits = null;\n\tconst maxTextures = gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);\n\tlet lineWidthAvailable = false;\n\tlet version = 0;\n\tconst glVersion = gl.getParameter(gl.VERSION);\n\n\tif (glVersion.indexOf('WebGL') !== -1) {\n\t\tversion = parseFloat(/^WebGL (\\d)/.exec(glVersion)[1]);\n\t\tlineWidthAvailable = version >= 1.0;\n\t} else if (glVersion.indexOf('OpenGL ES') !== -1) {\n\t\tversion = parseFloat(/^OpenGL ES (\\d)/.exec(glVersion)[1]);\n\t\tlineWidthAvailable = version >= 2.0;\n\t}\n\n\tlet currentTextureSlot = null;\n\tlet currentBoundTextures = {};\n\tconst scissorParam = gl.getParameter(gl.SCISSOR_BOX);\n\tconst viewportParam = gl.getParameter(gl.VIEWPORT);\n\tconst currentScissor = new Vector4().fromArray(scissorParam);\n\tconst currentViewport = new Vector4().fromArray(viewportParam);\n\n\tfunction createTexture(type, target, count) {\n\t\tconst data = new Uint8Array(4); // 4 is required to match default unpack alignment of 4.\n\n\t\tconst texture = gl.createTexture();\n\t\tgl.bindTexture(type, texture);\n\t\tgl.texParameteri(type, gl.TEXTURE_MIN_FILTER, gl.NEAREST);\n\t\tgl.texParameteri(type, gl.TEXTURE_MAG_FILTER, gl.NEAREST);\n\n\t\tfor (let i = 0; i < count; i++) {\n\t\t\tgl.texImage2D(target + i, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, data);\n\t\t}\n\n\t\treturn texture;\n\t}\n\n\tconst emptyTextures = {};\n\temptyTextures[gl.TEXTURE_2D] = createTexture(gl.TEXTURE_2D, gl.TEXTURE_2D, 1);\n\temptyTextures[gl.TEXTURE_CUBE_MAP] = createTexture(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_CUBE_MAP_POSITIVE_X, 6); // init\n\n\tcolorBuffer.setClear(0, 0, 0, 1);\n\tdepthBuffer.setClear(1);\n\tstencilBuffer.setClear(0);\n\tenable(gl.DEPTH_TEST);\n\tdepthBuffer.setFunc(LessEqualDepth);\n\tsetFlipSided(false);\n\tsetCullFace(CullFaceBack);\n\tenable(gl.CULL_FACE);\n\tsetBlending(NoBlending); //\n\n\tfunction enable(id) {\n\t\tif (enabledCapabilities[id] !== true) {\n\t\t\tgl.enable(id);\n\t\t\tenabledCapabilities[id] = true;\n\t\t}\n\t}\n\n\tfunction disable(id) {\n\t\tif (enabledCapabilities[id] !== false) {\n\t\t\tgl.disable(id);\n\t\t\tenabledCapabilities[id] = false;\n\t\t}\n\t}\n\n\tfunction bindFramebuffer(target, framebuffer) {\n\t\tif (currentBoundFramebuffers[target] !== framebuffer) {\n\t\t\tgl.bindFramebuffer(target, framebuffer);\n\t\t\tcurrentBoundFramebuffers[target] = framebuffer;\n\n\t\t\tif (isWebGL2) {\n\t\t\t\t// gl.DRAW_FRAMEBUFFER is equivalent to gl.FRAMEBUFFER\n\t\t\t\tif (target === gl.DRAW_FRAMEBUFFER) {\n\t\t\t\t\tcurrentBoundFramebuffers[gl.FRAMEBUFFER] = framebuffer;\n\t\t\t\t}\n\n\t\t\t\tif (target === gl.FRAMEBUFFER) {\n\t\t\t\t\tcurrentBoundFramebuffers[gl.DRAW_FRAMEBUFFER] = framebuffer;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tfunction drawBuffers(renderTarget, framebuffer) {\n\t\tlet drawBuffers = defaultDrawbuffers;\n\t\tlet needsUpdate = false;\n\n\t\tif (renderTarget) {\n\t\t\tdrawBuffers = currentDrawbuffers.get(framebuffer);\n\n\t\t\tif (drawBuffers === undefined) {\n\t\t\t\tdrawBuffers = [];\n\t\t\t\tcurrentDrawbuffers.set(framebuffer, drawBuffers);\n\t\t\t}\n\n\t\t\tif (renderTarget.isWebGLMultipleRenderTargets) {\n\t\t\t\tconst textures = renderTarget.texture;\n\n\t\t\t\tif (drawBuffers.length !== textures.length || drawBuffers[0] !== gl.COLOR_ATTACHMENT0) {\n\t\t\t\t\tfor (let i = 0, il = textures.length; i < il; i++) {\n\t\t\t\t\t\tdrawBuffers[i] = gl.COLOR_ATTACHMENT0 + i;\n\t\t\t\t\t}\n\n\t\t\t\t\tdrawBuffers.length = textures.length;\n\t\t\t\t\tneedsUpdate = true;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (drawBuffers[0] !== gl.COLOR_ATTACHMENT0) {\n\t\t\t\t\tdrawBuffers[0] = gl.COLOR_ATTACHMENT0;\n\t\t\t\t\tneedsUpdate = true;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (drawBuffers[0] !== gl.BACK) {\n\t\t\t\tdrawBuffers[0] = gl.BACK;\n\t\t\t\tneedsUpdate = true;\n\t\t\t}\n\t\t}\n\n\t\tif (needsUpdate) {\n\t\t\tif (capabilities.isWebGL2) {\n\t\t\t\tgl.drawBuffers(drawBuffers);\n\t\t\t} else {\n\t\t\t\textensions.get('WEBGL_draw_buffers').drawBuffersWEBGL(drawBuffers);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction useProgram(program) {\n\t\tif (currentProgram !== program) {\n\t\t\tgl.useProgram(program);\n\t\t\tcurrentProgram = program;\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tconst equationToGL = {\n\t\t[AddEquation]: gl.FUNC_ADD,\n\t\t[SubtractEquation]: gl.FUNC_SUBTRACT,\n\t\t[ReverseSubtractEquation]: gl.FUNC_REVERSE_SUBTRACT\n\t};\n\n\tif (isWebGL2) {\n\t\tequationToGL[MinEquation] = gl.MIN;\n\t\tequationToGL[MaxEquation] = gl.MAX;\n\t} else {\n\t\tconst extension = extensions.get('EXT_blend_minmax');\n\n\t\tif (extension !== null) {\n\t\t\tequationToGL[MinEquation] = extension.MIN_EXT;\n\t\t\tequationToGL[MaxEquation] = extension.MAX_EXT;\n\t\t}\n\t}\n\n\tconst factorToGL = {\n\t\t[ZeroFactor]: gl.ZERO,\n\t\t[OneFactor]: gl.ONE,\n\t\t[SrcColorFactor]: gl.SRC_COLOR,\n\t\t[SrcAlphaFactor]: gl.SRC_ALPHA,\n\t\t[SrcAlphaSaturateFactor]: gl.SRC_ALPHA_SATURATE,\n\t\t[DstColorFactor]: gl.DST_COLOR,\n\t\t[DstAlphaFactor]: gl.DST_ALPHA,\n\t\t[OneMinusSrcColorFactor]: gl.ONE_MINUS_SRC_COLOR,\n\t\t[OneMinusSrcAlphaFactor]: gl.ONE_MINUS_SRC_ALPHA,\n\t\t[OneMinusDstColorFactor]: gl.ONE_MINUS_DST_COLOR,\n\t\t[OneMinusDstAlphaFactor]: gl.ONE_MINUS_DST_ALPHA\n\t};\n\n\tfunction setBlending(blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, premultipliedAlpha) {\n\t\tif (blending === NoBlending) {\n\t\t\tif (currentBlendingEnabled === true) {\n\t\t\t\tdisable(gl.BLEND);\n\t\t\t\tcurrentBlendingEnabled = false;\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (currentBlendingEnabled === false) {\n\t\t\tenable(gl.BLEND);\n\t\t\tcurrentBlendingEnabled = true;\n\t\t}\n\n\t\tif (blending !== CustomBlending) {\n\t\t\tif (blending !== currentBlending || premultipliedAlpha !== currentPremultipledAlpha) {\n\t\t\t\tif (currentBlendEquation !== AddEquation || currentBlendEquationAlpha !== AddEquation) {\n\t\t\t\t\tgl.blendEquation(gl.FUNC_ADD);\n\t\t\t\t\tcurrentBlendEquation = AddEquation;\n\t\t\t\t\tcurrentBlendEquationAlpha = AddEquation;\n\t\t\t\t}\n\n\t\t\t\tif (premultipliedAlpha) {\n\t\t\t\t\tswitch (blending) {\n\t\t\t\t\t\tcase NormalBlending:\n\t\t\t\t\t\t\tgl.blendFuncSeparate(gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase AdditiveBlending:\n\t\t\t\t\t\t\tgl.blendFunc(gl.ONE, gl.ONE);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase SubtractiveBlending:\n\t\t\t\t\t\t\tgl.blendFuncSeparate(gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ZERO, gl.ONE);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase MultiplyBlending:\n\t\t\t\t\t\t\tgl.blendFuncSeparate(gl.ZERO, gl.SRC_COLOR, gl.ZERO, gl.SRC_ALPHA);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tconsole.error('THREE.WebGLState: Invalid blending: ', blending);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tswitch (blending) {\n\t\t\t\t\t\tcase NormalBlending:\n\t\t\t\t\t\t\tgl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase AdditiveBlending:\n\t\t\t\t\t\t\tgl.blendFunc(gl.SRC_ALPHA, gl.ONE);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase SubtractiveBlending:\n\t\t\t\t\t\t\tgl.blendFuncSeparate(gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ZERO, gl.ONE);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase MultiplyBlending:\n\t\t\t\t\t\t\tgl.blendFunc(gl.ZERO, gl.SRC_COLOR);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tconsole.error('THREE.WebGLState: Invalid blending: ', blending);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tcurrentBlendSrc = null;\n\t\t\t\tcurrentBlendDst = null;\n\t\t\t\tcurrentBlendSrcAlpha = null;\n\t\t\t\tcurrentBlendDstAlpha = null;\n\t\t\t\tcurrentBlending = blending;\n\t\t\t\tcurrentPremultipledAlpha = premultipliedAlpha;\n\t\t\t}\n\n\t\t\treturn;\n\t\t} // custom blending\n\n\n\t\tblendEquationAlpha = blendEquationAlpha || blendEquation;\n\t\tblendSrcAlpha = blendSrcAlpha || blendSrc;\n\t\tblendDstAlpha = blendDstAlpha || blendDst;\n\n\t\tif (blendEquation !== currentBlendEquation || blendEquationAlpha !== currentBlendEquationAlpha) {\n\t\t\tgl.blendEquationSeparate(equationToGL[blendEquation], equationToGL[blendEquationAlpha]);\n\t\t\tcurrentBlendEquation = blendEquation;\n\t\t\tcurrentBlendEquationAlpha = blendEquationAlpha;\n\t\t}\n\n\t\tif (blendSrc !== currentBlendSrc || blendDst !== currentBlendDst || blendSrcAlpha !== currentBlendSrcAlpha || blendDstAlpha !== currentBlendDstAlpha) {\n\t\t\tgl.blendFuncSeparate(factorToGL[blendSrc], factorToGL[blendDst], factorToGL[blendSrcAlpha], factorToGL[blendDstAlpha]);\n\t\t\tcurrentBlendSrc = blendSrc;\n\t\t\tcurrentBlendDst = blendDst;\n\t\t\tcurrentBlendSrcAlpha = blendSrcAlpha;\n\t\t\tcurrentBlendDstAlpha = blendDstAlpha;\n\t\t}\n\n\t\tcurrentBlending = blending;\n\t\tcurrentPremultipledAlpha = null;\n\t}\n\n\tfunction setMaterial(material, frontFaceCW) {\n\t\tmaterial.side === DoubleSide ? disable(gl.CULL_FACE) : enable(gl.CULL_FACE);\n\t\tlet flipSided = material.side === BackSide;\n\t\tif (frontFaceCW) flipSided = !flipSided;\n\t\tsetFlipSided(flipSided);\n\t\tmaterial.blending === NormalBlending && material.transparent === false ? setBlending(NoBlending) : setBlending(material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.premultipliedAlpha);\n\t\tdepthBuffer.setFunc(material.depthFunc);\n\t\tdepthBuffer.setTest(material.depthTest);\n\t\tdepthBuffer.setMask(material.depthWrite);\n\t\tcolorBuffer.setMask(material.colorWrite);\n\t\tconst stencilWrite = material.stencilWrite;\n\t\tstencilBuffer.setTest(stencilWrite);\n\n\t\tif (stencilWrite) {\n\t\t\tstencilBuffer.setMask(material.stencilWriteMask);\n\t\t\tstencilBuffer.setFunc(material.stencilFunc, material.stencilRef, material.stencilFuncMask);\n\t\t\tstencilBuffer.setOp(material.stencilFail, material.stencilZFail, material.stencilZPass);\n\t\t}\n\n\t\tsetPolygonOffset(material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits);\n\t\tmaterial.alphaToCoverage === true ? enable(gl.SAMPLE_ALPHA_TO_COVERAGE) : disable(gl.SAMPLE_ALPHA_TO_COVERAGE);\n\t} //\n\n\n\tfunction setFlipSided(flipSided) {\n\t\tif (currentFlipSided !== flipSided) {\n\t\t\tif (flipSided) {\n\t\t\t\tgl.frontFace(gl.CW);\n\t\t\t} else {\n\t\t\t\tgl.frontFace(gl.CCW);\n\t\t\t}\n\n\t\t\tcurrentFlipSided = flipSided;\n\t\t}\n\t}\n\n\tfunction setCullFace(cullFace) {\n\t\tif (cullFace !== CullFaceNone) {\n\t\t\tenable(gl.CULL_FACE);\n\n\t\t\tif (cullFace !== currentCullFace) {\n\t\t\t\tif (cullFace === CullFaceBack) {\n\t\t\t\t\tgl.cullFace(gl.BACK);\n\t\t\t\t} else if (cullFace === CullFaceFront) {\n\t\t\t\t\tgl.cullFace(gl.FRONT);\n\t\t\t\t} else {\n\t\t\t\t\tgl.cullFace(gl.FRONT_AND_BACK);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tdisable(gl.CULL_FACE);\n\t\t}\n\n\t\tcurrentCullFace = cullFace;\n\t}\n\n\tfunction setLineWidth(width) {\n\t\tif (width !== currentLineWidth) {\n\t\t\tif (lineWidthAvailable) gl.lineWidth(width);\n\t\t\tcurrentLineWidth = width;\n\t\t}\n\t}\n\n\tfunction setPolygonOffset(polygonOffset, factor, units) {\n\t\tif (polygonOffset) {\n\t\t\tenable(gl.POLYGON_OFFSET_FILL);\n\n\t\t\tif (currentPolygonOffsetFactor !== factor || currentPolygonOffsetUnits !== units) {\n\t\t\t\tgl.polygonOffset(factor, units);\n\t\t\t\tcurrentPolygonOffsetFactor = factor;\n\t\t\t\tcurrentPolygonOffsetUnits = units;\n\t\t\t}\n\t\t} else {\n\t\t\tdisable(gl.POLYGON_OFFSET_FILL);\n\t\t}\n\t}\n\n\tfunction setScissorTest(scissorTest) {\n\t\tif (scissorTest) {\n\t\t\tenable(gl.SCISSOR_TEST);\n\t\t} else {\n\t\t\tdisable(gl.SCISSOR_TEST);\n\t\t}\n\t} // texture\n\n\n\tfunction activeTexture(webglSlot) {\n\t\tif (webglSlot === undefined) webglSlot = gl.TEXTURE0 + maxTextures - 1;\n\n\t\tif (currentTextureSlot !== webglSlot) {\n\t\t\tgl.activeTexture(webglSlot);\n\t\t\tcurrentTextureSlot = webglSlot;\n\t\t}\n\t}\n\n\tfunction bindTexture(webglType, webglTexture, webglSlot) {\n\t\tif (webglSlot === undefined) {\n\t\t\tif (currentTextureSlot === null) {\n\t\t\t\twebglSlot = gl.TEXTURE0 + maxTextures - 1;\n\t\t\t} else {\n\t\t\t\twebglSlot = currentTextureSlot;\n\t\t\t}\n\t\t}\n\n\t\tlet boundTexture = currentBoundTextures[webglSlot];\n\n\t\tif (boundTexture === undefined) {\n\t\t\tboundTexture = {\n\t\t\t\ttype: undefined,\n\t\t\t\ttexture: undefined\n\t\t\t};\n\t\t\tcurrentBoundTextures[webglSlot] = boundTexture;\n\t\t}\n\n\t\tif (boundTexture.type !== webglType || boundTexture.texture !== webglTexture) {\n\t\t\tif (currentTextureSlot !== webglSlot) {\n\t\t\t\tgl.activeTexture(webglSlot);\n\t\t\t\tcurrentTextureSlot = webglSlot;\n\t\t\t}\n\n\t\t\tgl.bindTexture(webglType, webglTexture || emptyTextures[webglType]);\n\t\t\tboundTexture.type = webglType;\n\t\t\tboundTexture.texture = webglTexture;\n\t\t}\n\t}\n\n\tfunction unbindTexture() {\n\t\tconst boundTexture = currentBoundTextures[currentTextureSlot];\n\n\t\tif (boundTexture !== undefined && boundTexture.type !== undefined) {\n\t\t\tgl.bindTexture(boundTexture.type, null);\n\t\t\tboundTexture.type = undefined;\n\t\t\tboundTexture.texture = undefined;\n\t\t}\n\t}\n\n\tfunction compressedTexImage2D() {\n\t\ttry {\n\t\t\tgl.compressedTexImage2D.apply(gl, arguments);\n\t\t} catch (error) {\n\t\t\tconsole.error('THREE.WebGLState:', error);\n\t\t}\n\t}\n\n\tfunction texSubImage2D() {\n\t\ttry {\n\t\t\tgl.texSubImage2D.apply(gl, arguments);\n\t\t} catch (error) {\n\t\t\tconsole.error('THREE.WebGLState:', error);\n\t\t}\n\t}\n\n\tfunction texSubImage3D() {\n\t\ttry {\n\t\t\tgl.texSubImage3D.apply(gl, arguments);\n\t\t} catch (error) {\n\t\t\tconsole.error('THREE.WebGLState:', error);\n\t\t}\n\t}\n\n\tfunction compressedTexSubImage2D() {\n\t\ttry {\n\t\t\tgl.compressedTexSubImage2D.apply(gl, arguments);\n\t\t} catch (error) {\n\t\t\tconsole.error('THREE.WebGLState:', error);\n\t\t}\n\t}\n\n\tfunction texStorage2D() {\n\t\ttry {\n\t\t\tgl.texStorage2D.apply(gl, arguments);\n\t\t} catch (error) {\n\t\t\tconsole.error('THREE.WebGLState:', error);\n\t\t}\n\t}\n\n\tfunction texStorage3D() {\n\t\ttry {\n\t\t\tgl.texStorage3D.apply(gl, arguments);\n\t\t} catch (error) {\n\t\t\tconsole.error('THREE.WebGLState:', error);\n\t\t}\n\t}\n\n\tfunction texImage2D() {\n\t\ttry {\n\t\t\tgl.texImage2D.apply(gl, arguments);\n\t\t} catch (error) {\n\t\t\tconsole.error('THREE.WebGLState:', error);\n\t\t}\n\t}\n\n\tfunction texImage3D() {\n\t\ttry {\n\t\t\tgl.texImage3D.apply(gl, arguments);\n\t\t} catch (error) {\n\t\t\tconsole.error('THREE.WebGLState:', error);\n\t\t}\n\t} //\n\n\n\tfunction scissor(scissor) {\n\t\tif (currentScissor.equals(scissor) === false) {\n\t\t\tgl.scissor(scissor.x, scissor.y, scissor.z, scissor.w);\n\t\t\tcurrentScissor.copy(scissor);\n\t\t}\n\t}\n\n\tfunction viewport(viewport) {\n\t\tif (currentViewport.equals(viewport) === false) {\n\t\t\tgl.viewport(viewport.x, viewport.y, viewport.z, viewport.w);\n\t\t\tcurrentViewport.copy(viewport);\n\t\t}\n\t}\n\n\tfunction updateUBOMapping(uniformsGroup, program) {\n\t\tlet mapping = uboProgamMap.get(program);\n\n\t\tif (mapping === undefined) {\n\t\t\tmapping = new WeakMap();\n\t\t\tuboProgamMap.set(program, mapping);\n\t\t}\n\n\t\tlet blockIndex = mapping.get(uniformsGroup);\n\n\t\tif (blockIndex === undefined) {\n\t\t\tblockIndex = gl.getUniformBlockIndex(program, uniformsGroup.name);\n\t\t\tmapping.set(uniformsGroup, blockIndex);\n\t\t}\n\t}\n\n\tfunction uniformBlockBinding(uniformsGroup, program) {\n\t\tconst mapping = uboProgamMap.get(program);\n\t\tconst blockIndex = mapping.get(uniformsGroup);\n\n\t\tif (uboBindings.get(uniformsGroup) !== blockIndex) {\n\t\t\t// bind shader specific block index to global block point\n\t\t\tgl.uniformBlockBinding(program, blockIndex, uniformsGroup.__bindingPointIndex);\n\t\t\tuboBindings.set(uniformsGroup, blockIndex);\n\t\t}\n\t} //\n\n\n\tfunction reset() {\n\t\t// reset state\n\t\tgl.disable(gl.BLEND);\n\t\tgl.disable(gl.CULL_FACE);\n\t\tgl.disable(gl.DEPTH_TEST);\n\t\tgl.disable(gl.POLYGON_OFFSET_FILL);\n\t\tgl.disable(gl.SCISSOR_TEST);\n\t\tgl.disable(gl.STENCIL_TEST);\n\t\tgl.disable(gl.SAMPLE_ALPHA_TO_COVERAGE);\n\t\tgl.blendEquation(gl.FUNC_ADD);\n\t\tgl.blendFunc(gl.ONE, gl.ZERO);\n\t\tgl.blendFuncSeparate(gl.ONE, gl.ZERO, gl.ONE, gl.ZERO);\n\t\tgl.colorMask(true, true, true, true);\n\t\tgl.clearColor(0, 0, 0, 0);\n\t\tgl.depthMask(true);\n\t\tgl.depthFunc(gl.LESS);\n\t\tgl.clearDepth(1);\n\t\tgl.stencilMask(0xffffffff);\n\t\tgl.stencilFunc(gl.ALWAYS, 0, 0xffffffff);\n\t\tgl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);\n\t\tgl.clearStencil(0);\n\t\tgl.cullFace(gl.BACK);\n\t\tgl.frontFace(gl.CCW);\n\t\tgl.polygonOffset(0, 0);\n\t\tgl.activeTexture(gl.TEXTURE0);\n\t\tgl.bindFramebuffer(gl.FRAMEBUFFER, null);\n\n\t\tif (isWebGL2 === true) {\n\t\t\tgl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, null);\n\t\t\tgl.bindFramebuffer(gl.READ_FRAMEBUFFER, null);\n\t\t}\n\n\t\tgl.useProgram(null);\n\t\tgl.lineWidth(1);\n\t\tgl.scissor(0, 0, gl.canvas.width, gl.canvas.height);\n\t\tgl.viewport(0, 0, gl.canvas.width, gl.canvas.height); // reset internals\n\n\t\tenabledCapabilities = {};\n\t\tcurrentTextureSlot = null;\n\t\tcurrentBoundTextures = {};\n\t\tcurrentBoundFramebuffers = {};\n\t\tcurrentDrawbuffers = new WeakMap();\n\t\tdefaultDrawbuffers = [];\n\t\tcurrentProgram = null;\n\t\tcurrentBlendingEnabled = false;\n\t\tcurrentBlending = null;\n\t\tcurrentBlendEquation = null;\n\t\tcurrentBlendSrc = null;\n\t\tcurrentBlendDst = null;\n\t\tcurrentBlendEquationAlpha = null;\n\t\tcurrentBlendSrcAlpha = null;\n\t\tcurrentBlendDstAlpha = null;\n\t\tcurrentPremultipledAlpha = false;\n\t\tcurrentFlipSided = null;\n\t\tcurrentCullFace = null;\n\t\tcurrentLineWidth = null;\n\t\tcurrentPolygonOffsetFactor = null;\n\t\tcurrentPolygonOffsetUnits = null;\n\t\tcurrentScissor.set(0, 0, gl.canvas.width, gl.canvas.height);\n\t\tcurrentViewport.set(0, 0, gl.canvas.width, gl.canvas.height);\n\t\tcolorBuffer.reset();\n\t\tdepthBuffer.reset();\n\t\tstencilBuffer.reset();\n\t}\n\n\treturn {\n\t\tbuffers: {\n\t\t\tcolor: colorBuffer,\n\t\t\tdepth: depthBuffer,\n\t\t\tstencil: stencilBuffer\n\t\t},\n\t\tenable: enable,\n\t\tdisable: disable,\n\t\tbindFramebuffer: bindFramebuffer,\n\t\tdrawBuffers: drawBuffers,\n\t\tuseProgram: useProgram,\n\t\tsetBlending: setBlending,\n\t\tsetMaterial: setMaterial,\n\t\tsetFlipSided: setFlipSided,\n\t\tsetCullFace: setCullFace,\n\t\tsetLineWidth: setLineWidth,\n\t\tsetPolygonOffset: setPolygonOffset,\n\t\tsetScissorTest: setScissorTest,\n\t\tactiveTexture: activeTexture,\n\t\tbindTexture: bindTexture,\n\t\tunbindTexture: unbindTexture,\n\t\tcompressedTexImage2D: compressedTexImage2D,\n\t\ttexImage2D: texImage2D,\n\t\ttexImage3D: texImage3D,\n\t\tupdateUBOMapping: updateUBOMapping,\n\t\tuniformBlockBinding: uniformBlockBinding,\n\t\ttexStorage2D: texStorage2D,\n\t\ttexStorage3D: texStorage3D,\n\t\ttexSubImage2D: texSubImage2D,\n\t\ttexSubImage3D: texSubImage3D,\n\t\tcompressedTexSubImage2D: compressedTexSubImage2D,\n\t\tscissor: scissor,\n\t\tviewport: viewport,\n\t\treset: reset\n\t};\n}\n\nfunction WebGLTextures(_gl, extensions, state, properties, capabilities, utils, info) {\n\tconst isWebGL2 = capabilities.isWebGL2;\n\tconst maxTextures = capabilities.maxTextures;\n\tconst maxCubemapSize = capabilities.maxCubemapSize;\n\tconst maxTextureSize = capabilities.maxTextureSize;\n\tconst maxSamples = capabilities.maxSamples;\n\tconst multisampledRTTExt = extensions.has('WEBGL_multisampled_render_to_texture') ? extensions.get('WEBGL_multisampled_render_to_texture') : null;\n\tconst supportsInvalidateFramebuffer = /OculusBrowser/g.test(navigator.userAgent);\n\n\tconst _videoTextures = new WeakMap();\n\n\tlet _canvas;\n\n\tconst _sources = new WeakMap(); // maps WebglTexture objects to instances of Source\n\t// cordova iOS (as of 5.0) still uses UIWebView, which provides OffscreenCanvas,\n\t// also OffscreenCanvas.getContext(\"webgl\"), but not OffscreenCanvas.getContext(\"2d\")!\n\t// Some implementations may only implement OffscreenCanvas partially (e.g. lacking 2d).\n\n\n\tlet useOffscreenCanvas = false;\n\n\ttry {\n\t\tuseOffscreenCanvas = typeof OffscreenCanvas !== 'undefined' // eslint-disable-next-line compat/compat\n\t\t&& new OffscreenCanvas(1, 1).getContext('2d') !== null;\n\t} catch (err) {// Ignore any errors\n\t}\n\n\tfunction createCanvas(width, height) {\n\t\t// Use OffscreenCanvas when available. Specially needed in web workers\n\t\treturn useOffscreenCanvas ? // eslint-disable-next-line compat/compat\n\t\tnew OffscreenCanvas(width, height) : createElementNS('canvas');\n\t}\n\n\tfunction resizeImage(image, needsPowerOfTwo, needsNewCanvas, maxSize) {\n\t\tlet scale = 1; // handle case if texture exceeds max size\n\n\t\tif (image.width > maxSize || image.height > maxSize) {\n\t\t\tscale = maxSize / Math.max(image.width, image.height);\n\t\t} // only perform resize if necessary\n\n\n\t\tif (scale < 1 || needsPowerOfTwo === true) {\n\t\t\t// only perform resize for certain image types\n\t\t\tif (typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement || typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement || typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap) {\n\t\t\t\tconst floor = needsPowerOfTwo ? floorPowerOfTwo : Math.floor;\n\t\t\t\tconst width = floor(scale * image.width);\n\t\t\t\tconst height = floor(scale * image.height);\n\t\t\t\tif (_canvas === undefined) _canvas = createCanvas(width, height); // cube textures can't reuse the same canvas\n\n\t\t\t\tconst canvas = needsNewCanvas ? createCanvas(width, height) : _canvas;\n\t\t\t\tcanvas.width = width;\n\t\t\t\tcanvas.height = height;\n\t\t\t\tconst context = canvas.getContext('2d');\n\t\t\t\tcontext.drawImage(image, 0, 0, width, height);\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: Texture has been resized from (' + image.width + 'x' + image.height + ') to (' + width + 'x' + height + ').');\n\t\t\t\treturn canvas;\n\t\t\t} else {\n\t\t\t\tif ('data' in image) {\n\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: Image in DataTexture is too big (' + image.width + 'x' + image.height + ').');\n\t\t\t\t}\n\n\t\t\t\treturn image;\n\t\t\t}\n\t\t}\n\n\t\treturn image;\n\t}\n\n\tfunction isPowerOfTwo$1(image) {\n\t\treturn isPowerOfTwo(image.width) && isPowerOfTwo(image.height);\n\t}\n\n\tfunction textureNeedsPowerOfTwo(texture) {\n\t\tif (isWebGL2) return false;\n\t\treturn texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping || texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;\n\t}\n\n\tfunction textureNeedsGenerateMipmaps(texture, supportsMips) {\n\t\treturn texture.generateMipmaps && supportsMips && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;\n\t}\n\n\tfunction generateMipmap(target) {\n\t\t_gl.generateMipmap(target);\n\t}\n\n\tfunction getInternalFormat(internalFormatName, glFormat, glType, encoding, forceLinearEncoding = false) {\n\t\tif (isWebGL2 === false) return glFormat;\n\n\t\tif (internalFormatName !== null) {\n\t\t\tif (_gl[internalFormatName] !== undefined) return _gl[internalFormatName];\n\t\t\tconsole.warn('THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format \\'' + internalFormatName + '\\'');\n\t\t}\n\n\t\tlet internalFormat = glFormat;\n\n\t\tif (glFormat === _gl.RED) {\n\t\t\tif (glType === _gl.FLOAT) internalFormat = _gl.R32F;\n\t\t\tif (glType === _gl.HALF_FLOAT) internalFormat = _gl.R16F;\n\t\t\tif (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.R8;\n\t\t}\n\n\t\tif (glFormat === _gl.RG) {\n\t\t\tif (glType === _gl.FLOAT) internalFormat = _gl.RG32F;\n\t\t\tif (glType === _gl.HALF_FLOAT) internalFormat = _gl.RG16F;\n\t\t\tif (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.RG8;\n\t\t}\n\n\t\tif (glFormat === _gl.RGBA) {\n\t\t\tif (glType === _gl.FLOAT) internalFormat = _gl.RGBA32F;\n\t\t\tif (glType === _gl.HALF_FLOAT) internalFormat = _gl.RGBA16F;\n\t\t\tif (glType === _gl.UNSIGNED_BYTE) internalFormat = encoding === sRGBEncoding && forceLinearEncoding === false ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;\n\t\t\tif (glType === _gl.UNSIGNED_SHORT_4_4_4_4) internalFormat = _gl.RGBA4;\n\t\t\tif (glType === _gl.UNSIGNED_SHORT_5_5_5_1) internalFormat = _gl.RGB5_A1;\n\t\t}\n\n\t\tif (internalFormat === _gl.R16F || internalFormat === _gl.R32F || internalFormat === _gl.RG16F || internalFormat === _gl.RG32F || internalFormat === _gl.RGBA16F || internalFormat === _gl.RGBA32F) {\n\t\t\textensions.get('EXT_color_buffer_float');\n\t\t}\n\n\t\treturn internalFormat;\n\t}\n\n\tfunction getMipLevels(texture, image, supportsMips) {\n\t\tif (textureNeedsGenerateMipmaps(texture, supportsMips) === true || texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter) {\n\t\t\treturn Math.log2(Math.max(image.width, image.height)) + 1;\n\t\t} else if (texture.mipmaps !== undefined && texture.mipmaps.length > 0) {\n\t\t\t// user-defined mipmaps\n\t\t\treturn texture.mipmaps.length;\n\t\t} else if (texture.isCompressedTexture && Array.isArray(texture.image)) {\n\t\t\treturn image.mipmaps.length;\n\t\t} else {\n\t\t\t// texture without mipmaps (only base level)\n\t\t\treturn 1;\n\t\t}\n\t} // Fallback filters for non-power-of-2 textures\n\n\n\tfunction filterFallback(f) {\n\t\tif (f === NearestFilter || f === NearestMipmapNearestFilter || f === NearestMipmapLinearFilter) {\n\t\t\treturn _gl.NEAREST;\n\t\t}\n\n\t\treturn _gl.LINEAR;\n\t} //\n\n\n\tfunction onTextureDispose(event) {\n\t\tconst texture = event.target;\n\t\ttexture.removeEventListener('dispose', onTextureDispose);\n\t\tdeallocateTexture(texture);\n\n\t\tif (texture.isVideoTexture) {\n\t\t\t_videoTextures.delete(texture);\n\t\t}\n\t}\n\n\tfunction onRenderTargetDispose(event) {\n\t\tconst renderTarget = event.target;\n\t\trenderTarget.removeEventListener('dispose', onRenderTargetDispose);\n\t\tdeallocateRenderTarget(renderTarget);\n\t} //\n\n\n\tfunction deallocateTexture(texture) {\n\t\tconst textureProperties = properties.get(texture);\n\t\tif (textureProperties.__webglInit === undefined) return; // check if it's necessary to remove the WebGLTexture object\n\n\t\tconst source = texture.source;\n\n\t\tconst webglTextures = _sources.get(source);\n\n\t\tif (webglTextures) {\n\t\t\tconst webglTexture = webglTextures[textureProperties.__cacheKey];\n\t\t\twebglTexture.usedTimes--; // the WebGLTexture object is not used anymore, remove it\n\n\t\t\tif (webglTexture.usedTimes === 0) {\n\t\t\t\tdeleteTexture(texture);\n\t\t\t} // remove the weak map entry if no WebGLTexture uses the source anymore\n\n\n\t\t\tif (Object.keys(webglTextures).length === 0) {\n\t\t\t\t_sources.delete(source);\n\t\t\t}\n\t\t}\n\n\t\tproperties.remove(texture);\n\t}\n\n\tfunction deleteTexture(texture) {\n\t\tconst textureProperties = properties.get(texture);\n\n\t\t_gl.deleteTexture(textureProperties.__webglTexture);\n\n\t\tconst source = texture.source;\n\n\t\tconst webglTextures = _sources.get(source);\n\n\t\tdelete webglTextures[textureProperties.__cacheKey];\n\t\tinfo.memory.textures--;\n\t}\n\n\tfunction deallocateRenderTarget(renderTarget) {\n\t\tconst texture = renderTarget.texture;\n\t\tconst renderTargetProperties = properties.get(renderTarget);\n\t\tconst textureProperties = properties.get(texture);\n\n\t\tif (textureProperties.__webglTexture !== undefined) {\n\t\t\t_gl.deleteTexture(textureProperties.__webglTexture);\n\n\t\t\tinfo.memory.textures--;\n\t\t}\n\n\t\tif (renderTarget.depthTexture) {\n\t\t\trenderTarget.depthTexture.dispose();\n\t\t}\n\n\t\tif (renderTarget.isWebGLCubeRenderTarget) {\n\t\t\tfor (let i = 0; i < 6; i++) {\n\t\t\t\t_gl.deleteFramebuffer(renderTargetProperties.__webglFramebuffer[i]);\n\n\t\t\t\tif (renderTargetProperties.__webglDepthbuffer) _gl.deleteRenderbuffer(renderTargetProperties.__webglDepthbuffer[i]);\n\t\t\t}\n\t\t} else {\n\t\t\t_gl.deleteFramebuffer(renderTargetProperties.__webglFramebuffer);\n\n\t\t\tif (renderTargetProperties.__webglDepthbuffer) _gl.deleteRenderbuffer(renderTargetProperties.__webglDepthbuffer);\n\t\t\tif (renderTargetProperties.__webglMultisampledFramebuffer) _gl.deleteFramebuffer(renderTargetProperties.__webglMultisampledFramebuffer);\n\n\t\t\tif (renderTargetProperties.__webglColorRenderbuffer) {\n\t\t\t\tfor (let i = 0; i < renderTargetProperties.__webglColorRenderbuffer.length; i++) {\n\t\t\t\t\tif (renderTargetProperties.__webglColorRenderbuffer[i]) _gl.deleteRenderbuffer(renderTargetProperties.__webglColorRenderbuffer[i]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (renderTargetProperties.__webglDepthRenderbuffer) _gl.deleteRenderbuffer(renderTargetProperties.__webglDepthRenderbuffer);\n\t\t}\n\n\t\tif (renderTarget.isWebGLMultipleRenderTargets) {\n\t\t\tfor (let i = 0, il = texture.length; i < il; i++) {\n\t\t\t\tconst attachmentProperties = properties.get(texture[i]);\n\n\t\t\t\tif (attachmentProperties.__webglTexture) {\n\t\t\t\t\t_gl.deleteTexture(attachmentProperties.__webglTexture);\n\n\t\t\t\t\tinfo.memory.textures--;\n\t\t\t\t}\n\n\t\t\t\tproperties.remove(texture[i]);\n\t\t\t}\n\t\t}\n\n\t\tproperties.remove(texture);\n\t\tproperties.remove(renderTarget);\n\t} //\n\n\n\tlet textureUnits = 0;\n\n\tfunction resetTextureUnits() {\n\t\ttextureUnits = 0;\n\t}\n\n\tfunction allocateTextureUnit() {\n\t\tconst textureUnit = textureUnits;\n\n\t\tif (textureUnit >= maxTextures) {\n\t\t\tconsole.warn('THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + maxTextures);\n\t\t}\n\n\t\ttextureUnits += 1;\n\t\treturn textureUnit;\n\t}\n\n\tfunction getTextureCacheKey(texture) {\n\t\tconst array = [];\n\t\tarray.push(texture.wrapS);\n\t\tarray.push(texture.wrapT);\n\t\tarray.push(texture.magFilter);\n\t\tarray.push(texture.minFilter);\n\t\tarray.push(texture.anisotropy);\n\t\tarray.push(texture.internalFormat);\n\t\tarray.push(texture.format);\n\t\tarray.push(texture.type);\n\t\tarray.push(texture.generateMipmaps);\n\t\tarray.push(texture.premultiplyAlpha);\n\t\tarray.push(texture.flipY);\n\t\tarray.push(texture.unpackAlignment);\n\t\tarray.push(texture.encoding);\n\t\treturn array.join();\n\t} //\n\n\n\tfunction setTexture2D(texture, slot) {\n\t\tconst textureProperties = properties.get(texture);\n\t\tif (texture.isVideoTexture) updateVideoTexture(texture);\n\n\t\tif (texture.isRenderTargetTexture === false && texture.version > 0 && textureProperties.__version !== texture.version) {\n\t\t\tconst image = texture.image;\n\n\t\t\tif (image === null) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: Texture marked for update but no image data found.');\n\t\t\t} else if (image.complete === false) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: Texture marked for update but image is incomplete');\n\t\t\t} else {\n\t\t\t\tuploadTexture(textureProperties, texture, slot);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tstate.bindTexture(_gl.TEXTURE_2D, textureProperties.__webglTexture, _gl.TEXTURE0 + slot);\n\t}\n\n\tfunction setTexture2DArray(texture, slot) {\n\t\tconst textureProperties = properties.get(texture);\n\n\t\tif (texture.version > 0 && textureProperties.__version !== texture.version) {\n\t\t\tuploadTexture(textureProperties, texture, slot);\n\t\t\treturn;\n\t\t}\n\n\t\tstate.bindTexture(_gl.TEXTURE_2D_ARRAY, textureProperties.__webglTexture, _gl.TEXTURE0 + slot);\n\t}\n\n\tfunction setTexture3D(texture, slot) {\n\t\tconst textureProperties = properties.get(texture);\n\n\t\tif (texture.version > 0 && textureProperties.__version !== texture.version) {\n\t\t\tuploadTexture(textureProperties, texture, slot);\n\t\t\treturn;\n\t\t}\n\n\t\tstate.bindTexture(_gl.TEXTURE_3D, textureProperties.__webglTexture, _gl.TEXTURE0 + slot);\n\t}\n\n\tfunction setTextureCube(texture, slot) {\n\t\tconst textureProperties = properties.get(texture);\n\n\t\tif (texture.version > 0 && textureProperties.__version !== texture.version) {\n\t\t\tuploadCubeTexture(textureProperties, texture, slot);\n\t\t\treturn;\n\t\t}\n\n\t\tstate.bindTexture(_gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture, _gl.TEXTURE0 + slot);\n\t}\n\n\tconst wrappingToGL = {\n\t\t[RepeatWrapping]: _gl.REPEAT,\n\t\t[ClampToEdgeWrapping]: _gl.CLAMP_TO_EDGE,\n\t\t[MirroredRepeatWrapping]: _gl.MIRRORED_REPEAT\n\t};\n\tconst filterToGL = {\n\t\t[NearestFilter]: _gl.NEAREST,\n\t\t[NearestMipmapNearestFilter]: _gl.NEAREST_MIPMAP_NEAREST,\n\t\t[NearestMipmapLinearFilter]: _gl.NEAREST_MIPMAP_LINEAR,\n\t\t[LinearFilter]: _gl.LINEAR,\n\t\t[LinearMipmapNearestFilter]: _gl.LINEAR_MIPMAP_NEAREST,\n\t\t[LinearMipmapLinearFilter]: _gl.LINEAR_MIPMAP_LINEAR\n\t};\n\n\tfunction setTextureParameters(textureType, texture, supportsMips) {\n\t\tif (supportsMips) {\n\t\t\t_gl.texParameteri(textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[texture.wrapS]);\n\n\t\t\t_gl.texParameteri(textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[texture.wrapT]);\n\n\t\t\tif (textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY) {\n\t\t\t\t_gl.texParameteri(textureType, _gl.TEXTURE_WRAP_R, wrappingToGL[texture.wrapR]);\n\t\t\t}\n\n\t\t\t_gl.texParameteri(textureType, _gl.TEXTURE_MAG_FILTER, filterToGL[texture.magFilter]);\n\n\t\t\t_gl.texParameteri(textureType, _gl.TEXTURE_MIN_FILTER, filterToGL[texture.minFilter]);\n\t\t} else {\n\t\t\t_gl.texParameteri(textureType, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE);\n\n\t\t\t_gl.texParameteri(textureType, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE);\n\n\t\t\tif (textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY) {\n\t\t\t\t_gl.texParameteri(textureType, _gl.TEXTURE_WRAP_R, _gl.CLAMP_TO_EDGE);\n\t\t\t}\n\n\t\t\tif (texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.');\n\t\t\t}\n\n\t\t\t_gl.texParameteri(textureType, _gl.TEXTURE_MAG_FILTER, filterFallback(texture.magFilter));\n\n\t\t\t_gl.texParameteri(textureType, _gl.TEXTURE_MIN_FILTER, filterFallback(texture.minFilter));\n\n\t\t\tif (texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.');\n\t\t\t}\n\t\t}\n\n\t\tif (extensions.has('EXT_texture_filter_anisotropic') === true) {\n\t\t\tconst extension = extensions.get('EXT_texture_filter_anisotropic');\n\t\t\tif (texture.type === FloatType && extensions.has('OES_texture_float_linear') === false) return; // verify extension for WebGL 1 and WebGL 2\n\n\t\t\tif (isWebGL2 === false && texture.type === HalfFloatType && extensions.has('OES_texture_half_float_linear') === false) return; // verify extension for WebGL 1 only\n\n\t\t\tif (texture.anisotropy > 1 || properties.get(texture).__currentAnisotropy) {\n\t\t\t\t_gl.texParameterf(textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(texture.anisotropy, capabilities.getMaxAnisotropy()));\n\n\t\t\t\tproperties.get(texture).__currentAnisotropy = texture.anisotropy;\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction initTexture(textureProperties, texture) {\n\t\tlet forceUpload = false;\n\n\t\tif (textureProperties.__webglInit === undefined) {\n\t\t\ttextureProperties.__webglInit = true;\n\t\t\ttexture.addEventListener('dispose', onTextureDispose);\n\t\t} // create Source <-> WebGLTextures mapping if necessary\n\n\n\t\tconst source = texture.source;\n\n\t\tlet webglTextures = _sources.get(source);\n\n\t\tif (webglTextures === undefined) {\n\t\t\twebglTextures = {};\n\n\t\t\t_sources.set(source, webglTextures);\n\t\t} // check if there is already a WebGLTexture object for the given texture parameters\n\n\n\t\tconst textureCacheKey = getTextureCacheKey(texture);\n\n\t\tif (textureCacheKey !== textureProperties.__cacheKey) {\n\t\t\t// if not, create a new instance of WebGLTexture\n\t\t\tif (webglTextures[textureCacheKey] === undefined) {\n\t\t\t\t// create new entry\n\t\t\t\twebglTextures[textureCacheKey] = {\n\t\t\t\t\ttexture: _gl.createTexture(),\n\t\t\t\t\tusedTimes: 0\n\t\t\t\t};\n\t\t\t\tinfo.memory.textures++; // when a new instance of WebGLTexture was created, a texture upload is required\n\t\t\t\t// even if the image contents are identical\n\n\t\t\t\tforceUpload = true;\n\t\t\t}\n\n\t\t\twebglTextures[textureCacheKey].usedTimes++; // every time the texture cache key changes, it's necessary to check if an instance of\n\t\t\t// WebGLTexture can be deleted in order to avoid a memory leak.\n\n\t\t\tconst webglTexture = webglTextures[textureProperties.__cacheKey];\n\n\t\t\tif (webglTexture !== undefined) {\n\t\t\t\twebglTextures[textureProperties.__cacheKey].usedTimes--;\n\n\t\t\t\tif (webglTexture.usedTimes === 0) {\n\t\t\t\t\tdeleteTexture(texture);\n\t\t\t\t}\n\t\t\t} // store references to cache key and WebGLTexture object\n\n\n\t\t\ttextureProperties.__cacheKey = textureCacheKey;\n\t\t\ttextureProperties.__webglTexture = webglTextures[textureCacheKey].texture;\n\t\t}\n\n\t\treturn forceUpload;\n\t}\n\n\tfunction uploadTexture(textureProperties, texture, slot) {\n\t\tlet textureType = _gl.TEXTURE_2D;\n\t\tif (texture.isDataArrayTexture) textureType = _gl.TEXTURE_2D_ARRAY;\n\t\tif (texture.isData3DTexture) textureType = _gl.TEXTURE_3D;\n\t\tconst forceUpload = initTexture(textureProperties, texture);\n\t\tconst source = texture.source;\n\t\tstate.bindTexture(textureType, textureProperties.__webglTexture, _gl.TEXTURE0 + slot);\n\t\tconst sourceProperties = properties.get(source);\n\n\t\tif (source.version !== sourceProperties.__version || forceUpload === true) {\n\t\t\tstate.activeTexture(_gl.TEXTURE0 + slot);\n\n\t\t\t_gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);\n\n\t\t\t_gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha);\n\n\t\t\t_gl.pixelStorei(_gl.UNPACK_ALIGNMENT, texture.unpackAlignment);\n\n\t\t\t_gl.pixelStorei(_gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, _gl.NONE);\n\n\t\t\tconst needsPowerOfTwo = textureNeedsPowerOfTwo(texture) && isPowerOfTwo$1(texture.image) === false;\n\t\t\tlet image = resizeImage(texture.image, needsPowerOfTwo, false, maxTextureSize);\n\t\t\timage = verifyColorSpace(texture, image);\n\t\t\tconst supportsMips = isPowerOfTwo$1(image) || isWebGL2,\n\t\t\t\t\t\tglFormat = utils.convert(texture.format, texture.encoding);\n\t\t\tlet glType = utils.convert(texture.type),\n\t\t\t\t\tglInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding, texture.isVideoTexture);\n\t\t\tsetTextureParameters(textureType, texture, supportsMips);\n\t\t\tlet mipmap;\n\t\t\tconst mipmaps = texture.mipmaps;\n\t\t\tconst useTexStorage = isWebGL2 && texture.isVideoTexture !== true;\n\t\t\tconst allocateMemory = sourceProperties.__version === undefined || forceUpload === true;\n\t\t\tconst levels = getMipLevels(texture, image, supportsMips);\n\n\t\t\tif (texture.isDepthTexture) {\n\t\t\t\t// populate depth texture with dummy data\n\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT;\n\n\t\t\t\tif (isWebGL2) {\n\t\t\t\t\tif (texture.type === FloatType) {\n\t\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT32F;\n\t\t\t\t\t} else if (texture.type === UnsignedIntType) {\n\t\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT24;\n\t\t\t\t\t} else if (texture.type === UnsignedInt248Type) {\n\t\t\t\t\t\tglInternalFormat = _gl.DEPTH24_STENCIL8;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT16; // WebGL2 requires sized internalformat for glTexImage2D\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (texture.type === FloatType) {\n\t\t\t\t\t\tconsole.error('WebGLRenderer: Floating point depth texture requires WebGL2.');\n\t\t\t\t\t}\n\t\t\t\t} // validation checks for WebGL 1\n\n\n\t\t\t\tif (texture.format === DepthFormat && glInternalFormat === _gl.DEPTH_COMPONENT) {\n\t\t\t\t\t// The error INVALID_OPERATION is generated by texImage2D if format and internalformat are\n\t\t\t\t\t// DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT\n\t\t\t\t\t// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)\n\t\t\t\t\tif (texture.type !== UnsignedShortType && texture.type !== UnsignedIntType) {\n\t\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.');\n\t\t\t\t\t\ttexture.type = UnsignedIntType;\n\t\t\t\t\t\tglType = utils.convert(texture.type);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (texture.format === DepthStencilFormat && glInternalFormat === _gl.DEPTH_COMPONENT) {\n\t\t\t\t\t// Depth stencil textures need the DEPTH_STENCIL internal format\n\t\t\t\t\t// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)\n\t\t\t\t\tglInternalFormat = _gl.DEPTH_STENCIL; // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are\n\t\t\t\t\t// DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL.\n\t\t\t\t\t// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)\n\n\t\t\t\t\tif (texture.type !== UnsignedInt248Type) {\n\t\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.');\n\t\t\t\t\t\ttexture.type = UnsignedInt248Type;\n\t\t\t\t\t\tglType = utils.convert(texture.type);\n\t\t\t\t\t}\n\t\t\t\t} //\n\n\n\t\t\t\tif (allocateMemory) {\n\t\t\t\t\tif (useTexStorage) {\n\t\t\t\t\t\tstate.texStorage2D(_gl.TEXTURE_2D, 1, glInternalFormat, image.width, image.height);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstate.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (texture.isDataTexture) {\n\t\t\t\t// use manually created mipmaps if available\n\t\t\t\t// if there are no manual mipmaps\n\t\t\t\t// set 0 level mipmap and then use GL to generate other mipmap levels\n\t\t\t\tif (mipmaps.length > 0 && supportsMips) {\n\t\t\t\t\tif (useTexStorage && allocateMemory) {\n\t\t\t\t\t\tstate.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[0].width, mipmaps[0].height);\n\t\t\t\t\t}\n\n\t\t\t\t\tfor (let i = 0, il = mipmaps.length; i < il; i++) {\n\t\t\t\t\t\tmipmap = mipmaps[i];\n\n\t\t\t\t\t\tif (useTexStorage) {\n\t\t\t\t\t\t\tstate.texSubImage2D(_gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tstate.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\ttexture.generateMipmaps = false;\n\t\t\t\t} else {\n\t\t\t\t\tif (useTexStorage) {\n\t\t\t\t\t\tif (allocateMemory) {\n\t\t\t\t\t\t\tstate.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tstate.texSubImage2D(_gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, glFormat, glType, image.data);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstate.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (texture.isCompressedTexture) {\n\t\t\t\tif (useTexStorage && allocateMemory) {\n\t\t\t\t\tstate.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[0].width, mipmaps[0].height);\n\t\t\t\t}\n\n\t\t\t\tfor (let i = 0, il = mipmaps.length; i < il; i++) {\n\t\t\t\t\tmipmap = mipmaps[i];\n\n\t\t\t\t\tif (texture.format !== RGBAFormat) {\n\t\t\t\t\t\tif (glFormat !== null) {\n\t\t\t\t\t\t\tif (useTexStorage) {\n\t\t\t\t\t\t\t\tstate.compressedTexSubImage2D(_gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tstate.compressedTexImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()');\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (useTexStorage) {\n\t\t\t\t\t\t\tstate.texSubImage2D(_gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tstate.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (texture.isDataArrayTexture) {\n\t\t\t\tif (useTexStorage) {\n\t\t\t\t\tif (allocateMemory) {\n\t\t\t\t\t\tstate.texStorage3D(_gl.TEXTURE_2D_ARRAY, levels, glInternalFormat, image.width, image.height, image.depth);\n\t\t\t\t\t}\n\n\t\t\t\t\tstate.texSubImage3D(_gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data);\n\t\t\t\t} else {\n\t\t\t\t\tstate.texImage3D(_gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);\n\t\t\t\t}\n\t\t\t} else if (texture.isData3DTexture) {\n\t\t\t\tif (useTexStorage) {\n\t\t\t\t\tif (allocateMemory) {\n\t\t\t\t\t\tstate.texStorage3D(_gl.TEXTURE_3D, levels, glInternalFormat, image.width, image.height, image.depth);\n\t\t\t\t\t}\n\n\t\t\t\t\tstate.texSubImage3D(_gl.TEXTURE_3D, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data);\n\t\t\t\t} else {\n\t\t\t\t\tstate.texImage3D(_gl.TEXTURE_3D, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);\n\t\t\t\t}\n\t\t\t} else if (texture.isFramebufferTexture) {\n\t\t\t\tif (allocateMemory) {\n\t\t\t\t\tif (useTexStorage) {\n\t\t\t\t\t\tstate.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlet width = image.width,\n\t\t\t\t\t\t\t\theight = image.height;\n\n\t\t\t\t\t\tfor (let i = 0; i < levels; i++) {\n\t\t\t\t\t\t\tstate.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, width, height, 0, glFormat, glType, null);\n\t\t\t\t\t\t\twidth >>= 1;\n\t\t\t\t\t\t\theight >>= 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// regular Texture (image, video, canvas)\n\t\t\t\t// use manually created mipmaps if available\n\t\t\t\t// if there are no manual mipmaps\n\t\t\t\t// set 0 level mipmap and then use GL to generate other mipmap levels\n\t\t\t\tif (mipmaps.length > 0 && supportsMips) {\n\t\t\t\t\tif (useTexStorage && allocateMemory) {\n\t\t\t\t\t\tstate.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[0].width, mipmaps[0].height);\n\t\t\t\t\t}\n\n\t\t\t\t\tfor (let i = 0, il = mipmaps.length; i < il; i++) {\n\t\t\t\t\t\tmipmap = mipmaps[i];\n\n\t\t\t\t\t\tif (useTexStorage) {\n\t\t\t\t\t\t\tstate.texSubImage2D(_gl.TEXTURE_2D, i, 0, 0, glFormat, glType, mipmap);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tstate.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, glFormat, glType, mipmap);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\ttexture.generateMipmaps = false;\n\t\t\t\t} else {\n\t\t\t\t\tif (useTexStorage) {\n\t\t\t\t\t\tif (allocateMemory) {\n\t\t\t\t\t\t\tstate.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tstate.texSubImage2D(_gl.TEXTURE_2D, 0, 0, 0, glFormat, glType, image);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstate.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, glFormat, glType, image);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (textureNeedsGenerateMipmaps(texture, supportsMips)) {\n\t\t\t\tgenerateMipmap(textureType);\n\t\t\t}\n\n\t\t\tsourceProperties.__version = source.version;\n\t\t\tif (texture.onUpdate) texture.onUpdate(texture);\n\t\t}\n\n\t\ttextureProperties.__version = texture.version;\n\t}\n\n\tfunction uploadCubeTexture(textureProperties, texture, slot) {\n\t\tif (texture.image.length !== 6) return;\n\t\tconst forceUpload = initTexture(textureProperties, texture);\n\t\tconst source = texture.source;\n\t\tstate.bindTexture(_gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture, _gl.TEXTURE0 + slot);\n\t\tconst sourceProperties = properties.get(source);\n\n\t\tif (source.version !== sourceProperties.__version || forceUpload === true) {\n\t\t\tstate.activeTexture(_gl.TEXTURE0 + slot);\n\n\t\t\t_gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);\n\n\t\t\t_gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha);\n\n\t\t\t_gl.pixelStorei(_gl.UNPACK_ALIGNMENT, texture.unpackAlignment);\n\n\t\t\t_gl.pixelStorei(_gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, _gl.NONE);\n\n\t\t\tconst isCompressed = texture.isCompressedTexture || texture.image[0].isCompressedTexture;\n\t\t\tconst isDataTexture = texture.image[0] && texture.image[0].isDataTexture;\n\t\t\tconst cubeImage = [];\n\n\t\t\tfor (let i = 0; i < 6; i++) {\n\t\t\t\tif (!isCompressed && !isDataTexture) {\n\t\t\t\t\tcubeImage[i] = resizeImage(texture.image[i], false, true, maxCubemapSize);\n\t\t\t\t} else {\n\t\t\t\t\tcubeImage[i] = isDataTexture ? texture.image[i].image : texture.image[i];\n\t\t\t\t}\n\n\t\t\t\tcubeImage[i] = verifyColorSpace(texture, cubeImage[i]);\n\t\t\t}\n\n\t\t\tconst image = cubeImage[0],\n\t\t\t\t\t\tsupportsMips = isPowerOfTwo$1(image) || isWebGL2,\n\t\t\t\t\t\tglFormat = utils.convert(texture.format, texture.encoding),\n\t\t\t\t\t\tglType = utils.convert(texture.type),\n\t\t\t\t\t\tglInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);\n\t\t\tconst useTexStorage = isWebGL2 && texture.isVideoTexture !== true;\n\t\t\tconst allocateMemory = sourceProperties.__version === undefined || forceUpload === true;\n\t\t\tlet levels = getMipLevels(texture, image, supportsMips);\n\t\t\tsetTextureParameters(_gl.TEXTURE_CUBE_MAP, texture, supportsMips);\n\t\t\tlet mipmaps;\n\n\t\t\tif (isCompressed) {\n\t\t\t\tif (useTexStorage && allocateMemory) {\n\t\t\t\t\tstate.texStorage2D(_gl.TEXTURE_CUBE_MAP, levels, glInternalFormat, image.width, image.height);\n\t\t\t\t}\n\n\t\t\t\tfor (let i = 0; i < 6; i++) {\n\t\t\t\t\tmipmaps = cubeImage[i].mipmaps;\n\n\t\t\t\t\tfor (let j = 0; j < mipmaps.length; j++) {\n\t\t\t\t\t\tconst mipmap = mipmaps[j];\n\n\t\t\t\t\t\tif (texture.format !== RGBAFormat) {\n\t\t\t\t\t\t\tif (glFormat !== null) {\n\t\t\t\t\t\t\t\tif (useTexStorage) {\n\t\t\t\t\t\t\t\t\tstate.compressedTexSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tstate.compressedTexImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (useTexStorage) {\n\t\t\t\t\t\t\t\tstate.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tstate.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tmipmaps = texture.mipmaps;\n\n\t\t\t\tif (useTexStorage && allocateMemory) {\n\t\t\t\t\t// TODO: Uniformly handle mipmap definitions\n\t\t\t\t\t// Normal textures and compressed cube textures define base level + mips with their mipmap array\n\t\t\t\t\t// Uncompressed cube textures use their mipmap array only for mips (no base level)\n\t\t\t\t\tif (mipmaps.length > 0) levels++;\n\t\t\t\t\tstate.texStorage2D(_gl.TEXTURE_CUBE_MAP, levels, glInternalFormat, cubeImage[0].width, cubeImage[0].height);\n\t\t\t\t}\n\n\t\t\t\tfor (let i = 0; i < 6; i++) {\n\t\t\t\t\tif (isDataTexture) {\n\t\t\t\t\t\tif (useTexStorage) {\n\t\t\t\t\t\t\tstate.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, cubeImage[i].width, cubeImage[i].height, glFormat, glType, cubeImage[i].data);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tstate.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, cubeImage[i].width, cubeImage[i].height, 0, glFormat, glType, cubeImage[i].data);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (let j = 0; j < mipmaps.length; j++) {\n\t\t\t\t\t\t\tconst mipmap = mipmaps[j];\n\t\t\t\t\t\t\tconst mipmapImage = mipmap.image[i].image;\n\n\t\t\t\t\t\t\tif (useTexStorage) {\n\t\t\t\t\t\t\t\tstate.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, 0, 0, mipmapImage.width, mipmapImage.height, glFormat, glType, mipmapImage.data);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tstate.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (useTexStorage) {\n\t\t\t\t\t\t\tstate.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, glFormat, glType, cubeImage[i]);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tstate.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, glFormat, glType, cubeImage[i]);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (let j = 0; j < mipmaps.length; j++) {\n\t\t\t\t\t\t\tconst mipmap = mipmaps[j];\n\n\t\t\t\t\t\t\tif (useTexStorage) {\n\t\t\t\t\t\t\t\tstate.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, 0, 0, glFormat, glType, mipmap.image[i]);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tstate.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[i]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (textureNeedsGenerateMipmaps(texture, supportsMips)) {\n\t\t\t\t// We assume images for cube map have the same size.\n\t\t\t\tgenerateMipmap(_gl.TEXTURE_CUBE_MAP);\n\t\t\t}\n\n\t\t\tsourceProperties.__version = source.version;\n\t\t\tif (texture.onUpdate) texture.onUpdate(texture);\n\t\t}\n\n\t\ttextureProperties.__version = texture.version;\n\t} // Render targets\n\t// Setup storage for target texture and bind it to correct framebuffer\n\n\n\tfunction setupFrameBufferTexture(framebuffer, renderTarget, texture, attachment, textureTarget) {\n\t\tconst glFormat = utils.convert(texture.format, texture.encoding);\n\t\tconst glType = utils.convert(texture.type);\n\t\tconst glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);\n\t\tconst renderTargetProperties = properties.get(renderTarget);\n\n\t\tif (!renderTargetProperties.__hasExternalTextures) {\n\t\t\tif (textureTarget === _gl.TEXTURE_3D || textureTarget === _gl.TEXTURE_2D_ARRAY) {\n\t\t\t\tstate.texImage3D(textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, renderTarget.depth, 0, glFormat, glType, null);\n\t\t\t} else {\n\t\t\t\tstate.texImage2D(textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null);\n\t\t\t}\n\t\t}\n\n\t\tstate.bindFramebuffer(_gl.FRAMEBUFFER, framebuffer);\n\n\t\tif (useMultisampledRTT(renderTarget)) {\n\t\t\tmultisampledRTTExt.framebufferTexture2DMultisampleEXT(_gl.FRAMEBUFFER, attachment, textureTarget, properties.get(texture).__webglTexture, 0, getRenderTargetSamples(renderTarget));\n\t\t} else {\n\t\t\t_gl.framebufferTexture2D(_gl.FRAMEBUFFER, attachment, textureTarget, properties.get(texture).__webglTexture, 0);\n\t\t}\n\n\t\tstate.bindFramebuffer(_gl.FRAMEBUFFER, null);\n\t} // Setup storage for internal depth/stencil buffers and bind to correct framebuffer\n\n\n\tfunction setupRenderBufferStorage(renderbuffer, renderTarget, isMultisample) {\n\t\t_gl.bindRenderbuffer(_gl.RENDERBUFFER, renderbuffer);\n\n\t\tif (renderTarget.depthBuffer && !renderTarget.stencilBuffer) {\n\t\t\tlet glInternalFormat = _gl.DEPTH_COMPONENT16;\n\n\t\t\tif (isMultisample || useMultisampledRTT(renderTarget)) {\n\t\t\t\tconst depthTexture = renderTarget.depthTexture;\n\n\t\t\t\tif (depthTexture && depthTexture.isDepthTexture) {\n\t\t\t\t\tif (depthTexture.type === FloatType) {\n\t\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT32F;\n\t\t\t\t\t} else if (depthTexture.type === UnsignedIntType) {\n\t\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT24;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst samples = getRenderTargetSamples(renderTarget);\n\n\t\t\t\tif (useMultisampledRTT(renderTarget)) {\n\t\t\t\t\tmultisampledRTTExt.renderbufferStorageMultisampleEXT(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);\n\t\t\t\t} else {\n\t\t\t\t\t_gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t_gl.renderbufferStorage(_gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height);\n\t\t\t}\n\n\t\t\t_gl.framebufferRenderbuffer(_gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer);\n\t\t} else if (renderTarget.depthBuffer && renderTarget.stencilBuffer) {\n\t\t\tconst samples = getRenderTargetSamples(renderTarget);\n\n\t\t\tif (isMultisample && useMultisampledRTT(renderTarget) === false) {\n\t\t\t\t_gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, _gl.DEPTH24_STENCIL8, renderTarget.width, renderTarget.height);\n\t\t\t} else if (useMultisampledRTT(renderTarget)) {\n\t\t\t\tmultisampledRTTExt.renderbufferStorageMultisampleEXT(_gl.RENDERBUFFER, samples, _gl.DEPTH24_STENCIL8, renderTarget.width, renderTarget.height);\n\t\t\t} else {\n\t\t\t\t_gl.renderbufferStorage(_gl.RENDERBUFFER, _gl.DEPTH_STENCIL, renderTarget.width, renderTarget.height);\n\t\t\t}\n\n\t\t\t_gl.framebufferRenderbuffer(_gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer);\n\t\t} else {\n\t\t\tconst textures = renderTarget.isWebGLMultipleRenderTargets === true ? renderTarget.texture : [renderTarget.texture];\n\n\t\t\tfor (let i = 0; i < textures.length; i++) {\n\t\t\t\tconst texture = textures[i];\n\t\t\t\tconst glFormat = utils.convert(texture.format, texture.encoding);\n\t\t\t\tconst glType = utils.convert(texture.type);\n\t\t\t\tconst glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);\n\t\t\t\tconst samples = getRenderTargetSamples(renderTarget);\n\n\t\t\t\tif (isMultisample && useMultisampledRTT(renderTarget) === false) {\n\t\t\t\t\t_gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);\n\t\t\t\t} else if (useMultisampledRTT(renderTarget)) {\n\t\t\t\t\tmultisampledRTTExt.renderbufferStorageMultisampleEXT(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);\n\t\t\t\t} else {\n\t\t\t\t\t_gl.renderbufferStorage(_gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t_gl.bindRenderbuffer(_gl.RENDERBUFFER, null);\n\t} // Setup resources for a Depth Texture for a FBO (needs an extension)\n\n\n\tfunction setupDepthTexture(framebuffer, renderTarget) {\n\t\tconst isCube = renderTarget && renderTarget.isWebGLCubeRenderTarget;\n\t\tif (isCube) throw new Error('Depth Texture with cube render targets is not supported');\n\t\tstate.bindFramebuffer(_gl.FRAMEBUFFER, framebuffer);\n\n\t\tif (!(renderTarget.depthTexture && renderTarget.depthTexture.isDepthTexture)) {\n\t\t\tthrow new Error('renderTarget.depthTexture must be an instance of THREE.DepthTexture');\n\t\t} // upload an empty depth texture with framebuffer size\n\n\n\t\tif (!properties.get(renderTarget.depthTexture).__webglTexture || renderTarget.depthTexture.image.width !== renderTarget.width || renderTarget.depthTexture.image.height !== renderTarget.height) {\n\t\t\trenderTarget.depthTexture.image.width = renderTarget.width;\n\t\t\trenderTarget.depthTexture.image.height = renderTarget.height;\n\t\t\trenderTarget.depthTexture.needsUpdate = true;\n\t\t}\n\n\t\tsetTexture2D(renderTarget.depthTexture, 0);\n\n\t\tconst webglDepthTexture = properties.get(renderTarget.depthTexture).__webglTexture;\n\n\t\tconst samples = getRenderTargetSamples(renderTarget);\n\n\t\tif (renderTarget.depthTexture.format === DepthFormat) {\n\t\t\tif (useMultisampledRTT(renderTarget)) {\n\t\t\t\tmultisampledRTTExt.framebufferTexture2DMultisampleEXT(_gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples);\n\t\t\t} else {\n\t\t\t\t_gl.framebufferTexture2D(_gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0);\n\t\t\t}\n\t\t} else if (renderTarget.depthTexture.format === DepthStencilFormat) {\n\t\t\tif (useMultisampledRTT(renderTarget)) {\n\t\t\t\tmultisampledRTTExt.framebufferTexture2DMultisampleEXT(_gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples);\n\t\t\t} else {\n\t\t\t\t_gl.framebufferTexture2D(_gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new Error('Unknown depthTexture format');\n\t\t}\n\t} // Setup GL resources for a non-texture depth buffer\n\n\n\tfunction setupDepthRenderbuffer(renderTarget) {\n\t\tconst renderTargetProperties = properties.get(renderTarget);\n\t\tconst isCube = renderTarget.isWebGLCubeRenderTarget === true;\n\n\t\tif (renderTarget.depthTexture && !renderTargetProperties.__autoAllocateDepthBuffer) {\n\t\t\tif (isCube) throw new Error('target.depthTexture not supported in Cube render targets');\n\t\t\tsetupDepthTexture(renderTargetProperties.__webglFramebuffer, renderTarget);\n\t\t} else {\n\t\t\tif (isCube) {\n\t\t\t\trenderTargetProperties.__webglDepthbuffer = [];\n\n\t\t\t\tfor (let i = 0; i < 6; i++) {\n\t\t\t\t\tstate.bindFramebuffer(_gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer[i]);\n\t\t\t\t\trenderTargetProperties.__webglDepthbuffer[i] = _gl.createRenderbuffer();\n\t\t\t\t\tsetupRenderBufferStorage(renderTargetProperties.__webglDepthbuffer[i], renderTarget, false);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tstate.bindFramebuffer(_gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer);\n\t\t\t\trenderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer();\n\t\t\t\tsetupRenderBufferStorage(renderTargetProperties.__webglDepthbuffer, renderTarget, false);\n\t\t\t}\n\t\t}\n\n\t\tstate.bindFramebuffer(_gl.FRAMEBUFFER, null);\n\t} // rebind framebuffer with external textures\n\n\n\tfunction rebindTextures(renderTarget, colorTexture, depthTexture) {\n\t\tconst renderTargetProperties = properties.get(renderTarget);\n\n\t\tif (colorTexture !== undefined) {\n\t\t\tsetupFrameBufferTexture(renderTargetProperties.__webglFramebuffer, renderTarget, renderTarget.texture, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D);\n\t\t}\n\n\t\tif (depthTexture !== undefined) {\n\t\t\tsetupDepthRenderbuffer(renderTarget);\n\t\t}\n\t} // Set up GL resources for the render target\n\n\n\tfunction setupRenderTarget(renderTarget) {\n\t\tconst texture = renderTarget.texture;\n\t\tconst renderTargetProperties = properties.get(renderTarget);\n\t\tconst textureProperties = properties.get(texture);\n\t\trenderTarget.addEventListener('dispose', onRenderTargetDispose);\n\n\t\tif (renderTarget.isWebGLMultipleRenderTargets !== true) {\n\t\t\tif (textureProperties.__webglTexture === undefined) {\n\t\t\t\ttextureProperties.__webglTexture = _gl.createTexture();\n\t\t\t}\n\n\t\t\ttextureProperties.__version = texture.version;\n\t\t\tinfo.memory.textures++;\n\t\t}\n\n\t\tconst isCube = renderTarget.isWebGLCubeRenderTarget === true;\n\t\tconst isMultipleRenderTargets = renderTarget.isWebGLMultipleRenderTargets === true;\n\t\tconst supportsMips = isPowerOfTwo$1(renderTarget) || isWebGL2; // Setup framebuffer\n\n\t\tif (isCube) {\n\t\t\trenderTargetProperties.__webglFramebuffer = [];\n\n\t\t\tfor (let i = 0; i < 6; i++) {\n\t\t\t\trenderTargetProperties.__webglFramebuffer[i] = _gl.createFramebuffer();\n\t\t\t}\n\t\t} else {\n\t\t\trenderTargetProperties.__webglFramebuffer = _gl.createFramebuffer();\n\n\t\t\tif (isMultipleRenderTargets) {\n\t\t\t\tif (capabilities.drawBuffers) {\n\t\t\t\t\tconst textures = renderTarget.texture;\n\n\t\t\t\t\tfor (let i = 0, il = textures.length; i < il; i++) {\n\t\t\t\t\t\tconst attachmentProperties = properties.get(textures[i]);\n\n\t\t\t\t\t\tif (attachmentProperties.__webglTexture === undefined) {\n\t\t\t\t\t\t\tattachmentProperties.__webglTexture = _gl.createTexture();\n\t\t\t\t\t\t\tinfo.memory.textures++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.');\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isWebGL2 && renderTarget.samples > 0 && useMultisampledRTT(renderTarget) === false) {\n\t\t\t\tconst textures = isMultipleRenderTargets ? texture : [texture];\n\t\t\t\trenderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();\n\t\t\t\trenderTargetProperties.__webglColorRenderbuffer = [];\n\t\t\t\tstate.bindFramebuffer(_gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer);\n\n\t\t\t\tfor (let i = 0; i < textures.length; i++) {\n\t\t\t\t\tconst texture = textures[i];\n\t\t\t\t\trenderTargetProperties.__webglColorRenderbuffer[i] = _gl.createRenderbuffer();\n\n\t\t\t\t\t_gl.bindRenderbuffer(_gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[i]);\n\n\t\t\t\t\tconst glFormat = utils.convert(texture.format, texture.encoding);\n\t\t\t\t\tconst glType = utils.convert(texture.type);\n\t\t\t\t\tconst glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding, renderTarget.isXRRenderTarget === true);\n\t\t\t\t\tconst samples = getRenderTargetSamples(renderTarget);\n\n\t\t\t\t\t_gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);\n\n\t\t\t\t\t_gl.framebufferRenderbuffer(_gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[i]);\n\t\t\t\t}\n\n\t\t\t\t_gl.bindRenderbuffer(_gl.RENDERBUFFER, null);\n\n\t\t\t\tif (renderTarget.depthBuffer) {\n\t\t\t\t\trenderTargetProperties.__webglDepthRenderbuffer = _gl.createRenderbuffer();\n\t\t\t\t\tsetupRenderBufferStorage(renderTargetProperties.__webglDepthRenderbuffer, renderTarget, true);\n\t\t\t\t}\n\n\t\t\t\tstate.bindFramebuffer(_gl.FRAMEBUFFER, null);\n\t\t\t}\n\t\t} // Setup color buffer\n\n\n\t\tif (isCube) {\n\t\t\tstate.bindTexture(_gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture);\n\t\t\tsetTextureParameters(_gl.TEXTURE_CUBE_MAP, texture, supportsMips);\n\n\t\t\tfor (let i = 0; i < 6; i++) {\n\t\t\t\tsetupFrameBufferTexture(renderTargetProperties.__webglFramebuffer[i], renderTarget, texture, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i);\n\t\t\t}\n\n\t\t\tif (textureNeedsGenerateMipmaps(texture, supportsMips)) {\n\t\t\t\tgenerateMipmap(_gl.TEXTURE_CUBE_MAP);\n\t\t\t}\n\n\t\t\tstate.unbindTexture();\n\t\t} else if (isMultipleRenderTargets) {\n\t\t\tconst textures = renderTarget.texture;\n\n\t\t\tfor (let i = 0, il = textures.length; i < il; i++) {\n\t\t\t\tconst attachment = textures[i];\n\t\t\t\tconst attachmentProperties = properties.get(attachment);\n\t\t\t\tstate.bindTexture(_gl.TEXTURE_2D, attachmentProperties.__webglTexture);\n\t\t\t\tsetTextureParameters(_gl.TEXTURE_2D, attachment, supportsMips);\n\t\t\t\tsetupFrameBufferTexture(renderTargetProperties.__webglFramebuffer, renderTarget, attachment, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D);\n\n\t\t\t\tif (textureNeedsGenerateMipmaps(attachment, supportsMips)) {\n\t\t\t\t\tgenerateMipmap(_gl.TEXTURE_2D);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tstate.unbindTexture();\n\t\t} else {\n\t\t\tlet glTextureType = _gl.TEXTURE_2D;\n\n\t\t\tif (renderTarget.isWebGL3DRenderTarget || renderTarget.isWebGLArrayRenderTarget) {\n\t\t\t\tif (isWebGL2) {\n\t\t\t\t\tglTextureType = renderTarget.isWebGL3DRenderTarget ? _gl.TEXTURE_3D : _gl.TEXTURE_2D_ARRAY;\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error('THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.');\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tstate.bindTexture(glTextureType, textureProperties.__webglTexture);\n\t\t\tsetTextureParameters(glTextureType, texture, supportsMips);\n\t\t\tsetupFrameBufferTexture(renderTargetProperties.__webglFramebuffer, renderTarget, texture, _gl.COLOR_ATTACHMENT0, glTextureType);\n\n\t\t\tif (textureNeedsGenerateMipmaps(texture, supportsMips)) {\n\t\t\t\tgenerateMipmap(glTextureType);\n\t\t\t}\n\n\t\t\tstate.unbindTexture();\n\t\t} // Setup depth and stencil buffers\n\n\n\t\tif (renderTarget.depthBuffer) {\n\t\t\tsetupDepthRenderbuffer(renderTarget);\n\t\t}\n\t}\n\n\tfunction updateRenderTargetMipmap(renderTarget) {\n\t\tconst supportsMips = isPowerOfTwo$1(renderTarget) || isWebGL2;\n\t\tconst textures = renderTarget.isWebGLMultipleRenderTargets === true ? renderTarget.texture : [renderTarget.texture];\n\n\t\tfor (let i = 0, il = textures.length; i < il; i++) {\n\t\t\tconst texture = textures[i];\n\n\t\t\tif (textureNeedsGenerateMipmaps(texture, supportsMips)) {\n\t\t\t\tconst target = renderTarget.isWebGLCubeRenderTarget ? _gl.TEXTURE_CUBE_MAP : _gl.TEXTURE_2D;\n\n\t\t\t\tconst webglTexture = properties.get(texture).__webglTexture;\n\n\t\t\t\tstate.bindTexture(target, webglTexture);\n\t\t\t\tgenerateMipmap(target);\n\t\t\t\tstate.unbindTexture();\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction updateMultisampleRenderTarget(renderTarget) {\n\t\tif (isWebGL2 && renderTarget.samples > 0 && useMultisampledRTT(renderTarget) === false) {\n\t\t\tconst textures = renderTarget.isWebGLMultipleRenderTargets ? renderTarget.texture : [renderTarget.texture];\n\t\t\tconst width = renderTarget.width;\n\t\t\tconst height = renderTarget.height;\n\t\t\tlet mask = _gl.COLOR_BUFFER_BIT;\n\t\t\tconst invalidationArray = [];\n\t\t\tconst depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;\n\t\t\tconst renderTargetProperties = properties.get(renderTarget);\n\t\t\tconst isMultipleRenderTargets = renderTarget.isWebGLMultipleRenderTargets === true; // If MRT we need to remove FBO attachments\n\n\t\t\tif (isMultipleRenderTargets) {\n\t\t\t\tfor (let i = 0; i < textures.length; i++) {\n\t\t\t\t\tstate.bindFramebuffer(_gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer);\n\n\t\t\t\t\t_gl.framebufferRenderbuffer(_gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, null);\n\n\t\t\t\t\tstate.bindFramebuffer(_gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer);\n\n\t\t\t\t\t_gl.framebufferTexture2D(_gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, null, 0);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tstate.bindFramebuffer(_gl.READ_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer);\n\t\t\tstate.bindFramebuffer(_gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer);\n\n\t\t\tfor (let i = 0; i < textures.length; i++) {\n\t\t\t\tinvalidationArray.push(_gl.COLOR_ATTACHMENT0 + i);\n\n\t\t\t\tif (renderTarget.depthBuffer) {\n\t\t\t\t\tinvalidationArray.push(depthStyle);\n\t\t\t\t}\n\n\t\t\t\tconst ignoreDepthValues = renderTargetProperties.__ignoreDepthValues !== undefined ? renderTargetProperties.__ignoreDepthValues : false;\n\n\t\t\t\tif (ignoreDepthValues === false) {\n\t\t\t\t\tif (renderTarget.depthBuffer) mask |= _gl.DEPTH_BUFFER_BIT;\n\t\t\t\t\tif (renderTarget.stencilBuffer) mask |= _gl.STENCIL_BUFFER_BIT;\n\t\t\t\t}\n\n\t\t\t\tif (isMultipleRenderTargets) {\n\t\t\t\t\t_gl.framebufferRenderbuffer(_gl.READ_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[i]);\n\t\t\t\t}\n\n\t\t\t\tif (ignoreDepthValues === true) {\n\t\t\t\t\t_gl.invalidateFramebuffer(_gl.READ_FRAMEBUFFER, [depthStyle]);\n\n\t\t\t\t\t_gl.invalidateFramebuffer(_gl.DRAW_FRAMEBUFFER, [depthStyle]);\n\t\t\t\t}\n\n\t\t\t\tif (isMultipleRenderTargets) {\n\t\t\t\t\tconst webglTexture = properties.get(textures[i]).__webglTexture;\n\n\t\t\t\t\t_gl.framebufferTexture2D(_gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, webglTexture, 0);\n\t\t\t\t}\n\n\t\t\t\t_gl.blitFramebuffer(0, 0, width, height, 0, 0, width, height, mask, _gl.NEAREST);\n\n\t\t\t\tif (supportsInvalidateFramebuffer) {\n\t\t\t\t\t_gl.invalidateFramebuffer(_gl.READ_FRAMEBUFFER, invalidationArray);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tstate.bindFramebuffer(_gl.READ_FRAMEBUFFER, null);\n\t\t\tstate.bindFramebuffer(_gl.DRAW_FRAMEBUFFER, null); // If MRT since pre-blit we removed the FBO we need to reconstruct the attachments\n\n\t\t\tif (isMultipleRenderTargets) {\n\t\t\t\tfor (let i = 0; i < textures.length; i++) {\n\t\t\t\t\tstate.bindFramebuffer(_gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer);\n\n\t\t\t\t\t_gl.framebufferRenderbuffer(_gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[i]);\n\n\t\t\t\t\tconst webglTexture = properties.get(textures[i]).__webglTexture;\n\n\t\t\t\t\tstate.bindFramebuffer(_gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer);\n\n\t\t\t\t\t_gl.framebufferTexture2D(_gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, webglTexture, 0);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tstate.bindFramebuffer(_gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer);\n\t\t}\n\t}\n\n\tfunction getRenderTargetSamples(renderTarget) {\n\t\treturn Math.min(maxSamples, renderTarget.samples);\n\t}\n\n\tfunction useMultisampledRTT(renderTarget) {\n\t\tconst renderTargetProperties = properties.get(renderTarget);\n\t\treturn isWebGL2 && renderTarget.samples > 0 && extensions.has('WEBGL_multisampled_render_to_texture') === true && renderTargetProperties.__useRenderToTexture !== false;\n\t}\n\n\tfunction updateVideoTexture(texture) {\n\t\tconst frame = info.render.frame; // Check the last frame we updated the VideoTexture\n\n\t\tif (_videoTextures.get(texture) !== frame) {\n\t\t\t_videoTextures.set(texture, frame);\n\n\t\t\ttexture.update();\n\t\t}\n\t}\n\n\tfunction verifyColorSpace(texture, image) {\n\t\tconst encoding = texture.encoding;\n\t\tconst format = texture.format;\n\t\tconst type = texture.type;\n\t\tif (texture.isCompressedTexture === true || texture.isVideoTexture === true || texture.format === _SRGBAFormat) return image;\n\n\t\tif (encoding !== LinearEncoding) {\n\t\t\t// sRGB\n\t\t\tif (encoding === sRGBEncoding) {\n\t\t\t\tif (isWebGL2 === false) {\n\t\t\t\t\t// in WebGL 1, try to use EXT_sRGB extension and unsized formats\n\t\t\t\t\tif (extensions.has('EXT_sRGB') === true && format === RGBAFormat) {\n\t\t\t\t\t\ttexture.format = _SRGBAFormat; // it's not possible to generate mips in WebGL 1 with this extension\n\n\t\t\t\t\t\ttexture.minFilter = LinearFilter;\n\t\t\t\t\t\ttexture.generateMipmaps = false;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// slow fallback (CPU decode)\n\t\t\t\t\t\timage = ImageUtils.sRGBToLinear(image);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// in WebGL 2 uncompressed textures can only be sRGB encoded if they have the RGBA8 format\n\t\t\t\t\tif (format !== RGBAFormat || type !== UnsignedByteType) {\n\t\t\t\t\t\tconsole.warn('THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconsole.error('THREE.WebGLTextures: Unsupported texture encoding:', encoding);\n\t\t\t}\n\t\t}\n\n\t\treturn image;\n\t} //\n\n\n\tthis.allocateTextureUnit = allocateTextureUnit;\n\tthis.resetTextureUnits = resetTextureUnits;\n\tthis.setTexture2D = setTexture2D;\n\tthis.setTexture2DArray = setTexture2DArray;\n\tthis.setTexture3D = setTexture3D;\n\tthis.setTextureCube = setTextureCube;\n\tthis.rebindTextures = rebindTextures;\n\tthis.setupRenderTarget = setupRenderTarget;\n\tthis.updateRenderTargetMipmap = updateRenderTargetMipmap;\n\tthis.updateMultisampleRenderTarget = updateMultisampleRenderTarget;\n\tthis.setupDepthRenderbuffer = setupDepthRenderbuffer;\n\tthis.setupFrameBufferTexture = setupFrameBufferTexture;\n\tthis.useMultisampledRTT = useMultisampledRTT;\n}\n\nfunction WebGLUtils(gl, extensions, capabilities) {\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tfunction convert(p, encoding = null) {\n\t\tlet extension;\n\t\tif (p === UnsignedByteType) return gl.UNSIGNED_BYTE;\n\t\tif (p === UnsignedShort4444Type) return gl.UNSIGNED_SHORT_4_4_4_4;\n\t\tif (p === UnsignedShort5551Type) return gl.UNSIGNED_SHORT_5_5_5_1;\n\t\tif (p === ByteType) return gl.BYTE;\n\t\tif (p === ShortType) return gl.SHORT;\n\t\tif (p === UnsignedShortType) return gl.UNSIGNED_SHORT;\n\t\tif (p === IntType) return gl.INT;\n\t\tif (p === UnsignedIntType) return gl.UNSIGNED_INT;\n\t\tif (p === FloatType) return gl.FLOAT;\n\n\t\tif (p === HalfFloatType) {\n\t\t\tif (isWebGL2) return gl.HALF_FLOAT;\n\t\t\textension = extensions.get('OES_texture_half_float');\n\n\t\t\tif (extension !== null) {\n\t\t\t\treturn extension.HALF_FLOAT_OES;\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\tif (p === AlphaFormat) return gl.ALPHA;\n\t\tif (p === RGBAFormat) return gl.RGBA;\n\t\tif (p === LuminanceFormat) return gl.LUMINANCE;\n\t\tif (p === LuminanceAlphaFormat) return gl.LUMINANCE_ALPHA;\n\t\tif (p === DepthFormat) return gl.DEPTH_COMPONENT;\n\t\tif (p === DepthStencilFormat) return gl.DEPTH_STENCIL;\n\t\tif (p === RedFormat) return gl.RED; // @deprecated since r137\n\n\t\tif (p === RGBFormat) {\n\t\t\tconsole.warn('THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228');\n\t\t\treturn gl.RGBA;\n\t\t} // WebGL 1 sRGB fallback\n\n\n\t\tif (p === _SRGBAFormat) {\n\t\t\textension = extensions.get('EXT_sRGB');\n\n\t\t\tif (extension !== null) {\n\t\t\t\treturn extension.SRGB_ALPHA_EXT;\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t} // WebGL2 formats.\n\n\n\t\tif (p === RedIntegerFormat) return gl.RED_INTEGER;\n\t\tif (p === RGFormat) return gl.RG;\n\t\tif (p === RGIntegerFormat) return gl.RG_INTEGER;\n\t\tif (p === RGBAIntegerFormat) return gl.RGBA_INTEGER; // S3TC\n\n\t\tif (p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format || p === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format) {\n\t\t\tif (encoding === sRGBEncoding) {\n\t\t\t\textension = extensions.get('WEBGL_compressed_texture_s3tc_srgb');\n\n\t\t\t\tif (extension !== null) {\n\t\t\t\t\tif (p === RGB_S3TC_DXT1_Format) return extension.COMPRESSED_SRGB_S3TC_DXT1_EXT;\n\t\t\t\t\tif (p === RGBA_S3TC_DXT1_Format) return extension.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;\n\t\t\t\t\tif (p === RGBA_S3TC_DXT3_Format) return extension.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;\n\t\t\t\t\tif (p === RGBA_S3TC_DXT5_Format) return extension.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;\n\t\t\t\t} else {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\textension = extensions.get('WEBGL_compressed_texture_s3tc');\n\n\t\t\t\tif (extension !== null) {\n\t\t\t\t\tif (p === RGB_S3TC_DXT1_Format) return extension.COMPRESSED_RGB_S3TC_DXT1_EXT;\n\t\t\t\t\tif (p === RGBA_S3TC_DXT1_Format) return extension.COMPRESSED_RGBA_S3TC_DXT1_EXT;\n\t\t\t\t\tif (p === RGBA_S3TC_DXT3_Format) return extension.COMPRESSED_RGBA_S3TC_DXT3_EXT;\n\t\t\t\t\tif (p === RGBA_S3TC_DXT5_Format) return extension.COMPRESSED_RGBA_S3TC_DXT5_EXT;\n\t\t\t\t} else {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\t\t} // PVRTC\n\n\n\t\tif (p === RGB_PVRTC_4BPPV1_Format || p === RGB_PVRTC_2BPPV1_Format || p === RGBA_PVRTC_4BPPV1_Format || p === RGBA_PVRTC_2BPPV1_Format) {\n\t\t\textension = extensions.get('WEBGL_compressed_texture_pvrtc');\n\n\t\t\tif (extension !== null) {\n\t\t\t\tif (p === RGB_PVRTC_4BPPV1_Format) return extension.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;\n\t\t\t\tif (p === RGB_PVRTC_2BPPV1_Format) return extension.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;\n\t\t\t\tif (p === RGBA_PVRTC_4BPPV1_Format) return extension.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;\n\t\t\t\tif (p === RGBA_PVRTC_2BPPV1_Format) return extension.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t} // ETC1\n\n\n\t\tif (p === RGB_ETC1_Format) {\n\t\t\textension = extensions.get('WEBGL_compressed_texture_etc1');\n\n\t\t\tif (extension !== null) {\n\t\t\t\treturn extension.COMPRESSED_RGB_ETC1_WEBGL;\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t} // ETC2\n\n\n\t\tif (p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format) {\n\t\t\textension = extensions.get('WEBGL_compressed_texture_etc');\n\n\t\t\tif (extension !== null) {\n\t\t\t\tif (p === RGB_ETC2_Format) return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;\n\t\t\t\tif (p === RGBA_ETC2_EAC_Format) return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t} // ASTC\n\n\n\t\tif (p === RGBA_ASTC_4x4_Format || p === RGBA_ASTC_5x4_Format || p === RGBA_ASTC_5x5_Format || p === RGBA_ASTC_6x5_Format || p === RGBA_ASTC_6x6_Format || p === RGBA_ASTC_8x5_Format || p === RGBA_ASTC_8x6_Format || p === RGBA_ASTC_8x8_Format || p === RGBA_ASTC_10x5_Format || p === RGBA_ASTC_10x6_Format || p === RGBA_ASTC_10x8_Format || p === RGBA_ASTC_10x10_Format || p === RGBA_ASTC_12x10_Format || p === RGBA_ASTC_12x12_Format) {\n\t\t\textension = extensions.get('WEBGL_compressed_texture_astc');\n\n\t\t\tif (extension !== null) {\n\t\t\t\tif (p === RGBA_ASTC_4x4_Format) return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : extension.COMPRESSED_RGBA_ASTC_4x4_KHR;\n\t\t\t\tif (p === RGBA_ASTC_5x4_Format) return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : extension.COMPRESSED_RGBA_ASTC_5x4_KHR;\n\t\t\t\tif (p === RGBA_ASTC_5x5_Format) return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : extension.COMPRESSED_RGBA_ASTC_5x5_KHR;\n\t\t\t\tif (p === RGBA_ASTC_6x5_Format) return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : extension.COMPRESSED_RGBA_ASTC_6x5_KHR;\n\t\t\t\tif (p === RGBA_ASTC_6x6_Format) return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : extension.COMPRESSED_RGBA_ASTC_6x6_KHR;\n\t\t\t\tif (p === RGBA_ASTC_8x5_Format) return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : extension.COMPRESSED_RGBA_ASTC_8x5_KHR;\n\t\t\t\tif (p === RGBA_ASTC_8x6_Format) return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : extension.COMPRESSED_RGBA_ASTC_8x6_KHR;\n\t\t\t\tif (p === RGBA_ASTC_8x8_Format) return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : extension.COMPRESSED_RGBA_ASTC_8x8_KHR;\n\t\t\t\tif (p === RGBA_ASTC_10x5_Format) return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : extension.COMPRESSED_RGBA_ASTC_10x5_KHR;\n\t\t\t\tif (p === RGBA_ASTC_10x6_Format) return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : extension.COMPRESSED_RGBA_ASTC_10x6_KHR;\n\t\t\t\tif (p === RGBA_ASTC_10x8_Format) return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : extension.COMPRESSED_RGBA_ASTC_10x8_KHR;\n\t\t\t\tif (p === RGBA_ASTC_10x10_Format) return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : extension.COMPRESSED_RGBA_ASTC_10x10_KHR;\n\t\t\t\tif (p === RGBA_ASTC_12x10_Format) return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : extension.COMPRESSED_RGBA_ASTC_12x10_KHR;\n\t\t\t\tif (p === RGBA_ASTC_12x12_Format) return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : extension.COMPRESSED_RGBA_ASTC_12x12_KHR;\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t} // BPTC\n\n\n\t\tif (p === RGBA_BPTC_Format) {\n\t\t\textension = extensions.get('EXT_texture_compression_bptc');\n\n\t\t\tif (extension !== null) {\n\t\t\t\tif (p === RGBA_BPTC_Format) return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : extension.COMPRESSED_RGBA_BPTC_UNORM_EXT;\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t} //\n\n\n\t\tif (p === UnsignedInt248Type) {\n\t\t\tif (isWebGL2) return gl.UNSIGNED_INT_24_8;\n\t\t\textension = extensions.get('WEBGL_depth_texture');\n\n\t\t\tif (extension !== null) {\n\t\t\t\treturn extension.UNSIGNED_INT_24_8_WEBGL;\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t} // if \"p\" can't be resolved, assume the user defines a WebGL constant as a string (fallback/workaround for packed RGB formats)\n\n\n\t\treturn gl[p] !== undefined ? gl[p] : null;\n\t}\n\n\treturn {\n\t\tconvert: convert\n\t};\n}\n\nclass ArrayCamera extends PerspectiveCamera {\n\tconstructor(array = []) {\n\t\tsuper();\n\t\tthis.isArrayCamera = true;\n\t\tthis.cameras = array;\n\t}\n\n}\n\nclass Group extends Object3D {\n\tconstructor() {\n\t\tsuper();\n\t\tthis.isGroup = true;\n\t\tthis.type = 'Group';\n\t}\n\n}\n\nconst _moveEvent = {\n\ttype: 'move'\n};\n\nclass WebXRController {\n\tconstructor() {\n\t\tthis._targetRay = null;\n\t\tthis._grip = null;\n\t\tthis._hand = null;\n\t}\n\n\tgetHandSpace() {\n\t\tif (this._hand === null) {\n\t\t\tthis._hand = new Group();\n\t\t\tthis._hand.matrixAutoUpdate = false;\n\t\t\tthis._hand.visible = false;\n\t\t\tthis._hand.joints = {};\n\t\t\tthis._hand.inputState = {\n\t\t\t\tpinching: false\n\t\t\t};\n\t\t}\n\n\t\treturn this._hand;\n\t}\n\n\tgetTargetRaySpace() {\n\t\tif (this._targetRay === null) {\n\t\t\tthis._targetRay = new Group();\n\t\t\tthis._targetRay.matrixAutoUpdate = false;\n\t\t\tthis._targetRay.visible = false;\n\t\t\tthis._targetRay.hasLinearVelocity = false;\n\t\t\tthis._targetRay.linearVelocity = new Vector3();\n\t\t\tthis._targetRay.hasAngularVelocity = false;\n\t\t\tthis._targetRay.angularVelocity = new Vector3();\n\t\t}\n\n\t\treturn this._targetRay;\n\t}\n\n\tgetGripSpace() {\n\t\tif (this._grip === null) {\n\t\t\tthis._grip = new Group();\n\t\t\tthis._grip.matrixAutoUpdate = false;\n\t\t\tthis._grip.visible = false;\n\t\t\tthis._grip.hasLinearVelocity = false;\n\t\t\tthis._grip.linearVelocity = new Vector3();\n\t\t\tthis._grip.hasAngularVelocity = false;\n\t\t\tthis._grip.angularVelocity = new Vector3();\n\t\t}\n\n\t\treturn this._grip;\n\t}\n\n\tdispatchEvent(event) {\n\t\tif (this._targetRay !== null) {\n\t\t\tthis._targetRay.dispatchEvent(event);\n\t\t}\n\n\t\tif (this._grip !== null) {\n\t\t\tthis._grip.dispatchEvent(event);\n\t\t}\n\n\t\tif (this._hand !== null) {\n\t\t\tthis._hand.dispatchEvent(event);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tdisconnect(inputSource) {\n\t\tthis.dispatchEvent({\n\t\t\ttype: 'disconnected',\n\t\t\tdata: inputSource\n\t\t});\n\n\t\tif (this._targetRay !== null) {\n\t\t\tthis._targetRay.visible = false;\n\t\t}\n\n\t\tif (this._grip !== null) {\n\t\t\tthis._grip.visible = false;\n\t\t}\n\n\t\tif (this._hand !== null) {\n\t\t\tthis._hand.visible = false;\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tupdate(inputSource, frame, referenceSpace) {\n\t\tlet inputPose = null;\n\t\tlet gripPose = null;\n\t\tlet handPose = null;\n\t\tconst targetRay = this._targetRay;\n\t\tconst grip = this._grip;\n\t\tconst hand = this._hand;\n\n\t\tif (inputSource && frame.session.visibilityState !== 'visible-blurred') {\n\t\t\tif (hand && inputSource.hand) {\n\t\t\t\thandPose = true;\n\n\t\t\t\tfor (const inputjoint of inputSource.hand.values()) {\n\t\t\t\t\t// Update the joints groups with the XRJoint poses\n\t\t\t\t\tconst jointPose = frame.getJointPose(inputjoint, referenceSpace);\n\n\t\t\t\t\tif (hand.joints[inputjoint.jointName] === undefined) {\n\t\t\t\t\t\t// The transform of this joint will be updated with the joint pose on each frame\n\t\t\t\t\t\tconst joint = new Group();\n\t\t\t\t\t\tjoint.matrixAutoUpdate = false;\n\t\t\t\t\t\tjoint.visible = false;\n\t\t\t\t\t\thand.joints[inputjoint.jointName] = joint; // ??\n\n\t\t\t\t\t\thand.add(joint);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst joint = hand.joints[inputjoint.jointName];\n\n\t\t\t\t\tif (jointPose !== null) {\n\t\t\t\t\t\tjoint.matrix.fromArray(jointPose.transform.matrix);\n\t\t\t\t\t\tjoint.matrix.decompose(joint.position, joint.rotation, joint.scale);\n\t\t\t\t\t\tjoint.jointRadius = jointPose.radius;\n\t\t\t\t\t}\n\n\t\t\t\t\tjoint.visible = jointPose !== null;\n\t\t\t\t} // Custom events\n\t\t\t\t// Check pinchz\n\n\n\t\t\t\tconst indexTip = hand.joints['index-finger-tip'];\n\t\t\t\tconst thumbTip = hand.joints['thumb-tip'];\n\t\t\t\tconst distance = indexTip.position.distanceTo(thumbTip.position);\n\t\t\t\tconst distanceToPinch = 0.02;\n\t\t\t\tconst threshold = 0.005;\n\n\t\t\t\tif (hand.inputState.pinching && distance > distanceToPinch + threshold) {\n\t\t\t\t\thand.inputState.pinching = false;\n\t\t\t\t\tthis.dispatchEvent({\n\t\t\t\t\t\ttype: 'pinchend',\n\t\t\t\t\t\thandedness: inputSource.handedness,\n\t\t\t\t\t\ttarget: this\n\t\t\t\t\t});\n\t\t\t\t} else if (!hand.inputState.pinching && distance <= distanceToPinch - threshold) {\n\t\t\t\t\thand.inputState.pinching = true;\n\t\t\t\t\tthis.dispatchEvent({\n\t\t\t\t\t\ttype: 'pinchstart',\n\t\t\t\t\t\thandedness: inputSource.handedness,\n\t\t\t\t\t\ttarget: this\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (grip !== null && inputSource.gripSpace) {\n\t\t\t\t\tgripPose = frame.getPose(inputSource.gripSpace, referenceSpace);\n\n\t\t\t\t\tif (gripPose !== null) {\n\t\t\t\t\t\tgrip.matrix.fromArray(gripPose.transform.matrix);\n\t\t\t\t\t\tgrip.matrix.decompose(grip.position, grip.rotation, grip.scale);\n\n\t\t\t\t\t\tif (gripPose.linearVelocity) {\n\t\t\t\t\t\t\tgrip.hasLinearVelocity = true;\n\t\t\t\t\t\t\tgrip.linearVelocity.copy(gripPose.linearVelocity);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tgrip.hasLinearVelocity = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (gripPose.angularVelocity) {\n\t\t\t\t\t\t\tgrip.hasAngularVelocity = true;\n\t\t\t\t\t\t\tgrip.angularVelocity.copy(gripPose.angularVelocity);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tgrip.hasAngularVelocity = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (targetRay !== null) {\n\t\t\t\tinputPose = frame.getPose(inputSource.targetRaySpace, referenceSpace); // Some runtimes (namely Vive Cosmos with Vive OpenXR Runtime) have only grip space and ray space is equal to it\n\n\t\t\t\tif (inputPose === null && gripPose !== null) {\n\t\t\t\t\tinputPose = gripPose;\n\t\t\t\t}\n\n\t\t\t\tif (inputPose !== null) {\n\t\t\t\t\ttargetRay.matrix.fromArray(inputPose.transform.matrix);\n\t\t\t\t\ttargetRay.matrix.decompose(targetRay.position, targetRay.rotation, targetRay.scale);\n\n\t\t\t\t\tif (inputPose.linearVelocity) {\n\t\t\t\t\t\ttargetRay.hasLinearVelocity = true;\n\t\t\t\t\t\ttargetRay.linearVelocity.copy(inputPose.linearVelocity);\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttargetRay.hasLinearVelocity = false;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (inputPose.angularVelocity) {\n\t\t\t\t\t\ttargetRay.hasAngularVelocity = true;\n\t\t\t\t\t\ttargetRay.angularVelocity.copy(inputPose.angularVelocity);\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttargetRay.hasAngularVelocity = false;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.dispatchEvent(_moveEvent);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (targetRay !== null) {\n\t\t\ttargetRay.visible = inputPose !== null;\n\t\t}\n\n\t\tif (grip !== null) {\n\t\t\tgrip.visible = gripPose !== null;\n\t\t}\n\n\t\tif (hand !== null) {\n\t\t\thand.visible = handPose !== null;\n\t\t}\n\n\t\treturn this;\n\t}\n\n}\n\nclass DepthTexture extends Texture {\n\tconstructor(width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format) {\n\t\tformat = format !== undefined ? format : DepthFormat;\n\n\t\tif (format !== DepthFormat && format !== DepthStencilFormat) {\n\t\t\tthrow new Error('DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat');\n\t\t}\n\n\t\tif (type === undefined && format === DepthFormat) type = UnsignedIntType;\n\t\tif (type === undefined && format === DepthStencilFormat) type = UnsignedInt248Type;\n\t\tsuper(null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy);\n\t\tthis.isDepthTexture = true;\n\t\tthis.image = {\n\t\t\twidth: width,\n\t\t\theight: height\n\t\t};\n\t\tthis.magFilter = magFilter !== undefined ? magFilter : NearestFilter;\n\t\tthis.minFilter = minFilter !== undefined ? minFilter : NearestFilter;\n\t\tthis.flipY = false;\n\t\tthis.generateMipmaps = false;\n\t}\n\n}\n\nclass WebXRManager extends EventDispatcher {\n\tconstructor(renderer, gl) {\n\t\tsuper();\n\t\tconst scope = this;\n\t\tlet session = null;\n\t\tlet framebufferScaleFactor = 1.0;\n\t\tlet referenceSpace = null;\n\t\tlet referenceSpaceType = 'local-floor';\n\t\tlet customReferenceSpace = null;\n\t\tlet pose = null;\n\t\tlet glBinding = null;\n\t\tlet glProjLayer = null;\n\t\tlet glBaseLayer = null;\n\t\tlet xrFrame = null;\n\t\tconst attributes = gl.getContextAttributes();\n\t\tlet initialRenderTarget = null;\n\t\tlet newRenderTarget = null;\n\t\tconst controllers = [];\n\t\tconst controllerInputSources = []; //\n\n\t\tconst cameraL = new PerspectiveCamera();\n\t\tcameraL.layers.enable(1);\n\t\tcameraL.viewport = new Vector4();\n\t\tconst cameraR = new PerspectiveCamera();\n\t\tcameraR.layers.enable(2);\n\t\tcameraR.viewport = new Vector4();\n\t\tconst cameras = [cameraL, cameraR];\n\t\tconst cameraVR = new ArrayCamera();\n\t\tcameraVR.layers.enable(1);\n\t\tcameraVR.layers.enable(2);\n\t\tlet _currentDepthNear = null;\n\t\tlet _currentDepthFar = null; //\n\n\t\tthis.cameraAutoUpdate = true;\n\t\tthis.enabled = false;\n\t\tthis.isPresenting = false;\n\n\t\tthis.getController = function (index) {\n\t\t\tlet controller = controllers[index];\n\n\t\t\tif (controller === undefined) {\n\t\t\t\tcontroller = new WebXRController();\n\t\t\t\tcontrollers[index] = controller;\n\t\t\t}\n\n\t\t\treturn controller.getTargetRaySpace();\n\t\t};\n\n\t\tthis.getControllerGrip = function (index) {\n\t\t\tlet controller = controllers[index];\n\n\t\t\tif (controller === undefined) {\n\t\t\t\tcontroller = new WebXRController();\n\t\t\t\tcontrollers[index] = controller;\n\t\t\t}\n\n\t\t\treturn controller.getGripSpace();\n\t\t};\n\n\t\tthis.getHand = function (index) {\n\t\t\tlet controller = controllers[index];\n\n\t\t\tif (controller === undefined) {\n\t\t\t\tcontroller = new WebXRController();\n\t\t\t\tcontrollers[index] = controller;\n\t\t\t}\n\n\t\t\treturn controller.getHandSpace();\n\t\t}; //\n\n\n\t\tfunction onSessionEvent(event) {\n\t\t\tconst controllerIndex = controllerInputSources.indexOf(event.inputSource);\n\n\t\t\tif (controllerIndex === -1) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst controller = controllers[controllerIndex];\n\n\t\t\tif (controller !== undefined) {\n\t\t\t\tcontroller.dispatchEvent({\n\t\t\t\t\ttype: event.type,\n\t\t\t\t\tdata: event.inputSource\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tfunction onSessionEnd() {\n\t\t\tsession.removeEventListener('select', onSessionEvent);\n\t\t\tsession.removeEventListener('selectstart', onSessionEvent);\n\t\t\tsession.removeEventListener('selectend', onSessionEvent);\n\t\t\tsession.removeEventListener('squeeze', onSessionEvent);\n\t\t\tsession.removeEventListener('squeezestart', onSessionEvent);\n\t\t\tsession.removeEventListener('squeezeend', onSessionEvent);\n\t\t\tsession.removeEventListener('end', onSessionEnd);\n\t\t\tsession.removeEventListener('inputsourceschange', onInputSourcesChange);\n\n\t\t\tfor (let i = 0; i < controllers.length; i++) {\n\t\t\t\tconst inputSource = controllerInputSources[i];\n\t\t\t\tif (inputSource === null) continue;\n\t\t\t\tcontrollerInputSources[i] = null;\n\t\t\t\tcontrollers[i].disconnect(inputSource);\n\t\t\t}\n\n\t\t\t_currentDepthNear = null;\n\t\t\t_currentDepthFar = null; // restore framebuffer/rendering state\n\n\t\t\trenderer.setRenderTarget(initialRenderTarget);\n\t\t\tglBaseLayer = null;\n\t\t\tglProjLayer = null;\n\t\t\tglBinding = null;\n\t\t\tsession = null;\n\t\t\tnewRenderTarget = null; //\n\n\t\t\tanimation.stop();\n\t\t\tscope.isPresenting = false;\n\t\t\tscope.dispatchEvent({\n\t\t\t\ttype: 'sessionend'\n\t\t\t});\n\t\t}\n\n\t\tthis.setFramebufferScaleFactor = function (value) {\n\t\t\tframebufferScaleFactor = value;\n\n\t\t\tif (scope.isPresenting === true) {\n\t\t\t\tconsole.warn('THREE.WebXRManager: Cannot change framebuffer scale while presenting.');\n\t\t\t}\n\t\t};\n\n\t\tthis.setReferenceSpaceType = function (value) {\n\t\t\treferenceSpaceType = value;\n\n\t\t\tif (scope.isPresenting === true) {\n\t\t\t\tconsole.warn('THREE.WebXRManager: Cannot change reference space type while presenting.');\n\t\t\t}\n\t\t};\n\n\t\tthis.getReferenceSpace = function () {\n\t\t\treturn customReferenceSpace || referenceSpace;\n\t\t};\n\n\t\tthis.setReferenceSpace = function (space) {\n\t\t\tcustomReferenceSpace = space;\n\t\t};\n\n\t\tthis.getBaseLayer = function () {\n\t\t\treturn glProjLayer !== null ? glProjLayer : glBaseLayer;\n\t\t};\n\n\t\tthis.getBinding = function () {\n\t\t\treturn glBinding;\n\t\t};\n\n\t\tthis.getFrame = function () {\n\t\t\treturn xrFrame;\n\t\t};\n\n\t\tthis.getSession = function () {\n\t\t\treturn session;\n\t\t};\n\n\t\tthis.setSession = async function (value) {\n\t\t\tsession = value;\n\n\t\t\tif (session !== null) {\n\t\t\t\tinitialRenderTarget = renderer.getRenderTarget();\n\t\t\t\tsession.addEventListener('select', onSessionEvent);\n\t\t\t\tsession.addEventListener('selectstart', onSessionEvent);\n\t\t\t\tsession.addEventListener('selectend', onSessionEvent);\n\t\t\t\tsession.addEventListener('squeeze', onSessionEvent);\n\t\t\t\tsession.addEventListener('squeezestart', onSessionEvent);\n\t\t\t\tsession.addEventListener('squeezeend', onSessionEvent);\n\t\t\t\tsession.addEventListener('end', onSessionEnd);\n\t\t\t\tsession.addEventListener('inputsourceschange', onInputSourcesChange);\n\n\t\t\t\tif (attributes.xrCompatible !== true) {\n\t\t\t\t\tawait gl.makeXRCompatible();\n\t\t\t\t}\n\n\t\t\t\tif (session.renderState.layers === undefined || renderer.capabilities.isWebGL2 === false) {\n\t\t\t\t\tconst layerInit = {\n\t\t\t\t\t\tantialias: session.renderState.layers === undefined ? attributes.antialias : true,\n\t\t\t\t\t\talpha: attributes.alpha,\n\t\t\t\t\t\tdepth: attributes.depth,\n\t\t\t\t\t\tstencil: attributes.stencil,\n\t\t\t\t\t\tframebufferScaleFactor: framebufferScaleFactor\n\t\t\t\t\t};\n\t\t\t\t\tglBaseLayer = new XRWebGLLayer(session, gl, layerInit);\n\t\t\t\t\tsession.updateRenderState({\n\t\t\t\t\t\tbaseLayer: glBaseLayer\n\t\t\t\t\t});\n\t\t\t\t\tnewRenderTarget = new WebGLRenderTarget(glBaseLayer.framebufferWidth, glBaseLayer.framebufferHeight, {\n\t\t\t\t\t\tformat: RGBAFormat,\n\t\t\t\t\t\ttype: UnsignedByteType,\n\t\t\t\t\t\tencoding: renderer.outputEncoding,\n\t\t\t\t\t\tstencilBuffer: attributes.stencil\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tlet depthFormat = null;\n\t\t\t\t\tlet depthType = null;\n\t\t\t\t\tlet glDepthFormat = null;\n\n\t\t\t\t\tif (attributes.depth) {\n\t\t\t\t\t\tglDepthFormat = attributes.stencil ? gl.DEPTH24_STENCIL8 : gl.DEPTH_COMPONENT24;\n\t\t\t\t\t\tdepthFormat = attributes.stencil ? DepthStencilFormat : DepthFormat;\n\t\t\t\t\t\tdepthType = attributes.stencil ? UnsignedInt248Type : UnsignedIntType;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst projectionlayerInit = {\n\t\t\t\t\t\tcolorFormat: gl.RGBA8,\n\t\t\t\t\t\tdepthFormat: glDepthFormat,\n\t\t\t\t\t\tscaleFactor: framebufferScaleFactor\n\t\t\t\t\t};\n\t\t\t\t\tglBinding = new XRWebGLBinding(session, gl);\n\t\t\t\t\tglProjLayer = glBinding.createProjectionLayer(projectionlayerInit);\n\t\t\t\t\tsession.updateRenderState({\n\t\t\t\t\t\tlayers: [glProjLayer]\n\t\t\t\t\t});\n\t\t\t\t\tnewRenderTarget = new WebGLRenderTarget(glProjLayer.textureWidth, glProjLayer.textureHeight, {\n\t\t\t\t\t\tformat: RGBAFormat,\n\t\t\t\t\t\ttype: UnsignedByteType,\n\t\t\t\t\t\tdepthTexture: new DepthTexture(glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat),\n\t\t\t\t\t\tstencilBuffer: attributes.stencil,\n\t\t\t\t\t\tencoding: renderer.outputEncoding,\n\t\t\t\t\t\tsamples: attributes.antialias ? 4 : 0\n\t\t\t\t\t});\n\t\t\t\t\tconst renderTargetProperties = renderer.properties.get(newRenderTarget);\n\t\t\t\t\trenderTargetProperties.__ignoreDepthValues = glProjLayer.ignoreDepthValues;\n\t\t\t\t}\n\n\t\t\t\tnewRenderTarget.isXRRenderTarget = true; // TODO Remove this when possible, see #23278\n\t\t\t\t// Set foveation to maximum.\n\n\t\t\t\tthis.setFoveation(1.0);\n\t\t\t\tcustomReferenceSpace = null;\n\t\t\t\treferenceSpace = await session.requestReferenceSpace(referenceSpaceType);\n\t\t\t\tanimation.setContext(session);\n\t\t\t\tanimation.start();\n\t\t\t\tscope.isPresenting = true;\n\t\t\t\tscope.dispatchEvent({\n\t\t\t\t\ttype: 'sessionstart'\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\n\t\tfunction onInputSourcesChange(event) {\n\t\t\t// Notify disconnected\n\t\t\tfor (let i = 0; i < event.removed.length; i++) {\n\t\t\t\tconst inputSource = event.removed[i];\n\t\t\t\tconst index = controllerInputSources.indexOf(inputSource);\n\n\t\t\t\tif (index >= 0) {\n\t\t\t\t\tcontrollerInputSources[index] = null;\n\t\t\t\t\tcontrollers[index].dispatchEvent({\n\t\t\t\t\t\ttype: 'disconnected',\n\t\t\t\t\t\tdata: inputSource\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} // Notify connected\n\n\n\t\t\tfor (let i = 0; i < event.added.length; i++) {\n\t\t\t\tconst inputSource = event.added[i];\n\t\t\t\tlet controllerIndex = controllerInputSources.indexOf(inputSource);\n\n\t\t\t\tif (controllerIndex === -1) {\n\t\t\t\t\t// Assign input source a controller that currently has no input source\n\t\t\t\t\tfor (let i = 0; i < controllers.length; i++) {\n\t\t\t\t\t\tif (i >= controllerInputSources.length) {\n\t\t\t\t\t\t\tcontrollerInputSources.push(inputSource);\n\t\t\t\t\t\t\tcontrollerIndex = i;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} else if (controllerInputSources[i] === null) {\n\t\t\t\t\t\t\tcontrollerInputSources[i] = inputSource;\n\t\t\t\t\t\t\tcontrollerIndex = i;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t} // If all controllers do currently receive input we ignore new ones\n\n\n\t\t\t\t\tif (controllerIndex === -1) break;\n\t\t\t\t}\n\n\t\t\t\tconst controller = controllers[controllerIndex];\n\n\t\t\t\tif (controller) {\n\t\t\t\t\tcontroller.dispatchEvent({\n\t\t\t\t\t\ttype: 'connected',\n\t\t\t\t\t\tdata: inputSource\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} //\n\n\n\t\tconst cameraLPos = new Vector3();\n\t\tconst cameraRPos = new Vector3();\n\t\t/**\n\t\t * Assumes 2 cameras that are parallel and share an X-axis, and that\n\t\t * the cameras' projection and world matrices have already been set.\n\t\t * And that near and far planes are identical for both cameras.\n\t\t * Visualization of this technique: https://computergraphics.stackexchange.com/a/4765\n\t\t */\n\n\t\tfunction setProjectionFromUnion(camera, cameraL, cameraR) {\n\t\t\tcameraLPos.setFromMatrixPosition(cameraL.matrixWorld);\n\t\t\tcameraRPos.setFromMatrixPosition(cameraR.matrixWorld);\n\t\t\tconst ipd = cameraLPos.distanceTo(cameraRPos);\n\t\t\tconst projL = cameraL.projectionMatrix.elements;\n\t\t\tconst projR = cameraR.projectionMatrix.elements; // VR systems will have identical far and near planes, and\n\t\t\t// most likely identical top and bottom frustum extents.\n\t\t\t// Use the left camera for these values.\n\n\t\t\tconst near = projL[14] / (projL[10] - 1);\n\t\t\tconst far = projL[14] / (projL[10] + 1);\n\t\t\tconst topFov = (projL[9] + 1) / projL[5];\n\t\t\tconst bottomFov = (projL[9] - 1) / projL[5];\n\t\t\tconst leftFov = (projL[8] - 1) / projL[0];\n\t\t\tconst rightFov = (projR[8] + 1) / projR[0];\n\t\t\tconst left = near * leftFov;\n\t\t\tconst right = near * rightFov; // Calculate the new camera's position offset from the\n\t\t\t// left camera. xOffset should be roughly half `ipd`.\n\n\t\t\tconst zOffset = ipd / (-leftFov + rightFov);\n\t\t\tconst xOffset = zOffset * -leftFov; // TODO: Better way to apply this offset?\n\n\t\t\tcameraL.matrixWorld.decompose(camera.position, camera.quaternion, camera.scale);\n\t\t\tcamera.translateX(xOffset);\n\t\t\tcamera.translateZ(zOffset);\n\t\t\tcamera.matrixWorld.compose(camera.position, camera.quaternion, camera.scale);\n\t\t\tcamera.matrixWorldInverse.copy(camera.matrixWorld).invert(); // Find the union of the frustum values of the cameras and scale\n\t\t\t// the values so that the near plane's position does not change in world space,\n\t\t\t// although must now be relative to the new union camera.\n\n\t\t\tconst near2 = near + zOffset;\n\t\t\tconst far2 = far + zOffset;\n\t\t\tconst left2 = left - xOffset;\n\t\t\tconst right2 = right + (ipd - xOffset);\n\t\t\tconst top2 = topFov * far / far2 * near2;\n\t\t\tconst bottom2 = bottomFov * far / far2 * near2;\n\t\t\tcamera.projectionMatrix.makePerspective(left2, right2, top2, bottom2, near2, far2);\n\t\t}\n\n\t\tfunction updateCamera(camera, parent) {\n\t\t\tif (parent === null) {\n\t\t\t\tcamera.matrixWorld.copy(camera.matrix);\n\t\t\t} else {\n\t\t\t\tcamera.matrixWorld.multiplyMatrices(parent.matrixWorld, camera.matrix);\n\t\t\t}\n\n\t\t\tcamera.matrixWorldInverse.copy(camera.matrixWorld).invert();\n\t\t}\n\n\t\tthis.updateCamera = function (camera) {\n\t\t\tif (session === null) return;\n\t\t\tcameraVR.near = cameraR.near = cameraL.near = camera.near;\n\t\t\tcameraVR.far = cameraR.far = cameraL.far = camera.far;\n\n\t\t\tif (_currentDepthNear !== cameraVR.near || _currentDepthFar !== cameraVR.far) {\n\t\t\t\t// Note that the new renderState won't apply until the next frame. See #18320\n\t\t\t\tsession.updateRenderState({\n\t\t\t\t\tdepthNear: cameraVR.near,\n\t\t\t\t\tdepthFar: cameraVR.far\n\t\t\t\t});\n\t\t\t\t_currentDepthNear = cameraVR.near;\n\t\t\t\t_currentDepthFar = cameraVR.far;\n\t\t\t}\n\n\t\t\tconst parent = camera.parent;\n\t\t\tconst cameras = cameraVR.cameras;\n\t\t\tupdateCamera(cameraVR, parent);\n\n\t\t\tfor (let i = 0; i < cameras.length; i++) {\n\t\t\t\tupdateCamera(cameras[i], parent);\n\t\t\t}\n\n\t\t\tcameraVR.matrixWorld.decompose(cameraVR.position, cameraVR.quaternion, cameraVR.scale); // update user camera and its children\n\n\t\t\tcamera.matrix.copy(cameraVR.matrix);\n\t\t\tcamera.matrix.decompose(camera.position, camera.quaternion, camera.scale);\n\t\t\tconst children = camera.children;\n\n\t\t\tfor (let i = 0, l = children.length; i < l; i++) {\n\t\t\t\tchildren[i].updateMatrixWorld(true);\n\t\t\t} // update projection matrix for proper view frustum culling\n\n\n\t\t\tif (cameras.length === 2) {\n\t\t\t\tsetProjectionFromUnion(cameraVR, cameraL, cameraR);\n\t\t\t} else {\n\t\t\t\t// assume single camera setup (AR)\n\t\t\t\tcameraVR.projectionMatrix.copy(cameraL.projectionMatrix);\n\t\t\t}\n\t\t};\n\n\t\tthis.getCamera = function () {\n\t\t\treturn cameraVR;\n\t\t};\n\n\t\tthis.getFoveation = function () {\n\t\t\tif (glProjLayer !== null) {\n\t\t\t\treturn glProjLayer.fixedFoveation;\n\t\t\t}\n\n\t\t\tif (glBaseLayer !== null) {\n\t\t\t\treturn glBaseLayer.fixedFoveation;\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t};\n\n\t\tthis.setFoveation = function (foveation) {\n\t\t\t// 0 = no foveation = full resolution\n\t\t\t// 1 = maximum foveation = the edges render at lower resolution\n\t\t\tif (glProjLayer !== null) {\n\t\t\t\tglProjLayer.fixedFoveation = foveation;\n\t\t\t}\n\n\t\t\tif (glBaseLayer !== null && glBaseLayer.fixedFoveation !== undefined) {\n\t\t\t\tglBaseLayer.fixedFoveation = foveation;\n\t\t\t}\n\t\t}; // Animation Loop\n\n\n\t\tlet onAnimationFrameCallback = null;\n\n\t\tfunction onAnimationFrame(time, frame) {\n\t\t\tpose = frame.getViewerPose(customReferenceSpace || referenceSpace);\n\t\t\txrFrame = frame;\n\n\t\t\tif (pose !== null) {\n\t\t\t\tconst views = pose.views;\n\n\t\t\t\tif (glBaseLayer !== null) {\n\t\t\t\t\trenderer.setRenderTargetFramebuffer(newRenderTarget, glBaseLayer.framebuffer);\n\t\t\t\t\trenderer.setRenderTarget(newRenderTarget);\n\t\t\t\t}\n\n\t\t\t\tlet cameraVRNeedsUpdate = false; // check if it's necessary to rebuild cameraVR's camera list\n\n\t\t\t\tif (views.length !== cameraVR.cameras.length) {\n\t\t\t\t\tcameraVR.cameras.length = 0;\n\t\t\t\t\tcameraVRNeedsUpdate = true;\n\t\t\t\t}\n\n\t\t\t\tfor (let i = 0; i < views.length; i++) {\n\t\t\t\t\tconst view = views[i];\n\t\t\t\t\tlet viewport = null;\n\n\t\t\t\t\tif (glBaseLayer !== null) {\n\t\t\t\t\t\tviewport = glBaseLayer.getViewport(view);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst glSubImage = glBinding.getViewSubImage(glProjLayer, view);\n\t\t\t\t\t\tviewport = glSubImage.viewport; // For side-by-side projection, we only produce a single texture for both eyes.\n\n\t\t\t\t\t\tif (i === 0) {\n\t\t\t\t\t\t\trenderer.setRenderTargetTextures(newRenderTarget, glSubImage.colorTexture, glProjLayer.ignoreDepthValues ? undefined : glSubImage.depthStencilTexture);\n\t\t\t\t\t\t\trenderer.setRenderTarget(newRenderTarget);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tlet camera = cameras[i];\n\n\t\t\t\t\tif (camera === undefined) {\n\t\t\t\t\t\tcamera = new PerspectiveCamera();\n\t\t\t\t\t\tcamera.layers.enable(i);\n\t\t\t\t\t\tcamera.viewport = new Vector4();\n\t\t\t\t\t\tcameras[i] = camera;\n\t\t\t\t\t}\n\n\t\t\t\t\tcamera.matrix.fromArray(view.transform.matrix);\n\t\t\t\t\tcamera.projectionMatrix.fromArray(view.projectionMatrix);\n\t\t\t\t\tcamera.viewport.set(viewport.x, viewport.y, viewport.width, viewport.height);\n\n\t\t\t\t\tif (i === 0) {\n\t\t\t\t\t\tcameraVR.matrix.copy(camera.matrix);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (cameraVRNeedsUpdate === true) {\n\t\t\t\t\t\tcameraVR.cameras.push(camera);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} //\n\n\n\t\t\tfor (let i = 0; i < controllers.length; i++) {\n\t\t\t\tconst inputSource = controllerInputSources[i];\n\t\t\t\tconst controller = controllers[i];\n\n\t\t\t\tif (inputSource !== null && controller !== undefined) {\n\t\t\t\t\tcontroller.update(inputSource, frame, customReferenceSpace || referenceSpace);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (onAnimationFrameCallback) onAnimationFrameCallback(time, frame);\n\t\t\txrFrame = null;\n\t\t}\n\n\t\tconst animation = new WebGLAnimation();\n\t\tanimation.setAnimationLoop(onAnimationFrame);\n\n\t\tthis.setAnimationLoop = function (callback) {\n\t\t\tonAnimationFrameCallback = callback;\n\t\t};\n\n\t\tthis.dispose = function () {};\n\t}\n\n}\n\nfunction WebGLMaterials(renderer, properties) {\n\tfunction refreshFogUniforms(uniforms, fog) {\n\t\tuniforms.fogColor.value.copy(fog.color);\n\n\t\tif (fog.isFog) {\n\t\t\tuniforms.fogNear.value = fog.near;\n\t\t\tuniforms.fogFar.value = fog.far;\n\t\t} else if (fog.isFogExp2) {\n\t\t\tuniforms.fogDensity.value = fog.density;\n\t\t}\n\t}\n\n\tfunction refreshMaterialUniforms(uniforms, material, pixelRatio, height, transmissionRenderTarget) {\n\t\tif (material.isMeshBasicMaterial) {\n\t\t\trefreshUniformsCommon(uniforms, material);\n\t\t} else if (material.isMeshLambertMaterial) {\n\t\t\trefreshUniformsCommon(uniforms, material);\n\t\t} else if (material.isMeshToonMaterial) {\n\t\t\trefreshUniformsCommon(uniforms, material);\n\t\t\trefreshUniformsToon(uniforms, material);\n\t\t} else if (material.isMeshPhongMaterial) {\n\t\t\trefreshUniformsCommon(uniforms, material);\n\t\t\trefreshUniformsPhong(uniforms, material);\n\t\t} else if (material.isMeshStandardMaterial) {\n\t\t\trefreshUniformsCommon(uniforms, material);\n\t\t\trefreshUniformsStandard(uniforms, material);\n\n\t\t\tif (material.isMeshPhysicalMaterial) {\n\t\t\t\trefreshUniformsPhysical(uniforms, material, transmissionRenderTarget);\n\t\t\t}\n\t\t} else if (material.isMeshMatcapMaterial) {\n\t\t\trefreshUniformsCommon(uniforms, material);\n\t\t\trefreshUniformsMatcap(uniforms, material);\n\t\t} else if (material.isMeshDepthMaterial) {\n\t\t\trefreshUniformsCommon(uniforms, material);\n\t\t} else if (material.isMeshDistanceMaterial) {\n\t\t\trefreshUniformsCommon(uniforms, material);\n\t\t\trefreshUniformsDistance(uniforms, material);\n\t\t} else if (material.isMeshNormalMaterial) {\n\t\t\trefreshUniformsCommon(uniforms, material);\n\t\t} else if (material.isLineBasicMaterial) {\n\t\t\trefreshUniformsLine(uniforms, material);\n\n\t\t\tif (material.isLineDashedMaterial) {\n\t\t\t\trefreshUniformsDash(uniforms, material);\n\t\t\t}\n\t\t} else if (material.isPointsMaterial) {\n\t\t\trefreshUniformsPoints(uniforms, material, pixelRatio, height);\n\t\t} else if (material.isSpriteMaterial) {\n\t\t\trefreshUniformsSprites(uniforms, material);\n\t\t} else if (material.isShadowMaterial) {\n\t\t\tuniforms.color.value.copy(material.color);\n\t\t\tuniforms.opacity.value = material.opacity;\n\t\t} else if (material.isShaderMaterial) {\n\t\t\tmaterial.uniformsNeedUpdate = false; // #15581\n\t\t}\n\t}\n\n\tfunction refreshUniformsCommon(uniforms, material) {\n\t\tuniforms.opacity.value = material.opacity;\n\n\t\tif (material.color) {\n\t\t\tuniforms.diffuse.value.copy(material.color);\n\t\t}\n\n\t\tif (material.emissive) {\n\t\t\tuniforms.emissive.value.copy(material.emissive).multiplyScalar(material.emissiveIntensity);\n\t\t}\n\n\t\tif (material.map) {\n\t\t\tuniforms.map.value = material.map;\n\t\t}\n\n\t\tif (material.alphaMap) {\n\t\t\tuniforms.alphaMap.value = material.alphaMap;\n\t\t}\n\n\t\tif (material.bumpMap) {\n\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\tif (material.side === BackSide) uniforms.bumpScale.value *= -1;\n\t\t}\n\n\t\tif (material.displacementMap) {\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\t\t}\n\n\t\tif (material.emissiveMap) {\n\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\t\t}\n\n\t\tif (material.normalMap) {\n\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\tuniforms.normalScale.value.copy(material.normalScale);\n\t\t\tif (material.side === BackSide) uniforms.normalScale.value.negate();\n\t\t}\n\n\t\tif (material.specularMap) {\n\t\t\tuniforms.specularMap.value = material.specularMap;\n\t\t}\n\n\t\tif (material.alphaTest > 0) {\n\t\t\tuniforms.alphaTest.value = material.alphaTest;\n\t\t}\n\n\t\tconst envMap = properties.get(material).envMap;\n\n\t\tif (envMap) {\n\t\t\tuniforms.envMap.value = envMap;\n\t\t\tuniforms.flipEnvMap.value = envMap.isCubeTexture && envMap.isRenderTargetTexture === false ? -1 : 1;\n\t\t\tuniforms.reflectivity.value = material.reflectivity;\n\t\t\tuniforms.ior.value = material.ior;\n\t\t\tuniforms.refractionRatio.value = material.refractionRatio;\n\t\t}\n\n\t\tif (material.lightMap) {\n\t\t\tuniforms.lightMap.value = material.lightMap; // artist-friendly light intensity scaling factor\n\n\t\t\tconst scaleFactor = renderer.physicallyCorrectLights !== true ? Math.PI : 1;\n\t\t\tuniforms.lightMapIntensity.value = material.lightMapIntensity * scaleFactor;\n\t\t}\n\n\t\tif (material.aoMap) {\n\t\t\tuniforms.aoMap.value = material.aoMap;\n\t\t\tuniforms.aoMapIntensity.value = material.aoMapIntensity;\n\t\t} // uv repeat and offset setting priorities\n\t\t// 1. color map\n\t\t// 2. specular map\n\t\t// 3. displacementMap map\n\t\t// 4. normal map\n\t\t// 5. bump map\n\t\t// 6. roughnessMap map\n\t\t// 7. metalnessMap map\n\t\t// 8. alphaMap map\n\t\t// 9. emissiveMap map\n\t\t// 10. clearcoat map\n\t\t// 11. clearcoat normal map\n\t\t// 12. clearcoat roughnessMap map\n\t\t// 13. iridescence map\n\t\t// 14. iridescence thickness map\n\t\t// 15. specular intensity map\n\t\t// 16. specular tint map\n\t\t// 17. transmission map\n\t\t// 18. thickness map\n\n\n\t\tlet uvScaleMap;\n\n\t\tif (material.map) {\n\t\t\tuvScaleMap = material.map;\n\t\t} else if (material.specularMap) {\n\t\t\tuvScaleMap = material.specularMap;\n\t\t} else if (material.displacementMap) {\n\t\t\tuvScaleMap = material.displacementMap;\n\t\t} else if (material.normalMap) {\n\t\t\tuvScaleMap = material.normalMap;\n\t\t} else if (material.bumpMap) {\n\t\t\tuvScaleMap = material.bumpMap;\n\t\t} else if (material.roughnessMap) {\n\t\t\tuvScaleMap = material.roughnessMap;\n\t\t} else if (material.metalnessMap) {\n\t\t\tuvScaleMap = material.metalnessMap;\n\t\t} else if (material.alphaMap) {\n\t\t\tuvScaleMap = material.alphaMap;\n\t\t} else if (material.emissiveMap) {\n\t\t\tuvScaleMap = material.emissiveMap;\n\t\t} else if (material.clearcoatMap) {\n\t\t\tuvScaleMap = material.clearcoatMap;\n\t\t} else if (material.clearcoatNormalMap) {\n\t\t\tuvScaleMap = material.clearcoatNormalMap;\n\t\t} else if (material.clearcoatRoughnessMap) {\n\t\t\tuvScaleMap = material.clearcoatRoughnessMap;\n\t\t} else if (material.iridescenceMap) {\n\t\t\tuvScaleMap = material.iridescenceMap;\n\t\t} else if (material.iridescenceThicknessMap) {\n\t\t\tuvScaleMap = material.iridescenceThicknessMap;\n\t\t} else if (material.specularIntensityMap) {\n\t\t\tuvScaleMap = material.specularIntensityMap;\n\t\t} else if (material.specularColorMap) {\n\t\t\tuvScaleMap = material.specularColorMap;\n\t\t} else if (material.transmissionMap) {\n\t\t\tuvScaleMap = material.transmissionMap;\n\t\t} else if (material.thicknessMap) {\n\t\t\tuvScaleMap = material.thicknessMap;\n\t\t} else if (material.sheenColorMap) {\n\t\t\tuvScaleMap = material.sheenColorMap;\n\t\t} else if (material.sheenRoughnessMap) {\n\t\t\tuvScaleMap = material.sheenRoughnessMap;\n\t\t}\n\n\t\tif (uvScaleMap !== undefined) {\n\t\t\t// backwards compatibility\n\t\t\tif (uvScaleMap.isWebGLRenderTarget) {\n\t\t\t\tuvScaleMap = uvScaleMap.texture;\n\t\t\t}\n\n\t\t\tif (uvScaleMap.matrixAutoUpdate === true) {\n\t\t\t\tuvScaleMap.updateMatrix();\n\t\t\t}\n\n\t\t\tuniforms.uvTransform.value.copy(uvScaleMap.matrix);\n\t\t} // uv repeat and offset setting priorities for uv2\n\t\t// 1. ao map\n\t\t// 2. light map\n\n\n\t\tlet uv2ScaleMap;\n\n\t\tif (material.aoMap) {\n\t\t\tuv2ScaleMap = material.aoMap;\n\t\t} else if (material.lightMap) {\n\t\t\tuv2ScaleMap = material.lightMap;\n\t\t}\n\n\t\tif (uv2ScaleMap !== undefined) {\n\t\t\t// backwards compatibility\n\t\t\tif (uv2ScaleMap.isWebGLRenderTarget) {\n\t\t\t\tuv2ScaleMap = uv2ScaleMap.texture;\n\t\t\t}\n\n\t\t\tif (uv2ScaleMap.matrixAutoUpdate === true) {\n\t\t\t\tuv2ScaleMap.updateMatrix();\n\t\t\t}\n\n\t\t\tuniforms.uv2Transform.value.copy(uv2ScaleMap.matrix);\n\t\t}\n\t}\n\n\tfunction refreshUniformsLine(uniforms, material) {\n\t\tuniforms.diffuse.value.copy(material.color);\n\t\tuniforms.opacity.value = material.opacity;\n\t}\n\n\tfunction refreshUniformsDash(uniforms, material) {\n\t\tuniforms.dashSize.value = material.dashSize;\n\t\tuniforms.totalSize.value = material.dashSize + material.gapSize;\n\t\tuniforms.scale.value = material.scale;\n\t}\n\n\tfunction refreshUniformsPoints(uniforms, material, pixelRatio, height) {\n\t\tuniforms.diffuse.value.copy(material.color);\n\t\tuniforms.opacity.value = material.opacity;\n\t\tuniforms.size.value = material.size * pixelRatio;\n\t\tuniforms.scale.value = height * 0.5;\n\n\t\tif (material.map) {\n\t\t\tuniforms.map.value = material.map;\n\t\t}\n\n\t\tif (material.alphaMap) {\n\t\t\tuniforms.alphaMap.value = material.alphaMap;\n\t\t}\n\n\t\tif (material.alphaTest > 0) {\n\t\t\tuniforms.alphaTest.value = material.alphaTest;\n\t\t} // uv repeat and offset setting priorities\n\t\t// 1. color map\n\t\t// 2. alpha map\n\n\n\t\tlet uvScaleMap;\n\n\t\tif (material.map) {\n\t\t\tuvScaleMap = material.map;\n\t\t} else if (material.alphaMap) {\n\t\t\tuvScaleMap = material.alphaMap;\n\t\t}\n\n\t\tif (uvScaleMap !== undefined) {\n\t\t\tif (uvScaleMap.matrixAutoUpdate === true) {\n\t\t\t\tuvScaleMap.updateMatrix();\n\t\t\t}\n\n\t\t\tuniforms.uvTransform.value.copy(uvScaleMap.matrix);\n\t\t}\n\t}\n\n\tfunction refreshUniformsSprites(uniforms, material) {\n\t\tuniforms.diffuse.value.copy(material.color);\n\t\tuniforms.opacity.value = material.opacity;\n\t\tuniforms.rotation.value = material.rotation;\n\n\t\tif (material.map) {\n\t\t\tuniforms.map.value = material.map;\n\t\t}\n\n\t\tif (material.alphaMap) {\n\t\t\tuniforms.alphaMap.value = material.alphaMap;\n\t\t}\n\n\t\tif (material.alphaTest > 0) {\n\t\t\tuniforms.alphaTest.value = material.alphaTest;\n\t\t} // uv repeat and offset setting priorities\n\t\t// 1. color map\n\t\t// 2. alpha map\n\n\n\t\tlet uvScaleMap;\n\n\t\tif (material.map) {\n\t\t\tuvScaleMap = material.map;\n\t\t} else if (material.alphaMap) {\n\t\t\tuvScaleMap = material.alphaMap;\n\t\t}\n\n\t\tif (uvScaleMap !== undefined) {\n\t\t\tif (uvScaleMap.matrixAutoUpdate === true) {\n\t\t\t\tuvScaleMap.updateMatrix();\n\t\t\t}\n\n\t\t\tuniforms.uvTransform.value.copy(uvScaleMap.matrix);\n\t\t}\n\t}\n\n\tfunction refreshUniformsPhong(uniforms, material) {\n\t\tuniforms.specular.value.copy(material.specular);\n\t\tuniforms.shininess.value = Math.max(material.shininess, 1e-4); // to prevent pow( 0.0, 0.0 )\n\t}\n\n\tfunction refreshUniformsToon(uniforms, material) {\n\t\tif (material.gradientMap) {\n\t\t\tuniforms.gradientMap.value = material.gradientMap;\n\t\t}\n\t}\n\n\tfunction refreshUniformsStandard(uniforms, material) {\n\t\tuniforms.roughness.value = material.roughness;\n\t\tuniforms.metalness.value = material.metalness;\n\n\t\tif (material.roughnessMap) {\n\t\t\tuniforms.roughnessMap.value = material.roughnessMap;\n\t\t}\n\n\t\tif (material.metalnessMap) {\n\t\t\tuniforms.metalnessMap.value = material.metalnessMap;\n\t\t}\n\n\t\tconst envMap = properties.get(material).envMap;\n\n\t\tif (envMap) {\n\t\t\t//uniforms.envMap.value = material.envMap; // part of uniforms common\n\t\t\tuniforms.envMapIntensity.value = material.envMapIntensity;\n\t\t}\n\t}\n\n\tfunction refreshUniformsPhysical(uniforms, material, transmissionRenderTarget) {\n\t\tuniforms.ior.value = material.ior; // also part of uniforms common\n\n\t\tif (material.sheen > 0) {\n\t\t\tuniforms.sheenColor.value.copy(material.sheenColor).multiplyScalar(material.sheen);\n\t\t\tuniforms.sheenRoughness.value = material.sheenRoughness;\n\n\t\t\tif (material.sheenColorMap) {\n\t\t\t\tuniforms.sheenColorMap.value = material.sheenColorMap;\n\t\t\t}\n\n\t\t\tif (material.sheenRoughnessMap) {\n\t\t\t\tuniforms.sheenRoughnessMap.value = material.sheenRoughnessMap;\n\t\t\t}\n\t\t}\n\n\t\tif (material.clearcoat > 0) {\n\t\t\tuniforms.clearcoat.value = material.clearcoat;\n\t\t\tuniforms.clearcoatRoughness.value = material.clearcoatRoughness;\n\n\t\t\tif (material.clearcoatMap) {\n\t\t\t\tuniforms.clearcoatMap.value = material.clearcoatMap;\n\t\t\t}\n\n\t\t\tif (material.clearcoatRoughnessMap) {\n\t\t\t\tuniforms.clearcoatRoughnessMap.value = material.clearcoatRoughnessMap;\n\t\t\t}\n\n\t\t\tif (material.clearcoatNormalMap) {\n\t\t\t\tuniforms.clearcoatNormalScale.value.copy(material.clearcoatNormalScale);\n\t\t\t\tuniforms.clearcoatNormalMap.value = material.clearcoatNormalMap;\n\n\t\t\t\tif (material.side === BackSide) {\n\t\t\t\t\tuniforms.clearcoatNormalScale.value.negate();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (material.iridescence > 0) {\n\t\t\tuniforms.iridescence.value = material.iridescence;\n\t\t\tuniforms.iridescenceIOR.value = material.iridescenceIOR;\n\t\t\tuniforms.iridescenceThicknessMinimum.value = material.iridescenceThicknessRange[0];\n\t\t\tuniforms.iridescenceThicknessMaximum.value = material.iridescenceThicknessRange[1];\n\n\t\t\tif (material.iridescenceMap) {\n\t\t\t\tuniforms.iridescenceMap.value = material.iridescenceMap;\n\t\t\t}\n\n\t\t\tif (material.iridescenceThicknessMap) {\n\t\t\t\tuniforms.iridescenceThicknessMap.value = material.iridescenceThicknessMap;\n\t\t\t}\n\t\t}\n\n\t\tif (material.transmission > 0) {\n\t\t\tuniforms.transmission.value = material.transmission;\n\t\t\tuniforms.transmissionSamplerMap.value = transmissionRenderTarget.texture;\n\t\t\tuniforms.transmissionSamplerSize.value.set(transmissionRenderTarget.width, transmissionRenderTarget.height);\n\n\t\t\tif (material.transmissionMap) {\n\t\t\t\tuniforms.transmissionMap.value = material.transmissionMap;\n\t\t\t}\n\n\t\t\tuniforms.thickness.value = material.thickness;\n\n\t\t\tif (material.thicknessMap) {\n\t\t\t\tuniforms.thicknessMap.value = material.thicknessMap;\n\t\t\t}\n\n\t\t\tuniforms.attenuationDistance.value = material.attenuationDistance;\n\t\t\tuniforms.attenuationColor.value.copy(material.attenuationColor);\n\t\t}\n\n\t\tuniforms.specularIntensity.value = material.specularIntensity;\n\t\tuniforms.specularColor.value.copy(material.specularColor);\n\n\t\tif (material.specularIntensityMap) {\n\t\t\tuniforms.specularIntensityMap.value = material.specularIntensityMap;\n\t\t}\n\n\t\tif (material.specularColorMap) {\n\t\t\tuniforms.specularColorMap.value = material.specularColorMap;\n\t\t}\n\t}\n\n\tfunction refreshUniformsMatcap(uniforms, material) {\n\t\tif (material.matcap) {\n\t\t\tuniforms.matcap.value = material.matcap;\n\t\t}\n\t}\n\n\tfunction refreshUniformsDistance(uniforms, material) {\n\t\tuniforms.referencePosition.value.copy(material.referencePosition);\n\t\tuniforms.nearDistance.value = material.nearDistance;\n\t\tuniforms.farDistance.value = material.farDistance;\n\t}\n\n\treturn {\n\t\trefreshFogUniforms: refreshFogUniforms,\n\t\trefreshMaterialUniforms: refreshMaterialUniforms\n\t};\n}\n\nfunction WebGLUniformsGroups(gl, info, capabilities, state) {\n\tlet buffers = {};\n\tlet updateList = {};\n\tlet allocatedBindingPoints = [];\n\tconst maxBindingPoints = capabilities.isWebGL2 ? gl.getParameter(gl.MAX_UNIFORM_BUFFER_BINDINGS) : 0; // binding points are global whereas block indices are per shader program\n\n\tfunction bind(uniformsGroup, program) {\n\t\tconst webglProgram = program.program;\n\t\tstate.uniformBlockBinding(uniformsGroup, webglProgram);\n\t}\n\n\tfunction update(uniformsGroup, program) {\n\t\tlet buffer = buffers[uniformsGroup.id];\n\n\t\tif (buffer === undefined) {\n\t\t\tprepareUniformsGroup(uniformsGroup);\n\t\t\tbuffer = createBuffer(uniformsGroup);\n\t\t\tbuffers[uniformsGroup.id] = buffer;\n\t\t\tuniformsGroup.addEventListener('dispose', onUniformsGroupsDispose);\n\t\t} // ensure to update the binding points/block indices mapping for this program\n\n\n\t\tconst webglProgram = program.program;\n\t\tstate.updateUBOMapping(uniformsGroup, webglProgram); // update UBO once per frame\n\n\t\tconst frame = info.render.frame;\n\n\t\tif (updateList[uniformsGroup.id] !== frame) {\n\t\t\tupdateBufferData(uniformsGroup);\n\t\t\tupdateList[uniformsGroup.id] = frame;\n\t\t}\n\t}\n\n\tfunction createBuffer(uniformsGroup) {\n\t\t// the setup of an UBO is independent of a particular shader program but global\n\t\tconst bindingPointIndex = allocateBindingPointIndex();\n\t\tuniformsGroup.__bindingPointIndex = bindingPointIndex;\n\t\tconst buffer = gl.createBuffer();\n\t\tconst size = uniformsGroup.__size;\n\t\tconst usage = uniformsGroup.usage;\n\t\tgl.bindBuffer(gl.UNIFORM_BUFFER, buffer);\n\t\tgl.bufferData(gl.UNIFORM_BUFFER, size, usage);\n\t\tgl.bindBuffer(gl.UNIFORM_BUFFER, null);\n\t\tgl.bindBufferBase(gl.UNIFORM_BUFFER, bindingPointIndex, buffer);\n\t\treturn buffer;\n\t}\n\n\tfunction allocateBindingPointIndex() {\n\t\tfor (let i = 0; i < maxBindingPoints; i++) {\n\t\t\tif (allocatedBindingPoints.indexOf(i) === -1) {\n\t\t\t\tallocatedBindingPoints.push(i);\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\n\t\tconsole.error('THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached.');\n\t\treturn 0;\n\t}\n\n\tfunction updateBufferData(uniformsGroup) {\n\t\tconst buffer = buffers[uniformsGroup.id];\n\t\tconst uniforms = uniformsGroup.uniforms;\n\t\tconst cache = uniformsGroup.__cache;\n\t\tgl.bindBuffer(gl.UNIFORM_BUFFER, buffer);\n\n\t\tfor (let i = 0, il = uniforms.length; i < il; i++) {\n\t\t\tconst uniform = uniforms[i]; // partly update the buffer if necessary\n\n\t\t\tif (hasUniformChanged(uniform, i, cache) === true) {\n\t\t\t\tconst value = uniform.value;\n\t\t\t\tconst offset = uniform.__offset;\n\n\t\t\t\tif (typeof value === 'number') {\n\t\t\t\t\tuniform.__data[0] = value;\n\t\t\t\t\tgl.bufferSubData(gl.UNIFORM_BUFFER, offset, uniform.__data);\n\t\t\t\t} else {\n\t\t\t\t\tif (uniform.value.isMatrix3) {\n\t\t\t\t\t\t// manually converting 3x3 to 3x4\n\t\t\t\t\t\tuniform.__data[0] = uniform.value.elements[0];\n\t\t\t\t\t\tuniform.__data[1] = uniform.value.elements[1];\n\t\t\t\t\t\tuniform.__data[2] = uniform.value.elements[2];\n\t\t\t\t\t\tuniform.__data[3] = uniform.value.elements[0];\n\t\t\t\t\t\tuniform.__data[4] = uniform.value.elements[3];\n\t\t\t\t\t\tuniform.__data[5] = uniform.value.elements[4];\n\t\t\t\t\t\tuniform.__data[6] = uniform.value.elements[5];\n\t\t\t\t\t\tuniform.__data[7] = uniform.value.elements[0];\n\t\t\t\t\t\tuniform.__data[8] = uniform.value.elements[6];\n\t\t\t\t\t\tuniform.__data[9] = uniform.value.elements[7];\n\t\t\t\t\t\tuniform.__data[10] = uniform.value.elements[8];\n\t\t\t\t\t\tuniform.__data[11] = uniform.value.elements[0];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalue.toArray(uniform.__data);\n\t\t\t\t\t}\n\n\t\t\t\t\tgl.bufferSubData(gl.UNIFORM_BUFFER, offset, uniform.__data);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tgl.bindBuffer(gl.UNIFORM_BUFFER, null);\n\t}\n\n\tfunction hasUniformChanged(uniform, index, cache) {\n\t\tconst value = uniform.value;\n\n\t\tif (cache[index] === undefined) {\n\t\t\t// cache entry does not exist so far\n\t\t\tif (typeof value === 'number') {\n\t\t\t\tcache[index] = value;\n\t\t\t} else {\n\t\t\t\tcache[index] = value.clone();\n\t\t\t}\n\n\t\t\treturn true;\n\t\t} else {\n\t\t\t// compare current value with cached entry\n\t\t\tif (typeof value === 'number') {\n\t\t\t\tif (cache[index] !== value) {\n\t\t\t\t\tcache[index] = value;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst cachedObject = cache[index];\n\n\t\t\t\tif (cachedObject.equals(value) === false) {\n\t\t\t\t\tcachedObject.copy(value);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tfunction prepareUniformsGroup(uniformsGroup) {\n\t\t// determine total buffer size according to the STD140 layout\n\t\t// Hint: STD140 is the only supported layout in WebGL 2\n\t\tconst uniforms = uniformsGroup.uniforms;\n\t\tlet offset = 0; // global buffer offset in bytes\n\n\t\tconst chunkSize = 16; // size of a chunk in bytes\n\n\t\tlet chunkOffset = 0; // offset within a single chunk in bytes\n\n\t\tfor (let i = 0, l = uniforms.length; i < l; i++) {\n\t\t\tconst uniform = uniforms[i];\n\t\t\tconst info = getUniformSize(uniform); // the following two properties will be used for partial buffer updates\n\n\t\t\tuniform.__data = new Float32Array(info.storage / Float32Array.BYTES_PER_ELEMENT);\n\t\t\tuniform.__offset = offset; //\n\n\t\t\tif (i > 0) {\n\t\t\t\tchunkOffset = offset % chunkSize;\n\t\t\t\tconst remainingSizeInChunk = chunkSize - chunkOffset; // check for chunk overflow\n\n\t\t\t\tif (chunkOffset !== 0 && remainingSizeInChunk - info.boundary < 0) {\n\t\t\t\t\t// add padding and adjust offset\n\t\t\t\t\toffset += chunkSize - chunkOffset;\n\t\t\t\t\tuniform.__offset = offset;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\toffset += info.storage;\n\t\t} // ensure correct final padding\n\n\n\t\tchunkOffset = offset % chunkSize;\n\t\tif (chunkOffset > 0) offset += chunkSize - chunkOffset; //\n\n\t\tuniformsGroup.__size = offset;\n\t\tuniformsGroup.__cache = {};\n\t\treturn this;\n\t}\n\n\tfunction getUniformSize(uniform) {\n\t\tconst value = uniform.value;\n\t\tconst info = {\n\t\t\tboundary: 0,\n\t\t\t// bytes\n\t\t\tstorage: 0 // bytes\n\n\t\t}; // determine sizes according to STD140\n\n\t\tif (typeof value === 'number') {\n\t\t\t// float/int\n\t\t\tinfo.boundary = 4;\n\t\t\tinfo.storage = 4;\n\t\t} else if (value.isVector2) {\n\t\t\t// vec2\n\t\t\tinfo.boundary = 8;\n\t\t\tinfo.storage = 8;\n\t\t} else if (value.isVector3 || value.isColor) {\n\t\t\t// vec3\n\t\t\tinfo.boundary = 16;\n\t\t\tinfo.storage = 12; // evil: vec3 must start on a 16-byte boundary but it only consumes 12 bytes\n\t\t} else if (value.isVector4) {\n\t\t\t// vec4\n\t\t\tinfo.boundary = 16;\n\t\t\tinfo.storage = 16;\n\t\t} else if (value.isMatrix3) {\n\t\t\t// mat3 (in STD140 a 3x3 matrix is represented as 3x4)\n\t\t\tinfo.boundary = 48;\n\t\t\tinfo.storage = 48;\n\t\t} else if (value.isMatrix4) {\n\t\t\t// mat4\n\t\t\tinfo.boundary = 64;\n\t\t\tinfo.storage = 64;\n\t\t} else if (value.isTexture) {\n\t\t\tconsole.warn('THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.');\n\t\t} else {\n\t\t\tconsole.warn('THREE.WebGLRenderer: Unsupported uniform value type.', value);\n\t\t}\n\n\t\treturn info;\n\t}\n\n\tfunction onUniformsGroupsDispose(event) {\n\t\tconst uniformsGroup = event.target;\n\t\tuniformsGroup.removeEventListener('dispose', onUniformsGroupsDispose);\n\t\tconst index = allocatedBindingPoints.indexOf(uniformsGroup.__bindingPointIndex);\n\t\tallocatedBindingPoints.splice(index, 1);\n\t\tgl.deleteBuffer(buffers[uniformsGroup.id]);\n\t\tdelete buffers[uniformsGroup.id];\n\t\tdelete updateList[uniformsGroup.id];\n\t}\n\n\tfunction dispose() {\n\t\tfor (const id in buffers) {\n\t\t\tgl.deleteBuffer(buffers[id]);\n\t\t}\n\n\t\tallocatedBindingPoints = [];\n\t\tbuffers = {};\n\t\tupdateList = {};\n\t}\n\n\treturn {\n\t\tbind: bind,\n\t\tupdate: update,\n\t\tdispose: dispose\n\t};\n}\n\nfunction createCanvasElement() {\n\tconst canvas = createElementNS('canvas');\n\tcanvas.style.display = 'block';\n\treturn canvas;\n}\n\nfunction WebGLRenderer(parameters = {}) {\n\tthis.isWebGLRenderer = true;\n\n\tconst _canvas = parameters.canvas !== undefined ? parameters.canvas : createCanvasElement(),\n\t\t\t\t_context = parameters.context !== undefined ? parameters.context : null,\n\t\t\t\t_depth = parameters.depth !== undefined ? parameters.depth : true,\n\t\t\t\t_stencil = parameters.stencil !== undefined ? parameters.stencil : true,\n\t\t\t\t_antialias = parameters.antialias !== undefined ? parameters.antialias : false,\n\t\t\t\t_premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true,\n\t\t\t\t_preserveDrawingBuffer = parameters.preserveDrawingBuffer !== undefined ? parameters.preserveDrawingBuffer : false,\n\t\t\t\t_powerPreference = parameters.powerPreference !== undefined ? parameters.powerPreference : 'default',\n\t\t\t\t_failIfMajorPerformanceCaveat = parameters.failIfMajorPerformanceCaveat !== undefined ? parameters.failIfMajorPerformanceCaveat : false;\n\n\tlet _alpha;\n\n\tif (_context !== null) {\n\t\t_alpha = _context.getContextAttributes().alpha;\n\t} else {\n\t\t_alpha = parameters.alpha !== undefined ? parameters.alpha : false;\n\t}\n\n\tlet currentRenderList = null;\n\tlet currentRenderState = null; // render() can be called from within a callback triggered by another render.\n\t// We track this so that the nested render call gets its list and state isolated from the parent render call.\n\n\tconst renderListStack = [];\n\tconst renderStateStack = []; // public properties\n\n\tthis.domElement = _canvas; // Debug configuration container\n\n\tthis.debug = {\n\t\t/**\n\t\t * Enables error checking and reporting when shader programs are being compiled\n\t\t * @type {boolean}\n\t\t */\n\t\tcheckShaderErrors: true\n\t}; // clearing\n\n\tthis.autoClear = true;\n\tthis.autoClearColor = true;\n\tthis.autoClearDepth = true;\n\tthis.autoClearStencil = true; // scene graph\n\n\tthis.sortObjects = true; // user-defined clipping\n\n\tthis.clippingPlanes = [];\n\tthis.localClippingEnabled = false; // physically based shading\n\n\tthis.outputEncoding = LinearEncoding; // physical lights\n\n\tthis.physicallyCorrectLights = false; // tone mapping\n\n\tthis.toneMapping = NoToneMapping;\n\tthis.toneMappingExposure = 1.0; //\n\n\tObject.defineProperties(this, {\n\t\t// @deprecated since r136, 0e21088102b4de7e0a0a33140620b7a3424b9e6d\n\t\tgammaFactor: {\n\t\t\tget: function () {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: .gammaFactor has been removed.');\n\t\t\t\treturn 2;\n\t\t\t},\n\t\t\tset: function () {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: .gammaFactor has been removed.');\n\t\t\t}\n\t\t}\n\t}); // internal properties\n\n\tconst _this = this;\n\n\tlet _isContextLost = false; // internal state cache\n\n\tlet _currentActiveCubeFace = 0;\n\tlet _currentActiveMipmapLevel = 0;\n\tlet _currentRenderTarget = null;\n\n\tlet _currentMaterialId = -1;\n\n\tlet _currentCamera = null;\n\n\tconst _currentViewport = new Vector4();\n\n\tconst _currentScissor = new Vector4();\n\n\tlet _currentScissorTest = null; //\n\n\tlet _width = _canvas.width;\n\tlet _height = _canvas.height;\n\tlet _pixelRatio = 1;\n\tlet _opaqueSort = null;\n\tlet _transparentSort = null;\n\n\tconst _viewport = new Vector4(0, 0, _width, _height);\n\n\tconst _scissor = new Vector4(0, 0, _width, _height);\n\n\tlet _scissorTest = false; // frustum\n\n\tconst _frustum = new Frustum(); // clipping\n\n\n\tlet _clippingEnabled = false;\n\tlet _localClippingEnabled = false; // transmission\n\n\tlet _transmissionRenderTarget = null; // camera matrices cache\n\n\tconst _projScreenMatrix = new Matrix4();\n\n\tconst _vector2 = new Vector2();\n\n\tconst _vector3 = new Vector3();\n\n\tconst _emptyScene = {\n\t\tbackground: null,\n\t\tfog: null,\n\t\tenvironment: null,\n\t\toverrideMaterial: null,\n\t\tisScene: true\n\t};\n\n\tfunction getTargetPixelRatio() {\n\t\treturn _currentRenderTarget === null ? _pixelRatio : 1;\n\t} // initialize\n\n\n\tlet _gl = _context;\n\n\tfunction getContext(contextNames, contextAttributes) {\n\t\tfor (let i = 0; i < contextNames.length; i++) {\n\t\t\tconst contextName = contextNames[i];\n\n\t\t\tconst context = _canvas.getContext(contextName, contextAttributes);\n\n\t\t\tif (context !== null) return context;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst contextAttributes = {\n\t\t\talpha: true,\n\t\t\tdepth: _depth,\n\t\t\tstencil: _stencil,\n\t\t\tantialias: _antialias,\n\t\t\tpremultipliedAlpha: _premultipliedAlpha,\n\t\t\tpreserveDrawingBuffer: _preserveDrawingBuffer,\n\t\t\tpowerPreference: _powerPreference,\n\t\t\tfailIfMajorPerformanceCaveat: _failIfMajorPerformanceCaveat\n\t\t}; // OffscreenCanvas does not have setAttribute, see #22811\n\n\t\tif ('setAttribute' in _canvas) _canvas.setAttribute('data-engine', `three.js r${REVISION}`); // event listeners must be registered before WebGL context is created, see #12753\n\n\t\t_canvas.addEventListener('webglcontextlost', onContextLost, false);\n\n\t\t_canvas.addEventListener('webglcontextrestored', onContextRestore, false);\n\n\t\t_canvas.addEventListener('webglcontextcreationerror', onContextCreationError, false);\n\n\t\tif (_gl === null) {\n\t\t\tconst contextNames = ['webgl2', 'webgl', 'experimental-webgl'];\n\n\t\t\tif (_this.isWebGL1Renderer === true) {\n\t\t\t\tcontextNames.shift();\n\t\t\t}\n\n\t\t\t_gl = getContext(contextNames, contextAttributes);\n\n\t\t\tif (_gl === null) {\n\t\t\t\tif (getContext(contextNames)) {\n\t\t\t\t\tthrow new Error('Error creating WebGL context with your selected attributes.');\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error('Error creating WebGL context.');\n\t\t\t\t}\n\t\t\t}\n\t\t} // Some experimental-webgl implementations do not have getShaderPrecisionFormat\n\n\n\t\tif (_gl.getShaderPrecisionFormat === undefined) {\n\t\t\t_gl.getShaderPrecisionFormat = function () {\n\t\t\t\treturn {\n\t\t\t\t\t'rangeMin': 1,\n\t\t\t\t\t'rangeMax': 1,\n\t\t\t\t\t'precision': 1\n\t\t\t\t};\n\t\t\t};\n\t\t}\n\t} catch (error) {\n\t\tconsole.error('THREE.WebGLRenderer: ' + error.message);\n\t\tthrow error;\n\t}\n\n\tlet extensions, capabilities, state, info;\n\tlet properties, textures, cubemaps, cubeuvmaps, attributes, geometries, objects;\n\tlet programCache, materials, renderLists, renderStates, clipping, shadowMap;\n\tlet background, morphtargets, bufferRenderer, indexedBufferRenderer;\n\tlet utils, bindingStates, uniformsGroups;\n\n\tfunction initGLContext() {\n\t\textensions = new WebGLExtensions(_gl);\n\t\tcapabilities = new WebGLCapabilities(_gl, extensions, parameters);\n\t\textensions.init(capabilities);\n\t\tutils = new WebGLUtils(_gl, extensions, capabilities);\n\t\tstate = new WebGLState(_gl, extensions, capabilities);\n\t\tinfo = new WebGLInfo(_gl);\n\t\tproperties = new WebGLProperties();\n\t\ttextures = new WebGLTextures(_gl, extensions, state, properties, capabilities, utils, info);\n\t\tcubemaps = new WebGLCubeMaps(_this);\n\t\tcubeuvmaps = new WebGLCubeUVMaps(_this);\n\t\tattributes = new WebGLAttributes(_gl, capabilities);\n\t\tbindingStates = new WebGLBindingStates(_gl, extensions, attributes, capabilities);\n\t\tgeometries = new WebGLGeometries(_gl, attributes, info, bindingStates);\n\t\tobjects = new WebGLObjects(_gl, geometries, attributes, info);\n\t\tmorphtargets = new WebGLMorphtargets(_gl, capabilities, textures);\n\t\tclipping = new WebGLClipping(properties);\n\t\tprogramCache = new WebGLPrograms(_this, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping);\n\t\tmaterials = new WebGLMaterials(_this, properties);\n\t\trenderLists = new WebGLRenderLists();\n\t\trenderStates = new WebGLRenderStates(extensions, capabilities);\n\t\tbackground = new WebGLBackground(_this, cubemaps, state, objects, _alpha, _premultipliedAlpha);\n\t\tshadowMap = new WebGLShadowMap(_this, objects, capabilities);\n\t\tuniformsGroups = new WebGLUniformsGroups(_gl, info, capabilities, state);\n\t\tbufferRenderer = new WebGLBufferRenderer(_gl, extensions, info, capabilities);\n\t\tindexedBufferRenderer = new WebGLIndexedBufferRenderer(_gl, extensions, info, capabilities);\n\t\tinfo.programs = programCache.programs;\n\t\t_this.capabilities = capabilities;\n\t\t_this.extensions = extensions;\n\t\t_this.properties = properties;\n\t\t_this.renderLists = renderLists;\n\t\t_this.shadowMap = shadowMap;\n\t\t_this.state = state;\n\t\t_this.info = info;\n\t}\n\n\tinitGLContext(); // xr\n\n\tconst xr = new WebXRManager(_this, _gl);\n\tthis.xr = xr; // API\n\n\tthis.getContext = function () {\n\t\treturn _gl;\n\t};\n\n\tthis.getContextAttributes = function () {\n\t\treturn _gl.getContextAttributes();\n\t};\n\n\tthis.forceContextLoss = function () {\n\t\tconst extension = extensions.get('WEBGL_lose_context');\n\t\tif (extension) extension.loseContext();\n\t};\n\n\tthis.forceContextRestore = function () {\n\t\tconst extension = extensions.get('WEBGL_lose_context');\n\t\tif (extension) extension.restoreContext();\n\t};\n\n\tthis.getPixelRatio = function () {\n\t\treturn _pixelRatio;\n\t};\n\n\tthis.setPixelRatio = function (value) {\n\t\tif (value === undefined) return;\n\t\t_pixelRatio = value;\n\t\tthis.setSize(_width, _height, false);\n\t};\n\n\tthis.getSize = function (target) {\n\t\treturn target.set(_width, _height);\n\t};\n\n\tthis.setSize = function (width, height, updateStyle) {\n\t\tif (xr.isPresenting) {\n\t\t\tconsole.warn('THREE.WebGLRenderer: Can\\'t change size while VR device is presenting.');\n\t\t\treturn;\n\t\t}\n\n\t\t_width = width;\n\t\t_height = height;\n\t\t_canvas.width = Math.floor(width * _pixelRatio);\n\t\t_canvas.height = Math.floor(height * _pixelRatio);\n\n\t\tif (updateStyle !== false) {\n\t\t\t_canvas.style.width = width + 'px';\n\t\t\t_canvas.style.height = height + 'px';\n\t\t}\n\n\t\tthis.setViewport(0, 0, width, height);\n\t};\n\n\tthis.getDrawingBufferSize = function (target) {\n\t\treturn target.set(_width * _pixelRatio, _height * _pixelRatio).floor();\n\t};\n\n\tthis.setDrawingBufferSize = function (width, height, pixelRatio) {\n\t\t_width = width;\n\t\t_height = height;\n\t\t_pixelRatio = pixelRatio;\n\t\t_canvas.width = Math.floor(width * pixelRatio);\n\t\t_canvas.height = Math.floor(height * pixelRatio);\n\t\tthis.setViewport(0, 0, width, height);\n\t};\n\n\tthis.getCurrentViewport = function (target) {\n\t\treturn target.copy(_currentViewport);\n\t};\n\n\tthis.getViewport = function (target) {\n\t\treturn target.copy(_viewport);\n\t};\n\n\tthis.setViewport = function (x, y, width, height) {\n\t\tif (x.isVector4) {\n\t\t\t_viewport.set(x.x, x.y, x.z, x.w);\n\t\t} else {\n\t\t\t_viewport.set(x, y, width, height);\n\t\t}\n\n\t\tstate.viewport(_currentViewport.copy(_viewport).multiplyScalar(_pixelRatio).floor());\n\t};\n\n\tthis.getScissor = function (target) {\n\t\treturn target.copy(_scissor);\n\t};\n\n\tthis.setScissor = function (x, y, width, height) {\n\t\tif (x.isVector4) {\n\t\t\t_scissor.set(x.x, x.y, x.z, x.w);\n\t\t} else {\n\t\t\t_scissor.set(x, y, width, height);\n\t\t}\n\n\t\tstate.scissor(_currentScissor.copy(_scissor).multiplyScalar(_pixelRatio).floor());\n\t};\n\n\tthis.getScissorTest = function () {\n\t\treturn _scissorTest;\n\t};\n\n\tthis.setScissorTest = function (boolean) {\n\t\tstate.setScissorTest(_scissorTest = boolean);\n\t};\n\n\tthis.setOpaqueSort = function (method) {\n\t\t_opaqueSort = method;\n\t};\n\n\tthis.setTransparentSort = function (method) {\n\t\t_transparentSort = method;\n\t}; // Clearing\n\n\n\tthis.getClearColor = function (target) {\n\t\treturn target.copy(background.getClearColor());\n\t};\n\n\tthis.setClearColor = function () {\n\t\tbackground.setClearColor.apply(background, arguments);\n\t};\n\n\tthis.getClearAlpha = function () {\n\t\treturn background.getClearAlpha();\n\t};\n\n\tthis.setClearAlpha = function () {\n\t\tbackground.setClearAlpha.apply(background, arguments);\n\t};\n\n\tthis.clear = function (color = true, depth = true, stencil = true) {\n\t\tlet bits = 0;\n\t\tif (color) bits |= _gl.COLOR_BUFFER_BIT;\n\t\tif (depth) bits |= _gl.DEPTH_BUFFER_BIT;\n\t\tif (stencil) bits |= _gl.STENCIL_BUFFER_BIT;\n\n\t\t_gl.clear(bits);\n\t};\n\n\tthis.clearColor = function () {\n\t\tthis.clear(true, false, false);\n\t};\n\n\tthis.clearDepth = function () {\n\t\tthis.clear(false, true, false);\n\t};\n\n\tthis.clearStencil = function () {\n\t\tthis.clear(false, false, true);\n\t}; //\n\n\n\tthis.dispose = function () {\n\t\t_canvas.removeEventListener('webglcontextlost', onContextLost, false);\n\n\t\t_canvas.removeEventListener('webglcontextrestored', onContextRestore, false);\n\n\t\t_canvas.removeEventListener('webglcontextcreationerror', onContextCreationError, false);\n\n\t\trenderLists.dispose();\n\t\trenderStates.dispose();\n\t\tproperties.dispose();\n\t\tcubemaps.dispose();\n\t\tcubeuvmaps.dispose();\n\t\tobjects.dispose();\n\t\tbindingStates.dispose();\n\t\tuniformsGroups.dispose();\n\t\tprogramCache.dispose();\n\t\txr.dispose();\n\t\txr.removeEventListener('sessionstart', onXRSessionStart);\n\t\txr.removeEventListener('sessionend', onXRSessionEnd);\n\n\t\tif (_transmissionRenderTarget) {\n\t\t\t_transmissionRenderTarget.dispose();\n\n\t\t\t_transmissionRenderTarget = null;\n\t\t}\n\n\t\tanimation.stop();\n\t}; // Events\n\n\n\tfunction onContextLost(event) {\n\t\tevent.preventDefault();\n\t\tconsole.log('THREE.WebGLRenderer: Context Lost.');\n\t\t_isContextLost = true;\n\t}\n\n\tfunction\n\t\t/* event */\n\tonContextRestore() {\n\t\tconsole.log('THREE.WebGLRenderer: Context Restored.');\n\t\t_isContextLost = false;\n\t\tconst infoAutoReset = info.autoReset;\n\t\tconst shadowMapEnabled = shadowMap.enabled;\n\t\tconst shadowMapAutoUpdate = shadowMap.autoUpdate;\n\t\tconst shadowMapNeedsUpdate = shadowMap.needsUpdate;\n\t\tconst shadowMapType = shadowMap.type;\n\t\tinitGLContext();\n\t\tinfo.autoReset = infoAutoReset;\n\t\tshadowMap.enabled = shadowMapEnabled;\n\t\tshadowMap.autoUpdate = shadowMapAutoUpdate;\n\t\tshadowMap.needsUpdate = shadowMapNeedsUpdate;\n\t\tshadowMap.type = shadowMapType;\n\t}\n\n\tfunction onContextCreationError(event) {\n\t\tconsole.error('THREE.WebGLRenderer: A WebGL context could not be created. Reason: ', event.statusMessage);\n\t}\n\n\tfunction onMaterialDispose(event) {\n\t\tconst material = event.target;\n\t\tmaterial.removeEventListener('dispose', onMaterialDispose);\n\t\tdeallocateMaterial(material);\n\t} // Buffer deallocation\n\n\n\tfunction deallocateMaterial(material) {\n\t\treleaseMaterialProgramReferences(material);\n\t\tproperties.remove(material);\n\t}\n\n\tfunction releaseMaterialProgramReferences(material) {\n\t\tconst programs = properties.get(material).programs;\n\n\t\tif (programs !== undefined) {\n\t\t\tprograms.forEach(function (program) {\n\t\t\t\tprogramCache.releaseProgram(program);\n\t\t\t});\n\n\t\t\tif (material.isShaderMaterial) {\n\t\t\t\tprogramCache.releaseShaderCache(material);\n\t\t\t}\n\t\t}\n\t} // Buffer rendering\n\n\n\tthis.renderBufferDirect = function (camera, scene, geometry, material, object, group) {\n\t\tif (scene === null) scene = _emptyScene; // renderBufferDirect second parameter used to be fog (could be null)\n\n\t\tconst frontFaceCW = object.isMesh && object.matrixWorld.determinant() < 0;\n\t\tconst program = setProgram(camera, scene, geometry, material, object);\n\t\tstate.setMaterial(material, frontFaceCW); //\n\n\t\tlet index = geometry.index;\n\t\tconst position = geometry.attributes.position; //\n\n\t\tif (index === null) {\n\t\t\tif (position === undefined || position.count === 0) return;\n\t\t} else if (index.count === 0) {\n\t\t\treturn;\n\t\t} //\n\n\n\t\tlet rangeFactor = 1;\n\n\t\tif (material.wireframe === true) {\n\t\t\tindex = geometries.getWireframeAttribute(geometry);\n\t\t\trangeFactor = 2;\n\t\t}\n\n\t\tbindingStates.setup(object, material, program, geometry, index);\n\t\tlet attribute;\n\t\tlet renderer = bufferRenderer;\n\n\t\tif (index !== null) {\n\t\t\tattribute = attributes.get(index);\n\t\t\trenderer = indexedBufferRenderer;\n\t\t\trenderer.setIndex(attribute);\n\t\t} //\n\n\n\t\tconst dataCount = index !== null ? index.count : position.count;\n\t\tconst rangeStart = geometry.drawRange.start * rangeFactor;\n\t\tconst rangeCount = geometry.drawRange.count * rangeFactor;\n\t\tconst groupStart = group !== null ? group.start * rangeFactor : 0;\n\t\tconst groupCount = group !== null ? group.count * rangeFactor : Infinity;\n\t\tconst drawStart = Math.max(rangeStart, groupStart);\n\t\tconst drawEnd = Math.min(dataCount, rangeStart + rangeCount, groupStart + groupCount) - 1;\n\t\tconst drawCount = Math.max(0, drawEnd - drawStart + 1);\n\t\tif (drawCount === 0) return; //\n\n\t\tif (object.isMesh) {\n\t\t\tif (material.wireframe === true) {\n\t\t\t\tstate.setLineWidth(material.wireframeLinewidth * getTargetPixelRatio());\n\t\t\t\trenderer.setMode(_gl.LINES);\n\t\t\t} else {\n\t\t\t\trenderer.setMode(_gl.TRIANGLES);\n\t\t\t}\n\t\t} else if (object.isLine) {\n\t\t\tlet lineWidth = material.linewidth;\n\t\t\tif (lineWidth === undefined) lineWidth = 1; // Not using Line*Material\n\n\t\t\tstate.setLineWidth(lineWidth * getTargetPixelRatio());\n\n\t\t\tif (object.isLineSegments) {\n\t\t\t\trenderer.setMode(_gl.LINES);\n\t\t\t} else if (object.isLineLoop) {\n\t\t\t\trenderer.setMode(_gl.LINE_LOOP);\n\t\t\t} else {\n\t\t\t\trenderer.setMode(_gl.LINE_STRIP);\n\t\t\t}\n\t\t} else if (object.isPoints) {\n\t\t\trenderer.setMode(_gl.POINTS);\n\t\t} else if (object.isSprite) {\n\t\t\trenderer.setMode(_gl.TRIANGLES);\n\t\t}\n\n\t\tif (object.isInstancedMesh) {\n\t\t\trenderer.renderInstances(drawStart, drawCount, object.count);\n\t\t} else if (geometry.isInstancedBufferGeometry) {\n\t\t\tconst instanceCount = Math.min(geometry.instanceCount, geometry._maxInstanceCount);\n\t\t\trenderer.renderInstances(drawStart, drawCount, instanceCount);\n\t\t} else {\n\t\t\trenderer.render(drawStart, drawCount);\n\t\t}\n\t}; // Compile\n\n\n\tthis.compile = function (scene, camera) {\n\t\tfunction prepare(material, scene, object) {\n\t\t\tif (material.transparent === true && material.side === DoubleSide) {\n\t\t\t\tmaterial.side = BackSide;\n\t\t\t\tmaterial.needsUpdate = true;\n\t\t\t\tgetProgram(material, scene, object);\n\t\t\t\tmaterial.side = FrontSide;\n\t\t\t\tmaterial.needsUpdate = true;\n\t\t\t\tgetProgram(material, scene, object);\n\t\t\t\tmaterial.side = DoubleSide;\n\t\t\t} else {\n\t\t\t\tgetProgram(material, scene, object);\n\t\t\t}\n\t\t}\n\n\t\tcurrentRenderState = renderStates.get(scene);\n\t\tcurrentRenderState.init();\n\t\trenderStateStack.push(currentRenderState);\n\t\tscene.traverseVisible(function (object) {\n\t\t\tif (object.isLight && object.layers.test(camera.layers)) {\n\t\t\t\tcurrentRenderState.pushLight(object);\n\n\t\t\t\tif (object.castShadow) {\n\t\t\t\t\tcurrentRenderState.pushShadow(object);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tcurrentRenderState.setupLights(_this.physicallyCorrectLights);\n\t\tscene.traverse(function (object) {\n\t\t\tconst material = object.material;\n\n\t\t\tif (material) {\n\t\t\t\tif (Array.isArray(material)) {\n\t\t\t\t\tfor (let i = 0; i < material.length; i++) {\n\t\t\t\t\t\tconst material2 = material[i];\n\t\t\t\t\t\tprepare(material2, scene, object);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tprepare(material, scene, object);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\trenderStateStack.pop();\n\t\tcurrentRenderState = null;\n\t}; // Animation Loop\n\n\n\tlet onAnimationFrameCallback = null;\n\n\tfunction onAnimationFrame(time) {\n\t\tif (onAnimationFrameCallback) onAnimationFrameCallback(time);\n\t}\n\n\tfunction onXRSessionStart() {\n\t\tanimation.stop();\n\t}\n\n\tfunction onXRSessionEnd() {\n\t\tanimation.start();\n\t}\n\n\tconst animation = new WebGLAnimation();\n\tanimation.setAnimationLoop(onAnimationFrame);\n\tif (typeof self !== 'undefined') animation.setContext(self);\n\n\tthis.setAnimationLoop = function (callback) {\n\t\tonAnimationFrameCallback = callback;\n\t\txr.setAnimationLoop(callback);\n\t\tcallback === null ? animation.stop() : animation.start();\n\t};\n\n\txr.addEventListener('sessionstart', onXRSessionStart);\n\txr.addEventListener('sessionend', onXRSessionEnd); // Rendering\n\n\tthis.render = function (scene, camera) {\n\t\tif (camera !== undefined && camera.isCamera !== true) {\n\t\t\tconsole.error('THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.');\n\t\t\treturn;\n\t\t}\n\n\t\tif (_isContextLost === true) return; // update scene graph\n\n\t\tif (scene.matrixWorldAutoUpdate === true) scene.updateMatrixWorld(); // update camera matrices and frustum\n\n\t\tif (camera.parent === null && camera.matrixWorldAutoUpdate === true) camera.updateMatrixWorld();\n\n\t\tif (xr.enabled === true && xr.isPresenting === true) {\n\t\t\tif (xr.cameraAutoUpdate === true) xr.updateCamera(camera);\n\t\t\tcamera = xr.getCamera(); // use XR camera for rendering\n\t\t} //\n\n\n\t\tif (scene.isScene === true) scene.onBeforeRender(_this, scene, camera, _currentRenderTarget);\n\t\tcurrentRenderState = renderStates.get(scene, renderStateStack.length);\n\t\tcurrentRenderState.init();\n\t\trenderStateStack.push(currentRenderState);\n\n\t\t_projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);\n\n\t\t_frustum.setFromProjectionMatrix(_projScreenMatrix);\n\n\t\t_localClippingEnabled = this.localClippingEnabled;\n\t\t_clippingEnabled = clipping.init(this.clippingPlanes, _localClippingEnabled, camera);\n\t\tcurrentRenderList = renderLists.get(scene, renderListStack.length);\n\t\tcurrentRenderList.init();\n\t\trenderListStack.push(currentRenderList);\n\t\tprojectObject(scene, camera, 0, _this.sortObjects);\n\t\tcurrentRenderList.finish();\n\n\t\tif (_this.sortObjects === true) {\n\t\t\tcurrentRenderList.sort(_opaqueSort, _transparentSort);\n\t\t} //\n\n\n\t\tif (_clippingEnabled === true) clipping.beginShadows();\n\t\tconst shadowsArray = currentRenderState.state.shadowsArray;\n\t\tshadowMap.render(shadowsArray, scene, camera);\n\t\tif (_clippingEnabled === true) clipping.endShadows(); //\n\n\t\tif (this.info.autoReset === true) this.info.reset(); //\n\n\t\tbackground.render(currentRenderList, scene); // render scene\n\n\t\tcurrentRenderState.setupLights(_this.physicallyCorrectLights);\n\n\t\tif (camera.isArrayCamera) {\n\t\t\tconst cameras = camera.cameras;\n\n\t\t\tfor (let i = 0, l = cameras.length; i < l; i++) {\n\t\t\t\tconst camera2 = cameras[i];\n\t\t\t\trenderScene(currentRenderList, scene, camera2, camera2.viewport);\n\t\t\t}\n\t\t} else {\n\t\t\trenderScene(currentRenderList, scene, camera);\n\t\t} //\n\n\n\t\tif (_currentRenderTarget !== null) {\n\t\t\t// resolve multisample renderbuffers to a single-sample texture if necessary\n\t\t\ttextures.updateMultisampleRenderTarget(_currentRenderTarget); // Generate mipmap if we're using any kind of mipmap filtering\n\n\t\t\ttextures.updateRenderTargetMipmap(_currentRenderTarget);\n\t\t} //\n\n\n\t\tif (scene.isScene === true) scene.onAfterRender(_this, scene, camera); // _gl.finish();\n\n\t\tbindingStates.resetDefaultState();\n\t\t_currentMaterialId = -1;\n\t\t_currentCamera = null;\n\t\trenderStateStack.pop();\n\n\t\tif (renderStateStack.length > 0) {\n\t\t\tcurrentRenderState = renderStateStack[renderStateStack.length - 1];\n\t\t} else {\n\t\t\tcurrentRenderState = null;\n\t\t}\n\n\t\trenderListStack.pop();\n\n\t\tif (renderListStack.length > 0) {\n\t\t\tcurrentRenderList = renderListStack[renderListStack.length - 1];\n\t\t} else {\n\t\t\tcurrentRenderList = null;\n\t\t}\n\t};\n\n\tfunction projectObject(object, camera, groupOrder, sortObjects) {\n\t\tif (object.visible === false) return;\n\t\tconst visible = object.layers.test(camera.layers);\n\n\t\tif (visible) {\n\t\t\tif (object.isGroup) {\n\t\t\t\tgroupOrder = object.renderOrder;\n\t\t\t} else if (object.isLOD) {\n\t\t\t\tif (object.autoUpdate === true) object.update(camera);\n\t\t\t} else if (object.isLight) {\n\t\t\t\tcurrentRenderState.pushLight(object);\n\n\t\t\t\tif (object.castShadow) {\n\t\t\t\t\tcurrentRenderState.pushShadow(object);\n\t\t\t\t}\n\t\t\t} else if (object.isSprite) {\n\t\t\t\tif (!object.frustumCulled || _frustum.intersectsSprite(object)) {\n\t\t\t\t\tif (sortObjects) {\n\t\t\t\t\t\t_vector3.setFromMatrixPosition(object.matrixWorld).applyMatrix4(_projScreenMatrix);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst geometry = objects.update(object);\n\t\t\t\t\tconst material = object.material;\n\n\t\t\t\t\tif (material.visible) {\n\t\t\t\t\t\tcurrentRenderList.push(object, geometry, material, groupOrder, _vector3.z, null);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (object.isMesh || object.isLine || object.isPoints) {\n\t\t\t\tif (object.isSkinnedMesh) {\n\t\t\t\t\t// update skeleton only once in a frame\n\t\t\t\t\tif (object.skeleton.frame !== info.render.frame) {\n\t\t\t\t\t\tobject.skeleton.update();\n\t\t\t\t\t\tobject.skeleton.frame = info.render.frame;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!object.frustumCulled || _frustum.intersectsObject(object)) {\n\t\t\t\t\tif (sortObjects) {\n\t\t\t\t\t\t_vector3.setFromMatrixPosition(object.matrixWorld).applyMatrix4(_projScreenMatrix);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst geometry = objects.update(object);\n\t\t\t\t\tconst material = object.material;\n\n\t\t\t\t\tif (Array.isArray(material)) {\n\t\t\t\t\t\tconst groups = geometry.groups;\n\n\t\t\t\t\t\tfor (let i = 0, l = groups.length; i < l; i++) {\n\t\t\t\t\t\t\tconst group = groups[i];\n\t\t\t\t\t\t\tconst groupMaterial = material[group.materialIndex];\n\n\t\t\t\t\t\t\tif (groupMaterial && groupMaterial.visible) {\n\t\t\t\t\t\t\t\tcurrentRenderList.push(object, geometry, groupMaterial, groupOrder, _vector3.z, group);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (material.visible) {\n\t\t\t\t\t\tcurrentRenderList.push(object, geometry, material, groupOrder, _vector3.z, null);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst children = object.children;\n\n\t\tfor (let i = 0, l = children.length; i < l; i++) {\n\t\t\tprojectObject(children[i], camera, groupOrder, sortObjects);\n\t\t}\n\t}\n\n\tfunction renderScene(currentRenderList, scene, camera, viewport) {\n\t\tconst opaqueObjects = currentRenderList.opaque;\n\t\tconst transmissiveObjects = currentRenderList.transmissive;\n\t\tconst transparentObjects = currentRenderList.transparent;\n\t\tcurrentRenderState.setupLightsView(camera);\n\t\tif (transmissiveObjects.length > 0) renderTransmissionPass(opaqueObjects, scene, camera);\n\t\tif (viewport) state.viewport(_currentViewport.copy(viewport));\n\t\tif (opaqueObjects.length > 0) renderObjects(opaqueObjects, scene, camera);\n\t\tif (transmissiveObjects.length > 0) renderObjects(transmissiveObjects, scene, camera);\n\t\tif (transparentObjects.length > 0) renderObjects(transparentObjects, scene, camera); // Ensure depth buffer writing is enabled so it can be cleared on next render\n\n\t\tstate.buffers.depth.setTest(true);\n\t\tstate.buffers.depth.setMask(true);\n\t\tstate.buffers.color.setMask(true);\n\t\tstate.setPolygonOffset(false);\n\t}\n\n\tfunction renderTransmissionPass(opaqueObjects, scene, camera) {\n\t\tconst isWebGL2 = capabilities.isWebGL2;\n\n\t\tif (_transmissionRenderTarget === null) {\n\t\t\t_transmissionRenderTarget = new WebGLRenderTarget(1, 1, {\n\t\t\t\tgenerateMipmaps: true,\n\t\t\t\ttype: extensions.has('EXT_color_buffer_half_float') ? HalfFloatType : UnsignedByteType,\n\t\t\t\tminFilter: LinearMipmapLinearFilter,\n\t\t\t\tsamples: isWebGL2 && _antialias === true ? 4 : 0\n\t\t\t});\n\t\t}\n\n\t\t_this.getDrawingBufferSize(_vector2);\n\n\t\tif (isWebGL2) {\n\t\t\t_transmissionRenderTarget.setSize(_vector2.x, _vector2.y);\n\t\t} else {\n\t\t\t_transmissionRenderTarget.setSize(floorPowerOfTwo(_vector2.x), floorPowerOfTwo(_vector2.y));\n\t\t} //\n\n\n\t\tconst currentRenderTarget = _this.getRenderTarget();\n\n\t\t_this.setRenderTarget(_transmissionRenderTarget);\n\n\t\t_this.clear(); // Turn off the features which can affect the frag color for opaque objects pass.\n\t\t// Otherwise they are applied twice in opaque objects pass and transmission objects pass.\n\n\n\t\tconst currentToneMapping = _this.toneMapping;\n\t\t_this.toneMapping = NoToneMapping;\n\t\trenderObjects(opaqueObjects, scene, camera);\n\t\t_this.toneMapping = currentToneMapping;\n\t\ttextures.updateMultisampleRenderTarget(_transmissionRenderTarget);\n\t\ttextures.updateRenderTargetMipmap(_transmissionRenderTarget);\n\n\t\t_this.setRenderTarget(currentRenderTarget);\n\t}\n\n\tfunction renderObjects(renderList, scene, camera) {\n\t\tconst overrideMaterial = scene.isScene === true ? scene.overrideMaterial : null;\n\n\t\tfor (let i = 0, l = renderList.length; i < l; i++) {\n\t\t\tconst renderItem = renderList[i];\n\t\t\tconst object = renderItem.object;\n\t\t\tconst geometry = renderItem.geometry;\n\t\t\tconst material = overrideMaterial === null ? renderItem.material : overrideMaterial;\n\t\t\tconst group = renderItem.group;\n\n\t\t\tif (object.layers.test(camera.layers)) {\n\t\t\t\trenderObject(object, scene, camera, geometry, material, group);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction renderObject(object, scene, camera, geometry, material, group) {\n\t\tobject.onBeforeRender(_this, scene, camera, geometry, material, group);\n\t\tobject.modelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, object.matrixWorld);\n\t\tobject.normalMatrix.getNormalMatrix(object.modelViewMatrix);\n\t\tmaterial.onBeforeRender(_this, scene, camera, geometry, object, group);\n\n\t\tif (material.transparent === true && material.side === DoubleSide) {\n\t\t\tmaterial.side = BackSide;\n\t\t\tmaterial.needsUpdate = true;\n\n\t\t\t_this.renderBufferDirect(camera, scene, geometry, material, object, group);\n\n\t\t\tmaterial.side = FrontSide;\n\t\t\tmaterial.needsUpdate = true;\n\n\t\t\t_this.renderBufferDirect(camera, scene, geometry, material, object, group);\n\n\t\t\tmaterial.side = DoubleSide;\n\t\t} else {\n\t\t\t_this.renderBufferDirect(camera, scene, geometry, material, object, group);\n\t\t}\n\n\t\tobject.onAfterRender(_this, scene, camera, geometry, material, group);\n\t}\n\n\tfunction getProgram(material, scene, object) {\n\t\tif (scene.isScene !== true) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...\n\n\t\tconst materialProperties = properties.get(material);\n\t\tconst lights = currentRenderState.state.lights;\n\t\tconst shadowsArray = currentRenderState.state.shadowsArray;\n\t\tconst lightsStateVersion = lights.state.version;\n\t\tconst parameters = programCache.getParameters(material, lights.state, shadowsArray, scene, object);\n\t\tconst programCacheKey = programCache.getProgramCacheKey(parameters);\n\t\tlet programs = materialProperties.programs; // always update environment and fog - changing these trigger an getProgram call, but it's possible that the program doesn't change\n\n\t\tmaterialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;\n\t\tmaterialProperties.fog = scene.fog;\n\t\tmaterialProperties.envMap = (material.isMeshStandardMaterial ? cubeuvmaps : cubemaps).get(material.envMap || materialProperties.environment);\n\n\t\tif (programs === undefined) {\n\t\t\t// new material\n\t\t\tmaterial.addEventListener('dispose', onMaterialDispose);\n\t\t\tprograms = new Map();\n\t\t\tmaterialProperties.programs = programs;\n\t\t}\n\n\t\tlet program = programs.get(programCacheKey);\n\n\t\tif (program !== undefined) {\n\t\t\t// early out if program and light state is identical\n\t\t\tif (materialProperties.currentProgram === program && materialProperties.lightsStateVersion === lightsStateVersion) {\n\t\t\t\tupdateCommonMaterialProperties(material, parameters);\n\t\t\t\treturn program;\n\t\t\t}\n\t\t} else {\n\t\t\tparameters.uniforms = programCache.getUniforms(material);\n\t\t\tmaterial.onBuild(object, parameters, _this);\n\t\t\tmaterial.onBeforeCompile(parameters, _this);\n\t\t\tprogram = programCache.acquireProgram(parameters, programCacheKey);\n\t\t\tprograms.set(programCacheKey, program);\n\t\t\tmaterialProperties.uniforms = parameters.uniforms;\n\t\t}\n\n\t\tconst uniforms = materialProperties.uniforms;\n\n\t\tif (!material.isShaderMaterial && !material.isRawShaderMaterial || material.clipping === true) {\n\t\t\tuniforms.clippingPlanes = clipping.uniform;\n\t\t}\n\n\t\tupdateCommonMaterialProperties(material, parameters); // store the light setup it was created for\n\n\t\tmaterialProperties.needsLights = materialNeedsLights(material);\n\t\tmaterialProperties.lightsStateVersion = lightsStateVersion;\n\n\t\tif (materialProperties.needsLights) {\n\t\t\t// wire up the material to this renderer's lighting state\n\t\t\tuniforms.ambientLightColor.value = lights.state.ambient;\n\t\t\tuniforms.lightProbe.value = lights.state.probe;\n\t\t\tuniforms.directionalLights.value = lights.state.directional;\n\t\t\tuniforms.directionalLightShadows.value = lights.state.directionalShadow;\n\t\t\tuniforms.spotLights.value = lights.state.spot;\n\t\t\tuniforms.spotLightShadows.value = lights.state.spotShadow;\n\t\t\tuniforms.rectAreaLights.value = lights.state.rectArea;\n\t\t\tuniforms.ltc_1.value = lights.state.rectAreaLTC1;\n\t\t\tuniforms.ltc_2.value = lights.state.rectAreaLTC2;\n\t\t\tuniforms.pointLights.value = lights.state.point;\n\t\t\tuniforms.pointLightShadows.value = lights.state.pointShadow;\n\t\t\tuniforms.hemisphereLights.value = lights.state.hemi;\n\t\t\tuniforms.directionalShadowMap.value = lights.state.directionalShadowMap;\n\t\t\tuniforms.directionalShadowMatrix.value = lights.state.directionalShadowMatrix;\n\t\t\tuniforms.spotShadowMap.value = lights.state.spotShadowMap;\n\t\t\tuniforms.spotLightMatrix.value = lights.state.spotLightMatrix;\n\t\t\tuniforms.spotLightMap.value = lights.state.spotLightMap;\n\t\t\tuniforms.pointShadowMap.value = lights.state.pointShadowMap;\n\t\t\tuniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix; // TODO (abelnation): add area lights shadow info to uniforms\n\t\t}\n\n\t\tconst progUniforms = program.getUniforms();\n\t\tconst uniformsList = WebGLUniforms.seqWithValue(progUniforms.seq, uniforms);\n\t\tmaterialProperties.currentProgram = program;\n\t\tmaterialProperties.uniformsList = uniformsList;\n\t\treturn program;\n\t}\n\n\tfunction updateCommonMaterialProperties(material, parameters) {\n\t\tconst materialProperties = properties.get(material);\n\t\tmaterialProperties.outputEncoding = parameters.outputEncoding;\n\t\tmaterialProperties.instancing = parameters.instancing;\n\t\tmaterialProperties.skinning = parameters.skinning;\n\t\tmaterialProperties.morphTargets = parameters.morphTargets;\n\t\tmaterialProperties.morphNormals = parameters.morphNormals;\n\t\tmaterialProperties.morphColors = parameters.morphColors;\n\t\tmaterialProperties.morphTargetsCount = parameters.morphTargetsCount;\n\t\tmaterialProperties.numClippingPlanes = parameters.numClippingPlanes;\n\t\tmaterialProperties.numIntersection = parameters.numClipIntersection;\n\t\tmaterialProperties.vertexAlphas = parameters.vertexAlphas;\n\t\tmaterialProperties.vertexTangents = parameters.vertexTangents;\n\t\tmaterialProperties.toneMapping = parameters.toneMapping;\n\t}\n\n\tfunction setProgram(camera, scene, geometry, material, object) {\n\t\tif (scene.isScene !== true) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...\n\n\t\ttextures.resetTextureUnits();\n\t\tconst fog = scene.fog;\n\t\tconst environment = material.isMeshStandardMaterial ? scene.environment : null;\n\t\tconst encoding = _currentRenderTarget === null ? _this.outputEncoding : _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.encoding : LinearEncoding;\n\t\tconst envMap = (material.isMeshStandardMaterial ? cubeuvmaps : cubemaps).get(material.envMap || environment);\n\t\tconst vertexAlphas = material.vertexColors === true && !!geometry.attributes.color && geometry.attributes.color.itemSize === 4;\n\t\tconst vertexTangents = !!material.normalMap && !!geometry.attributes.tangent;\n\t\tconst morphTargets = !!geometry.morphAttributes.position;\n\t\tconst morphNormals = !!geometry.morphAttributes.normal;\n\t\tconst morphColors = !!geometry.morphAttributes.color;\n\t\tconst toneMapping = material.toneMapped ? _this.toneMapping : NoToneMapping;\n\t\tconst morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;\n\t\tconst morphTargetsCount = morphAttribute !== undefined ? morphAttribute.length : 0;\n\t\tconst materialProperties = properties.get(material);\n\t\tconst lights = currentRenderState.state.lights;\n\n\t\tif (_clippingEnabled === true) {\n\t\t\tif (_localClippingEnabled === true || camera !== _currentCamera) {\n\t\t\t\tconst useCache = camera === _currentCamera && material.id === _currentMaterialId; // we might want to call this function with some ClippingGroup\n\t\t\t\t// object instead of the material, once it becomes feasible\n\t\t\t\t// (#8465, #8379)\n\n\t\t\t\tclipping.setState(material, camera, useCache);\n\t\t\t}\n\t\t} //\n\n\n\t\tlet needsProgramChange = false;\n\n\t\tif (material.version === materialProperties.__version) {\n\t\t\tif (materialProperties.needsLights && materialProperties.lightsStateVersion !== lights.state.version) {\n\t\t\t\tneedsProgramChange = true;\n\t\t\t} else if (materialProperties.outputEncoding !== encoding) {\n\t\t\t\tneedsProgramChange = true;\n\t\t\t} else if (object.isInstancedMesh && materialProperties.instancing === false) {\n\t\t\t\tneedsProgramChange = true;\n\t\t\t} else if (!object.isInstancedMesh && materialProperties.instancing === true) {\n\t\t\t\tneedsProgramChange = true;\n\t\t\t} else if (object.isSkinnedMesh && materialProperties.skinning === false) {\n\t\t\t\tneedsProgramChange = true;\n\t\t\t} else if (!object.isSkinnedMesh && materialProperties.skinning === true) {\n\t\t\t\tneedsProgramChange = true;\n\t\t\t} else if (materialProperties.envMap !== envMap) {\n\t\t\t\tneedsProgramChange = true;\n\t\t\t} else if (material.fog === true && materialProperties.fog !== fog) {\n\t\t\t\tneedsProgramChange = true;\n\t\t\t} else if (materialProperties.numClippingPlanes !== undefined && (materialProperties.numClippingPlanes !== clipping.numPlanes || materialProperties.numIntersection !== clipping.numIntersection)) {\n\t\t\t\tneedsProgramChange = true;\n\t\t\t} else if (materialProperties.vertexAlphas !== vertexAlphas) {\n\t\t\t\tneedsProgramChange = true;\n\t\t\t} else if (materialProperties.vertexTangents !== vertexTangents) {\n\t\t\t\tneedsProgramChange = true;\n\t\t\t} else if (materialProperties.morphTargets !== morphTargets) {\n\t\t\t\tneedsProgramChange = true;\n\t\t\t} else if (materialProperties.morphNormals !== morphNormals) {\n\t\t\t\tneedsProgramChange = true;\n\t\t\t} else if (materialProperties.morphColors !== morphColors) {\n\t\t\t\tneedsProgramChange = true;\n\t\t\t} else if (materialProperties.toneMapping !== toneMapping) {\n\t\t\t\tneedsProgramChange = true;\n\t\t\t} else if (capabilities.isWebGL2 === true && materialProperties.morphTargetsCount !== morphTargetsCount) {\n\t\t\t\tneedsProgramChange = true;\n\t\t\t}\n\t\t} else {\n\t\t\tneedsProgramChange = true;\n\t\t\tmaterialProperties.__version = material.version;\n\t\t} //\n\n\n\t\tlet program = materialProperties.currentProgram;\n\n\t\tif (needsProgramChange === true) {\n\t\t\tprogram = getProgram(material, scene, object);\n\t\t}\n\n\t\tlet refreshProgram = false;\n\t\tlet refreshMaterial = false;\n\t\tlet refreshLights = false;\n\t\tconst p_uniforms = program.getUniforms(),\n\t\t\t\t\tm_uniforms = materialProperties.uniforms;\n\n\t\tif (state.useProgram(program.program)) {\n\t\t\trefreshProgram = true;\n\t\t\trefreshMaterial = true;\n\t\t\trefreshLights = true;\n\t\t}\n\n\t\tif (material.id !== _currentMaterialId) {\n\t\t\t_currentMaterialId = material.id;\n\t\t\trefreshMaterial = true;\n\t\t}\n\n\t\tif (refreshProgram || _currentCamera !== camera) {\n\t\t\tp_uniforms.setValue(_gl, 'projectionMatrix', camera.projectionMatrix);\n\n\t\t\tif (capabilities.logarithmicDepthBuffer) {\n\t\t\t\tp_uniforms.setValue(_gl, 'logDepthBufFC', 2.0 / (Math.log(camera.far + 1.0) / Math.LN2));\n\t\t\t}\n\n\t\t\tif (_currentCamera !== camera) {\n\t\t\t\t_currentCamera = camera; // lighting uniforms depend on the camera so enforce an update\n\t\t\t\t// now, in case this material supports lights - or later, when\n\t\t\t\t// the next material that does gets activated:\n\n\t\t\t\trefreshMaterial = true; // set to true on material change\n\n\t\t\t\trefreshLights = true; // remains set until update done\n\t\t\t} // load material specific uniforms\n\t\t\t// (shader material also gets them for the sake of genericity)\n\n\n\t\t\tif (material.isShaderMaterial || material.isMeshPhongMaterial || material.isMeshToonMaterial || material.isMeshStandardMaterial || material.envMap) {\n\t\t\t\tconst uCamPos = p_uniforms.map.cameraPosition;\n\n\t\t\t\tif (uCamPos !== undefined) {\n\t\t\t\t\tuCamPos.setValue(_gl, _vector3.setFromMatrixPosition(camera.matrixWorld));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (material.isMeshPhongMaterial || material.isMeshToonMaterial || material.isMeshLambertMaterial || material.isMeshBasicMaterial || material.isMeshStandardMaterial || material.isShaderMaterial) {\n\t\t\t\tp_uniforms.setValue(_gl, 'isOrthographic', camera.isOrthographicCamera === true);\n\t\t\t}\n\n\t\t\tif (material.isMeshPhongMaterial || material.isMeshToonMaterial || material.isMeshLambertMaterial || material.isMeshBasicMaterial || material.isMeshStandardMaterial || material.isShaderMaterial || material.isShadowMaterial || object.isSkinnedMesh) {\n\t\t\t\tp_uniforms.setValue(_gl, 'viewMatrix', camera.matrixWorldInverse);\n\t\t\t}\n\t\t} // skinning and morph target uniforms must be set even if material didn't change\n\t\t// auto-setting of texture unit for bone and morph texture must go before other textures\n\t\t// otherwise textures used for skinning and morphing can take over texture units reserved for other material textures\n\n\n\t\tif (object.isSkinnedMesh) {\n\t\t\tp_uniforms.setOptional(_gl, object, 'bindMatrix');\n\t\t\tp_uniforms.setOptional(_gl, object, 'bindMatrixInverse');\n\t\t\tconst skeleton = object.skeleton;\n\n\t\t\tif (skeleton) {\n\t\t\t\tif (capabilities.floatVertexTextures) {\n\t\t\t\t\tif (skeleton.boneTexture === null) skeleton.computeBoneTexture();\n\t\t\t\t\tp_uniforms.setValue(_gl, 'boneTexture', skeleton.boneTexture, textures);\n\t\t\t\t\tp_uniforms.setValue(_gl, 'boneTextureSize', skeleton.boneTextureSize);\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required.');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst morphAttributes = geometry.morphAttributes;\n\n\t\tif (morphAttributes.position !== undefined || morphAttributes.normal !== undefined || morphAttributes.color !== undefined && capabilities.isWebGL2 === true) {\n\t\t\tmorphtargets.update(object, geometry, material, program);\n\t\t}\n\n\t\tif (refreshMaterial || materialProperties.receiveShadow !== object.receiveShadow) {\n\t\t\tmaterialProperties.receiveShadow = object.receiveShadow;\n\t\t\tp_uniforms.setValue(_gl, 'receiveShadow', object.receiveShadow);\n\t\t} // https://github.com/mrdoob/three.js/pull/24467#issuecomment-1209031512\n\n\n\t\tif (material.isMeshGouraudMaterial && material.envMap !== null) {\n\t\t\tm_uniforms.envMap.value = envMap;\n\t\t\tm_uniforms.flipEnvMap.value = envMap.isCubeTexture && envMap.isRenderTargetTexture === false ? -1 : 1;\n\t\t}\n\n\t\tif (refreshMaterial) {\n\t\t\tp_uniforms.setValue(_gl, 'toneMappingExposure', _this.toneMappingExposure);\n\n\t\t\tif (materialProperties.needsLights) {\n\t\t\t\t// the current material requires lighting info\n\t\t\t\t// note: all lighting uniforms are always set correctly\n\t\t\t\t// they simply reference the renderer's state for their\n\t\t\t\t// values\n\t\t\t\t//\n\t\t\t\t// use the current material's .needsUpdate flags to set\n\t\t\t\t// the GL state when required\n\t\t\t\tmarkUniformsLightsNeedsUpdate(m_uniforms, refreshLights);\n\t\t\t} // refresh uniforms common to several materials\n\n\n\t\t\tif (fog && material.fog === true) {\n\t\t\t\tmaterials.refreshFogUniforms(m_uniforms, fog);\n\t\t\t}\n\n\t\t\tmaterials.refreshMaterialUniforms(m_uniforms, material, _pixelRatio, _height, _transmissionRenderTarget);\n\t\t\tWebGLUniforms.upload(_gl, materialProperties.uniformsList, m_uniforms, textures);\n\t\t}\n\n\t\tif (material.isShaderMaterial && material.uniformsNeedUpdate === true) {\n\t\t\tWebGLUniforms.upload(_gl, materialProperties.uniformsList, m_uniforms, textures);\n\t\t\tmaterial.uniformsNeedUpdate = false;\n\t\t}\n\n\t\tif (material.isSpriteMaterial) {\n\t\t\tp_uniforms.setValue(_gl, 'center', object.center);\n\t\t} // common matrices\n\n\n\t\tp_uniforms.setValue(_gl, 'modelViewMatrix', object.modelViewMatrix);\n\t\tp_uniforms.setValue(_gl, 'normalMatrix', object.normalMatrix);\n\t\tp_uniforms.setValue(_gl, 'modelMatrix', object.matrixWorld); // UBOs\n\n\t\tif (material.isShaderMaterial || material.isRawShaderMaterial) {\n\t\t\tconst groups = material.uniformsGroups;\n\n\t\t\tfor (let i = 0, l = groups.length; i < l; i++) {\n\t\t\t\tif (capabilities.isWebGL2) {\n\t\t\t\t\tconst group = groups[i];\n\t\t\t\t\tuniformsGroups.update(group, program);\n\t\t\t\t\tuniformsGroups.bind(group, program);\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn program;\n\t} // If uniforms are marked as clean, they don't need to be loaded to the GPU.\n\n\n\tfunction markUniformsLightsNeedsUpdate(uniforms, value) {\n\t\tuniforms.ambientLightColor.needsUpdate = value;\n\t\tuniforms.lightProbe.needsUpdate = value;\n\t\tuniforms.directionalLights.needsUpdate = value;\n\t\tuniforms.directionalLightShadows.needsUpdate = value;\n\t\tuniforms.pointLights.needsUpdate = value;\n\t\tuniforms.pointLightShadows.needsUpdate = value;\n\t\tuniforms.spotLights.needsUpdate = value;\n\t\tuniforms.spotLightShadows.needsUpdate = value;\n\t\tuniforms.rectAreaLights.needsUpdate = value;\n\t\tuniforms.hemisphereLights.needsUpdate = value;\n\t}\n\n\tfunction materialNeedsLights(material) {\n\t\treturn material.isMeshLambertMaterial || material.isMeshToonMaterial || material.isMeshPhongMaterial || material.isMeshStandardMaterial || material.isShadowMaterial || material.isShaderMaterial && material.lights === true;\n\t}\n\n\tthis.getActiveCubeFace = function () {\n\t\treturn _currentActiveCubeFace;\n\t};\n\n\tthis.getActiveMipmapLevel = function () {\n\t\treturn _currentActiveMipmapLevel;\n\t};\n\n\tthis.getRenderTarget = function () {\n\t\treturn _currentRenderTarget;\n\t};\n\n\tthis.setRenderTargetTextures = function (renderTarget, colorTexture, depthTexture) {\n\t\tproperties.get(renderTarget.texture).__webglTexture = colorTexture;\n\t\tproperties.get(renderTarget.depthTexture).__webglTexture = depthTexture;\n\t\tconst renderTargetProperties = properties.get(renderTarget);\n\t\trenderTargetProperties.__hasExternalTextures = true;\n\n\t\tif (renderTargetProperties.__hasExternalTextures) {\n\t\t\trenderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;\n\n\t\t\tif (!renderTargetProperties.__autoAllocateDepthBuffer) {\n\t\t\t\t// The multisample_render_to_texture extension doesn't work properly if there\n\t\t\t\t// are midframe flushes and an external depth buffer. Disable use of the extension.\n\t\t\t\tif (extensions.has('WEBGL_multisampled_render_to_texture') === true) {\n\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided');\n\t\t\t\t\trenderTargetProperties.__useRenderToTexture = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\n\tthis.setRenderTargetFramebuffer = function (renderTarget, defaultFramebuffer) {\n\t\tconst renderTargetProperties = properties.get(renderTarget);\n\t\trenderTargetProperties.__webglFramebuffer = defaultFramebuffer;\n\t\trenderTargetProperties.__useDefaultFramebuffer = defaultFramebuffer === undefined;\n\t};\n\n\tthis.setRenderTarget = function (renderTarget, activeCubeFace = 0, activeMipmapLevel = 0) {\n\t\t_currentRenderTarget = renderTarget;\n\t\t_currentActiveCubeFace = activeCubeFace;\n\t\t_currentActiveMipmapLevel = activeMipmapLevel;\n\t\tlet useDefaultFramebuffer = true;\n\n\t\tif (renderTarget) {\n\t\t\tconst renderTargetProperties = properties.get(renderTarget);\n\n\t\t\tif (renderTargetProperties.__useDefaultFramebuffer !== undefined) {\n\t\t\t\t// We need to make sure to rebind the framebuffer.\n\t\t\t\tstate.bindFramebuffer(_gl.FRAMEBUFFER, null);\n\t\t\t\tuseDefaultFramebuffer = false;\n\t\t\t} else if (renderTargetProperties.__webglFramebuffer === undefined) {\n\t\t\t\ttextures.setupRenderTarget(renderTarget);\n\t\t\t} else if (renderTargetProperties.__hasExternalTextures) {\n\t\t\t\t// Color and depth texture must be rebound in order for the swapchain to update.\n\t\t\t\ttextures.rebindTextures(renderTarget, properties.get(renderTarget.texture).__webglTexture, properties.get(renderTarget.depthTexture).__webglTexture);\n\t\t\t}\n\t\t}\n\n\t\tlet framebuffer = null;\n\t\tlet isCube = false;\n\t\tlet isRenderTarget3D = false;\n\n\t\tif (renderTarget) {\n\t\t\tconst texture = renderTarget.texture;\n\n\t\t\tif (texture.isData3DTexture || texture.isDataArrayTexture) {\n\t\t\t\tisRenderTarget3D = true;\n\t\t\t}\n\n\t\t\tconst __webglFramebuffer = properties.get(renderTarget).__webglFramebuffer;\n\n\t\t\tif (renderTarget.isWebGLCubeRenderTarget) {\n\t\t\t\tframebuffer = __webglFramebuffer[activeCubeFace];\n\t\t\t\tisCube = true;\n\t\t\t} else if (capabilities.isWebGL2 && renderTarget.samples > 0 && textures.useMultisampledRTT(renderTarget) === false) {\n\t\t\t\tframebuffer = properties.get(renderTarget).__webglMultisampledFramebuffer;\n\t\t\t} else {\n\t\t\t\tframebuffer = __webglFramebuffer;\n\t\t\t}\n\n\t\t\t_currentViewport.copy(renderTarget.viewport);\n\n\t\t\t_currentScissor.copy(renderTarget.scissor);\n\n\t\t\t_currentScissorTest = renderTarget.scissorTest;\n\t\t} else {\n\t\t\t_currentViewport.copy(_viewport).multiplyScalar(_pixelRatio).floor();\n\n\t\t\t_currentScissor.copy(_scissor).multiplyScalar(_pixelRatio).floor();\n\n\t\t\t_currentScissorTest = _scissorTest;\n\t\t}\n\n\t\tconst framebufferBound = state.bindFramebuffer(_gl.FRAMEBUFFER, framebuffer);\n\n\t\tif (framebufferBound && capabilities.drawBuffers && useDefaultFramebuffer) {\n\t\t\tstate.drawBuffers(renderTarget, framebuffer);\n\t\t}\n\n\t\tstate.viewport(_currentViewport);\n\t\tstate.scissor(_currentScissor);\n\t\tstate.setScissorTest(_currentScissorTest);\n\n\t\tif (isCube) {\n\t\t\tconst textureProperties = properties.get(renderTarget.texture);\n\n\t\t\t_gl.framebufferTexture2D(_gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + activeCubeFace, textureProperties.__webglTexture, activeMipmapLevel);\n\t\t} else if (isRenderTarget3D) {\n\t\t\tconst textureProperties = properties.get(renderTarget.texture);\n\t\t\tconst layer = activeCubeFace || 0;\n\n\t\t\t_gl.framebufferTextureLayer(_gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, textureProperties.__webglTexture, activeMipmapLevel || 0, layer);\n\t\t}\n\n\t\t_currentMaterialId = -1; // reset current material to ensure correct uniform bindings\n\t};\n\n\tthis.readRenderTargetPixels = function (renderTarget, x, y, width, height, buffer, activeCubeFaceIndex) {\n\t\tif (!(renderTarget && renderTarget.isWebGLRenderTarget)) {\n\t\t\tconsole.error('THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.');\n\t\t\treturn;\n\t\t}\n\n\t\tlet framebuffer = properties.get(renderTarget).__webglFramebuffer;\n\n\t\tif (renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined) {\n\t\t\tframebuffer = framebuffer[activeCubeFaceIndex];\n\t\t}\n\n\t\tif (framebuffer) {\n\t\t\tstate.bindFramebuffer(_gl.FRAMEBUFFER, framebuffer);\n\n\t\t\ttry {\n\t\t\t\tconst texture = renderTarget.texture;\n\t\t\t\tconst textureFormat = texture.format;\n\t\t\t\tconst textureType = texture.type;\n\n\t\t\t\tif (textureFormat !== RGBAFormat && utils.convert(textureFormat) !== _gl.getParameter(_gl.IMPLEMENTATION_COLOR_READ_FORMAT)) {\n\t\t\t\t\tconsole.error('THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.');\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst halfFloatSupportedByExt = textureType === HalfFloatType && (extensions.has('EXT_color_buffer_half_float') || capabilities.isWebGL2 && extensions.has('EXT_color_buffer_float'));\n\n\t\t\t\tif (textureType !== UnsignedByteType && utils.convert(textureType) !== _gl.getParameter(_gl.IMPLEMENTATION_COLOR_READ_TYPE) && // Edge and Chrome Mac < 52 (#9513)\n\t\t\t\t!(textureType === FloatType && (capabilities.isWebGL2 || extensions.has('OES_texture_float') || extensions.has('WEBGL_color_buffer_float'))) && // Chrome Mac >= 52 and Firefox\n\t\t\t\t!halfFloatSupportedByExt) {\n\t\t\t\t\tconsole.error('THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.');\n\t\t\t\t\treturn;\n\t\t\t\t} // the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)\n\n\n\t\t\t\tif (x >= 0 && x <= renderTarget.width - width && y >= 0 && y <= renderTarget.height - height) {\n\t\t\t\t\t_gl.readPixels(x, y, width, height, utils.convert(textureFormat), utils.convert(textureType), buffer);\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\t// restore framebuffer of current render target if necessary\n\t\t\t\tconst framebuffer = _currentRenderTarget !== null ? properties.get(_currentRenderTarget).__webglFramebuffer : null;\n\t\t\t\tstate.bindFramebuffer(_gl.FRAMEBUFFER, framebuffer);\n\t\t\t}\n\t\t}\n\t};\n\n\tthis.copyFramebufferToTexture = function (position, texture, level = 0) {\n\t\tconst levelScale = Math.pow(2, -level);\n\t\tconst width = Math.floor(texture.image.width * levelScale);\n\t\tconst height = Math.floor(texture.image.height * levelScale);\n\t\ttextures.setTexture2D(texture, 0);\n\n\t\t_gl.copyTexSubImage2D(_gl.TEXTURE_2D, level, 0, 0, position.x, position.y, width, height);\n\n\t\tstate.unbindTexture();\n\t};\n\n\tthis.copyTextureToTexture = function (position, srcTexture, dstTexture, level = 0) {\n\t\tconst width = srcTexture.image.width;\n\t\tconst height = srcTexture.image.height;\n\t\tconst glFormat = utils.convert(dstTexture.format);\n\t\tconst glType = utils.convert(dstTexture.type);\n\t\ttextures.setTexture2D(dstTexture, 0); // As another texture upload may have changed pixelStorei\n\t\t// parameters, make sure they are correct for the dstTexture\n\n\t\t_gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY);\n\n\t\t_gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha);\n\n\t\t_gl.pixelStorei(_gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment);\n\n\t\tif (srcTexture.isDataTexture) {\n\t\t\t_gl.texSubImage2D(_gl.TEXTURE_2D, level, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data);\n\t\t} else {\n\t\t\tif (srcTexture.isCompressedTexture) {\n\t\t\t\t_gl.compressedTexSubImage2D(_gl.TEXTURE_2D, level, position.x, position.y, srcTexture.mipmaps[0].width, srcTexture.mipmaps[0].height, glFormat, srcTexture.mipmaps[0].data);\n\t\t\t} else {\n\t\t\t\t_gl.texSubImage2D(_gl.TEXTURE_2D, level, position.x, position.y, glFormat, glType, srcTexture.image);\n\t\t\t}\n\t\t} // Generate mipmaps only when copying level 0\n\n\n\t\tif (level === 0 && dstTexture.generateMipmaps) _gl.generateMipmap(_gl.TEXTURE_2D);\n\t\tstate.unbindTexture();\n\t};\n\n\tthis.copyTextureToTexture3D = function (sourceBox, position, srcTexture, dstTexture, level = 0) {\n\t\tif (_this.isWebGL1Renderer) {\n\t\t\tconsole.warn('THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.');\n\t\t\treturn;\n\t\t}\n\n\t\tconst width = sourceBox.max.x - sourceBox.min.x + 1;\n\t\tconst height = sourceBox.max.y - sourceBox.min.y + 1;\n\t\tconst depth = sourceBox.max.z - sourceBox.min.z + 1;\n\t\tconst glFormat = utils.convert(dstTexture.format);\n\t\tconst glType = utils.convert(dstTexture.type);\n\t\tlet glTarget;\n\n\t\tif (dstTexture.isData3DTexture) {\n\t\t\ttextures.setTexture3D(dstTexture, 0);\n\t\t\tglTarget = _gl.TEXTURE_3D;\n\t\t} else if (dstTexture.isDataArrayTexture) {\n\t\t\ttextures.setTexture2DArray(dstTexture, 0);\n\t\t\tglTarget = _gl.TEXTURE_2D_ARRAY;\n\t\t} else {\n\t\t\tconsole.warn('THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.');\n\t\t\treturn;\n\t\t}\n\n\t\t_gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY);\n\n\t\t_gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha);\n\n\t\t_gl.pixelStorei(_gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment);\n\n\t\tconst unpackRowLen = _gl.getParameter(_gl.UNPACK_ROW_LENGTH);\n\n\t\tconst unpackImageHeight = _gl.getParameter(_gl.UNPACK_IMAGE_HEIGHT);\n\n\t\tconst unpackSkipPixels = _gl.getParameter(_gl.UNPACK_SKIP_PIXELS);\n\n\t\tconst unpackSkipRows = _gl.getParameter(_gl.UNPACK_SKIP_ROWS);\n\n\t\tconst unpackSkipImages = _gl.getParameter(_gl.UNPACK_SKIP_IMAGES);\n\n\t\tconst image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[0] : srcTexture.image;\n\n\t\t_gl.pixelStorei(_gl.UNPACK_ROW_LENGTH, image.width);\n\n\t\t_gl.pixelStorei(_gl.UNPACK_IMAGE_HEIGHT, image.height);\n\n\t\t_gl.pixelStorei(_gl.UNPACK_SKIP_PIXELS, sourceBox.min.x);\n\n\t\t_gl.pixelStorei(_gl.UNPACK_SKIP_ROWS, sourceBox.min.y);\n\n\t\t_gl.pixelStorei(_gl.UNPACK_SKIP_IMAGES, sourceBox.min.z);\n\n\t\tif (srcTexture.isDataTexture || srcTexture.isData3DTexture) {\n\t\t\t_gl.texSubImage3D(glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, glType, image.data);\n\t\t} else {\n\t\t\tif (srcTexture.isCompressedTexture) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture.');\n\n\t\t\t\t_gl.compressedTexSubImage3D(glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, image.data);\n\t\t\t} else {\n\t\t\t\t_gl.texSubImage3D(glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, glType, image);\n\t\t\t}\n\t\t}\n\n\t\t_gl.pixelStorei(_gl.UNPACK_ROW_LENGTH, unpackRowLen);\n\n\t\t_gl.pixelStorei(_gl.UNPACK_IMAGE_HEIGHT, unpackImageHeight);\n\n\t\t_gl.pixelStorei(_gl.UNPACK_SKIP_PIXELS, unpackSkipPixels);\n\n\t\t_gl.pixelStorei(_gl.UNPACK_SKIP_ROWS, unpackSkipRows);\n\n\t\t_gl.pixelStorei(_gl.UNPACK_SKIP_IMAGES, unpackSkipImages); // Generate mipmaps only when copying level 0\n\n\n\t\tif (level === 0 && dstTexture.generateMipmaps) _gl.generateMipmap(glTarget);\n\t\tstate.unbindTexture();\n\t};\n\n\tthis.initTexture = function (texture) {\n\t\tif (texture.isCubeTexture) {\n\t\t\ttextures.setTextureCube(texture, 0);\n\t\t} else if (texture.isData3DTexture) {\n\t\t\ttextures.setTexture3D(texture, 0);\n\t\t} else if (texture.isDataArrayTexture) {\n\t\t\ttextures.setTexture2DArray(texture, 0);\n\t\t} else {\n\t\t\ttextures.setTexture2D(texture, 0);\n\t\t}\n\n\t\tstate.unbindTexture();\n\t};\n\n\tthis.resetState = function () {\n\t\t_currentActiveCubeFace = 0;\n\t\t_currentActiveMipmapLevel = 0;\n\t\t_currentRenderTarget = null;\n\t\tstate.reset();\n\t\tbindingStates.reset();\n\t};\n\n\tif (typeof __THREE_DEVTOOLS__ !== 'undefined') {\n\t\t__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('observe', {\n\t\t\tdetail: this\n\t\t}));\n\t}\n}\n\nclass WebGL1Renderer extends WebGLRenderer {}\n\nWebGL1Renderer.prototype.isWebGL1Renderer = true;\n\nclass FogExp2 {\n\tconstructor(color, density = 0.00025) {\n\t\tthis.isFogExp2 = true;\n\t\tthis.name = '';\n\t\tthis.color = new Color(color);\n\t\tthis.density = density;\n\t}\n\n\tclone() {\n\t\treturn new FogExp2(this.color, this.density);\n\t}\n\n\ttoJSON() {\n\t\treturn {\n\t\t\ttype: 'FogExp2',\n\t\t\tcolor: this.color.getHex(),\n\t\t\tdensity: this.density\n\t\t};\n\t}\n\n}\n\nclass Fog {\n\tconstructor(color, near = 1, far = 1000) {\n\t\tthis.isFog = true;\n\t\tthis.name = '';\n\t\tthis.color = new Color(color);\n\t\tthis.near = near;\n\t\tthis.far = far;\n\t}\n\n\tclone() {\n\t\treturn new Fog(this.color, this.near, this.far);\n\t}\n\n\ttoJSON() {\n\t\treturn {\n\t\t\ttype: 'Fog',\n\t\t\tcolor: this.color.getHex(),\n\t\t\tnear: this.near,\n\t\t\tfar: this.far\n\t\t};\n\t}\n\n}\n\nclass Scene extends Object3D {\n\tconstructor() {\n\t\tsuper();\n\t\tthis.isScene = true;\n\t\tthis.type = 'Scene';\n\t\tthis.background = null;\n\t\tthis.environment = null;\n\t\tthis.fog = null;\n\t\tthis.overrideMaterial = null;\n\n\t\tif (typeof __THREE_DEVTOOLS__ !== 'undefined') {\n\t\t\t__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('observe', {\n\t\t\t\tdetail: this\n\t\t\t}));\n\t\t}\n\t}\n\n\tcopy(source, recursive) {\n\t\tsuper.copy(source, recursive);\n\t\tif (source.background !== null) this.background = source.background.clone();\n\t\tif (source.environment !== null) this.environment = source.environment.clone();\n\t\tif (source.fog !== null) this.fog = source.fog.clone();\n\t\tif (source.overrideMaterial !== null) this.overrideMaterial = source.overrideMaterial.clone();\n\t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\t\treturn this;\n\t}\n\n\ttoJSON(meta) {\n\t\tconst data = super.toJSON(meta);\n\t\tif (this.fog !== null) data.object.fog = this.fog.toJSON();\n\t\treturn data;\n\t} // @deprecated\n\n\n\tget autoUpdate() {\n\t\tconsole.warn('THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144.');\n\t\treturn this.matrixWorldAutoUpdate;\n\t}\n\n\tset autoUpdate(value) {\n\t\tconsole.warn('THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144.');\n\t\tthis.matrixWorldAutoUpdate = value;\n\t}\n\n}\n\nclass InterleavedBuffer {\n\tconstructor(array, stride) {\n\t\tthis.isInterleavedBuffer = true;\n\t\tthis.array = array;\n\t\tthis.stride = stride;\n\t\tthis.count = array !== undefined ? array.length / stride : 0;\n\t\tthis.usage = StaticDrawUsage;\n\t\tthis.updateRange = {\n\t\t\toffset: 0,\n\t\t\tcount: -1\n\t\t};\n\t\tthis.version = 0;\n\t\tthis.uuid = generateUUID();\n\t}\n\n\tonUploadCallback() {}\n\n\tset needsUpdate(value) {\n\t\tif (value === true) this.version++;\n\t}\n\n\tsetUsage(value) {\n\t\tthis.usage = value;\n\t\treturn this;\n\t}\n\n\tcopy(source) {\n\t\tthis.array = new source.array.constructor(source.array);\n\t\tthis.count = source.count;\n\t\tthis.stride = source.stride;\n\t\tthis.usage = source.usage;\n\t\treturn this;\n\t}\n\n\tcopyAt(index1, attribute, index2) {\n\t\tindex1 *= this.stride;\n\t\tindex2 *= attribute.stride;\n\n\t\tfor (let i = 0, l = this.stride; i < l; i++) {\n\t\t\tthis.array[index1 + i] = attribute.array[index2 + i];\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tset(value, offset = 0) {\n\t\tthis.array.set(value, offset);\n\t\treturn this;\n\t}\n\n\tclone(data) {\n\t\tif (data.arrayBuffers === undefined) {\n\t\t\tdata.arrayBuffers = {};\n\t\t}\n\n\t\tif (this.array.buffer._uuid === undefined) {\n\t\t\tthis.array.buffer._uuid = generateUUID();\n\t\t}\n\n\t\tif (data.arrayBuffers[this.array.buffer._uuid] === undefined) {\n\t\t\tdata.arrayBuffers[this.array.buffer._uuid] = this.array.slice(0).buffer;\n\t\t}\n\n\t\tconst array = new this.array.constructor(data.arrayBuffers[this.array.buffer._uuid]);\n\t\tconst ib = new this.constructor(array, this.stride);\n\t\tib.setUsage(this.usage);\n\t\treturn ib;\n\t}\n\n\tonUpload(callback) {\n\t\tthis.onUploadCallback = callback;\n\t\treturn this;\n\t}\n\n\ttoJSON(data) {\n\t\tif (data.arrayBuffers === undefined) {\n\t\t\tdata.arrayBuffers = {};\n\t\t} // generate UUID for array buffer if necessary\n\n\n\t\tif (this.array.buffer._uuid === undefined) {\n\t\t\tthis.array.buffer._uuid = generateUUID();\n\t\t}\n\n\t\tif (data.arrayBuffers[this.array.buffer._uuid] === undefined) {\n\t\t\tdata.arrayBuffers[this.array.buffer._uuid] = Array.from(new Uint32Array(this.array.buffer));\n\t\t} //\n\n\n\t\treturn {\n\t\t\tuuid: this.uuid,\n\t\t\tbuffer: this.array.buffer._uuid,\n\t\t\ttype: this.array.constructor.name,\n\t\t\tstride: this.stride\n\t\t};\n\t}\n\n}\n\nconst _vector$6 = /*@__PURE__*/new Vector3();\n\nclass InterleavedBufferAttribute {\n\tconstructor(interleavedBuffer, itemSize, offset, normalized = false) {\n\t\tthis.isInterleavedBufferAttribute = true;\n\t\tthis.name = '';\n\t\tthis.data = interleavedBuffer;\n\t\tthis.itemSize = itemSize;\n\t\tthis.offset = offset;\n\t\tthis.normalized = normalized === true;\n\t}\n\n\tget count() {\n\t\treturn this.data.count;\n\t}\n\n\tget array() {\n\t\treturn this.data.array;\n\t}\n\n\tset needsUpdate(value) {\n\t\tthis.data.needsUpdate = value;\n\t}\n\n\tapplyMatrix4(m) {\n\t\tfor (let i = 0, l = this.data.count; i < l; i++) {\n\t\t\t_vector$6.fromBufferAttribute(this, i);\n\n\t\t\t_vector$6.applyMatrix4(m);\n\n\t\t\tthis.setXYZ(i, _vector$6.x, _vector$6.y, _vector$6.z);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tapplyNormalMatrix(m) {\n\t\tfor (let i = 0, l = this.count; i < l; i++) {\n\t\t\t_vector$6.fromBufferAttribute(this, i);\n\n\t\t\t_vector$6.applyNormalMatrix(m);\n\n\t\t\tthis.setXYZ(i, _vector$6.x, _vector$6.y, _vector$6.z);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\ttransformDirection(m) {\n\t\tfor (let i = 0, l = this.count; i < l; i++) {\n\t\t\t_vector$6.fromBufferAttribute(this, i);\n\n\t\t\t_vector$6.transformDirection(m);\n\n\t\t\tthis.setXYZ(i, _vector$6.x, _vector$6.y, _vector$6.z);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tsetX(index, x) {\n\t\tif (this.normalized) x = normalize(x, this.array);\n\t\tthis.data.array[index * this.data.stride + this.offset] = x;\n\t\treturn this;\n\t}\n\n\tsetY(index, y) {\n\t\tif (this.normalized) y = normalize(y, this.array);\n\t\tthis.data.array[index * this.data.stride + this.offset + 1] = y;\n\t\treturn this;\n\t}\n\n\tsetZ(index, z) {\n\t\tif (this.normalized) z = normalize(z, this.array);\n\t\tthis.data.array[index * this.data.stride + this.offset + 2] = z;\n\t\treturn this;\n\t}\n\n\tsetW(index, w) {\n\t\tif (this.normalized) w = normalize(w, this.array);\n\t\tthis.data.array[index * this.data.stride + this.offset + 3] = w;\n\t\treturn this;\n\t}\n\n\tgetX(index) {\n\t\tlet x = this.data.array[index * this.data.stride + this.offset];\n\t\tif (this.normalized) x = denormalize(x, this.array);\n\t\treturn x;\n\t}\n\n\tgetY(index) {\n\t\tlet y = this.data.array[index * this.data.stride + this.offset + 1];\n\t\tif (this.normalized) y = denormalize(y, this.array);\n\t\treturn y;\n\t}\n\n\tgetZ(index) {\n\t\tlet z = this.data.array[index * this.data.stride + this.offset + 2];\n\t\tif (this.normalized) z = denormalize(z, this.array);\n\t\treturn z;\n\t}\n\n\tgetW(index) {\n\t\tlet w = this.data.array[index * this.data.stride + this.offset + 3];\n\t\tif (this.normalized) w = denormalize(w, this.array);\n\t\treturn w;\n\t}\n\n\tsetXY(index, x, y) {\n\t\tindex = index * this.data.stride + this.offset;\n\n\t\tif (this.normalized) {\n\t\t\tx = normalize(x, this.array);\n\t\t\ty = normalize(y, this.array);\n\t\t}\n\n\t\tthis.data.array[index + 0] = x;\n\t\tthis.data.array[index + 1] = y;\n\t\treturn this;\n\t}\n\n\tsetXYZ(index, x, y, z) {\n\t\tindex = index * this.data.stride + this.offset;\n\n\t\tif (this.normalized) {\n\t\t\tx = normalize(x, this.array);\n\t\t\ty = normalize(y, this.array);\n\t\t\tz = normalize(z, this.array);\n\t\t}\n\n\t\tthis.data.array[index + 0] = x;\n\t\tthis.data.array[index + 1] = y;\n\t\tthis.data.array[index + 2] = z;\n\t\treturn this;\n\t}\n\n\tsetXYZW(index, x, y, z, w) {\n\t\tindex = index * this.data.stride + this.offset;\n\n\t\tif (this.normalized) {\n\t\t\tx = normalize(x, this.array);\n\t\t\ty = normalize(y, this.array);\n\t\t\tz = normalize(z, this.array);\n\t\t\tw = normalize(w, this.array);\n\t\t}\n\n\t\tthis.data.array[index + 0] = x;\n\t\tthis.data.array[index + 1] = y;\n\t\tthis.data.array[index + 2] = z;\n\t\tthis.data.array[index + 3] = w;\n\t\treturn this;\n\t}\n\n\tclone(data) {\n\t\tif (data === undefined) {\n\t\t\tconsole.log('THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will deinterleave buffer data.');\n\t\t\tconst array = [];\n\n\t\t\tfor (let i = 0; i < this.count; i++) {\n\t\t\t\tconst index = i * this.data.stride + this.offset;\n\n\t\t\t\tfor (let j = 0; j < this.itemSize; j++) {\n\t\t\t\t\tarray.push(this.data.array[index + j]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn new BufferAttribute(new this.array.constructor(array), this.itemSize, this.normalized);\n\t\t} else {\n\t\t\tif (data.interleavedBuffers === undefined) {\n\t\t\t\tdata.interleavedBuffers = {};\n\t\t\t}\n\n\t\t\tif (data.interleavedBuffers[this.data.uuid] === undefined) {\n\t\t\t\tdata.interleavedBuffers[this.data.uuid] = this.data.clone(data);\n\t\t\t}\n\n\t\t\treturn new InterleavedBufferAttribute(data.interleavedBuffers[this.data.uuid], this.itemSize, this.offset, this.normalized);\n\t\t}\n\t}\n\n\ttoJSON(data) {\n\t\tif (data === undefined) {\n\t\t\tconsole.log('THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will deinterleave buffer data.');\n\t\t\tconst array = [];\n\n\t\t\tfor (let i = 0; i < this.count; i++) {\n\t\t\t\tconst index = i * this.data.stride + this.offset;\n\n\t\t\t\tfor (let j = 0; j < this.itemSize; j++) {\n\t\t\t\t\tarray.push(this.data.array[index + j]);\n\t\t\t\t}\n\t\t\t} // deinterleave data and save it as an ordinary buffer attribute for now\n\n\n\t\t\treturn {\n\t\t\t\titemSize: this.itemSize,\n\t\t\t\ttype: this.array.constructor.name,\n\t\t\t\tarray: array,\n\t\t\t\tnormalized: this.normalized\n\t\t\t};\n\t\t} else {\n\t\t\t// save as true interleaved attribtue\n\t\t\tif (data.interleavedBuffers === undefined) {\n\t\t\t\tdata.interleavedBuffers = {};\n\t\t\t}\n\n\t\t\tif (data.interleavedBuffers[this.data.uuid] === undefined) {\n\t\t\t\tdata.interleavedBuffers[this.data.uuid] = this.data.toJSON(data);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tisInterleavedBufferAttribute: true,\n\t\t\t\titemSize: this.itemSize,\n\t\t\t\tdata: this.data.uuid,\n\t\t\t\toffset: this.offset,\n\t\t\t\tnormalized: this.normalized\n\t\t\t};\n\t\t}\n\t}\n\n}\n\nclass SpriteMaterial extends Material {\n\tconstructor(parameters) {\n\t\tsuper();\n\t\tthis.isSpriteMaterial = true;\n\t\tthis.type = 'SpriteMaterial';\n\t\tthis.color = new Color(0xffffff);\n\t\tthis.map = null;\n\t\tthis.alphaMap = null;\n\t\tthis.rotation = 0;\n\t\tthis.sizeAttenuation = true;\n\t\tthis.transparent = true;\n\t\tthis.fog = true;\n\t\tthis.setValues(parameters);\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.color.copy(source.color);\n\t\tthis.map = source.map;\n\t\tthis.alphaMap = source.alphaMap;\n\t\tthis.rotation = source.rotation;\n\t\tthis.sizeAttenuation = source.sizeAttenuation;\n\t\tthis.fog = source.fog;\n\t\treturn this;\n\t}\n\n}\n\nlet _geometry;\n\nconst _intersectPoint = /*@__PURE__*/new Vector3();\n\nconst _worldScale = /*@__PURE__*/new Vector3();\n\nconst _mvPosition = /*@__PURE__*/new Vector3();\n\nconst _alignedPosition = /*@__PURE__*/new Vector2();\n\nconst _rotatedPosition = /*@__PURE__*/new Vector2();\n\nconst _viewWorldMatrix = /*@__PURE__*/new Matrix4();\n\nconst _vA = /*@__PURE__*/new Vector3();\n\nconst _vB = /*@__PURE__*/new Vector3();\n\nconst _vC = /*@__PURE__*/new Vector3();\n\nconst _uvA = /*@__PURE__*/new Vector2();\n\nconst _uvB = /*@__PURE__*/new Vector2();\n\nconst _uvC = /*@__PURE__*/new Vector2();\n\nclass Sprite extends Object3D {\n\tconstructor(material) {\n\t\tsuper();\n\t\tthis.isSprite = true;\n\t\tthis.type = 'Sprite';\n\n\t\tif (_geometry === undefined) {\n\t\t\t_geometry = new BufferGeometry();\n\t\t\tconst float32Array = new Float32Array([-0.5, -0.5, 0, 0, 0, 0.5, -0.5, 0, 1, 0, 0.5, 0.5, 0, 1, 1, -0.5, 0.5, 0, 0, 1]);\n\t\t\tconst interleavedBuffer = new InterleavedBuffer(float32Array, 5);\n\n\t\t\t_geometry.setIndex([0, 1, 2, 0, 2, 3]);\n\n\t\t\t_geometry.setAttribute('position', new InterleavedBufferAttribute(interleavedBuffer, 3, 0, false));\n\n\t\t\t_geometry.setAttribute('uv', new InterleavedBufferAttribute(interleavedBuffer, 2, 3, false));\n\t\t}\n\n\t\tthis.geometry = _geometry;\n\t\tthis.material = material !== undefined ? material : new SpriteMaterial();\n\t\tthis.center = new Vector2(0.5, 0.5);\n\t}\n\n\traycast(raycaster, intersects) {\n\t\tif (raycaster.camera === null) {\n\t\t\tconsole.error('THREE.Sprite: \"Raycaster.camera\" needs to be set in order to raycast against sprites.');\n\t\t}\n\n\t\t_worldScale.setFromMatrixScale(this.matrixWorld);\n\n\t\t_viewWorldMatrix.copy(raycaster.camera.matrixWorld);\n\n\t\tthis.modelViewMatrix.multiplyMatrices(raycaster.camera.matrixWorldInverse, this.matrixWorld);\n\n\t\t_mvPosition.setFromMatrixPosition(this.modelViewMatrix);\n\n\t\tif (raycaster.camera.isPerspectiveCamera && this.material.sizeAttenuation === false) {\n\t\t\t_worldScale.multiplyScalar(-_mvPosition.z);\n\t\t}\n\n\t\tconst rotation = this.material.rotation;\n\t\tlet sin, cos;\n\n\t\tif (rotation !== 0) {\n\t\t\tcos = Math.cos(rotation);\n\t\t\tsin = Math.sin(rotation);\n\t\t}\n\n\t\tconst center = this.center;\n\t\ttransformVertex(_vA.set(-0.5, -0.5, 0), _mvPosition, center, _worldScale, sin, cos);\n\t\ttransformVertex(_vB.set(0.5, -0.5, 0), _mvPosition, center, _worldScale, sin, cos);\n\t\ttransformVertex(_vC.set(0.5, 0.5, 0), _mvPosition, center, _worldScale, sin, cos);\n\n\t\t_uvA.set(0, 0);\n\n\t\t_uvB.set(1, 0);\n\n\t\t_uvC.set(1, 1); // check first triangle\n\n\n\t\tlet intersect = raycaster.ray.intersectTriangle(_vA, _vB, _vC, false, _intersectPoint);\n\n\t\tif (intersect === null) {\n\t\t\t// check second triangle\n\t\t\ttransformVertex(_vB.set(-0.5, 0.5, 0), _mvPosition, center, _worldScale, sin, cos);\n\n\t\t\t_uvB.set(0, 1);\n\n\t\t\tintersect = raycaster.ray.intersectTriangle(_vA, _vC, _vB, false, _intersectPoint);\n\n\t\t\tif (intersect === null) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tconst distance = raycaster.ray.origin.distanceTo(_intersectPoint);\n\t\tif (distance < raycaster.near || distance > raycaster.far) return;\n\t\tintersects.push({\n\t\t\tdistance: distance,\n\t\t\tpoint: _intersectPoint.clone(),\n\t\t\tuv: Triangle.getUV(_intersectPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2()),\n\t\t\tface: null,\n\t\t\tobject: this\n\t\t});\n\t}\n\n\tcopy(source, recursive) {\n\t\tsuper.copy(source, recursive);\n\t\tif (source.center !== undefined) this.center.copy(source.center);\n\t\tthis.material = source.material;\n\t\treturn this;\n\t}\n\n}\n\nfunction transformVertex(vertexPosition, mvPosition, center, scale, sin, cos) {\n\t// compute position in camera space\n\t_alignedPosition.subVectors(vertexPosition, center).addScalar(0.5).multiply(scale); // to check if rotation is not zero\n\n\n\tif (sin !== undefined) {\n\t\t_rotatedPosition.x = cos * _alignedPosition.x - sin * _alignedPosition.y;\n\t\t_rotatedPosition.y = sin * _alignedPosition.x + cos * _alignedPosition.y;\n\t} else {\n\t\t_rotatedPosition.copy(_alignedPosition);\n\t}\n\n\tvertexPosition.copy(mvPosition);\n\tvertexPosition.x += _rotatedPosition.x;\n\tvertexPosition.y += _rotatedPosition.y; // transform to world space\n\n\tvertexPosition.applyMatrix4(_viewWorldMatrix);\n}\n\nconst _v1$2 = /*@__PURE__*/new Vector3();\n\nconst _v2$1 = /*@__PURE__*/new Vector3();\n\nclass LOD extends Object3D {\n\tconstructor() {\n\t\tsuper();\n\t\tthis._currentLevel = 0;\n\t\tthis.type = 'LOD';\n\t\tObject.defineProperties(this, {\n\t\t\tlevels: {\n\t\t\t\tenumerable: true,\n\t\t\t\tvalue: []\n\t\t\t},\n\t\t\tisLOD: {\n\t\t\t\tvalue: true\n\t\t\t}\n\t\t});\n\t\tthis.autoUpdate = true;\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source, false);\n\t\tconst levels = source.levels;\n\n\t\tfor (let i = 0, l = levels.length; i < l; i++) {\n\t\t\tconst level = levels[i];\n\t\t\tthis.addLevel(level.object.clone(), level.distance);\n\t\t}\n\n\t\tthis.autoUpdate = source.autoUpdate;\n\t\treturn this;\n\t}\n\n\taddLevel(object, distance = 0) {\n\t\tdistance = Math.abs(distance);\n\t\tconst levels = this.levels;\n\t\tlet l;\n\n\t\tfor (l = 0; l < levels.length; l++) {\n\t\t\tif (distance < levels[l].distance) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tlevels.splice(l, 0, {\n\t\t\tdistance: distance,\n\t\t\tobject: object\n\t\t});\n\t\tthis.add(object);\n\t\treturn this;\n\t}\n\n\tgetCurrentLevel() {\n\t\treturn this._currentLevel;\n\t}\n\n\tgetObjectForDistance(distance) {\n\t\tconst levels = this.levels;\n\n\t\tif (levels.length > 0) {\n\t\t\tlet i, l;\n\n\t\t\tfor (i = 1, l = levels.length; i < l; i++) {\n\t\t\t\tif (distance < levels[i].distance) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn levels[i - 1].object;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\traycast(raycaster, intersects) {\n\t\tconst levels = this.levels;\n\n\t\tif (levels.length > 0) {\n\t\t\t_v1$2.setFromMatrixPosition(this.matrixWorld);\n\n\t\t\tconst distance = raycaster.ray.origin.distanceTo(_v1$2);\n\t\t\tthis.getObjectForDistance(distance).raycast(raycaster, intersects);\n\t\t}\n\t}\n\n\tupdate(camera) {\n\t\tconst levels = this.levels;\n\n\t\tif (levels.length > 1) {\n\t\t\t_v1$2.setFromMatrixPosition(camera.matrixWorld);\n\n\t\t\t_v2$1.setFromMatrixPosition(this.matrixWorld);\n\n\t\t\tconst distance = _v1$2.distanceTo(_v2$1) / camera.zoom;\n\t\t\tlevels[0].object.visible = true;\n\t\t\tlet i, l;\n\n\t\t\tfor (i = 1, l = levels.length; i < l; i++) {\n\t\t\t\tif (distance >= levels[i].distance) {\n\t\t\t\t\tlevels[i - 1].object.visible = false;\n\t\t\t\t\tlevels[i].object.visible = true;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis._currentLevel = i - 1;\n\n\t\t\tfor (; i < l; i++) {\n\t\t\t\tlevels[i].object.visible = false;\n\t\t\t}\n\t\t}\n\t}\n\n\ttoJSON(meta) {\n\t\tconst data = super.toJSON(meta);\n\t\tif (this.autoUpdate === false) data.object.autoUpdate = false;\n\t\tdata.object.levels = [];\n\t\tconst levels = this.levels;\n\n\t\tfor (let i = 0, l = levels.length; i < l; i++) {\n\t\t\tconst level = levels[i];\n\t\t\tdata.object.levels.push({\n\t\t\t\tobject: level.object.uuid,\n\t\t\t\tdistance: level.distance\n\t\t\t});\n\t\t}\n\n\t\treturn data;\n\t}\n\n}\n\nconst _basePosition = /*@__PURE__*/new Vector3();\n\nconst _skinIndex = /*@__PURE__*/new Vector4();\n\nconst _skinWeight = /*@__PURE__*/new Vector4();\n\nconst _vector$5 = /*@__PURE__*/new Vector3();\n\nconst _matrix = /*@__PURE__*/new Matrix4();\n\nclass SkinnedMesh extends Mesh {\n\tconstructor(geometry, material) {\n\t\tsuper(geometry, material);\n\t\tthis.isSkinnedMesh = true;\n\t\tthis.type = 'SkinnedMesh';\n\t\tthis.bindMode = 'attached';\n\t\tthis.bindMatrix = new Matrix4();\n\t\tthis.bindMatrixInverse = new Matrix4();\n\t}\n\n\tcopy(source, recursive) {\n\t\tsuper.copy(source, recursive);\n\t\tthis.bindMode = source.bindMode;\n\t\tthis.bindMatrix.copy(source.bindMatrix);\n\t\tthis.bindMatrixInverse.copy(source.bindMatrixInverse);\n\t\tthis.skeleton = source.skeleton;\n\t\treturn this;\n\t}\n\n\tbind(skeleton, bindMatrix) {\n\t\tthis.skeleton = skeleton;\n\n\t\tif (bindMatrix === undefined) {\n\t\t\tthis.updateMatrixWorld(true);\n\t\t\tthis.skeleton.calculateInverses();\n\t\t\tbindMatrix = this.matrixWorld;\n\t\t}\n\n\t\tthis.bindMatrix.copy(bindMatrix);\n\t\tthis.bindMatrixInverse.copy(bindMatrix).invert();\n\t}\n\n\tpose() {\n\t\tthis.skeleton.pose();\n\t}\n\n\tnormalizeSkinWeights() {\n\t\tconst vector = new Vector4();\n\t\tconst skinWeight = this.geometry.attributes.skinWeight;\n\n\t\tfor (let i = 0, l = skinWeight.count; i < l; i++) {\n\t\t\tvector.fromBufferAttribute(skinWeight, i);\n\t\t\tconst scale = 1.0 / vector.manhattanLength();\n\n\t\t\tif (scale !== Infinity) {\n\t\t\t\tvector.multiplyScalar(scale);\n\t\t\t} else {\n\t\t\t\tvector.set(1, 0, 0, 0); // do something reasonable\n\t\t\t}\n\n\t\t\tskinWeight.setXYZW(i, vector.x, vector.y, vector.z, vector.w);\n\t\t}\n\t}\n\n\tupdateMatrixWorld(force) {\n\t\tsuper.updateMatrixWorld(force);\n\n\t\tif (this.bindMode === 'attached') {\n\t\t\tthis.bindMatrixInverse.copy(this.matrixWorld).invert();\n\t\t} else if (this.bindMode === 'detached') {\n\t\t\tthis.bindMatrixInverse.copy(this.bindMatrix).invert();\n\t\t} else {\n\t\t\tconsole.warn('THREE.SkinnedMesh: Unrecognized bindMode: ' + this.bindMode);\n\t\t}\n\t}\n\n\tboneTransform(index, target) {\n\t\tconst skeleton = this.skeleton;\n\t\tconst geometry = this.geometry;\n\n\t\t_skinIndex.fromBufferAttribute(geometry.attributes.skinIndex, index);\n\n\t\t_skinWeight.fromBufferAttribute(geometry.attributes.skinWeight, index);\n\n\t\t_basePosition.copy(target).applyMatrix4(this.bindMatrix);\n\n\t\ttarget.set(0, 0, 0);\n\n\t\tfor (let i = 0; i < 4; i++) {\n\t\t\tconst weight = _skinWeight.getComponent(i);\n\n\t\t\tif (weight !== 0) {\n\t\t\t\tconst boneIndex = _skinIndex.getComponent(i);\n\n\t\t\t\t_matrix.multiplyMatrices(skeleton.bones[boneIndex].matrixWorld, skeleton.boneInverses[boneIndex]);\n\n\t\t\t\ttarget.addScaledVector(_vector$5.copy(_basePosition).applyMatrix4(_matrix), weight);\n\t\t\t}\n\t\t}\n\n\t\treturn target.applyMatrix4(this.bindMatrixInverse);\n\t}\n\n}\n\nclass Bone extends Object3D {\n\tconstructor() {\n\t\tsuper();\n\t\tthis.isBone = true;\n\t\tthis.type = 'Bone';\n\t}\n\n}\n\nclass DataTexture extends Texture {\n\tconstructor(data = null, width = 1, height = 1, format, type, mapping, wrapS, wrapT, magFilter = NearestFilter, minFilter = NearestFilter, anisotropy, encoding) {\n\t\tsuper(null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding);\n\t\tthis.isDataTexture = true;\n\t\tthis.image = {\n\t\t\tdata: data,\n\t\t\twidth: width,\n\t\t\theight: height\n\t\t};\n\t\tthis.generateMipmaps = false;\n\t\tthis.flipY = false;\n\t\tthis.unpackAlignment = 1;\n\t}\n\n}\n\nconst _offsetMatrix = /*@__PURE__*/new Matrix4();\n\nconst _identityMatrix = /*@__PURE__*/new Matrix4();\n\nclass Skeleton {\n\tconstructor(bones = [], boneInverses = []) {\n\t\tthis.uuid = generateUUID();\n\t\tthis.bones = bones.slice(0);\n\t\tthis.boneInverses = boneInverses;\n\t\tthis.boneMatrices = null;\n\t\tthis.boneTexture = null;\n\t\tthis.boneTextureSize = 0;\n\t\tthis.frame = -1;\n\t\tthis.init();\n\t}\n\n\tinit() {\n\t\tconst bones = this.bones;\n\t\tconst boneInverses = this.boneInverses;\n\t\tthis.boneMatrices = new Float32Array(bones.length * 16); // calculate inverse bone matrices if necessary\n\n\t\tif (boneInverses.length === 0) {\n\t\t\tthis.calculateInverses();\n\t\t} else {\n\t\t\t// handle special case\n\t\t\tif (bones.length !== boneInverses.length) {\n\t\t\t\tconsole.warn('THREE.Skeleton: Number of inverse bone matrices does not match amount of bones.');\n\t\t\t\tthis.boneInverses = [];\n\n\t\t\t\tfor (let i = 0, il = this.bones.length; i < il; i++) {\n\t\t\t\t\tthis.boneInverses.push(new Matrix4());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tcalculateInverses() {\n\t\tthis.boneInverses.length = 0;\n\n\t\tfor (let i = 0, il = this.bones.length; i < il; i++) {\n\t\t\tconst inverse = new Matrix4();\n\n\t\t\tif (this.bones[i]) {\n\t\t\t\tinverse.copy(this.bones[i].matrixWorld).invert();\n\t\t\t}\n\n\t\t\tthis.boneInverses.push(inverse);\n\t\t}\n\t}\n\n\tpose() {\n\t\t// recover the bind-time world matrices\n\t\tfor (let i = 0, il = this.bones.length; i < il; i++) {\n\t\t\tconst bone = this.bones[i];\n\n\t\t\tif (bone) {\n\t\t\t\tbone.matrixWorld.copy(this.boneInverses[i]).invert();\n\t\t\t}\n\t\t} // compute the local matrices, positions, rotations and scales\n\n\n\t\tfor (let i = 0, il = this.bones.length; i < il; i++) {\n\t\t\tconst bone = this.bones[i];\n\n\t\t\tif (bone) {\n\t\t\t\tif (bone.parent && bone.parent.isBone) {\n\t\t\t\t\tbone.matrix.copy(bone.parent.matrixWorld).invert();\n\t\t\t\t\tbone.matrix.multiply(bone.matrixWorld);\n\t\t\t\t} else {\n\t\t\t\t\tbone.matrix.copy(bone.matrixWorld);\n\t\t\t\t}\n\n\t\t\t\tbone.matrix.decompose(bone.position, bone.quaternion, bone.scale);\n\t\t\t}\n\t\t}\n\t}\n\n\tupdate() {\n\t\tconst bones = this.bones;\n\t\tconst boneInverses = this.boneInverses;\n\t\tconst boneMatrices = this.boneMatrices;\n\t\tconst boneTexture = this.boneTexture; // flatten bone matrices to array\n\n\t\tfor (let i = 0, il = bones.length; i < il; i++) {\n\t\t\t// compute the offset between the current and the original transform\n\t\t\tconst matrix = bones[i] ? bones[i].matrixWorld : _identityMatrix;\n\n\t\t\t_offsetMatrix.multiplyMatrices(matrix, boneInverses[i]);\n\n\t\t\t_offsetMatrix.toArray(boneMatrices, i * 16);\n\t\t}\n\n\t\tif (boneTexture !== null) {\n\t\t\tboneTexture.needsUpdate = true;\n\t\t}\n\t}\n\n\tclone() {\n\t\treturn new Skeleton(this.bones, this.boneInverses);\n\t}\n\n\tcomputeBoneTexture() {\n\t\t// layout (1 matrix = 4 pixels)\n\t\t//\t\t\tRGBA RGBA RGBA RGBA (=> column1, column2, column3, column4)\n\t\t//\twith\t8x8\tpixel texture max\t 16 bones * 4 pixels =\t(8 * 8)\n\t\t//\t\t\t 16x16 pixel texture max\t 64 bones * 4 pixels = (16 * 16)\n\t\t//\t\t\t 32x32 pixel texture max\t256 bones * 4 pixels = (32 * 32)\n\t\t//\t\t\t 64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64)\n\t\tlet size = Math.sqrt(this.bones.length * 4); // 4 pixels needed for 1 matrix\n\n\t\tsize = ceilPowerOfTwo(size);\n\t\tsize = Math.max(size, 4);\n\t\tconst boneMatrices = new Float32Array(size * size * 4); // 4 floats per RGBA pixel\n\n\t\tboneMatrices.set(this.boneMatrices); // copy current values\n\n\t\tconst boneTexture = new DataTexture(boneMatrices, size, size, RGBAFormat, FloatType);\n\t\tboneTexture.needsUpdate = true;\n\t\tthis.boneMatrices = boneMatrices;\n\t\tthis.boneTexture = boneTexture;\n\t\tthis.boneTextureSize = size;\n\t\treturn this;\n\t}\n\n\tgetBoneByName(name) {\n\t\tfor (let i = 0, il = this.bones.length; i < il; i++) {\n\t\t\tconst bone = this.bones[i];\n\n\t\t\tif (bone.name === name) {\n\t\t\t\treturn bone;\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tdispose() {\n\t\tif (this.boneTexture !== null) {\n\t\t\tthis.boneTexture.dispose();\n\t\t\tthis.boneTexture = null;\n\t\t}\n\t}\n\n\tfromJSON(json, bones) {\n\t\tthis.uuid = json.uuid;\n\n\t\tfor (let i = 0, l = json.bones.length; i < l; i++) {\n\t\t\tconst uuid = json.bones[i];\n\t\t\tlet bone = bones[uuid];\n\n\t\t\tif (bone === undefined) {\n\t\t\t\tconsole.warn('THREE.Skeleton: No bone found with UUID:', uuid);\n\t\t\t\tbone = new Bone();\n\t\t\t}\n\n\t\t\tthis.bones.push(bone);\n\t\t\tthis.boneInverses.push(new Matrix4().fromArray(json.boneInverses[i]));\n\t\t}\n\n\t\tthis.init();\n\t\treturn this;\n\t}\n\n\ttoJSON() {\n\t\tconst data = {\n\t\t\tmetadata: {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'Skeleton',\n\t\t\t\tgenerator: 'Skeleton.toJSON'\n\t\t\t},\n\t\t\tbones: [],\n\t\t\tboneInverses: []\n\t\t};\n\t\tdata.uuid = this.uuid;\n\t\tconst bones = this.bones;\n\t\tconst boneInverses = this.boneInverses;\n\n\t\tfor (let i = 0, l = bones.length; i < l; i++) {\n\t\t\tconst bone = bones[i];\n\t\t\tdata.bones.push(bone.uuid);\n\t\t\tconst boneInverse = boneInverses[i];\n\t\t\tdata.boneInverses.push(boneInverse.toArray());\n\t\t}\n\n\t\treturn data;\n\t}\n\n}\n\nclass InstancedBufferAttribute extends BufferAttribute {\n\tconstructor(array, itemSize, normalized, meshPerAttribute = 1) {\n\t\tsuper(array, itemSize, normalized);\n\t\tthis.isInstancedBufferAttribute = true;\n\t\tthis.meshPerAttribute = meshPerAttribute;\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.meshPerAttribute = source.meshPerAttribute;\n\t\treturn this;\n\t}\n\n\ttoJSON() {\n\t\tconst data = super.toJSON();\n\t\tdata.meshPerAttribute = this.meshPerAttribute;\n\t\tdata.isInstancedBufferAttribute = true;\n\t\treturn data;\n\t}\n\n}\n\nconst _instanceLocalMatrix = /*@__PURE__*/new Matrix4();\n\nconst _instanceWorldMatrix = /*@__PURE__*/new Matrix4();\n\nconst _instanceIntersects = [];\n\nconst _mesh = /*@__PURE__*/new Mesh();\n\nclass InstancedMesh extends Mesh {\n\tconstructor(geometry, material, count) {\n\t\tsuper(geometry, material);\n\t\tthis.isInstancedMesh = true;\n\t\tthis.instanceMatrix = new InstancedBufferAttribute(new Float32Array(count * 16), 16);\n\t\tthis.instanceColor = null;\n\t\tthis.count = count;\n\t\tthis.frustumCulled = false;\n\t}\n\n\tcopy(source, recursive) {\n\t\tsuper.copy(source, recursive);\n\t\tthis.instanceMatrix.copy(source.instanceMatrix);\n\t\tif (source.instanceColor !== null) this.instanceColor = source.instanceColor.clone();\n\t\tthis.count = source.count;\n\t\treturn this;\n\t}\n\n\tgetColorAt(index, color) {\n\t\tcolor.fromArray(this.instanceColor.array, index * 3);\n\t}\n\n\tgetMatrixAt(index, matrix) {\n\t\tmatrix.fromArray(this.instanceMatrix.array, index * 16);\n\t}\n\n\traycast(raycaster, intersects) {\n\t\tconst matrixWorld = this.matrixWorld;\n\t\tconst raycastTimes = this.count;\n\t\t_mesh.geometry = this.geometry;\n\t\t_mesh.material = this.material;\n\t\tif (_mesh.material === undefined) return;\n\n\t\tfor (let instanceId = 0; instanceId < raycastTimes; instanceId++) {\n\t\t\t// calculate the world matrix for each instance\n\t\t\tthis.getMatrixAt(instanceId, _instanceLocalMatrix);\n\n\t\t\t_instanceWorldMatrix.multiplyMatrices(matrixWorld, _instanceLocalMatrix); // the mesh represents this single instance\n\n\n\t\t\t_mesh.matrixWorld = _instanceWorldMatrix;\n\n\t\t\t_mesh.raycast(raycaster, _instanceIntersects); // process the result of raycast\n\n\n\t\t\tfor (let i = 0, l = _instanceIntersects.length; i < l; i++) {\n\t\t\t\tconst intersect = _instanceIntersects[i];\n\t\t\t\tintersect.instanceId = instanceId;\n\t\t\t\tintersect.object = this;\n\t\t\t\tintersects.push(intersect);\n\t\t\t}\n\n\t\t\t_instanceIntersects.length = 0;\n\t\t}\n\t}\n\n\tsetColorAt(index, color) {\n\t\tif (this.instanceColor === null) {\n\t\t\tthis.instanceColor = new InstancedBufferAttribute(new Float32Array(this.instanceMatrix.count * 3), 3);\n\t\t}\n\n\t\tcolor.toArray(this.instanceColor.array, index * 3);\n\t}\n\n\tsetMatrixAt(index, matrix) {\n\t\tmatrix.toArray(this.instanceMatrix.array, index * 16);\n\t}\n\n\tupdateMorphTargets() {}\n\n\tdispose() {\n\t\tthis.dispatchEvent({\n\t\t\ttype: 'dispose'\n\t\t});\n\t}\n\n}\n\nclass LineBasicMaterial extends Material {\n\tconstructor(parameters) {\n\t\tsuper();\n\t\tthis.isLineBasicMaterial = true;\n\t\tthis.type = 'LineBasicMaterial';\n\t\tthis.color = new Color(0xffffff);\n\t\tthis.linewidth = 1;\n\t\tthis.linecap = 'round';\n\t\tthis.linejoin = 'round';\n\t\tthis.fog = true;\n\t\tthis.setValues(parameters);\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.color.copy(source.color);\n\t\tthis.linewidth = source.linewidth;\n\t\tthis.linecap = source.linecap;\n\t\tthis.linejoin = source.linejoin;\n\t\tthis.fog = source.fog;\n\t\treturn this;\n\t}\n\n}\n\nconst _start$1 = /*@__PURE__*/new Vector3();\n\nconst _end$1 = /*@__PURE__*/new Vector3();\n\nconst _inverseMatrix$1 = /*@__PURE__*/new Matrix4();\n\nconst _ray$1 = /*@__PURE__*/new Ray();\n\nconst _sphere$1 = /*@__PURE__*/new Sphere();\n\nclass Line extends Object3D {\n\tconstructor(geometry = new BufferGeometry(), material = new LineBasicMaterial()) {\n\t\tsuper();\n\t\tthis.isLine = true;\n\t\tthis.type = 'Line';\n\t\tthis.geometry = geometry;\n\t\tthis.material = material;\n\t\tthis.updateMorphTargets();\n\t}\n\n\tcopy(source, recursive) {\n\t\tsuper.copy(source, recursive);\n\t\tthis.material = source.material;\n\t\tthis.geometry = source.geometry;\n\t\treturn this;\n\t}\n\n\tcomputeLineDistances() {\n\t\tconst geometry = this.geometry; // we assume non-indexed geometry\n\n\t\tif (geometry.index === null) {\n\t\t\tconst positionAttribute = geometry.attributes.position;\n\t\t\tconst lineDistances = [0];\n\n\t\t\tfor (let i = 1, l = positionAttribute.count; i < l; i++) {\n\t\t\t\t_start$1.fromBufferAttribute(positionAttribute, i - 1);\n\n\t\t\t\t_end$1.fromBufferAttribute(positionAttribute, i);\n\n\t\t\t\tlineDistances[i] = lineDistances[i - 1];\n\t\t\t\tlineDistances[i] += _start$1.distanceTo(_end$1);\n\t\t\t}\n\n\t\t\tgeometry.setAttribute('lineDistance', new Float32BufferAttribute(lineDistances, 1));\n\t\t} else {\n\t\t\tconsole.warn('THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.');\n\t\t}\n\n\t\treturn this;\n\t}\n\n\traycast(raycaster, intersects) {\n\t\tconst geometry = this.geometry;\n\t\tconst matrixWorld = this.matrixWorld;\n\t\tconst threshold = raycaster.params.Line.threshold;\n\t\tconst drawRange = geometry.drawRange; // Checking boundingSphere distance to ray\n\n\t\tif (geometry.boundingSphere === null) geometry.computeBoundingSphere();\n\n\t\t_sphere$1.copy(geometry.boundingSphere);\n\n\t\t_sphere$1.applyMatrix4(matrixWorld);\n\n\t\t_sphere$1.radius += threshold;\n\t\tif (raycaster.ray.intersectsSphere(_sphere$1) === false) return; //\n\n\t\t_inverseMatrix$1.copy(matrixWorld).invert();\n\n\t\t_ray$1.copy(raycaster.ray).applyMatrix4(_inverseMatrix$1);\n\n\t\tconst localThreshold = threshold / ((this.scale.x + this.scale.y + this.scale.z) / 3);\n\t\tconst localThresholdSq = localThreshold * localThreshold;\n\t\tconst vStart = new Vector3();\n\t\tconst vEnd = new Vector3();\n\t\tconst interSegment = new Vector3();\n\t\tconst interRay = new Vector3();\n\t\tconst step = this.isLineSegments ? 2 : 1;\n\t\tconst index = geometry.index;\n\t\tconst attributes = geometry.attributes;\n\t\tconst positionAttribute = attributes.position;\n\n\t\tif (index !== null) {\n\t\t\tconst start = Math.max(0, drawRange.start);\n\t\t\tconst end = Math.min(index.count, drawRange.start + drawRange.count);\n\n\t\t\tfor (let i = start, l = end - 1; i < l; i += step) {\n\t\t\t\tconst a = index.getX(i);\n\t\t\t\tconst b = index.getX(i + 1);\n\t\t\t\tvStart.fromBufferAttribute(positionAttribute, a);\n\t\t\t\tvEnd.fromBufferAttribute(positionAttribute, b);\n\n\t\t\t\tconst distSq = _ray$1.distanceSqToSegment(vStart, vEnd, interRay, interSegment);\n\n\t\t\t\tif (distSq > localThresholdSq) continue;\n\t\t\t\tinterRay.applyMatrix4(this.matrixWorld); //Move back to world space for distance calculation\n\n\t\t\t\tconst distance = raycaster.ray.origin.distanceTo(interRay);\n\t\t\t\tif (distance < raycaster.near || distance > raycaster.far) continue;\n\t\t\t\tintersects.push({\n\t\t\t\t\tdistance: distance,\n\t\t\t\t\t// What do we want? intersection point on the ray or on the segment??\n\t\t\t\t\t// point: raycaster.ray.at( distance ),\n\t\t\t\t\tpoint: interSegment.clone().applyMatrix4(this.matrixWorld),\n\t\t\t\t\tindex: i,\n\t\t\t\t\tface: null,\n\t\t\t\t\tfaceIndex: null,\n\t\t\t\t\tobject: this\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tconst start = Math.max(0, drawRange.start);\n\t\t\tconst end = Math.min(positionAttribute.count, drawRange.start + drawRange.count);\n\n\t\t\tfor (let i = start, l = end - 1; i < l; i += step) {\n\t\t\t\tvStart.fromBufferAttribute(positionAttribute, i);\n\t\t\t\tvEnd.fromBufferAttribute(positionAttribute, i + 1);\n\n\t\t\t\tconst distSq = _ray$1.distanceSqToSegment(vStart, vEnd, interRay, interSegment);\n\n\t\t\t\tif (distSq > localThresholdSq) continue;\n\t\t\t\tinterRay.applyMatrix4(this.matrixWorld); //Move back to world space for distance calculation\n\n\t\t\t\tconst distance = raycaster.ray.origin.distanceTo(interRay);\n\t\t\t\tif (distance < raycaster.near || distance > raycaster.far) continue;\n\t\t\t\tintersects.push({\n\t\t\t\t\tdistance: distance,\n\t\t\t\t\t// What do we want? intersection point on the ray or on the segment??\n\t\t\t\t\t// point: raycaster.ray.at( distance ),\n\t\t\t\t\tpoint: interSegment.clone().applyMatrix4(this.matrixWorld),\n\t\t\t\t\tindex: i,\n\t\t\t\t\tface: null,\n\t\t\t\t\tfaceIndex: null,\n\t\t\t\t\tobject: this\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tupdateMorphTargets() {\n\t\tconst geometry = this.geometry;\n\t\tconst morphAttributes = geometry.morphAttributes;\n\t\tconst keys = Object.keys(morphAttributes);\n\n\t\tif (keys.length > 0) {\n\t\t\tconst morphAttribute = morphAttributes[keys[0]];\n\n\t\t\tif (morphAttribute !== undefined) {\n\t\t\t\tthis.morphTargetInfluences = [];\n\t\t\t\tthis.morphTargetDictionary = {};\n\n\t\t\t\tfor (let m = 0, ml = morphAttribute.length; m < ml; m++) {\n\t\t\t\t\tconst name = morphAttribute[m].name || String(m);\n\t\t\t\t\tthis.morphTargetInfluences.push(0);\n\t\t\t\t\tthis.morphTargetDictionary[name] = m;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n}\n\nconst _start = /*@__PURE__*/new Vector3();\n\nconst _end = /*@__PURE__*/new Vector3();\n\nclass LineSegments extends Line {\n\tconstructor(geometry, material) {\n\t\tsuper(geometry, material);\n\t\tthis.isLineSegments = true;\n\t\tthis.type = 'LineSegments';\n\t}\n\n\tcomputeLineDistances() {\n\t\tconst geometry = this.geometry; // we assume non-indexed geometry\n\n\t\tif (geometry.index === null) {\n\t\t\tconst positionAttribute = geometry.attributes.position;\n\t\t\tconst lineDistances = [];\n\n\t\t\tfor (let i = 0, l = positionAttribute.count; i < l; i += 2) {\n\t\t\t\t_start.fromBufferAttribute(positionAttribute, i);\n\n\t\t\t\t_end.fromBufferAttribute(positionAttribute, i + 1);\n\n\t\t\t\tlineDistances[i] = i === 0 ? 0 : lineDistances[i - 1];\n\t\t\t\tlineDistances[i + 1] = lineDistances[i] + _start.distanceTo(_end);\n\t\t\t}\n\n\t\t\tgeometry.setAttribute('lineDistance', new Float32BufferAttribute(lineDistances, 1));\n\t\t} else {\n\t\t\tconsole.warn('THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.');\n\t\t}\n\n\t\treturn this;\n\t}\n\n}\n\nclass LineLoop extends Line {\n\tconstructor(geometry, material) {\n\t\tsuper(geometry, material);\n\t\tthis.isLineLoop = true;\n\t\tthis.type = 'LineLoop';\n\t}\n\n}\n\nclass PointsMaterial extends Material {\n\tconstructor(parameters) {\n\t\tsuper();\n\t\tthis.isPointsMaterial = true;\n\t\tthis.type = 'PointsMaterial';\n\t\tthis.color = new Color(0xffffff);\n\t\tthis.map = null;\n\t\tthis.alphaMap = null;\n\t\tthis.size = 1;\n\t\tthis.sizeAttenuation = true;\n\t\tthis.fog = true;\n\t\tthis.setValues(parameters);\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.color.copy(source.color);\n\t\tthis.map = source.map;\n\t\tthis.alphaMap = source.alphaMap;\n\t\tthis.size = source.size;\n\t\tthis.sizeAttenuation = source.sizeAttenuation;\n\t\tthis.fog = source.fog;\n\t\treturn this;\n\t}\n\n}\n\nconst _inverseMatrix = /*@__PURE__*/new Matrix4();\n\nconst _ray = /*@__PURE__*/new Ray();\n\nconst _sphere = /*@__PURE__*/new Sphere();\n\nconst _position$2 = /*@__PURE__*/new Vector3();\n\nclass Points extends Object3D {\n\tconstructor(geometry = new BufferGeometry(), material = new PointsMaterial()) {\n\t\tsuper();\n\t\tthis.isPoints = true;\n\t\tthis.type = 'Points';\n\t\tthis.geometry = geometry;\n\t\tthis.material = material;\n\t\tthis.updateMorphTargets();\n\t}\n\n\tcopy(source, recursive) {\n\t\tsuper.copy(source, recursive);\n\t\tthis.material = source.material;\n\t\tthis.geometry = source.geometry;\n\t\treturn this;\n\t}\n\n\traycast(raycaster, intersects) {\n\t\tconst geometry = this.geometry;\n\t\tconst matrixWorld = this.matrixWorld;\n\t\tconst threshold = raycaster.params.Points.threshold;\n\t\tconst drawRange = geometry.drawRange; // Checking boundingSphere distance to ray\n\n\t\tif (geometry.boundingSphere === null) geometry.computeBoundingSphere();\n\n\t\t_sphere.copy(geometry.boundingSphere);\n\n\t\t_sphere.applyMatrix4(matrixWorld);\n\n\t\t_sphere.radius += threshold;\n\t\tif (raycaster.ray.intersectsSphere(_sphere) === false) return; //\n\n\t\t_inverseMatrix.copy(matrixWorld).invert();\n\n\t\t_ray.copy(raycaster.ray).applyMatrix4(_inverseMatrix);\n\n\t\tconst localThreshold = threshold / ((this.scale.x + this.scale.y + this.scale.z) / 3);\n\t\tconst localThresholdSq = localThreshold * localThreshold;\n\t\tconst index = geometry.index;\n\t\tconst attributes = geometry.attributes;\n\t\tconst positionAttribute = attributes.position;\n\n\t\tif (index !== null) {\n\t\t\tconst start = Math.max(0, drawRange.start);\n\t\t\tconst end = Math.min(index.count, drawRange.start + drawRange.count);\n\n\t\t\tfor (let i = start, il = end; i < il; i++) {\n\t\t\t\tconst a = index.getX(i);\n\n\t\t\t\t_position$2.fromBufferAttribute(positionAttribute, a);\n\n\t\t\t\ttestPoint(_position$2, a, localThresholdSq, matrixWorld, raycaster, intersects, this);\n\t\t\t}\n\t\t} else {\n\t\t\tconst start = Math.max(0, drawRange.start);\n\t\t\tconst end = Math.min(positionAttribute.count, drawRange.start + drawRange.count);\n\n\t\t\tfor (let i = start, l = end; i < l; i++) {\n\t\t\t\t_position$2.fromBufferAttribute(positionAttribute, i);\n\n\t\t\t\ttestPoint(_position$2, i, localThresholdSq, matrixWorld, raycaster, intersects, this);\n\t\t\t}\n\t\t}\n\t}\n\n\tupdateMorphTargets() {\n\t\tconst geometry = this.geometry;\n\t\tconst morphAttributes = geometry.morphAttributes;\n\t\tconst keys = Object.keys(morphAttributes);\n\n\t\tif (keys.length > 0) {\n\t\t\tconst morphAttribute = morphAttributes[keys[0]];\n\n\t\t\tif (morphAttribute !== undefined) {\n\t\t\t\tthis.morphTargetInfluences = [];\n\t\t\t\tthis.morphTargetDictionary = {};\n\n\t\t\t\tfor (let m = 0, ml = morphAttribute.length; m < ml; m++) {\n\t\t\t\t\tconst name = morphAttribute[m].name || String(m);\n\t\t\t\t\tthis.morphTargetInfluences.push(0);\n\t\t\t\t\tthis.morphTargetDictionary[name] = m;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n}\n\nfunction testPoint(point, index, localThresholdSq, matrixWorld, raycaster, intersects, object) {\n\tconst rayPointDistanceSq = _ray.distanceSqToPoint(point);\n\n\tif (rayPointDistanceSq < localThresholdSq) {\n\t\tconst intersectPoint = new Vector3();\n\n\t\t_ray.closestPointToPoint(point, intersectPoint);\n\n\t\tintersectPoint.applyMatrix4(matrixWorld);\n\t\tconst distance = raycaster.ray.origin.distanceTo(intersectPoint);\n\t\tif (distance < raycaster.near || distance > raycaster.far) return;\n\t\tintersects.push({\n\t\t\tdistance: distance,\n\t\t\tdistanceToRay: Math.sqrt(rayPointDistanceSq),\n\t\t\tpoint: intersectPoint,\n\t\t\tindex: index,\n\t\t\tface: null,\n\t\t\tobject: object\n\t\t});\n\t}\n}\n\nclass VideoTexture extends Texture {\n\tconstructor(video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy) {\n\t\tsuper(video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy);\n\t\tthis.isVideoTexture = true;\n\t\tthis.minFilter = minFilter !== undefined ? minFilter : LinearFilter;\n\t\tthis.magFilter = magFilter !== undefined ? magFilter : LinearFilter;\n\t\tthis.generateMipmaps = false;\n\t\tconst scope = this;\n\n\t\tfunction updateVideo() {\n\t\t\tscope.needsUpdate = true;\n\t\t\tvideo.requestVideoFrameCallback(updateVideo);\n\t\t}\n\n\t\tif ('requestVideoFrameCallback' in video) {\n\t\t\tvideo.requestVideoFrameCallback(updateVideo);\n\t\t}\n\t}\n\n\tclone() {\n\t\treturn new this.constructor(this.image).copy(this);\n\t}\n\n\tupdate() {\n\t\tconst video = this.image;\n\t\tconst hasVideoFrameCallback = ('requestVideoFrameCallback' in video);\n\n\t\tif (hasVideoFrameCallback === false && video.readyState >= video.HAVE_CURRENT_DATA) {\n\t\t\tthis.needsUpdate = true;\n\t\t}\n\t}\n\n}\n\nclass FramebufferTexture extends Texture {\n\tconstructor(width, height, format) {\n\t\tsuper({\n\t\t\twidth,\n\t\t\theight\n\t\t});\n\t\tthis.isFramebufferTexture = true;\n\t\tthis.format = format;\n\t\tthis.magFilter = NearestFilter;\n\t\tthis.minFilter = NearestFilter;\n\t\tthis.generateMipmaps = false;\n\t\tthis.needsUpdate = true;\n\t}\n\n}\n\nclass CompressedTexture extends Texture {\n\tconstructor(mipmaps, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding) {\n\t\tsuper(null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding);\n\t\tthis.isCompressedTexture = true;\n\t\tthis.image = {\n\t\t\twidth: width,\n\t\t\theight: height\n\t\t};\n\t\tthis.mipmaps = mipmaps; // no flipping for cube textures\n\t\t// (also flipping doesn't work for compressed textures )\n\n\t\tthis.flipY = false; // can't generate mipmaps for compressed textures\n\t\t// mips must be embedded in DDS files\n\n\t\tthis.generateMipmaps = false;\n\t}\n\n}\n\nclass CanvasTexture extends Texture {\n\tconstructor(canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy) {\n\t\tsuper(canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy);\n\t\tthis.isCanvasTexture = true;\n\t\tthis.needsUpdate = true;\n\t}\n\n}\n\n/**\n * Extensible curve object.\n *\n * Some common of curve methods:\n * .getPoint( t, optionalTarget ), .getTangent( t, optionalTarget )\n * .getPointAt( u, optionalTarget ), .getTangentAt( u, optionalTarget )\n * .getPoints(), .getSpacedPoints()\n * .getLength()\n * .updateArcLengths()\n *\n * This following curves inherit from THREE.Curve:\n *\n * -- 2D curves --\n * THREE.ArcCurve\n * THREE.CubicBezierCurve\n * THREE.EllipseCurve\n * THREE.LineCurve\n * THREE.QuadraticBezierCurve\n * THREE.SplineCurve\n *\n * -- 3D curves --\n * THREE.CatmullRomCurve3\n * THREE.CubicBezierCurve3\n * THREE.LineCurve3\n * THREE.QuadraticBezierCurve3\n *\n * A series of curves can be represented as a THREE.CurvePath.\n *\n **/\n\nclass Curve {\n\tconstructor() {\n\t\tthis.type = 'Curve';\n\t\tthis.arcLengthDivisions = 200;\n\t} // Virtual base class method to overwrite and implement in subclasses\n\t//\t- t [0 .. 1]\n\n\n\tgetPoint() {\n\t\tconsole.warn('THREE.Curve: .getPoint() not implemented.');\n\t\treturn null;\n\t} // Get point at relative position in curve according to arc length\n\t// - u [0 .. 1]\n\n\n\tgetPointAt(u, optionalTarget) {\n\t\tconst t = this.getUtoTmapping(u);\n\t\treturn this.getPoint(t, optionalTarget);\n\t} // Get sequence of points using getPoint( t )\n\n\n\tgetPoints(divisions = 5) {\n\t\tconst points = [];\n\n\t\tfor (let d = 0; d <= divisions; d++) {\n\t\t\tpoints.push(this.getPoint(d / divisions));\n\t\t}\n\n\t\treturn points;\n\t} // Get sequence of points using getPointAt( u )\n\n\n\tgetSpacedPoints(divisions = 5) {\n\t\tconst points = [];\n\n\t\tfor (let d = 0; d <= divisions; d++) {\n\t\t\tpoints.push(this.getPointAt(d / divisions));\n\t\t}\n\n\t\treturn points;\n\t} // Get total curve arc length\n\n\n\tgetLength() {\n\t\tconst lengths = this.getLengths();\n\t\treturn lengths[lengths.length - 1];\n\t} // Get list of cumulative segment lengths\n\n\n\tgetLengths(divisions = this.arcLengthDivisions) {\n\t\tif (this.cacheArcLengths && this.cacheArcLengths.length === divisions + 1 && !this.needsUpdate) {\n\t\t\treturn this.cacheArcLengths;\n\t\t}\n\n\t\tthis.needsUpdate = false;\n\t\tconst cache = [];\n\t\tlet current,\n\t\t\t\tlast = this.getPoint(0);\n\t\tlet sum = 0;\n\t\tcache.push(0);\n\n\t\tfor (let p = 1; p <= divisions; p++) {\n\t\t\tcurrent = this.getPoint(p / divisions);\n\t\t\tsum += current.distanceTo(last);\n\t\t\tcache.push(sum);\n\t\t\tlast = current;\n\t\t}\n\n\t\tthis.cacheArcLengths = cache;\n\t\treturn cache; // { sums: cache, sum: sum }; Sum is in the last element.\n\t}\n\n\tupdateArcLengths() {\n\t\tthis.needsUpdate = true;\n\t\tthis.getLengths();\n\t} // Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant\n\n\n\tgetUtoTmapping(u, distance) {\n\t\tconst arcLengths = this.getLengths();\n\t\tlet i = 0;\n\t\tconst il = arcLengths.length;\n\t\tlet targetArcLength; // The targeted u distance value to get\n\n\t\tif (distance) {\n\t\t\ttargetArcLength = distance;\n\t\t} else {\n\t\t\ttargetArcLength = u * arcLengths[il - 1];\n\t\t} // binary search for the index with largest value smaller than target u distance\n\n\n\t\tlet low = 0,\n\t\t\t\thigh = il - 1,\n\t\t\t\tcomparison;\n\n\t\twhile (low <= high) {\n\t\t\ti = Math.floor(low + (high - low) / 2); // less likely to overflow, though probably not issue here, JS doesn't really have integers, all numbers are floats\n\n\t\t\tcomparison = arcLengths[i] - targetArcLength;\n\n\t\t\tif (comparison < 0) {\n\t\t\t\tlow = i + 1;\n\t\t\t} else if (comparison > 0) {\n\t\t\t\thigh = i - 1;\n\t\t\t} else {\n\t\t\t\thigh = i;\n\t\t\t\tbreak; // DONE\n\t\t\t}\n\t\t}\n\n\t\ti = high;\n\n\t\tif (arcLengths[i] === targetArcLength) {\n\t\t\treturn i / (il - 1);\n\t\t} // we could get finer grain at lengths, or use simple interpolation between two points\n\n\n\t\tconst lengthBefore = arcLengths[i];\n\t\tconst lengthAfter = arcLengths[i + 1];\n\t\tconst segmentLength = lengthAfter - lengthBefore; // determine where we are between the 'before' and 'after' points\n\n\t\tconst segmentFraction = (targetArcLength - lengthBefore) / segmentLength; // add that fractional amount to t\n\n\t\tconst t = (i + segmentFraction) / (il - 1);\n\t\treturn t;\n\t} // Returns a unit vector tangent at t\n\t// In case any sub curve does not implement its tangent derivation,\n\t// 2 points a small delta apart will be used to find its gradient\n\t// which seems to give a reasonable approximation\n\n\n\tgetTangent(t, optionalTarget) {\n\t\tconst delta = 0.0001;\n\t\tlet t1 = t - delta;\n\t\tlet t2 = t + delta; // Capping in case of danger\n\n\t\tif (t1 < 0) t1 = 0;\n\t\tif (t2 > 1) t2 = 1;\n\t\tconst pt1 = this.getPoint(t1);\n\t\tconst pt2 = this.getPoint(t2);\n\t\tconst tangent = optionalTarget || (pt1.isVector2 ? new Vector2() : new Vector3());\n\t\ttangent.copy(pt2).sub(pt1).normalize();\n\t\treturn tangent;\n\t}\n\n\tgetTangentAt(u, optionalTarget) {\n\t\tconst t = this.getUtoTmapping(u);\n\t\treturn this.getTangent(t, optionalTarget);\n\t}\n\n\tcomputeFrenetFrames(segments, closed) {\n\t\t// see http://www.cs.indiana.edu/pub/techreports/TR425.pdf\n\t\tconst normal = new Vector3();\n\t\tconst tangents = [];\n\t\tconst normals = [];\n\t\tconst binormals = [];\n\t\tconst vec = new Vector3();\n\t\tconst mat = new Matrix4(); // compute the tangent vectors for each segment on the curve\n\n\t\tfor (let i = 0; i <= segments; i++) {\n\t\t\tconst u = i / segments;\n\t\t\ttangents[i] = this.getTangentAt(u, new Vector3());\n\t\t} // select an initial normal vector perpendicular to the first tangent vector,\n\t\t// and in the direction of the minimum tangent xyz component\n\n\n\t\tnormals[0] = new Vector3();\n\t\tbinormals[0] = new Vector3();\n\t\tlet min = Number.MAX_VALUE;\n\t\tconst tx = Math.abs(tangents[0].x);\n\t\tconst ty = Math.abs(tangents[0].y);\n\t\tconst tz = Math.abs(tangents[0].z);\n\n\t\tif (tx <= min) {\n\t\t\tmin = tx;\n\t\t\tnormal.set(1, 0, 0);\n\t\t}\n\n\t\tif (ty <= min) {\n\t\t\tmin = ty;\n\t\t\tnormal.set(0, 1, 0);\n\t\t}\n\n\t\tif (tz <= min) {\n\t\t\tnormal.set(0, 0, 1);\n\t\t}\n\n\t\tvec.crossVectors(tangents[0], normal).normalize();\n\t\tnormals[0].crossVectors(tangents[0], vec);\n\t\tbinormals[0].crossVectors(tangents[0], normals[0]); // compute the slowly-varying normal and binormal vectors for each segment on the curve\n\n\t\tfor (let i = 1; i <= segments; i++) {\n\t\t\tnormals[i] = normals[i - 1].clone();\n\t\t\tbinormals[i] = binormals[i - 1].clone();\n\t\t\tvec.crossVectors(tangents[i - 1], tangents[i]);\n\n\t\t\tif (vec.length() > Number.EPSILON) {\n\t\t\t\tvec.normalize();\n\t\t\t\tconst theta = Math.acos(clamp(tangents[i - 1].dot(tangents[i]), -1, 1)); // clamp for floating pt errors\n\n\t\t\t\tnormals[i].applyMatrix4(mat.makeRotationAxis(vec, theta));\n\t\t\t}\n\n\t\t\tbinormals[i].crossVectors(tangents[i], normals[i]);\n\t\t} // if the curve is closed, postprocess the vectors so the first and last normal vectors are the same\n\n\n\t\tif (closed === true) {\n\t\t\tlet theta = Math.acos(clamp(normals[0].dot(normals[segments]), -1, 1));\n\t\t\ttheta /= segments;\n\n\t\t\tif (tangents[0].dot(vec.crossVectors(normals[0], normals[segments])) > 0) {\n\t\t\t\ttheta = -theta;\n\t\t\t}\n\n\t\t\tfor (let i = 1; i <= segments; i++) {\n\t\t\t\t// twist a little...\n\t\t\t\tnormals[i].applyMatrix4(mat.makeRotationAxis(tangents[i], theta * i));\n\t\t\t\tbinormals[i].crossVectors(tangents[i], normals[i]);\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\ttangents: tangents,\n\t\t\tnormals: normals,\n\t\t\tbinormals: binormals\n\t\t};\n\t}\n\n\tclone() {\n\t\treturn new this.constructor().copy(this);\n\t}\n\n\tcopy(source) {\n\t\tthis.arcLengthDivisions = source.arcLengthDivisions;\n\t\treturn this;\n\t}\n\n\ttoJSON() {\n\t\tconst data = {\n\t\t\tmetadata: {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'Curve',\n\t\t\t\tgenerator: 'Curve.toJSON'\n\t\t\t}\n\t\t};\n\t\tdata.arcLengthDivisions = this.arcLengthDivisions;\n\t\tdata.type = this.type;\n\t\treturn data;\n\t}\n\n\tfromJSON(json) {\n\t\tthis.arcLengthDivisions = json.arcLengthDivisions;\n\t\treturn this;\n\t}\n\n}\n\nclass EllipseCurve extends Curve {\n\tconstructor(aX = 0, aY = 0, xRadius = 1, yRadius = 1, aStartAngle = 0, aEndAngle = Math.PI * 2, aClockwise = false, aRotation = 0) {\n\t\tsuper();\n\t\tthis.isEllipseCurve = true;\n\t\tthis.type = 'EllipseCurve';\n\t\tthis.aX = aX;\n\t\tthis.aY = aY;\n\t\tthis.xRadius = xRadius;\n\t\tthis.yRadius = yRadius;\n\t\tthis.aStartAngle = aStartAngle;\n\t\tthis.aEndAngle = aEndAngle;\n\t\tthis.aClockwise = aClockwise;\n\t\tthis.aRotation = aRotation;\n\t}\n\n\tgetPoint(t, optionalTarget) {\n\t\tconst point = optionalTarget || new Vector2();\n\t\tconst twoPi = Math.PI * 2;\n\t\tlet deltaAngle = this.aEndAngle - this.aStartAngle;\n\t\tconst samePoints = Math.abs(deltaAngle) < Number.EPSILON; // ensures that deltaAngle is 0 .. 2 PI\n\n\t\twhile (deltaAngle < 0) deltaAngle += twoPi;\n\n\t\twhile (deltaAngle > twoPi) deltaAngle -= twoPi;\n\n\t\tif (deltaAngle < Number.EPSILON) {\n\t\t\tif (samePoints) {\n\t\t\t\tdeltaAngle = 0;\n\t\t\t} else {\n\t\t\t\tdeltaAngle = twoPi;\n\t\t\t}\n\t\t}\n\n\t\tif (this.aClockwise === true && !samePoints) {\n\t\t\tif (deltaAngle === twoPi) {\n\t\t\t\tdeltaAngle = -twoPi;\n\t\t\t} else {\n\t\t\t\tdeltaAngle = deltaAngle - twoPi;\n\t\t\t}\n\t\t}\n\n\t\tconst angle = this.aStartAngle + t * deltaAngle;\n\t\tlet x = this.aX + this.xRadius * Math.cos(angle);\n\t\tlet y = this.aY + this.yRadius * Math.sin(angle);\n\n\t\tif (this.aRotation !== 0) {\n\t\t\tconst cos = Math.cos(this.aRotation);\n\t\t\tconst sin = Math.sin(this.aRotation);\n\t\t\tconst tx = x - this.aX;\n\t\t\tconst ty = y - this.aY; // Rotate the point about the center of the ellipse.\n\n\t\t\tx = tx * cos - ty * sin + this.aX;\n\t\t\ty = tx * sin + ty * cos + this.aY;\n\t\t}\n\n\t\treturn point.set(x, y);\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.aX = source.aX;\n\t\tthis.aY = source.aY;\n\t\tthis.xRadius = source.xRadius;\n\t\tthis.yRadius = source.yRadius;\n\t\tthis.aStartAngle = source.aStartAngle;\n\t\tthis.aEndAngle = source.aEndAngle;\n\t\tthis.aClockwise = source.aClockwise;\n\t\tthis.aRotation = source.aRotation;\n\t\treturn this;\n\t}\n\n\ttoJSON() {\n\t\tconst data = super.toJSON();\n\t\tdata.aX = this.aX;\n\t\tdata.aY = this.aY;\n\t\tdata.xRadius = this.xRadius;\n\t\tdata.yRadius = this.yRadius;\n\t\tdata.aStartAngle = this.aStartAngle;\n\t\tdata.aEndAngle = this.aEndAngle;\n\t\tdata.aClockwise = this.aClockwise;\n\t\tdata.aRotation = this.aRotation;\n\t\treturn data;\n\t}\n\n\tfromJSON(json) {\n\t\tsuper.fromJSON(json);\n\t\tthis.aX = json.aX;\n\t\tthis.aY = json.aY;\n\t\tthis.xRadius = json.xRadius;\n\t\tthis.yRadius = json.yRadius;\n\t\tthis.aStartAngle = json.aStartAngle;\n\t\tthis.aEndAngle = json.aEndAngle;\n\t\tthis.aClockwise = json.aClockwise;\n\t\tthis.aRotation = json.aRotation;\n\t\treturn this;\n\t}\n\n}\n\nclass ArcCurve extends EllipseCurve {\n\tconstructor(aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise) {\n\t\tsuper(aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise);\n\t\tthis.isArcCurve = true;\n\t\tthis.type = 'ArcCurve';\n\t}\n\n}\n\n/**\n * Centripetal CatmullRom Curve - which is useful for avoiding\n * cusps and self-intersections in non-uniform catmull rom curves.\n * http://www.cemyuksel.com/research/catmullrom_param/catmullrom.pdf\n *\n * curve.type accepts centripetal(default), chordal and catmullrom\n * curve.tension is used for catmullrom which defaults to 0.5\n */\n\n/*\nBased on an optimized c++ solution in\n - http://stackoverflow.com/questions/9489736/catmull-rom-curve-with-no-cusps-and-no-self-intersections/\n - http://ideone.com/NoEbVM\n\nThis CubicPoly class could be used for reusing some variables and calculations,\nbut for three.js curve use, it could be possible inlined and flatten into a single function call\nwhich can be placed in CurveUtils.\n*/\n\nfunction CubicPoly() {\n\tlet c0 = 0,\n\t\t\tc1 = 0,\n\t\t\tc2 = 0,\n\t\t\tc3 = 0;\n\t/*\n\t * Compute coefficients for a cubic polynomial\n\t *\t p(s) = c0 + c1*s + c2*s^2 + c3*s^3\n\t * such that\n\t *\t p(0) = x0, p(1) = x1\n\t *\tand\n\t *\t p'(0) = t0, p'(1) = t1.\n\t */\n\n\tfunction init(x0, x1, t0, t1) {\n\t\tc0 = x0;\n\t\tc1 = t0;\n\t\tc2 = -3 * x0 + 3 * x1 - 2 * t0 - t1;\n\t\tc3 = 2 * x0 - 2 * x1 + t0 + t1;\n\t}\n\n\treturn {\n\t\tinitCatmullRom: function (x0, x1, x2, x3, tension) {\n\t\t\tinit(x1, x2, tension * (x2 - x0), tension * (x3 - x1));\n\t\t},\n\t\tinitNonuniformCatmullRom: function (x0, x1, x2, x3, dt0, dt1, dt2) {\n\t\t\t// compute tangents when parameterized in [t1,t2]\n\t\t\tlet t1 = (x1 - x0) / dt0 - (x2 - x0) / (dt0 + dt1) + (x2 - x1) / dt1;\n\t\t\tlet t2 = (x2 - x1) / dt1 - (x3 - x1) / (dt1 + dt2) + (x3 - x2) / dt2; // rescale tangents for parametrization in [0,1]\n\n\t\t\tt1 *= dt1;\n\t\t\tt2 *= dt1;\n\t\t\tinit(x1, x2, t1, t2);\n\t\t},\n\t\tcalc: function (t) {\n\t\t\tconst t2 = t * t;\n\t\t\tconst t3 = t2 * t;\n\t\t\treturn c0 + c1 * t + c2 * t2 + c3 * t3;\n\t\t}\n\t};\n} //\n\n\nconst tmp = /*@__PURE__*/new Vector3();\nconst px = /*@__PURE__*/new CubicPoly();\nconst py = /*@__PURE__*/new CubicPoly();\nconst pz = /*@__PURE__*/new CubicPoly();\n\nclass CatmullRomCurve3 extends Curve {\n\tconstructor(points = [], closed = false, curveType = 'centripetal', tension = 0.5) {\n\t\tsuper();\n\t\tthis.isCatmullRomCurve3 = true;\n\t\tthis.type = 'CatmullRomCurve3';\n\t\tthis.points = points;\n\t\tthis.closed = closed;\n\t\tthis.curveType = curveType;\n\t\tthis.tension = tension;\n\t}\n\n\tgetPoint(t, optionalTarget = new Vector3()) {\n\t\tconst point = optionalTarget;\n\t\tconst points = this.points;\n\t\tconst l = points.length;\n\t\tconst p = (l - (this.closed ? 0 : 1)) * t;\n\t\tlet intPoint = Math.floor(p);\n\t\tlet weight = p - intPoint;\n\n\t\tif (this.closed) {\n\t\t\tintPoint += intPoint > 0 ? 0 : (Math.floor(Math.abs(intPoint) / l) + 1) * l;\n\t\t} else if (weight === 0 && intPoint === l - 1) {\n\t\t\tintPoint = l - 2;\n\t\t\tweight = 1;\n\t\t}\n\n\t\tlet p0, p3; // 4 points (p1 & p2 defined below)\n\n\t\tif (this.closed || intPoint > 0) {\n\t\t\tp0 = points[(intPoint - 1) % l];\n\t\t} else {\n\t\t\t// extrapolate first point\n\t\t\ttmp.subVectors(points[0], points[1]).add(points[0]);\n\t\t\tp0 = tmp;\n\t\t}\n\n\t\tconst p1 = points[intPoint % l];\n\t\tconst p2 = points[(intPoint + 1) % l];\n\n\t\tif (this.closed || intPoint + 2 < l) {\n\t\t\tp3 = points[(intPoint + 2) % l];\n\t\t} else {\n\t\t\t// extrapolate last point\n\t\t\ttmp.subVectors(points[l - 1], points[l - 2]).add(points[l - 1]);\n\t\t\tp3 = tmp;\n\t\t}\n\n\t\tif (this.curveType === 'centripetal' || this.curveType === 'chordal') {\n\t\t\t// init Centripetal / Chordal Catmull-Rom\n\t\t\tconst pow = this.curveType === 'chordal' ? 0.5 : 0.25;\n\t\t\tlet dt0 = Math.pow(p0.distanceToSquared(p1), pow);\n\t\t\tlet dt1 = Math.pow(p1.distanceToSquared(p2), pow);\n\t\t\tlet dt2 = Math.pow(p2.distanceToSquared(p3), pow); // safety check for repeated points\n\n\t\t\tif (dt1 < 1e-4) dt1 = 1.0;\n\t\t\tif (dt0 < 1e-4) dt0 = dt1;\n\t\t\tif (dt2 < 1e-4) dt2 = dt1;\n\t\t\tpx.initNonuniformCatmullRom(p0.x, p1.x, p2.x, p3.x, dt0, dt1, dt2);\n\t\t\tpy.initNonuniformCatmullRom(p0.y, p1.y, p2.y, p3.y, dt0, dt1, dt2);\n\t\t\tpz.initNonuniformCatmullRom(p0.z, p1.z, p2.z, p3.z, dt0, dt1, dt2);\n\t\t} else if (this.curveType === 'catmullrom') {\n\t\t\tpx.initCatmullRom(p0.x, p1.x, p2.x, p3.x, this.tension);\n\t\t\tpy.initCatmullRom(p0.y, p1.y, p2.y, p3.y, this.tension);\n\t\t\tpz.initCatmullRom(p0.z, p1.z, p2.z, p3.z, this.tension);\n\t\t}\n\n\t\tpoint.set(px.calc(weight), py.calc(weight), pz.calc(weight));\n\t\treturn point;\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.points = [];\n\n\t\tfor (let i = 0, l = source.points.length; i < l; i++) {\n\t\t\tconst point = source.points[i];\n\t\t\tthis.points.push(point.clone());\n\t\t}\n\n\t\tthis.closed = source.closed;\n\t\tthis.curveType = source.curveType;\n\t\tthis.tension = source.tension;\n\t\treturn this;\n\t}\n\n\ttoJSON() {\n\t\tconst data = super.toJSON();\n\t\tdata.points = [];\n\n\t\tfor (let i = 0, l = this.points.length; i < l; i++) {\n\t\t\tconst point = this.points[i];\n\t\t\tdata.points.push(point.toArray());\n\t\t}\n\n\t\tdata.closed = this.closed;\n\t\tdata.curveType = this.curveType;\n\t\tdata.tension = this.tension;\n\t\treturn data;\n\t}\n\n\tfromJSON(json) {\n\t\tsuper.fromJSON(json);\n\t\tthis.points = [];\n\n\t\tfor (let i = 0, l = json.points.length; i < l; i++) {\n\t\t\tconst point = json.points[i];\n\t\t\tthis.points.push(new Vector3().fromArray(point));\n\t\t}\n\n\t\tthis.closed = json.closed;\n\t\tthis.curveType = json.curveType;\n\t\tthis.tension = json.tension;\n\t\treturn this;\n\t}\n\n}\n\n/**\n * Bezier Curves formulas obtained from\n * https://en.wikipedia.org/wiki/B%C3%A9zier_curve\n */\nfunction CatmullRom(t, p0, p1, p2, p3) {\n\tconst v0 = (p2 - p0) * 0.5;\n\tconst v1 = (p3 - p1) * 0.5;\n\tconst t2 = t * t;\n\tconst t3 = t * t2;\n\treturn (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;\n} //\n\n\nfunction QuadraticBezierP0(t, p) {\n\tconst k = 1 - t;\n\treturn k * k * p;\n}\n\nfunction QuadraticBezierP1(t, p) {\n\treturn 2 * (1 - t) * t * p;\n}\n\nfunction QuadraticBezierP2(t, p) {\n\treturn t * t * p;\n}\n\nfunction QuadraticBezier(t, p0, p1, p2) {\n\treturn QuadraticBezierP0(t, p0) + QuadraticBezierP1(t, p1) + QuadraticBezierP2(t, p2);\n} //\n\n\nfunction CubicBezierP0(t, p) {\n\tconst k = 1 - t;\n\treturn k * k * k * p;\n}\n\nfunction CubicBezierP1(t, p) {\n\tconst k = 1 - t;\n\treturn 3 * k * k * t * p;\n}\n\nfunction CubicBezierP2(t, p) {\n\treturn 3 * (1 - t) * t * t * p;\n}\n\nfunction CubicBezierP3(t, p) {\n\treturn t * t * t * p;\n}\n\nfunction CubicBezier(t, p0, p1, p2, p3) {\n\treturn CubicBezierP0(t, p0) + CubicBezierP1(t, p1) + CubicBezierP2(t, p2) + CubicBezierP3(t, p3);\n}\n\nclass CubicBezierCurve extends Curve {\n\tconstructor(v0 = new Vector2(), v1 = new Vector2(), v2 = new Vector2(), v3 = new Vector2()) {\n\t\tsuper();\n\t\tthis.isCubicBezierCurve = true;\n\t\tthis.type = 'CubicBezierCurve';\n\t\tthis.v0 = v0;\n\t\tthis.v1 = v1;\n\t\tthis.v2 = v2;\n\t\tthis.v3 = v3;\n\t}\n\n\tgetPoint(t, optionalTarget = new Vector2()) {\n\t\tconst point = optionalTarget;\n\t\tconst v0 = this.v0,\n\t\t\t\t\tv1 = this.v1,\n\t\t\t\t\tv2 = this.v2,\n\t\t\t\t\tv3 = this.v3;\n\t\tpoint.set(CubicBezier(t, v0.x, v1.x, v2.x, v3.x), CubicBezier(t, v0.y, v1.y, v2.y, v3.y));\n\t\treturn point;\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.v0.copy(source.v0);\n\t\tthis.v1.copy(source.v1);\n\t\tthis.v2.copy(source.v2);\n\t\tthis.v3.copy(source.v3);\n\t\treturn this;\n\t}\n\n\ttoJSON() {\n\t\tconst data = super.toJSON();\n\t\tdata.v0 = this.v0.toArray();\n\t\tdata.v1 = this.v1.toArray();\n\t\tdata.v2 = this.v2.toArray();\n\t\tdata.v3 = this.v3.toArray();\n\t\treturn data;\n\t}\n\n\tfromJSON(json) {\n\t\tsuper.fromJSON(json);\n\t\tthis.v0.fromArray(json.v0);\n\t\tthis.v1.fromArray(json.v1);\n\t\tthis.v2.fromArray(json.v2);\n\t\tthis.v3.fromArray(json.v3);\n\t\treturn this;\n\t}\n\n}\n\nclass CubicBezierCurve3 extends Curve {\n\tconstructor(v0 = new Vector3(), v1 = new Vector3(), v2 = new Vector3(), v3 = new Vector3()) {\n\t\tsuper();\n\t\tthis.isCubicBezierCurve3 = true;\n\t\tthis.type = 'CubicBezierCurve3';\n\t\tthis.v0 = v0;\n\t\tthis.v1 = v1;\n\t\tthis.v2 = v2;\n\t\tthis.v3 = v3;\n\t}\n\n\tgetPoint(t, optionalTarget = new Vector3()) {\n\t\tconst point = optionalTarget;\n\t\tconst v0 = this.v0,\n\t\t\t\t\tv1 = this.v1,\n\t\t\t\t\tv2 = this.v2,\n\t\t\t\t\tv3 = this.v3;\n\t\tpoint.set(CubicBezier(t, v0.x, v1.x, v2.x, v3.x), CubicBezier(t, v0.y, v1.y, v2.y, v3.y), CubicBezier(t, v0.z, v1.z, v2.z, v3.z));\n\t\treturn point;\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.v0.copy(source.v0);\n\t\tthis.v1.copy(source.v1);\n\t\tthis.v2.copy(source.v2);\n\t\tthis.v3.copy(source.v3);\n\t\treturn this;\n\t}\n\n\ttoJSON() {\n\t\tconst data = super.toJSON();\n\t\tdata.v0 = this.v0.toArray();\n\t\tdata.v1 = this.v1.toArray();\n\t\tdata.v2 = this.v2.toArray();\n\t\tdata.v3 = this.v3.toArray();\n\t\treturn data;\n\t}\n\n\tfromJSON(json) {\n\t\tsuper.fromJSON(json);\n\t\tthis.v0.fromArray(json.v0);\n\t\tthis.v1.fromArray(json.v1);\n\t\tthis.v2.fromArray(json.v2);\n\t\tthis.v3.fromArray(json.v3);\n\t\treturn this;\n\t}\n\n}\n\nclass LineCurve extends Curve {\n\tconstructor(v1 = new Vector2(), v2 = new Vector2()) {\n\t\tsuper();\n\t\tthis.isLineCurve = true;\n\t\tthis.type = 'LineCurve';\n\t\tthis.v1 = v1;\n\t\tthis.v2 = v2;\n\t}\n\n\tgetPoint(t, optionalTarget = new Vector2()) {\n\t\tconst point = optionalTarget;\n\n\t\tif (t === 1) {\n\t\t\tpoint.copy(this.v2);\n\t\t} else {\n\t\t\tpoint.copy(this.v2).sub(this.v1);\n\t\t\tpoint.multiplyScalar(t).add(this.v1);\n\t\t}\n\n\t\treturn point;\n\t} // Line curve is linear, so we can overwrite default getPointAt\n\n\n\tgetPointAt(u, optionalTarget) {\n\t\treturn this.getPoint(u, optionalTarget);\n\t}\n\n\tgetTangent(t, optionalTarget) {\n\t\tconst tangent = optionalTarget || new Vector2();\n\t\ttangent.copy(this.v2).sub(this.v1).normalize();\n\t\treturn tangent;\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.v1.copy(source.v1);\n\t\tthis.v2.copy(source.v2);\n\t\treturn this;\n\t}\n\n\ttoJSON() {\n\t\tconst data = super.toJSON();\n\t\tdata.v1 = this.v1.toArray();\n\t\tdata.v2 = this.v2.toArray();\n\t\treturn data;\n\t}\n\n\tfromJSON(json) {\n\t\tsuper.fromJSON(json);\n\t\tthis.v1.fromArray(json.v1);\n\t\tthis.v2.fromArray(json.v2);\n\t\treturn this;\n\t}\n\n}\n\nclass LineCurve3 extends Curve {\n\tconstructor(v1 = new Vector3(), v2 = new Vector3()) {\n\t\tsuper();\n\t\tthis.isLineCurve3 = true;\n\t\tthis.type = 'LineCurve3';\n\t\tthis.v1 = v1;\n\t\tthis.v2 = v2;\n\t}\n\n\tgetPoint(t, optionalTarget = new Vector3()) {\n\t\tconst point = optionalTarget;\n\n\t\tif (t === 1) {\n\t\t\tpoint.copy(this.v2);\n\t\t} else {\n\t\t\tpoint.copy(this.v2).sub(this.v1);\n\t\t\tpoint.multiplyScalar(t).add(this.v1);\n\t\t}\n\n\t\treturn point;\n\t} // Line curve is linear, so we can overwrite default getPointAt\n\n\n\tgetPointAt(u, optionalTarget) {\n\t\treturn this.getPoint(u, optionalTarget);\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.v1.copy(source.v1);\n\t\tthis.v2.copy(source.v2);\n\t\treturn this;\n\t}\n\n\ttoJSON() {\n\t\tconst data = super.toJSON();\n\t\tdata.v1 = this.v1.toArray();\n\t\tdata.v2 = this.v2.toArray();\n\t\treturn data;\n\t}\n\n\tfromJSON(json) {\n\t\tsuper.fromJSON(json);\n\t\tthis.v1.fromArray(json.v1);\n\t\tthis.v2.fromArray(json.v2);\n\t\treturn this;\n\t}\n\n}\n\nclass QuadraticBezierCurve extends Curve {\n\tconstructor(v0 = new Vector2(), v1 = new Vector2(), v2 = new Vector2()) {\n\t\tsuper();\n\t\tthis.isQuadraticBezierCurve = true;\n\t\tthis.type = 'QuadraticBezierCurve';\n\t\tthis.v0 = v0;\n\t\tthis.v1 = v1;\n\t\tthis.v2 = v2;\n\t}\n\n\tgetPoint(t, optionalTarget = new Vector2()) {\n\t\tconst point = optionalTarget;\n\t\tconst v0 = this.v0,\n\t\t\t\t\tv1 = this.v1,\n\t\t\t\t\tv2 = this.v2;\n\t\tpoint.set(QuadraticBezier(t, v0.x, v1.x, v2.x), QuadraticBezier(t, v0.y, v1.y, v2.y));\n\t\treturn point;\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.v0.copy(source.v0);\n\t\tthis.v1.copy(source.v1);\n\t\tthis.v2.copy(source.v2);\n\t\treturn this;\n\t}\n\n\ttoJSON() {\n\t\tconst data = super.toJSON();\n\t\tdata.v0 = this.v0.toArray();\n\t\tdata.v1 = this.v1.toArray();\n\t\tdata.v2 = this.v2.toArray();\n\t\treturn data;\n\t}\n\n\tfromJSON(json) {\n\t\tsuper.fromJSON(json);\n\t\tthis.v0.fromArray(json.v0);\n\t\tthis.v1.fromArray(json.v1);\n\t\tthis.v2.fromArray(json.v2);\n\t\treturn this;\n\t}\n\n}\n\nclass QuadraticBezierCurve3 extends Curve {\n\tconstructor(v0 = new Vector3(), v1 = new Vector3(), v2 = new Vector3()) {\n\t\tsuper();\n\t\tthis.isQuadraticBezierCurve3 = true;\n\t\tthis.type = 'QuadraticBezierCurve3';\n\t\tthis.v0 = v0;\n\t\tthis.v1 = v1;\n\t\tthis.v2 = v2;\n\t}\n\n\tgetPoint(t, optionalTarget = new Vector3()) {\n\t\tconst point = optionalTarget;\n\t\tconst v0 = this.v0,\n\t\t\t\t\tv1 = this.v1,\n\t\t\t\t\tv2 = this.v2;\n\t\tpoint.set(QuadraticBezier(t, v0.x, v1.x, v2.x), QuadraticBezier(t, v0.y, v1.y, v2.y), QuadraticBezier(t, v0.z, v1.z, v2.z));\n\t\treturn point;\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.v0.copy(source.v0);\n\t\tthis.v1.copy(source.v1);\n\t\tthis.v2.copy(source.v2);\n\t\treturn this;\n\t}\n\n\ttoJSON() {\n\t\tconst data = super.toJSON();\n\t\tdata.v0 = this.v0.toArray();\n\t\tdata.v1 = this.v1.toArray();\n\t\tdata.v2 = this.v2.toArray();\n\t\treturn data;\n\t}\n\n\tfromJSON(json) {\n\t\tsuper.fromJSON(json);\n\t\tthis.v0.fromArray(json.v0);\n\t\tthis.v1.fromArray(json.v1);\n\t\tthis.v2.fromArray(json.v2);\n\t\treturn this;\n\t}\n\n}\n\nclass SplineCurve extends Curve {\n\tconstructor(points = []) {\n\t\tsuper();\n\t\tthis.isSplineCurve = true;\n\t\tthis.type = 'SplineCurve';\n\t\tthis.points = points;\n\t}\n\n\tgetPoint(t, optionalTarget = new Vector2()) {\n\t\tconst point = optionalTarget;\n\t\tconst points = this.points;\n\t\tconst p = (points.length - 1) * t;\n\t\tconst intPoint = Math.floor(p);\n\t\tconst weight = p - intPoint;\n\t\tconst p0 = points[intPoint === 0 ? intPoint : intPoint - 1];\n\t\tconst p1 = points[intPoint];\n\t\tconst p2 = points[intPoint > points.length - 2 ? points.length - 1 : intPoint + 1];\n\t\tconst p3 = points[intPoint > points.length - 3 ? points.length - 1 : intPoint + 2];\n\t\tpoint.set(CatmullRom(weight, p0.x, p1.x, p2.x, p3.x), CatmullRom(weight, p0.y, p1.y, p2.y, p3.y));\n\t\treturn point;\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.points = [];\n\n\t\tfor (let i = 0, l = source.points.length; i < l; i++) {\n\t\t\tconst point = source.points[i];\n\t\t\tthis.points.push(point.clone());\n\t\t}\n\n\t\treturn this;\n\t}\n\n\ttoJSON() {\n\t\tconst data = super.toJSON();\n\t\tdata.points = [];\n\n\t\tfor (let i = 0, l = this.points.length; i < l; i++) {\n\t\t\tconst point = this.points[i];\n\t\t\tdata.points.push(point.toArray());\n\t\t}\n\n\t\treturn data;\n\t}\n\n\tfromJSON(json) {\n\t\tsuper.fromJSON(json);\n\t\tthis.points = [];\n\n\t\tfor (let i = 0, l = json.points.length; i < l; i++) {\n\t\t\tconst point = json.points[i];\n\t\t\tthis.points.push(new Vector2().fromArray(point));\n\t\t}\n\n\t\treturn this;\n\t}\n\n}\n\nvar Curves = /*#__PURE__*/Object.freeze({\n\t__proto__: null,\n\tArcCurve: ArcCurve,\n\tCatmullRomCurve3: CatmullRomCurve3,\n\tCubicBezierCurve: CubicBezierCurve,\n\tCubicBezierCurve3: CubicBezierCurve3,\n\tEllipseCurve: EllipseCurve,\n\tLineCurve: LineCurve,\n\tLineCurve3: LineCurve3,\n\tQuadraticBezierCurve: QuadraticBezierCurve,\n\tQuadraticBezierCurve3: QuadraticBezierCurve3,\n\tSplineCurve: SplineCurve\n});\n\n/**************************************************************\n *\tCurved Path - a curve path is simply a array of connected\n *\tcurves, but retains the api of a curve\n **************************************************************/\n\nclass CurvePath extends Curve {\n\tconstructor() {\n\t\tsuper();\n\t\tthis.type = 'CurvePath';\n\t\tthis.curves = [];\n\t\tthis.autoClose = false; // Automatically closes the path\n\t}\n\n\tadd(curve) {\n\t\tthis.curves.push(curve);\n\t}\n\n\tclosePath() {\n\t\t// Add a line curve if start and end of lines are not connected\n\t\tconst startPoint = this.curves[0].getPoint(0);\n\t\tconst endPoint = this.curves[this.curves.length - 1].getPoint(1);\n\n\t\tif (!startPoint.equals(endPoint)) {\n\t\t\tthis.curves.push(new LineCurve(endPoint, startPoint));\n\t\t}\n\t} // To get accurate point with reference to\n\t// entire path distance at time t,\n\t// following has to be done:\n\t// 1. Length of each sub path have to be known\n\t// 2. Locate and identify type of curve\n\t// 3. Get t for the curve\n\t// 4. Return curve.getPointAt(t')\n\n\n\tgetPoint(t, optionalTarget) {\n\t\tconst d = t * this.getLength();\n\t\tconst curveLengths = this.getCurveLengths();\n\t\tlet i = 0; // To think about boundaries points.\n\n\t\twhile (i < curveLengths.length) {\n\t\t\tif (curveLengths[i] >= d) {\n\t\t\t\tconst diff = curveLengths[i] - d;\n\t\t\t\tconst curve = this.curves[i];\n\t\t\t\tconst segmentLength = curve.getLength();\n\t\t\t\tconst u = segmentLength === 0 ? 0 : 1 - diff / segmentLength;\n\t\t\t\treturn curve.getPointAt(u, optionalTarget);\n\t\t\t}\n\n\t\t\ti++;\n\t\t}\n\n\t\treturn null; // loop where sum != 0, sum > d , sum+1 1 && !points[points.length - 1].equals(points[0])) {\n\t\t\tpoints.push(points[0]);\n\t\t}\n\n\t\treturn points;\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.curves = [];\n\n\t\tfor (let i = 0, l = source.curves.length; i < l; i++) {\n\t\t\tconst curve = source.curves[i];\n\t\t\tthis.curves.push(curve.clone());\n\t\t}\n\n\t\tthis.autoClose = source.autoClose;\n\t\treturn this;\n\t}\n\n\ttoJSON() {\n\t\tconst data = super.toJSON();\n\t\tdata.autoClose = this.autoClose;\n\t\tdata.curves = [];\n\n\t\tfor (let i = 0, l = this.curves.length; i < l; i++) {\n\t\t\tconst curve = this.curves[i];\n\t\t\tdata.curves.push(curve.toJSON());\n\t\t}\n\n\t\treturn data;\n\t}\n\n\tfromJSON(json) {\n\t\tsuper.fromJSON(json);\n\t\tthis.autoClose = json.autoClose;\n\t\tthis.curves = [];\n\n\t\tfor (let i = 0, l = json.curves.length; i < l; i++) {\n\t\t\tconst curve = json.curves[i];\n\t\t\tthis.curves.push(new Curves[curve.type]().fromJSON(curve));\n\t\t}\n\n\t\treturn this;\n\t}\n\n}\n\nclass Path extends CurvePath {\n\tconstructor(points) {\n\t\tsuper();\n\t\tthis.type = 'Path';\n\t\tthis.currentPoint = new Vector2();\n\n\t\tif (points) {\n\t\t\tthis.setFromPoints(points);\n\t\t}\n\t}\n\n\tsetFromPoints(points) {\n\t\tthis.moveTo(points[0].x, points[0].y);\n\n\t\tfor (let i = 1, l = points.length; i < l; i++) {\n\t\t\tthis.lineTo(points[i].x, points[i].y);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tmoveTo(x, y) {\n\t\tthis.currentPoint.set(x, y); // TODO consider referencing vectors instead of copying?\n\n\t\treturn this;\n\t}\n\n\tlineTo(x, y) {\n\t\tconst curve = new LineCurve(this.currentPoint.clone(), new Vector2(x, y));\n\t\tthis.curves.push(curve);\n\t\tthis.currentPoint.set(x, y);\n\t\treturn this;\n\t}\n\n\tquadraticCurveTo(aCPx, aCPy, aX, aY) {\n\t\tconst curve = new QuadraticBezierCurve(this.currentPoint.clone(), new Vector2(aCPx, aCPy), new Vector2(aX, aY));\n\t\tthis.curves.push(curve);\n\t\tthis.currentPoint.set(aX, aY);\n\t\treturn this;\n\t}\n\n\tbezierCurveTo(aCP1x, aCP1y, aCP2x, aCP2y, aX, aY) {\n\t\tconst curve = new CubicBezierCurve(this.currentPoint.clone(), new Vector2(aCP1x, aCP1y), new Vector2(aCP2x, aCP2y), new Vector2(aX, aY));\n\t\tthis.curves.push(curve);\n\t\tthis.currentPoint.set(aX, aY);\n\t\treturn this;\n\t}\n\n\tsplineThru(pts\n\t/*Array of Vector*/\n\t) {\n\t\tconst npts = [this.currentPoint.clone()].concat(pts);\n\t\tconst curve = new SplineCurve(npts);\n\t\tthis.curves.push(curve);\n\t\tthis.currentPoint.copy(pts[pts.length - 1]);\n\t\treturn this;\n\t}\n\n\tarc(aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise) {\n\t\tconst x0 = this.currentPoint.x;\n\t\tconst y0 = this.currentPoint.y;\n\t\tthis.absarc(aX + x0, aY + y0, aRadius, aStartAngle, aEndAngle, aClockwise);\n\t\treturn this;\n\t}\n\n\tabsarc(aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise) {\n\t\tthis.absellipse(aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise);\n\t\treturn this;\n\t}\n\n\tellipse(aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation) {\n\t\tconst x0 = this.currentPoint.x;\n\t\tconst y0 = this.currentPoint.y;\n\t\tthis.absellipse(aX + x0, aY + y0, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation);\n\t\treturn this;\n\t}\n\n\tabsellipse(aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation) {\n\t\tconst curve = new EllipseCurve(aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation);\n\n\t\tif (this.curves.length > 0) {\n\t\t\t// if a previous curve is present, attempt to join\n\t\t\tconst firstPoint = curve.getPoint(0);\n\n\t\t\tif (!firstPoint.equals(this.currentPoint)) {\n\t\t\t\tthis.lineTo(firstPoint.x, firstPoint.y);\n\t\t\t}\n\t\t}\n\n\t\tthis.curves.push(curve);\n\t\tconst lastPoint = curve.getPoint(1);\n\t\tthis.currentPoint.copy(lastPoint);\n\t\treturn this;\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.currentPoint.copy(source.currentPoint);\n\t\treturn this;\n\t}\n\n\ttoJSON() {\n\t\tconst data = super.toJSON();\n\t\tdata.currentPoint = this.currentPoint.toArray();\n\t\treturn data;\n\t}\n\n\tfromJSON(json) {\n\t\tsuper.fromJSON(json);\n\t\tthis.currentPoint.fromArray(json.currentPoint);\n\t\treturn this;\n\t}\n\n}\n\nclass LatheGeometry extends BufferGeometry {\n\tconstructor(points = [new Vector2(0, -0.5), new Vector2(0.5, 0), new Vector2(0, 0.5)], segments = 12, phiStart = 0, phiLength = Math.PI * 2) {\n\t\tsuper();\n\t\tthis.type = 'LatheGeometry';\n\t\tthis.parameters = {\n\t\t\tpoints: points,\n\t\t\tsegments: segments,\n\t\t\tphiStart: phiStart,\n\t\t\tphiLength: phiLength\n\t\t};\n\t\tsegments = Math.floor(segments); // clamp phiLength so it's in range of [ 0, 2PI ]\n\n\t\tphiLength = clamp(phiLength, 0, Math.PI * 2); // buffers\n\n\t\tconst indices = [];\n\t\tconst vertices = [];\n\t\tconst uvs = [];\n\t\tconst initNormals = [];\n\t\tconst normals = []; // helper variables\n\n\t\tconst inverseSegments = 1.0 / segments;\n\t\tconst vertex = new Vector3();\n\t\tconst uv = new Vector2();\n\t\tconst normal = new Vector3();\n\t\tconst curNormal = new Vector3();\n\t\tconst prevNormal = new Vector3();\n\t\tlet dx = 0;\n\t\tlet dy = 0; // pre-compute normals for initial \"meridian\"\n\n\t\tfor (let j = 0; j <= points.length - 1; j++) {\n\t\t\tswitch (j) {\n\t\t\t\tcase 0:\n\t\t\t\t\t// special handling for 1st vertex on path\n\t\t\t\t\tdx = points[j + 1].x - points[j].x;\n\t\t\t\t\tdy = points[j + 1].y - points[j].y;\n\t\t\t\t\tnormal.x = dy * 1.0;\n\t\t\t\t\tnormal.y = -dx;\n\t\t\t\t\tnormal.z = dy * 0.0;\n\t\t\t\t\tprevNormal.copy(normal);\n\t\t\t\t\tnormal.normalize();\n\t\t\t\t\tinitNormals.push(normal.x, normal.y, normal.z);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase points.length - 1:\n\t\t\t\t\t// special handling for last Vertex on path\n\t\t\t\t\tinitNormals.push(prevNormal.x, prevNormal.y, prevNormal.z);\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\t// default handling for all vertices in between\n\t\t\t\t\tdx = points[j + 1].x - points[j].x;\n\t\t\t\t\tdy = points[j + 1].y - points[j].y;\n\t\t\t\t\tnormal.x = dy * 1.0;\n\t\t\t\t\tnormal.y = -dx;\n\t\t\t\t\tnormal.z = dy * 0.0;\n\t\t\t\t\tcurNormal.copy(normal);\n\t\t\t\t\tnormal.x += prevNormal.x;\n\t\t\t\t\tnormal.y += prevNormal.y;\n\t\t\t\t\tnormal.z += prevNormal.z;\n\t\t\t\t\tnormal.normalize();\n\t\t\t\t\tinitNormals.push(normal.x, normal.y, normal.z);\n\t\t\t\t\tprevNormal.copy(curNormal);\n\t\t\t}\n\t\t} // generate vertices, uvs and normals\n\n\n\t\tfor (let i = 0; i <= segments; i++) {\n\t\t\tconst phi = phiStart + i * inverseSegments * phiLength;\n\t\t\tconst sin = Math.sin(phi);\n\t\t\tconst cos = Math.cos(phi);\n\n\t\t\tfor (let j = 0; j <= points.length - 1; j++) {\n\t\t\t\t// vertex\n\t\t\t\tvertex.x = points[j].x * sin;\n\t\t\t\tvertex.y = points[j].y;\n\t\t\t\tvertex.z = points[j].x * cos;\n\t\t\t\tvertices.push(vertex.x, vertex.y, vertex.z); // uv\n\n\t\t\t\tuv.x = i / segments;\n\t\t\t\tuv.y = j / (points.length - 1);\n\t\t\t\tuvs.push(uv.x, uv.y); // normal\n\n\t\t\t\tconst x = initNormals[3 * j + 0] * sin;\n\t\t\t\tconst y = initNormals[3 * j + 1];\n\t\t\t\tconst z = initNormals[3 * j + 0] * cos;\n\t\t\t\tnormals.push(x, y, z);\n\t\t\t}\n\t\t} // indices\n\n\n\t\tfor (let i = 0; i < segments; i++) {\n\t\t\tfor (let j = 0; j < points.length - 1; j++) {\n\t\t\t\tconst base = j + i * points.length;\n\t\t\t\tconst a = base;\n\t\t\t\tconst b = base + points.length;\n\t\t\t\tconst c = base + points.length + 1;\n\t\t\t\tconst d = base + 1; // faces\n\n\t\t\t\tindices.push(a, b, d);\n\t\t\t\tindices.push(c, d, b);\n\t\t\t}\n\t\t} // build geometry\n\n\n\t\tthis.setIndex(indices);\n\t\tthis.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\tthis.setAttribute('uv', new Float32BufferAttribute(uvs, 2));\n\t\tthis.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\t}\n\n\tstatic fromJSON(data) {\n\t\treturn new LatheGeometry(data.points, data.segments, data.phiStart, data.phiLength);\n\t}\n\n}\n\nclass CapsuleGeometry extends LatheGeometry {\n\tconstructor(radius = 1, length = 1, capSegments = 4, radialSegments = 8) {\n\t\tconst path = new Path();\n\t\tpath.absarc(0, -length / 2, radius, Math.PI * 1.5, 0);\n\t\tpath.absarc(0, length / 2, radius, 0, Math.PI * 0.5);\n\t\tsuper(path.getPoints(capSegments), radialSegments);\n\t\tthis.type = 'CapsuleGeometry';\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\theight: length,\n\t\t\tcapSegments: capSegments,\n\t\t\tradialSegments: radialSegments\n\t\t};\n\t}\n\n\tstatic fromJSON(data) {\n\t\treturn new CapsuleGeometry(data.radius, data.length, data.capSegments, data.radialSegments);\n\t}\n\n}\n\nclass CircleGeometry extends BufferGeometry {\n\tconstructor(radius = 1, segments = 8, thetaStart = 0, thetaLength = Math.PI * 2) {\n\t\tsuper();\n\t\tthis.type = 'CircleGeometry';\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\tsegments: segments,\n\t\t\tthetaStart: thetaStart,\n\t\t\tthetaLength: thetaLength\n\t\t};\n\t\tsegments = Math.max(3, segments); // buffers\n\n\t\tconst indices = [];\n\t\tconst vertices = [];\n\t\tconst normals = [];\n\t\tconst uvs = []; // helper variables\n\n\t\tconst vertex = new Vector3();\n\t\tconst uv = new Vector2(); // center point\n\n\t\tvertices.push(0, 0, 0);\n\t\tnormals.push(0, 0, 1);\n\t\tuvs.push(0.5, 0.5);\n\n\t\tfor (let s = 0, i = 3; s <= segments; s++, i += 3) {\n\t\t\tconst segment = thetaStart + s / segments * thetaLength; // vertex\n\n\t\t\tvertex.x = radius * Math.cos(segment);\n\t\t\tvertex.y = radius * Math.sin(segment);\n\t\t\tvertices.push(vertex.x, vertex.y, vertex.z); // normal\n\n\t\t\tnormals.push(0, 0, 1); // uvs\n\n\t\t\tuv.x = (vertices[i] / radius + 1) / 2;\n\t\t\tuv.y = (vertices[i + 1] / radius + 1) / 2;\n\t\t\tuvs.push(uv.x, uv.y);\n\t\t} // indices\n\n\n\t\tfor (let i = 1; i <= segments; i++) {\n\t\t\tindices.push(i, i + 1, 0);\n\t\t} // build geometry\n\n\n\t\tthis.setIndex(indices);\n\t\tthis.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\tthis.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\t\tthis.setAttribute('uv', new Float32BufferAttribute(uvs, 2));\n\t}\n\n\tstatic fromJSON(data) {\n\t\treturn new CircleGeometry(data.radius, data.segments, data.thetaStart, data.thetaLength);\n\t}\n\n}\n\nclass CylinderGeometry extends BufferGeometry {\n\tconstructor(radiusTop = 1, radiusBottom = 1, height = 1, radialSegments = 8, heightSegments = 1, openEnded = false, thetaStart = 0, thetaLength = Math.PI * 2) {\n\t\tsuper();\n\t\tthis.type = 'CylinderGeometry';\n\t\tthis.parameters = {\n\t\t\tradiusTop: radiusTop,\n\t\t\tradiusBottom: radiusBottom,\n\t\t\theight: height,\n\t\t\tradialSegments: radialSegments,\n\t\t\theightSegments: heightSegments,\n\t\t\topenEnded: openEnded,\n\t\t\tthetaStart: thetaStart,\n\t\t\tthetaLength: thetaLength\n\t\t};\n\t\tconst scope = this;\n\t\tradialSegments = Math.floor(radialSegments);\n\t\theightSegments = Math.floor(heightSegments); // buffers\n\n\t\tconst indices = [];\n\t\tconst vertices = [];\n\t\tconst normals = [];\n\t\tconst uvs = []; // helper variables\n\n\t\tlet index = 0;\n\t\tconst indexArray = [];\n\t\tconst halfHeight = height / 2;\n\t\tlet groupStart = 0; // generate geometry\n\n\t\tgenerateTorso();\n\n\t\tif (openEnded === false) {\n\t\t\tif (radiusTop > 0) generateCap(true);\n\t\t\tif (radiusBottom > 0) generateCap(false);\n\t\t} // build geometry\n\n\n\t\tthis.setIndex(indices);\n\t\tthis.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\tthis.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\t\tthis.setAttribute('uv', new Float32BufferAttribute(uvs, 2));\n\n\t\tfunction generateTorso() {\n\t\t\tconst normal = new Vector3();\n\t\t\tconst vertex = new Vector3();\n\t\t\tlet groupCount = 0; // this will be used to calculate the normal\n\n\t\t\tconst slope = (radiusBottom - radiusTop) / height; // generate vertices, normals and uvs\n\n\t\t\tfor (let y = 0; y <= heightSegments; y++) {\n\t\t\t\tconst indexRow = [];\n\t\t\t\tconst v = y / heightSegments; // calculate the radius of the current row\n\n\t\t\t\tconst radius = v * (radiusBottom - radiusTop) + radiusTop;\n\n\t\t\t\tfor (let x = 0; x <= radialSegments; x++) {\n\t\t\t\t\tconst u = x / radialSegments;\n\t\t\t\t\tconst theta = u * thetaLength + thetaStart;\n\t\t\t\t\tconst sinTheta = Math.sin(theta);\n\t\t\t\t\tconst cosTheta = Math.cos(theta); // vertex\n\n\t\t\t\t\tvertex.x = radius * sinTheta;\n\t\t\t\t\tvertex.y = -v * height + halfHeight;\n\t\t\t\t\tvertex.z = radius * cosTheta;\n\t\t\t\t\tvertices.push(vertex.x, vertex.y, vertex.z); // normal\n\n\t\t\t\t\tnormal.set(sinTheta, slope, cosTheta).normalize();\n\t\t\t\t\tnormals.push(normal.x, normal.y, normal.z); // uv\n\n\t\t\t\t\tuvs.push(u, 1 - v); // save index of vertex in respective row\n\n\t\t\t\t\tindexRow.push(index++);\n\t\t\t\t} // now save vertices of the row in our index array\n\n\n\t\t\t\tindexArray.push(indexRow);\n\t\t\t} // generate indices\n\n\n\t\t\tfor (let x = 0; x < radialSegments; x++) {\n\t\t\t\tfor (let y = 0; y < heightSegments; y++) {\n\t\t\t\t\t// we use the index array to access the correct indices\n\t\t\t\t\tconst a = indexArray[y][x];\n\t\t\t\t\tconst b = indexArray[y + 1][x];\n\t\t\t\t\tconst c = indexArray[y + 1][x + 1];\n\t\t\t\t\tconst d = indexArray[y][x + 1]; // faces\n\n\t\t\t\t\tindices.push(a, b, d);\n\t\t\t\t\tindices.push(b, c, d); // update group counter\n\n\t\t\t\t\tgroupCount += 6;\n\t\t\t\t}\n\t\t\t} // add a group to the geometry. this will ensure multi material support\n\n\n\t\t\tscope.addGroup(groupStart, groupCount, 0); // calculate new start value for groups\n\n\t\t\tgroupStart += groupCount;\n\t\t}\n\n\t\tfunction generateCap(top) {\n\t\t\t// save the index of the first center vertex\n\t\t\tconst centerIndexStart = index;\n\t\t\tconst uv = new Vector2();\n\t\t\tconst vertex = new Vector3();\n\t\t\tlet groupCount = 0;\n\t\t\tconst radius = top === true ? radiusTop : radiusBottom;\n\t\t\tconst sign = top === true ? 1 : -1; // first we generate the center vertex data of the cap.\n\t\t\t// because the geometry needs one set of uvs per face,\n\t\t\t// we must generate a center vertex per face/segment\n\n\t\t\tfor (let x = 1; x <= radialSegments; x++) {\n\t\t\t\t// vertex\n\t\t\t\tvertices.push(0, halfHeight * sign, 0); // normal\n\n\t\t\t\tnormals.push(0, sign, 0); // uv\n\n\t\t\t\tuvs.push(0.5, 0.5); // increase index\n\n\t\t\t\tindex++;\n\t\t\t} // save the index of the last center vertex\n\n\n\t\t\tconst centerIndexEnd = index; // now we generate the surrounding vertices, normals and uvs\n\n\t\t\tfor (let x = 0; x <= radialSegments; x++) {\n\t\t\t\tconst u = x / radialSegments;\n\t\t\t\tconst theta = u * thetaLength + thetaStart;\n\t\t\t\tconst cosTheta = Math.cos(theta);\n\t\t\t\tconst sinTheta = Math.sin(theta); // vertex\n\n\t\t\t\tvertex.x = radius * sinTheta;\n\t\t\t\tvertex.y = halfHeight * sign;\n\t\t\t\tvertex.z = radius * cosTheta;\n\t\t\t\tvertices.push(vertex.x, vertex.y, vertex.z); // normal\n\n\t\t\t\tnormals.push(0, sign, 0); // uv\n\n\t\t\t\tuv.x = cosTheta * 0.5 + 0.5;\n\t\t\t\tuv.y = sinTheta * 0.5 * sign + 0.5;\n\t\t\t\tuvs.push(uv.x, uv.y); // increase index\n\n\t\t\t\tindex++;\n\t\t\t} // generate indices\n\n\n\t\t\tfor (let x = 0; x < radialSegments; x++) {\n\t\t\t\tconst c = centerIndexStart + x;\n\t\t\t\tconst i = centerIndexEnd + x;\n\n\t\t\t\tif (top === true) {\n\t\t\t\t\t// face top\n\t\t\t\t\tindices.push(i, i + 1, c);\n\t\t\t\t} else {\n\t\t\t\t\t// face bottom\n\t\t\t\t\tindices.push(i + 1, i, c);\n\t\t\t\t}\n\n\t\t\t\tgroupCount += 3;\n\t\t\t} // add a group to the geometry. this will ensure multi material support\n\n\n\t\t\tscope.addGroup(groupStart, groupCount, top === true ? 1 : 2); // calculate new start value for groups\n\n\t\t\tgroupStart += groupCount;\n\t\t}\n\t}\n\n\tstatic fromJSON(data) {\n\t\treturn new CylinderGeometry(data.radiusTop, data.radiusBottom, data.height, data.radialSegments, data.heightSegments, data.openEnded, data.thetaStart, data.thetaLength);\n\t}\n\n}\n\nclass ConeGeometry extends CylinderGeometry {\n\tconstructor(radius = 1, height = 1, radialSegments = 8, heightSegments = 1, openEnded = false, thetaStart = 0, thetaLength = Math.PI * 2) {\n\t\tsuper(0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength);\n\t\tthis.type = 'ConeGeometry';\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\theight: height,\n\t\t\tradialSegments: radialSegments,\n\t\t\theightSegments: heightSegments,\n\t\t\topenEnded: openEnded,\n\t\t\tthetaStart: thetaStart,\n\t\t\tthetaLength: thetaLength\n\t\t};\n\t}\n\n\tstatic fromJSON(data) {\n\t\treturn new ConeGeometry(data.radius, data.height, data.radialSegments, data.heightSegments, data.openEnded, data.thetaStart, data.thetaLength);\n\t}\n\n}\n\nclass PolyhedronGeometry extends BufferGeometry {\n\tconstructor(vertices = [], indices = [], radius = 1, detail = 0) {\n\t\tsuper();\n\t\tthis.type = 'PolyhedronGeometry';\n\t\tthis.parameters = {\n\t\t\tvertices: vertices,\n\t\t\tindices: indices,\n\t\t\tradius: radius,\n\t\t\tdetail: detail\n\t\t}; // default buffer data\n\n\t\tconst vertexBuffer = [];\n\t\tconst uvBuffer = []; // the subdivision creates the vertex buffer data\n\n\t\tsubdivide(detail); // all vertices should lie on a conceptual sphere with a given radius\n\n\t\tapplyRadius(radius); // finally, create the uv data\n\n\t\tgenerateUVs(); // build non-indexed geometry\n\n\t\tthis.setAttribute('position', new Float32BufferAttribute(vertexBuffer, 3));\n\t\tthis.setAttribute('normal', new Float32BufferAttribute(vertexBuffer.slice(), 3));\n\t\tthis.setAttribute('uv', new Float32BufferAttribute(uvBuffer, 2));\n\n\t\tif (detail === 0) {\n\t\t\tthis.computeVertexNormals(); // flat normals\n\t\t} else {\n\t\t\tthis.normalizeNormals(); // smooth normals\n\t\t} // helper functions\n\n\n\t\tfunction subdivide(detail) {\n\t\t\tconst a = new Vector3();\n\t\t\tconst b = new Vector3();\n\t\t\tconst c = new Vector3(); // iterate over all faces and apply a subdivison with the given detail value\n\n\t\t\tfor (let i = 0; i < indices.length; i += 3) {\n\t\t\t\t// get the vertices of the face\n\t\t\t\tgetVertexByIndex(indices[i + 0], a);\n\t\t\t\tgetVertexByIndex(indices[i + 1], b);\n\t\t\t\tgetVertexByIndex(indices[i + 2], c); // perform subdivision\n\n\t\t\t\tsubdivideFace(a, b, c, detail);\n\t\t\t}\n\t\t}\n\n\t\tfunction subdivideFace(a, b, c, detail) {\n\t\t\tconst cols = detail + 1; // we use this multidimensional array as a data structure for creating the subdivision\n\n\t\t\tconst v = []; // construct all of the vertices for this subdivision\n\n\t\t\tfor (let i = 0; i <= cols; i++) {\n\t\t\t\tv[i] = [];\n\t\t\t\tconst aj = a.clone().lerp(c, i / cols);\n\t\t\t\tconst bj = b.clone().lerp(c, i / cols);\n\t\t\t\tconst rows = cols - i;\n\n\t\t\t\tfor (let j = 0; j <= rows; j++) {\n\t\t\t\t\tif (j === 0 && i === cols) {\n\t\t\t\t\t\tv[i][j] = aj;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tv[i][j] = aj.clone().lerp(bj, j / rows);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} // construct all of the faces\n\n\n\t\t\tfor (let i = 0; i < cols; i++) {\n\t\t\t\tfor (let j = 0; j < 2 * (cols - i) - 1; j++) {\n\t\t\t\t\tconst k = Math.floor(j / 2);\n\n\t\t\t\t\tif (j % 2 === 0) {\n\t\t\t\t\t\tpushVertex(v[i][k + 1]);\n\t\t\t\t\t\tpushVertex(v[i + 1][k]);\n\t\t\t\t\t\tpushVertex(v[i][k]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpushVertex(v[i][k + 1]);\n\t\t\t\t\t\tpushVertex(v[i + 1][k + 1]);\n\t\t\t\t\t\tpushVertex(v[i + 1][k]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction applyRadius(radius) {\n\t\t\tconst vertex = new Vector3(); // iterate over the entire buffer and apply the radius to each vertex\n\n\t\t\tfor (let i = 0; i < vertexBuffer.length; i += 3) {\n\t\t\t\tvertex.x = vertexBuffer[i + 0];\n\t\t\t\tvertex.y = vertexBuffer[i + 1];\n\t\t\t\tvertex.z = vertexBuffer[i + 2];\n\t\t\t\tvertex.normalize().multiplyScalar(radius);\n\t\t\t\tvertexBuffer[i + 0] = vertex.x;\n\t\t\t\tvertexBuffer[i + 1] = vertex.y;\n\t\t\t\tvertexBuffer[i + 2] = vertex.z;\n\t\t\t}\n\t\t}\n\n\t\tfunction generateUVs() {\n\t\t\tconst vertex = new Vector3();\n\n\t\t\tfor (let i = 0; i < vertexBuffer.length; i += 3) {\n\t\t\t\tvertex.x = vertexBuffer[i + 0];\n\t\t\t\tvertex.y = vertexBuffer[i + 1];\n\t\t\t\tvertex.z = vertexBuffer[i + 2];\n\t\t\t\tconst u = azimuth(vertex) / 2 / Math.PI + 0.5;\n\t\t\t\tconst v = inclination(vertex) / Math.PI + 0.5;\n\t\t\t\tuvBuffer.push(u, 1 - v);\n\t\t\t}\n\n\t\t\tcorrectUVs();\n\t\t\tcorrectSeam();\n\t\t}\n\n\t\tfunction correctSeam() {\n\t\t\t// handle case when face straddles the seam, see #3269\n\t\t\tfor (let i = 0; i < uvBuffer.length; i += 6) {\n\t\t\t\t// uv data of a single face\n\t\t\t\tconst x0 = uvBuffer[i + 0];\n\t\t\t\tconst x1 = uvBuffer[i + 2];\n\t\t\t\tconst x2 = uvBuffer[i + 4];\n\t\t\t\tconst max = Math.max(x0, x1, x2);\n\t\t\t\tconst min = Math.min(x0, x1, x2); // 0.9 is somewhat arbitrary\n\n\t\t\t\tif (max > 0.9 && min < 0.1) {\n\t\t\t\t\tif (x0 < 0.2) uvBuffer[i + 0] += 1;\n\t\t\t\t\tif (x1 < 0.2) uvBuffer[i + 2] += 1;\n\t\t\t\t\tif (x2 < 0.2) uvBuffer[i + 4] += 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction pushVertex(vertex) {\n\t\t\tvertexBuffer.push(vertex.x, vertex.y, vertex.z);\n\t\t}\n\n\t\tfunction getVertexByIndex(index, vertex) {\n\t\t\tconst stride = index * 3;\n\t\t\tvertex.x = vertices[stride + 0];\n\t\t\tvertex.y = vertices[stride + 1];\n\t\t\tvertex.z = vertices[stride + 2];\n\t\t}\n\n\t\tfunction correctUVs() {\n\t\t\tconst a = new Vector3();\n\t\t\tconst b = new Vector3();\n\t\t\tconst c = new Vector3();\n\t\t\tconst centroid = new Vector3();\n\t\t\tconst uvA = new Vector2();\n\t\t\tconst uvB = new Vector2();\n\t\t\tconst uvC = new Vector2();\n\n\t\t\tfor (let i = 0, j = 0; i < vertexBuffer.length; i += 9, j += 6) {\n\t\t\t\ta.set(vertexBuffer[i + 0], vertexBuffer[i + 1], vertexBuffer[i + 2]);\n\t\t\t\tb.set(vertexBuffer[i + 3], vertexBuffer[i + 4], vertexBuffer[i + 5]);\n\t\t\t\tc.set(vertexBuffer[i + 6], vertexBuffer[i + 7], vertexBuffer[i + 8]);\n\t\t\t\tuvA.set(uvBuffer[j + 0], uvBuffer[j + 1]);\n\t\t\t\tuvB.set(uvBuffer[j + 2], uvBuffer[j + 3]);\n\t\t\t\tuvC.set(uvBuffer[j + 4], uvBuffer[j + 5]);\n\t\t\t\tcentroid.copy(a).add(b).add(c).divideScalar(3);\n\t\t\t\tconst azi = azimuth(centroid);\n\t\t\t\tcorrectUV(uvA, j + 0, a, azi);\n\t\t\t\tcorrectUV(uvB, j + 2, b, azi);\n\t\t\t\tcorrectUV(uvC, j + 4, c, azi);\n\t\t\t}\n\t\t}\n\n\t\tfunction correctUV(uv, stride, vector, azimuth) {\n\t\t\tif (azimuth < 0 && uv.x === 1) {\n\t\t\t\tuvBuffer[stride] = uv.x - 1;\n\t\t\t}\n\n\t\t\tif (vector.x === 0 && vector.z === 0) {\n\t\t\t\tuvBuffer[stride] = azimuth / 2 / Math.PI + 0.5;\n\t\t\t}\n\t\t} // Angle around the Y axis, counter-clockwise when looking from above.\n\n\n\t\tfunction azimuth(vector) {\n\t\t\treturn Math.atan2(vector.z, -vector.x);\n\t\t} // Angle above the XZ plane.\n\n\n\t\tfunction inclination(vector) {\n\t\t\treturn Math.atan2(-vector.y, Math.sqrt(vector.x * vector.x + vector.z * vector.z));\n\t\t}\n\t}\n\n\tstatic fromJSON(data) {\n\t\treturn new PolyhedronGeometry(data.vertices, data.indices, data.radius, data.details);\n\t}\n\n}\n\nclass DodecahedronGeometry extends PolyhedronGeometry {\n\tconstructor(radius = 1, detail = 0) {\n\t\tconst t = (1 + Math.sqrt(5)) / 2;\n\t\tconst r = 1 / t;\n\t\tconst vertices = [// (±1, ±1, ±1)\n\t\t-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, ±1/φ, ±φ)\n\t\t0, -r, -t, 0, -r, t, 0, r, -t, 0, r, t, // (±1/φ, ±φ, 0)\n\t\t-r, -t, 0, -r, t, 0, r, -t, 0, r, t, 0, // (±φ, 0, ±1/φ)\n\t\t-t, 0, -r, t, 0, -r, -t, 0, r, t, 0, r];\n\t\tconst indices = [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];\n\t\tsuper(vertices, indices, radius, detail);\n\t\tthis.type = 'DodecahedronGeometry';\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\tdetail: detail\n\t\t};\n\t}\n\n\tstatic fromJSON(data) {\n\t\treturn new DodecahedronGeometry(data.radius, data.detail);\n\t}\n\n}\n\nconst _v0 = /*@__PURE__*/new Vector3();\n\nconst _v1$1 = /*@__PURE__*/new Vector3();\n\nconst _normal = /*@__PURE__*/new Vector3();\n\nconst _triangle = /*@__PURE__*/new Triangle();\n\nclass EdgesGeometry extends BufferGeometry {\n\tconstructor(geometry = null, thresholdAngle = 1) {\n\t\tsuper();\n\t\tthis.type = 'EdgesGeometry';\n\t\tthis.parameters = {\n\t\t\tgeometry: geometry,\n\t\t\tthresholdAngle: thresholdAngle\n\t\t};\n\n\t\tif (geometry !== null) {\n\t\t\tconst precisionPoints = 4;\n\t\t\tconst precision = Math.pow(10, precisionPoints);\n\t\t\tconst thresholdDot = Math.cos(DEG2RAD * thresholdAngle);\n\t\t\tconst indexAttr = geometry.getIndex();\n\t\t\tconst positionAttr = geometry.getAttribute('position');\n\t\t\tconst indexCount = indexAttr ? indexAttr.count : positionAttr.count;\n\t\t\tconst indexArr = [0, 0, 0];\n\t\t\tconst vertKeys = ['a', 'b', 'c'];\n\t\t\tconst hashes = new Array(3);\n\t\t\tconst edgeData = {};\n\t\t\tconst vertices = [];\n\n\t\t\tfor (let i = 0; i < indexCount; i += 3) {\n\t\t\t\tif (indexAttr) {\n\t\t\t\t\tindexArr[0] = indexAttr.getX(i);\n\t\t\t\t\tindexArr[1] = indexAttr.getX(i + 1);\n\t\t\t\t\tindexArr[2] = indexAttr.getX(i + 2);\n\t\t\t\t} else {\n\t\t\t\t\tindexArr[0] = i;\n\t\t\t\t\tindexArr[1] = i + 1;\n\t\t\t\t\tindexArr[2] = i + 2;\n\t\t\t\t}\n\n\t\t\t\tconst {\n\t\t\t\t\ta,\n\t\t\t\t\tb,\n\t\t\t\t\tc\n\t\t\t\t} = _triangle;\n\t\t\t\ta.fromBufferAttribute(positionAttr, indexArr[0]);\n\t\t\t\tb.fromBufferAttribute(positionAttr, indexArr[1]);\n\t\t\t\tc.fromBufferAttribute(positionAttr, indexArr[2]);\n\n\t\t\t\t_triangle.getNormal(_normal); // create hashes for the edge from the vertices\n\n\n\t\t\t\thashes[0] = `${Math.round(a.x * precision)},${Math.round(a.y * precision)},${Math.round(a.z * precision)}`;\n\t\t\t\thashes[1] = `${Math.round(b.x * precision)},${Math.round(b.y * precision)},${Math.round(b.z * precision)}`;\n\t\t\t\thashes[2] = `${Math.round(c.x * precision)},${Math.round(c.y * precision)},${Math.round(c.z * precision)}`; // skip degenerate triangles\n\n\t\t\t\tif (hashes[0] === hashes[1] || hashes[1] === hashes[2] || hashes[2] === hashes[0]) {\n\t\t\t\t\tcontinue;\n\t\t\t\t} // iterate over every edge\n\n\n\t\t\t\tfor (let j = 0; j < 3; j++) {\n\t\t\t\t\t// get the first and next vertex making up the edge\n\t\t\t\t\tconst jNext = (j + 1) % 3;\n\t\t\t\t\tconst vecHash0 = hashes[j];\n\t\t\t\t\tconst vecHash1 = hashes[jNext];\n\t\t\t\t\tconst v0 = _triangle[vertKeys[j]];\n\t\t\t\t\tconst v1 = _triangle[vertKeys[jNext]];\n\t\t\t\t\tconst hash = `${vecHash0}_${vecHash1}`;\n\t\t\t\t\tconst reverseHash = `${vecHash1}_${vecHash0}`;\n\n\t\t\t\t\tif (reverseHash in edgeData && edgeData[reverseHash]) {\n\t\t\t\t\t\t// if we found a sibling edge add it into the vertex array if\n\t\t\t\t\t\t// it meets the angle threshold and delete the edge from the map.\n\t\t\t\t\t\tif (_normal.dot(edgeData[reverseHash].normal) <= thresholdDot) {\n\t\t\t\t\t\t\tvertices.push(v0.x, v0.y, v0.z);\n\t\t\t\t\t\t\tvertices.push(v1.x, v1.y, v1.z);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tedgeData[reverseHash] = null;\n\t\t\t\t\t} else if (!(hash in edgeData)) {\n\t\t\t\t\t\t// if we've already got an edge here then skip adding a new one\n\t\t\t\t\t\tedgeData[hash] = {\n\t\t\t\t\t\t\tindex0: indexArr[j],\n\t\t\t\t\t\t\tindex1: indexArr[jNext],\n\t\t\t\t\t\t\tnormal: _normal.clone()\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} // iterate over all remaining, unmatched edges and add them to the vertex array\n\n\n\t\t\tfor (const key in edgeData) {\n\t\t\t\tif (edgeData[key]) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tindex0,\n\t\t\t\t\t\tindex1\n\t\t\t\t\t} = edgeData[key];\n\n\t\t\t\t\t_v0.fromBufferAttribute(positionAttr, index0);\n\n\t\t\t\t\t_v1$1.fromBufferAttribute(positionAttr, index1);\n\n\t\t\t\t\tvertices.push(_v0.x, _v0.y, _v0.z);\n\t\t\t\t\tvertices.push(_v1$1.x, _v1$1.y, _v1$1.z);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\t}\n\t}\n\n}\n\nclass Shape extends Path {\n\tconstructor(points) {\n\t\tsuper(points);\n\t\tthis.uuid = generateUUID();\n\t\tthis.type = 'Shape';\n\t\tthis.holes = [];\n\t}\n\n\tgetPointsHoles(divisions) {\n\t\tconst holesPts = [];\n\n\t\tfor (let i = 0, l = this.holes.length; i < l; i++) {\n\t\t\tholesPts[i] = this.holes[i].getPoints(divisions);\n\t\t}\n\n\t\treturn holesPts;\n\t} // get points of shape and holes (keypoints based on segments parameter)\n\n\n\textractPoints(divisions) {\n\t\treturn {\n\t\t\tshape: this.getPoints(divisions),\n\t\t\tholes: this.getPointsHoles(divisions)\n\t\t};\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.holes = [];\n\n\t\tfor (let i = 0, l = source.holes.length; i < l; i++) {\n\t\t\tconst hole = source.holes[i];\n\t\t\tthis.holes.push(hole.clone());\n\t\t}\n\n\t\treturn this;\n\t}\n\n\ttoJSON() {\n\t\tconst data = super.toJSON();\n\t\tdata.uuid = this.uuid;\n\t\tdata.holes = [];\n\n\t\tfor (let i = 0, l = this.holes.length; i < l; i++) {\n\t\t\tconst hole = this.holes[i];\n\t\t\tdata.holes.push(hole.toJSON());\n\t\t}\n\n\t\treturn data;\n\t}\n\n\tfromJSON(json) {\n\t\tsuper.fromJSON(json);\n\t\tthis.uuid = json.uuid;\n\t\tthis.holes = [];\n\n\t\tfor (let i = 0, l = json.holes.length; i < l; i++) {\n\t\t\tconst hole = json.holes[i];\n\t\t\tthis.holes.push(new Path().fromJSON(hole));\n\t\t}\n\n\t\treturn this;\n\t}\n\n}\n\n/**\n * Port from https://github.com/mapbox/earcut (v2.2.2)\n */\nconst Earcut = {\n\ttriangulate: function (data, holeIndices, dim = 2) {\n\t\tconst hasHoles = holeIndices && holeIndices.length;\n\t\tconst outerLen = hasHoles ? holeIndices[0] * dim : data.length;\n\t\tlet outerNode = linkedList(data, 0, outerLen, dim, true);\n\t\tconst triangles = [];\n\t\tif (!outerNode || outerNode.next === outerNode.prev) return triangles;\n\t\tlet minX, minY, maxX, maxY, x, y, invSize;\n\t\tif (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim); // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox\n\n\t\tif (data.length > 80 * dim) {\n\t\t\tminX = maxX = data[0];\n\t\t\tminY = maxY = data[1];\n\n\t\t\tfor (let i = dim; i < outerLen; i += dim) {\n\t\t\t\tx = data[i];\n\t\t\t\ty = data[i + 1];\n\t\t\t\tif (x < minX) minX = x;\n\t\t\t\tif (y < minY) minY = y;\n\t\t\t\tif (x > maxX) maxX = x;\n\t\t\t\tif (y > maxY) maxY = y;\n\t\t\t} // minX, minY and invSize are later used to transform coords into integers for z-order calculation\n\n\n\t\t\tinvSize = Math.max(maxX - minX, maxY - minY);\n\t\t\tinvSize = invSize !== 0 ? 1 / invSize : 0;\n\t\t}\n\n\t\tearcutLinked(outerNode, triangles, dim, minX, minY, invSize);\n\t\treturn triangles;\n\t}\n}; // create a circular doubly linked list from polygon points in the specified winding order\n\nfunction linkedList(data, start, end, dim, clockwise) {\n\tlet i, last;\n\n\tif (clockwise === signedArea(data, start, end, dim) > 0) {\n\t\tfor (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last);\n\t} else {\n\t\tfor (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last);\n\t}\n\n\tif (last && equals(last, last.next)) {\n\t\tremoveNode(last);\n\t\tlast = last.next;\n\t}\n\n\treturn last;\n} // eliminate colinear or duplicate points\n\n\nfunction filterPoints(start, end) {\n\tif (!start) return start;\n\tif (!end) end = start;\n\tlet p = start,\n\t\t\tagain;\n\n\tdo {\n\t\tagain = false;\n\n\t\tif (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {\n\t\t\tremoveNode(p);\n\t\t\tp = end = p.prev;\n\t\t\tif (p === p.next) break;\n\t\t\tagain = true;\n\t\t} else {\n\t\t\tp = p.next;\n\t\t}\n\t} while (again || p !== end);\n\n\treturn end;\n} // main ear slicing loop which triangulates a polygon (given as a linked list)\n\n\nfunction earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {\n\tif (!ear) return; // interlink polygon nodes in z-order\n\n\tif (!pass && invSize) indexCurve(ear, minX, minY, invSize);\n\tlet stop = ear,\n\t\t\tprev,\n\t\t\tnext; // iterate through ears, slicing them one by one\n\n\twhile (ear.prev !== ear.next) {\n\t\tprev = ear.prev;\n\t\tnext = ear.next;\n\n\t\tif (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {\n\t\t\t// cut off the triangle\n\t\t\ttriangles.push(prev.i / dim);\n\t\t\ttriangles.push(ear.i / dim);\n\t\t\ttriangles.push(next.i / dim);\n\t\t\tremoveNode(ear); // skipping the next vertex leads to less sliver triangles\n\n\t\t\tear = next.next;\n\t\t\tstop = next.next;\n\t\t\tcontinue;\n\t\t}\n\n\t\tear = next; // if we looped through the whole remaining polygon and can't find any more ears\n\n\t\tif (ear === stop) {\n\t\t\t// try filtering points and slicing again\n\t\t\tif (!pass) {\n\t\t\t\tearcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1); // if this didn't work, try curing all small self-intersections locally\n\t\t\t} else if (pass === 1) {\n\t\t\t\tear = cureLocalIntersections(filterPoints(ear), triangles, dim);\n\t\t\t\tearcutLinked(ear, triangles, dim, minX, minY, invSize, 2); // as a last resort, try splitting the remaining polygon into two\n\t\t\t} else if (pass === 2) {\n\t\t\t\tsplitEarcut(ear, triangles, dim, minX, minY, invSize);\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\t}\n} // check whether a polygon node forms a valid ear with adjacent nodes\n\n\nfunction isEar(ear) {\n\tconst a = ear.prev,\n\t\t\t\tb = ear,\n\t\t\t\tc = ear.next;\n\tif (area(a, b, c) >= 0) return false; // reflex, can't be an ear\n\t// now make sure we don't have other points inside the potential ear\n\n\tlet p = ear.next.next;\n\n\twhile (p !== ear.prev) {\n\t\tif (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n\t\tp = p.next;\n\t}\n\n\treturn true;\n}\n\nfunction isEarHashed(ear, minX, minY, invSize) {\n\tconst a = ear.prev,\n\t\t\t\tb = ear,\n\t\t\t\tc = ear.next;\n\tif (area(a, b, c) >= 0) return false; // reflex, can't be an ear\n\t// triangle bbox; min & max are calculated like this for speed\n\n\tconst minTX = a.x < b.x ? a.x < c.x ? a.x : c.x : b.x < c.x ? b.x : c.x,\n\t\t\t\tminTY = a.y < b.y ? a.y < c.y ? a.y : c.y : b.y < c.y ? b.y : c.y,\n\t\t\t\tmaxTX = a.x > b.x ? a.x > c.x ? a.x : c.x : b.x > c.x ? b.x : c.x,\n\t\t\t\tmaxTY = a.y > b.y ? a.y > c.y ? a.y : c.y : b.y > c.y ? b.y : c.y; // z-order range for the current triangle bbox;\n\n\tconst minZ = zOrder(minTX, minTY, minX, minY, invSize),\n\t\t\t\tmaxZ = zOrder(maxTX, maxTY, minX, minY, invSize);\n\tlet p = ear.prevZ,\n\t\t\tn = ear.nextZ; // look for points inside the triangle in both directions\n\n\twhile (p && p.z >= minZ && n && n.z <= maxZ) {\n\t\tif (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n\t\tp = p.prevZ;\n\t\tif (n !== ear.prev && n !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;\n\t\tn = n.nextZ;\n\t} // look for remaining points in decreasing z-order\n\n\n\twhile (p && p.z >= minZ) {\n\t\tif (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n\t\tp = p.prevZ;\n\t} // look for remaining points in increasing z-order\n\n\n\twhile (n && n.z <= maxZ) {\n\t\tif (n !== ear.prev && n !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;\n\t\tn = n.nextZ;\n\t}\n\n\treturn true;\n} // go through all polygon nodes and cure small local self-intersections\n\n\nfunction cureLocalIntersections(start, triangles, dim) {\n\tlet p = start;\n\n\tdo {\n\t\tconst a = p.prev,\n\t\t\t\t\tb = p.next.next;\n\n\t\tif (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {\n\t\t\ttriangles.push(a.i / dim);\n\t\t\ttriangles.push(p.i / dim);\n\t\t\ttriangles.push(b.i / dim); // remove two nodes involved\n\n\t\t\tremoveNode(p);\n\t\t\tremoveNode(p.next);\n\t\t\tp = start = b;\n\t\t}\n\n\t\tp = p.next;\n\t} while (p !== start);\n\n\treturn filterPoints(p);\n} // try splitting polygon into two and triangulate them independently\n\n\nfunction splitEarcut(start, triangles, dim, minX, minY, invSize) {\n\t// look for a valid diagonal that divides the polygon into two\n\tlet a = start;\n\n\tdo {\n\t\tlet b = a.next.next;\n\n\t\twhile (b !== a.prev) {\n\t\t\tif (a.i !== b.i && isValidDiagonal(a, b)) {\n\t\t\t\t// split the polygon in two by the diagonal\n\t\t\t\tlet c = splitPolygon(a, b); // filter colinear points around the cuts\n\n\t\t\t\ta = filterPoints(a, a.next);\n\t\t\t\tc = filterPoints(c, c.next); // run earcut on each half\n\n\t\t\t\tearcutLinked(a, triangles, dim, minX, minY, invSize);\n\t\t\t\tearcutLinked(c, triangles, dim, minX, minY, invSize);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tb = b.next;\n\t\t}\n\n\t\ta = a.next;\n\t} while (a !== start);\n} // link every hole into the outer loop, producing a single-ring polygon without holes\n\n\nfunction eliminateHoles(data, holeIndices, outerNode, dim) {\n\tconst queue = [];\n\tlet i, len, start, end, list;\n\n\tfor (i = 0, len = holeIndices.length; i < len; i++) {\n\t\tstart = holeIndices[i] * dim;\n\t\tend = i < len - 1 ? holeIndices[i + 1] * dim : data.length;\n\t\tlist = linkedList(data, start, end, dim, false);\n\t\tif (list === list.next) list.steiner = true;\n\t\tqueue.push(getLeftmost(list));\n\t}\n\n\tqueue.sort(compareX); // process holes from left to right\n\n\tfor (i = 0; i < queue.length; i++) {\n\t\teliminateHole(queue[i], outerNode);\n\t\touterNode = filterPoints(outerNode, outerNode.next);\n\t}\n\n\treturn outerNode;\n}\n\nfunction compareX(a, b) {\n\treturn a.x - b.x;\n} // find a bridge between vertices that connects hole with an outer ring and link it\n\n\nfunction eliminateHole(hole, outerNode) {\n\touterNode = findHoleBridge(hole, outerNode);\n\n\tif (outerNode) {\n\t\tconst b = splitPolygon(outerNode, hole); // filter collinear points around the cuts\n\n\t\tfilterPoints(outerNode, outerNode.next);\n\t\tfilterPoints(b, b.next);\n\t}\n} // David Eberly's algorithm for finding a bridge between hole and outer polygon\n\n\nfunction findHoleBridge(hole, outerNode) {\n\tlet p = outerNode;\n\tconst hx = hole.x;\n\tconst hy = hole.y;\n\tlet qx = -Infinity,\n\t\t\tm; // find a segment intersected by a ray from the hole's leftmost point to the left;\n\t// segment's endpoint with lesser x will be potential connection point\n\n\tdo {\n\t\tif (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {\n\t\t\tconst x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);\n\n\t\t\tif (x <= hx && x > qx) {\n\t\t\t\tqx = x;\n\n\t\t\t\tif (x === hx) {\n\t\t\t\t\tif (hy === p.y) return p;\n\t\t\t\t\tif (hy === p.next.y) return p.next;\n\t\t\t\t}\n\n\t\t\t\tm = p.x < p.next.x ? p : p.next;\n\t\t\t}\n\t\t}\n\n\t\tp = p.next;\n\t} while (p !== outerNode);\n\n\tif (!m) return null;\n\tif (hx === qx) return m; // hole touches outer segment; pick leftmost endpoint\n\t// look for points inside the triangle of hole point, segment intersection and endpoint;\n\t// if there are no points found, we have a valid connection;\n\t// otherwise choose the point of the minimum angle with the ray as connection point\n\n\tconst stop = m,\n\t\t\t\tmx = m.x,\n\t\t\t\tmy = m.y;\n\tlet tanMin = Infinity,\n\t\t\ttan;\n\tp = m;\n\n\tdo {\n\t\tif (hx >= p.x && p.x >= mx && hx !== p.x && pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {\n\t\t\ttan = Math.abs(hy - p.y) / (hx - p.x); // tangential\n\n\t\t\tif (locallyInside(p, hole) && (tan < tanMin || tan === tanMin && (p.x > m.x || p.x === m.x && sectorContainsSector(m, p)))) {\n\t\t\t\tm = p;\n\t\t\t\ttanMin = tan;\n\t\t\t}\n\t\t}\n\n\t\tp = p.next;\n\t} while (p !== stop);\n\n\treturn m;\n} // whether sector in vertex m contains sector in vertex p in the same coordinates\n\n\nfunction sectorContainsSector(m, p) {\n\treturn area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;\n} // interlink polygon nodes in z-order\n\n\nfunction indexCurve(start, minX, minY, invSize) {\n\tlet p = start;\n\n\tdo {\n\t\tif (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, invSize);\n\t\tp.prevZ = p.prev;\n\t\tp.nextZ = p.next;\n\t\tp = p.next;\n\t} while (p !== start);\n\n\tp.prevZ.nextZ = null;\n\tp.prevZ = null;\n\tsortLinked(p);\n} // Simon Tatham's linked list merge sort algorithm\n// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html\n\n\nfunction sortLinked(list) {\n\tlet i,\n\t\t\tp,\n\t\t\tq,\n\t\t\te,\n\t\t\ttail,\n\t\t\tnumMerges,\n\t\t\tpSize,\n\t\t\tqSize,\n\t\t\tinSize = 1;\n\n\tdo {\n\t\tp = list;\n\t\tlist = null;\n\t\ttail = null;\n\t\tnumMerges = 0;\n\n\t\twhile (p) {\n\t\t\tnumMerges++;\n\t\t\tq = p;\n\t\t\tpSize = 0;\n\n\t\t\tfor (i = 0; i < inSize; i++) {\n\t\t\t\tpSize++;\n\t\t\t\tq = q.nextZ;\n\t\t\t\tif (!q) break;\n\t\t\t}\n\n\t\t\tqSize = inSize;\n\n\t\t\twhile (pSize > 0 || qSize > 0 && q) {\n\t\t\t\tif (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {\n\t\t\t\t\te = p;\n\t\t\t\t\tp = p.nextZ;\n\t\t\t\t\tpSize--;\n\t\t\t\t} else {\n\t\t\t\t\te = q;\n\t\t\t\t\tq = q.nextZ;\n\t\t\t\t\tqSize--;\n\t\t\t\t}\n\n\t\t\t\tif (tail) tail.nextZ = e;else list = e;\n\t\t\t\te.prevZ = tail;\n\t\t\t\ttail = e;\n\t\t\t}\n\n\t\t\tp = q;\n\t\t}\n\n\t\ttail.nextZ = null;\n\t\tinSize *= 2;\n\t} while (numMerges > 1);\n\n\treturn list;\n} // z-order of a point given coords and inverse of the longer side of data bbox\n\n\nfunction zOrder(x, y, minX, minY, invSize) {\n\t// coords are transformed into non-negative 15-bit integer range\n\tx = 32767 * (x - minX) * invSize;\n\ty = 32767 * (y - minY) * invSize;\n\tx = (x | x << 8) & 0x00FF00FF;\n\tx = (x | x << 4) & 0x0F0F0F0F;\n\tx = (x | x << 2) & 0x33333333;\n\tx = (x | x << 1) & 0x55555555;\n\ty = (y | y << 8) & 0x00FF00FF;\n\ty = (y | y << 4) & 0x0F0F0F0F;\n\ty = (y | y << 2) & 0x33333333;\n\ty = (y | y << 1) & 0x55555555;\n\treturn x | y << 1;\n} // find the leftmost node of a polygon ring\n\n\nfunction getLeftmost(start) {\n\tlet p = start,\n\t\t\tleftmost = start;\n\n\tdo {\n\t\tif (p.x < leftmost.x || p.x === leftmost.x && p.y < leftmost.y) leftmost = p;\n\t\tp = p.next;\n\t} while (p !== start);\n\n\treturn leftmost;\n} // check if a point lies within a convex triangle\n\n\nfunction pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {\n\treturn (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;\n} // check if a diagonal between two polygon nodes is valid (lies in polygon interior)\n\n\nfunction isValidDiagonal(a, b) {\n\treturn a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && ( // doesn't intersect other edges\n\tlocallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && ( // locally visible\n\tarea(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors\n\tequals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case\n} // signed area of a triangle\n\n\nfunction area(p, q, r) {\n\treturn (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);\n} // check if two points are equal\n\n\nfunction equals(p1, p2) {\n\treturn p1.x === p2.x && p1.y === p2.y;\n} // check if two segments intersect\n\n\nfunction intersects(p1, q1, p2, q2) {\n\tconst o1 = sign(area(p1, q1, p2));\n\tconst o2 = sign(area(p1, q1, q2));\n\tconst o3 = sign(area(p2, q2, p1));\n\tconst o4 = sign(area(p2, q2, q1));\n\tif (o1 !== o2 && o3 !== o4) return true; // general case\n\n\tif (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1\n\n\tif (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1\n\n\tif (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2\n\n\tif (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2\n\n\treturn false;\n} // for collinear points p, q, r, check if point q lies on segment pr\n\n\nfunction onSegment(p, q, r) {\n\treturn q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);\n}\n\nfunction sign(num) {\n\treturn num > 0 ? 1 : num < 0 ? -1 : 0;\n} // check if a polygon diagonal intersects any polygon segments\n\n\nfunction intersectsPolygon(a, b) {\n\tlet p = a;\n\n\tdo {\n\t\tif (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && intersects(p, p.next, a, b)) return true;\n\t\tp = p.next;\n\t} while (p !== a);\n\n\treturn false;\n} // check if a polygon diagonal is locally inside the polygon\n\n\nfunction locallyInside(a, b) {\n\treturn area(a.prev, a, a.next) < 0 ? area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;\n} // check if the middle point of a polygon diagonal is inside the polygon\n\n\nfunction middleInside(a, b) {\n\tlet p = a,\n\t\t\tinside = false;\n\tconst px = (a.x + b.x) / 2,\n\t\t\t\tpy = (a.y + b.y) / 2;\n\n\tdo {\n\t\tif (p.y > py !== p.next.y > py && p.next.y !== p.y && px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x) inside = !inside;\n\t\tp = p.next;\n\t} while (p !== a);\n\n\treturn inside;\n} // link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;\n// if one belongs to the outer ring and another to a hole, it merges it into a single ring\n\n\nfunction splitPolygon(a, b) {\n\tconst a2 = new Node(a.i, a.x, a.y),\n\t\t\t\tb2 = new Node(b.i, b.x, b.y),\n\t\t\t\tan = a.next,\n\t\t\t\tbp = b.prev;\n\ta.next = b;\n\tb.prev = a;\n\ta2.next = an;\n\tan.prev = a2;\n\tb2.next = a2;\n\ta2.prev = b2;\n\tbp.next = b2;\n\tb2.prev = bp;\n\treturn b2;\n} // create a node and optionally link it with previous one (in a circular doubly linked list)\n\n\nfunction insertNode(i, x, y, last) {\n\tconst p = new Node(i, x, y);\n\n\tif (!last) {\n\t\tp.prev = p;\n\t\tp.next = p;\n\t} else {\n\t\tp.next = last.next;\n\t\tp.prev = last;\n\t\tlast.next.prev = p;\n\t\tlast.next = p;\n\t}\n\n\treturn p;\n}\n\nfunction removeNode(p) {\n\tp.next.prev = p.prev;\n\tp.prev.next = p.next;\n\tif (p.prevZ) p.prevZ.nextZ = p.nextZ;\n\tif (p.nextZ) p.nextZ.prevZ = p.prevZ;\n}\n\nfunction Node(i, x, y) {\n\t// vertex index in coordinates array\n\tthis.i = i; // vertex coordinates\n\n\tthis.x = x;\n\tthis.y = y; // previous and next vertex nodes in a polygon ring\n\n\tthis.prev = null;\n\tthis.next = null; // z-order curve value\n\n\tthis.z = null; // previous and next nodes in z-order\n\n\tthis.prevZ = null;\n\tthis.nextZ = null; // indicates whether this is a steiner point\n\n\tthis.steiner = false;\n}\n\nfunction signedArea(data, start, end, dim) {\n\tlet sum = 0;\n\n\tfor (let i = start, j = end - dim; i < end; i += dim) {\n\t\tsum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);\n\t\tj = i;\n\t}\n\n\treturn sum;\n}\n\nclass ShapeUtils {\n\t// calculate area of the contour polygon\n\tstatic area(contour) {\n\t\tconst n = contour.length;\n\t\tlet a = 0.0;\n\n\t\tfor (let p = n - 1, q = 0; q < n; p = q++) {\n\t\t\ta += contour[p].x * contour[q].y - contour[q].x * contour[p].y;\n\t\t}\n\n\t\treturn a * 0.5;\n\t}\n\n\tstatic isClockWise(pts) {\n\t\treturn ShapeUtils.area(pts) < 0;\n\t}\n\n\tstatic triangulateShape(contour, holes) {\n\t\tconst vertices = []; // flat array of vertices like [ x0,y0, x1,y1, x2,y2, ... ]\n\n\t\tconst holeIndices = []; // array of hole indices\n\n\t\tconst faces = []; // final array of vertex indices like [ [ a,b,d ], [ b,c,d ] ]\n\n\t\tremoveDupEndPts(contour);\n\t\taddContour(vertices, contour); //\n\n\t\tlet holeIndex = contour.length;\n\t\tholes.forEach(removeDupEndPts);\n\n\t\tfor (let i = 0; i < holes.length; i++) {\n\t\t\tholeIndices.push(holeIndex);\n\t\t\tholeIndex += holes[i].length;\n\t\t\taddContour(vertices, holes[i]);\n\t\t} //\n\n\n\t\tconst triangles = Earcut.triangulate(vertices, holeIndices); //\n\n\t\tfor (let i = 0; i < triangles.length; i += 3) {\n\t\t\tfaces.push(triangles.slice(i, i + 3));\n\t\t}\n\n\t\treturn faces;\n\t}\n\n}\n\nfunction removeDupEndPts(points) {\n\tconst l = points.length;\n\n\tif (l > 2 && points[l - 1].equals(points[0])) {\n\t\tpoints.pop();\n\t}\n}\n\nfunction addContour(vertices, contour) {\n\tfor (let i = 0; i < contour.length; i++) {\n\t\tvertices.push(contour[i].x);\n\t\tvertices.push(contour[i].y);\n\t}\n}\n\n/**\n * Creates extruded geometry from a path shape.\n *\n * parameters = {\n *\n *\tcurveSegments: , // number of points on the curves\n *\tsteps: , // number of points for z-side extrusions / used for subdividing segments of extrude spline too\n *\tdepth: , // Depth to extrude the shape\n *\n *\tbevelEnabled: , // turn on bevel\n *\tbevelThickness: , // how deep into the original shape bevel goes\n *\tbevelSize: , // how far from shape outline (including bevelOffset) is bevel\n *\tbevelOffset: , // how far from shape outline does bevel start\n *\tbevelSegments: , // number of bevel layers\n *\n *\textrudePath: // curve to extrude shape along\n *\n *\tUVGenerator: // object that provides UV generator functions\n *\n * }\n */\n\nclass ExtrudeGeometry extends BufferGeometry {\n\tconstructor(shapes = new Shape([new Vector2(0.5, 0.5), new Vector2(-0.5, 0.5), new Vector2(-0.5, -0.5), new Vector2(0.5, -0.5)]), options = {}) {\n\t\tsuper();\n\t\tthis.type = 'ExtrudeGeometry';\n\t\tthis.parameters = {\n\t\t\tshapes: shapes,\n\t\t\toptions: options\n\t\t};\n\t\tshapes = Array.isArray(shapes) ? shapes : [shapes];\n\t\tconst scope = this;\n\t\tconst verticesArray = [];\n\t\tconst uvArray = [];\n\n\t\tfor (let i = 0, l = shapes.length; i < l; i++) {\n\t\t\tconst shape = shapes[i];\n\t\t\taddShape(shape);\n\t\t} // build geometry\n\n\n\t\tthis.setAttribute('position', new Float32BufferAttribute(verticesArray, 3));\n\t\tthis.setAttribute('uv', new Float32BufferAttribute(uvArray, 2));\n\t\tthis.computeVertexNormals(); // functions\n\n\t\tfunction addShape(shape) {\n\t\t\tconst placeholder = []; // options\n\n\t\t\tconst curveSegments = options.curveSegments !== undefined ? options.curveSegments : 12;\n\t\t\tconst steps = options.steps !== undefined ? options.steps : 1;\n\t\t\tconst depth = options.depth !== undefined ? options.depth : 1;\n\t\t\tlet bevelEnabled = options.bevelEnabled !== undefined ? options.bevelEnabled : true;\n\t\t\tlet bevelThickness = options.bevelThickness !== undefined ? options.bevelThickness : 0.2;\n\t\t\tlet bevelSize = options.bevelSize !== undefined ? options.bevelSize : bevelThickness - 0.1;\n\t\t\tlet bevelOffset = options.bevelOffset !== undefined ? options.bevelOffset : 0;\n\t\t\tlet bevelSegments = options.bevelSegments !== undefined ? options.bevelSegments : 3;\n\t\t\tconst extrudePath = options.extrudePath;\n\t\t\tconst uvgen = options.UVGenerator !== undefined ? options.UVGenerator : WorldUVGenerator; //\n\n\t\t\tlet extrudePts,\n\t\t\t\t\textrudeByPath = false;\n\t\t\tlet splineTube, binormal, normal, position2;\n\n\t\t\tif (extrudePath) {\n\t\t\t\textrudePts = extrudePath.getSpacedPoints(steps);\n\t\t\t\textrudeByPath = true;\n\t\t\t\tbevelEnabled = false; // bevels not supported for path extrusion\n\t\t\t\t// SETUP TNB variables\n\t\t\t\t// TODO1 - have a .isClosed in spline?\n\n\t\t\t\tsplineTube = extrudePath.computeFrenetFrames(steps, false); // console.log(splineTube, 'splineTube', splineTube.normals.length, 'steps', steps, 'extrudePts', extrudePts.length);\n\n\t\t\t\tbinormal = new Vector3();\n\t\t\t\tnormal = new Vector3();\n\t\t\t\tposition2 = new Vector3();\n\t\t\t} // Safeguards if bevels are not enabled\n\n\n\t\t\tif (!bevelEnabled) {\n\t\t\t\tbevelSegments = 0;\n\t\t\t\tbevelThickness = 0;\n\t\t\t\tbevelSize = 0;\n\t\t\t\tbevelOffset = 0;\n\t\t\t} // Variables initialization\n\n\n\t\t\tconst shapePoints = shape.extractPoints(curveSegments);\n\t\t\tlet vertices = shapePoints.shape;\n\t\t\tconst holes = shapePoints.holes;\n\t\t\tconst reverse = !ShapeUtils.isClockWise(vertices);\n\n\t\t\tif (reverse) {\n\t\t\t\tvertices = vertices.reverse(); // Maybe we should also check if holes are in the opposite direction, just to be safe ...\n\n\t\t\t\tfor (let h = 0, hl = holes.length; h < hl; h++) {\n\t\t\t\t\tconst ahole = holes[h];\n\n\t\t\t\t\tif (ShapeUtils.isClockWise(ahole)) {\n\t\t\t\t\t\tholes[h] = ahole.reverse();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst faces = ShapeUtils.triangulateShape(vertices, holes);\n\t\t\t/* Vertices */\n\n\t\t\tconst contour = vertices; // vertices has all points but contour has only points of circumference\n\n\t\t\tfor (let h = 0, hl = holes.length; h < hl; h++) {\n\t\t\t\tconst ahole = holes[h];\n\t\t\t\tvertices = vertices.concat(ahole);\n\t\t\t}\n\n\t\t\tfunction scalePt2(pt, vec, size) {\n\t\t\t\tif (!vec) console.error('THREE.ExtrudeGeometry: vec does not exist');\n\t\t\t\treturn vec.clone().multiplyScalar(size).add(pt);\n\t\t\t}\n\n\t\t\tconst vlen = vertices.length,\n\t\t\t\t\t\tflen = faces.length; // Find directions for point movement\n\n\t\t\tfunction getBevelVec(inPt, inPrev, inNext) {\n\t\t\t\t// computes for inPt the corresponding point inPt' on a new contour\n\t\t\t\t//\t shifted by 1 unit (length of normalized vector) to the left\n\t\t\t\t// if we walk along contour clockwise, this new contour is outside the old one\n\t\t\t\t//\n\t\t\t\t// inPt' is the intersection of the two lines parallel to the two\n\t\t\t\t//\tadjacent edges of inPt at a distance of 1 unit on the left side.\n\t\t\t\tlet v_trans_x, v_trans_y, shrink_by; // resulting translation vector for inPt\n\t\t\t\t// good reading for geometry algorithms (here: line-line intersection)\n\t\t\t\t// http://geomalgorithms.com/a05-_intersect-1.html\n\n\t\t\t\tconst v_prev_x = inPt.x - inPrev.x,\n\t\t\t\t\t\t\tv_prev_y = inPt.y - inPrev.y;\n\t\t\t\tconst v_next_x = inNext.x - inPt.x,\n\t\t\t\t\t\t\tv_next_y = inNext.y - inPt.y;\n\t\t\t\tconst v_prev_lensq = v_prev_x * v_prev_x + v_prev_y * v_prev_y; // check for collinear edges\n\n\t\t\t\tconst collinear0 = v_prev_x * v_next_y - v_prev_y * v_next_x;\n\n\t\t\t\tif (Math.abs(collinear0) > Number.EPSILON) {\n\t\t\t\t\t// not collinear\n\t\t\t\t\t// length of vectors for normalizing\n\t\t\t\t\tconst v_prev_len = Math.sqrt(v_prev_lensq);\n\t\t\t\t\tconst v_next_len = Math.sqrt(v_next_x * v_next_x + v_next_y * v_next_y); // shift adjacent points by unit vectors to the left\n\n\t\t\t\t\tconst ptPrevShift_x = inPrev.x - v_prev_y / v_prev_len;\n\t\t\t\t\tconst ptPrevShift_y = inPrev.y + v_prev_x / v_prev_len;\n\t\t\t\t\tconst ptNextShift_x = inNext.x - v_next_y / v_next_len;\n\t\t\t\t\tconst ptNextShift_y = inNext.y + v_next_x / v_next_len; // scaling factor for v_prev to intersection point\n\n\t\t\t\t\tconst sf = ((ptNextShift_x - ptPrevShift_x) * v_next_y - (ptNextShift_y - ptPrevShift_y) * v_next_x) / (v_prev_x * v_next_y - v_prev_y * v_next_x); // vector from inPt to intersection point\n\n\t\t\t\t\tv_trans_x = ptPrevShift_x + v_prev_x * sf - inPt.x;\n\t\t\t\t\tv_trans_y = ptPrevShift_y + v_prev_y * sf - inPt.y; // Don't normalize!, otherwise sharp corners become ugly\n\t\t\t\t\t//\tbut prevent crazy spikes\n\n\t\t\t\t\tconst v_trans_lensq = v_trans_x * v_trans_x + v_trans_y * v_trans_y;\n\n\t\t\t\t\tif (v_trans_lensq <= 2) {\n\t\t\t\t\t\treturn new Vector2(v_trans_x, v_trans_y);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tshrink_by = Math.sqrt(v_trans_lensq / 2);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// handle special case of collinear edges\n\t\t\t\t\tlet direction_eq = false; // assumes: opposite\n\n\t\t\t\t\tif (v_prev_x > Number.EPSILON) {\n\t\t\t\t\t\tif (v_next_x > Number.EPSILON) {\n\t\t\t\t\t\t\tdirection_eq = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (v_prev_x < -Number.EPSILON) {\n\t\t\t\t\t\t\tif (v_next_x < -Number.EPSILON) {\n\t\t\t\t\t\t\t\tdirection_eq = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (Math.sign(v_prev_y) === Math.sign(v_next_y)) {\n\t\t\t\t\t\t\t\tdirection_eq = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (direction_eq) {\n\t\t\t\t\t\t// console.log(\"Warning: lines are a straight sequence\");\n\t\t\t\t\t\tv_trans_x = -v_prev_y;\n\t\t\t\t\t\tv_trans_y = v_prev_x;\n\t\t\t\t\t\tshrink_by = Math.sqrt(v_prev_lensq);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// console.log(\"Warning: lines are a straight spike\");\n\t\t\t\t\t\tv_trans_x = v_prev_x;\n\t\t\t\t\t\tv_trans_y = v_prev_y;\n\t\t\t\t\t\tshrink_by = Math.sqrt(v_prev_lensq / 2);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new Vector2(v_trans_x / shrink_by, v_trans_y / shrink_by);\n\t\t\t}\n\n\t\t\tconst contourMovements = [];\n\n\t\t\tfor (let i = 0, il = contour.length, j = il - 1, k = i + 1; i < il; i++, j++, k++) {\n\t\t\t\tif (j === il) j = 0;\n\t\t\t\tif (k === il) k = 0; //\t(j)---(i)---(k)\n\t\t\t\t// console.log('i,j,k', i, j , k)\n\n\t\t\t\tcontourMovements[i] = getBevelVec(contour[i], contour[j], contour[k]);\n\t\t\t}\n\n\t\t\tconst holesMovements = [];\n\t\t\tlet oneHoleMovements,\n\t\t\t\t\tverticesMovements = contourMovements.concat();\n\n\t\t\tfor (let h = 0, hl = holes.length; h < hl; h++) {\n\t\t\t\tconst ahole = holes[h];\n\t\t\t\toneHoleMovements = [];\n\n\t\t\t\tfor (let i = 0, il = ahole.length, j = il - 1, k = i + 1; i < il; i++, j++, k++) {\n\t\t\t\t\tif (j === il) j = 0;\n\t\t\t\t\tif (k === il) k = 0; //\t(j)---(i)---(k)\n\n\t\t\t\t\toneHoleMovements[i] = getBevelVec(ahole[i], ahole[j], ahole[k]);\n\t\t\t\t}\n\n\t\t\t\tholesMovements.push(oneHoleMovements);\n\t\t\t\tverticesMovements = verticesMovements.concat(oneHoleMovements);\n\t\t\t} // Loop bevelSegments, 1 for the front, 1 for the back\n\n\n\t\t\tfor (let b = 0; b < bevelSegments; b++) {\n\t\t\t\t//for ( b = bevelSegments; b > 0; b -- ) {\n\t\t\t\tconst t = b / bevelSegments;\n\t\t\t\tconst z = bevelThickness * Math.cos(t * Math.PI / 2);\n\t\t\t\tconst bs = bevelSize * Math.sin(t * Math.PI / 2) + bevelOffset; // contract shape\n\n\t\t\t\tfor (let i = 0, il = contour.length; i < il; i++) {\n\t\t\t\t\tconst vert = scalePt2(contour[i], contourMovements[i], bs);\n\t\t\t\t\tv(vert.x, vert.y, -z);\n\t\t\t\t} // expand holes\n\n\n\t\t\t\tfor (let h = 0, hl = holes.length; h < hl; h++) {\n\t\t\t\t\tconst ahole = holes[h];\n\t\t\t\t\toneHoleMovements = holesMovements[h];\n\n\t\t\t\t\tfor (let i = 0, il = ahole.length; i < il; i++) {\n\t\t\t\t\t\tconst vert = scalePt2(ahole[i], oneHoleMovements[i], bs);\n\t\t\t\t\t\tv(vert.x, vert.y, -z);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst bs = bevelSize + bevelOffset; // Back facing vertices\n\n\t\t\tfor (let i = 0; i < vlen; i++) {\n\t\t\t\tconst vert = bevelEnabled ? scalePt2(vertices[i], verticesMovements[i], bs) : vertices[i];\n\n\t\t\t\tif (!extrudeByPath) {\n\t\t\t\t\tv(vert.x, vert.y, 0);\n\t\t\t\t} else {\n\t\t\t\t\t// v( vert.x, vert.y + extrudePts[ 0 ].y, extrudePts[ 0 ].x );\n\t\t\t\t\tnormal.copy(splineTube.normals[0]).multiplyScalar(vert.x);\n\t\t\t\t\tbinormal.copy(splineTube.binormals[0]).multiplyScalar(vert.y);\n\t\t\t\t\tposition2.copy(extrudePts[0]).add(normal).add(binormal);\n\t\t\t\t\tv(position2.x, position2.y, position2.z);\n\t\t\t\t}\n\t\t\t} // Add stepped vertices...\n\t\t\t// Including front facing vertices\n\n\n\t\t\tfor (let s = 1; s <= steps; s++) {\n\t\t\t\tfor (let i = 0; i < vlen; i++) {\n\t\t\t\t\tconst vert = bevelEnabled ? scalePt2(vertices[i], verticesMovements[i], bs) : vertices[i];\n\n\t\t\t\t\tif (!extrudeByPath) {\n\t\t\t\t\t\tv(vert.x, vert.y, depth / steps * s);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// v( vert.x, vert.y + extrudePts[ s - 1 ].y, extrudePts[ s - 1 ].x );\n\t\t\t\t\t\tnormal.copy(splineTube.normals[s]).multiplyScalar(vert.x);\n\t\t\t\t\t\tbinormal.copy(splineTube.binormals[s]).multiplyScalar(vert.y);\n\t\t\t\t\t\tposition2.copy(extrudePts[s]).add(normal).add(binormal);\n\t\t\t\t\t\tv(position2.x, position2.y, position2.z);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} // Add bevel segments planes\n\t\t\t//for ( b = 1; b <= bevelSegments; b ++ ) {\n\n\n\t\t\tfor (let b = bevelSegments - 1; b >= 0; b--) {\n\t\t\t\tconst t = b / bevelSegments;\n\t\t\t\tconst z = bevelThickness * Math.cos(t * Math.PI / 2);\n\t\t\t\tconst bs = bevelSize * Math.sin(t * Math.PI / 2) + bevelOffset; // contract shape\n\n\t\t\t\tfor (let i = 0, il = contour.length; i < il; i++) {\n\t\t\t\t\tconst vert = scalePt2(contour[i], contourMovements[i], bs);\n\t\t\t\t\tv(vert.x, vert.y, depth + z);\n\t\t\t\t} // expand holes\n\n\n\t\t\t\tfor (let h = 0, hl = holes.length; h < hl; h++) {\n\t\t\t\t\tconst ahole = holes[h];\n\t\t\t\t\toneHoleMovements = holesMovements[h];\n\n\t\t\t\t\tfor (let i = 0, il = ahole.length; i < il; i++) {\n\t\t\t\t\t\tconst vert = scalePt2(ahole[i], oneHoleMovements[i], bs);\n\n\t\t\t\t\t\tif (!extrudeByPath) {\n\t\t\t\t\t\t\tv(vert.x, vert.y, depth + z);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tv(vert.x, vert.y + extrudePts[steps - 1].y, extrudePts[steps - 1].x + z);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t/* Faces */\n\t\t\t// Top and bottom faces\n\n\n\t\t\tbuildLidFaces(); // Sides faces\n\n\t\t\tbuildSideFaces(); /////\tInternal functions\n\n\t\t\tfunction buildLidFaces() {\n\t\t\t\tconst start = verticesArray.length / 3;\n\n\t\t\t\tif (bevelEnabled) {\n\t\t\t\t\tlet layer = 0; // steps + 1\n\n\t\t\t\t\tlet offset = vlen * layer; // Bottom faces\n\n\t\t\t\t\tfor (let i = 0; i < flen; i++) {\n\t\t\t\t\t\tconst face = faces[i];\n\t\t\t\t\t\tf3(face[2] + offset, face[1] + offset, face[0] + offset);\n\t\t\t\t\t}\n\n\t\t\t\t\tlayer = steps + bevelSegments * 2;\n\t\t\t\t\toffset = vlen * layer; // Top faces\n\n\t\t\t\t\tfor (let i = 0; i < flen; i++) {\n\t\t\t\t\t\tconst face = faces[i];\n\t\t\t\t\t\tf3(face[0] + offset, face[1] + offset, face[2] + offset);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Bottom faces\n\t\t\t\t\tfor (let i = 0; i < flen; i++) {\n\t\t\t\t\t\tconst face = faces[i];\n\t\t\t\t\t\tf3(face[2], face[1], face[0]);\n\t\t\t\t\t} // Top faces\n\n\n\t\t\t\t\tfor (let i = 0; i < flen; i++) {\n\t\t\t\t\t\tconst face = faces[i];\n\t\t\t\t\t\tf3(face[0] + vlen * steps, face[1] + vlen * steps, face[2] + vlen * steps);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tscope.addGroup(start, verticesArray.length / 3 - start, 0);\n\t\t\t} // Create faces for the z-sides of the shape\n\n\n\t\t\tfunction buildSideFaces() {\n\t\t\t\tconst start = verticesArray.length / 3;\n\t\t\t\tlet layeroffset = 0;\n\t\t\t\tsidewalls(contour, layeroffset);\n\t\t\t\tlayeroffset += contour.length;\n\n\t\t\t\tfor (let h = 0, hl = holes.length; h < hl; h++) {\n\t\t\t\t\tconst ahole = holes[h];\n\t\t\t\t\tsidewalls(ahole, layeroffset); //, true\n\n\t\t\t\t\tlayeroffset += ahole.length;\n\t\t\t\t}\n\n\t\t\t\tscope.addGroup(start, verticesArray.length / 3 - start, 1);\n\t\t\t}\n\n\t\t\tfunction sidewalls(contour, layeroffset) {\n\t\t\t\tlet i = contour.length;\n\n\t\t\t\twhile (--i >= 0) {\n\t\t\t\t\tconst j = i;\n\t\t\t\t\tlet k = i - 1;\n\t\t\t\t\tif (k < 0) k = contour.length - 1; //console.log('b', i,j, i-1, k,vertices.length);\n\n\t\t\t\t\tfor (let s = 0, sl = steps + bevelSegments * 2; s < sl; s++) {\n\t\t\t\t\t\tconst slen1 = vlen * s;\n\t\t\t\t\t\tconst slen2 = vlen * (s + 1);\n\t\t\t\t\t\tconst a = layeroffset + j + slen1,\n\t\t\t\t\t\t\t\t\tb = layeroffset + k + slen1,\n\t\t\t\t\t\t\t\t\tc = layeroffset + k + slen2,\n\t\t\t\t\t\t\t\t\td = layeroffset + j + slen2;\n\t\t\t\t\t\tf4(a, b, c, d);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction v(x, y, z) {\n\t\t\t\tplaceholder.push(x);\n\t\t\t\tplaceholder.push(y);\n\t\t\t\tplaceholder.push(z);\n\t\t\t}\n\n\t\t\tfunction f3(a, b, c) {\n\t\t\t\taddVertex(a);\n\t\t\t\taddVertex(b);\n\t\t\t\taddVertex(c);\n\t\t\t\tconst nextIndex = verticesArray.length / 3;\n\t\t\t\tconst uvs = uvgen.generateTopUV(scope, verticesArray, nextIndex - 3, nextIndex - 2, nextIndex - 1);\n\t\t\t\taddUV(uvs[0]);\n\t\t\t\taddUV(uvs[1]);\n\t\t\t\taddUV(uvs[2]);\n\t\t\t}\n\n\t\t\tfunction f4(a, b, c, d) {\n\t\t\t\taddVertex(a);\n\t\t\t\taddVertex(b);\n\t\t\t\taddVertex(d);\n\t\t\t\taddVertex(b);\n\t\t\t\taddVertex(c);\n\t\t\t\taddVertex(d);\n\t\t\t\tconst nextIndex = verticesArray.length / 3;\n\t\t\t\tconst uvs = uvgen.generateSideWallUV(scope, verticesArray, nextIndex - 6, nextIndex - 3, nextIndex - 2, nextIndex - 1);\n\t\t\t\taddUV(uvs[0]);\n\t\t\t\taddUV(uvs[1]);\n\t\t\t\taddUV(uvs[3]);\n\t\t\t\taddUV(uvs[1]);\n\t\t\t\taddUV(uvs[2]);\n\t\t\t\taddUV(uvs[3]);\n\t\t\t}\n\n\t\t\tfunction addVertex(index) {\n\t\t\t\tverticesArray.push(placeholder[index * 3 + 0]);\n\t\t\t\tverticesArray.push(placeholder[index * 3 + 1]);\n\t\t\t\tverticesArray.push(placeholder[index * 3 + 2]);\n\t\t\t}\n\n\t\t\tfunction addUV(vector2) {\n\t\t\t\tuvArray.push(vector2.x);\n\t\t\t\tuvArray.push(vector2.y);\n\t\t\t}\n\t\t}\n\t}\n\n\ttoJSON() {\n\t\tconst data = super.toJSON();\n\t\tconst shapes = this.parameters.shapes;\n\t\tconst options = this.parameters.options;\n\t\treturn toJSON$1(shapes, options, data);\n\t}\n\n\tstatic fromJSON(data, shapes) {\n\t\tconst geometryShapes = [];\n\n\t\tfor (let j = 0, jl = data.shapes.length; j < jl; j++) {\n\t\t\tconst shape = shapes[data.shapes[j]];\n\t\t\tgeometryShapes.push(shape);\n\t\t}\n\n\t\tconst extrudePath = data.options.extrudePath;\n\n\t\tif (extrudePath !== undefined) {\n\t\t\tdata.options.extrudePath = new Curves[extrudePath.type]().fromJSON(extrudePath);\n\t\t}\n\n\t\treturn new ExtrudeGeometry(geometryShapes, data.options);\n\t}\n\n}\n\nconst WorldUVGenerator = {\n\tgenerateTopUV: function (geometry, vertices, indexA, indexB, indexC) {\n\t\tconst a_x = vertices[indexA * 3];\n\t\tconst a_y = vertices[indexA * 3 + 1];\n\t\tconst b_x = vertices[indexB * 3];\n\t\tconst b_y = vertices[indexB * 3 + 1];\n\t\tconst c_x = vertices[indexC * 3];\n\t\tconst c_y = vertices[indexC * 3 + 1];\n\t\treturn [new Vector2(a_x, a_y), new Vector2(b_x, b_y), new Vector2(c_x, c_y)];\n\t},\n\tgenerateSideWallUV: function (geometry, vertices, indexA, indexB, indexC, indexD) {\n\t\tconst a_x = vertices[indexA * 3];\n\t\tconst a_y = vertices[indexA * 3 + 1];\n\t\tconst a_z = vertices[indexA * 3 + 2];\n\t\tconst b_x = vertices[indexB * 3];\n\t\tconst b_y = vertices[indexB * 3 + 1];\n\t\tconst b_z = vertices[indexB * 3 + 2];\n\t\tconst c_x = vertices[indexC * 3];\n\t\tconst c_y = vertices[indexC * 3 + 1];\n\t\tconst c_z = vertices[indexC * 3 + 2];\n\t\tconst d_x = vertices[indexD * 3];\n\t\tconst d_y = vertices[indexD * 3 + 1];\n\t\tconst d_z = vertices[indexD * 3 + 2];\n\n\t\tif (Math.abs(a_y - b_y) < Math.abs(a_x - b_x)) {\n\t\t\treturn [new Vector2(a_x, 1 - a_z), new Vector2(b_x, 1 - b_z), new Vector2(c_x, 1 - c_z), new Vector2(d_x, 1 - d_z)];\n\t\t} else {\n\t\t\treturn [new Vector2(a_y, 1 - a_z), new Vector2(b_y, 1 - b_z), new Vector2(c_y, 1 - c_z), new Vector2(d_y, 1 - d_z)];\n\t\t}\n\t}\n};\n\nfunction toJSON$1(shapes, options, data) {\n\tdata.shapes = [];\n\n\tif (Array.isArray(shapes)) {\n\t\tfor (let i = 0, l = shapes.length; i < l; i++) {\n\t\t\tconst shape = shapes[i];\n\t\t\tdata.shapes.push(shape.uuid);\n\t\t}\n\t} else {\n\t\tdata.shapes.push(shapes.uuid);\n\t}\n\n\tdata.options = Object.assign({}, options);\n\tif (options.extrudePath !== undefined) data.options.extrudePath = options.extrudePath.toJSON();\n\treturn data;\n}\n\nclass IcosahedronGeometry extends PolyhedronGeometry {\n\tconstructor(radius = 1, detail = 0) {\n\t\tconst t = (1 + Math.sqrt(5)) / 2;\n\t\tconst vertices = [-1, t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, 0, -1, t, 0, 1, t, 0, -1, -t, 0, 1, -t, t, 0, -1, t, 0, 1, -t, 0, -1, -t, 0, 1];\n\t\tconst indices = [0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 0, 10, 11, 1, 5, 9, 5, 11, 4, 11, 10, 2, 10, 7, 6, 7, 1, 8, 3, 9, 4, 3, 4, 2, 3, 2, 6, 3, 6, 8, 3, 8, 9, 4, 9, 5, 2, 4, 11, 6, 2, 10, 8, 6, 7, 9, 8, 1];\n\t\tsuper(vertices, indices, radius, detail);\n\t\tthis.type = 'IcosahedronGeometry';\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\tdetail: detail\n\t\t};\n\t}\n\n\tstatic fromJSON(data) {\n\t\treturn new IcosahedronGeometry(data.radius, data.detail);\n\t}\n\n}\n\nclass OctahedronGeometry extends PolyhedronGeometry {\n\tconstructor(radius = 1, detail = 0) {\n\t\tconst vertices = [1, 0, 0, -1, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 1, 0, 0, -1];\n\t\tconst indices = [0, 2, 4, 0, 4, 3, 0, 3, 5, 0, 5, 2, 1, 2, 5, 1, 5, 3, 1, 3, 4, 1, 4, 2];\n\t\tsuper(vertices, indices, radius, detail);\n\t\tthis.type = 'OctahedronGeometry';\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\tdetail: detail\n\t\t};\n\t}\n\n\tstatic fromJSON(data) {\n\t\treturn new OctahedronGeometry(data.radius, data.detail);\n\t}\n\n}\n\nclass RingGeometry extends BufferGeometry {\n\tconstructor(innerRadius = 0.5, outerRadius = 1, thetaSegments = 8, phiSegments = 1, thetaStart = 0, thetaLength = Math.PI * 2) {\n\t\tsuper();\n\t\tthis.type = 'RingGeometry';\n\t\tthis.parameters = {\n\t\t\tinnerRadius: innerRadius,\n\t\t\touterRadius: outerRadius,\n\t\t\tthetaSegments: thetaSegments,\n\t\t\tphiSegments: phiSegments,\n\t\t\tthetaStart: thetaStart,\n\t\t\tthetaLength: thetaLength\n\t\t};\n\t\tthetaSegments = Math.max(3, thetaSegments);\n\t\tphiSegments = Math.max(1, phiSegments); // buffers\n\n\t\tconst indices = [];\n\t\tconst vertices = [];\n\t\tconst normals = [];\n\t\tconst uvs = []; // some helper variables\n\n\t\tlet radius = innerRadius;\n\t\tconst radiusStep = (outerRadius - innerRadius) / phiSegments;\n\t\tconst vertex = new Vector3();\n\t\tconst uv = new Vector2(); // generate vertices, normals and uvs\n\n\t\tfor (let j = 0; j <= phiSegments; j++) {\n\t\t\tfor (let i = 0; i <= thetaSegments; i++) {\n\t\t\t\t// values are generate from the inside of the ring to the outside\n\t\t\t\tconst segment = thetaStart + i / thetaSegments * thetaLength; // vertex\n\n\t\t\t\tvertex.x = radius * Math.cos(segment);\n\t\t\t\tvertex.y = radius * Math.sin(segment);\n\t\t\t\tvertices.push(vertex.x, vertex.y, vertex.z); // normal\n\n\t\t\t\tnormals.push(0, 0, 1); // uv\n\n\t\t\t\tuv.x = (vertex.x / outerRadius + 1) / 2;\n\t\t\t\tuv.y = (vertex.y / outerRadius + 1) / 2;\n\t\t\t\tuvs.push(uv.x, uv.y);\n\t\t\t} // increase the radius for next row of vertices\n\n\n\t\t\tradius += radiusStep;\n\t\t} // indices\n\n\n\t\tfor (let j = 0; j < phiSegments; j++) {\n\t\t\tconst thetaSegmentLevel = j * (thetaSegments + 1);\n\n\t\t\tfor (let i = 0; i < thetaSegments; i++) {\n\t\t\t\tconst segment = i + thetaSegmentLevel;\n\t\t\t\tconst a = segment;\n\t\t\t\tconst b = segment + thetaSegments + 1;\n\t\t\t\tconst c = segment + thetaSegments + 2;\n\t\t\t\tconst d = segment + 1; // faces\n\n\t\t\t\tindices.push(a, b, d);\n\t\t\t\tindices.push(b, c, d);\n\t\t\t}\n\t\t} // build geometry\n\n\n\t\tthis.setIndex(indices);\n\t\tthis.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\tthis.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\t\tthis.setAttribute('uv', new Float32BufferAttribute(uvs, 2));\n\t}\n\n\tstatic fromJSON(data) {\n\t\treturn new RingGeometry(data.innerRadius, data.outerRadius, data.thetaSegments, data.phiSegments, data.thetaStart, data.thetaLength);\n\t}\n\n}\n\nclass ShapeGeometry extends BufferGeometry {\n\tconstructor(shapes = new Shape([new Vector2(0, 0.5), new Vector2(-0.5, -0.5), new Vector2(0.5, -0.5)]), curveSegments = 12) {\n\t\tsuper();\n\t\tthis.type = 'ShapeGeometry';\n\t\tthis.parameters = {\n\t\t\tshapes: shapes,\n\t\t\tcurveSegments: curveSegments\n\t\t}; // buffers\n\n\t\tconst indices = [];\n\t\tconst vertices = [];\n\t\tconst normals = [];\n\t\tconst uvs = []; // helper variables\n\n\t\tlet groupStart = 0;\n\t\tlet groupCount = 0; // allow single and array values for \"shapes\" parameter\n\n\t\tif (Array.isArray(shapes) === false) {\n\t\t\taddShape(shapes);\n\t\t} else {\n\t\t\tfor (let i = 0; i < shapes.length; i++) {\n\t\t\t\taddShape(shapes[i]);\n\t\t\t\tthis.addGroup(groupStart, groupCount, i); // enables MultiMaterial support\n\n\t\t\t\tgroupStart += groupCount;\n\t\t\t\tgroupCount = 0;\n\t\t\t}\n\t\t} // build geometry\n\n\n\t\tthis.setIndex(indices);\n\t\tthis.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\tthis.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\t\tthis.setAttribute('uv', new Float32BufferAttribute(uvs, 2)); // helper functions\n\n\t\tfunction addShape(shape) {\n\t\t\tconst indexOffset = vertices.length / 3;\n\t\t\tconst points = shape.extractPoints(curveSegments);\n\t\t\tlet shapeVertices = points.shape;\n\t\t\tconst shapeHoles = points.holes; // check direction of vertices\n\n\t\t\tif (ShapeUtils.isClockWise(shapeVertices) === false) {\n\t\t\t\tshapeVertices = shapeVertices.reverse();\n\t\t\t}\n\n\t\t\tfor (let i = 0, l = shapeHoles.length; i < l; i++) {\n\t\t\t\tconst shapeHole = shapeHoles[i];\n\n\t\t\t\tif (ShapeUtils.isClockWise(shapeHole) === true) {\n\t\t\t\t\tshapeHoles[i] = shapeHole.reverse();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst faces = ShapeUtils.triangulateShape(shapeVertices, shapeHoles); // join vertices of inner and outer paths to a single array\n\n\t\t\tfor (let i = 0, l = shapeHoles.length; i < l; i++) {\n\t\t\t\tconst shapeHole = shapeHoles[i];\n\t\t\t\tshapeVertices = shapeVertices.concat(shapeHole);\n\t\t\t} // vertices, normals, uvs\n\n\n\t\t\tfor (let i = 0, l = shapeVertices.length; i < l; i++) {\n\t\t\t\tconst vertex = shapeVertices[i];\n\t\t\t\tvertices.push(vertex.x, vertex.y, 0);\n\t\t\t\tnormals.push(0, 0, 1);\n\t\t\t\tuvs.push(vertex.x, vertex.y); // world uvs\n\t\t\t} // incides\n\n\n\t\t\tfor (let i = 0, l = faces.length; i < l; i++) {\n\t\t\t\tconst face = faces[i];\n\t\t\t\tconst a = face[0] + indexOffset;\n\t\t\t\tconst b = face[1] + indexOffset;\n\t\t\t\tconst c = face[2] + indexOffset;\n\t\t\t\tindices.push(a, b, c);\n\t\t\t\tgroupCount += 3;\n\t\t\t}\n\t\t}\n\t}\n\n\ttoJSON() {\n\t\tconst data = super.toJSON();\n\t\tconst shapes = this.parameters.shapes;\n\t\treturn toJSON(shapes, data);\n\t}\n\n\tstatic fromJSON(data, shapes) {\n\t\tconst geometryShapes = [];\n\n\t\tfor (let j = 0, jl = data.shapes.length; j < jl; j++) {\n\t\t\tconst shape = shapes[data.shapes[j]];\n\t\t\tgeometryShapes.push(shape);\n\t\t}\n\n\t\treturn new ShapeGeometry(geometryShapes, data.curveSegments);\n\t}\n\n}\n\nfunction toJSON(shapes, data) {\n\tdata.shapes = [];\n\n\tif (Array.isArray(shapes)) {\n\t\tfor (let i = 0, l = shapes.length; i < l; i++) {\n\t\t\tconst shape = shapes[i];\n\t\t\tdata.shapes.push(shape.uuid);\n\t\t}\n\t} else {\n\t\tdata.shapes.push(shapes.uuid);\n\t}\n\n\treturn data;\n}\n\nclass SphereGeometry extends BufferGeometry {\n\tconstructor(radius = 1, widthSegments = 32, heightSegments = 16, phiStart = 0, phiLength = Math.PI * 2, thetaStart = 0, thetaLength = Math.PI) {\n\t\tsuper();\n\t\tthis.type = 'SphereGeometry';\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\twidthSegments: widthSegments,\n\t\t\theightSegments: heightSegments,\n\t\t\tphiStart: phiStart,\n\t\t\tphiLength: phiLength,\n\t\t\tthetaStart: thetaStart,\n\t\t\tthetaLength: thetaLength\n\t\t};\n\t\twidthSegments = Math.max(3, Math.floor(widthSegments));\n\t\theightSegments = Math.max(2, Math.floor(heightSegments));\n\t\tconst thetaEnd = Math.min(thetaStart + thetaLength, Math.PI);\n\t\tlet index = 0;\n\t\tconst grid = [];\n\t\tconst vertex = new Vector3();\n\t\tconst normal = new Vector3(); // buffers\n\n\t\tconst indices = [];\n\t\tconst vertices = [];\n\t\tconst normals = [];\n\t\tconst uvs = []; // generate vertices, normals and uvs\n\n\t\tfor (let iy = 0; iy <= heightSegments; iy++) {\n\t\t\tconst verticesRow = [];\n\t\t\tconst v = iy / heightSegments; // special case for the poles\n\n\t\t\tlet uOffset = 0;\n\n\t\t\tif (iy == 0 && thetaStart == 0) {\n\t\t\t\tuOffset = 0.5 / widthSegments;\n\t\t\t} else if (iy == heightSegments && thetaEnd == Math.PI) {\n\t\t\t\tuOffset = -0.5 / widthSegments;\n\t\t\t}\n\n\t\t\tfor (let ix = 0; ix <= widthSegments; ix++) {\n\t\t\t\tconst u = ix / widthSegments; // vertex\n\n\t\t\t\tvertex.x = -radius * Math.cos(phiStart + u * phiLength) * Math.sin(thetaStart + v * thetaLength);\n\t\t\t\tvertex.y = radius * Math.cos(thetaStart + v * thetaLength);\n\t\t\t\tvertex.z = radius * Math.sin(phiStart + u * phiLength) * Math.sin(thetaStart + v * thetaLength);\n\t\t\t\tvertices.push(vertex.x, vertex.y, vertex.z); // normal\n\n\t\t\t\tnormal.copy(vertex).normalize();\n\t\t\t\tnormals.push(normal.x, normal.y, normal.z); // uv\n\n\t\t\t\tuvs.push(u + uOffset, 1 - v);\n\t\t\t\tverticesRow.push(index++);\n\t\t\t}\n\n\t\t\tgrid.push(verticesRow);\n\t\t} // indices\n\n\n\t\tfor (let iy = 0; iy < heightSegments; iy++) {\n\t\t\tfor (let ix = 0; ix < widthSegments; ix++) {\n\t\t\t\tconst a = grid[iy][ix + 1];\n\t\t\t\tconst b = grid[iy][ix];\n\t\t\t\tconst c = grid[iy + 1][ix];\n\t\t\t\tconst d = grid[iy + 1][ix + 1];\n\t\t\t\tif (iy !== 0 || thetaStart > 0) indices.push(a, b, d);\n\t\t\t\tif (iy !== heightSegments - 1 || thetaEnd < Math.PI) indices.push(b, c, d);\n\t\t\t}\n\t\t} // build geometry\n\n\n\t\tthis.setIndex(indices);\n\t\tthis.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\tthis.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\t\tthis.setAttribute('uv', new Float32BufferAttribute(uvs, 2));\n\t}\n\n\tstatic fromJSON(data) {\n\t\treturn new SphereGeometry(data.radius, data.widthSegments, data.heightSegments, data.phiStart, data.phiLength, data.thetaStart, data.thetaLength);\n\t}\n\n}\n\nclass TetrahedronGeometry extends PolyhedronGeometry {\n\tconstructor(radius = 1, detail = 0) {\n\t\tconst vertices = [1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1];\n\t\tconst indices = [2, 1, 0, 0, 3, 2, 1, 3, 0, 2, 3, 1];\n\t\tsuper(vertices, indices, radius, detail);\n\t\tthis.type = 'TetrahedronGeometry';\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\tdetail: detail\n\t\t};\n\t}\n\n\tstatic fromJSON(data) {\n\t\treturn new TetrahedronGeometry(data.radius, data.detail);\n\t}\n\n}\n\nclass TorusGeometry extends BufferGeometry {\n\tconstructor(radius = 1, tube = 0.4, radialSegments = 8, tubularSegments = 6, arc = Math.PI * 2) {\n\t\tsuper();\n\t\tthis.type = 'TorusGeometry';\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\ttube: tube,\n\t\t\tradialSegments: radialSegments,\n\t\t\ttubularSegments: tubularSegments,\n\t\t\tarc: arc\n\t\t};\n\t\tradialSegments = Math.floor(radialSegments);\n\t\ttubularSegments = Math.floor(tubularSegments); // buffers\n\n\t\tconst indices = [];\n\t\tconst vertices = [];\n\t\tconst normals = [];\n\t\tconst uvs = []; // helper variables\n\n\t\tconst center = new Vector3();\n\t\tconst vertex = new Vector3();\n\t\tconst normal = new Vector3(); // generate vertices, normals and uvs\n\n\t\tfor (let j = 0; j <= radialSegments; j++) {\n\t\t\tfor (let i = 0; i <= tubularSegments; i++) {\n\t\t\t\tconst u = i / tubularSegments * arc;\n\t\t\t\tconst v = j / radialSegments * Math.PI * 2; // vertex\n\n\t\t\t\tvertex.x = (radius + tube * Math.cos(v)) * Math.cos(u);\n\t\t\t\tvertex.y = (radius + tube * Math.cos(v)) * Math.sin(u);\n\t\t\t\tvertex.z = tube * Math.sin(v);\n\t\t\t\tvertices.push(vertex.x, vertex.y, vertex.z); // normal\n\n\t\t\t\tcenter.x = radius * Math.cos(u);\n\t\t\t\tcenter.y = radius * Math.sin(u);\n\t\t\t\tnormal.subVectors(vertex, center).normalize();\n\t\t\t\tnormals.push(normal.x, normal.y, normal.z); // uv\n\n\t\t\t\tuvs.push(i / tubularSegments);\n\t\t\t\tuvs.push(j / radialSegments);\n\t\t\t}\n\t\t} // generate indices\n\n\n\t\tfor (let j = 1; j <= radialSegments; j++) {\n\t\t\tfor (let i = 1; i <= tubularSegments; i++) {\n\t\t\t\t// indices\n\t\t\t\tconst a = (tubularSegments + 1) * j + i - 1;\n\t\t\t\tconst b = (tubularSegments + 1) * (j - 1) + i - 1;\n\t\t\t\tconst c = (tubularSegments + 1) * (j - 1) + i;\n\t\t\t\tconst d = (tubularSegments + 1) * j + i; // faces\n\n\t\t\t\tindices.push(a, b, d);\n\t\t\t\tindices.push(b, c, d);\n\t\t\t}\n\t\t} // build geometry\n\n\n\t\tthis.setIndex(indices);\n\t\tthis.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\tthis.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\t\tthis.setAttribute('uv', new Float32BufferAttribute(uvs, 2));\n\t}\n\n\tstatic fromJSON(data) {\n\t\treturn new TorusGeometry(data.radius, data.tube, data.radialSegments, data.tubularSegments, data.arc);\n\t}\n\n}\n\nclass TorusKnotGeometry extends BufferGeometry {\n\tconstructor(radius = 1, tube = 0.4, tubularSegments = 64, radialSegments = 8, p = 2, q = 3) {\n\t\tsuper();\n\t\tthis.type = 'TorusKnotGeometry';\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\ttube: tube,\n\t\t\ttubularSegments: tubularSegments,\n\t\t\tradialSegments: radialSegments,\n\t\t\tp: p,\n\t\t\tq: q\n\t\t};\n\t\ttubularSegments = Math.floor(tubularSegments);\n\t\tradialSegments = Math.floor(radialSegments); // buffers\n\n\t\tconst indices = [];\n\t\tconst vertices = [];\n\t\tconst normals = [];\n\t\tconst uvs = []; // helper variables\n\n\t\tconst vertex = new Vector3();\n\t\tconst normal = new Vector3();\n\t\tconst P1 = new Vector3();\n\t\tconst P2 = new Vector3();\n\t\tconst B = new Vector3();\n\t\tconst T = new Vector3();\n\t\tconst N = new Vector3(); // generate vertices, normals and uvs\n\n\t\tfor (let i = 0; i <= tubularSegments; ++i) {\n\t\t\t// the radian \"u\" is used to calculate the position on the torus curve of the current tubular segment\n\t\t\tconst u = i / tubularSegments * p * Math.PI * 2; // now we calculate two points. P1 is our current position on the curve, P2 is a little farther ahead.\n\t\t\t// these points are used to create a special \"coordinate space\", which is necessary to calculate the correct vertex positions\n\n\t\t\tcalculatePositionOnCurve(u, p, q, radius, P1);\n\t\t\tcalculatePositionOnCurve(u + 0.01, p, q, radius, P2); // calculate orthonormal basis\n\n\t\t\tT.subVectors(P2, P1);\n\t\t\tN.addVectors(P2, P1);\n\t\t\tB.crossVectors(T, N);\n\t\t\tN.crossVectors(B, T); // normalize B, N. T can be ignored, we don't use it\n\n\t\t\tB.normalize();\n\t\t\tN.normalize();\n\n\t\t\tfor (let j = 0; j <= radialSegments; ++j) {\n\t\t\t\t// now calculate the vertices. they are nothing more than an extrusion of the torus curve.\n\t\t\t\t// because we extrude a shape in the xy-plane, there is no need to calculate a z-value.\n\t\t\t\tconst v = j / radialSegments * Math.PI * 2;\n\t\t\t\tconst cx = -tube * Math.cos(v);\n\t\t\t\tconst cy = tube * Math.sin(v); // now calculate the final vertex position.\n\t\t\t\t// first we orient the extrusion with our basis vectors, then we add it to the current position on the curve\n\n\t\t\t\tvertex.x = P1.x + (cx * N.x + cy * B.x);\n\t\t\t\tvertex.y = P1.y + (cx * N.y + cy * B.y);\n\t\t\t\tvertex.z = P1.z + (cx * N.z + cy * B.z);\n\t\t\t\tvertices.push(vertex.x, vertex.y, vertex.z); // normal (P1 is always the center/origin of the extrusion, thus we can use it to calculate the normal)\n\n\t\t\t\tnormal.subVectors(vertex, P1).normalize();\n\t\t\t\tnormals.push(normal.x, normal.y, normal.z); // uv\n\n\t\t\t\tuvs.push(i / tubularSegments);\n\t\t\t\tuvs.push(j / radialSegments);\n\t\t\t}\n\t\t} // generate indices\n\n\n\t\tfor (let j = 1; j <= tubularSegments; j++) {\n\t\t\tfor (let i = 1; i <= radialSegments; i++) {\n\t\t\t\t// indices\n\t\t\t\tconst a = (radialSegments + 1) * (j - 1) + (i - 1);\n\t\t\t\tconst b = (radialSegments + 1) * j + (i - 1);\n\t\t\t\tconst c = (radialSegments + 1) * j + i;\n\t\t\t\tconst d = (radialSegments + 1) * (j - 1) + i; // faces\n\n\t\t\t\tindices.push(a, b, d);\n\t\t\t\tindices.push(b, c, d);\n\t\t\t}\n\t\t} // build geometry\n\n\n\t\tthis.setIndex(indices);\n\t\tthis.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\tthis.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\t\tthis.setAttribute('uv', new Float32BufferAttribute(uvs, 2)); // this function calculates the current position on the torus curve\n\n\t\tfunction calculatePositionOnCurve(u, p, q, radius, position) {\n\t\t\tconst cu = Math.cos(u);\n\t\t\tconst su = Math.sin(u);\n\t\t\tconst quOverP = q / p * u;\n\t\t\tconst cs = Math.cos(quOverP);\n\t\t\tposition.x = radius * (2 + cs) * 0.5 * cu;\n\t\t\tposition.y = radius * (2 + cs) * su * 0.5;\n\t\t\tposition.z = radius * Math.sin(quOverP) * 0.5;\n\t\t}\n\t}\n\n\tstatic fromJSON(data) {\n\t\treturn new TorusKnotGeometry(data.radius, data.tube, data.tubularSegments, data.radialSegments, data.p, data.q);\n\t}\n\n}\n\nclass TubeGeometry extends BufferGeometry {\n\tconstructor(path = new QuadraticBezierCurve3(new Vector3(-1, -1, 0), new Vector3(-1, 1, 0), new Vector3(1, 1, 0)), tubularSegments = 64, radius = 1, radialSegments = 8, closed = false) {\n\t\tsuper();\n\t\tthis.type = 'TubeGeometry';\n\t\tthis.parameters = {\n\t\t\tpath: path,\n\t\t\ttubularSegments: tubularSegments,\n\t\t\tradius: radius,\n\t\t\tradialSegments: radialSegments,\n\t\t\tclosed: closed\n\t\t};\n\t\tconst frames = path.computeFrenetFrames(tubularSegments, closed); // expose internals\n\n\t\tthis.tangents = frames.tangents;\n\t\tthis.normals = frames.normals;\n\t\tthis.binormals = frames.binormals; // helper variables\n\n\t\tconst vertex = new Vector3();\n\t\tconst normal = new Vector3();\n\t\tconst uv = new Vector2();\n\t\tlet P = new Vector3(); // buffer\n\n\t\tconst vertices = [];\n\t\tconst normals = [];\n\t\tconst uvs = [];\n\t\tconst indices = []; // create buffer data\n\n\t\tgenerateBufferData(); // build geometry\n\n\t\tthis.setIndex(indices);\n\t\tthis.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\tthis.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\t\tthis.setAttribute('uv', new Float32BufferAttribute(uvs, 2)); // functions\n\n\t\tfunction generateBufferData() {\n\t\t\tfor (let i = 0; i < tubularSegments; i++) {\n\t\t\t\tgenerateSegment(i);\n\t\t\t} // if the geometry is not closed, generate the last row of vertices and normals\n\t\t\t// at the regular position on the given path\n\t\t\t//\n\t\t\t// if the geometry is closed, duplicate the first row of vertices and normals (uvs will differ)\n\n\n\t\t\tgenerateSegment(closed === false ? tubularSegments : 0); // uvs are generated in a separate function.\n\t\t\t// this makes it easy compute correct values for closed geometries\n\n\t\t\tgenerateUVs(); // finally create faces\n\n\t\t\tgenerateIndices();\n\t\t}\n\n\t\tfunction generateSegment(i) {\n\t\t\t// we use getPointAt to sample evenly distributed points from the given path\n\t\t\tP = path.getPointAt(i / tubularSegments, P); // retrieve corresponding normal and binormal\n\n\t\t\tconst N = frames.normals[i];\n\t\t\tconst B = frames.binormals[i]; // generate normals and vertices for the current segment\n\n\t\t\tfor (let j = 0; j <= radialSegments; j++) {\n\t\t\t\tconst v = j / radialSegments * Math.PI * 2;\n\t\t\t\tconst sin = Math.sin(v);\n\t\t\t\tconst cos = -Math.cos(v); // normal\n\n\t\t\t\tnormal.x = cos * N.x + sin * B.x;\n\t\t\t\tnormal.y = cos * N.y + sin * B.y;\n\t\t\t\tnormal.z = cos * N.z + sin * B.z;\n\t\t\t\tnormal.normalize();\n\t\t\t\tnormals.push(normal.x, normal.y, normal.z); // vertex\n\n\t\t\t\tvertex.x = P.x + radius * normal.x;\n\t\t\t\tvertex.y = P.y + radius * normal.y;\n\t\t\t\tvertex.z = P.z + radius * normal.z;\n\t\t\t\tvertices.push(vertex.x, vertex.y, vertex.z);\n\t\t\t}\n\t\t}\n\n\t\tfunction generateIndices() {\n\t\t\tfor (let j = 1; j <= tubularSegments; j++) {\n\t\t\t\tfor (let i = 1; i <= radialSegments; i++) {\n\t\t\t\t\tconst a = (radialSegments + 1) * (j - 1) + (i - 1);\n\t\t\t\t\tconst b = (radialSegments + 1) * j + (i - 1);\n\t\t\t\t\tconst c = (radialSegments + 1) * j + i;\n\t\t\t\t\tconst d = (radialSegments + 1) * (j - 1) + i; // faces\n\n\t\t\t\t\tindices.push(a, b, d);\n\t\t\t\t\tindices.push(b, c, d);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction generateUVs() {\n\t\t\tfor (let i = 0; i <= tubularSegments; i++) {\n\t\t\t\tfor (let j = 0; j <= radialSegments; j++) {\n\t\t\t\t\tuv.x = i / tubularSegments;\n\t\t\t\t\tuv.y = j / radialSegments;\n\t\t\t\t\tuvs.push(uv.x, uv.y);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\ttoJSON() {\n\t\tconst data = super.toJSON();\n\t\tdata.path = this.parameters.path.toJSON();\n\t\treturn data;\n\t}\n\n\tstatic fromJSON(data) {\n\t\t// This only works for built-in curves (e.g. CatmullRomCurve3).\n\t\t// User defined curves or instances of CurvePath will not be deserialized.\n\t\treturn new TubeGeometry(new Curves[data.path.type]().fromJSON(data.path), data.tubularSegments, data.radius, data.radialSegments, data.closed);\n\t}\n\n}\n\nclass WireframeGeometry extends BufferGeometry {\n\tconstructor(geometry = null) {\n\t\tsuper();\n\t\tthis.type = 'WireframeGeometry';\n\t\tthis.parameters = {\n\t\t\tgeometry: geometry\n\t\t};\n\n\t\tif (geometry !== null) {\n\t\t\t// buffer\n\t\t\tconst vertices = [];\n\t\t\tconst edges = new Set(); // helper variables\n\n\t\t\tconst start = new Vector3();\n\t\t\tconst end = new Vector3();\n\n\t\t\tif (geometry.index !== null) {\n\t\t\t\t// indexed BufferGeometry\n\t\t\t\tconst position = geometry.attributes.position;\n\t\t\t\tconst indices = geometry.index;\n\t\t\t\tlet groups = geometry.groups;\n\n\t\t\t\tif (groups.length === 0) {\n\t\t\t\t\tgroups = [{\n\t\t\t\t\t\tstart: 0,\n\t\t\t\t\t\tcount: indices.count,\n\t\t\t\t\t\tmaterialIndex: 0\n\t\t\t\t\t}];\n\t\t\t\t} // create a data structure that contains all edges without duplicates\n\n\n\t\t\t\tfor (let o = 0, ol = groups.length; o < ol; ++o) {\n\t\t\t\t\tconst group = groups[o];\n\t\t\t\t\tconst groupStart = group.start;\n\t\t\t\t\tconst groupCount = group.count;\n\n\t\t\t\t\tfor (let i = groupStart, l = groupStart + groupCount; i < l; i += 3) {\n\t\t\t\t\t\tfor (let j = 0; j < 3; j++) {\n\t\t\t\t\t\t\tconst index1 = indices.getX(i + j);\n\t\t\t\t\t\t\tconst index2 = indices.getX(i + (j + 1) % 3);\n\t\t\t\t\t\t\tstart.fromBufferAttribute(position, index1);\n\t\t\t\t\t\t\tend.fromBufferAttribute(position, index2);\n\n\t\t\t\t\t\t\tif (isUniqueEdge(start, end, edges) === true) {\n\t\t\t\t\t\t\t\tvertices.push(start.x, start.y, start.z);\n\t\t\t\t\t\t\t\tvertices.push(end.x, end.y, end.z);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// non-indexed BufferGeometry\n\t\t\t\tconst position = geometry.attributes.position;\n\n\t\t\t\tfor (let i = 0, l = position.count / 3; i < l; i++) {\n\t\t\t\t\tfor (let j = 0; j < 3; j++) {\n\t\t\t\t\t\t// three edges per triangle, an edge is represented as (index1, index2)\n\t\t\t\t\t\t// e.g. the first triangle has the following edges: (0,1),(1,2),(2,0)\n\t\t\t\t\t\tconst index1 = 3 * i + j;\n\t\t\t\t\t\tconst index2 = 3 * i + (j + 1) % 3;\n\t\t\t\t\t\tstart.fromBufferAttribute(position, index1);\n\t\t\t\t\t\tend.fromBufferAttribute(position, index2);\n\n\t\t\t\t\t\tif (isUniqueEdge(start, end, edges) === true) {\n\t\t\t\t\t\t\tvertices.push(start.x, start.y, start.z);\n\t\t\t\t\t\t\tvertices.push(end.x, end.y, end.z);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} // build geometry\n\n\n\t\t\tthis.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\t}\n\t}\n\n}\n\nfunction isUniqueEdge(start, end, edges) {\n\tconst hash1 = `${start.x},${start.y},${start.z}-${end.x},${end.y},${end.z}`;\n\tconst hash2 = `${end.x},${end.y},${end.z}-${start.x},${start.y},${start.z}`; // coincident edge\n\n\tif (edges.has(hash1) === true || edges.has(hash2) === true) {\n\t\treturn false;\n\t} else {\n\t\tedges.add(hash1);\n\t\tedges.add(hash2);\n\t\treturn true;\n\t}\n}\n\nvar Geometries = /*#__PURE__*/Object.freeze({\n\t__proto__: null,\n\tBoxGeometry: BoxGeometry,\n\tCapsuleGeometry: CapsuleGeometry,\n\tCircleGeometry: CircleGeometry,\n\tConeGeometry: ConeGeometry,\n\tCylinderGeometry: CylinderGeometry,\n\tDodecahedronGeometry: DodecahedronGeometry,\n\tEdgesGeometry: EdgesGeometry,\n\tExtrudeGeometry: ExtrudeGeometry,\n\tIcosahedronGeometry: IcosahedronGeometry,\n\tLatheGeometry: LatheGeometry,\n\tOctahedronGeometry: OctahedronGeometry,\n\tPlaneGeometry: PlaneGeometry,\n\tPolyhedronGeometry: PolyhedronGeometry,\n\tRingGeometry: RingGeometry,\n\tShapeGeometry: ShapeGeometry,\n\tSphereGeometry: SphereGeometry,\n\tTetrahedronGeometry: TetrahedronGeometry,\n\tTorusGeometry: TorusGeometry,\n\tTorusKnotGeometry: TorusKnotGeometry,\n\tTubeGeometry: TubeGeometry,\n\tWireframeGeometry: WireframeGeometry\n});\n\nclass ShadowMaterial extends Material {\n\tconstructor(parameters) {\n\t\tsuper();\n\t\tthis.isShadowMaterial = true;\n\t\tthis.type = 'ShadowMaterial';\n\t\tthis.color = new Color(0x000000);\n\t\tthis.transparent = true;\n\t\tthis.fog = true;\n\t\tthis.setValues(parameters);\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.color.copy(source.color);\n\t\tthis.fog = source.fog;\n\t\treturn this;\n\t}\n\n}\n\nclass RawShaderMaterial extends ShaderMaterial {\n\tconstructor(parameters) {\n\t\tsuper(parameters);\n\t\tthis.isRawShaderMaterial = true;\n\t\tthis.type = 'RawShaderMaterial';\n\t}\n\n}\n\nclass MeshStandardMaterial extends Material {\n\tconstructor(parameters) {\n\t\tsuper();\n\t\tthis.isMeshStandardMaterial = true;\n\t\tthis.defines = {\n\t\t\t'STANDARD': ''\n\t\t};\n\t\tthis.type = 'MeshStandardMaterial';\n\t\tthis.color = new Color(0xffffff); // diffuse\n\n\t\tthis.roughness = 1.0;\n\t\tthis.metalness = 0.0;\n\t\tthis.map = null;\n\t\tthis.lightMap = null;\n\t\tthis.lightMapIntensity = 1.0;\n\t\tthis.aoMap = null;\n\t\tthis.aoMapIntensity = 1.0;\n\t\tthis.emissive = new Color(0x000000);\n\t\tthis.emissiveIntensity = 1.0;\n\t\tthis.emissiveMap = null;\n\t\tthis.bumpMap = null;\n\t\tthis.bumpScale = 1;\n\t\tthis.normalMap = null;\n\t\tthis.normalMapType = TangentSpaceNormalMap;\n\t\tthis.normalScale = new Vector2(1, 1);\n\t\tthis.displacementMap = null;\n\t\tthis.displacementScale = 1;\n\t\tthis.displacementBias = 0;\n\t\tthis.roughnessMap = null;\n\t\tthis.metalnessMap = null;\n\t\tthis.alphaMap = null;\n\t\tthis.envMap = null;\n\t\tthis.envMapIntensity = 1.0;\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\t\tthis.wireframeLinecap = 'round';\n\t\tthis.wireframeLinejoin = 'round';\n\t\tthis.flatShading = false;\n\t\tthis.fog = true;\n\t\tthis.setValues(parameters);\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.defines = {\n\t\t\t'STANDARD': ''\n\t\t};\n\t\tthis.color.copy(source.color);\n\t\tthis.roughness = source.roughness;\n\t\tthis.metalness = source.metalness;\n\t\tthis.map = source.map;\n\t\tthis.lightMap = source.lightMap;\n\t\tthis.lightMapIntensity = source.lightMapIntensity;\n\t\tthis.aoMap = source.aoMap;\n\t\tthis.aoMapIntensity = source.aoMapIntensity;\n\t\tthis.emissive.copy(source.emissive);\n\t\tthis.emissiveMap = source.emissiveMap;\n\t\tthis.emissiveIntensity = source.emissiveIntensity;\n\t\tthis.bumpMap = source.bumpMap;\n\t\tthis.bumpScale = source.bumpScale;\n\t\tthis.normalMap = source.normalMap;\n\t\tthis.normalMapType = source.normalMapType;\n\t\tthis.normalScale.copy(source.normalScale);\n\t\tthis.displacementMap = source.displacementMap;\n\t\tthis.displacementScale = source.displacementScale;\n\t\tthis.displacementBias = source.displacementBias;\n\t\tthis.roughnessMap = source.roughnessMap;\n\t\tthis.metalnessMap = source.metalnessMap;\n\t\tthis.alphaMap = source.alphaMap;\n\t\tthis.envMap = source.envMap;\n\t\tthis.envMapIntensity = source.envMapIntensity;\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\t\tthis.wireframeLinecap = source.wireframeLinecap;\n\t\tthis.wireframeLinejoin = source.wireframeLinejoin;\n\t\tthis.flatShading = source.flatShading;\n\t\tthis.fog = source.fog;\n\t\treturn this;\n\t}\n\n}\n\nclass MeshPhysicalMaterial extends MeshStandardMaterial {\n\tconstructor(parameters) {\n\t\tsuper();\n\t\tthis.isMeshPhysicalMaterial = true;\n\t\tthis.defines = {\n\t\t\t'STANDARD': '',\n\t\t\t'PHYSICAL': ''\n\t\t};\n\t\tthis.type = 'MeshPhysicalMaterial';\n\t\tthis.clearcoatMap = null;\n\t\tthis.clearcoatRoughness = 0.0;\n\t\tthis.clearcoatRoughnessMap = null;\n\t\tthis.clearcoatNormalScale = new Vector2(1, 1);\n\t\tthis.clearcoatNormalMap = null;\n\t\tthis.ior = 1.5;\n\t\tObject.defineProperty(this, 'reflectivity', {\n\t\t\tget: function () {\n\t\t\t\treturn clamp(2.5 * (this.ior - 1) / (this.ior + 1), 0, 1);\n\t\t\t},\n\t\t\tset: function (reflectivity) {\n\t\t\t\tthis.ior = (1 + 0.4 * reflectivity) / (1 - 0.4 * reflectivity);\n\t\t\t}\n\t\t});\n\t\tthis.iridescenceMap = null;\n\t\tthis.iridescenceIOR = 1.3;\n\t\tthis.iridescenceThicknessRange = [100, 400];\n\t\tthis.iridescenceThicknessMap = null;\n\t\tthis.sheenColor = new Color(0x000000);\n\t\tthis.sheenColorMap = null;\n\t\tthis.sheenRoughness = 1.0;\n\t\tthis.sheenRoughnessMap = null;\n\t\tthis.transmissionMap = null;\n\t\tthis.thickness = 0;\n\t\tthis.thicknessMap = null;\n\t\tthis.attenuationDistance = Infinity;\n\t\tthis.attenuationColor = new Color(1, 1, 1);\n\t\tthis.specularIntensity = 1.0;\n\t\tthis.specularIntensityMap = null;\n\t\tthis.specularColor = new Color(1, 1, 1);\n\t\tthis.specularColorMap = null;\n\t\tthis._sheen = 0.0;\n\t\tthis._clearcoat = 0;\n\t\tthis._iridescence = 0;\n\t\tthis._transmission = 0;\n\t\tthis.setValues(parameters);\n\t}\n\n\tget sheen() {\n\t\treturn this._sheen;\n\t}\n\n\tset sheen(value) {\n\t\tif (this._sheen > 0 !== value > 0) {\n\t\t\tthis.version++;\n\t\t}\n\n\t\tthis._sheen = value;\n\t}\n\n\tget clearcoat() {\n\t\treturn this._clearcoat;\n\t}\n\n\tset clearcoat(value) {\n\t\tif (this._clearcoat > 0 !== value > 0) {\n\t\t\tthis.version++;\n\t\t}\n\n\t\tthis._clearcoat = value;\n\t}\n\n\tget iridescence() {\n\t\treturn this._iridescence;\n\t}\n\n\tset iridescence(value) {\n\t\tif (this._iridescence > 0 !== value > 0) {\n\t\t\tthis.version++;\n\t\t}\n\n\t\tthis._iridescence = value;\n\t}\n\n\tget transmission() {\n\t\treturn this._transmission;\n\t}\n\n\tset transmission(value) {\n\t\tif (this._transmission > 0 !== value > 0) {\n\t\t\tthis.version++;\n\t\t}\n\n\t\tthis._transmission = value;\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.defines = {\n\t\t\t'STANDARD': '',\n\t\t\t'PHYSICAL': ''\n\t\t};\n\t\tthis.clearcoat = source.clearcoat;\n\t\tthis.clearcoatMap = source.clearcoatMap;\n\t\tthis.clearcoatRoughness = source.clearcoatRoughness;\n\t\tthis.clearcoatRoughnessMap = source.clearcoatRoughnessMap;\n\t\tthis.clearcoatNormalMap = source.clearcoatNormalMap;\n\t\tthis.clearcoatNormalScale.copy(source.clearcoatNormalScale);\n\t\tthis.ior = source.ior;\n\t\tthis.iridescence = source.iridescence;\n\t\tthis.iridescenceMap = source.iridescenceMap;\n\t\tthis.iridescenceIOR = source.iridescenceIOR;\n\t\tthis.iridescenceThicknessRange = [...source.iridescenceThicknessRange];\n\t\tthis.iridescenceThicknessMap = source.iridescenceThicknessMap;\n\t\tthis.sheen = source.sheen;\n\t\tthis.sheenColor.copy(source.sheenColor);\n\t\tthis.sheenColorMap = source.sheenColorMap;\n\t\tthis.sheenRoughness = source.sheenRoughness;\n\t\tthis.sheenRoughnessMap = source.sheenRoughnessMap;\n\t\tthis.transmission = source.transmission;\n\t\tthis.transmissionMap = source.transmissionMap;\n\t\tthis.thickness = source.thickness;\n\t\tthis.thicknessMap = source.thicknessMap;\n\t\tthis.attenuationDistance = source.attenuationDistance;\n\t\tthis.attenuationColor.copy(source.attenuationColor);\n\t\tthis.specularIntensity = source.specularIntensity;\n\t\tthis.specularIntensityMap = source.specularIntensityMap;\n\t\tthis.specularColor.copy(source.specularColor);\n\t\tthis.specularColorMap = source.specularColorMap;\n\t\treturn this;\n\t}\n\n}\n\nclass MeshPhongMaterial extends Material {\n\tconstructor(parameters) {\n\t\tsuper();\n\t\tthis.isMeshPhongMaterial = true;\n\t\tthis.type = 'MeshPhongMaterial';\n\t\tthis.color = new Color(0xffffff); // diffuse\n\n\t\tthis.specular = new Color(0x111111);\n\t\tthis.shininess = 30;\n\t\tthis.map = null;\n\t\tthis.lightMap = null;\n\t\tthis.lightMapIntensity = 1.0;\n\t\tthis.aoMap = null;\n\t\tthis.aoMapIntensity = 1.0;\n\t\tthis.emissive = new Color(0x000000);\n\t\tthis.emissiveIntensity = 1.0;\n\t\tthis.emissiveMap = null;\n\t\tthis.bumpMap = null;\n\t\tthis.bumpScale = 1;\n\t\tthis.normalMap = null;\n\t\tthis.normalMapType = TangentSpaceNormalMap;\n\t\tthis.normalScale = new Vector2(1, 1);\n\t\tthis.displacementMap = null;\n\t\tthis.displacementScale = 1;\n\t\tthis.displacementBias = 0;\n\t\tthis.specularMap = null;\n\t\tthis.alphaMap = null;\n\t\tthis.envMap = null;\n\t\tthis.combine = MultiplyOperation;\n\t\tthis.reflectivity = 1;\n\t\tthis.refractionRatio = 0.98;\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\t\tthis.wireframeLinecap = 'round';\n\t\tthis.wireframeLinejoin = 'round';\n\t\tthis.flatShading = false;\n\t\tthis.fog = true;\n\t\tthis.setValues(parameters);\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.color.copy(source.color);\n\t\tthis.specular.copy(source.specular);\n\t\tthis.shininess = source.shininess;\n\t\tthis.map = source.map;\n\t\tthis.lightMap = source.lightMap;\n\t\tthis.lightMapIntensity = source.lightMapIntensity;\n\t\tthis.aoMap = source.aoMap;\n\t\tthis.aoMapIntensity = source.aoMapIntensity;\n\t\tthis.emissive.copy(source.emissive);\n\t\tthis.emissiveMap = source.emissiveMap;\n\t\tthis.emissiveIntensity = source.emissiveIntensity;\n\t\tthis.bumpMap = source.bumpMap;\n\t\tthis.bumpScale = source.bumpScale;\n\t\tthis.normalMap = source.normalMap;\n\t\tthis.normalMapType = source.normalMapType;\n\t\tthis.normalScale.copy(source.normalScale);\n\t\tthis.displacementMap = source.displacementMap;\n\t\tthis.displacementScale = source.displacementScale;\n\t\tthis.displacementBias = source.displacementBias;\n\t\tthis.specularMap = source.specularMap;\n\t\tthis.alphaMap = source.alphaMap;\n\t\tthis.envMap = source.envMap;\n\t\tthis.combine = source.combine;\n\t\tthis.reflectivity = source.reflectivity;\n\t\tthis.refractionRatio = source.refractionRatio;\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\t\tthis.wireframeLinecap = source.wireframeLinecap;\n\t\tthis.wireframeLinejoin = source.wireframeLinejoin;\n\t\tthis.flatShading = source.flatShading;\n\t\tthis.fog = source.fog;\n\t\treturn this;\n\t}\n\n}\n\nclass MeshToonMaterial extends Material {\n\tconstructor(parameters) {\n\t\tsuper();\n\t\tthis.isMeshToonMaterial = true;\n\t\tthis.defines = {\n\t\t\t'TOON': ''\n\t\t};\n\t\tthis.type = 'MeshToonMaterial';\n\t\tthis.color = new Color(0xffffff);\n\t\tthis.map = null;\n\t\tthis.gradientMap = null;\n\t\tthis.lightMap = null;\n\t\tthis.lightMapIntensity = 1.0;\n\t\tthis.aoMap = null;\n\t\tthis.aoMapIntensity = 1.0;\n\t\tthis.emissive = new Color(0x000000);\n\t\tthis.emissiveIntensity = 1.0;\n\t\tthis.emissiveMap = null;\n\t\tthis.bumpMap = null;\n\t\tthis.bumpScale = 1;\n\t\tthis.normalMap = null;\n\t\tthis.normalMapType = TangentSpaceNormalMap;\n\t\tthis.normalScale = new Vector2(1, 1);\n\t\tthis.displacementMap = null;\n\t\tthis.displacementScale = 1;\n\t\tthis.displacementBias = 0;\n\t\tthis.alphaMap = null;\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\t\tthis.wireframeLinecap = 'round';\n\t\tthis.wireframeLinejoin = 'round';\n\t\tthis.fog = true;\n\t\tthis.setValues(parameters);\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.color.copy(source.color);\n\t\tthis.map = source.map;\n\t\tthis.gradientMap = source.gradientMap;\n\t\tthis.lightMap = source.lightMap;\n\t\tthis.lightMapIntensity = source.lightMapIntensity;\n\t\tthis.aoMap = source.aoMap;\n\t\tthis.aoMapIntensity = source.aoMapIntensity;\n\t\tthis.emissive.copy(source.emissive);\n\t\tthis.emissiveMap = source.emissiveMap;\n\t\tthis.emissiveIntensity = source.emissiveIntensity;\n\t\tthis.bumpMap = source.bumpMap;\n\t\tthis.bumpScale = source.bumpScale;\n\t\tthis.normalMap = source.normalMap;\n\t\tthis.normalMapType = source.normalMapType;\n\t\tthis.normalScale.copy(source.normalScale);\n\t\tthis.displacementMap = source.displacementMap;\n\t\tthis.displacementScale = source.displacementScale;\n\t\tthis.displacementBias = source.displacementBias;\n\t\tthis.alphaMap = source.alphaMap;\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\t\tthis.wireframeLinecap = source.wireframeLinecap;\n\t\tthis.wireframeLinejoin = source.wireframeLinejoin;\n\t\tthis.fog = source.fog;\n\t\treturn this;\n\t}\n\n}\n\nclass MeshNormalMaterial extends Material {\n\tconstructor(parameters) {\n\t\tsuper();\n\t\tthis.isMeshNormalMaterial = true;\n\t\tthis.type = 'MeshNormalMaterial';\n\t\tthis.bumpMap = null;\n\t\tthis.bumpScale = 1;\n\t\tthis.normalMap = null;\n\t\tthis.normalMapType = TangentSpaceNormalMap;\n\t\tthis.normalScale = new Vector2(1, 1);\n\t\tthis.displacementMap = null;\n\t\tthis.displacementScale = 1;\n\t\tthis.displacementBias = 0;\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\t\tthis.flatShading = false;\n\t\tthis.setValues(parameters);\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.bumpMap = source.bumpMap;\n\t\tthis.bumpScale = source.bumpScale;\n\t\tthis.normalMap = source.normalMap;\n\t\tthis.normalMapType = source.normalMapType;\n\t\tthis.normalScale.copy(source.normalScale);\n\t\tthis.displacementMap = source.displacementMap;\n\t\tthis.displacementScale = source.displacementScale;\n\t\tthis.displacementBias = source.displacementBias;\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\t\tthis.flatShading = source.flatShading;\n\t\treturn this;\n\t}\n\n}\n\nclass MeshLambertMaterial extends Material {\n\tconstructor(parameters) {\n\t\tsuper();\n\t\tthis.isMeshLambertMaterial = true;\n\t\tthis.type = 'MeshLambertMaterial';\n\t\tthis.color = new Color(0xffffff); // diffuse\n\n\t\tthis.map = null;\n\t\tthis.lightMap = null;\n\t\tthis.lightMapIntensity = 1.0;\n\t\tthis.aoMap = null;\n\t\tthis.aoMapIntensity = 1.0;\n\t\tthis.emissive = new Color(0x000000);\n\t\tthis.emissiveIntensity = 1.0;\n\t\tthis.emissiveMap = null;\n\t\tthis.bumpMap = null;\n\t\tthis.bumpScale = 1;\n\t\tthis.normalMap = null;\n\t\tthis.normalMapType = TangentSpaceNormalMap;\n\t\tthis.normalScale = new Vector2(1, 1);\n\t\tthis.displacementMap = null;\n\t\tthis.displacementScale = 1;\n\t\tthis.displacementBias = 0;\n\t\tthis.specularMap = null;\n\t\tthis.alphaMap = null;\n\t\tthis.envMap = null;\n\t\tthis.combine = MultiplyOperation;\n\t\tthis.reflectivity = 1;\n\t\tthis.refractionRatio = 0.98;\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\t\tthis.wireframeLinecap = 'round';\n\t\tthis.wireframeLinejoin = 'round';\n\t\tthis.flatShading = false;\n\t\tthis.fog = true;\n\t\tthis.setValues(parameters);\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.color.copy(source.color);\n\t\tthis.map = source.map;\n\t\tthis.lightMap = source.lightMap;\n\t\tthis.lightMapIntensity = source.lightMapIntensity;\n\t\tthis.aoMap = source.aoMap;\n\t\tthis.aoMapIntensity = source.aoMapIntensity;\n\t\tthis.emissive.copy(source.emissive);\n\t\tthis.emissiveMap = source.emissiveMap;\n\t\tthis.emissiveIntensity = source.emissiveIntensity;\n\t\tthis.bumpMap = source.bumpMap;\n\t\tthis.bumpScale = source.bumpScale;\n\t\tthis.normalMap = source.normalMap;\n\t\tthis.normalMapType = source.normalMapType;\n\t\tthis.normalScale.copy(source.normalScale);\n\t\tthis.displacementMap = source.displacementMap;\n\t\tthis.displacementScale = source.displacementScale;\n\t\tthis.displacementBias = source.displacementBias;\n\t\tthis.specularMap = source.specularMap;\n\t\tthis.alphaMap = source.alphaMap;\n\t\tthis.envMap = source.envMap;\n\t\tthis.combine = source.combine;\n\t\tthis.reflectivity = source.reflectivity;\n\t\tthis.refractionRatio = source.refractionRatio;\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\t\tthis.wireframeLinecap = source.wireframeLinecap;\n\t\tthis.wireframeLinejoin = source.wireframeLinejoin;\n\t\tthis.flatShading = source.flatShading;\n\t\tthis.fog = source.fog;\n\t\treturn this;\n\t}\n\n}\n\nclass MeshMatcapMaterial extends Material {\n\tconstructor(parameters) {\n\t\tsuper();\n\t\tthis.isMeshMatcapMaterial = true;\n\t\tthis.defines = {\n\t\t\t'MATCAP': ''\n\t\t};\n\t\tthis.type = 'MeshMatcapMaterial';\n\t\tthis.color = new Color(0xffffff); // diffuse\n\n\t\tthis.matcap = null;\n\t\tthis.map = null;\n\t\tthis.bumpMap = null;\n\t\tthis.bumpScale = 1;\n\t\tthis.normalMap = null;\n\t\tthis.normalMapType = TangentSpaceNormalMap;\n\t\tthis.normalScale = new Vector2(1, 1);\n\t\tthis.displacementMap = null;\n\t\tthis.displacementScale = 1;\n\t\tthis.displacementBias = 0;\n\t\tthis.alphaMap = null;\n\t\tthis.flatShading = false;\n\t\tthis.fog = true;\n\t\tthis.setValues(parameters);\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.defines = {\n\t\t\t'MATCAP': ''\n\t\t};\n\t\tthis.color.copy(source.color);\n\t\tthis.matcap = source.matcap;\n\t\tthis.map = source.map;\n\t\tthis.bumpMap = source.bumpMap;\n\t\tthis.bumpScale = source.bumpScale;\n\t\tthis.normalMap = source.normalMap;\n\t\tthis.normalMapType = source.normalMapType;\n\t\tthis.normalScale.copy(source.normalScale);\n\t\tthis.displacementMap = source.displacementMap;\n\t\tthis.displacementScale = source.displacementScale;\n\t\tthis.displacementBias = source.displacementBias;\n\t\tthis.alphaMap = source.alphaMap;\n\t\tthis.flatShading = source.flatShading;\n\t\tthis.fog = source.fog;\n\t\treturn this;\n\t}\n\n}\n\nclass LineDashedMaterial extends LineBasicMaterial {\n\tconstructor(parameters) {\n\t\tsuper();\n\t\tthis.isLineDashedMaterial = true;\n\t\tthis.type = 'LineDashedMaterial';\n\t\tthis.scale = 1;\n\t\tthis.dashSize = 3;\n\t\tthis.gapSize = 1;\n\t\tthis.setValues(parameters);\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.scale = source.scale;\n\t\tthis.dashSize = source.dashSize;\n\t\tthis.gapSize = source.gapSize;\n\t\treturn this;\n\t}\n\n}\n\nfunction arraySlice(array, from, to) {\n\tif (isTypedArray(array)) {\n\t\t// in ios9 array.subarray(from, undefined) will return empty array\n\t\t// but array.subarray(from) or array.subarray(from, len) is correct\n\t\treturn new array.constructor(array.subarray(from, to !== undefined ? to : array.length));\n\t}\n\n\treturn array.slice(from, to);\n} // converts an array to a specific type\n\n\nfunction convertArray(array, type, forceClone) {\n\tif (!array || // let 'undefined' and 'null' pass\n\t!forceClone && array.constructor === type) return array;\n\n\tif (typeof type.BYTES_PER_ELEMENT === 'number') {\n\t\treturn new type(array); // create typed array\n\t}\n\n\treturn Array.prototype.slice.call(array); // create Array\n}\n\nfunction isTypedArray(object) {\n\treturn ArrayBuffer.isView(object) && !(object instanceof DataView);\n} // returns an array by which times and values can be sorted\n\n\nfunction getKeyframeOrder(times) {\n\tfunction compareTime(i, j) {\n\t\treturn times[i] - times[j];\n\t}\n\n\tconst n = times.length;\n\tconst result = new Array(n);\n\n\tfor (let i = 0; i !== n; ++i) result[i] = i;\n\n\tresult.sort(compareTime);\n\treturn result;\n} // uses the array previously returned by 'getKeyframeOrder' to sort data\n\n\nfunction sortedArray(values, stride, order) {\n\tconst nValues = values.length;\n\tconst result = new values.constructor(nValues);\n\n\tfor (let i = 0, dstOffset = 0; dstOffset !== nValues; ++i) {\n\t\tconst srcOffset = order[i] * stride;\n\n\t\tfor (let j = 0; j !== stride; ++j) {\n\t\t\tresult[dstOffset++] = values[srcOffset + j];\n\t\t}\n\t}\n\n\treturn result;\n} // function for parsing AOS keyframe formats\n\n\nfunction flattenJSON(jsonKeys, times, values, valuePropertyName) {\n\tlet i = 1,\n\t\t\tkey = jsonKeys[0];\n\n\twhile (key !== undefined && key[valuePropertyName] === undefined) {\n\t\tkey = jsonKeys[i++];\n\t}\n\n\tif (key === undefined) return; // no data\n\n\tlet value = key[valuePropertyName];\n\tif (value === undefined) return; // no data\n\n\tif (Array.isArray(value)) {\n\t\tdo {\n\t\t\tvalue = key[valuePropertyName];\n\n\t\t\tif (value !== undefined) {\n\t\t\t\ttimes.push(key.time);\n\t\t\t\tvalues.push.apply(values, value); // push all elements\n\t\t\t}\n\n\t\t\tkey = jsonKeys[i++];\n\t\t} while (key !== undefined);\n\t} else if (value.toArray !== undefined) {\n\t\t// ...assume THREE.Math-ish\n\t\tdo {\n\t\t\tvalue = key[valuePropertyName];\n\n\t\t\tif (value !== undefined) {\n\t\t\t\ttimes.push(key.time);\n\t\t\t\tvalue.toArray(values, values.length);\n\t\t\t}\n\n\t\t\tkey = jsonKeys[i++];\n\t\t} while (key !== undefined);\n\t} else {\n\t\t// otherwise push as-is\n\t\tdo {\n\t\t\tvalue = key[valuePropertyName];\n\n\t\t\tif (value !== undefined) {\n\t\t\t\ttimes.push(key.time);\n\t\t\t\tvalues.push(value);\n\t\t\t}\n\n\t\t\tkey = jsonKeys[i++];\n\t\t} while (key !== undefined);\n\t}\n}\n\nfunction subclip(sourceClip, name, startFrame, endFrame, fps = 30) {\n\tconst clip = sourceClip.clone();\n\tclip.name = name;\n\tconst tracks = [];\n\n\tfor (let i = 0; i < clip.tracks.length; ++i) {\n\t\tconst track = clip.tracks[i];\n\t\tconst valueSize = track.getValueSize();\n\t\tconst times = [];\n\t\tconst values = [];\n\n\t\tfor (let j = 0; j < track.times.length; ++j) {\n\t\t\tconst frame = track.times[j] * fps;\n\t\t\tif (frame < startFrame || frame >= endFrame) continue;\n\t\t\ttimes.push(track.times[j]);\n\n\t\t\tfor (let k = 0; k < valueSize; ++k) {\n\t\t\t\tvalues.push(track.values[j * valueSize + k]);\n\t\t\t}\n\t\t}\n\n\t\tif (times.length === 0) continue;\n\t\ttrack.times = convertArray(times, track.times.constructor);\n\t\ttrack.values = convertArray(values, track.values.constructor);\n\t\ttracks.push(track);\n\t}\n\n\tclip.tracks = tracks; // find minimum .times value across all tracks in the trimmed clip\n\n\tlet minStartTime = Infinity;\n\n\tfor (let i = 0; i < clip.tracks.length; ++i) {\n\t\tif (minStartTime > clip.tracks[i].times[0]) {\n\t\t\tminStartTime = clip.tracks[i].times[0];\n\t\t}\n\t} // shift all tracks such that clip begins at t=0\n\n\n\tfor (let i = 0; i < clip.tracks.length; ++i) {\n\t\tclip.tracks[i].shift(-1 * minStartTime);\n\t}\n\n\tclip.resetDuration();\n\treturn clip;\n}\n\nfunction makeClipAdditive(targetClip, referenceFrame = 0, referenceClip = targetClip, fps = 30) {\n\tif (fps <= 0) fps = 30;\n\tconst numTracks = referenceClip.tracks.length;\n\tconst referenceTime = referenceFrame / fps; // Make each track's values relative to the values at the reference frame\n\n\tfor (let i = 0; i < numTracks; ++i) {\n\t\tconst referenceTrack = referenceClip.tracks[i];\n\t\tconst referenceTrackType = referenceTrack.ValueTypeName; // Skip this track if it's non-numeric\n\n\t\tif (referenceTrackType === 'bool' || referenceTrackType === 'string') continue; // Find the track in the target clip whose name and type matches the reference track\n\n\t\tconst targetTrack = targetClip.tracks.find(function (track) {\n\t\t\treturn track.name === referenceTrack.name && track.ValueTypeName === referenceTrackType;\n\t\t});\n\t\tif (targetTrack === undefined) continue;\n\t\tlet referenceOffset = 0;\n\t\tconst referenceValueSize = referenceTrack.getValueSize();\n\n\t\tif (referenceTrack.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline) {\n\t\t\treferenceOffset = referenceValueSize / 3;\n\t\t}\n\n\t\tlet targetOffset = 0;\n\t\tconst targetValueSize = targetTrack.getValueSize();\n\n\t\tif (targetTrack.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline) {\n\t\t\ttargetOffset = targetValueSize / 3;\n\t\t}\n\n\t\tconst lastIndex = referenceTrack.times.length - 1;\n\t\tlet referenceValue; // Find the value to subtract out of the track\n\n\t\tif (referenceTime <= referenceTrack.times[0]) {\n\t\t\t// Reference frame is earlier than the first keyframe, so just use the first keyframe\n\t\t\tconst startIndex = referenceOffset;\n\t\t\tconst endIndex = referenceValueSize - referenceOffset;\n\t\t\treferenceValue = arraySlice(referenceTrack.values, startIndex, endIndex);\n\t\t} else if (referenceTime >= referenceTrack.times[lastIndex]) {\n\t\t\t// Reference frame is after the last keyframe, so just use the last keyframe\n\t\t\tconst startIndex = lastIndex * referenceValueSize + referenceOffset;\n\t\t\tconst endIndex = startIndex + referenceValueSize - referenceOffset;\n\t\t\treferenceValue = arraySlice(referenceTrack.values, startIndex, endIndex);\n\t\t} else {\n\t\t\t// Interpolate to the reference value\n\t\t\tconst interpolant = referenceTrack.createInterpolant();\n\t\t\tconst startIndex = referenceOffset;\n\t\t\tconst endIndex = referenceValueSize - referenceOffset;\n\t\t\tinterpolant.evaluate(referenceTime);\n\t\t\treferenceValue = arraySlice(interpolant.resultBuffer, startIndex, endIndex);\n\t\t} // Conjugate the quaternion\n\n\n\t\tif (referenceTrackType === 'quaternion') {\n\t\t\tconst referenceQuat = new Quaternion().fromArray(referenceValue).normalize().conjugate();\n\t\t\treferenceQuat.toArray(referenceValue);\n\t\t} // Subtract the reference value from all of the track values\n\n\n\t\tconst numTimes = targetTrack.times.length;\n\n\t\tfor (let j = 0; j < numTimes; ++j) {\n\t\t\tconst valueStart = j * targetValueSize + targetOffset;\n\n\t\t\tif (referenceTrackType === 'quaternion') {\n\t\t\t\t// Multiply the conjugate for quaternion track types\n\t\t\t\tQuaternion.multiplyQuaternionsFlat(targetTrack.values, valueStart, referenceValue, 0, targetTrack.values, valueStart);\n\t\t\t} else {\n\t\t\t\tconst valueEnd = targetValueSize - targetOffset * 2; // Subtract each value for all other numeric track types\n\n\t\t\t\tfor (let k = 0; k < valueEnd; ++k) {\n\t\t\t\t\ttargetTrack.values[valueStart + k] -= referenceValue[k];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\ttargetClip.blendMode = AdditiveAnimationBlendMode;\n\treturn targetClip;\n}\n\nvar AnimationUtils = /*#__PURE__*/Object.freeze({\n\t__proto__: null,\n\tarraySlice: arraySlice,\n\tconvertArray: convertArray,\n\tisTypedArray: isTypedArray,\n\tgetKeyframeOrder: getKeyframeOrder,\n\tsortedArray: sortedArray,\n\tflattenJSON: flattenJSON,\n\tsubclip: subclip,\n\tmakeClipAdditive: makeClipAdditive\n});\n\n/**\n * Abstract base class of interpolants over parametric samples.\n *\n * The parameter domain is one dimensional, typically the time or a path\n * along a curve defined by the data.\n *\n * The sample values can have any dimensionality and derived classes may\n * apply special interpretations to the data.\n *\n * This class provides the interval seek in a Template Method, deferring\n * the actual interpolation to derived classes.\n *\n * Time complexity is O(1) for linear access crossing at most two points\n * and O(log N) for random access, where N is the number of positions.\n *\n * References:\n *\n * \t\thttp://www.oodesign.com/template-method-pattern.html\n *\n */\nclass Interpolant {\n\tconstructor(parameterPositions, sampleValues, sampleSize, resultBuffer) {\n\t\tthis.parameterPositions = parameterPositions;\n\t\tthis._cachedIndex = 0;\n\t\tthis.resultBuffer = resultBuffer !== undefined ? resultBuffer : new sampleValues.constructor(sampleSize);\n\t\tthis.sampleValues = sampleValues;\n\t\tthis.valueSize = sampleSize;\n\t\tthis.settings = null;\n\t\tthis.DefaultSettings_ = {};\n\t}\n\n\tevaluate(t) {\n\t\tconst pp = this.parameterPositions;\n\t\tlet i1 = this._cachedIndex,\n\t\t\t\tt1 = pp[i1],\n\t\t\t\tt0 = pp[i1 - 1];\n\n\t\tvalidate_interval: {\n\t\t\tseek: {\n\t\t\t\tlet right;\n\n\t\t\t\tlinear_scan: {\n\t\t\t\t\t//- See http://jsperf.com/comparison-to-undefined/3\n\t\t\t\t\t//- slower code:\n\t\t\t\t\t//-\n\t\t\t\t\t//- \t\t\t\tif ( t >= t1 || t1 === undefined ) {\n\t\t\t\t\tforward_scan: if (!(t < t1)) {\n\t\t\t\t\t\tfor (let giveUpAt = i1 + 2;;) {\n\t\t\t\t\t\t\tif (t1 === undefined) {\n\t\t\t\t\t\t\t\tif (t < t0) break forward_scan; // after end\n\n\t\t\t\t\t\t\t\ti1 = pp.length;\n\t\t\t\t\t\t\t\tthis._cachedIndex = i1;\n\t\t\t\t\t\t\t\treturn this.copySampleValue_(i1 - 1);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (i1 === giveUpAt) break; // this loop\n\n\t\t\t\t\t\t\tt0 = t1;\n\t\t\t\t\t\t\tt1 = pp[++i1];\n\n\t\t\t\t\t\t\tif (t < t1) {\n\t\t\t\t\t\t\t\t// we have arrived at the sought interval\n\t\t\t\t\t\t\t\tbreak seek;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} // prepare binary search on the right side of the index\n\n\n\t\t\t\t\t\tright = pp.length;\n\t\t\t\t\t\tbreak linear_scan;\n\t\t\t\t\t} //- slower code:\n\t\t\t\t\t//-\t\t\t\t\tif ( t < t0 || t0 === undefined ) {\n\n\n\t\t\t\t\tif (!(t >= t0)) {\n\t\t\t\t\t\t// looping?\n\t\t\t\t\t\tconst t1global = pp[1];\n\n\t\t\t\t\t\tif (t < t1global) {\n\t\t\t\t\t\t\ti1 = 2; // + 1, using the scan for the details\n\n\t\t\t\t\t\t\tt0 = t1global;\n\t\t\t\t\t\t} // linear reverse scan\n\n\n\t\t\t\t\t\tfor (let giveUpAt = i1 - 2;;) {\n\t\t\t\t\t\t\tif (t0 === undefined) {\n\t\t\t\t\t\t\t\t// before start\n\t\t\t\t\t\t\t\tthis._cachedIndex = 0;\n\t\t\t\t\t\t\t\treturn this.copySampleValue_(0);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (i1 === giveUpAt) break; // this loop\n\n\t\t\t\t\t\t\tt1 = t0;\n\t\t\t\t\t\t\tt0 = pp[--i1 - 1];\n\n\t\t\t\t\t\t\tif (t >= t0) {\n\t\t\t\t\t\t\t\t// we have arrived at the sought interval\n\t\t\t\t\t\t\t\tbreak seek;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} // prepare binary search on the left side of the index\n\n\n\t\t\t\t\t\tright = i1;\n\t\t\t\t\t\ti1 = 0;\n\t\t\t\t\t\tbreak linear_scan;\n\t\t\t\t\t} // the interval is valid\n\n\n\t\t\t\t\tbreak validate_interval;\n\t\t\t\t} // linear scan\n\t\t\t\t// binary search\n\n\n\t\t\t\twhile (i1 < right) {\n\t\t\t\t\tconst mid = i1 + right >>> 1;\n\n\t\t\t\t\tif (t < pp[mid]) {\n\t\t\t\t\t\tright = mid;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ti1 = mid + 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tt1 = pp[i1];\n\t\t\t\tt0 = pp[i1 - 1]; // check boundary cases, again\n\n\t\t\t\tif (t0 === undefined) {\n\t\t\t\t\tthis._cachedIndex = 0;\n\t\t\t\t\treturn this.copySampleValue_(0);\n\t\t\t\t}\n\n\t\t\t\tif (t1 === undefined) {\n\t\t\t\t\ti1 = pp.length;\n\t\t\t\t\tthis._cachedIndex = i1;\n\t\t\t\t\treturn this.copySampleValue_(i1 - 1);\n\t\t\t\t}\n\t\t\t} // seek\n\n\n\t\t\tthis._cachedIndex = i1;\n\t\t\tthis.intervalChanged_(i1, t0, t1);\n\t\t} // validate_interval\n\n\n\t\treturn this.interpolate_(i1, t0, t, t1);\n\t}\n\n\tgetSettings_() {\n\t\treturn this.settings || this.DefaultSettings_;\n\t}\n\n\tcopySampleValue_(index) {\n\t\t// copies a sample value to the result buffer\n\t\tconst result = this.resultBuffer,\n\t\t\t\t\tvalues = this.sampleValues,\n\t\t\t\t\tstride = this.valueSize,\n\t\t\t\t\toffset = index * stride;\n\n\t\tfor (let i = 0; i !== stride; ++i) {\n\t\t\tresult[i] = values[offset + i];\n\t\t}\n\n\t\treturn result;\n\t} // Template methods for derived classes:\n\n\n\tinterpolate_() {\n\t\tthrow new Error('call to abstract method'); // implementations shall return this.resultBuffer\n\t}\n\n\tintervalChanged_() {// empty\n\t}\n\n}\n\n/**\n * Fast and simple cubic spline interpolant.\n *\n * It was derived from a Hermitian construction setting the first derivative\n * at each sample position to the linear slope between neighboring positions\n * over their parameter interval.\n */\n\nclass CubicInterpolant extends Interpolant {\n\tconstructor(parameterPositions, sampleValues, sampleSize, resultBuffer) {\n\t\tsuper(parameterPositions, sampleValues, sampleSize, resultBuffer);\n\t\tthis._weightPrev = -0;\n\t\tthis._offsetPrev = -0;\n\t\tthis._weightNext = -0;\n\t\tthis._offsetNext = -0;\n\t\tthis.DefaultSettings_ = {\n\t\t\tendingStart: ZeroCurvatureEnding,\n\t\t\tendingEnd: ZeroCurvatureEnding\n\t\t};\n\t}\n\n\tintervalChanged_(i1, t0, t1) {\n\t\tconst pp = this.parameterPositions;\n\t\tlet iPrev = i1 - 2,\n\t\t\t\tiNext = i1 + 1,\n\t\t\t\ttPrev = pp[iPrev],\n\t\t\t\ttNext = pp[iNext];\n\n\t\tif (tPrev === undefined) {\n\t\t\tswitch (this.getSettings_().endingStart) {\n\t\t\t\tcase ZeroSlopeEnding:\n\t\t\t\t\t// f'(t0) = 0\n\t\t\t\t\tiPrev = i1;\n\t\t\t\t\ttPrev = 2 * t0 - t1;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase WrapAroundEnding:\n\t\t\t\t\t// use the other end of the curve\n\t\t\t\t\tiPrev = pp.length - 2;\n\t\t\t\t\ttPrev = t0 + pp[iPrev] - pp[iPrev + 1];\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\t// ZeroCurvatureEnding\n\t\t\t\t\t// f''(t0) = 0 a.k.a. Natural Spline\n\t\t\t\t\tiPrev = i1;\n\t\t\t\t\ttPrev = t1;\n\t\t\t}\n\t\t}\n\n\t\tif (tNext === undefined) {\n\t\t\tswitch (this.getSettings_().endingEnd) {\n\t\t\t\tcase ZeroSlopeEnding:\n\t\t\t\t\t// f'(tN) = 0\n\t\t\t\t\tiNext = i1;\n\t\t\t\t\ttNext = 2 * t1 - t0;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase WrapAroundEnding:\n\t\t\t\t\t// use the other end of the curve\n\t\t\t\t\tiNext = 1;\n\t\t\t\t\ttNext = t1 + pp[1] - pp[0];\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\t// ZeroCurvatureEnding\n\t\t\t\t\t// f''(tN) = 0, a.k.a. Natural Spline\n\t\t\t\t\tiNext = i1 - 1;\n\t\t\t\t\ttNext = t0;\n\t\t\t}\n\t\t}\n\n\t\tconst halfDt = (t1 - t0) * 0.5,\n\t\t\t\t\tstride = this.valueSize;\n\t\tthis._weightPrev = halfDt / (t0 - tPrev);\n\t\tthis._weightNext = halfDt / (tNext - t1);\n\t\tthis._offsetPrev = iPrev * stride;\n\t\tthis._offsetNext = iNext * stride;\n\t}\n\n\tinterpolate_(i1, t0, t, t1) {\n\t\tconst result = this.resultBuffer,\n\t\t\t\t\tvalues = this.sampleValues,\n\t\t\t\t\tstride = this.valueSize,\n\t\t\t\t\to1 = i1 * stride,\n\t\t\t\t\to0 = o1 - stride,\n\t\t\t\t\toP = this._offsetPrev,\n\t\t\t\t\toN = this._offsetNext,\n\t\t\t\t\twP = this._weightPrev,\n\t\t\t\t\twN = this._weightNext,\n\t\t\t\t\tp = (t - t0) / (t1 - t0),\n\t\t\t\t\tpp = p * p,\n\t\t\t\t\tppp = pp * p; // evaluate polynomials\n\n\t\tconst sP = -wP * ppp + 2 * wP * pp - wP * p;\n\t\tconst s0 = (1 + wP) * ppp + (-1.5 - 2 * wP) * pp + (-0.5 + wP) * p + 1;\n\t\tconst s1 = (-1 - wN) * ppp + (1.5 + wN) * pp + 0.5 * p;\n\t\tconst sN = wN * ppp - wN * pp; // combine data linearly\n\n\t\tfor (let i = 0; i !== stride; ++i) {\n\t\t\tresult[i] = sP * values[oP + i] + s0 * values[o0 + i] + s1 * values[o1 + i] + sN * values[oN + i];\n\t\t}\n\n\t\treturn result;\n\t}\n\n}\n\nclass LinearInterpolant extends Interpolant {\n\tconstructor(parameterPositions, sampleValues, sampleSize, resultBuffer) {\n\t\tsuper(parameterPositions, sampleValues, sampleSize, resultBuffer);\n\t}\n\n\tinterpolate_(i1, t0, t, t1) {\n\t\tconst result = this.resultBuffer,\n\t\t\t\t\tvalues = this.sampleValues,\n\t\t\t\t\tstride = this.valueSize,\n\t\t\t\t\toffset1 = i1 * stride,\n\t\t\t\t\toffset0 = offset1 - stride,\n\t\t\t\t\tweight1 = (t - t0) / (t1 - t0),\n\t\t\t\t\tweight0 = 1 - weight1;\n\n\t\tfor (let i = 0; i !== stride; ++i) {\n\t\t\tresult[i] = values[offset0 + i] * weight0 + values[offset1 + i] * weight1;\n\t\t}\n\n\t\treturn result;\n\t}\n\n}\n\n/**\n *\n * Interpolant that evaluates to the sample value at the position preceding\n * the parameter.\n */\n\nclass DiscreteInterpolant extends Interpolant {\n\tconstructor(parameterPositions, sampleValues, sampleSize, resultBuffer) {\n\t\tsuper(parameterPositions, sampleValues, sampleSize, resultBuffer);\n\t}\n\n\tinterpolate_(i1\n\t/*, t0, t, t1 */\n\t) {\n\t\treturn this.copySampleValue_(i1 - 1);\n\t}\n\n}\n\nclass KeyframeTrack {\n\tconstructor(name, times, values, interpolation) {\n\t\tif (name === undefined) throw new Error('THREE.KeyframeTrack: track name is undefined');\n\t\tif (times === undefined || times.length === 0) throw new Error('THREE.KeyframeTrack: no keyframes in track named ' + name);\n\t\tthis.name = name;\n\t\tthis.times = convertArray(times, this.TimeBufferType);\n\t\tthis.values = convertArray(values, this.ValueBufferType);\n\t\tthis.setInterpolation(interpolation || this.DefaultInterpolation);\n\t} // Serialization (in static context, because of constructor invocation\n\t// and automatic invocation of .toJSON):\n\n\n\tstatic toJSON(track) {\n\t\tconst trackType = track.constructor;\n\t\tlet json; // derived classes can define a static toJSON method\n\n\t\tif (trackType.toJSON !== this.toJSON) {\n\t\t\tjson = trackType.toJSON(track);\n\t\t} else {\n\t\t\t// by default, we assume the data can be serialized as-is\n\t\t\tjson = {\n\t\t\t\t'name': track.name,\n\t\t\t\t'times': convertArray(track.times, Array),\n\t\t\t\t'values': convertArray(track.values, Array)\n\t\t\t};\n\t\t\tconst interpolation = track.getInterpolation();\n\n\t\t\tif (interpolation !== track.DefaultInterpolation) {\n\t\t\t\tjson.interpolation = interpolation;\n\t\t\t}\n\t\t}\n\n\t\tjson.type = track.ValueTypeName; // mandatory\n\n\t\treturn json;\n\t}\n\n\tInterpolantFactoryMethodDiscrete(result) {\n\t\treturn new DiscreteInterpolant(this.times, this.values, this.getValueSize(), result);\n\t}\n\n\tInterpolantFactoryMethodLinear(result) {\n\t\treturn new LinearInterpolant(this.times, this.values, this.getValueSize(), result);\n\t}\n\n\tInterpolantFactoryMethodSmooth(result) {\n\t\treturn new CubicInterpolant(this.times, this.values, this.getValueSize(), result);\n\t}\n\n\tsetInterpolation(interpolation) {\n\t\tlet factoryMethod;\n\n\t\tswitch (interpolation) {\n\t\t\tcase InterpolateDiscrete:\n\t\t\t\tfactoryMethod = this.InterpolantFactoryMethodDiscrete;\n\t\t\t\tbreak;\n\n\t\t\tcase InterpolateLinear:\n\t\t\t\tfactoryMethod = this.InterpolantFactoryMethodLinear;\n\t\t\t\tbreak;\n\n\t\t\tcase InterpolateSmooth:\n\t\t\t\tfactoryMethod = this.InterpolantFactoryMethodSmooth;\n\t\t\t\tbreak;\n\t\t}\n\n\t\tif (factoryMethod === undefined) {\n\t\t\tconst message = 'unsupported interpolation for ' + this.ValueTypeName + ' keyframe track named ' + this.name;\n\n\t\t\tif (this.createInterpolant === undefined) {\n\t\t\t\t// fall back to default, unless the default itself is messed up\n\t\t\t\tif (interpolation !== this.DefaultInterpolation) {\n\t\t\t\t\tthis.setInterpolation(this.DefaultInterpolation);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(message); // fatal, in this case\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconsole.warn('THREE.KeyframeTrack:', message);\n\t\t\treturn this;\n\t\t}\n\n\t\tthis.createInterpolant = factoryMethod;\n\t\treturn this;\n\t}\n\n\tgetInterpolation() {\n\t\tswitch (this.createInterpolant) {\n\t\t\tcase this.InterpolantFactoryMethodDiscrete:\n\t\t\t\treturn InterpolateDiscrete;\n\n\t\t\tcase this.InterpolantFactoryMethodLinear:\n\t\t\t\treturn InterpolateLinear;\n\n\t\t\tcase this.InterpolantFactoryMethodSmooth:\n\t\t\t\treturn InterpolateSmooth;\n\t\t}\n\t}\n\n\tgetValueSize() {\n\t\treturn this.values.length / this.times.length;\n\t} // move all keyframes either forwards or backwards in time\n\n\n\tshift(timeOffset) {\n\t\tif (timeOffset !== 0.0) {\n\t\t\tconst times = this.times;\n\n\t\t\tfor (let i = 0, n = times.length; i !== n; ++i) {\n\t\t\t\ttimes[i] += timeOffset;\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t} // scale all keyframe times by a factor (useful for frame <-> seconds conversions)\n\n\n\tscale(timeScale) {\n\t\tif (timeScale !== 1.0) {\n\t\t\tconst times = this.times;\n\n\t\t\tfor (let i = 0, n = times.length; i !== n; ++i) {\n\t\t\t\ttimes[i] *= timeScale;\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t} // removes keyframes before and after animation without changing any values within the range [startTime, endTime].\n\t// IMPORTANT: We do not shift around keys to the start of the track time, because for interpolated keys this will change their values\n\n\n\ttrim(startTime, endTime) {\n\t\tconst times = this.times,\n\t\t\t\t\tnKeys = times.length;\n\t\tlet from = 0,\n\t\t\t\tto = nKeys - 1;\n\n\t\twhile (from !== nKeys && times[from] < startTime) {\n\t\t\t++from;\n\t\t}\n\n\t\twhile (to !== -1 && times[to] > endTime) {\n\t\t\t--to;\n\t\t}\n\n\t\t++to; // inclusive -> exclusive bound\n\n\t\tif (from !== 0 || to !== nKeys) {\n\t\t\t// empty tracks are forbidden, so keep at least one keyframe\n\t\t\tif (from >= to) {\n\t\t\t\tto = Math.max(to, 1);\n\t\t\t\tfrom = to - 1;\n\t\t\t}\n\n\t\t\tconst stride = this.getValueSize();\n\t\t\tthis.times = arraySlice(times, from, to);\n\t\t\tthis.values = arraySlice(this.values, from * stride, to * stride);\n\t\t}\n\n\t\treturn this;\n\t} // ensure we do not get a GarbageInGarbageOut situation, make sure tracks are at least minimally viable\n\n\n\tvalidate() {\n\t\tlet valid = true;\n\t\tconst valueSize = this.getValueSize();\n\n\t\tif (valueSize - Math.floor(valueSize) !== 0) {\n\t\t\tconsole.error('THREE.KeyframeTrack: Invalid value size in track.', this);\n\t\t\tvalid = false;\n\t\t}\n\n\t\tconst times = this.times,\n\t\t\t\t\tvalues = this.values,\n\t\t\t\t\tnKeys = times.length;\n\n\t\tif (nKeys === 0) {\n\t\t\tconsole.error('THREE.KeyframeTrack: Track is empty.', this);\n\t\t\tvalid = false;\n\t\t}\n\n\t\tlet prevTime = null;\n\n\t\tfor (let i = 0; i !== nKeys; i++) {\n\t\t\tconst currTime = times[i];\n\n\t\t\tif (typeof currTime === 'number' && isNaN(currTime)) {\n\t\t\t\tconsole.error('THREE.KeyframeTrack: Time is not a valid number.', this, i, currTime);\n\t\t\t\tvalid = false;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (prevTime !== null && prevTime > currTime) {\n\t\t\t\tconsole.error('THREE.KeyframeTrack: Out of order keys.', this, i, currTime, prevTime);\n\t\t\t\tvalid = false;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tprevTime = currTime;\n\t\t}\n\n\t\tif (values !== undefined) {\n\t\t\tif (isTypedArray(values)) {\n\t\t\t\tfor (let i = 0, n = values.length; i !== n; ++i) {\n\t\t\t\t\tconst value = values[i];\n\n\t\t\t\t\tif (isNaN(value)) {\n\t\t\t\t\t\tconsole.error('THREE.KeyframeTrack: Value is not a valid number.', this, i, value);\n\t\t\t\t\t\tvalid = false;\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\n\t\treturn valid;\n\t} // removes equivalent sequential keys as common in morph target sequences\n\t// (0,0,0,0,1,1,1,0,0,0,0,0,0,0) --> (0,0,1,1,0,0)\n\n\n\toptimize() {\n\t\t// times or values may be shared with other tracks, so overwriting is unsafe\n\t\tconst times = arraySlice(this.times),\n\t\t\t\t\tvalues = arraySlice(this.values),\n\t\t\t\t\tstride = this.getValueSize(),\n\t\t\t\t\tsmoothInterpolation = this.getInterpolation() === InterpolateSmooth,\n\t\t\t\t\tlastIndex = times.length - 1;\n\t\tlet writeIndex = 1;\n\n\t\tfor (let i = 1; i < lastIndex; ++i) {\n\t\t\tlet keep = false;\n\t\t\tconst time = times[i];\n\t\t\tconst timeNext = times[i + 1]; // remove adjacent keyframes scheduled at the same time\n\n\t\t\tif (time !== timeNext && (i !== 1 || time !== times[0])) {\n\t\t\t\tif (!smoothInterpolation) {\n\t\t\t\t\t// remove unnecessary keyframes same as their neighbors\n\t\t\t\t\tconst offset = i * stride,\n\t\t\t\t\t\t\t\toffsetP = offset - stride,\n\t\t\t\t\t\t\t\toffsetN = offset + stride;\n\n\t\t\t\t\tfor (let j = 0; j !== stride; ++j) {\n\t\t\t\t\t\tconst value = values[offset + j];\n\n\t\t\t\t\t\tif (value !== values[offsetP + j] || value !== values[offsetN + j]) {\n\t\t\t\t\t\t\tkeep = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tkeep = true;\n\t\t\t\t}\n\t\t\t} // in-place compaction\n\n\n\t\t\tif (keep) {\n\t\t\t\tif (i !== writeIndex) {\n\t\t\t\t\ttimes[writeIndex] = times[i];\n\t\t\t\t\tconst readOffset = i * stride,\n\t\t\t\t\t\t\t\twriteOffset = writeIndex * stride;\n\n\t\t\t\t\tfor (let j = 0; j !== stride; ++j) {\n\t\t\t\t\t\tvalues[writeOffset + j] = values[readOffset + j];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t++writeIndex;\n\t\t\t}\n\t\t} // flush last keyframe (compaction looks ahead)\n\n\n\t\tif (lastIndex > 0) {\n\t\t\ttimes[writeIndex] = times[lastIndex];\n\n\t\t\tfor (let readOffset = lastIndex * stride, writeOffset = writeIndex * stride, j = 0; j !== stride; ++j) {\n\t\t\t\tvalues[writeOffset + j] = values[readOffset + j];\n\t\t\t}\n\n\t\t\t++writeIndex;\n\t\t}\n\n\t\tif (writeIndex !== times.length) {\n\t\t\tthis.times = arraySlice(times, 0, writeIndex);\n\t\t\tthis.values = arraySlice(values, 0, writeIndex * stride);\n\t\t} else {\n\t\t\tthis.times = times;\n\t\t\tthis.values = values;\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\tconst times = arraySlice(this.times, 0);\n\t\tconst values = arraySlice(this.values, 0);\n\t\tconst TypedKeyframeTrack = this.constructor;\n\t\tconst track = new TypedKeyframeTrack(this.name, times, values); // Interpolant argument to constructor is not saved, so copy the factory method directly.\n\n\t\ttrack.createInterpolant = this.createInterpolant;\n\t\treturn track;\n\t}\n\n}\n\nKeyframeTrack.prototype.TimeBufferType = Float32Array;\nKeyframeTrack.prototype.ValueBufferType = Float32Array;\nKeyframeTrack.prototype.DefaultInterpolation = InterpolateLinear;\n\n/**\n * A Track of Boolean keyframe values.\n */\n\nclass BooleanKeyframeTrack extends KeyframeTrack {}\n\nBooleanKeyframeTrack.prototype.ValueTypeName = 'bool';\nBooleanKeyframeTrack.prototype.ValueBufferType = Array;\nBooleanKeyframeTrack.prototype.DefaultInterpolation = InterpolateDiscrete;\nBooleanKeyframeTrack.prototype.InterpolantFactoryMethodLinear = undefined;\nBooleanKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined; // Note: Actually this track could have a optimized / compressed\n\n/**\n * A Track of keyframe values that represent color.\n */\n\nclass ColorKeyframeTrack extends KeyframeTrack {}\n\nColorKeyframeTrack.prototype.ValueTypeName = 'color'; // ValueBufferType is inherited\n\n/**\n * A Track of numeric keyframe values.\n */\n\nclass NumberKeyframeTrack extends KeyframeTrack {}\n\nNumberKeyframeTrack.prototype.ValueTypeName = 'number'; // ValueBufferType is inherited\n\n/**\n * Spherical linear unit quaternion interpolant.\n */\n\nclass QuaternionLinearInterpolant extends Interpolant {\n\tconstructor(parameterPositions, sampleValues, sampleSize, resultBuffer) {\n\t\tsuper(parameterPositions, sampleValues, sampleSize, resultBuffer);\n\t}\n\n\tinterpolate_(i1, t0, t, t1) {\n\t\tconst result = this.resultBuffer,\n\t\t\t\t\tvalues = this.sampleValues,\n\t\t\t\t\tstride = this.valueSize,\n\t\t\t\t\talpha = (t - t0) / (t1 - t0);\n\t\tlet offset = i1 * stride;\n\n\t\tfor (let end = offset + stride; offset !== end; offset += 4) {\n\t\t\tQuaternion.slerpFlat(result, 0, values, offset - stride, values, offset, alpha);\n\t\t}\n\n\t\treturn result;\n\t}\n\n}\n\n/**\n * A Track of quaternion keyframe values.\n */\n\nclass QuaternionKeyframeTrack extends KeyframeTrack {\n\tInterpolantFactoryMethodLinear(result) {\n\t\treturn new QuaternionLinearInterpolant(this.times, this.values, this.getValueSize(), result);\n\t}\n\n}\n\nQuaternionKeyframeTrack.prototype.ValueTypeName = 'quaternion'; // ValueBufferType is inherited\n\nQuaternionKeyframeTrack.prototype.DefaultInterpolation = InterpolateLinear;\nQuaternionKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined;\n\n/**\n * A Track that interpolates Strings\n */\n\nclass StringKeyframeTrack extends KeyframeTrack {}\n\nStringKeyframeTrack.prototype.ValueTypeName = 'string';\nStringKeyframeTrack.prototype.ValueBufferType = Array;\nStringKeyframeTrack.prototype.DefaultInterpolation = InterpolateDiscrete;\nStringKeyframeTrack.prototype.InterpolantFactoryMethodLinear = undefined;\nStringKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined;\n\n/**\n * A Track of vectored keyframe values.\n */\n\nclass VectorKeyframeTrack extends KeyframeTrack {}\n\nVectorKeyframeTrack.prototype.ValueTypeName = 'vector'; // ValueBufferType is inherited\n\nclass AnimationClip {\n\tconstructor(name, duration = -1, tracks, blendMode = NormalAnimationBlendMode) {\n\t\tthis.name = name;\n\t\tthis.tracks = tracks;\n\t\tthis.duration = duration;\n\t\tthis.blendMode = blendMode;\n\t\tthis.uuid = generateUUID(); // this means it should figure out its duration by scanning the tracks\n\n\t\tif (this.duration < 0) {\n\t\t\tthis.resetDuration();\n\t\t}\n\t}\n\n\tstatic parse(json) {\n\t\tconst tracks = [],\n\t\t\t\t\tjsonTracks = json.tracks,\n\t\t\t\t\tframeTime = 1.0 / (json.fps || 1.0);\n\n\t\tfor (let i = 0, n = jsonTracks.length; i !== n; ++i) {\n\t\t\ttracks.push(parseKeyframeTrack(jsonTracks[i]).scale(frameTime));\n\t\t}\n\n\t\tconst clip = new this(json.name, json.duration, tracks, json.blendMode);\n\t\tclip.uuid = json.uuid;\n\t\treturn clip;\n\t}\n\n\tstatic toJSON(clip) {\n\t\tconst tracks = [],\n\t\t\t\t\tclipTracks = clip.tracks;\n\t\tconst json = {\n\t\t\t'name': clip.name,\n\t\t\t'duration': clip.duration,\n\t\t\t'tracks': tracks,\n\t\t\t'uuid': clip.uuid,\n\t\t\t'blendMode': clip.blendMode\n\t\t};\n\n\t\tfor (let i = 0, n = clipTracks.length; i !== n; ++i) {\n\t\t\ttracks.push(KeyframeTrack.toJSON(clipTracks[i]));\n\t\t}\n\n\t\treturn json;\n\t}\n\n\tstatic CreateFromMorphTargetSequence(name, morphTargetSequence, fps, noLoop) {\n\t\tconst numMorphTargets = morphTargetSequence.length;\n\t\tconst tracks = [];\n\n\t\tfor (let i = 0; i < numMorphTargets; i++) {\n\t\t\tlet times = [];\n\t\t\tlet values = [];\n\t\t\ttimes.push((i + numMorphTargets - 1) % numMorphTargets, i, (i + 1) % numMorphTargets);\n\t\t\tvalues.push(0, 1, 0);\n\t\t\tconst order = getKeyframeOrder(times);\n\t\t\ttimes = sortedArray(times, 1, order);\n\t\t\tvalues = sortedArray(values, 1, order); // if there is a key at the first frame, duplicate it as the\n\t\t\t// last frame as well for perfect loop.\n\n\t\t\tif (!noLoop && times[0] === 0) {\n\t\t\t\ttimes.push(numMorphTargets);\n\t\t\t\tvalues.push(values[0]);\n\t\t\t}\n\n\t\t\ttracks.push(new NumberKeyframeTrack('.morphTargetInfluences[' + morphTargetSequence[i].name + ']', times, values).scale(1.0 / fps));\n\t\t}\n\n\t\treturn new this(name, -1, tracks);\n\t}\n\n\tstatic findByName(objectOrClipArray, name) {\n\t\tlet clipArray = objectOrClipArray;\n\n\t\tif (!Array.isArray(objectOrClipArray)) {\n\t\t\tconst o = objectOrClipArray;\n\t\t\tclipArray = o.geometry && o.geometry.animations || o.animations;\n\t\t}\n\n\t\tfor (let i = 0; i < clipArray.length; i++) {\n\t\t\tif (clipArray[i].name === name) {\n\t\t\t\treturn clipArray[i];\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tstatic CreateClipsFromMorphTargetSequences(morphTargets, fps, noLoop) {\n\t\tconst animationToMorphTargets = {}; // tested with https://regex101.com/ on trick sequences\n\t\t// such flamingo_flyA_003, flamingo_run1_003, crdeath0059\n\n\t\tconst pattern = /^([\\w-]*?)([\\d]+)$/; // sort morph target names into animation groups based\n\t\t// patterns like Walk_001, Walk_002, Run_001, Run_002\n\n\t\tfor (let i = 0, il = morphTargets.length; i < il; i++) {\n\t\t\tconst morphTarget = morphTargets[i];\n\t\t\tconst parts = morphTarget.name.match(pattern);\n\n\t\t\tif (parts && parts.length > 1) {\n\t\t\t\tconst name = parts[1];\n\t\t\t\tlet animationMorphTargets = animationToMorphTargets[name];\n\n\t\t\t\tif (!animationMorphTargets) {\n\t\t\t\t\tanimationToMorphTargets[name] = animationMorphTargets = [];\n\t\t\t\t}\n\n\t\t\t\tanimationMorphTargets.push(morphTarget);\n\t\t\t}\n\t\t}\n\n\t\tconst clips = [];\n\n\t\tfor (const name in animationToMorphTargets) {\n\t\t\tclips.push(this.CreateFromMorphTargetSequence(name, animationToMorphTargets[name], fps, noLoop));\n\t\t}\n\n\t\treturn clips;\n\t} // parse the animation.hierarchy format\n\n\n\tstatic parseAnimation(animation, bones) {\n\t\tif (!animation) {\n\t\t\tconsole.error('THREE.AnimationClip: No animation in JSONLoader data.');\n\t\t\treturn null;\n\t\t}\n\n\t\tconst addNonemptyTrack = function (trackType, trackName, animationKeys, propertyName, destTracks) {\n\t\t\t// only return track if there are actually keys.\n\t\t\tif (animationKeys.length !== 0) {\n\t\t\t\tconst times = [];\n\t\t\t\tconst values = [];\n\t\t\t\tflattenJSON(animationKeys, times, values, propertyName); // empty keys are filtered out, so check again\n\n\t\t\t\tif (times.length !== 0) {\n\t\t\t\t\tdestTracks.push(new trackType(trackName, times, values));\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tconst tracks = [];\n\t\tconst clipName = animation.name || 'default';\n\t\tconst fps = animation.fps || 30;\n\t\tconst blendMode = animation.blendMode; // automatic length determination in AnimationClip.\n\n\t\tlet duration = animation.length || -1;\n\t\tconst hierarchyTracks = animation.hierarchy || [];\n\n\t\tfor (let h = 0; h < hierarchyTracks.length; h++) {\n\t\t\tconst animationKeys = hierarchyTracks[h].keys; // skip empty tracks\n\n\t\t\tif (!animationKeys || animationKeys.length === 0) continue; // process morph targets\n\n\t\t\tif (animationKeys[0].morphTargets) {\n\t\t\t\t// figure out all morph targets used in this track\n\t\t\t\tconst morphTargetNames = {};\n\t\t\t\tlet k;\n\n\t\t\t\tfor (k = 0; k < animationKeys.length; k++) {\n\t\t\t\t\tif (animationKeys[k].morphTargets) {\n\t\t\t\t\t\tfor (let m = 0; m < animationKeys[k].morphTargets.length; m++) {\n\t\t\t\t\t\t\tmorphTargetNames[animationKeys[k].morphTargets[m]] = -1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} // create a track for each morph target with all zero\n\t\t\t\t// morphTargetInfluences except for the keys in which\n\t\t\t\t// the morphTarget is named.\n\n\n\t\t\t\tfor (const morphTargetName in morphTargetNames) {\n\t\t\t\t\tconst times = [];\n\t\t\t\t\tconst values = [];\n\n\t\t\t\t\tfor (let m = 0; m !== animationKeys[k].morphTargets.length; ++m) {\n\t\t\t\t\t\tconst animationKey = animationKeys[k];\n\t\t\t\t\t\ttimes.push(animationKey.time);\n\t\t\t\t\t\tvalues.push(animationKey.morphTarget === morphTargetName ? 1 : 0);\n\t\t\t\t\t}\n\n\t\t\t\t\ttracks.push(new NumberKeyframeTrack('.morphTargetInfluence[' + morphTargetName + ']', times, values));\n\t\t\t\t}\n\n\t\t\t\tduration = morphTargetNames.length * fps;\n\t\t\t} else {\n\t\t\t\t// ...assume skeletal animation\n\t\t\t\tconst boneName = '.bones[' + bones[h].name + ']';\n\t\t\t\taddNonemptyTrack(VectorKeyframeTrack, boneName + '.position', animationKeys, 'pos', tracks);\n\t\t\t\taddNonemptyTrack(QuaternionKeyframeTrack, boneName + '.quaternion', animationKeys, 'rot', tracks);\n\t\t\t\taddNonemptyTrack(VectorKeyframeTrack, boneName + '.scale', animationKeys, 'scl', tracks);\n\t\t\t}\n\t\t}\n\n\t\tif (tracks.length === 0) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst clip = new this(clipName, duration, tracks, blendMode);\n\t\treturn clip;\n\t}\n\n\tresetDuration() {\n\t\tconst tracks = this.tracks;\n\t\tlet duration = 0;\n\n\t\tfor (let i = 0, n = tracks.length; i !== n; ++i) {\n\t\t\tconst track = this.tracks[i];\n\t\t\tduration = Math.max(duration, track.times[track.times.length - 1]);\n\t\t}\n\n\t\tthis.duration = duration;\n\t\treturn this;\n\t}\n\n\ttrim() {\n\t\tfor (let i = 0; i < this.tracks.length; i++) {\n\t\t\tthis.tracks[i].trim(0, this.duration);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tvalidate() {\n\t\tlet valid = true;\n\n\t\tfor (let i = 0; i < this.tracks.length; i++) {\n\t\t\tvalid = valid && this.tracks[i].validate();\n\t\t}\n\n\t\treturn valid;\n\t}\n\n\toptimize() {\n\t\tfor (let i = 0; i < this.tracks.length; i++) {\n\t\t\tthis.tracks[i].optimize();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\tconst tracks = [];\n\n\t\tfor (let i = 0; i < this.tracks.length; i++) {\n\t\t\ttracks.push(this.tracks[i].clone());\n\t\t}\n\n\t\treturn new this.constructor(this.name, this.duration, tracks, this.blendMode);\n\t}\n\n\ttoJSON() {\n\t\treturn this.constructor.toJSON(this);\n\t}\n\n}\n\nfunction getTrackTypeForValueTypeName(typeName) {\n\tswitch (typeName.toLowerCase()) {\n\t\tcase 'scalar':\n\t\tcase 'double':\n\t\tcase 'float':\n\t\tcase 'number':\n\t\tcase 'integer':\n\t\t\treturn NumberKeyframeTrack;\n\n\t\tcase 'vector':\n\t\tcase 'vector2':\n\t\tcase 'vector3':\n\t\tcase 'vector4':\n\t\t\treturn VectorKeyframeTrack;\n\n\t\tcase 'color':\n\t\t\treturn ColorKeyframeTrack;\n\n\t\tcase 'quaternion':\n\t\t\treturn QuaternionKeyframeTrack;\n\n\t\tcase 'bool':\n\t\tcase 'boolean':\n\t\t\treturn BooleanKeyframeTrack;\n\n\t\tcase 'string':\n\t\t\treturn StringKeyframeTrack;\n\t}\n\n\tthrow new Error('THREE.KeyframeTrack: Unsupported typeName: ' + typeName);\n}\n\nfunction parseKeyframeTrack(json) {\n\tif (json.type === undefined) {\n\t\tthrow new Error('THREE.KeyframeTrack: track type undefined, can not parse');\n\t}\n\n\tconst trackType = getTrackTypeForValueTypeName(json.type);\n\n\tif (json.times === undefined) {\n\t\tconst times = [],\n\t\t\t\t\tvalues = [];\n\t\tflattenJSON(json.keys, times, values, 'value');\n\t\tjson.times = times;\n\t\tjson.values = values;\n\t} // derived classes can define a static parse method\n\n\n\tif (trackType.parse !== undefined) {\n\t\treturn trackType.parse(json);\n\t} else {\n\t\t// by default, we assume a constructor compatible with the base\n\t\treturn new trackType(json.name, json.times, json.values, json.interpolation);\n\t}\n}\n\nconst Cache = {\n\tenabled: false,\n\tfiles: {},\n\tadd: function (key, file) {\n\t\tif (this.enabled === false) return; // console.log( 'THREE.Cache', 'Adding key:', key );\n\n\t\tthis.files[key] = file;\n\t},\n\tget: function (key) {\n\t\tif (this.enabled === false) return; // console.log( 'THREE.Cache', 'Checking key:', key );\n\n\t\treturn this.files[key];\n\t},\n\tremove: function (key) {\n\t\tdelete this.files[key];\n\t},\n\tclear: function () {\n\t\tthis.files = {};\n\t}\n};\n\nclass LoadingManager {\n\tconstructor(onLoad, onProgress, onError) {\n\t\tconst scope = this;\n\t\tlet isLoading = false;\n\t\tlet itemsLoaded = 0;\n\t\tlet itemsTotal = 0;\n\t\tlet urlModifier = undefined;\n\t\tconst handlers = []; // Refer to #5689 for the reason why we don't set .onStart\n\t\t// in the constructor\n\n\t\tthis.onStart = undefined;\n\t\tthis.onLoad = onLoad;\n\t\tthis.onProgress = onProgress;\n\t\tthis.onError = onError;\n\n\t\tthis.itemStart = function (url) {\n\t\t\titemsTotal++;\n\n\t\t\tif (isLoading === false) {\n\t\t\t\tif (scope.onStart !== undefined) {\n\t\t\t\t\tscope.onStart(url, itemsLoaded, itemsTotal);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tisLoading = true;\n\t\t};\n\n\t\tthis.itemEnd = function (url) {\n\t\t\titemsLoaded++;\n\n\t\t\tif (scope.onProgress !== undefined) {\n\t\t\t\tscope.onProgress(url, itemsLoaded, itemsTotal);\n\t\t\t}\n\n\t\t\tif (itemsLoaded === itemsTotal) {\n\t\t\t\tisLoading = false;\n\n\t\t\t\tif (scope.onLoad !== undefined) {\n\t\t\t\t\tscope.onLoad();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tthis.itemError = function (url) {\n\t\t\tif (scope.onError !== undefined) {\n\t\t\t\tscope.onError(url);\n\t\t\t}\n\t\t};\n\n\t\tthis.resolveURL = function (url) {\n\t\t\tif (urlModifier) {\n\t\t\t\treturn urlModifier(url);\n\t\t\t}\n\n\t\t\treturn url;\n\t\t};\n\n\t\tthis.setURLModifier = function (transform) {\n\t\t\turlModifier = transform;\n\t\t\treturn this;\n\t\t};\n\n\t\tthis.addHandler = function (regex, loader) {\n\t\t\thandlers.push(regex, loader);\n\t\t\treturn this;\n\t\t};\n\n\t\tthis.removeHandler = function (regex) {\n\t\t\tconst index = handlers.indexOf(regex);\n\n\t\t\tif (index !== -1) {\n\t\t\t\thandlers.splice(index, 2);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\tthis.getHandler = function (file) {\n\t\t\tfor (let i = 0, l = handlers.length; i < l; i += 2) {\n\t\t\t\tconst regex = handlers[i];\n\t\t\t\tconst loader = handlers[i + 1];\n\t\t\t\tif (regex.global) regex.lastIndex = 0; // see #17920\n\n\t\t\t\tif (regex.test(file)) {\n\t\t\t\t\treturn loader;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn null;\n\t\t};\n\t}\n\n}\n\nconst DefaultLoadingManager = /*@__PURE__*/new LoadingManager();\n\nclass Loader {\n\tconstructor(manager) {\n\t\tthis.manager = manager !== undefined ? manager : DefaultLoadingManager;\n\t\tthis.crossOrigin = 'anonymous';\n\t\tthis.withCredentials = false;\n\t\tthis.path = '';\n\t\tthis.resourcePath = '';\n\t\tthis.requestHeader = {};\n\t}\n\n\tload() {}\n\n\tloadAsync(url, onProgress) {\n\t\tconst scope = this;\n\t\treturn new Promise(function (resolve, reject) {\n\t\t\tscope.load(url, resolve, onProgress, reject);\n\t\t});\n\t}\n\n\tparse() {}\n\n\tsetCrossOrigin(crossOrigin) {\n\t\tthis.crossOrigin = crossOrigin;\n\t\treturn this;\n\t}\n\n\tsetWithCredentials(value) {\n\t\tthis.withCredentials = value;\n\t\treturn this;\n\t}\n\n\tsetPath(path) {\n\t\tthis.path = path;\n\t\treturn this;\n\t}\n\n\tsetResourcePath(resourcePath) {\n\t\tthis.resourcePath = resourcePath;\n\t\treturn this;\n\t}\n\n\tsetRequestHeader(requestHeader) {\n\t\tthis.requestHeader = requestHeader;\n\t\treturn this;\n\t}\n\n}\n\nconst loading = {};\n\nclass HttpError extends Error {\n\tconstructor(message, response) {\n\t\tsuper(message);\n\t\tthis.response = response;\n\t}\n\n}\n\nclass FileLoader extends Loader {\n\tconstructor(manager) {\n\t\tsuper(manager);\n\t}\n\n\tload(url, onLoad, onProgress, onError) {\n\t\tif (url === undefined) url = '';\n\t\tif (this.path !== undefined) url = this.path + url;\n\t\turl = this.manager.resolveURL(url);\n\t\tconst cached = Cache.get(url);\n\n\t\tif (cached !== undefined) {\n\t\t\tthis.manager.itemStart(url);\n\t\t\tsetTimeout(() => {\n\t\t\t\tif (onLoad) onLoad(cached);\n\t\t\t\tthis.manager.itemEnd(url);\n\t\t\t}, 0);\n\t\t\treturn cached;\n\t\t} // Check if request is duplicate\n\n\n\t\tif (loading[url] !== undefined) {\n\t\t\tloading[url].push({\n\t\t\t\tonLoad: onLoad,\n\t\t\t\tonProgress: onProgress,\n\t\t\t\tonError: onError\n\t\t\t});\n\t\t\treturn;\n\t\t} // Initialise array for duplicate requests\n\n\n\t\tloading[url] = [];\n\t\tloading[url].push({\n\t\t\tonLoad: onLoad,\n\t\t\tonProgress: onProgress,\n\t\t\tonError: onError\n\t\t}); // create request\n\n\t\tconst req = new Request(url, {\n\t\t\theaders: new Headers(this.requestHeader),\n\t\t\tcredentials: this.withCredentials ? 'include' : 'same-origin' // An abort controller could be added within a future PR\n\n\t\t}); // record states ( avoid data race )\n\n\t\tconst mimeType = this.mimeType;\n\t\tconst responseType = this.responseType; // start the fetch\n\n\t\tfetch(req).then(response => {\n\t\t\tif (response.status === 200 || response.status === 0) {\n\t\t\t\t// Some browsers return HTTP Status 0 when using non-http protocol\n\t\t\t\t// e.g. 'file://' or 'data://'. Handle as success.\n\t\t\t\tif (response.status === 0) {\n\t\t\t\t\tconsole.warn('THREE.FileLoader: HTTP Status 0 received.');\n\t\t\t\t} // Workaround: Checking if response.body === undefined for Alipay browser #23548\n\n\n\t\t\t\tif (typeof ReadableStream === 'undefined' || response.body === undefined || response.body.getReader === undefined) {\n\t\t\t\t\treturn response;\n\t\t\t\t}\n\n\t\t\t\tconst callbacks = loading[url];\n\t\t\t\tconst reader = response.body.getReader();\n\t\t\t\tconst contentLength = response.headers.get('Content-Length');\n\t\t\t\tconst total = contentLength ? parseInt(contentLength) : 0;\n\t\t\t\tconst lengthComputable = total !== 0;\n\t\t\t\tlet loaded = 0; // periodically read data into the new stream tracking while download progress\n\n\t\t\t\tconst stream = new ReadableStream({\n\t\t\t\t\tstart(controller) {\n\t\t\t\t\t\treadData();\n\n\t\t\t\t\t\tfunction readData() {\n\t\t\t\t\t\t\treader.read().then(({\n\t\t\t\t\t\t\t\tdone,\n\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t}) => {\n\t\t\t\t\t\t\t\tif (done) {\n\t\t\t\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tloaded += value.byteLength;\n\t\t\t\t\t\t\t\t\tconst event = new ProgressEvent('progress', {\n\t\t\t\t\t\t\t\t\t\tlengthComputable,\n\t\t\t\t\t\t\t\t\t\tloaded,\n\t\t\t\t\t\t\t\t\t\ttotal\n\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\tfor (let i = 0, il = callbacks.length; i < il; i++) {\n\t\t\t\t\t\t\t\t\t\tconst callback = callbacks[i];\n\t\t\t\t\t\t\t\t\t\tif (callback.onProgress) callback.onProgress(event);\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tcontroller.enqueue(value);\n\t\t\t\t\t\t\t\t\treadData();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t});\n\t\t\t\treturn new Response(stream);\n\t\t\t} else {\n\t\t\t\tthrow new HttpError(`fetch for \"${response.url}\" responded with ${response.status}: ${response.statusText}`, response);\n\t\t\t}\n\t\t}).then(response => {\n\t\t\tswitch (responseType) {\n\t\t\t\tcase 'arraybuffer':\n\t\t\t\t\treturn response.arrayBuffer();\n\n\t\t\t\tcase 'blob':\n\t\t\t\t\treturn response.blob();\n\n\t\t\t\tcase 'document':\n\t\t\t\t\treturn response.text().then(text => {\n\t\t\t\t\t\tconst parser = new DOMParser();\n\t\t\t\t\t\treturn parser.parseFromString(text, mimeType);\n\t\t\t\t\t});\n\n\t\t\t\tcase 'json':\n\t\t\t\t\treturn response.json();\n\n\t\t\t\tdefault:\n\t\t\t\t\tif (mimeType === undefined) {\n\t\t\t\t\t\treturn response.text();\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// sniff encoding\n\t\t\t\t\t\tconst re = /charset=\"?([^;\"\\s]*)\"?/i;\n\t\t\t\t\t\tconst exec = re.exec(mimeType);\n\t\t\t\t\t\tconst label = exec && exec[1] ? exec[1].toLowerCase() : undefined;\n\t\t\t\t\t\tconst decoder = new TextDecoder(label);\n\t\t\t\t\t\treturn response.arrayBuffer().then(ab => decoder.decode(ab));\n\t\t\t\t\t}\n\n\t\t\t}\n\t\t}).then(data => {\n\t\t\t// Add to cache only on HTTP success, so that we do not cache\n\t\t\t// error response bodies as proper responses to requests.\n\t\t\tCache.add(url, data);\n\t\t\tconst callbacks = loading[url];\n\t\t\tdelete loading[url];\n\n\t\t\tfor (let i = 0, il = callbacks.length; i < il; i++) {\n\t\t\t\tconst callback = callbacks[i];\n\t\t\t\tif (callback.onLoad) callback.onLoad(data);\n\t\t\t}\n\t\t}).catch(err => {\n\t\t\t// Abort errors and other errors are handled the same\n\t\t\tconst callbacks = loading[url];\n\n\t\t\tif (callbacks === undefined) {\n\t\t\t\t// When onLoad was called and url was deleted in `loading`\n\t\t\t\tthis.manager.itemError(url);\n\t\t\t\tthrow err;\n\t\t\t}\n\n\t\t\tdelete loading[url];\n\n\t\t\tfor (let i = 0, il = callbacks.length; i < il; i++) {\n\t\t\t\tconst callback = callbacks[i];\n\t\t\t\tif (callback.onError) callback.onError(err);\n\t\t\t}\n\n\t\t\tthis.manager.itemError(url);\n\t\t}).finally(() => {\n\t\t\tthis.manager.itemEnd(url);\n\t\t});\n\t\tthis.manager.itemStart(url);\n\t}\n\n\tsetResponseType(value) {\n\t\tthis.responseType = value;\n\t\treturn this;\n\t}\n\n\tsetMimeType(value) {\n\t\tthis.mimeType = value;\n\t\treturn this;\n\t}\n\n}\n\nclass AnimationLoader extends Loader {\n\tconstructor(manager) {\n\t\tsuper(manager);\n\t}\n\n\tload(url, onLoad, onProgress, onError) {\n\t\tconst scope = this;\n\t\tconst loader = new FileLoader(this.manager);\n\t\tloader.setPath(this.path);\n\t\tloader.setRequestHeader(this.requestHeader);\n\t\tloader.setWithCredentials(this.withCredentials);\n\t\tloader.load(url, function (text) {\n\t\t\ttry {\n\t\t\t\tonLoad(scope.parse(JSON.parse(text)));\n\t\t\t} catch (e) {\n\t\t\t\tif (onError) {\n\t\t\t\t\tonError(e);\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(e);\n\t\t\t\t}\n\n\t\t\t\tscope.manager.itemError(url);\n\t\t\t}\n\t\t}, onProgress, onError);\n\t}\n\n\tparse(json) {\n\t\tconst animations = [];\n\n\t\tfor (let i = 0; i < json.length; i++) {\n\t\t\tconst clip = AnimationClip.parse(json[i]);\n\t\t\tanimations.push(clip);\n\t\t}\n\n\t\treturn animations;\n\t}\n\n}\n\n/**\n * Abstract Base class to block based textures loader (dds, pvr, ...)\n *\n * Sub classes have to implement the parse() method which will be used in load().\n */\n\nclass CompressedTextureLoader extends Loader {\n\tconstructor(manager) {\n\t\tsuper(manager);\n\t}\n\n\tload(url, onLoad, onProgress, onError) {\n\t\tconst scope = this;\n\t\tconst images = [];\n\t\tconst texture = new CompressedTexture();\n\t\tconst loader = new FileLoader(this.manager);\n\t\tloader.setPath(this.path);\n\t\tloader.setResponseType('arraybuffer');\n\t\tloader.setRequestHeader(this.requestHeader);\n\t\tloader.setWithCredentials(scope.withCredentials);\n\t\tlet loaded = 0;\n\n\t\tfunction loadTexture(i) {\n\t\t\tloader.load(url[i], function (buffer) {\n\t\t\t\tconst texDatas = scope.parse(buffer, true);\n\t\t\t\timages[i] = {\n\t\t\t\t\twidth: texDatas.width,\n\t\t\t\t\theight: texDatas.height,\n\t\t\t\t\tformat: texDatas.format,\n\t\t\t\t\tmipmaps: texDatas.mipmaps\n\t\t\t\t};\n\t\t\t\tloaded += 1;\n\n\t\t\t\tif (loaded === 6) {\n\t\t\t\t\tif (texDatas.mipmapCount === 1) texture.minFilter = LinearFilter;\n\t\t\t\t\ttexture.image = images;\n\t\t\t\t\ttexture.format = texDatas.format;\n\t\t\t\t\ttexture.needsUpdate = true;\n\t\t\t\t\tif (onLoad) onLoad(texture);\n\t\t\t\t}\n\t\t\t}, onProgress, onError);\n\t\t}\n\n\t\tif (Array.isArray(url)) {\n\t\t\tfor (let i = 0, il = url.length; i < il; ++i) {\n\t\t\t\tloadTexture(i);\n\t\t\t}\n\t\t} else {\n\t\t\t// compressed cubemap texture stored in a single DDS file\n\t\t\tloader.load(url, function (buffer) {\n\t\t\t\tconst texDatas = scope.parse(buffer, true);\n\n\t\t\t\tif (texDatas.isCubemap) {\n\t\t\t\t\tconst faces = texDatas.mipmaps.length / texDatas.mipmapCount;\n\n\t\t\t\t\tfor (let f = 0; f < faces; f++) {\n\t\t\t\t\t\timages[f] = {\n\t\t\t\t\t\t\tmipmaps: []\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tfor (let i = 0; i < texDatas.mipmapCount; i++) {\n\t\t\t\t\t\t\timages[f].mipmaps.push(texDatas.mipmaps[f * texDatas.mipmapCount + i]);\n\t\t\t\t\t\t\timages[f].format = texDatas.format;\n\t\t\t\t\t\t\timages[f].width = texDatas.width;\n\t\t\t\t\t\t\timages[f].height = texDatas.height;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\ttexture.image = images;\n\t\t\t\t} else {\n\t\t\t\t\ttexture.image.width = texDatas.width;\n\t\t\t\t\ttexture.image.height = texDatas.height;\n\t\t\t\t\ttexture.mipmaps = texDatas.mipmaps;\n\t\t\t\t}\n\n\t\t\t\tif (texDatas.mipmapCount === 1) {\n\t\t\t\t\ttexture.minFilter = LinearFilter;\n\t\t\t\t}\n\n\t\t\t\ttexture.format = texDatas.format;\n\t\t\t\ttexture.needsUpdate = true;\n\t\t\t\tif (onLoad) onLoad(texture);\n\t\t\t}, onProgress, onError);\n\t\t}\n\n\t\treturn texture;\n\t}\n\n}\n\nclass ImageLoader extends Loader {\n\tconstructor(manager) {\n\t\tsuper(manager);\n\t}\n\n\tload(url, onLoad, onProgress, onError) {\n\t\tif (this.path !== undefined) url = this.path + url;\n\t\turl = this.manager.resolveURL(url);\n\t\tconst scope = this;\n\t\tconst cached = Cache.get(url);\n\n\t\tif (cached !== undefined) {\n\t\t\tscope.manager.itemStart(url);\n\t\t\tsetTimeout(function () {\n\t\t\t\tif (onLoad) onLoad(cached);\n\t\t\t\tscope.manager.itemEnd(url);\n\t\t\t}, 0);\n\t\t\treturn cached;\n\t\t}\n\n\t\tconst image = createElementNS('img');\n\n\t\tfunction onImageLoad() {\n\t\t\tremoveEventListeners();\n\t\t\tCache.add(url, this);\n\t\t\tif (onLoad) onLoad(this);\n\t\t\tscope.manager.itemEnd(url);\n\t\t}\n\n\t\tfunction onImageError(event) {\n\t\t\tremoveEventListeners();\n\t\t\tif (onError) onError(event);\n\t\t\tscope.manager.itemError(url);\n\t\t\tscope.manager.itemEnd(url);\n\t\t}\n\n\t\tfunction removeEventListeners() {\n\t\t\timage.removeEventListener('load', onImageLoad, false);\n\t\t\timage.removeEventListener('error', onImageError, false);\n\t\t}\n\n\t\timage.addEventListener('load', onImageLoad, false);\n\t\timage.addEventListener('error', onImageError, false);\n\n\t\tif (url.slice(0, 5) !== 'data:') {\n\t\t\tif (this.crossOrigin !== undefined) image.crossOrigin = this.crossOrigin;\n\t\t}\n\n\t\tscope.manager.itemStart(url);\n\t\timage.src = url;\n\t\treturn image;\n\t}\n\n}\n\nclass CubeTextureLoader extends Loader {\n\tconstructor(manager) {\n\t\tsuper(manager);\n\t}\n\n\tload(urls, onLoad, onProgress, onError) {\n\t\tconst texture = new CubeTexture();\n\t\tconst loader = new ImageLoader(this.manager);\n\t\tloader.setCrossOrigin(this.crossOrigin);\n\t\tloader.setPath(this.path);\n\t\tlet loaded = 0;\n\n\t\tfunction loadTexture(i) {\n\t\t\tloader.load(urls[i], function (image) {\n\t\t\t\ttexture.images[i] = image;\n\t\t\t\tloaded++;\n\n\t\t\t\tif (loaded === 6) {\n\t\t\t\t\ttexture.needsUpdate = true;\n\t\t\t\t\tif (onLoad) onLoad(texture);\n\t\t\t\t}\n\t\t\t}, undefined, onError);\n\t\t}\n\n\t\tfor (let i = 0; i < urls.length; ++i) {\n\t\t\tloadTexture(i);\n\t\t}\n\n\t\treturn texture;\n\t}\n\n}\n\n/**\n * Abstract Base class to load generic binary textures formats (rgbe, hdr, ...)\n *\n * Sub classes have to implement the parse() method which will be used in load().\n */\n\nclass DataTextureLoader extends Loader {\n\tconstructor(manager) {\n\t\tsuper(manager);\n\t}\n\n\tload(url, onLoad, onProgress, onError) {\n\t\tconst scope = this;\n\t\tconst texture = new DataTexture();\n\t\tconst loader = new FileLoader(this.manager);\n\t\tloader.setResponseType('arraybuffer');\n\t\tloader.setRequestHeader(this.requestHeader);\n\t\tloader.setPath(this.path);\n\t\tloader.setWithCredentials(scope.withCredentials);\n\t\tloader.load(url, function (buffer) {\n\t\t\tconst texData = scope.parse(buffer);\n\t\t\tif (!texData) return;\n\n\t\t\tif (texData.image !== undefined) {\n\t\t\t\ttexture.image = texData.image;\n\t\t\t} else if (texData.data !== undefined) {\n\t\t\t\ttexture.image.width = texData.width;\n\t\t\t\ttexture.image.height = texData.height;\n\t\t\t\ttexture.image.data = texData.data;\n\t\t\t}\n\n\t\t\ttexture.wrapS = texData.wrapS !== undefined ? texData.wrapS : ClampToEdgeWrapping;\n\t\t\ttexture.wrapT = texData.wrapT !== undefined ? texData.wrapT : ClampToEdgeWrapping;\n\t\t\ttexture.magFilter = texData.magFilter !== undefined ? texData.magFilter : LinearFilter;\n\t\t\ttexture.minFilter = texData.minFilter !== undefined ? texData.minFilter : LinearFilter;\n\t\t\ttexture.anisotropy = texData.anisotropy !== undefined ? texData.anisotropy : 1;\n\n\t\t\tif (texData.encoding !== undefined) {\n\t\t\t\ttexture.encoding = texData.encoding;\n\t\t\t}\n\n\t\t\tif (texData.flipY !== undefined) {\n\t\t\t\ttexture.flipY = texData.flipY;\n\t\t\t}\n\n\t\t\tif (texData.format !== undefined) {\n\t\t\t\ttexture.format = texData.format;\n\t\t\t}\n\n\t\t\tif (texData.type !== undefined) {\n\t\t\t\ttexture.type = texData.type;\n\t\t\t}\n\n\t\t\tif (texData.mipmaps !== undefined) {\n\t\t\t\ttexture.mipmaps = texData.mipmaps;\n\t\t\t\ttexture.minFilter = LinearMipmapLinearFilter; // presumably...\n\t\t\t}\n\n\t\t\tif (texData.mipmapCount === 1) {\n\t\t\t\ttexture.minFilter = LinearFilter;\n\t\t\t}\n\n\t\t\tif (texData.generateMipmaps !== undefined) {\n\t\t\t\ttexture.generateMipmaps = texData.generateMipmaps;\n\t\t\t}\n\n\t\t\ttexture.needsUpdate = true;\n\t\t\tif (onLoad) onLoad(texture, texData);\n\t\t}, onProgress, onError);\n\t\treturn texture;\n\t}\n\n}\n\nclass TextureLoader extends Loader {\n\tconstructor(manager) {\n\t\tsuper(manager);\n\t}\n\n\tload(url, onLoad, onProgress, onError) {\n\t\tconst texture = new Texture();\n\t\tconst loader = new ImageLoader(this.manager);\n\t\tloader.setCrossOrigin(this.crossOrigin);\n\t\tloader.setPath(this.path);\n\t\tloader.load(url, function (image) {\n\t\t\ttexture.image = image;\n\t\t\ttexture.needsUpdate = true;\n\n\t\t\tif (onLoad !== undefined) {\n\t\t\t\tonLoad(texture);\n\t\t\t}\n\t\t}, onProgress, onError);\n\t\treturn texture;\n\t}\n\n}\n\nclass Light extends Object3D {\n\tconstructor(color, intensity = 1) {\n\t\tsuper();\n\t\tthis.isLight = true;\n\t\tthis.type = 'Light';\n\t\tthis.color = new Color(color);\n\t\tthis.intensity = intensity;\n\t}\n\n\tdispose() {// Empty here in base class; some subclasses override.\n\t}\n\n\tcopy(source, recursive) {\n\t\tsuper.copy(source, recursive);\n\t\tthis.color.copy(source.color);\n\t\tthis.intensity = source.intensity;\n\t\treturn this;\n\t}\n\n\ttoJSON(meta) {\n\t\tconst data = super.toJSON(meta);\n\t\tdata.object.color = this.color.getHex();\n\t\tdata.object.intensity = this.intensity;\n\t\tif (this.groundColor !== undefined) data.object.groundColor = this.groundColor.getHex();\n\t\tif (this.distance !== undefined) data.object.distance = this.distance;\n\t\tif (this.angle !== undefined) data.object.angle = this.angle;\n\t\tif (this.decay !== undefined) data.object.decay = this.decay;\n\t\tif (this.penumbra !== undefined) data.object.penumbra = this.penumbra;\n\t\tif (this.shadow !== undefined) data.object.shadow = this.shadow.toJSON();\n\t\treturn data;\n\t}\n\n}\n\nclass HemisphereLight extends Light {\n\tconstructor(skyColor, groundColor, intensity) {\n\t\tsuper(skyColor, intensity);\n\t\tthis.isHemisphereLight = true;\n\t\tthis.type = 'HemisphereLight';\n\t\tthis.position.copy(Object3D.DefaultUp);\n\t\tthis.updateMatrix();\n\t\tthis.groundColor = new Color(groundColor);\n\t}\n\n\tcopy(source, recursive) {\n\t\tsuper.copy(source, recursive);\n\t\tthis.groundColor.copy(source.groundColor);\n\t\treturn this;\n\t}\n\n}\n\nconst _projScreenMatrix$1 = /*@__PURE__*/new Matrix4();\n\nconst _lightPositionWorld$1 = /*@__PURE__*/new Vector3();\n\nconst _lookTarget$1 = /*@__PURE__*/new Vector3();\n\nclass LightShadow {\n\tconstructor(camera) {\n\t\tthis.camera = camera;\n\t\tthis.bias = 0;\n\t\tthis.normalBias = 0;\n\t\tthis.radius = 1;\n\t\tthis.blurSamples = 8;\n\t\tthis.mapSize = new Vector2(512, 512);\n\t\tthis.map = null;\n\t\tthis.mapPass = null;\n\t\tthis.matrix = new Matrix4();\n\t\tthis.autoUpdate = true;\n\t\tthis.needsUpdate = false;\n\t\tthis._frustum = new Frustum();\n\t\tthis._frameExtents = new Vector2(1, 1);\n\t\tthis._viewportCount = 1;\n\t\tthis._viewports = [new Vector4(0, 0, 1, 1)];\n\t}\n\n\tgetViewportCount() {\n\t\treturn this._viewportCount;\n\t}\n\n\tgetFrustum() {\n\t\treturn this._frustum;\n\t}\n\n\tupdateMatrices(light) {\n\t\tconst shadowCamera = this.camera;\n\t\tconst shadowMatrix = this.matrix;\n\n\t\t_lightPositionWorld$1.setFromMatrixPosition(light.matrixWorld);\n\n\t\tshadowCamera.position.copy(_lightPositionWorld$1);\n\n\t\t_lookTarget$1.setFromMatrixPosition(light.target.matrixWorld);\n\n\t\tshadowCamera.lookAt(_lookTarget$1);\n\t\tshadowCamera.updateMatrixWorld();\n\n\t\t_projScreenMatrix$1.multiplyMatrices(shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse);\n\n\t\tthis._frustum.setFromProjectionMatrix(_projScreenMatrix$1);\n\n\t\tshadowMatrix.set(0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0);\n\t\tshadowMatrix.multiply(_projScreenMatrix$1);\n\t}\n\n\tgetViewport(viewportIndex) {\n\t\treturn this._viewports[viewportIndex];\n\t}\n\n\tgetFrameExtents() {\n\t\treturn this._frameExtents;\n\t}\n\n\tdispose() {\n\t\tif (this.map) {\n\t\t\tthis.map.dispose();\n\t\t}\n\n\t\tif (this.mapPass) {\n\t\t\tthis.mapPass.dispose();\n\t\t}\n\t}\n\n\tcopy(source) {\n\t\tthis.camera = source.camera.clone();\n\t\tthis.bias = source.bias;\n\t\tthis.radius = source.radius;\n\t\tthis.mapSize.copy(source.mapSize);\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\treturn new this.constructor().copy(this);\n\t}\n\n\ttoJSON() {\n\t\tconst object = {};\n\t\tif (this.bias !== 0) object.bias = this.bias;\n\t\tif (this.normalBias !== 0) object.normalBias = this.normalBias;\n\t\tif (this.radius !== 1) object.radius = this.radius;\n\t\tif (this.mapSize.x !== 512 || this.mapSize.y !== 512) object.mapSize = this.mapSize.toArray();\n\t\tobject.camera = this.camera.toJSON(false).object;\n\t\tdelete object.camera.matrix;\n\t\treturn object;\n\t}\n\n}\n\nclass SpotLightShadow extends LightShadow {\n\tconstructor() {\n\t\tsuper(new PerspectiveCamera(50, 1, 0.5, 500));\n\t\tthis.isSpotLightShadow = true;\n\t\tthis.focus = 1;\n\t}\n\n\tupdateMatrices(light) {\n\t\tconst camera = this.camera;\n\t\tconst fov = RAD2DEG * 2 * light.angle * this.focus;\n\t\tconst aspect = this.mapSize.width / this.mapSize.height;\n\t\tconst far = light.distance || camera.far;\n\n\t\tif (fov !== camera.fov || aspect !== camera.aspect || far !== camera.far) {\n\t\t\tcamera.fov = fov;\n\t\t\tcamera.aspect = aspect;\n\t\t\tcamera.far = far;\n\t\t\tcamera.updateProjectionMatrix();\n\t\t}\n\n\t\tsuper.updateMatrices(light);\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.focus = source.focus;\n\t\treturn this;\n\t}\n\n}\n\nclass SpotLight extends Light {\n\tconstructor(color, intensity, distance = 0, angle = Math.PI / 3, penumbra = 0, decay = 1) {\n\t\tsuper(color, intensity);\n\t\tthis.isSpotLight = true;\n\t\tthis.type = 'SpotLight';\n\t\tthis.position.copy(Object3D.DefaultUp);\n\t\tthis.updateMatrix();\n\t\tthis.target = new Object3D();\n\t\tthis.distance = distance;\n\t\tthis.angle = angle;\n\t\tthis.penumbra = penumbra;\n\t\tthis.decay = decay; // for physically correct lights, should be 2.\n\n\t\tthis.map = null;\n\t\tthis.shadow = new SpotLightShadow();\n\t}\n\n\tget power() {\n\t\t// compute the light's luminous power (in lumens) from its intensity (in candela)\n\t\t// by convention for a spotlight, luminous power (lm) = Ï€ * luminous intensity (cd)\n\t\treturn this.intensity * Math.PI;\n\t}\n\n\tset power(power) {\n\t\t// set the light's intensity (in candela) from the desired luminous power (in lumens)\n\t\tthis.intensity = power / Math.PI;\n\t}\n\n\tdispose() {\n\t\tthis.shadow.dispose();\n\t}\n\n\tcopy(source, recursive) {\n\t\tsuper.copy(source, recursive);\n\t\tthis.distance = source.distance;\n\t\tthis.angle = source.angle;\n\t\tthis.penumbra = source.penumbra;\n\t\tthis.decay = source.decay;\n\t\tthis.target = source.target.clone();\n\t\tthis.shadow = source.shadow.clone();\n\t\treturn this;\n\t}\n\n}\n\nconst _projScreenMatrix = /*@__PURE__*/new Matrix4();\n\nconst _lightPositionWorld = /*@__PURE__*/new Vector3();\n\nconst _lookTarget = /*@__PURE__*/new Vector3();\n\nclass PointLightShadow extends LightShadow {\n\tconstructor() {\n\t\tsuper(new PerspectiveCamera(90, 1, 0.5, 500));\n\t\tthis.isPointLightShadow = true;\n\t\tthis._frameExtents = new Vector2(4, 2);\n\t\tthis._viewportCount = 6;\n\t\tthis._viewports = [// These viewports map a cube-map onto a 2D texture with the\n\t\t// following orientation:\n\t\t//\n\t\t//\txzXZ\n\t\t//\t y Y\n\t\t//\n\t\t// X - Positive x direction\n\t\t// x - Negative x direction\n\t\t// Y - Positive y direction\n\t\t// y - Negative y direction\n\t\t// Z - Positive z direction\n\t\t// z - Negative z direction\n\t\t// positive X\n\t\tnew Vector4(2, 1, 1, 1), // negative X\n\t\tnew Vector4(0, 1, 1, 1), // positive Z\n\t\tnew Vector4(3, 1, 1, 1), // negative Z\n\t\tnew Vector4(1, 1, 1, 1), // positive Y\n\t\tnew Vector4(3, 0, 1, 1), // negative Y\n\t\tnew Vector4(1, 0, 1, 1)];\n\t\tthis._cubeDirections = [new Vector3(1, 0, 0), new Vector3(-1, 0, 0), new Vector3(0, 0, 1), new Vector3(0, 0, -1), new Vector3(0, 1, 0), new Vector3(0, -1, 0)];\n\t\tthis._cubeUps = [new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1), new Vector3(0, 0, -1)];\n\t}\n\n\tupdateMatrices(light, viewportIndex = 0) {\n\t\tconst camera = this.camera;\n\t\tconst shadowMatrix = this.matrix;\n\t\tconst far = light.distance || camera.far;\n\n\t\tif (far !== camera.far) {\n\t\t\tcamera.far = far;\n\t\t\tcamera.updateProjectionMatrix();\n\t\t}\n\n\t\t_lightPositionWorld.setFromMatrixPosition(light.matrixWorld);\n\n\t\tcamera.position.copy(_lightPositionWorld);\n\n\t\t_lookTarget.copy(camera.position);\n\n\t\t_lookTarget.add(this._cubeDirections[viewportIndex]);\n\n\t\tcamera.up.copy(this._cubeUps[viewportIndex]);\n\t\tcamera.lookAt(_lookTarget);\n\t\tcamera.updateMatrixWorld();\n\t\tshadowMatrix.makeTranslation(-_lightPositionWorld.x, -_lightPositionWorld.y, -_lightPositionWorld.z);\n\n\t\t_projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);\n\n\t\tthis._frustum.setFromProjectionMatrix(_projScreenMatrix);\n\t}\n\n}\n\nclass PointLight extends Light {\n\tconstructor(color, intensity, distance = 0, decay = 1) {\n\t\tsuper(color, intensity);\n\t\tthis.isPointLight = true;\n\t\tthis.type = 'PointLight';\n\t\tthis.distance = distance;\n\t\tthis.decay = decay; // for physically correct lights, should be 2.\n\n\t\tthis.shadow = new PointLightShadow();\n\t}\n\n\tget power() {\n\t\t// compute the light's luminous power (in lumens) from its intensity (in candela)\n\t\t// for an isotropic light source, luminous power (lm) = 4 Ï€ luminous intensity (cd)\n\t\treturn this.intensity * 4 * Math.PI;\n\t}\n\n\tset power(power) {\n\t\t// set the light's intensity (in candela) from the desired luminous power (in lumens)\n\t\tthis.intensity = power / (4 * Math.PI);\n\t}\n\n\tdispose() {\n\t\tthis.shadow.dispose();\n\t}\n\n\tcopy(source, recursive) {\n\t\tsuper.copy(source, recursive);\n\t\tthis.distance = source.distance;\n\t\tthis.decay = source.decay;\n\t\tthis.shadow = source.shadow.clone();\n\t\treturn this;\n\t}\n\n}\n\nclass DirectionalLightShadow extends LightShadow {\n\tconstructor() {\n\t\tsuper(new OrthographicCamera(-5, 5, 5, -5, 0.5, 500));\n\t\tthis.isDirectionalLightShadow = true;\n\t}\n\n}\n\nclass DirectionalLight extends Light {\n\tconstructor(color, intensity) {\n\t\tsuper(color, intensity);\n\t\tthis.isDirectionalLight = true;\n\t\tthis.type = 'DirectionalLight';\n\t\tthis.position.copy(Object3D.DefaultUp);\n\t\tthis.updateMatrix();\n\t\tthis.target = new Object3D();\n\t\tthis.shadow = new DirectionalLightShadow();\n\t}\n\n\tdispose() {\n\t\tthis.shadow.dispose();\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.target = source.target.clone();\n\t\tthis.shadow = source.shadow.clone();\n\t\treturn this;\n\t}\n\n}\n\nclass AmbientLight extends Light {\n\tconstructor(color, intensity) {\n\t\tsuper(color, intensity);\n\t\tthis.isAmbientLight = true;\n\t\tthis.type = 'AmbientLight';\n\t}\n\n}\n\nclass RectAreaLight extends Light {\n\tconstructor(color, intensity, width = 10, height = 10) {\n\t\tsuper(color, intensity);\n\t\tthis.isRectAreaLight = true;\n\t\tthis.type = 'RectAreaLight';\n\t\tthis.width = width;\n\t\tthis.height = height;\n\t}\n\n\tget power() {\n\t\t// compute the light's luminous power (in lumens) from its intensity (in nits)\n\t\treturn this.intensity * this.width * this.height * Math.PI;\n\t}\n\n\tset power(power) {\n\t\t// set the light's intensity (in nits) from the desired luminous power (in lumens)\n\t\tthis.intensity = power / (this.width * this.height * Math.PI);\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.width = source.width;\n\t\tthis.height = source.height;\n\t\treturn this;\n\t}\n\n\ttoJSON(meta) {\n\t\tconst data = super.toJSON(meta);\n\t\tdata.object.width = this.width;\n\t\tdata.object.height = this.height;\n\t\treturn data;\n\t}\n\n}\n\n/**\n * Primary reference:\n *\t https://graphics.stanford.edu/papers/envmap/envmap.pdf\n *\n * Secondary reference:\n *\t https://www.ppsloan.org/publications/StupidSH36.pdf\n */\n// 3-band SH defined by 9 coefficients\n\nclass SphericalHarmonics3 {\n\tconstructor() {\n\t\tthis.isSphericalHarmonics3 = true;\n\t\tthis.coefficients = [];\n\n\t\tfor (let i = 0; i < 9; i++) {\n\t\t\tthis.coefficients.push(new Vector3());\n\t\t}\n\t}\n\n\tset(coefficients) {\n\t\tfor (let i = 0; i < 9; i++) {\n\t\t\tthis.coefficients[i].copy(coefficients[i]);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tzero() {\n\t\tfor (let i = 0; i < 9; i++) {\n\t\t\tthis.coefficients[i].set(0, 0, 0);\n\t\t}\n\n\t\treturn this;\n\t} // get the radiance in the direction of the normal\n\t// target is a Vector3\n\n\n\tgetAt(normal, target) {\n\t\t// normal is assumed to be unit length\n\t\tconst x = normal.x,\n\t\t\t\t\ty = normal.y,\n\t\t\t\t\tz = normal.z;\n\t\tconst coeff = this.coefficients; // band 0\n\n\t\ttarget.copy(coeff[0]).multiplyScalar(0.282095); // band 1\n\n\t\ttarget.addScaledVector(coeff[1], 0.488603 * y);\n\t\ttarget.addScaledVector(coeff[2], 0.488603 * z);\n\t\ttarget.addScaledVector(coeff[3], 0.488603 * x); // band 2\n\n\t\ttarget.addScaledVector(coeff[4], 1.092548 * (x * y));\n\t\ttarget.addScaledVector(coeff[5], 1.092548 * (y * z));\n\t\ttarget.addScaledVector(coeff[6], 0.315392 * (3.0 * z * z - 1.0));\n\t\ttarget.addScaledVector(coeff[7], 1.092548 * (x * z));\n\t\ttarget.addScaledVector(coeff[8], 0.546274 * (x * x - y * y));\n\t\treturn target;\n\t} // get the irradiance (radiance convolved with cosine lobe) in the direction of the normal\n\t// target is a Vector3\n\t// https://graphics.stanford.edu/papers/envmap/envmap.pdf\n\n\n\tgetIrradianceAt(normal, target) {\n\t\t// normal is assumed to be unit length\n\t\tconst x = normal.x,\n\t\t\t\t\ty = normal.y,\n\t\t\t\t\tz = normal.z;\n\t\tconst coeff = this.coefficients; // band 0\n\n\t\ttarget.copy(coeff[0]).multiplyScalar(0.886227); // Ï€ * 0.282095\n\t\t// band 1\n\n\t\ttarget.addScaledVector(coeff[1], 2.0 * 0.511664 * y); // ( 2 * Ï€ / 3 ) * 0.488603\n\n\t\ttarget.addScaledVector(coeff[2], 2.0 * 0.511664 * z);\n\t\ttarget.addScaledVector(coeff[3], 2.0 * 0.511664 * x); // band 2\n\n\t\ttarget.addScaledVector(coeff[4], 2.0 * 0.429043 * x * y); // ( Ï€ / 4 ) * 1.092548\n\n\t\ttarget.addScaledVector(coeff[5], 2.0 * 0.429043 * y * z);\n\t\ttarget.addScaledVector(coeff[6], 0.743125 * z * z - 0.247708); // ( Ï€ / 4 ) * 0.315392 * 3\n\n\t\ttarget.addScaledVector(coeff[7], 2.0 * 0.429043 * x * z);\n\t\ttarget.addScaledVector(coeff[8], 0.429043 * (x * x - y * y)); // ( Ï€ / 4 ) * 0.546274\n\n\t\treturn target;\n\t}\n\n\tadd(sh) {\n\t\tfor (let i = 0; i < 9; i++) {\n\t\t\tthis.coefficients[i].add(sh.coefficients[i]);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\taddScaledSH(sh, s) {\n\t\tfor (let i = 0; i < 9; i++) {\n\t\t\tthis.coefficients[i].addScaledVector(sh.coefficients[i], s);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tscale(s) {\n\t\tfor (let i = 0; i < 9; i++) {\n\t\t\tthis.coefficients[i].multiplyScalar(s);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tlerp(sh, alpha) {\n\t\tfor (let i = 0; i < 9; i++) {\n\t\t\tthis.coefficients[i].lerp(sh.coefficients[i], alpha);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tequals(sh) {\n\t\tfor (let i = 0; i < 9; i++) {\n\t\t\tif (!this.coefficients[i].equals(sh.coefficients[i])) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tcopy(sh) {\n\t\treturn this.set(sh.coefficients);\n\t}\n\n\tclone() {\n\t\treturn new this.constructor().copy(this);\n\t}\n\n\tfromArray(array, offset = 0) {\n\t\tconst coefficients = this.coefficients;\n\n\t\tfor (let i = 0; i < 9; i++) {\n\t\t\tcoefficients[i].fromArray(array, offset + i * 3);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\ttoArray(array = [], offset = 0) {\n\t\tconst coefficients = this.coefficients;\n\n\t\tfor (let i = 0; i < 9; i++) {\n\t\t\tcoefficients[i].toArray(array, offset + i * 3);\n\t\t}\n\n\t\treturn array;\n\t} // evaluate the basis functions\n\t// shBasis is an Array[ 9 ]\n\n\n\tstatic getBasisAt(normal, shBasis) {\n\t\t// normal is assumed to be unit length\n\t\tconst x = normal.x,\n\t\t\t\t\ty = normal.y,\n\t\t\t\t\tz = normal.z; // band 0\n\n\t\tshBasis[0] = 0.282095; // band 1\n\n\t\tshBasis[1] = 0.488603 * y;\n\t\tshBasis[2] = 0.488603 * z;\n\t\tshBasis[3] = 0.488603 * x; // band 2\n\n\t\tshBasis[4] = 1.092548 * x * y;\n\t\tshBasis[5] = 1.092548 * y * z;\n\t\tshBasis[6] = 0.315392 * (3 * z * z - 1);\n\t\tshBasis[7] = 1.092548 * x * z;\n\t\tshBasis[8] = 0.546274 * (x * x - y * y);\n\t}\n\n}\n\nclass LightProbe extends Light {\n\tconstructor(sh = new SphericalHarmonics3(), intensity = 1) {\n\t\tsuper(undefined, intensity);\n\t\tthis.isLightProbe = true;\n\t\tthis.sh = sh;\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.sh.copy(source.sh);\n\t\treturn this;\n\t}\n\n\tfromJSON(json) {\n\t\tthis.intensity = json.intensity; // TODO: Move this bit to Light.fromJSON();\n\n\t\tthis.sh.fromArray(json.sh);\n\t\treturn this;\n\t}\n\n\ttoJSON(meta) {\n\t\tconst data = super.toJSON(meta);\n\t\tdata.object.sh = this.sh.toArray();\n\t\treturn data;\n\t}\n\n}\n\nclass MaterialLoader extends Loader {\n\tconstructor(manager) {\n\t\tsuper(manager);\n\t\tthis.textures = {};\n\t}\n\n\tload(url, onLoad, onProgress, onError) {\n\t\tconst scope = this;\n\t\tconst loader = new FileLoader(scope.manager);\n\t\tloader.setPath(scope.path);\n\t\tloader.setRequestHeader(scope.requestHeader);\n\t\tloader.setWithCredentials(scope.withCredentials);\n\t\tloader.load(url, function (text) {\n\t\t\ttry {\n\t\t\t\tonLoad(scope.parse(JSON.parse(text)));\n\t\t\t} catch (e) {\n\t\t\t\tif (onError) {\n\t\t\t\t\tonError(e);\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(e);\n\t\t\t\t}\n\n\t\t\t\tscope.manager.itemError(url);\n\t\t\t}\n\t\t}, onProgress, onError);\n\t}\n\n\tparse(json) {\n\t\tconst textures = this.textures;\n\n\t\tfunction getTexture(name) {\n\t\t\tif (textures[name] === undefined) {\n\t\t\t\tconsole.warn('THREE.MaterialLoader: Undefined texture', name);\n\t\t\t}\n\n\t\t\treturn textures[name];\n\t\t}\n\n\t\tconst material = MaterialLoader.createMaterialFromType(json.type);\n\t\tif (json.uuid !== undefined) material.uuid = json.uuid;\n\t\tif (json.name !== undefined) material.name = json.name;\n\t\tif (json.color !== undefined && material.color !== undefined) material.color.setHex(json.color);\n\t\tif (json.roughness !== undefined) material.roughness = json.roughness;\n\t\tif (json.metalness !== undefined) material.metalness = json.metalness;\n\t\tif (json.sheen !== undefined) material.sheen = json.sheen;\n\t\tif (json.sheenColor !== undefined) material.sheenColor = new Color().setHex(json.sheenColor);\n\t\tif (json.sheenRoughness !== undefined) material.sheenRoughness = json.sheenRoughness;\n\t\tif (json.emissive !== undefined && material.emissive !== undefined) material.emissive.setHex(json.emissive);\n\t\tif (json.specular !== undefined && material.specular !== undefined) material.specular.setHex(json.specular);\n\t\tif (json.specularIntensity !== undefined) material.specularIntensity = json.specularIntensity;\n\t\tif (json.specularColor !== undefined && material.specularColor !== undefined) material.specularColor.setHex(json.specularColor);\n\t\tif (json.shininess !== undefined) material.shininess = json.shininess;\n\t\tif (json.clearcoat !== undefined) material.clearcoat = json.clearcoat;\n\t\tif (json.clearcoatRoughness !== undefined) material.clearcoatRoughness = json.clearcoatRoughness;\n\t\tif (json.iridescence !== undefined) material.iridescence = json.iridescence;\n\t\tif (json.iridescenceIOR !== undefined) material.iridescenceIOR = json.iridescenceIOR;\n\t\tif (json.iridescenceThicknessRange !== undefined) material.iridescenceThicknessRange = json.iridescenceThicknessRange;\n\t\tif (json.transmission !== undefined) material.transmission = json.transmission;\n\t\tif (json.thickness !== undefined) material.thickness = json.thickness;\n\t\tif (json.attenuationDistance !== undefined) material.attenuationDistance = json.attenuationDistance;\n\t\tif (json.attenuationColor !== undefined && material.attenuationColor !== undefined) material.attenuationColor.setHex(json.attenuationColor);\n\t\tif (json.fog !== undefined) material.fog = json.fog;\n\t\tif (json.flatShading !== undefined) material.flatShading = json.flatShading;\n\t\tif (json.blending !== undefined) material.blending = json.blending;\n\t\tif (json.combine !== undefined) material.combine = json.combine;\n\t\tif (json.side !== undefined) material.side = json.side;\n\t\tif (json.shadowSide !== undefined) material.shadowSide = json.shadowSide;\n\t\tif (json.opacity !== undefined) material.opacity = json.opacity;\n\t\tif (json.transparent !== undefined) material.transparent = json.transparent;\n\t\tif (json.alphaTest !== undefined) material.alphaTest = json.alphaTest;\n\t\tif (json.depthTest !== undefined) material.depthTest = json.depthTest;\n\t\tif (json.depthWrite !== undefined) material.depthWrite = json.depthWrite;\n\t\tif (json.colorWrite !== undefined) material.colorWrite = json.colorWrite;\n\t\tif (json.stencilWrite !== undefined) material.stencilWrite = json.stencilWrite;\n\t\tif (json.stencilWriteMask !== undefined) material.stencilWriteMask = json.stencilWriteMask;\n\t\tif (json.stencilFunc !== undefined) material.stencilFunc = json.stencilFunc;\n\t\tif (json.stencilRef !== undefined) material.stencilRef = json.stencilRef;\n\t\tif (json.stencilFuncMask !== undefined) material.stencilFuncMask = json.stencilFuncMask;\n\t\tif (json.stencilFail !== undefined) material.stencilFail = json.stencilFail;\n\t\tif (json.stencilZFail !== undefined) material.stencilZFail = json.stencilZFail;\n\t\tif (json.stencilZPass !== undefined) material.stencilZPass = json.stencilZPass;\n\t\tif (json.wireframe !== undefined) material.wireframe = json.wireframe;\n\t\tif (json.wireframeLinewidth !== undefined) material.wireframeLinewidth = json.wireframeLinewidth;\n\t\tif (json.wireframeLinecap !== undefined) material.wireframeLinecap = json.wireframeLinecap;\n\t\tif (json.wireframeLinejoin !== undefined) material.wireframeLinejoin = json.wireframeLinejoin;\n\t\tif (json.rotation !== undefined) material.rotation = json.rotation;\n\t\tif (json.linewidth !== 1) material.linewidth = json.linewidth;\n\t\tif (json.dashSize !== undefined) material.dashSize = json.dashSize;\n\t\tif (json.gapSize !== undefined) material.gapSize = json.gapSize;\n\t\tif (json.scale !== undefined) material.scale = json.scale;\n\t\tif (json.polygonOffset !== undefined) material.polygonOffset = json.polygonOffset;\n\t\tif (json.polygonOffsetFactor !== undefined) material.polygonOffsetFactor = json.polygonOffsetFactor;\n\t\tif (json.polygonOffsetUnits !== undefined) material.polygonOffsetUnits = json.polygonOffsetUnits;\n\t\tif (json.dithering !== undefined) material.dithering = json.dithering;\n\t\tif (json.alphaToCoverage !== undefined) material.alphaToCoverage = json.alphaToCoverage;\n\t\tif (json.premultipliedAlpha !== undefined) material.premultipliedAlpha = json.premultipliedAlpha;\n\t\tif (json.visible !== undefined) material.visible = json.visible;\n\t\tif (json.toneMapped !== undefined) material.toneMapped = json.toneMapped;\n\t\tif (json.userData !== undefined) material.userData = json.userData;\n\n\t\tif (json.vertexColors !== undefined) {\n\t\t\tif (typeof json.vertexColors === 'number') {\n\t\t\t\tmaterial.vertexColors = json.vertexColors > 0 ? true : false;\n\t\t\t} else {\n\t\t\t\tmaterial.vertexColors = json.vertexColors;\n\t\t\t}\n\t\t} // Shader Material\n\n\n\t\tif (json.uniforms !== undefined) {\n\t\t\tfor (const name in json.uniforms) {\n\t\t\t\tconst uniform = json.uniforms[name];\n\t\t\t\tmaterial.uniforms[name] = {};\n\n\t\t\t\tswitch (uniform.type) {\n\t\t\t\t\tcase 't':\n\t\t\t\t\t\tmaterial.uniforms[name].value = getTexture(uniform.value);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'c':\n\t\t\t\t\t\tmaterial.uniforms[name].value = new Color().setHex(uniform.value);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'v2':\n\t\t\t\t\t\tmaterial.uniforms[name].value = new Vector2().fromArray(uniform.value);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'v3':\n\t\t\t\t\t\tmaterial.uniforms[name].value = new Vector3().fromArray(uniform.value);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'v4':\n\t\t\t\t\t\tmaterial.uniforms[name].value = new Vector4().fromArray(uniform.value);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'm3':\n\t\t\t\t\t\tmaterial.uniforms[name].value = new Matrix3().fromArray(uniform.value);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'm4':\n\t\t\t\t\t\tmaterial.uniforms[name].value = new Matrix4().fromArray(uniform.value);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tmaterial.uniforms[name].value = uniform.value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (json.defines !== undefined) material.defines = json.defines;\n\t\tif (json.vertexShader !== undefined) material.vertexShader = json.vertexShader;\n\t\tif (json.fragmentShader !== undefined) material.fragmentShader = json.fragmentShader;\n\t\tif (json.glslVersion !== undefined) material.glslVersion = json.glslVersion;\n\n\t\tif (json.extensions !== undefined) {\n\t\t\tfor (const key in json.extensions) {\n\t\t\t\tmaterial.extensions[key] = json.extensions[key];\n\t\t\t}\n\t\t} // for PointsMaterial\n\n\n\t\tif (json.size !== undefined) material.size = json.size;\n\t\tif (json.sizeAttenuation !== undefined) material.sizeAttenuation = json.sizeAttenuation; // maps\n\n\t\tif (json.map !== undefined) material.map = getTexture(json.map);\n\t\tif (json.matcap !== undefined) material.matcap = getTexture(json.matcap);\n\t\tif (json.alphaMap !== undefined) material.alphaMap = getTexture(json.alphaMap);\n\t\tif (json.bumpMap !== undefined) material.bumpMap = getTexture(json.bumpMap);\n\t\tif (json.bumpScale !== undefined) material.bumpScale = json.bumpScale;\n\t\tif (json.normalMap !== undefined) material.normalMap = getTexture(json.normalMap);\n\t\tif (json.normalMapType !== undefined) material.normalMapType = json.normalMapType;\n\n\t\tif (json.normalScale !== undefined) {\n\t\t\tlet normalScale = json.normalScale;\n\n\t\t\tif (Array.isArray(normalScale) === false) {\n\t\t\t\t// Blender exporter used to export a scalar. See #7459\n\t\t\t\tnormalScale = [normalScale, normalScale];\n\t\t\t}\n\n\t\t\tmaterial.normalScale = new Vector2().fromArray(normalScale);\n\t\t}\n\n\t\tif (json.displacementMap !== undefined) material.displacementMap = getTexture(json.displacementMap);\n\t\tif (json.displacementScale !== undefined) material.displacementScale = json.displacementScale;\n\t\tif (json.displacementBias !== undefined) material.displacementBias = json.displacementBias;\n\t\tif (json.roughnessMap !== undefined) material.roughnessMap = getTexture(json.roughnessMap);\n\t\tif (json.metalnessMap !== undefined) material.metalnessMap = getTexture(json.metalnessMap);\n\t\tif (json.emissiveMap !== undefined) material.emissiveMap = getTexture(json.emissiveMap);\n\t\tif (json.emissiveIntensity !== undefined) material.emissiveIntensity = json.emissiveIntensity;\n\t\tif (json.specularMap !== undefined) material.specularMap = getTexture(json.specularMap);\n\t\tif (json.specularIntensityMap !== undefined) material.specularIntensityMap = getTexture(json.specularIntensityMap);\n\t\tif (json.specularColorMap !== undefined) material.specularColorMap = getTexture(json.specularColorMap);\n\t\tif (json.envMap !== undefined) material.envMap = getTexture(json.envMap);\n\t\tif (json.envMapIntensity !== undefined) material.envMapIntensity = json.envMapIntensity;\n\t\tif (json.reflectivity !== undefined) material.reflectivity = json.reflectivity;\n\t\tif (json.refractionRatio !== undefined) material.refractionRatio = json.refractionRatio;\n\t\tif (json.lightMap !== undefined) material.lightMap = getTexture(json.lightMap);\n\t\tif (json.lightMapIntensity !== undefined) material.lightMapIntensity = json.lightMapIntensity;\n\t\tif (json.aoMap !== undefined) material.aoMap = getTexture(json.aoMap);\n\t\tif (json.aoMapIntensity !== undefined) material.aoMapIntensity = json.aoMapIntensity;\n\t\tif (json.gradientMap !== undefined) material.gradientMap = getTexture(json.gradientMap);\n\t\tif (json.clearcoatMap !== undefined) material.clearcoatMap = getTexture(json.clearcoatMap);\n\t\tif (json.clearcoatRoughnessMap !== undefined) material.clearcoatRoughnessMap = getTexture(json.clearcoatRoughnessMap);\n\t\tif (json.clearcoatNormalMap !== undefined) material.clearcoatNormalMap = getTexture(json.clearcoatNormalMap);\n\t\tif (json.clearcoatNormalScale !== undefined) material.clearcoatNormalScale = new Vector2().fromArray(json.clearcoatNormalScale);\n\t\tif (json.iridescenceMap !== undefined) material.iridescenceMap = getTexture(json.iridescenceMap);\n\t\tif (json.iridescenceThicknessMap !== undefined) material.iridescenceThicknessMap = getTexture(json.iridescenceThicknessMap);\n\t\tif (json.transmissionMap !== undefined) material.transmissionMap = getTexture(json.transmissionMap);\n\t\tif (json.thicknessMap !== undefined) material.thicknessMap = getTexture(json.thicknessMap);\n\t\tif (json.sheenColorMap !== undefined) material.sheenColorMap = getTexture(json.sheenColorMap);\n\t\tif (json.sheenRoughnessMap !== undefined) material.sheenRoughnessMap = getTexture(json.sheenRoughnessMap);\n\t\treturn material;\n\t}\n\n\tsetTextures(value) {\n\t\tthis.textures = value;\n\t\treturn this;\n\t}\n\n\tstatic createMaterialFromType(type) {\n\t\tconst materialLib = {\n\t\t\tShadowMaterial,\n\t\t\tSpriteMaterial,\n\t\t\tRawShaderMaterial,\n\t\t\tShaderMaterial,\n\t\t\tPointsMaterial,\n\t\t\tMeshPhysicalMaterial,\n\t\t\tMeshStandardMaterial,\n\t\t\tMeshPhongMaterial,\n\t\t\tMeshToonMaterial,\n\t\t\tMeshNormalMaterial,\n\t\t\tMeshLambertMaterial,\n\t\t\tMeshDepthMaterial,\n\t\t\tMeshDistanceMaterial,\n\t\t\tMeshBasicMaterial,\n\t\t\tMeshMatcapMaterial,\n\t\t\tLineDashedMaterial,\n\t\t\tLineBasicMaterial,\n\t\t\tMaterial\n\t\t};\n\t\treturn new materialLib[type]();\n\t}\n\n}\n\nclass LoaderUtils {\n\tstatic decodeText(array) {\n\t\tif (typeof TextDecoder !== 'undefined') {\n\t\t\treturn new TextDecoder().decode(array);\n\t\t} // Avoid the String.fromCharCode.apply(null, array) shortcut, which\n\t\t// throws a \"maximum call stack size exceeded\" error for large arrays.\n\n\n\t\tlet s = '';\n\n\t\tfor (let i = 0, il = array.length; i < il; i++) {\n\t\t\t// Implicitly assumes little-endian.\n\t\t\ts += String.fromCharCode(array[i]);\n\t\t}\n\n\t\ttry {\n\t\t\t// merges multi-byte utf-8 characters.\n\t\t\treturn decodeURIComponent(escape(s));\n\t\t} catch (e) {\n\t\t\t// see #16358\n\t\t\treturn s;\n\t\t}\n\t}\n\n\tstatic extractUrlBase(url) {\n\t\tconst index = url.lastIndexOf('/');\n\t\tif (index === -1) return './';\n\t\treturn url.slice(0, index + 1);\n\t}\n\n\tstatic resolveURL(url, path) {\n\t\t// Invalid URL\n\t\tif (typeof url !== 'string' || url === '') return ''; // Host Relative URL\n\n\t\tif (/^https?:\\/\\//i.test(path) && /^\\//.test(url)) {\n\t\t\tpath = path.replace(/(^https?:\\/\\/[^\\/]+).*/i, '$1');\n\t\t} // Absolute URL http://,https://,//\n\n\n\t\tif (/^(https?:)?\\/\\//i.test(url)) return url; // Data URI\n\n\t\tif (/^data:.*,.*$/i.test(url)) return url; // Blob URL\n\n\t\tif (/^blob:.*$/i.test(url)) return url; // Relative URL\n\n\t\treturn path + url;\n\t}\n\n}\n\nclass InstancedBufferGeometry extends BufferGeometry {\n\tconstructor() {\n\t\tsuper();\n\t\tthis.isInstancedBufferGeometry = true;\n\t\tthis.type = 'InstancedBufferGeometry';\n\t\tthis.instanceCount = Infinity;\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.instanceCount = source.instanceCount;\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\treturn new this.constructor().copy(this);\n\t}\n\n\ttoJSON() {\n\t\tconst data = super.toJSON(this);\n\t\tdata.instanceCount = this.instanceCount;\n\t\tdata.isInstancedBufferGeometry = true;\n\t\treturn data;\n\t}\n\n}\n\nclass BufferGeometryLoader extends Loader {\n\tconstructor(manager) {\n\t\tsuper(manager);\n\t}\n\n\tload(url, onLoad, onProgress, onError) {\n\t\tconst scope = this;\n\t\tconst loader = new FileLoader(scope.manager);\n\t\tloader.setPath(scope.path);\n\t\tloader.setRequestHeader(scope.requestHeader);\n\t\tloader.setWithCredentials(scope.withCredentials);\n\t\tloader.load(url, function (text) {\n\t\t\ttry {\n\t\t\t\tonLoad(scope.parse(JSON.parse(text)));\n\t\t\t} catch (e) {\n\t\t\t\tif (onError) {\n\t\t\t\t\tonError(e);\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(e);\n\t\t\t\t}\n\n\t\t\t\tscope.manager.itemError(url);\n\t\t\t}\n\t\t}, onProgress, onError);\n\t}\n\n\tparse(json) {\n\t\tconst interleavedBufferMap = {};\n\t\tconst arrayBufferMap = {};\n\n\t\tfunction getInterleavedBuffer(json, uuid) {\n\t\t\tif (interleavedBufferMap[uuid] !== undefined) return interleavedBufferMap[uuid];\n\t\t\tconst interleavedBuffers = json.interleavedBuffers;\n\t\t\tconst interleavedBuffer = interleavedBuffers[uuid];\n\t\t\tconst buffer = getArrayBuffer(json, interleavedBuffer.buffer);\n\t\t\tconst array = getTypedArray(interleavedBuffer.type, buffer);\n\t\t\tconst ib = new InterleavedBuffer(array, interleavedBuffer.stride);\n\t\t\tib.uuid = interleavedBuffer.uuid;\n\t\t\tinterleavedBufferMap[uuid] = ib;\n\t\t\treturn ib;\n\t\t}\n\n\t\tfunction getArrayBuffer(json, uuid) {\n\t\t\tif (arrayBufferMap[uuid] !== undefined) return arrayBufferMap[uuid];\n\t\t\tconst arrayBuffers = json.arrayBuffers;\n\t\t\tconst arrayBuffer = arrayBuffers[uuid];\n\t\t\tconst ab = new Uint32Array(arrayBuffer).buffer;\n\t\t\tarrayBufferMap[uuid] = ab;\n\t\t\treturn ab;\n\t\t}\n\n\t\tconst geometry = json.isInstancedBufferGeometry ? new InstancedBufferGeometry() : new BufferGeometry();\n\t\tconst index = json.data.index;\n\n\t\tif (index !== undefined) {\n\t\t\tconst typedArray = getTypedArray(index.type, index.array);\n\t\t\tgeometry.setIndex(new BufferAttribute(typedArray, 1));\n\t\t}\n\n\t\tconst attributes = json.data.attributes;\n\n\t\tfor (const key in attributes) {\n\t\t\tconst attribute = attributes[key];\n\t\t\tlet bufferAttribute;\n\n\t\t\tif (attribute.isInterleavedBufferAttribute) {\n\t\t\t\tconst interleavedBuffer = getInterleavedBuffer(json.data, attribute.data);\n\t\t\t\tbufferAttribute = new InterleavedBufferAttribute(interleavedBuffer, attribute.itemSize, attribute.offset, attribute.normalized);\n\t\t\t} else {\n\t\t\t\tconst typedArray = getTypedArray(attribute.type, attribute.array);\n\t\t\t\tconst bufferAttributeConstr = attribute.isInstancedBufferAttribute ? InstancedBufferAttribute : BufferAttribute;\n\t\t\t\tbufferAttribute = new bufferAttributeConstr(typedArray, attribute.itemSize, attribute.normalized);\n\t\t\t}\n\n\t\t\tif (attribute.name !== undefined) bufferAttribute.name = attribute.name;\n\t\t\tif (attribute.usage !== undefined) bufferAttribute.setUsage(attribute.usage);\n\n\t\t\tif (attribute.updateRange !== undefined) {\n\t\t\t\tbufferAttribute.updateRange.offset = attribute.updateRange.offset;\n\t\t\t\tbufferAttribute.updateRange.count = attribute.updateRange.count;\n\t\t\t}\n\n\t\t\tgeometry.setAttribute(key, bufferAttribute);\n\t\t}\n\n\t\tconst morphAttributes = json.data.morphAttributes;\n\n\t\tif (morphAttributes) {\n\t\t\tfor (const key in morphAttributes) {\n\t\t\t\tconst attributeArray = morphAttributes[key];\n\t\t\t\tconst array = [];\n\n\t\t\t\tfor (let i = 0, il = attributeArray.length; i < il; i++) {\n\t\t\t\t\tconst attribute = attributeArray[i];\n\t\t\t\t\tlet bufferAttribute;\n\n\t\t\t\t\tif (attribute.isInterleavedBufferAttribute) {\n\t\t\t\t\t\tconst interleavedBuffer = getInterleavedBuffer(json.data, attribute.data);\n\t\t\t\t\t\tbufferAttribute = new InterleavedBufferAttribute(interleavedBuffer, attribute.itemSize, attribute.offset, attribute.normalized);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst typedArray = getTypedArray(attribute.type, attribute.array);\n\t\t\t\t\t\tbufferAttribute = new BufferAttribute(typedArray, attribute.itemSize, attribute.normalized);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (attribute.name !== undefined) bufferAttribute.name = attribute.name;\n\t\t\t\t\tarray.push(bufferAttribute);\n\t\t\t\t}\n\n\t\t\t\tgeometry.morphAttributes[key] = array;\n\t\t\t}\n\t\t}\n\n\t\tconst morphTargetsRelative = json.data.morphTargetsRelative;\n\n\t\tif (morphTargetsRelative) {\n\t\t\tgeometry.morphTargetsRelative = true;\n\t\t}\n\n\t\tconst groups = json.data.groups || json.data.drawcalls || json.data.offsets;\n\n\t\tif (groups !== undefined) {\n\t\t\tfor (let i = 0, n = groups.length; i !== n; ++i) {\n\t\t\t\tconst group = groups[i];\n\t\t\t\tgeometry.addGroup(group.start, group.count, group.materialIndex);\n\t\t\t}\n\t\t}\n\n\t\tconst boundingSphere = json.data.boundingSphere;\n\n\t\tif (boundingSphere !== undefined) {\n\t\t\tconst center = new Vector3();\n\n\t\t\tif (boundingSphere.center !== undefined) {\n\t\t\t\tcenter.fromArray(boundingSphere.center);\n\t\t\t}\n\n\t\t\tgeometry.boundingSphere = new Sphere(center, boundingSphere.radius);\n\t\t}\n\n\t\tif (json.name) geometry.name = json.name;\n\t\tif (json.userData) geometry.userData = json.userData;\n\t\treturn geometry;\n\t}\n\n}\n\nclass ObjectLoader extends Loader {\n\tconstructor(manager) {\n\t\tsuper(manager);\n\t}\n\n\tload(url, onLoad, onProgress, onError) {\n\t\tconst scope = this;\n\t\tconst path = this.path === '' ? LoaderUtils.extractUrlBase(url) : this.path;\n\t\tthis.resourcePath = this.resourcePath || path;\n\t\tconst loader = new FileLoader(this.manager);\n\t\tloader.setPath(this.path);\n\t\tloader.setRequestHeader(this.requestHeader);\n\t\tloader.setWithCredentials(this.withCredentials);\n\t\tloader.load(url, function (text) {\n\t\t\tlet json = null;\n\n\t\t\ttry {\n\t\t\t\tjson = JSON.parse(text);\n\t\t\t} catch (error) {\n\t\t\t\tif (onError !== undefined) onError(error);\n\t\t\t\tconsole.error('THREE:ObjectLoader: Can\\'t parse ' + url + '.', error.message);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst metadata = json.metadata;\n\n\t\t\tif (metadata === undefined || metadata.type === undefined || metadata.type.toLowerCase() === 'geometry') {\n\t\t\t\tconsole.error('THREE.ObjectLoader: Can\\'t load ' + url);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tscope.parse(json, onLoad);\n\t\t}, onProgress, onError);\n\t}\n\n\tasync loadAsync(url, onProgress) {\n\t\tconst scope = this;\n\t\tconst path = this.path === '' ? LoaderUtils.extractUrlBase(url) : this.path;\n\t\tthis.resourcePath = this.resourcePath || path;\n\t\tconst loader = new FileLoader(this.manager);\n\t\tloader.setPath(this.path);\n\t\tloader.setRequestHeader(this.requestHeader);\n\t\tloader.setWithCredentials(this.withCredentials);\n\t\tconst text = await loader.loadAsync(url, onProgress);\n\t\tconst json = JSON.parse(text);\n\t\tconst metadata = json.metadata;\n\n\t\tif (metadata === undefined || metadata.type === undefined || metadata.type.toLowerCase() === 'geometry') {\n\t\t\tthrow new Error('THREE.ObjectLoader: Can\\'t load ' + url);\n\t\t}\n\n\t\treturn await scope.parseAsync(json);\n\t}\n\n\tparse(json, onLoad) {\n\t\tconst animations = this.parseAnimations(json.animations);\n\t\tconst shapes = this.parseShapes(json.shapes);\n\t\tconst geometries = this.parseGeometries(json.geometries, shapes);\n\t\tconst images = this.parseImages(json.images, function () {\n\t\t\tif (onLoad !== undefined) onLoad(object);\n\t\t});\n\t\tconst textures = this.parseTextures(json.textures, images);\n\t\tconst materials = this.parseMaterials(json.materials, textures);\n\t\tconst object = this.parseObject(json.object, geometries, materials, textures, animations);\n\t\tconst skeletons = this.parseSkeletons(json.skeletons, object);\n\t\tthis.bindSkeletons(object, skeletons); //\n\n\t\tif (onLoad !== undefined) {\n\t\t\tlet hasImages = false;\n\n\t\t\tfor (const uuid in images) {\n\t\t\t\tif (images[uuid].data instanceof HTMLImageElement) {\n\t\t\t\t\thasImages = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (hasImages === false) onLoad(object);\n\t\t}\n\n\t\treturn object;\n\t}\n\n\tasync parseAsync(json) {\n\t\tconst animations = this.parseAnimations(json.animations);\n\t\tconst shapes = this.parseShapes(json.shapes);\n\t\tconst geometries = this.parseGeometries(json.geometries, shapes);\n\t\tconst images = await this.parseImagesAsync(json.images);\n\t\tconst textures = this.parseTextures(json.textures, images);\n\t\tconst materials = this.parseMaterials(json.materials, textures);\n\t\tconst object = this.parseObject(json.object, geometries, materials, textures, animations);\n\t\tconst skeletons = this.parseSkeletons(json.skeletons, object);\n\t\tthis.bindSkeletons(object, skeletons);\n\t\treturn object;\n\t}\n\n\tparseShapes(json) {\n\t\tconst shapes = {};\n\n\t\tif (json !== undefined) {\n\t\t\tfor (let i = 0, l = json.length; i < l; i++) {\n\t\t\t\tconst shape = new Shape().fromJSON(json[i]);\n\t\t\t\tshapes[shape.uuid] = shape;\n\t\t\t}\n\t\t}\n\n\t\treturn shapes;\n\t}\n\n\tparseSkeletons(json, object) {\n\t\tconst skeletons = {};\n\t\tconst bones = {}; // generate bone lookup table\n\n\t\tobject.traverse(function (child) {\n\t\t\tif (child.isBone) bones[child.uuid] = child;\n\t\t}); // create skeletons\n\n\t\tif (json !== undefined) {\n\t\t\tfor (let i = 0, l = json.length; i < l; i++) {\n\t\t\t\tconst skeleton = new Skeleton().fromJSON(json[i], bones);\n\t\t\t\tskeletons[skeleton.uuid] = skeleton;\n\t\t\t}\n\t\t}\n\n\t\treturn skeletons;\n\t}\n\n\tparseGeometries(json, shapes) {\n\t\tconst geometries = {};\n\n\t\tif (json !== undefined) {\n\t\t\tconst bufferGeometryLoader = new BufferGeometryLoader();\n\n\t\t\tfor (let i = 0, l = json.length; i < l; i++) {\n\t\t\t\tlet geometry;\n\t\t\t\tconst data = json[i];\n\n\t\t\t\tswitch (data.type) {\n\t\t\t\t\tcase 'BufferGeometry':\n\t\t\t\t\tcase 'InstancedBufferGeometry':\n\t\t\t\t\t\tgeometry = bufferGeometryLoader.parse(data);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tif (data.type in Geometries) {\n\t\t\t\t\t\t\tgeometry = Geometries[data.type].fromJSON(data, shapes);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconsole.warn(`THREE.ObjectLoader: Unsupported geometry type \"${data.type}\"`);\n\t\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tgeometry.uuid = data.uuid;\n\t\t\t\tif (data.name !== undefined) geometry.name = data.name;\n\t\t\t\tif (geometry.isBufferGeometry === true && data.userData !== undefined) geometry.userData = data.userData;\n\t\t\t\tgeometries[data.uuid] = geometry;\n\t\t\t}\n\t\t}\n\n\t\treturn geometries;\n\t}\n\n\tparseMaterials(json, textures) {\n\t\tconst cache = {}; // MultiMaterial\n\n\t\tconst materials = {};\n\n\t\tif (json !== undefined) {\n\t\t\tconst loader = new MaterialLoader();\n\t\t\tloader.setTextures(textures);\n\n\t\t\tfor (let i = 0, l = json.length; i < l; i++) {\n\t\t\t\tconst data = json[i];\n\n\t\t\t\tif (cache[data.uuid] === undefined) {\n\t\t\t\t\tcache[data.uuid] = loader.parse(data);\n\t\t\t\t}\n\n\t\t\t\tmaterials[data.uuid] = cache[data.uuid];\n\t\t\t}\n\t\t}\n\n\t\treturn materials;\n\t}\n\n\tparseAnimations(json) {\n\t\tconst animations = {};\n\n\t\tif (json !== undefined) {\n\t\t\tfor (let i = 0; i < json.length; i++) {\n\t\t\t\tconst data = json[i];\n\t\t\t\tconst clip = AnimationClip.parse(data);\n\t\t\t\tanimations[clip.uuid] = clip;\n\t\t\t}\n\t\t}\n\n\t\treturn animations;\n\t}\n\n\tparseImages(json, onLoad) {\n\t\tconst scope = this;\n\t\tconst images = {};\n\t\tlet loader;\n\n\t\tfunction loadImage(url) {\n\t\t\tscope.manager.itemStart(url);\n\t\t\treturn loader.load(url, function () {\n\t\t\t\tscope.manager.itemEnd(url);\n\t\t\t}, undefined, function () {\n\t\t\t\tscope.manager.itemError(url);\n\t\t\t\tscope.manager.itemEnd(url);\n\t\t\t});\n\t\t}\n\n\t\tfunction deserializeImage(image) {\n\t\t\tif (typeof image === 'string') {\n\t\t\t\tconst url = image;\n\t\t\t\tconst path = /^(\\/\\/)|([a-z]+:(\\/\\/)?)/i.test(url) ? url : scope.resourcePath + url;\n\t\t\t\treturn loadImage(path);\n\t\t\t} else {\n\t\t\t\tif (image.data) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdata: getTypedArray(image.type, image.data),\n\t\t\t\t\t\twidth: image.width,\n\t\t\t\t\t\theight: image.height\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (json !== undefined && json.length > 0) {\n\t\t\tconst manager = new LoadingManager(onLoad);\n\t\t\tloader = new ImageLoader(manager);\n\t\t\tloader.setCrossOrigin(this.crossOrigin);\n\n\t\t\tfor (let i = 0, il = json.length; i < il; i++) {\n\t\t\t\tconst image = json[i];\n\t\t\t\tconst url = image.url;\n\n\t\t\t\tif (Array.isArray(url)) {\n\t\t\t\t\t// load array of images e.g CubeTexture\n\t\t\t\t\tconst imageArray = [];\n\n\t\t\t\t\tfor (let j = 0, jl = url.length; j < jl; j++) {\n\t\t\t\t\t\tconst currentUrl = url[j];\n\t\t\t\t\t\tconst deserializedImage = deserializeImage(currentUrl);\n\n\t\t\t\t\t\tif (deserializedImage !== null) {\n\t\t\t\t\t\t\tif (deserializedImage instanceof HTMLImageElement) {\n\t\t\t\t\t\t\t\timageArray.push(deserializedImage);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// special case: handle array of data textures for cube textures\n\t\t\t\t\t\t\t\timageArray.push(new DataTexture(deserializedImage.data, deserializedImage.width, deserializedImage.height));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\timages[image.uuid] = new Source(imageArray);\n\t\t\t\t} else {\n\t\t\t\t\t// load single image\n\t\t\t\t\tconst deserializedImage = deserializeImage(image.url);\n\t\t\t\t\timages[image.uuid] = new Source(deserializedImage);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn images;\n\t}\n\n\tasync parseImagesAsync(json) {\n\t\tconst scope = this;\n\t\tconst images = {};\n\t\tlet loader;\n\n\t\tasync function deserializeImage(image) {\n\t\t\tif (typeof image === 'string') {\n\t\t\t\tconst url = image;\n\t\t\t\tconst path = /^(\\/\\/)|([a-z]+:(\\/\\/)?)/i.test(url) ? url : scope.resourcePath + url;\n\t\t\t\treturn await loader.loadAsync(path);\n\t\t\t} else {\n\t\t\t\tif (image.data) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdata: getTypedArray(image.type, image.data),\n\t\t\t\t\t\twidth: image.width,\n\t\t\t\t\t\theight: image.height\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (json !== undefined && json.length > 0) {\n\t\t\tloader = new ImageLoader(this.manager);\n\t\t\tloader.setCrossOrigin(this.crossOrigin);\n\n\t\t\tfor (let i = 0, il = json.length; i < il; i++) {\n\t\t\t\tconst image = json[i];\n\t\t\t\tconst url = image.url;\n\n\t\t\t\tif (Array.isArray(url)) {\n\t\t\t\t\t// load array of images e.g CubeTexture\n\t\t\t\t\tconst imageArray = [];\n\n\t\t\t\t\tfor (let j = 0, jl = url.length; j < jl; j++) {\n\t\t\t\t\t\tconst currentUrl = url[j];\n\t\t\t\t\t\tconst deserializedImage = await deserializeImage(currentUrl);\n\n\t\t\t\t\t\tif (deserializedImage !== null) {\n\t\t\t\t\t\t\tif (deserializedImage instanceof HTMLImageElement) {\n\t\t\t\t\t\t\t\timageArray.push(deserializedImage);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// special case: handle array of data textures for cube textures\n\t\t\t\t\t\t\t\timageArray.push(new DataTexture(deserializedImage.data, deserializedImage.width, deserializedImage.height));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\timages[image.uuid] = new Source(imageArray);\n\t\t\t\t} else {\n\t\t\t\t\t// load single image\n\t\t\t\t\tconst deserializedImage = await deserializeImage(image.url);\n\t\t\t\t\timages[image.uuid] = new Source(deserializedImage);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn images;\n\t}\n\n\tparseTextures(json, images) {\n\t\tfunction parseConstant(value, type) {\n\t\t\tif (typeof value === 'number') return value;\n\t\t\tconsole.warn('THREE.ObjectLoader.parseTexture: Constant should be in numeric form.', value);\n\t\t\treturn type[value];\n\t\t}\n\n\t\tconst textures = {};\n\n\t\tif (json !== undefined) {\n\t\t\tfor (let i = 0, l = json.length; i < l; i++) {\n\t\t\t\tconst data = json[i];\n\n\t\t\t\tif (data.image === undefined) {\n\t\t\t\t\tconsole.warn('THREE.ObjectLoader: No \"image\" specified for', data.uuid);\n\t\t\t\t}\n\n\t\t\t\tif (images[data.image] === undefined) {\n\t\t\t\t\tconsole.warn('THREE.ObjectLoader: Undefined image', data.image);\n\t\t\t\t}\n\n\t\t\t\tconst source = images[data.image];\n\t\t\t\tconst image = source.data;\n\t\t\t\tlet texture;\n\n\t\t\t\tif (Array.isArray(image)) {\n\t\t\t\t\ttexture = new CubeTexture();\n\t\t\t\t\tif (image.length === 6) texture.needsUpdate = true;\n\t\t\t\t} else {\n\t\t\t\t\tif (image && image.data) {\n\t\t\t\t\t\ttexture = new DataTexture();\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttexture = new Texture();\n\t\t\t\t\t}\n\n\t\t\t\t\tif (image) texture.needsUpdate = true; // textures can have undefined image data\n\t\t\t\t}\n\n\t\t\t\ttexture.source = source;\n\t\t\t\ttexture.uuid = data.uuid;\n\t\t\t\tif (data.name !== undefined) texture.name = data.name;\n\t\t\t\tif (data.mapping !== undefined) texture.mapping = parseConstant(data.mapping, TEXTURE_MAPPING);\n\t\t\t\tif (data.offset !== undefined) texture.offset.fromArray(data.offset);\n\t\t\t\tif (data.repeat !== undefined) texture.repeat.fromArray(data.repeat);\n\t\t\t\tif (data.center !== undefined) texture.center.fromArray(data.center);\n\t\t\t\tif (data.rotation !== undefined) texture.rotation = data.rotation;\n\n\t\t\t\tif (data.wrap !== undefined) {\n\t\t\t\t\ttexture.wrapS = parseConstant(data.wrap[0], TEXTURE_WRAPPING);\n\t\t\t\t\ttexture.wrapT = parseConstant(data.wrap[1], TEXTURE_WRAPPING);\n\t\t\t\t}\n\n\t\t\t\tif (data.format !== undefined) texture.format = data.format;\n\t\t\t\tif (data.type !== undefined) texture.type = data.type;\n\t\t\t\tif (data.encoding !== undefined) texture.encoding = data.encoding;\n\t\t\t\tif (data.minFilter !== undefined) texture.minFilter = parseConstant(data.minFilter, TEXTURE_FILTER);\n\t\t\t\tif (data.magFilter !== undefined) texture.magFilter = parseConstant(data.magFilter, TEXTURE_FILTER);\n\t\t\t\tif (data.anisotropy !== undefined) texture.anisotropy = data.anisotropy;\n\t\t\t\tif (data.flipY !== undefined) texture.flipY = data.flipY;\n\t\t\t\tif (data.premultiplyAlpha !== undefined) texture.premultiplyAlpha = data.premultiplyAlpha;\n\t\t\t\tif (data.unpackAlignment !== undefined) texture.unpackAlignment = data.unpackAlignment;\n\t\t\t\tif (data.userData !== undefined) texture.userData = data.userData;\n\t\t\t\ttextures[data.uuid] = texture;\n\t\t\t}\n\t\t}\n\n\t\treturn textures;\n\t}\n\n\tparseObject(data, geometries, materials, textures, animations) {\n\t\tlet object;\n\n\t\tfunction getGeometry(name) {\n\t\t\tif (geometries[name] === undefined) {\n\t\t\t\tconsole.warn('THREE.ObjectLoader: Undefined geometry', name);\n\t\t\t}\n\n\t\t\treturn geometries[name];\n\t\t}\n\n\t\tfunction getMaterial(name) {\n\t\t\tif (name === undefined) return undefined;\n\n\t\t\tif (Array.isArray(name)) {\n\t\t\t\tconst array = [];\n\n\t\t\t\tfor (let i = 0, l = name.length; i < l; i++) {\n\t\t\t\t\tconst uuid = name[i];\n\n\t\t\t\t\tif (materials[uuid] === undefined) {\n\t\t\t\t\t\tconsole.warn('THREE.ObjectLoader: Undefined material', uuid);\n\t\t\t\t\t}\n\n\t\t\t\t\tarray.push(materials[uuid]);\n\t\t\t\t}\n\n\t\t\t\treturn array;\n\t\t\t}\n\n\t\t\tif (materials[name] === undefined) {\n\t\t\t\tconsole.warn('THREE.ObjectLoader: Undefined material', name);\n\t\t\t}\n\n\t\t\treturn materials[name];\n\t\t}\n\n\t\tfunction getTexture(uuid) {\n\t\t\tif (textures[uuid] === undefined) {\n\t\t\t\tconsole.warn('THREE.ObjectLoader: Undefined texture', uuid);\n\t\t\t}\n\n\t\t\treturn textures[uuid];\n\t\t}\n\n\t\tlet geometry, material;\n\n\t\tswitch (data.type) {\n\t\t\tcase 'Scene':\n\t\t\t\tobject = new Scene();\n\n\t\t\t\tif (data.background !== undefined) {\n\t\t\t\t\tif (Number.isInteger(data.background)) {\n\t\t\t\t\t\tobject.background = new Color(data.background);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tobject.background = getTexture(data.background);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (data.environment !== undefined) {\n\t\t\t\t\tobject.environment = getTexture(data.environment);\n\t\t\t\t}\n\n\t\t\t\tif (data.fog !== undefined) {\n\t\t\t\t\tif (data.fog.type === 'Fog') {\n\t\t\t\t\t\tobject.fog = new Fog(data.fog.color, data.fog.near, data.fog.far);\n\t\t\t\t\t} else if (data.fog.type === 'FogExp2') {\n\t\t\t\t\t\tobject.fog = new FogExp2(data.fog.color, data.fog.density);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'PerspectiveCamera':\n\t\t\t\tobject = new PerspectiveCamera(data.fov, data.aspect, data.near, data.far);\n\t\t\t\tif (data.focus !== undefined) object.focus = data.focus;\n\t\t\t\tif (data.zoom !== undefined) object.zoom = data.zoom;\n\t\t\t\tif (data.filmGauge !== undefined) object.filmGauge = data.filmGauge;\n\t\t\t\tif (data.filmOffset !== undefined) object.filmOffset = data.filmOffset;\n\t\t\t\tif (data.view !== undefined) object.view = Object.assign({}, data.view);\n\t\t\t\tbreak;\n\n\t\t\tcase 'OrthographicCamera':\n\t\t\t\tobject = new OrthographicCamera(data.left, data.right, data.top, data.bottom, data.near, data.far);\n\t\t\t\tif (data.zoom !== undefined) object.zoom = data.zoom;\n\t\t\t\tif (data.view !== undefined) object.view = Object.assign({}, data.view);\n\t\t\t\tbreak;\n\n\t\t\tcase 'AmbientLight':\n\t\t\t\tobject = new AmbientLight(data.color, data.intensity);\n\t\t\t\tbreak;\n\n\t\t\tcase 'DirectionalLight':\n\t\t\t\tobject = new DirectionalLight(data.color, data.intensity);\n\t\t\t\tbreak;\n\n\t\t\tcase 'PointLight':\n\t\t\t\tobject = new PointLight(data.color, data.intensity, data.distance, data.decay);\n\t\t\t\tbreak;\n\n\t\t\tcase 'RectAreaLight':\n\t\t\t\tobject = new RectAreaLight(data.color, data.intensity, data.width, data.height);\n\t\t\t\tbreak;\n\n\t\t\tcase 'SpotLight':\n\t\t\t\tobject = new SpotLight(data.color, data.intensity, data.distance, data.angle, data.penumbra, data.decay);\n\t\t\t\tbreak;\n\n\t\t\tcase 'HemisphereLight':\n\t\t\t\tobject = new HemisphereLight(data.color, data.groundColor, data.intensity);\n\t\t\t\tbreak;\n\n\t\t\tcase 'LightProbe':\n\t\t\t\tobject = new LightProbe().fromJSON(data);\n\t\t\t\tbreak;\n\n\t\t\tcase 'SkinnedMesh':\n\t\t\t\tgeometry = getGeometry(data.geometry);\n\t\t\t\tmaterial = getMaterial(data.material);\n\t\t\t\tobject = new SkinnedMesh(geometry, material);\n\t\t\t\tif (data.bindMode !== undefined) object.bindMode = data.bindMode;\n\t\t\t\tif (data.bindMatrix !== undefined) object.bindMatrix.fromArray(data.bindMatrix);\n\t\t\t\tif (data.skeleton !== undefined) object.skeleton = data.skeleton;\n\t\t\t\tbreak;\n\n\t\t\tcase 'Mesh':\n\t\t\t\tgeometry = getGeometry(data.geometry);\n\t\t\t\tmaterial = getMaterial(data.material);\n\t\t\t\tobject = new Mesh(geometry, material);\n\t\t\t\tbreak;\n\n\t\t\tcase 'InstancedMesh':\n\t\t\t\tgeometry = getGeometry(data.geometry);\n\t\t\t\tmaterial = getMaterial(data.material);\n\t\t\t\tconst count = data.count;\n\t\t\t\tconst instanceMatrix = data.instanceMatrix;\n\t\t\t\tconst instanceColor = data.instanceColor;\n\t\t\t\tobject = new InstancedMesh(geometry, material, count);\n\t\t\t\tobject.instanceMatrix = new InstancedBufferAttribute(new Float32Array(instanceMatrix.array), 16);\n\t\t\t\tif (instanceColor !== undefined) object.instanceColor = new InstancedBufferAttribute(new Float32Array(instanceColor.array), instanceColor.itemSize);\n\t\t\t\tbreak;\n\n\t\t\tcase 'LOD':\n\t\t\t\tobject = new LOD();\n\t\t\t\tbreak;\n\n\t\t\tcase 'Line':\n\t\t\t\tobject = new Line(getGeometry(data.geometry), getMaterial(data.material));\n\t\t\t\tbreak;\n\n\t\t\tcase 'LineLoop':\n\t\t\t\tobject = new LineLoop(getGeometry(data.geometry), getMaterial(data.material));\n\t\t\t\tbreak;\n\n\t\t\tcase 'LineSegments':\n\t\t\t\tobject = new LineSegments(getGeometry(data.geometry), getMaterial(data.material));\n\t\t\t\tbreak;\n\n\t\t\tcase 'PointCloud':\n\t\t\tcase 'Points':\n\t\t\t\tobject = new Points(getGeometry(data.geometry), getMaterial(data.material));\n\t\t\t\tbreak;\n\n\t\t\tcase 'Sprite':\n\t\t\t\tobject = new Sprite(getMaterial(data.material));\n\t\t\t\tbreak;\n\n\t\t\tcase 'Group':\n\t\t\t\tobject = new Group();\n\t\t\t\tbreak;\n\n\t\t\tcase 'Bone':\n\t\t\t\tobject = new Bone();\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tobject = new Object3D();\n\t\t}\n\n\t\tobject.uuid = data.uuid;\n\t\tif (data.name !== undefined) object.name = data.name;\n\n\t\tif (data.matrix !== undefined) {\n\t\t\tobject.matrix.fromArray(data.matrix);\n\t\t\tif (data.matrixAutoUpdate !== undefined) object.matrixAutoUpdate = data.matrixAutoUpdate;\n\t\t\tif (object.matrixAutoUpdate) object.matrix.decompose(object.position, object.quaternion, object.scale);\n\t\t} else {\n\t\t\tif (data.position !== undefined) object.position.fromArray(data.position);\n\t\t\tif (data.rotation !== undefined) object.rotation.fromArray(data.rotation);\n\t\t\tif (data.quaternion !== undefined) object.quaternion.fromArray(data.quaternion);\n\t\t\tif (data.scale !== undefined) object.scale.fromArray(data.scale);\n\t\t}\n\n\t\tif (data.castShadow !== undefined) object.castShadow = data.castShadow;\n\t\tif (data.receiveShadow !== undefined) object.receiveShadow = data.receiveShadow;\n\n\t\tif (data.shadow) {\n\t\t\tif (data.shadow.bias !== undefined) object.shadow.bias = data.shadow.bias;\n\t\t\tif (data.shadow.normalBias !== undefined) object.shadow.normalBias = data.shadow.normalBias;\n\t\t\tif (data.shadow.radius !== undefined) object.shadow.radius = data.shadow.radius;\n\t\t\tif (data.shadow.mapSize !== undefined) object.shadow.mapSize.fromArray(data.shadow.mapSize);\n\t\t\tif (data.shadow.camera !== undefined) object.shadow.camera = this.parseObject(data.shadow.camera);\n\t\t}\n\n\t\tif (data.visible !== undefined) object.visible = data.visible;\n\t\tif (data.frustumCulled !== undefined) object.frustumCulled = data.frustumCulled;\n\t\tif (data.renderOrder !== undefined) object.renderOrder = data.renderOrder;\n\t\tif (data.userData !== undefined) object.userData = data.userData;\n\t\tif (data.layers !== undefined) object.layers.mask = data.layers;\n\n\t\tif (data.children !== undefined) {\n\t\t\tconst children = data.children;\n\n\t\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\t\tobject.add(this.parseObject(children[i], geometries, materials, textures, animations));\n\t\t\t}\n\t\t}\n\n\t\tif (data.animations !== undefined) {\n\t\t\tconst objectAnimations = data.animations;\n\n\t\t\tfor (let i = 0; i < objectAnimations.length; i++) {\n\t\t\t\tconst uuid = objectAnimations[i];\n\t\t\t\tobject.animations.push(animations[uuid]);\n\t\t\t}\n\t\t}\n\n\t\tif (data.type === 'LOD') {\n\t\t\tif (data.autoUpdate !== undefined) object.autoUpdate = data.autoUpdate;\n\t\t\tconst levels = data.levels;\n\n\t\t\tfor (let l = 0; l < levels.length; l++) {\n\t\t\t\tconst level = levels[l];\n\t\t\t\tconst child = object.getObjectByProperty('uuid', level.object);\n\n\t\t\t\tif (child !== undefined) {\n\t\t\t\t\tobject.addLevel(child, level.distance);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn object;\n\t}\n\n\tbindSkeletons(object, skeletons) {\n\t\tif (Object.keys(skeletons).length === 0) return;\n\t\tobject.traverse(function (child) {\n\t\t\tif (child.isSkinnedMesh === true && child.skeleton !== undefined) {\n\t\t\t\tconst skeleton = skeletons[child.skeleton];\n\n\t\t\t\tif (skeleton === undefined) {\n\t\t\t\t\tconsole.warn('THREE.ObjectLoader: No skeleton found with UUID:', child.skeleton);\n\t\t\t\t} else {\n\t\t\t\t\tchild.bind(skeleton, child.bindMatrix);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n}\n\nconst TEXTURE_MAPPING = {\n\tUVMapping: UVMapping,\n\tCubeReflectionMapping: CubeReflectionMapping,\n\tCubeRefractionMapping: CubeRefractionMapping,\n\tEquirectangularReflectionMapping: EquirectangularReflectionMapping,\n\tEquirectangularRefractionMapping: EquirectangularRefractionMapping,\n\tCubeUVReflectionMapping: CubeUVReflectionMapping\n};\nconst TEXTURE_WRAPPING = {\n\tRepeatWrapping: RepeatWrapping,\n\tClampToEdgeWrapping: ClampToEdgeWrapping,\n\tMirroredRepeatWrapping: MirroredRepeatWrapping\n};\nconst TEXTURE_FILTER = {\n\tNearestFilter: NearestFilter,\n\tNearestMipmapNearestFilter: NearestMipmapNearestFilter,\n\tNearestMipmapLinearFilter: NearestMipmapLinearFilter,\n\tLinearFilter: LinearFilter,\n\tLinearMipmapNearestFilter: LinearMipmapNearestFilter,\n\tLinearMipmapLinearFilter: LinearMipmapLinearFilter\n};\n\nclass ImageBitmapLoader extends Loader {\n\tconstructor(manager) {\n\t\tsuper(manager);\n\t\tthis.isImageBitmapLoader = true;\n\n\t\tif (typeof createImageBitmap === 'undefined') {\n\t\t\tconsole.warn('THREE.ImageBitmapLoader: createImageBitmap() not supported.');\n\t\t}\n\n\t\tif (typeof fetch === 'undefined') {\n\t\t\tconsole.warn('THREE.ImageBitmapLoader: fetch() not supported.');\n\t\t}\n\n\t\tthis.options = {\n\t\t\tpremultiplyAlpha: 'none'\n\t\t};\n\t}\n\n\tsetOptions(options) {\n\t\tthis.options = options;\n\t\treturn this;\n\t}\n\n\tload(url, onLoad, onProgress, onError) {\n\t\tif (url === undefined) url = '';\n\t\tif (this.path !== undefined) url = this.path + url;\n\t\turl = this.manager.resolveURL(url);\n\t\tconst scope = this;\n\t\tconst cached = Cache.get(url);\n\n\t\tif (cached !== undefined) {\n\t\t\tscope.manager.itemStart(url);\n\t\t\tsetTimeout(function () {\n\t\t\t\tif (onLoad) onLoad(cached);\n\t\t\t\tscope.manager.itemEnd(url);\n\t\t\t}, 0);\n\t\t\treturn cached;\n\t\t}\n\n\t\tconst fetchOptions = {};\n\t\tfetchOptions.credentials = this.crossOrigin === 'anonymous' ? 'same-origin' : 'include';\n\t\tfetchOptions.headers = this.requestHeader;\n\t\tfetch(url, fetchOptions).then(function (res) {\n\t\t\treturn res.blob();\n\t\t}).then(function (blob) {\n\t\t\treturn createImageBitmap(blob, Object.assign(scope.options, {\n\t\t\t\tcolorSpaceConversion: 'none'\n\t\t\t}));\n\t\t}).then(function (imageBitmap) {\n\t\t\tCache.add(url, imageBitmap);\n\t\t\tif (onLoad) onLoad(imageBitmap);\n\t\t\tscope.manager.itemEnd(url);\n\t\t}).catch(function (e) {\n\t\t\tif (onError) onError(e);\n\t\t\tscope.manager.itemError(url);\n\t\t\tscope.manager.itemEnd(url);\n\t\t});\n\t\tscope.manager.itemStart(url);\n\t}\n\n}\n\nlet _context;\n\nconst AudioContext = {\n\tgetContext: function () {\n\t\tif (_context === undefined) {\n\t\t\t_context = new (window.AudioContext || window.webkitAudioContext)();\n\t\t}\n\n\t\treturn _context;\n\t},\n\tsetContext: function (value) {\n\t\t_context = value;\n\t}\n};\n\nclass AudioLoader extends Loader {\n\tconstructor(manager) {\n\t\tsuper(manager);\n\t}\n\n\tload(url, onLoad, onProgress, onError) {\n\t\tconst scope = this;\n\t\tconst loader = new FileLoader(this.manager);\n\t\tloader.setResponseType('arraybuffer');\n\t\tloader.setPath(this.path);\n\t\tloader.setRequestHeader(this.requestHeader);\n\t\tloader.setWithCredentials(this.withCredentials);\n\t\tloader.load(url, function (buffer) {\n\t\t\ttry {\n\t\t\t\t// Create a copy of the buffer. The `decodeAudioData` method\n\t\t\t\t// detaches the buffer when complete, preventing reuse.\n\t\t\t\tconst bufferCopy = buffer.slice(0);\n\t\t\t\tconst context = AudioContext.getContext();\n\t\t\t\tcontext.decodeAudioData(bufferCopy, function (audioBuffer) {\n\t\t\t\t\tonLoad(audioBuffer);\n\t\t\t\t});\n\t\t\t} catch (e) {\n\t\t\t\tif (onError) {\n\t\t\t\t\tonError(e);\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(e);\n\t\t\t\t}\n\n\t\t\t\tscope.manager.itemError(url);\n\t\t\t}\n\t\t}, onProgress, onError);\n\t}\n\n}\n\nclass HemisphereLightProbe extends LightProbe {\n\tconstructor(skyColor, groundColor, intensity = 1) {\n\t\tsuper(undefined, intensity);\n\t\tthis.isHemisphereLightProbe = true;\n\t\tconst color1 = new Color().set(skyColor);\n\t\tconst color2 = new Color().set(groundColor);\n\t\tconst sky = new Vector3(color1.r, color1.g, color1.b);\n\t\tconst ground = new Vector3(color2.r, color2.g, color2.b); // without extra factor of PI in the shader, should = 1 / Math.sqrt( Math.PI );\n\n\t\tconst c0 = Math.sqrt(Math.PI);\n\t\tconst c1 = c0 * Math.sqrt(0.75);\n\t\tthis.sh.coefficients[0].copy(sky).add(ground).multiplyScalar(c0);\n\t\tthis.sh.coefficients[1].copy(sky).sub(ground).multiplyScalar(c1);\n\t}\n\n}\n\nclass AmbientLightProbe extends LightProbe {\n\tconstructor(color, intensity = 1) {\n\t\tsuper(undefined, intensity);\n\t\tthis.isAmbientLightProbe = true;\n\t\tconst color1 = new Color().set(color); // without extra factor of PI in the shader, would be 2 / Math.sqrt( Math.PI );\n\n\t\tthis.sh.coefficients[0].set(color1.r, color1.g, color1.b).multiplyScalar(2 * Math.sqrt(Math.PI));\n\t}\n\n}\n\nconst _eyeRight = /*@__PURE__*/new Matrix4();\n\nconst _eyeLeft = /*@__PURE__*/new Matrix4();\n\nconst _projectionMatrix = /*@__PURE__*/new Matrix4();\n\nclass StereoCamera {\n\tconstructor() {\n\t\tthis.type = 'StereoCamera';\n\t\tthis.aspect = 1;\n\t\tthis.eyeSep = 0.064;\n\t\tthis.cameraL = new PerspectiveCamera();\n\t\tthis.cameraL.layers.enable(1);\n\t\tthis.cameraL.matrixAutoUpdate = false;\n\t\tthis.cameraR = new PerspectiveCamera();\n\t\tthis.cameraR.layers.enable(2);\n\t\tthis.cameraR.matrixAutoUpdate = false;\n\t\tthis._cache = {\n\t\t\tfocus: null,\n\t\t\tfov: null,\n\t\t\taspect: null,\n\t\t\tnear: null,\n\t\t\tfar: null,\n\t\t\tzoom: null,\n\t\t\teyeSep: null\n\t\t};\n\t}\n\n\tupdate(camera) {\n\t\tconst cache = this._cache;\n\t\tconst needsUpdate = cache.focus !== camera.focus || cache.fov !== camera.fov || cache.aspect !== camera.aspect * this.aspect || cache.near !== camera.near || cache.far !== camera.far || cache.zoom !== camera.zoom || cache.eyeSep !== this.eyeSep;\n\n\t\tif (needsUpdate) {\n\t\t\tcache.focus = camera.focus;\n\t\t\tcache.fov = camera.fov;\n\t\t\tcache.aspect = camera.aspect * this.aspect;\n\t\t\tcache.near = camera.near;\n\t\t\tcache.far = camera.far;\n\t\t\tcache.zoom = camera.zoom;\n\t\t\tcache.eyeSep = this.eyeSep; // Off-axis stereoscopic effect based on\n\t\t\t// http://paulbourke.net/stereographics/stereorender/\n\n\t\t\t_projectionMatrix.copy(camera.projectionMatrix);\n\n\t\t\tconst eyeSepHalf = cache.eyeSep / 2;\n\t\t\tconst eyeSepOnProjection = eyeSepHalf * cache.near / cache.focus;\n\t\t\tconst ymax = cache.near * Math.tan(DEG2RAD * cache.fov * 0.5) / cache.zoom;\n\t\t\tlet xmin, xmax; // translate xOffset\n\n\t\t\t_eyeLeft.elements[12] = -eyeSepHalf;\n\t\t\t_eyeRight.elements[12] = eyeSepHalf; // for left eye\n\n\t\t\txmin = -ymax * cache.aspect + eyeSepOnProjection;\n\t\t\txmax = ymax * cache.aspect + eyeSepOnProjection;\n\t\t\t_projectionMatrix.elements[0] = 2 * cache.near / (xmax - xmin);\n\t\t\t_projectionMatrix.elements[8] = (xmax + xmin) / (xmax - xmin);\n\t\t\tthis.cameraL.projectionMatrix.copy(_projectionMatrix); // for right eye\n\n\t\t\txmin = -ymax * cache.aspect - eyeSepOnProjection;\n\t\t\txmax = ymax * cache.aspect - eyeSepOnProjection;\n\t\t\t_projectionMatrix.elements[0] = 2 * cache.near / (xmax - xmin);\n\t\t\t_projectionMatrix.elements[8] = (xmax + xmin) / (xmax - xmin);\n\t\t\tthis.cameraR.projectionMatrix.copy(_projectionMatrix);\n\t\t}\n\n\t\tthis.cameraL.matrixWorld.copy(camera.matrixWorld).multiply(_eyeLeft);\n\t\tthis.cameraR.matrixWorld.copy(camera.matrixWorld).multiply(_eyeRight);\n\t}\n\n}\n\nclass Clock {\n\tconstructor(autoStart = true) {\n\t\tthis.autoStart = autoStart;\n\t\tthis.startTime = 0;\n\t\tthis.oldTime = 0;\n\t\tthis.elapsedTime = 0;\n\t\tthis.running = false;\n\t}\n\n\tstart() {\n\t\tthis.startTime = now();\n\t\tthis.oldTime = this.startTime;\n\t\tthis.elapsedTime = 0;\n\t\tthis.running = true;\n\t}\n\n\tstop() {\n\t\tthis.getElapsedTime();\n\t\tthis.running = false;\n\t\tthis.autoStart = false;\n\t}\n\n\tgetElapsedTime() {\n\t\tthis.getDelta();\n\t\treturn this.elapsedTime;\n\t}\n\n\tgetDelta() {\n\t\tlet diff = 0;\n\n\t\tif (this.autoStart && !this.running) {\n\t\t\tthis.start();\n\t\t\treturn 0;\n\t\t}\n\n\t\tif (this.running) {\n\t\t\tconst newTime = now();\n\t\t\tdiff = (newTime - this.oldTime) / 1000;\n\t\t\tthis.oldTime = newTime;\n\t\t\tthis.elapsedTime += diff;\n\t\t}\n\n\t\treturn diff;\n\t}\n\n}\n\nfunction now() {\n\treturn (typeof performance === 'undefined' ? Date : performance).now(); // see #10732\n}\n\nconst _position$1 = /*@__PURE__*/new Vector3();\n\nconst _quaternion$1 = /*@__PURE__*/new Quaternion();\n\nconst _scale$1 = /*@__PURE__*/new Vector3();\n\nconst _orientation$1 = /*@__PURE__*/new Vector3();\n\nclass AudioListener extends Object3D {\n\tconstructor() {\n\t\tsuper();\n\t\tthis.type = 'AudioListener';\n\t\tthis.context = AudioContext.getContext();\n\t\tthis.gain = this.context.createGain();\n\t\tthis.gain.connect(this.context.destination);\n\t\tthis.filter = null;\n\t\tthis.timeDelta = 0; // private\n\n\t\tthis._clock = new Clock();\n\t}\n\n\tgetInput() {\n\t\treturn this.gain;\n\t}\n\n\tremoveFilter() {\n\t\tif (this.filter !== null) {\n\t\t\tthis.gain.disconnect(this.filter);\n\t\t\tthis.filter.disconnect(this.context.destination);\n\t\t\tthis.gain.connect(this.context.destination);\n\t\t\tthis.filter = null;\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tgetFilter() {\n\t\treturn this.filter;\n\t}\n\n\tsetFilter(value) {\n\t\tif (this.filter !== null) {\n\t\t\tthis.gain.disconnect(this.filter);\n\t\t\tthis.filter.disconnect(this.context.destination);\n\t\t} else {\n\t\t\tthis.gain.disconnect(this.context.destination);\n\t\t}\n\n\t\tthis.filter = value;\n\t\tthis.gain.connect(this.filter);\n\t\tthis.filter.connect(this.context.destination);\n\t\treturn this;\n\t}\n\n\tgetMasterVolume() {\n\t\treturn this.gain.gain.value;\n\t}\n\n\tsetMasterVolume(value) {\n\t\tthis.gain.gain.setTargetAtTime(value, this.context.currentTime, 0.01);\n\t\treturn this;\n\t}\n\n\tupdateMatrixWorld(force) {\n\t\tsuper.updateMatrixWorld(force);\n\t\tconst listener = this.context.listener;\n\t\tconst up = this.up;\n\t\tthis.timeDelta = this._clock.getDelta();\n\t\tthis.matrixWorld.decompose(_position$1, _quaternion$1, _scale$1);\n\n\t\t_orientation$1.set(0, 0, -1).applyQuaternion(_quaternion$1);\n\n\t\tif (listener.positionX) {\n\t\t\t// code path for Chrome (see #14393)\n\t\t\tconst endTime = this.context.currentTime + this.timeDelta;\n\t\t\tlistener.positionX.linearRampToValueAtTime(_position$1.x, endTime);\n\t\t\tlistener.positionY.linearRampToValueAtTime(_position$1.y, endTime);\n\t\t\tlistener.positionZ.linearRampToValueAtTime(_position$1.z, endTime);\n\t\t\tlistener.forwardX.linearRampToValueAtTime(_orientation$1.x, endTime);\n\t\t\tlistener.forwardY.linearRampToValueAtTime(_orientation$1.y, endTime);\n\t\t\tlistener.forwardZ.linearRampToValueAtTime(_orientation$1.z, endTime);\n\t\t\tlistener.upX.linearRampToValueAtTime(up.x, endTime);\n\t\t\tlistener.upY.linearRampToValueAtTime(up.y, endTime);\n\t\t\tlistener.upZ.linearRampToValueAtTime(up.z, endTime);\n\t\t} else {\n\t\t\tlistener.setPosition(_position$1.x, _position$1.y, _position$1.z);\n\t\t\tlistener.setOrientation(_orientation$1.x, _orientation$1.y, _orientation$1.z, up.x, up.y, up.z);\n\t\t}\n\t}\n\n}\n\nclass Audio extends Object3D {\n\tconstructor(listener) {\n\t\tsuper();\n\t\tthis.type = 'Audio';\n\t\tthis.listener = listener;\n\t\tthis.context = listener.context;\n\t\tthis.gain = this.context.createGain();\n\t\tthis.gain.connect(listener.getInput());\n\t\tthis.autoplay = false;\n\t\tthis.buffer = null;\n\t\tthis.detune = 0;\n\t\tthis.loop = false;\n\t\tthis.loopStart = 0;\n\t\tthis.loopEnd = 0;\n\t\tthis.offset = 0;\n\t\tthis.duration = undefined;\n\t\tthis.playbackRate = 1;\n\t\tthis.isPlaying = false;\n\t\tthis.hasPlaybackControl = true;\n\t\tthis.source = null;\n\t\tthis.sourceType = 'empty';\n\t\tthis._startedAt = 0;\n\t\tthis._progress = 0;\n\t\tthis._connected = false;\n\t\tthis.filters = [];\n\t}\n\n\tgetOutput() {\n\t\treturn this.gain;\n\t}\n\n\tsetNodeSource(audioNode) {\n\t\tthis.hasPlaybackControl = false;\n\t\tthis.sourceType = 'audioNode';\n\t\tthis.source = audioNode;\n\t\tthis.connect();\n\t\treturn this;\n\t}\n\n\tsetMediaElementSource(mediaElement) {\n\t\tthis.hasPlaybackControl = false;\n\t\tthis.sourceType = 'mediaNode';\n\t\tthis.source = this.context.createMediaElementSource(mediaElement);\n\t\tthis.connect();\n\t\treturn this;\n\t}\n\n\tsetMediaStreamSource(mediaStream) {\n\t\tthis.hasPlaybackControl = false;\n\t\tthis.sourceType = 'mediaStreamNode';\n\t\tthis.source = this.context.createMediaStreamSource(mediaStream);\n\t\tthis.connect();\n\t\treturn this;\n\t}\n\n\tsetBuffer(audioBuffer) {\n\t\tthis.buffer = audioBuffer;\n\t\tthis.sourceType = 'buffer';\n\t\tif (this.autoplay) this.play();\n\t\treturn this;\n\t}\n\n\tplay(delay = 0) {\n\t\tif (this.isPlaying === true) {\n\t\t\tconsole.warn('THREE.Audio: Audio is already playing.');\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.hasPlaybackControl === false) {\n\t\t\tconsole.warn('THREE.Audio: this Audio has no playback control.');\n\t\t\treturn;\n\t\t}\n\n\t\tthis._startedAt = this.context.currentTime + delay;\n\t\tconst source = this.context.createBufferSource();\n\t\tsource.buffer = this.buffer;\n\t\tsource.loop = this.loop;\n\t\tsource.loopStart = this.loopStart;\n\t\tsource.loopEnd = this.loopEnd;\n\t\tsource.onended = this.onEnded.bind(this);\n\t\tsource.start(this._startedAt, this._progress + this.offset, this.duration);\n\t\tthis.isPlaying = true;\n\t\tthis.source = source;\n\t\tthis.setDetune(this.detune);\n\t\tthis.setPlaybackRate(this.playbackRate);\n\t\treturn this.connect();\n\t}\n\n\tpause() {\n\t\tif (this.hasPlaybackControl === false) {\n\t\t\tconsole.warn('THREE.Audio: this Audio has no playback control.');\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.isPlaying === true) {\n\t\t\t// update current progress\n\t\t\tthis._progress += Math.max(this.context.currentTime - this._startedAt, 0) * this.playbackRate;\n\n\t\t\tif (this.loop === true) {\n\t\t\t\t// ensure _progress does not exceed duration with looped audios\n\t\t\t\tthis._progress = this._progress % (this.duration || this.buffer.duration);\n\t\t\t}\n\n\t\t\tthis.source.stop();\n\t\t\tthis.source.onended = null;\n\t\t\tthis.isPlaying = false;\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tstop() {\n\t\tif (this.hasPlaybackControl === false) {\n\t\t\tconsole.warn('THREE.Audio: this Audio has no playback control.');\n\t\t\treturn;\n\t\t}\n\n\t\tthis._progress = 0;\n\t\tthis.source.stop();\n\t\tthis.source.onended = null;\n\t\tthis.isPlaying = false;\n\t\treturn this;\n\t}\n\n\tconnect() {\n\t\tif (this.filters.length > 0) {\n\t\t\tthis.source.connect(this.filters[0]);\n\n\t\t\tfor (let i = 1, l = this.filters.length; i < l; i++) {\n\t\t\t\tthis.filters[i - 1].connect(this.filters[i]);\n\t\t\t}\n\n\t\t\tthis.filters[this.filters.length - 1].connect(this.getOutput());\n\t\t} else {\n\t\t\tthis.source.connect(this.getOutput());\n\t\t}\n\n\t\tthis._connected = true;\n\t\treturn this;\n\t}\n\n\tdisconnect() {\n\t\tif (this.filters.length > 0) {\n\t\t\tthis.source.disconnect(this.filters[0]);\n\n\t\t\tfor (let i = 1, l = this.filters.length; i < l; i++) {\n\t\t\t\tthis.filters[i - 1].disconnect(this.filters[i]);\n\t\t\t}\n\n\t\t\tthis.filters[this.filters.length - 1].disconnect(this.getOutput());\n\t\t} else {\n\t\t\tthis.source.disconnect(this.getOutput());\n\t\t}\n\n\t\tthis._connected = false;\n\t\treturn this;\n\t}\n\n\tgetFilters() {\n\t\treturn this.filters;\n\t}\n\n\tsetFilters(value) {\n\t\tif (!value) value = [];\n\n\t\tif (this._connected === true) {\n\t\t\tthis.disconnect();\n\t\t\tthis.filters = value.slice();\n\t\t\tthis.connect();\n\t\t} else {\n\t\t\tthis.filters = value.slice();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tsetDetune(value) {\n\t\tthis.detune = value;\n\t\tif (this.source.detune === undefined) return; // only set detune when available\n\n\t\tif (this.isPlaying === true) {\n\t\t\tthis.source.detune.setTargetAtTime(this.detune, this.context.currentTime, 0.01);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tgetDetune() {\n\t\treturn this.detune;\n\t}\n\n\tgetFilter() {\n\t\treturn this.getFilters()[0];\n\t}\n\n\tsetFilter(filter) {\n\t\treturn this.setFilters(filter ? [filter] : []);\n\t}\n\n\tsetPlaybackRate(value) {\n\t\tif (this.hasPlaybackControl === false) {\n\t\t\tconsole.warn('THREE.Audio: this Audio has no playback control.');\n\t\t\treturn;\n\t\t}\n\n\t\tthis.playbackRate = value;\n\n\t\tif (this.isPlaying === true) {\n\t\t\tthis.source.playbackRate.setTargetAtTime(this.playbackRate, this.context.currentTime, 0.01);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tgetPlaybackRate() {\n\t\treturn this.playbackRate;\n\t}\n\n\tonEnded() {\n\t\tthis.isPlaying = false;\n\t}\n\n\tgetLoop() {\n\t\tif (this.hasPlaybackControl === false) {\n\t\t\tconsole.warn('THREE.Audio: this Audio has no playback control.');\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.loop;\n\t}\n\n\tsetLoop(value) {\n\t\tif (this.hasPlaybackControl === false) {\n\t\t\tconsole.warn('THREE.Audio: this Audio has no playback control.');\n\t\t\treturn;\n\t\t}\n\n\t\tthis.loop = value;\n\n\t\tif (this.isPlaying === true) {\n\t\t\tthis.source.loop = this.loop;\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tsetLoopStart(value) {\n\t\tthis.loopStart = value;\n\t\treturn this;\n\t}\n\n\tsetLoopEnd(value) {\n\t\tthis.loopEnd = value;\n\t\treturn this;\n\t}\n\n\tgetVolume() {\n\t\treturn this.gain.gain.value;\n\t}\n\n\tsetVolume(value) {\n\t\tthis.gain.gain.setTargetAtTime(value, this.context.currentTime, 0.01);\n\t\treturn this;\n\t}\n\n}\n\nconst _position = /*@__PURE__*/new Vector3();\n\nconst _quaternion = /*@__PURE__*/new Quaternion();\n\nconst _scale = /*@__PURE__*/new Vector3();\n\nconst _orientation = /*@__PURE__*/new Vector3();\n\nclass PositionalAudio extends Audio {\n\tconstructor(listener) {\n\t\tsuper(listener);\n\t\tthis.panner = this.context.createPanner();\n\t\tthis.panner.panningModel = 'HRTF';\n\t\tthis.panner.connect(this.gain);\n\t}\n\n\tdisconnect() {\n\t\tsuper.disconnect();\n\t\tthis.panner.disconnect(this.gain);\n\t}\n\n\tgetOutput() {\n\t\treturn this.panner;\n\t}\n\n\tgetRefDistance() {\n\t\treturn this.panner.refDistance;\n\t}\n\n\tsetRefDistance(value) {\n\t\tthis.panner.refDistance = value;\n\t\treturn this;\n\t}\n\n\tgetRolloffFactor() {\n\t\treturn this.panner.rolloffFactor;\n\t}\n\n\tsetRolloffFactor(value) {\n\t\tthis.panner.rolloffFactor = value;\n\t\treturn this;\n\t}\n\n\tgetDistanceModel() {\n\t\treturn this.panner.distanceModel;\n\t}\n\n\tsetDistanceModel(value) {\n\t\tthis.panner.distanceModel = value;\n\t\treturn this;\n\t}\n\n\tgetMaxDistance() {\n\t\treturn this.panner.maxDistance;\n\t}\n\n\tsetMaxDistance(value) {\n\t\tthis.panner.maxDistance = value;\n\t\treturn this;\n\t}\n\n\tsetDirectionalCone(coneInnerAngle, coneOuterAngle, coneOuterGain) {\n\t\tthis.panner.coneInnerAngle = coneInnerAngle;\n\t\tthis.panner.coneOuterAngle = coneOuterAngle;\n\t\tthis.panner.coneOuterGain = coneOuterGain;\n\t\treturn this;\n\t}\n\n\tupdateMatrixWorld(force) {\n\t\tsuper.updateMatrixWorld(force);\n\t\tif (this.hasPlaybackControl === true && this.isPlaying === false) return;\n\t\tthis.matrixWorld.decompose(_position, _quaternion, _scale);\n\n\t\t_orientation.set(0, 0, 1).applyQuaternion(_quaternion);\n\n\t\tconst panner = this.panner;\n\n\t\tif (panner.positionX) {\n\t\t\t// code path for Chrome and Firefox (see #14393)\n\t\t\tconst endTime = this.context.currentTime + this.listener.timeDelta;\n\t\t\tpanner.positionX.linearRampToValueAtTime(_position.x, endTime);\n\t\t\tpanner.positionY.linearRampToValueAtTime(_position.y, endTime);\n\t\t\tpanner.positionZ.linearRampToValueAtTime(_position.z, endTime);\n\t\t\tpanner.orientationX.linearRampToValueAtTime(_orientation.x, endTime);\n\t\t\tpanner.orientationY.linearRampToValueAtTime(_orientation.y, endTime);\n\t\t\tpanner.orientationZ.linearRampToValueAtTime(_orientation.z, endTime);\n\t\t} else {\n\t\t\tpanner.setPosition(_position.x, _position.y, _position.z);\n\t\t\tpanner.setOrientation(_orientation.x, _orientation.y, _orientation.z);\n\t\t}\n\t}\n\n}\n\nclass AudioAnalyser {\n\tconstructor(audio, fftSize = 2048) {\n\t\tthis.analyser = audio.context.createAnalyser();\n\t\tthis.analyser.fftSize = fftSize;\n\t\tthis.data = new Uint8Array(this.analyser.frequencyBinCount);\n\t\taudio.getOutput().connect(this.analyser);\n\t}\n\n\tgetFrequencyData() {\n\t\tthis.analyser.getByteFrequencyData(this.data);\n\t\treturn this.data;\n\t}\n\n\tgetAverageFrequency() {\n\t\tlet value = 0;\n\t\tconst data = this.getFrequencyData();\n\n\t\tfor (let i = 0; i < data.length; i++) {\n\t\t\tvalue += data[i];\n\t\t}\n\n\t\treturn value / data.length;\n\t}\n\n}\n\nclass PropertyMixer {\n\tconstructor(binding, typeName, valueSize) {\n\t\tthis.binding = binding;\n\t\tthis.valueSize = valueSize;\n\t\tlet mixFunction, mixFunctionAdditive, setIdentity; // buffer layout: [ incoming | accu0 | accu1 | orig | addAccu | (optional work) ]\n\t\t//\n\t\t// interpolators can use .buffer as their .result\n\t\t// the data then goes to 'incoming'\n\t\t//\n\t\t// 'accu0' and 'accu1' are used frame-interleaved for\n\t\t// the cumulative result and are compared to detect\n\t\t// changes\n\t\t//\n\t\t// 'orig' stores the original state of the property\n\t\t//\n\t\t// 'add' is used for additive cumulative results\n\t\t//\n\t\t// 'work' is optional and is only present for quaternion types. It is used\n\t\t// to store intermediate quaternion multiplication results\n\n\t\tswitch (typeName) {\n\t\t\tcase 'quaternion':\n\t\t\t\tmixFunction = this._slerp;\n\t\t\t\tmixFunctionAdditive = this._slerpAdditive;\n\t\t\t\tsetIdentity = this._setAdditiveIdentityQuaternion;\n\t\t\t\tthis.buffer = new Float64Array(valueSize * 6);\n\t\t\t\tthis._workIndex = 5;\n\t\t\t\tbreak;\n\n\t\t\tcase 'string':\n\t\t\tcase 'bool':\n\t\t\t\tmixFunction = this._select; // Use the regular mix function and for additive on these types,\n\t\t\t\t// additive is not relevant for non-numeric types\n\n\t\t\t\tmixFunctionAdditive = this._select;\n\t\t\t\tsetIdentity = this._setAdditiveIdentityOther;\n\t\t\t\tthis.buffer = new Array(valueSize * 5);\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tmixFunction = this._lerp;\n\t\t\t\tmixFunctionAdditive = this._lerpAdditive;\n\t\t\t\tsetIdentity = this._setAdditiveIdentityNumeric;\n\t\t\t\tthis.buffer = new Float64Array(valueSize * 5);\n\t\t}\n\n\t\tthis._mixBufferRegion = mixFunction;\n\t\tthis._mixBufferRegionAdditive = mixFunctionAdditive;\n\t\tthis._setIdentity = setIdentity;\n\t\tthis._origIndex = 3;\n\t\tthis._addIndex = 4;\n\t\tthis.cumulativeWeight = 0;\n\t\tthis.cumulativeWeightAdditive = 0;\n\t\tthis.useCount = 0;\n\t\tthis.referenceCount = 0;\n\t} // accumulate data in the 'incoming' region into 'accu'\n\n\n\taccumulate(accuIndex, weight) {\n\t\t// note: happily accumulating nothing when weight = 0, the caller knows\n\t\t// the weight and shouldn't have made the call in the first place\n\t\tconst buffer = this.buffer,\n\t\t\t\t\tstride = this.valueSize,\n\t\t\t\t\toffset = accuIndex * stride + stride;\n\t\tlet currentWeight = this.cumulativeWeight;\n\n\t\tif (currentWeight === 0) {\n\t\t\t// accuN := incoming * weight\n\t\t\tfor (let i = 0; i !== stride; ++i) {\n\t\t\t\tbuffer[offset + i] = buffer[i];\n\t\t\t}\n\n\t\t\tcurrentWeight = weight;\n\t\t} else {\n\t\t\t// accuN := accuN + incoming * weight\n\t\t\tcurrentWeight += weight;\n\t\t\tconst mix = weight / currentWeight;\n\n\t\t\tthis._mixBufferRegion(buffer, offset, 0, mix, stride);\n\t\t}\n\n\t\tthis.cumulativeWeight = currentWeight;\n\t} // accumulate data in the 'incoming' region into 'add'\n\n\n\taccumulateAdditive(weight) {\n\t\tconst buffer = this.buffer,\n\t\t\t\t\tstride = this.valueSize,\n\t\t\t\t\toffset = stride * this._addIndex;\n\n\t\tif (this.cumulativeWeightAdditive === 0) {\n\t\t\t// add = identity\n\t\t\tthis._setIdentity();\n\t\t} // add := add + incoming * weight\n\n\n\t\tthis._mixBufferRegionAdditive(buffer, offset, 0, weight, stride);\n\n\t\tthis.cumulativeWeightAdditive += weight;\n\t} // apply the state of 'accu' to the binding when accus differ\n\n\n\tapply(accuIndex) {\n\t\tconst stride = this.valueSize,\n\t\t\t\t\tbuffer = this.buffer,\n\t\t\t\t\toffset = accuIndex * stride + stride,\n\t\t\t\t\tweight = this.cumulativeWeight,\n\t\t\t\t\tweightAdditive = this.cumulativeWeightAdditive,\n\t\t\t\t\tbinding = this.binding;\n\t\tthis.cumulativeWeight = 0;\n\t\tthis.cumulativeWeightAdditive = 0;\n\n\t\tif (weight < 1) {\n\t\t\t// accuN := accuN + original * ( 1 - cumulativeWeight )\n\t\t\tconst originalValueOffset = stride * this._origIndex;\n\n\t\t\tthis._mixBufferRegion(buffer, offset, originalValueOffset, 1 - weight, stride);\n\t\t}\n\n\t\tif (weightAdditive > 0) {\n\t\t\t// accuN := accuN + additive accuN\n\t\t\tthis._mixBufferRegionAdditive(buffer, offset, this._addIndex * stride, 1, stride);\n\t\t}\n\n\t\tfor (let i = stride, e = stride + stride; i !== e; ++i) {\n\t\t\tif (buffer[i] !== buffer[i + stride]) {\n\t\t\t\t// value has changed -> update scene graph\n\t\t\t\tbinding.setValue(buffer, offset);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t} // remember the state of the bound property and copy it to both accus\n\n\n\tsaveOriginalState() {\n\t\tconst binding = this.binding;\n\t\tconst buffer = this.buffer,\n\t\t\t\t\tstride = this.valueSize,\n\t\t\t\t\toriginalValueOffset = stride * this._origIndex;\n\t\tbinding.getValue(buffer, originalValueOffset); // accu[0..1] := orig -- initially detect changes against the original\n\n\t\tfor (let i = stride, e = originalValueOffset; i !== e; ++i) {\n\t\t\tbuffer[i] = buffer[originalValueOffset + i % stride];\n\t\t} // Add to identity for additive\n\n\n\t\tthis._setIdentity();\n\n\t\tthis.cumulativeWeight = 0;\n\t\tthis.cumulativeWeightAdditive = 0;\n\t} // apply the state previously taken via 'saveOriginalState' to the binding\n\n\n\trestoreOriginalState() {\n\t\tconst originalValueOffset = this.valueSize * 3;\n\t\tthis.binding.setValue(this.buffer, originalValueOffset);\n\t}\n\n\t_setAdditiveIdentityNumeric() {\n\t\tconst startIndex = this._addIndex * this.valueSize;\n\t\tconst endIndex = startIndex + this.valueSize;\n\n\t\tfor (let i = startIndex; i < endIndex; i++) {\n\t\t\tthis.buffer[i] = 0;\n\t\t}\n\t}\n\n\t_setAdditiveIdentityQuaternion() {\n\t\tthis._setAdditiveIdentityNumeric();\n\n\t\tthis.buffer[this._addIndex * this.valueSize + 3] = 1;\n\t}\n\n\t_setAdditiveIdentityOther() {\n\t\tconst startIndex = this._origIndex * this.valueSize;\n\t\tconst targetIndex = this._addIndex * this.valueSize;\n\n\t\tfor (let i = 0; i < this.valueSize; i++) {\n\t\t\tthis.buffer[targetIndex + i] = this.buffer[startIndex + i];\n\t\t}\n\t} // mix functions\n\n\n\t_select(buffer, dstOffset, srcOffset, t, stride) {\n\t\tif (t >= 0.5) {\n\t\t\tfor (let i = 0; i !== stride; ++i) {\n\t\t\t\tbuffer[dstOffset + i] = buffer[srcOffset + i];\n\t\t\t}\n\t\t}\n\t}\n\n\t_slerp(buffer, dstOffset, srcOffset, t) {\n\t\tQuaternion.slerpFlat(buffer, dstOffset, buffer, dstOffset, buffer, srcOffset, t);\n\t}\n\n\t_slerpAdditive(buffer, dstOffset, srcOffset, t, stride) {\n\t\tconst workOffset = this._workIndex * stride; // Store result in intermediate buffer offset\n\n\t\tQuaternion.multiplyQuaternionsFlat(buffer, workOffset, buffer, dstOffset, buffer, srcOffset); // Slerp to the intermediate result\n\n\t\tQuaternion.slerpFlat(buffer, dstOffset, buffer, dstOffset, buffer, workOffset, t);\n\t}\n\n\t_lerp(buffer, dstOffset, srcOffset, t, stride) {\n\t\tconst s = 1 - t;\n\n\t\tfor (let i = 0; i !== stride; ++i) {\n\t\t\tconst j = dstOffset + i;\n\t\t\tbuffer[j] = buffer[j] * s + buffer[srcOffset + i] * t;\n\t\t}\n\t}\n\n\t_lerpAdditive(buffer, dstOffset, srcOffset, t, stride) {\n\t\tfor (let i = 0; i !== stride; ++i) {\n\t\t\tconst j = dstOffset + i;\n\t\t\tbuffer[j] = buffer[j] + buffer[srcOffset + i] * t;\n\t\t}\n\t}\n\n}\n\n// Characters [].:/ are reserved for track binding syntax.\nconst _RESERVED_CHARS_RE = '\\\\[\\\\]\\\\.:\\\\/';\n\nconst _reservedRe = new RegExp('[' + _RESERVED_CHARS_RE + ']', 'g'); // Attempts to allow node names from any language. ES5's `\\w` regexp matches\n// only latin characters, and the unicode \\p{L} is not yet supported. So\n// instead, we exclude reserved characters and match everything else.\n\n\nconst _wordChar = '[^' + _RESERVED_CHARS_RE + ']';\n\nconst _wordCharOrDot = '[^' + _RESERVED_CHARS_RE.replace('\\\\.', '') + ']'; // Parent directories, delimited by '/' or ':'. Currently unused, but must\n// be matched to parse the rest of the track name.\n\n\nconst _directoryRe = /*@__PURE__*/ /((?:WC+[\\/:])*)/.source.replace('WC', _wordChar); // Target node. May contain word characters (a-zA-Z0-9_) and '.' or '-'.\n\n\nconst _nodeRe = /*@__PURE__*/ /(WCOD+)?/.source.replace('WCOD', _wordCharOrDot); // Object on target node, and accessor. May not contain reserved\n// characters. Accessor may contain any character except closing bracket.\n\n\nconst _objectRe = /*@__PURE__*/ /(?:\\.(WC+)(?:\\[(.+)\\])?)?/.source.replace('WC', _wordChar); // Property and accessor. May not contain reserved characters. Accessor may\n// contain any non-bracket characters.\n\n\nconst _propertyRe = /*@__PURE__*/ /\\.(WC+)(?:\\[(.+)\\])?/.source.replace('WC', _wordChar);\n\nconst _trackRe = new RegExp('' + '^' + _directoryRe + _nodeRe + _objectRe + _propertyRe + '$');\n\nconst _supportedObjectNames = ['material', 'materials', 'bones', 'map'];\n\nclass Composite {\n\tconstructor(targetGroup, path, optionalParsedPath) {\n\t\tconst parsedPath = optionalParsedPath || PropertyBinding.parseTrackName(path);\n\t\tthis._targetGroup = targetGroup;\n\t\tthis._bindings = targetGroup.subscribe_(path, parsedPath);\n\t}\n\n\tgetValue(array, offset) {\n\t\tthis.bind(); // bind all binding\n\n\t\tconst firstValidIndex = this._targetGroup.nCachedObjects_,\n\t\t\t\t\tbinding = this._bindings[firstValidIndex]; // and only call .getValue on the first\n\n\t\tif (binding !== undefined) binding.getValue(array, offset);\n\t}\n\n\tsetValue(array, offset) {\n\t\tconst bindings = this._bindings;\n\n\t\tfor (let i = this._targetGroup.nCachedObjects_, n = bindings.length; i !== n; ++i) {\n\t\t\tbindings[i].setValue(array, offset);\n\t\t}\n\t}\n\n\tbind() {\n\t\tconst bindings = this._bindings;\n\n\t\tfor (let i = this._targetGroup.nCachedObjects_, n = bindings.length; i !== n; ++i) {\n\t\t\tbindings[i].bind();\n\t\t}\n\t}\n\n\tunbind() {\n\t\tconst bindings = this._bindings;\n\n\t\tfor (let i = this._targetGroup.nCachedObjects_, n = bindings.length; i !== n; ++i) {\n\t\t\tbindings[i].unbind();\n\t\t}\n\t}\n\n} // Note: This class uses a State pattern on a per-method basis:\n// 'bind' sets 'this.getValue' / 'setValue' and shadows the\n// prototype version of these methods with one that represents\n// the bound state. When the property is not found, the methods\n// become no-ops.\n\n\nclass PropertyBinding {\n\tconstructor(rootNode, path, parsedPath) {\n\t\tthis.path = path;\n\t\tthis.parsedPath = parsedPath || PropertyBinding.parseTrackName(path);\n\t\tthis.node = PropertyBinding.findNode(rootNode, this.parsedPath.nodeName) || rootNode;\n\t\tthis.rootNode = rootNode; // initial state of these methods that calls 'bind'\n\n\t\tthis.getValue = this._getValue_unbound;\n\t\tthis.setValue = this._setValue_unbound;\n\t}\n\n\tstatic create(root, path, parsedPath) {\n\t\tif (!(root && root.isAnimationObjectGroup)) {\n\t\t\treturn new PropertyBinding(root, path, parsedPath);\n\t\t} else {\n\t\t\treturn new PropertyBinding.Composite(root, path, parsedPath);\n\t\t}\n\t}\n\t/**\n\t * Replaces spaces with underscores and removes unsupported characters from\n\t * node names, to ensure compatibility with parseTrackName().\n\t *\n\t * @param {string} name Node name to be sanitized.\n\t * @return {string}\n\t */\n\n\n\tstatic sanitizeNodeName(name) {\n\t\treturn name.replace(/\\s/g, '_').replace(_reservedRe, '');\n\t}\n\n\tstatic parseTrackName(trackName) {\n\t\tconst matches = _trackRe.exec(trackName);\n\n\t\tif (matches === null) {\n\t\t\tthrow new Error('PropertyBinding: Cannot parse trackName: ' + trackName);\n\t\t}\n\n\t\tconst results = {\n\t\t\t// directoryName: matches[ 1 ], // (tschw) currently unused\n\t\t\tnodeName: matches[2],\n\t\t\tobjectName: matches[3],\n\t\t\tobjectIndex: matches[4],\n\t\t\tpropertyName: matches[5],\n\t\t\t// required\n\t\t\tpropertyIndex: matches[6]\n\t\t};\n\t\tconst lastDot = results.nodeName && results.nodeName.lastIndexOf('.');\n\n\t\tif (lastDot !== undefined && lastDot !== -1) {\n\t\t\tconst objectName = results.nodeName.substring(lastDot + 1); // Object names must be checked against an allowlist. Otherwise, there\n\t\t\t// is no way to parse 'foo.bar.baz': 'baz' must be a property, but\n\t\t\t// 'bar' could be the objectName, or part of a nodeName (which can\n\t\t\t// include '.' characters).\n\n\t\t\tif (_supportedObjectNames.indexOf(objectName) !== -1) {\n\t\t\t\tresults.nodeName = results.nodeName.substring(0, lastDot);\n\t\t\t\tresults.objectName = objectName;\n\t\t\t}\n\t\t}\n\n\t\tif (results.propertyName === null || results.propertyName.length === 0) {\n\t\t\tthrow new Error('PropertyBinding: can not parse propertyName from trackName: ' + trackName);\n\t\t}\n\n\t\treturn results;\n\t}\n\n\tstatic findNode(root, nodeName) {\n\t\tif (nodeName === undefined || nodeName === '' || nodeName === '.' || nodeName === -1 || nodeName === root.name || nodeName === root.uuid) {\n\t\t\treturn root;\n\t\t} // search into skeleton bones.\n\n\n\t\tif (root.skeleton) {\n\t\t\tconst bone = root.skeleton.getBoneByName(nodeName);\n\n\t\t\tif (bone !== undefined) {\n\t\t\t\treturn bone;\n\t\t\t}\n\t\t} // search into node subtree.\n\n\n\t\tif (root.children) {\n\t\t\tconst searchNodeSubtree = function (children) {\n\t\t\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\t\t\tconst childNode = children[i];\n\n\t\t\t\t\tif (childNode.name === nodeName || childNode.uuid === nodeName) {\n\t\t\t\t\t\treturn childNode;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst result = searchNodeSubtree(childNode.children);\n\t\t\t\t\tif (result) return result;\n\t\t\t\t}\n\n\t\t\t\treturn null;\n\t\t\t};\n\n\t\t\tconst subTreeNode = searchNodeSubtree(root.children);\n\n\t\t\tif (subTreeNode) {\n\t\t\t\treturn subTreeNode;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t} // these are used to \"bind\" a nonexistent property\n\n\n\t_getValue_unavailable() {}\n\n\t_setValue_unavailable() {} // Getters\n\n\n\t_getValue_direct(buffer, offset) {\n\t\tbuffer[offset] = this.targetObject[this.propertyName];\n\t}\n\n\t_getValue_array(buffer, offset) {\n\t\tconst source = this.resolvedProperty;\n\n\t\tfor (let i = 0, n = source.length; i !== n; ++i) {\n\t\t\tbuffer[offset++] = source[i];\n\t\t}\n\t}\n\n\t_getValue_arrayElement(buffer, offset) {\n\t\tbuffer[offset] = this.resolvedProperty[this.propertyIndex];\n\t}\n\n\t_getValue_toArray(buffer, offset) {\n\t\tthis.resolvedProperty.toArray(buffer, offset);\n\t} // Direct\n\n\n\t_setValue_direct(buffer, offset) {\n\t\tthis.targetObject[this.propertyName] = buffer[offset];\n\t}\n\n\t_setValue_direct_setNeedsUpdate(buffer, offset) {\n\t\tthis.targetObject[this.propertyName] = buffer[offset];\n\t\tthis.targetObject.needsUpdate = true;\n\t}\n\n\t_setValue_direct_setMatrixWorldNeedsUpdate(buffer, offset) {\n\t\tthis.targetObject[this.propertyName] = buffer[offset];\n\t\tthis.targetObject.matrixWorldNeedsUpdate = true;\n\t} // EntireArray\n\n\n\t_setValue_array(buffer, offset) {\n\t\tconst dest = this.resolvedProperty;\n\n\t\tfor (let i = 0, n = dest.length; i !== n; ++i) {\n\t\t\tdest[i] = buffer[offset++];\n\t\t}\n\t}\n\n\t_setValue_array_setNeedsUpdate(buffer, offset) {\n\t\tconst dest = this.resolvedProperty;\n\n\t\tfor (let i = 0, n = dest.length; i !== n; ++i) {\n\t\t\tdest[i] = buffer[offset++];\n\t\t}\n\n\t\tthis.targetObject.needsUpdate = true;\n\t}\n\n\t_setValue_array_setMatrixWorldNeedsUpdate(buffer, offset) {\n\t\tconst dest = this.resolvedProperty;\n\n\t\tfor (let i = 0, n = dest.length; i !== n; ++i) {\n\t\t\tdest[i] = buffer[offset++];\n\t\t}\n\n\t\tthis.targetObject.matrixWorldNeedsUpdate = true;\n\t} // ArrayElement\n\n\n\t_setValue_arrayElement(buffer, offset) {\n\t\tthis.resolvedProperty[this.propertyIndex] = buffer[offset];\n\t}\n\n\t_setValue_arrayElement_setNeedsUpdate(buffer, offset) {\n\t\tthis.resolvedProperty[this.propertyIndex] = buffer[offset];\n\t\tthis.targetObject.needsUpdate = true;\n\t}\n\n\t_setValue_arrayElement_setMatrixWorldNeedsUpdate(buffer, offset) {\n\t\tthis.resolvedProperty[this.propertyIndex] = buffer[offset];\n\t\tthis.targetObject.matrixWorldNeedsUpdate = true;\n\t} // HasToFromArray\n\n\n\t_setValue_fromArray(buffer, offset) {\n\t\tthis.resolvedProperty.fromArray(buffer, offset);\n\t}\n\n\t_setValue_fromArray_setNeedsUpdate(buffer, offset) {\n\t\tthis.resolvedProperty.fromArray(buffer, offset);\n\t\tthis.targetObject.needsUpdate = true;\n\t}\n\n\t_setValue_fromArray_setMatrixWorldNeedsUpdate(buffer, offset) {\n\t\tthis.resolvedProperty.fromArray(buffer, offset);\n\t\tthis.targetObject.matrixWorldNeedsUpdate = true;\n\t}\n\n\t_getValue_unbound(targetArray, offset) {\n\t\tthis.bind();\n\t\tthis.getValue(targetArray, offset);\n\t}\n\n\t_setValue_unbound(sourceArray, offset) {\n\t\tthis.bind();\n\t\tthis.setValue(sourceArray, offset);\n\t} // create getter / setter pair for a property in the scene graph\n\n\n\tbind() {\n\t\tlet targetObject = this.node;\n\t\tconst parsedPath = this.parsedPath;\n\t\tconst objectName = parsedPath.objectName;\n\t\tconst propertyName = parsedPath.propertyName;\n\t\tlet propertyIndex = parsedPath.propertyIndex;\n\n\t\tif (!targetObject) {\n\t\t\ttargetObject = PropertyBinding.findNode(this.rootNode, parsedPath.nodeName) || this.rootNode;\n\t\t\tthis.node = targetObject;\n\t\t} // set fail state so we can just 'return' on error\n\n\n\t\tthis.getValue = this._getValue_unavailable;\n\t\tthis.setValue = this._setValue_unavailable; // ensure there is a value node\n\n\t\tif (!targetObject) {\n\t\t\tconsole.error('THREE.PropertyBinding: Trying to update node for track: ' + this.path + ' but it wasn\\'t found.');\n\t\t\treturn;\n\t\t}\n\n\t\tif (objectName) {\n\t\t\tlet objectIndex = parsedPath.objectIndex; // special cases were we need to reach deeper into the hierarchy to get the face materials....\n\n\t\t\tswitch (objectName) {\n\t\t\t\tcase 'materials':\n\t\t\t\t\tif (!targetObject.material) {\n\t\t\t\t\t\tconsole.error('THREE.PropertyBinding: Can not bind to material as node does not have a material.', this);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!targetObject.material.materials) {\n\t\t\t\t\t\tconsole.error('THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.', this);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\ttargetObject = targetObject.material.materials;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'bones':\n\t\t\t\t\tif (!targetObject.skeleton) {\n\t\t\t\t\t\tconsole.error('THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.', this);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t} // potential future optimization: skip this if propertyIndex is already an integer\n\t\t\t\t\t// and convert the integer string to a true integer.\n\n\n\t\t\t\t\ttargetObject = targetObject.skeleton.bones; // support resolving morphTarget names into indices.\n\n\t\t\t\t\tfor (let i = 0; i < targetObject.length; i++) {\n\t\t\t\t\t\tif (targetObject[i].name === objectIndex) {\n\t\t\t\t\t\t\tobjectIndex = i;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'map':\n\t\t\t\t\tif ('map' in targetObject) {\n\t\t\t\t\t\ttargetObject = targetObject.map;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!targetObject.material) {\n\t\t\t\t\t\tconsole.error('THREE.PropertyBinding: Can not bind to material as node does not have a material.', this);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!targetObject.material.map) {\n\t\t\t\t\t\tconsole.error('THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.', this);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\ttargetObject = targetObject.material.map;\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tif (targetObject[objectName] === undefined) {\n\t\t\t\t\t\tconsole.error('THREE.PropertyBinding: Can not bind to objectName of node undefined.', this);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\ttargetObject = targetObject[objectName];\n\t\t\t}\n\n\t\t\tif (objectIndex !== undefined) {\n\t\t\t\tif (targetObject[objectIndex] === undefined) {\n\t\t\t\t\tconsole.error('THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.', this, targetObject);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\ttargetObject = targetObject[objectIndex];\n\t\t\t}\n\t\t} // resolve property\n\n\n\t\tconst nodeProperty = targetObject[propertyName];\n\n\t\tif (nodeProperty === undefined) {\n\t\t\tconst nodeName = parsedPath.nodeName;\n\t\t\tconsole.error('THREE.PropertyBinding: Trying to update property for track: ' + nodeName + '.' + propertyName + ' but it wasn\\'t found.', targetObject);\n\t\t\treturn;\n\t\t} // determine versioning scheme\n\n\n\t\tlet versioning = this.Versioning.None;\n\t\tthis.targetObject = targetObject;\n\n\t\tif (targetObject.needsUpdate !== undefined) {\n\t\t\t// material\n\t\t\tversioning = this.Versioning.NeedsUpdate;\n\t\t} else if (targetObject.matrixWorldNeedsUpdate !== undefined) {\n\t\t\t// node transform\n\t\t\tversioning = this.Versioning.MatrixWorldNeedsUpdate;\n\t\t} // determine how the property gets bound\n\n\n\t\tlet bindingType = this.BindingType.Direct;\n\n\t\tif (propertyIndex !== undefined) {\n\t\t\t// access a sub element of the property array (only primitives are supported right now)\n\t\t\tif (propertyName === 'morphTargetInfluences') {\n\t\t\t\t// potential optimization, skip this if propertyIndex is already an integer, and convert the integer string to a true integer.\n\t\t\t\t// support resolving morphTarget names into indices.\n\t\t\t\tif (!targetObject.geometry) {\n\t\t\t\t\tconsole.error('THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.', this);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (!targetObject.geometry.morphAttributes) {\n\t\t\t\t\tconsole.error('THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.', this);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (targetObject.morphTargetDictionary[propertyIndex] !== undefined) {\n\t\t\t\t\tpropertyIndex = targetObject.morphTargetDictionary[propertyIndex];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbindingType = this.BindingType.ArrayElement;\n\t\t\tthis.resolvedProperty = nodeProperty;\n\t\t\tthis.propertyIndex = propertyIndex;\n\t\t} else if (nodeProperty.fromArray !== undefined && nodeProperty.toArray !== undefined) {\n\t\t\t// must use copy for Object3D.Euler/Quaternion\n\t\t\tbindingType = this.BindingType.HasFromToArray;\n\t\t\tthis.resolvedProperty = nodeProperty;\n\t\t} else if (Array.isArray(nodeProperty)) {\n\t\t\tbindingType = this.BindingType.EntireArray;\n\t\t\tthis.resolvedProperty = nodeProperty;\n\t\t} else {\n\t\t\tthis.propertyName = propertyName;\n\t\t} // select getter / setter\n\n\n\t\tthis.getValue = this.GetterByBindingType[bindingType];\n\t\tthis.setValue = this.SetterByBindingTypeAndVersioning[bindingType][versioning];\n\t}\n\n\tunbind() {\n\t\tthis.node = null; // back to the prototype version of getValue / setValue\n\t\t// note: avoiding to mutate the shape of 'this' via 'delete'\n\n\t\tthis.getValue = this._getValue_unbound;\n\t\tthis.setValue = this._setValue_unbound;\n\t}\n\n}\n\nPropertyBinding.Composite = Composite;\nPropertyBinding.prototype.BindingType = {\n\tDirect: 0,\n\tEntireArray: 1,\n\tArrayElement: 2,\n\tHasFromToArray: 3\n};\nPropertyBinding.prototype.Versioning = {\n\tNone: 0,\n\tNeedsUpdate: 1,\n\tMatrixWorldNeedsUpdate: 2\n};\nPropertyBinding.prototype.GetterByBindingType = [PropertyBinding.prototype._getValue_direct, PropertyBinding.prototype._getValue_array, PropertyBinding.prototype._getValue_arrayElement, PropertyBinding.prototype._getValue_toArray];\nPropertyBinding.prototype.SetterByBindingTypeAndVersioning = [[// Direct\nPropertyBinding.prototype._setValue_direct, PropertyBinding.prototype._setValue_direct_setNeedsUpdate, PropertyBinding.prototype._setValue_direct_setMatrixWorldNeedsUpdate], [// EntireArray\nPropertyBinding.prototype._setValue_array, PropertyBinding.prototype._setValue_array_setNeedsUpdate, PropertyBinding.prototype._setValue_array_setMatrixWorldNeedsUpdate], [// ArrayElement\nPropertyBinding.prototype._setValue_arrayElement, PropertyBinding.prototype._setValue_arrayElement_setNeedsUpdate, PropertyBinding.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate], [// HasToFromArray\nPropertyBinding.prototype._setValue_fromArray, PropertyBinding.prototype._setValue_fromArray_setNeedsUpdate, PropertyBinding.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];\n\n/**\n *\n * A group of objects that receives a shared animation state.\n *\n * Usage:\n *\n *\t- Add objects you would otherwise pass as 'root' to the\n *\t\tconstructor or the .clipAction method of AnimationMixer.\n *\n *\t- Instead pass this object as 'root'.\n *\n *\t- You can also add and remove objects later when the mixer\n *\t\tis running.\n *\n * Note:\n *\n *\t\tObjects of this class appear as one object to the mixer,\n *\t\tso cache control of the individual objects must be done\n *\t\ton the group.\n *\n * Limitation:\n *\n *\t- The animated properties must be compatible among the\n *\t\tall objects in the group.\n *\n *\t- A single property can either be controlled through a\n *\t\ttarget group or directly, but not both.\n */\n\nclass AnimationObjectGroup {\n\tconstructor() {\n\t\tthis.isAnimationObjectGroup = true;\n\t\tthis.uuid = generateUUID(); // cached objects followed by the active ones\n\n\t\tthis._objects = Array.prototype.slice.call(arguments);\n\t\tthis.nCachedObjects_ = 0; // threshold\n\t\t// note: read by PropertyBinding.Composite\n\n\t\tconst indices = {};\n\t\tthis._indicesByUUID = indices; // for bookkeeping\n\n\t\tfor (let i = 0, n = arguments.length; i !== n; ++i) {\n\t\t\tindices[arguments[i].uuid] = i;\n\t\t}\n\n\t\tthis._paths = []; // inside: string\n\n\t\tthis._parsedPaths = []; // inside: { we don't care, here }\n\n\t\tthis._bindings = []; // inside: Array< PropertyBinding >\n\n\t\tthis._bindingsIndicesByPath = {}; // inside: indices in these arrays\n\n\t\tconst scope = this;\n\t\tthis.stats = {\n\t\t\tobjects: {\n\t\t\t\tget total() {\n\t\t\t\t\treturn scope._objects.length;\n\t\t\t\t},\n\n\t\t\t\tget inUse() {\n\t\t\t\t\treturn this.total - scope.nCachedObjects_;\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tget bindingsPerObject() {\n\t\t\t\treturn scope._bindings.length;\n\t\t\t}\n\n\t\t};\n\t}\n\n\tadd() {\n\t\tconst objects = this._objects,\n\t\t\t\t\tindicesByUUID = this._indicesByUUID,\n\t\t\t\t\tpaths = this._paths,\n\t\t\t\t\tparsedPaths = this._parsedPaths,\n\t\t\t\t\tbindings = this._bindings,\n\t\t\t\t\tnBindings = bindings.length;\n\t\tlet knownObject = undefined,\n\t\t\t\tnObjects = objects.length,\n\t\t\t\tnCachedObjects = this.nCachedObjects_;\n\n\t\tfor (let i = 0, n = arguments.length; i !== n; ++i) {\n\t\t\tconst object = arguments[i],\n\t\t\t\t\t\tuuid = object.uuid;\n\t\t\tlet index = indicesByUUID[uuid];\n\n\t\t\tif (index === undefined) {\n\t\t\t\t// unknown object -> add it to the ACTIVE region\n\t\t\t\tindex = nObjects++;\n\t\t\t\tindicesByUUID[uuid] = index;\n\t\t\t\tobjects.push(object); // accounting is done, now do the same for all bindings\n\n\t\t\t\tfor (let j = 0, m = nBindings; j !== m; ++j) {\n\t\t\t\t\tbindings[j].push(new PropertyBinding(object, paths[j], parsedPaths[j]));\n\t\t\t\t}\n\t\t\t} else if (index < nCachedObjects) {\n\t\t\t\tknownObject = objects[index]; // move existing object to the ACTIVE region\n\n\t\t\t\tconst firstActiveIndex = --nCachedObjects,\n\t\t\t\t\t\t\tlastCachedObject = objects[firstActiveIndex];\n\t\t\t\tindicesByUUID[lastCachedObject.uuid] = index;\n\t\t\t\tobjects[index] = lastCachedObject;\n\t\t\t\tindicesByUUID[uuid] = firstActiveIndex;\n\t\t\t\tobjects[firstActiveIndex] = object; // accounting is done, now do the same for all bindings\n\n\t\t\t\tfor (let j = 0, m = nBindings; j !== m; ++j) {\n\t\t\t\t\tconst bindingsForPath = bindings[j],\n\t\t\t\t\t\t\t\tlastCached = bindingsForPath[firstActiveIndex];\n\t\t\t\t\tlet binding = bindingsForPath[index];\n\t\t\t\t\tbindingsForPath[index] = lastCached;\n\n\t\t\t\t\tif (binding === undefined) {\n\t\t\t\t\t\t// since we do not bother to create new bindings\n\t\t\t\t\t\t// for objects that are cached, the binding may\n\t\t\t\t\t\t// or may not exist\n\t\t\t\t\t\tbinding = new PropertyBinding(object, paths[j], parsedPaths[j]);\n\t\t\t\t\t}\n\n\t\t\t\t\tbindingsForPath[firstActiveIndex] = binding;\n\t\t\t\t}\n\t\t\t} else if (objects[index] !== knownObject) {\n\t\t\t\tconsole.error('THREE.AnimationObjectGroup: Different objects with the same UUID ' + 'detected. Clean the caches or recreate your infrastructure when reloading scenes.');\n\t\t\t} // else the object is already where we want it to be\n\n\t\t} // for arguments\n\n\n\t\tthis.nCachedObjects_ = nCachedObjects;\n\t}\n\n\tremove() {\n\t\tconst objects = this._objects,\n\t\t\t\t\tindicesByUUID = this._indicesByUUID,\n\t\t\t\t\tbindings = this._bindings,\n\t\t\t\t\tnBindings = bindings.length;\n\t\tlet nCachedObjects = this.nCachedObjects_;\n\n\t\tfor (let i = 0, n = arguments.length; i !== n; ++i) {\n\t\t\tconst object = arguments[i],\n\t\t\t\t\t\tuuid = object.uuid,\n\t\t\t\t\t\tindex = indicesByUUID[uuid];\n\n\t\t\tif (index !== undefined && index >= nCachedObjects) {\n\t\t\t\t// move existing object into the CACHED region\n\t\t\t\tconst lastCachedIndex = nCachedObjects++,\n\t\t\t\t\t\t\tfirstActiveObject = objects[lastCachedIndex];\n\t\t\t\tindicesByUUID[firstActiveObject.uuid] = index;\n\t\t\t\tobjects[index] = firstActiveObject;\n\t\t\t\tindicesByUUID[uuid] = lastCachedIndex;\n\t\t\t\tobjects[lastCachedIndex] = object; // accounting is done, now do the same for all bindings\n\n\t\t\t\tfor (let j = 0, m = nBindings; j !== m; ++j) {\n\t\t\t\t\tconst bindingsForPath = bindings[j],\n\t\t\t\t\t\t\t\tfirstActive = bindingsForPath[lastCachedIndex],\n\t\t\t\t\t\t\t\tbinding = bindingsForPath[index];\n\t\t\t\t\tbindingsForPath[index] = firstActive;\n\t\t\t\t\tbindingsForPath[lastCachedIndex] = binding;\n\t\t\t\t}\n\t\t\t}\n\t\t} // for arguments\n\n\n\t\tthis.nCachedObjects_ = nCachedObjects;\n\t} // remove & forget\n\n\n\tuncache() {\n\t\tconst objects = this._objects,\n\t\t\t\t\tindicesByUUID = this._indicesByUUID,\n\t\t\t\t\tbindings = this._bindings,\n\t\t\t\t\tnBindings = bindings.length;\n\t\tlet nCachedObjects = this.nCachedObjects_,\n\t\t\t\tnObjects = objects.length;\n\n\t\tfor (let i = 0, n = arguments.length; i !== n; ++i) {\n\t\t\tconst object = arguments[i],\n\t\t\t\t\t\tuuid = object.uuid,\n\t\t\t\t\t\tindex = indicesByUUID[uuid];\n\n\t\t\tif (index !== undefined) {\n\t\t\t\tdelete indicesByUUID[uuid];\n\n\t\t\t\tif (index < nCachedObjects) {\n\t\t\t\t\t// object is cached, shrink the CACHED region\n\t\t\t\t\tconst firstActiveIndex = --nCachedObjects,\n\t\t\t\t\t\t\t\tlastCachedObject = objects[firstActiveIndex],\n\t\t\t\t\t\t\t\tlastIndex = --nObjects,\n\t\t\t\t\t\t\t\tlastObject = objects[lastIndex]; // last cached object takes this object's place\n\n\t\t\t\t\tindicesByUUID[lastCachedObject.uuid] = index;\n\t\t\t\t\tobjects[index] = lastCachedObject; // last object goes to the activated slot and pop\n\n\t\t\t\t\tindicesByUUID[lastObject.uuid] = firstActiveIndex;\n\t\t\t\t\tobjects[firstActiveIndex] = lastObject;\n\t\t\t\t\tobjects.pop(); // accounting is done, now do the same for all bindings\n\n\t\t\t\t\tfor (let j = 0, m = nBindings; j !== m; ++j) {\n\t\t\t\t\t\tconst bindingsForPath = bindings[j],\n\t\t\t\t\t\t\t\t\tlastCached = bindingsForPath[firstActiveIndex],\n\t\t\t\t\t\t\t\t\tlast = bindingsForPath[lastIndex];\n\t\t\t\t\t\tbindingsForPath[index] = lastCached;\n\t\t\t\t\t\tbindingsForPath[firstActiveIndex] = last;\n\t\t\t\t\t\tbindingsForPath.pop();\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// object is active, just swap with the last and pop\n\t\t\t\t\tconst lastIndex = --nObjects,\n\t\t\t\t\t\t\t\tlastObject = objects[lastIndex];\n\n\t\t\t\t\tif (lastIndex > 0) {\n\t\t\t\t\t\tindicesByUUID[lastObject.uuid] = index;\n\t\t\t\t\t}\n\n\t\t\t\t\tobjects[index] = lastObject;\n\t\t\t\t\tobjects.pop(); // accounting is done, now do the same for all bindings\n\n\t\t\t\t\tfor (let j = 0, m = nBindings; j !== m; ++j) {\n\t\t\t\t\t\tconst bindingsForPath = bindings[j];\n\t\t\t\t\t\tbindingsForPath[index] = bindingsForPath[lastIndex];\n\t\t\t\t\t\tbindingsForPath.pop();\n\t\t\t\t\t}\n\t\t\t\t} // cached or active\n\n\t\t\t} // if object is known\n\n\t\t} // for arguments\n\n\n\t\tthis.nCachedObjects_ = nCachedObjects;\n\t} // Internal interface used by befriended PropertyBinding.Composite:\n\n\n\tsubscribe_(path, parsedPath) {\n\t\t// returns an array of bindings for the given path that is changed\n\t\t// according to the contained objects in the group\n\t\tconst indicesByPath = this._bindingsIndicesByPath;\n\t\tlet index = indicesByPath[path];\n\t\tconst bindings = this._bindings;\n\t\tif (index !== undefined) return bindings[index];\n\t\tconst paths = this._paths,\n\t\t\t\t\tparsedPaths = this._parsedPaths,\n\t\t\t\t\tobjects = this._objects,\n\t\t\t\t\tnObjects = objects.length,\n\t\t\t\t\tnCachedObjects = this.nCachedObjects_,\n\t\t\t\t\tbindingsForPath = new Array(nObjects);\n\t\tindex = bindings.length;\n\t\tindicesByPath[path] = index;\n\t\tpaths.push(path);\n\t\tparsedPaths.push(parsedPath);\n\t\tbindings.push(bindingsForPath);\n\n\t\tfor (let i = nCachedObjects, n = objects.length; i !== n; ++i) {\n\t\t\tconst object = objects[i];\n\t\t\tbindingsForPath[i] = new PropertyBinding(object, path, parsedPath);\n\t\t}\n\n\t\treturn bindingsForPath;\n\t}\n\n\tunsubscribe_(path) {\n\t\t// tells the group to forget about a property path and no longer\n\t\t// update the array previously obtained with 'subscribe_'\n\t\tconst indicesByPath = this._bindingsIndicesByPath,\n\t\t\t\t\tindex = indicesByPath[path];\n\n\t\tif (index !== undefined) {\n\t\t\tconst paths = this._paths,\n\t\t\t\t\t\tparsedPaths = this._parsedPaths,\n\t\t\t\t\t\tbindings = this._bindings,\n\t\t\t\t\t\tlastBindingsIndex = bindings.length - 1,\n\t\t\t\t\t\tlastBindings = bindings[lastBindingsIndex],\n\t\t\t\t\t\tlastBindingsPath = path[lastBindingsIndex];\n\t\t\tindicesByPath[lastBindingsPath] = index;\n\t\t\tbindings[index] = lastBindings;\n\t\t\tbindings.pop();\n\t\t\tparsedPaths[index] = parsedPaths[lastBindingsIndex];\n\t\t\tparsedPaths.pop();\n\t\t\tpaths[index] = paths[lastBindingsIndex];\n\t\t\tpaths.pop();\n\t\t}\n\t}\n\n}\n\nclass AnimationAction {\n\tconstructor(mixer, clip, localRoot = null, blendMode = clip.blendMode) {\n\t\tthis._mixer = mixer;\n\t\tthis._clip = clip;\n\t\tthis._localRoot = localRoot;\n\t\tthis.blendMode = blendMode;\n\t\tconst tracks = clip.tracks,\n\t\t\t\t\tnTracks = tracks.length,\n\t\t\t\t\tinterpolants = new Array(nTracks);\n\t\tconst interpolantSettings = {\n\t\t\tendingStart: ZeroCurvatureEnding,\n\t\t\tendingEnd: ZeroCurvatureEnding\n\t\t};\n\n\t\tfor (let i = 0; i !== nTracks; ++i) {\n\t\t\tconst interpolant = tracks[i].createInterpolant(null);\n\t\t\tinterpolants[i] = interpolant;\n\t\t\tinterpolant.settings = interpolantSettings;\n\t\t}\n\n\t\tthis._interpolantSettings = interpolantSettings;\n\t\tthis._interpolants = interpolants; // bound by the mixer\n\t\t// inside: PropertyMixer (managed by the mixer)\n\n\t\tthis._propertyBindings = new Array(nTracks);\n\t\tthis._cacheIndex = null; // for the memory manager\n\n\t\tthis._byClipCacheIndex = null; // for the memory manager\n\n\t\tthis._timeScaleInterpolant = null;\n\t\tthis._weightInterpolant = null;\n\t\tthis.loop = LoopRepeat;\n\t\tthis._loopCount = -1; // global mixer time when the action is to be started\n\t\t// it's set back to 'null' upon start of the action\n\n\t\tthis._startTime = null; // scaled local time of the action\n\t\t// gets clamped or wrapped to 0..clip.duration according to loop\n\n\t\tthis.time = 0;\n\t\tthis.timeScale = 1;\n\t\tthis._effectiveTimeScale = 1;\n\t\tthis.weight = 1;\n\t\tthis._effectiveWeight = 1;\n\t\tthis.repetitions = Infinity; // no. of repetitions when looping\n\n\t\tthis.paused = false; // true -> zero effective time scale\n\n\t\tthis.enabled = true; // false -> zero effective weight\n\n\t\tthis.clampWhenFinished = false; // keep feeding the last frame?\n\n\t\tthis.zeroSlopeAtStart = true; // for smooth interpolation w/o separate\n\n\t\tthis.zeroSlopeAtEnd = true; // clips for start, loop and end\n\t} // State & Scheduling\n\n\n\tplay() {\n\t\tthis._mixer._activateAction(this);\n\n\t\treturn this;\n\t}\n\n\tstop() {\n\t\tthis._mixer._deactivateAction(this);\n\n\t\treturn this.reset();\n\t}\n\n\treset() {\n\t\tthis.paused = false;\n\t\tthis.enabled = true;\n\t\tthis.time = 0; // restart clip\n\n\t\tthis._loopCount = -1; // forget previous loops\n\n\t\tthis._startTime = null; // forget scheduling\n\n\t\treturn this.stopFading().stopWarping();\n\t}\n\n\tisRunning() {\n\t\treturn this.enabled && !this.paused && this.timeScale !== 0 && this._startTime === null && this._mixer._isActiveAction(this);\n\t} // return true when play has been called\n\n\n\tisScheduled() {\n\t\treturn this._mixer._isActiveAction(this);\n\t}\n\n\tstartAt(time) {\n\t\tthis._startTime = time;\n\t\treturn this;\n\t}\n\n\tsetLoop(mode, repetitions) {\n\t\tthis.loop = mode;\n\t\tthis.repetitions = repetitions;\n\t\treturn this;\n\t} // Weight\n\t// set the weight stopping any scheduled fading\n\t// although .enabled = false yields an effective weight of zero, this\n\t// method does *not* change .enabled, because it would be confusing\n\n\n\tsetEffectiveWeight(weight) {\n\t\tthis.weight = weight; // note: same logic as when updated at runtime\n\n\t\tthis._effectiveWeight = this.enabled ? weight : 0;\n\t\treturn this.stopFading();\n\t} // return the weight considering fading and .enabled\n\n\n\tgetEffectiveWeight() {\n\t\treturn this._effectiveWeight;\n\t}\n\n\tfadeIn(duration) {\n\t\treturn this._scheduleFading(duration, 0, 1);\n\t}\n\n\tfadeOut(duration) {\n\t\treturn this._scheduleFading(duration, 1, 0);\n\t}\n\n\tcrossFadeFrom(fadeOutAction, duration, warp) {\n\t\tfadeOutAction.fadeOut(duration);\n\t\tthis.fadeIn(duration);\n\n\t\tif (warp) {\n\t\t\tconst fadeInDuration = this._clip.duration,\n\t\t\t\t\t\tfadeOutDuration = fadeOutAction._clip.duration,\n\t\t\t\t\t\tstartEndRatio = fadeOutDuration / fadeInDuration,\n\t\t\t\t\t\tendStartRatio = fadeInDuration / fadeOutDuration;\n\t\t\tfadeOutAction.warp(1.0, startEndRatio, duration);\n\t\t\tthis.warp(endStartRatio, 1.0, duration);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tcrossFadeTo(fadeInAction, duration, warp) {\n\t\treturn fadeInAction.crossFadeFrom(this, duration, warp);\n\t}\n\n\tstopFading() {\n\t\tconst weightInterpolant = this._weightInterpolant;\n\n\t\tif (weightInterpolant !== null) {\n\t\t\tthis._weightInterpolant = null;\n\n\t\t\tthis._mixer._takeBackControlInterpolant(weightInterpolant);\n\t\t}\n\n\t\treturn this;\n\t} // Time Scale Control\n\t// set the time scale stopping any scheduled warping\n\t// although .paused = true yields an effective time scale of zero, this\n\t// method does *not* change .paused, because it would be confusing\n\n\n\tsetEffectiveTimeScale(timeScale) {\n\t\tthis.timeScale = timeScale;\n\t\tthis._effectiveTimeScale = this.paused ? 0 : timeScale;\n\t\treturn this.stopWarping();\n\t} // return the time scale considering warping and .paused\n\n\n\tgetEffectiveTimeScale() {\n\t\treturn this._effectiveTimeScale;\n\t}\n\n\tsetDuration(duration) {\n\t\tthis.timeScale = this._clip.duration / duration;\n\t\treturn this.stopWarping();\n\t}\n\n\tsyncWith(action) {\n\t\tthis.time = action.time;\n\t\tthis.timeScale = action.timeScale;\n\t\treturn this.stopWarping();\n\t}\n\n\thalt(duration) {\n\t\treturn this.warp(this._effectiveTimeScale, 0, duration);\n\t}\n\n\twarp(startTimeScale, endTimeScale, duration) {\n\t\tconst mixer = this._mixer,\n\t\t\t\t\tnow = mixer.time,\n\t\t\t\t\ttimeScale = this.timeScale;\n\t\tlet interpolant = this._timeScaleInterpolant;\n\n\t\tif (interpolant === null) {\n\t\t\tinterpolant = mixer._lendControlInterpolant();\n\t\t\tthis._timeScaleInterpolant = interpolant;\n\t\t}\n\n\t\tconst times = interpolant.parameterPositions,\n\t\t\t\t\tvalues = interpolant.sampleValues;\n\t\ttimes[0] = now;\n\t\ttimes[1] = now + duration;\n\t\tvalues[0] = startTimeScale / timeScale;\n\t\tvalues[1] = endTimeScale / timeScale;\n\t\treturn this;\n\t}\n\n\tstopWarping() {\n\t\tconst timeScaleInterpolant = this._timeScaleInterpolant;\n\n\t\tif (timeScaleInterpolant !== null) {\n\t\t\tthis._timeScaleInterpolant = null;\n\n\t\t\tthis._mixer._takeBackControlInterpolant(timeScaleInterpolant);\n\t\t}\n\n\t\treturn this;\n\t} // Object Accessors\n\n\n\tgetMixer() {\n\t\treturn this._mixer;\n\t}\n\n\tgetClip() {\n\t\treturn this._clip;\n\t}\n\n\tgetRoot() {\n\t\treturn this._localRoot || this._mixer._root;\n\t} // Interna\n\n\n\t_update(time, deltaTime, timeDirection, accuIndex) {\n\t\t// called by the mixer\n\t\tif (!this.enabled) {\n\t\t\t// call ._updateWeight() to update ._effectiveWeight\n\t\t\tthis._updateWeight(time);\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst startTime = this._startTime;\n\n\t\tif (startTime !== null) {\n\t\t\t// check for scheduled start of action\n\t\t\tconst timeRunning = (time - startTime) * timeDirection;\n\n\t\t\tif (timeRunning < 0 || timeDirection === 0) {\n\t\t\t\tdeltaTime = 0;\n\t\t\t} else {\n\t\t\t\tthis._startTime = null; // unschedule\n\n\t\t\t\tdeltaTime = timeDirection * timeRunning;\n\t\t\t}\n\t\t} // apply time scale and advance time\n\n\n\t\tdeltaTime *= this._updateTimeScale(time);\n\n\t\tconst clipTime = this._updateTime(deltaTime); // note: _updateTime may disable the action resulting in\n\t\t// an effective weight of 0\n\n\n\t\tconst weight = this._updateWeight(time);\n\n\t\tif (weight > 0) {\n\t\t\tconst interpolants = this._interpolants;\n\t\t\tconst propertyMixers = this._propertyBindings;\n\n\t\t\tswitch (this.blendMode) {\n\t\t\t\tcase AdditiveAnimationBlendMode:\n\t\t\t\t\tfor (let j = 0, m = interpolants.length; j !== m; ++j) {\n\t\t\t\t\t\tinterpolants[j].evaluate(clipTime);\n\t\t\t\t\t\tpropertyMixers[j].accumulateAdditive(weight);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase NormalAnimationBlendMode:\n\t\t\t\tdefault:\n\t\t\t\t\tfor (let j = 0, m = interpolants.length; j !== m; ++j) {\n\t\t\t\t\t\tinterpolants[j].evaluate(clipTime);\n\t\t\t\t\t\tpropertyMixers[j].accumulate(accuIndex, weight);\n\t\t\t\t\t}\n\n\t\t\t}\n\t\t}\n\t}\n\n\t_updateWeight(time) {\n\t\tlet weight = 0;\n\n\t\tif (this.enabled) {\n\t\t\tweight = this.weight;\n\t\t\tconst interpolant = this._weightInterpolant;\n\n\t\t\tif (interpolant !== null) {\n\t\t\t\tconst interpolantValue = interpolant.evaluate(time)[0];\n\t\t\t\tweight *= interpolantValue;\n\n\t\t\t\tif (time > interpolant.parameterPositions[1]) {\n\t\t\t\t\tthis.stopFading();\n\n\t\t\t\t\tif (interpolantValue === 0) {\n\t\t\t\t\t\t// faded out, disable\n\t\t\t\t\t\tthis.enabled = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis._effectiveWeight = weight;\n\t\treturn weight;\n\t}\n\n\t_updateTimeScale(time) {\n\t\tlet timeScale = 0;\n\n\t\tif (!this.paused) {\n\t\t\ttimeScale = this.timeScale;\n\t\t\tconst interpolant = this._timeScaleInterpolant;\n\n\t\t\tif (interpolant !== null) {\n\t\t\t\tconst interpolantValue = interpolant.evaluate(time)[0];\n\t\t\t\ttimeScale *= interpolantValue;\n\n\t\t\t\tif (time > interpolant.parameterPositions[1]) {\n\t\t\t\t\tthis.stopWarping();\n\n\t\t\t\t\tif (timeScale === 0) {\n\t\t\t\t\t\t// motion has halted, pause\n\t\t\t\t\t\tthis.paused = true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// warp done - apply final time scale\n\t\t\t\t\t\tthis.timeScale = timeScale;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis._effectiveTimeScale = timeScale;\n\t\treturn timeScale;\n\t}\n\n\t_updateTime(deltaTime) {\n\t\tconst duration = this._clip.duration;\n\t\tconst loop = this.loop;\n\t\tlet time = this.time + deltaTime;\n\t\tlet loopCount = this._loopCount;\n\t\tconst pingPong = loop === LoopPingPong;\n\n\t\tif (deltaTime === 0) {\n\t\t\tif (loopCount === -1) return time;\n\t\t\treturn pingPong && (loopCount & 1) === 1 ? duration - time : time;\n\t\t}\n\n\t\tif (loop === LoopOnce) {\n\t\t\tif (loopCount === -1) {\n\t\t\t\t// just started\n\t\t\t\tthis._loopCount = 0;\n\n\t\t\t\tthis._setEndings(true, true, false);\n\t\t\t}\n\n\t\t\thandle_stop: {\n\t\t\t\tif (time >= duration) {\n\t\t\t\t\ttime = duration;\n\t\t\t\t} else if (time < 0) {\n\t\t\t\t\ttime = 0;\n\t\t\t\t} else {\n\t\t\t\t\tthis.time = time;\n\t\t\t\t\tbreak handle_stop;\n\t\t\t\t}\n\n\t\t\t\tif (this.clampWhenFinished) this.paused = true;else this.enabled = false;\n\t\t\t\tthis.time = time;\n\n\t\t\t\tthis._mixer.dispatchEvent({\n\t\t\t\t\ttype: 'finished',\n\t\t\t\t\taction: this,\n\t\t\t\t\tdirection: deltaTime < 0 ? -1 : 1\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\t// repetitive Repeat or PingPong\n\t\t\tif (loopCount === -1) {\n\t\t\t\t// just started\n\t\t\t\tif (deltaTime >= 0) {\n\t\t\t\t\tloopCount = 0;\n\n\t\t\t\t\tthis._setEndings(true, this.repetitions === 0, pingPong);\n\t\t\t\t} else {\n\t\t\t\t\t// when looping in reverse direction, the initial\n\t\t\t\t\t// transition through zero counts as a repetition,\n\t\t\t\t\t// so leave loopCount at -1\n\t\t\t\t\tthis._setEndings(this.repetitions === 0, true, pingPong);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (time >= duration || time < 0) {\n\t\t\t\t// wrap around\n\t\t\t\tconst loopDelta = Math.floor(time / duration); // signed\n\n\t\t\t\ttime -= duration * loopDelta;\n\t\t\t\tloopCount += Math.abs(loopDelta);\n\t\t\t\tconst pending = this.repetitions - loopCount;\n\n\t\t\t\tif (pending <= 0) {\n\t\t\t\t\t// have to stop (switch state, clamp time, fire event)\n\t\t\t\t\tif (this.clampWhenFinished) this.paused = true;else this.enabled = false;\n\t\t\t\t\ttime = deltaTime > 0 ? duration : 0;\n\t\t\t\t\tthis.time = time;\n\n\t\t\t\t\tthis._mixer.dispatchEvent({\n\t\t\t\t\t\ttype: 'finished',\n\t\t\t\t\t\taction: this,\n\t\t\t\t\t\tdirection: deltaTime > 0 ? 1 : -1\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\t// keep running\n\t\t\t\t\tif (pending === 1) {\n\t\t\t\t\t\t// entering the last round\n\t\t\t\t\t\tconst atStart = deltaTime < 0;\n\n\t\t\t\t\t\tthis._setEndings(atStart, !atStart, pingPong);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis._setEndings(false, false, pingPong);\n\t\t\t\t\t}\n\n\t\t\t\t\tthis._loopCount = loopCount;\n\t\t\t\t\tthis.time = time;\n\n\t\t\t\t\tthis._mixer.dispatchEvent({\n\t\t\t\t\t\ttype: 'loop',\n\t\t\t\t\t\taction: this,\n\t\t\t\t\t\tloopDelta: loopDelta\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.time = time;\n\t\t\t}\n\n\t\t\tif (pingPong && (loopCount & 1) === 1) {\n\t\t\t\t// invert time for the \"pong round\"\n\t\t\t\treturn duration - time;\n\t\t\t}\n\t\t}\n\n\t\treturn time;\n\t}\n\n\t_setEndings(atStart, atEnd, pingPong) {\n\t\tconst settings = this._interpolantSettings;\n\n\t\tif (pingPong) {\n\t\t\tsettings.endingStart = ZeroSlopeEnding;\n\t\t\tsettings.endingEnd = ZeroSlopeEnding;\n\t\t} else {\n\t\t\t// assuming for LoopOnce atStart == atEnd == true\n\t\t\tif (atStart) {\n\t\t\t\tsettings.endingStart = this.zeroSlopeAtStart ? ZeroSlopeEnding : ZeroCurvatureEnding;\n\t\t\t} else {\n\t\t\t\tsettings.endingStart = WrapAroundEnding;\n\t\t\t}\n\n\t\t\tif (atEnd) {\n\t\t\t\tsettings.endingEnd = this.zeroSlopeAtEnd ? ZeroSlopeEnding : ZeroCurvatureEnding;\n\t\t\t} else {\n\t\t\t\tsettings.endingEnd = WrapAroundEnding;\n\t\t\t}\n\t\t}\n\t}\n\n\t_scheduleFading(duration, weightNow, weightThen) {\n\t\tconst mixer = this._mixer,\n\t\t\t\t\tnow = mixer.time;\n\t\tlet interpolant = this._weightInterpolant;\n\n\t\tif (interpolant === null) {\n\t\t\tinterpolant = mixer._lendControlInterpolant();\n\t\t\tthis._weightInterpolant = interpolant;\n\t\t}\n\n\t\tconst times = interpolant.parameterPositions,\n\t\t\t\t\tvalues = interpolant.sampleValues;\n\t\ttimes[0] = now;\n\t\tvalues[0] = weightNow;\n\t\ttimes[1] = now + duration;\n\t\tvalues[1] = weightThen;\n\t\treturn this;\n\t}\n\n}\n\nconst _controlInterpolantsResultBuffer = new Float32Array(1);\n\nclass AnimationMixer extends EventDispatcher {\n\tconstructor(root) {\n\t\tsuper();\n\t\tthis._root = root;\n\n\t\tthis._initMemoryManager();\n\n\t\tthis._accuIndex = 0;\n\t\tthis.time = 0;\n\t\tthis.timeScale = 1.0;\n\t}\n\n\t_bindAction(action, prototypeAction) {\n\t\tconst root = action._localRoot || this._root,\n\t\t\t\t\ttracks = action._clip.tracks,\n\t\t\t\t\tnTracks = tracks.length,\n\t\t\t\t\tbindings = action._propertyBindings,\n\t\t\t\t\tinterpolants = action._interpolants,\n\t\t\t\t\trootUuid = root.uuid,\n\t\t\t\t\tbindingsByRoot = this._bindingsByRootAndName;\n\t\tlet bindingsByName = bindingsByRoot[rootUuid];\n\n\t\tif (bindingsByName === undefined) {\n\t\t\tbindingsByName = {};\n\t\t\tbindingsByRoot[rootUuid] = bindingsByName;\n\t\t}\n\n\t\tfor (let i = 0; i !== nTracks; ++i) {\n\t\t\tconst track = tracks[i],\n\t\t\t\t\t\ttrackName = track.name;\n\t\t\tlet binding = bindingsByName[trackName];\n\n\t\t\tif (binding !== undefined) {\n\t\t\t\t++binding.referenceCount;\n\t\t\t\tbindings[i] = binding;\n\t\t\t} else {\n\t\t\t\tbinding = bindings[i];\n\n\t\t\t\tif (binding !== undefined) {\n\t\t\t\t\t// existing binding, make sure the cache knows\n\t\t\t\t\tif (binding._cacheIndex === null) {\n\t\t\t\t\t\t++binding.referenceCount;\n\n\t\t\t\t\t\tthis._addInactiveBinding(binding, rootUuid, trackName);\n\t\t\t\t\t}\n\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst path = prototypeAction && prototypeAction._propertyBindings[i].binding.parsedPath;\n\t\t\t\tbinding = new PropertyMixer(PropertyBinding.create(root, trackName, path), track.ValueTypeName, track.getValueSize());\n\t\t\t\t++binding.referenceCount;\n\n\t\t\t\tthis._addInactiveBinding(binding, rootUuid, trackName);\n\n\t\t\t\tbindings[i] = binding;\n\t\t\t}\n\n\t\t\tinterpolants[i].resultBuffer = binding.buffer;\n\t\t}\n\t}\n\n\t_activateAction(action) {\n\t\tif (!this._isActiveAction(action)) {\n\t\t\tif (action._cacheIndex === null) {\n\t\t\t\t// this action has been forgotten by the cache, but the user\n\t\t\t\t// appears to be still using it -> rebind\n\t\t\t\tconst rootUuid = (action._localRoot || this._root).uuid,\n\t\t\t\t\t\t\tclipUuid = action._clip.uuid,\n\t\t\t\t\t\t\tactionsForClip = this._actionsByClip[clipUuid];\n\n\t\t\t\tthis._bindAction(action, actionsForClip && actionsForClip.knownActions[0]);\n\n\t\t\t\tthis._addInactiveAction(action, clipUuid, rootUuid);\n\t\t\t}\n\n\t\t\tconst bindings = action._propertyBindings; // increment reference counts / sort out state\n\n\t\t\tfor (let i = 0, n = bindings.length; i !== n; ++i) {\n\t\t\t\tconst binding = bindings[i];\n\n\t\t\t\tif (binding.useCount++ === 0) {\n\t\t\t\t\tthis._lendBinding(binding);\n\n\t\t\t\t\tbinding.saveOriginalState();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis._lendAction(action);\n\t\t}\n\t}\n\n\t_deactivateAction(action) {\n\t\tif (this._isActiveAction(action)) {\n\t\t\tconst bindings = action._propertyBindings; // decrement reference counts / sort out state\n\n\t\t\tfor (let i = 0, n = bindings.length; i !== n; ++i) {\n\t\t\t\tconst binding = bindings[i];\n\n\t\t\t\tif (--binding.useCount === 0) {\n\t\t\t\t\tbinding.restoreOriginalState();\n\n\t\t\t\t\tthis._takeBackBinding(binding);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis._takeBackAction(action);\n\t\t}\n\t} // Memory manager\n\n\n\t_initMemoryManager() {\n\t\tthis._actions = []; // 'nActiveActions' followed by inactive ones\n\n\t\tthis._nActiveActions = 0;\n\t\tthis._actionsByClip = {}; // inside:\n\t\t// {\n\t\t// \tknownActions: Array< AnimationAction > - used as prototypes\n\t\t// \tactionByRoot: AnimationAction - lookup\n\t\t// }\n\n\t\tthis._bindings = []; // 'nActiveBindings' followed by inactive ones\n\n\t\tthis._nActiveBindings = 0;\n\t\tthis._bindingsByRootAndName = {}; // inside: Map< name, PropertyMixer >\n\n\t\tthis._controlInterpolants = []; // same game as above\n\n\t\tthis._nActiveControlInterpolants = 0;\n\t\tconst scope = this;\n\t\tthis.stats = {\n\t\t\tactions: {\n\t\t\t\tget total() {\n\t\t\t\t\treturn scope._actions.length;\n\t\t\t\t},\n\n\t\t\t\tget inUse() {\n\t\t\t\t\treturn scope._nActiveActions;\n\t\t\t\t}\n\n\t\t\t},\n\t\t\tbindings: {\n\t\t\t\tget total() {\n\t\t\t\t\treturn scope._bindings.length;\n\t\t\t\t},\n\n\t\t\t\tget inUse() {\n\t\t\t\t\treturn scope._nActiveBindings;\n\t\t\t\t}\n\n\t\t\t},\n\t\t\tcontrolInterpolants: {\n\t\t\t\tget total() {\n\t\t\t\t\treturn scope._controlInterpolants.length;\n\t\t\t\t},\n\n\t\t\t\tget inUse() {\n\t\t\t\t\treturn scope._nActiveControlInterpolants;\n\t\t\t\t}\n\n\t\t\t}\n\t\t};\n\t} // Memory management for AnimationAction objects\n\n\n\t_isActiveAction(action) {\n\t\tconst index = action._cacheIndex;\n\t\treturn index !== null && index < this._nActiveActions;\n\t}\n\n\t_addInactiveAction(action, clipUuid, rootUuid) {\n\t\tconst actions = this._actions,\n\t\t\t\t\tactionsByClip = this._actionsByClip;\n\t\tlet actionsForClip = actionsByClip[clipUuid];\n\n\t\tif (actionsForClip === undefined) {\n\t\t\tactionsForClip = {\n\t\t\t\tknownActions: [action],\n\t\t\t\tactionByRoot: {}\n\t\t\t};\n\t\t\taction._byClipCacheIndex = 0;\n\t\t\tactionsByClip[clipUuid] = actionsForClip;\n\t\t} else {\n\t\t\tconst knownActions = actionsForClip.knownActions;\n\t\t\taction._byClipCacheIndex = knownActions.length;\n\t\t\tknownActions.push(action);\n\t\t}\n\n\t\taction._cacheIndex = actions.length;\n\t\tactions.push(action);\n\t\tactionsForClip.actionByRoot[rootUuid] = action;\n\t}\n\n\t_removeInactiveAction(action) {\n\t\tconst actions = this._actions,\n\t\t\t\t\tlastInactiveAction = actions[actions.length - 1],\n\t\t\t\t\tcacheIndex = action._cacheIndex;\n\t\tlastInactiveAction._cacheIndex = cacheIndex;\n\t\tactions[cacheIndex] = lastInactiveAction;\n\t\tactions.pop();\n\t\taction._cacheIndex = null;\n\t\tconst clipUuid = action._clip.uuid,\n\t\t\t\t\tactionsByClip = this._actionsByClip,\n\t\t\t\t\tactionsForClip = actionsByClip[clipUuid],\n\t\t\t\t\tknownActionsForClip = actionsForClip.knownActions,\n\t\t\t\t\tlastKnownAction = knownActionsForClip[knownActionsForClip.length - 1],\n\t\t\t\t\tbyClipCacheIndex = action._byClipCacheIndex;\n\t\tlastKnownAction._byClipCacheIndex = byClipCacheIndex;\n\t\tknownActionsForClip[byClipCacheIndex] = lastKnownAction;\n\t\tknownActionsForClip.pop();\n\t\taction._byClipCacheIndex = null;\n\t\tconst actionByRoot = actionsForClip.actionByRoot,\n\t\t\t\t\trootUuid = (action._localRoot || this._root).uuid;\n\t\tdelete actionByRoot[rootUuid];\n\n\t\tif (knownActionsForClip.length === 0) {\n\t\t\tdelete actionsByClip[clipUuid];\n\t\t}\n\n\t\tthis._removeInactiveBindingsForAction(action);\n\t}\n\n\t_removeInactiveBindingsForAction(action) {\n\t\tconst bindings = action._propertyBindings;\n\n\t\tfor (let i = 0, n = bindings.length; i !== n; ++i) {\n\t\t\tconst binding = bindings[i];\n\n\t\t\tif (--binding.referenceCount === 0) {\n\t\t\t\tthis._removeInactiveBinding(binding);\n\t\t\t}\n\t\t}\n\t}\n\n\t_lendAction(action) {\n\t\t// [ active actions |\tinactive actions\t]\n\t\t// [\tactive actions >| inactive actions ]\n\t\t//\t\t\t\t\t\t\t\t s\t\t\t\ta\n\t\t//\t\t\t\t\t\t\t\t\t<-swap->\n\t\t//\t\t\t\t\t\t\t\t a\t\t\t\ts\n\t\tconst actions = this._actions,\n\t\t\t\t\tprevIndex = action._cacheIndex,\n\t\t\t\t\tlastActiveIndex = this._nActiveActions++,\n\t\t\t\t\tfirstInactiveAction = actions[lastActiveIndex];\n\t\taction._cacheIndex = lastActiveIndex;\n\t\tactions[lastActiveIndex] = action;\n\t\tfirstInactiveAction._cacheIndex = prevIndex;\n\t\tactions[prevIndex] = firstInactiveAction;\n\t}\n\n\t_takeBackAction(action) {\n\t\t// [\tactive actions\t| inactive actions ]\n\t\t// [ active actions |< inactive actions\t]\n\t\t//\t\t\t\ta\t\t\t\ts\n\t\t//\t\t\t\t <-swap->\n\t\t//\t\t\t\ts\t\t\t\ta\n\t\tconst actions = this._actions,\n\t\t\t\t\tprevIndex = action._cacheIndex,\n\t\t\t\t\tfirstInactiveIndex = --this._nActiveActions,\n\t\t\t\t\tlastActiveAction = actions[firstInactiveIndex];\n\t\taction._cacheIndex = firstInactiveIndex;\n\t\tactions[firstInactiveIndex] = action;\n\t\tlastActiveAction._cacheIndex = prevIndex;\n\t\tactions[prevIndex] = lastActiveAction;\n\t} // Memory management for PropertyMixer objects\n\n\n\t_addInactiveBinding(binding, rootUuid, trackName) {\n\t\tconst bindingsByRoot = this._bindingsByRootAndName,\n\t\t\t\t\tbindings = this._bindings;\n\t\tlet bindingByName = bindingsByRoot[rootUuid];\n\n\t\tif (bindingByName === undefined) {\n\t\t\tbindingByName = {};\n\t\t\tbindingsByRoot[rootUuid] = bindingByName;\n\t\t}\n\n\t\tbindingByName[trackName] = binding;\n\t\tbinding._cacheIndex = bindings.length;\n\t\tbindings.push(binding);\n\t}\n\n\t_removeInactiveBinding(binding) {\n\t\tconst bindings = this._bindings,\n\t\t\t\t\tpropBinding = binding.binding,\n\t\t\t\t\trootUuid = propBinding.rootNode.uuid,\n\t\t\t\t\ttrackName = propBinding.path,\n\t\t\t\t\tbindingsByRoot = this._bindingsByRootAndName,\n\t\t\t\t\tbindingByName = bindingsByRoot[rootUuid],\n\t\t\t\t\tlastInactiveBinding = bindings[bindings.length - 1],\n\t\t\t\t\tcacheIndex = binding._cacheIndex;\n\t\tlastInactiveBinding._cacheIndex = cacheIndex;\n\t\tbindings[cacheIndex] = lastInactiveBinding;\n\t\tbindings.pop();\n\t\tdelete bindingByName[trackName];\n\n\t\tif (Object.keys(bindingByName).length === 0) {\n\t\t\tdelete bindingsByRoot[rootUuid];\n\t\t}\n\t}\n\n\t_lendBinding(binding) {\n\t\tconst bindings = this._bindings,\n\t\t\t\t\tprevIndex = binding._cacheIndex,\n\t\t\t\t\tlastActiveIndex = this._nActiveBindings++,\n\t\t\t\t\tfirstInactiveBinding = bindings[lastActiveIndex];\n\t\tbinding._cacheIndex = lastActiveIndex;\n\t\tbindings[lastActiveIndex] = binding;\n\t\tfirstInactiveBinding._cacheIndex = prevIndex;\n\t\tbindings[prevIndex] = firstInactiveBinding;\n\t}\n\n\t_takeBackBinding(binding) {\n\t\tconst bindings = this._bindings,\n\t\t\t\t\tprevIndex = binding._cacheIndex,\n\t\t\t\t\tfirstInactiveIndex = --this._nActiveBindings,\n\t\t\t\t\tlastActiveBinding = bindings[firstInactiveIndex];\n\t\tbinding._cacheIndex = firstInactiveIndex;\n\t\tbindings[firstInactiveIndex] = binding;\n\t\tlastActiveBinding._cacheIndex = prevIndex;\n\t\tbindings[prevIndex] = lastActiveBinding;\n\t} // Memory management of Interpolants for weight and time scale\n\n\n\t_lendControlInterpolant() {\n\t\tconst interpolants = this._controlInterpolants,\n\t\t\t\t\tlastActiveIndex = this._nActiveControlInterpolants++;\n\t\tlet interpolant = interpolants[lastActiveIndex];\n\n\t\tif (interpolant === undefined) {\n\t\t\tinterpolant = new LinearInterpolant(new Float32Array(2), new Float32Array(2), 1, _controlInterpolantsResultBuffer);\n\t\t\tinterpolant.__cacheIndex = lastActiveIndex;\n\t\t\tinterpolants[lastActiveIndex] = interpolant;\n\t\t}\n\n\t\treturn interpolant;\n\t}\n\n\t_takeBackControlInterpolant(interpolant) {\n\t\tconst interpolants = this._controlInterpolants,\n\t\t\t\t\tprevIndex = interpolant.__cacheIndex,\n\t\t\t\t\tfirstInactiveIndex = --this._nActiveControlInterpolants,\n\t\t\t\t\tlastActiveInterpolant = interpolants[firstInactiveIndex];\n\t\tinterpolant.__cacheIndex = firstInactiveIndex;\n\t\tinterpolants[firstInactiveIndex] = interpolant;\n\t\tlastActiveInterpolant.__cacheIndex = prevIndex;\n\t\tinterpolants[prevIndex] = lastActiveInterpolant;\n\t} // return an action for a clip optionally using a custom root target\n\t// object (this method allocates a lot of dynamic memory in case a\n\t// previously unknown clip/root combination is specified)\n\n\n\tclipAction(clip, optionalRoot, blendMode) {\n\t\tconst root = optionalRoot || this._root,\n\t\t\t\t\trootUuid = root.uuid;\n\t\tlet clipObject = typeof clip === 'string' ? AnimationClip.findByName(root, clip) : clip;\n\t\tconst clipUuid = clipObject !== null ? clipObject.uuid : clip;\n\t\tconst actionsForClip = this._actionsByClip[clipUuid];\n\t\tlet prototypeAction = null;\n\n\t\tif (blendMode === undefined) {\n\t\t\tif (clipObject !== null) {\n\t\t\t\tblendMode = clipObject.blendMode;\n\t\t\t} else {\n\t\t\t\tblendMode = NormalAnimationBlendMode;\n\t\t\t}\n\t\t}\n\n\t\tif (actionsForClip !== undefined) {\n\t\t\tconst existingAction = actionsForClip.actionByRoot[rootUuid];\n\n\t\t\tif (existingAction !== undefined && existingAction.blendMode === blendMode) {\n\t\t\t\treturn existingAction;\n\t\t\t} // we know the clip, so we don't have to parse all\n\t\t\t// the bindings again but can just copy\n\n\n\t\t\tprototypeAction = actionsForClip.knownActions[0]; // also, take the clip from the prototype action\n\n\t\t\tif (clipObject === null) clipObject = prototypeAction._clip;\n\t\t} // clip must be known when specified via string\n\n\n\t\tif (clipObject === null) return null; // allocate all resources required to run it\n\n\t\tconst newAction = new AnimationAction(this, clipObject, optionalRoot, blendMode);\n\n\t\tthis._bindAction(newAction, prototypeAction); // and make the action known to the memory manager\n\n\n\t\tthis._addInactiveAction(newAction, clipUuid, rootUuid);\n\n\t\treturn newAction;\n\t} // get an existing action\n\n\n\texistingAction(clip, optionalRoot) {\n\t\tconst root = optionalRoot || this._root,\n\t\t\t\t\trootUuid = root.uuid,\n\t\t\t\t\tclipObject = typeof clip === 'string' ? AnimationClip.findByName(root, clip) : clip,\n\t\t\t\t\tclipUuid = clipObject ? clipObject.uuid : clip,\n\t\t\t\t\tactionsForClip = this._actionsByClip[clipUuid];\n\n\t\tif (actionsForClip !== undefined) {\n\t\t\treturn actionsForClip.actionByRoot[rootUuid] || null;\n\t\t}\n\n\t\treturn null;\n\t} // deactivates all previously scheduled actions\n\n\n\tstopAllAction() {\n\t\tconst actions = this._actions,\n\t\t\t\t\tnActions = this._nActiveActions;\n\n\t\tfor (let i = nActions - 1; i >= 0; --i) {\n\t\t\tactions[i].stop();\n\t\t}\n\n\t\treturn this;\n\t} // advance the time and update apply the animation\n\n\n\tupdate(deltaTime) {\n\t\tdeltaTime *= this.timeScale;\n\t\tconst actions = this._actions,\n\t\t\t\t\tnActions = this._nActiveActions,\n\t\t\t\t\ttime = this.time += deltaTime,\n\t\t\t\t\ttimeDirection = Math.sign(deltaTime),\n\t\t\t\t\taccuIndex = this._accuIndex ^= 1; // run active actions\n\n\t\tfor (let i = 0; i !== nActions; ++i) {\n\t\t\tconst action = actions[i];\n\n\t\t\taction._update(time, deltaTime, timeDirection, accuIndex);\n\t\t} // update scene graph\n\n\n\t\tconst bindings = this._bindings,\n\t\t\t\t\tnBindings = this._nActiveBindings;\n\n\t\tfor (let i = 0; i !== nBindings; ++i) {\n\t\t\tbindings[i].apply(accuIndex);\n\t\t}\n\n\t\treturn this;\n\t} // Allows you to seek to a specific time in an animation.\n\n\n\tsetTime(timeInSeconds) {\n\t\tthis.time = 0; // Zero out time attribute for AnimationMixer object;\n\n\t\tfor (let i = 0; i < this._actions.length; i++) {\n\t\t\tthis._actions[i].time = 0; // Zero out time attribute for all associated AnimationAction objects.\n\t\t}\n\n\t\treturn this.update(timeInSeconds); // Update used to set exact time. Returns \"this\" AnimationMixer object.\n\t} // return this mixer's root target object\n\n\n\tgetRoot() {\n\t\treturn this._root;\n\t} // free all resources specific to a particular clip\n\n\n\tuncacheClip(clip) {\n\t\tconst actions = this._actions,\n\t\t\t\t\tclipUuid = clip.uuid,\n\t\t\t\t\tactionsByClip = this._actionsByClip,\n\t\t\t\t\tactionsForClip = actionsByClip[clipUuid];\n\n\t\tif (actionsForClip !== undefined) {\n\t\t\t// note: just calling _removeInactiveAction would mess up the\n\t\t\t// iteration state and also require updating the state we can\n\t\t\t// just throw away\n\t\t\tconst actionsToRemove = actionsForClip.knownActions;\n\n\t\t\tfor (let i = 0, n = actionsToRemove.length; i !== n; ++i) {\n\t\t\t\tconst action = actionsToRemove[i];\n\n\t\t\t\tthis._deactivateAction(action);\n\n\t\t\t\tconst cacheIndex = action._cacheIndex,\n\t\t\t\t\t\t\tlastInactiveAction = actions[actions.length - 1];\n\t\t\t\taction._cacheIndex = null;\n\t\t\t\taction._byClipCacheIndex = null;\n\t\t\t\tlastInactiveAction._cacheIndex = cacheIndex;\n\t\t\t\tactions[cacheIndex] = lastInactiveAction;\n\t\t\t\tactions.pop();\n\n\t\t\t\tthis._removeInactiveBindingsForAction(action);\n\t\t\t}\n\n\t\t\tdelete actionsByClip[clipUuid];\n\t\t}\n\t} // free all resources specific to a particular root target object\n\n\n\tuncacheRoot(root) {\n\t\tconst rootUuid = root.uuid,\n\t\t\t\t\tactionsByClip = this._actionsByClip;\n\n\t\tfor (const clipUuid in actionsByClip) {\n\t\t\tconst actionByRoot = actionsByClip[clipUuid].actionByRoot,\n\t\t\t\t\t\taction = actionByRoot[rootUuid];\n\n\t\t\tif (action !== undefined) {\n\t\t\t\tthis._deactivateAction(action);\n\n\t\t\t\tthis._removeInactiveAction(action);\n\t\t\t}\n\t\t}\n\n\t\tconst bindingsByRoot = this._bindingsByRootAndName,\n\t\t\t\t\tbindingByName = bindingsByRoot[rootUuid];\n\n\t\tif (bindingByName !== undefined) {\n\t\t\tfor (const trackName in bindingByName) {\n\t\t\t\tconst binding = bindingByName[trackName];\n\t\t\t\tbinding.restoreOriginalState();\n\n\t\t\t\tthis._removeInactiveBinding(binding);\n\t\t\t}\n\t\t}\n\t} // remove a targeted clip from the cache\n\n\n\tuncacheAction(clip, optionalRoot) {\n\t\tconst action = this.existingAction(clip, optionalRoot);\n\n\t\tif (action !== null) {\n\t\t\tthis._deactivateAction(action);\n\n\t\t\tthis._removeInactiveAction(action);\n\t\t}\n\t}\n\n}\n\nclass Uniform {\n\tconstructor(value) {\n\t\tthis.value = value;\n\t}\n\n\tclone() {\n\t\treturn new Uniform(this.value.clone === undefined ? this.value : this.value.clone());\n\t}\n\n}\n\nlet id = 0;\n\nclass UniformsGroup extends EventDispatcher {\n\tconstructor() {\n\t\tsuper();\n\t\tthis.isUniformsGroup = true;\n\t\tObject.defineProperty(this, 'id', {\n\t\t\tvalue: id++\n\t\t});\n\t\tthis.name = '';\n\t\tthis.usage = StaticDrawUsage;\n\t\tthis.uniforms = [];\n\t}\n\n\tadd(uniform) {\n\t\tthis.uniforms.push(uniform);\n\t\treturn this;\n\t}\n\n\tremove(uniform) {\n\t\tconst index = this.uniforms.indexOf(uniform);\n\t\tif (index !== -1) this.uniforms.splice(index, 1);\n\t\treturn this;\n\t}\n\n\tsetName(name) {\n\t\tthis.name = name;\n\t\treturn this;\n\t}\n\n\tsetUsage(value) {\n\t\tthis.usage = value;\n\t\treturn this;\n\t}\n\n\tdispose() {\n\t\tthis.dispatchEvent({\n\t\t\ttype: 'dispose'\n\t\t});\n\t\treturn this;\n\t}\n\n\tcopy(source) {\n\t\tthis.name = source.name;\n\t\tthis.usage = source.usage;\n\t\tconst uniformsSource = source.uniforms;\n\t\tthis.uniforms.length = 0;\n\n\t\tfor (let i = 0, l = uniformsSource.length; i < l; i++) {\n\t\t\tthis.uniforms.push(uniformsSource[i].clone());\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\treturn new this.constructor().copy(this);\n\t}\n\n}\n\nclass InstancedInterleavedBuffer extends InterleavedBuffer {\n\tconstructor(array, stride, meshPerAttribute = 1) {\n\t\tsuper(array, stride);\n\t\tthis.isInstancedInterleavedBuffer = true;\n\t\tthis.meshPerAttribute = meshPerAttribute;\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source);\n\t\tthis.meshPerAttribute = source.meshPerAttribute;\n\t\treturn this;\n\t}\n\n\tclone(data) {\n\t\tconst ib = super.clone(data);\n\t\tib.meshPerAttribute = this.meshPerAttribute;\n\t\treturn ib;\n\t}\n\n\ttoJSON(data) {\n\t\tconst json = super.toJSON(data);\n\t\tjson.isInstancedInterleavedBuffer = true;\n\t\tjson.meshPerAttribute = this.meshPerAttribute;\n\t\treturn json;\n\t}\n\n}\n\nclass GLBufferAttribute {\n\tconstructor(buffer, type, itemSize, elementSize, count) {\n\t\tthis.isGLBufferAttribute = true;\n\t\tthis.buffer = buffer;\n\t\tthis.type = type;\n\t\tthis.itemSize = itemSize;\n\t\tthis.elementSize = elementSize;\n\t\tthis.count = count;\n\t\tthis.version = 0;\n\t}\n\n\tset needsUpdate(value) {\n\t\tif (value === true) this.version++;\n\t}\n\n\tsetBuffer(buffer) {\n\t\tthis.buffer = buffer;\n\t\treturn this;\n\t}\n\n\tsetType(type, elementSize) {\n\t\tthis.type = type;\n\t\tthis.elementSize = elementSize;\n\t\treturn this;\n\t}\n\n\tsetItemSize(itemSize) {\n\t\tthis.itemSize = itemSize;\n\t\treturn this;\n\t}\n\n\tsetCount(count) {\n\t\tthis.count = count;\n\t\treturn this;\n\t}\n\n}\n\nclass Raycaster {\n\tconstructor(origin, direction, near = 0, far = Infinity) {\n\t\tthis.ray = new Ray(origin, direction); // direction is assumed to be normalized (for accurate distance calculations)\n\n\t\tthis.near = near;\n\t\tthis.far = far;\n\t\tthis.camera = null;\n\t\tthis.layers = new Layers();\n\t\tthis.params = {\n\t\t\tMesh: {},\n\t\t\tLine: {\n\t\t\t\tthreshold: 1\n\t\t\t},\n\t\t\tLOD: {},\n\t\t\tPoints: {\n\t\t\t\tthreshold: 1\n\t\t\t},\n\t\t\tSprite: {}\n\t\t};\n\t}\n\n\tset(origin, direction) {\n\t\t// direction is assumed to be normalized (for accurate distance calculations)\n\t\tthis.ray.set(origin, direction);\n\t}\n\n\tsetFromCamera(coords, camera) {\n\t\tif (camera.isPerspectiveCamera) {\n\t\t\tthis.ray.origin.setFromMatrixPosition(camera.matrixWorld);\n\t\t\tthis.ray.direction.set(coords.x, coords.y, 0.5).unproject(camera).sub(this.ray.origin).normalize();\n\t\t\tthis.camera = camera;\n\t\t} else if (camera.isOrthographicCamera) {\n\t\t\tthis.ray.origin.set(coords.x, coords.y, (camera.near + camera.far) / (camera.near - camera.far)).unproject(camera); // set origin in plane of camera\n\n\t\t\tthis.ray.direction.set(0, 0, -1).transformDirection(camera.matrixWorld);\n\t\t\tthis.camera = camera;\n\t\t} else {\n\t\t\tconsole.error('THREE.Raycaster: Unsupported camera type: ' + camera.type);\n\t\t}\n\t}\n\n\tintersectObject(object, recursive = true, intersects = []) {\n\t\tintersectObject(object, this, intersects, recursive);\n\t\tintersects.sort(ascSort);\n\t\treturn intersects;\n\t}\n\n\tintersectObjects(objects, recursive = true, intersects = []) {\n\t\tfor (let i = 0, l = objects.length; i < l; i++) {\n\t\t\tintersectObject(objects[i], this, intersects, recursive);\n\t\t}\n\n\t\tintersects.sort(ascSort);\n\t\treturn intersects;\n\t}\n\n}\n\nfunction ascSort(a, b) {\n\treturn a.distance - b.distance;\n}\n\nfunction intersectObject(object, raycaster, intersects, recursive) {\n\tif (object.layers.test(raycaster.layers)) {\n\t\tobject.raycast(raycaster, intersects);\n\t}\n\n\tif (recursive === true) {\n\t\tconst children = object.children;\n\n\t\tfor (let i = 0, l = children.length; i < l; i++) {\n\t\t\tintersectObject(children[i], raycaster, intersects, true);\n\t\t}\n\t}\n}\n\n/**\n * Ref: https://en.wikipedia.org/wiki/Spherical_coordinate_system\n *\n * The polar angle (phi) is measured from the positive y-axis. The positive y-axis is up.\n * The azimuthal angle (theta) is measured from the positive z-axis.\n */\n\nclass Spherical {\n\tconstructor(radius = 1, phi = 0, theta = 0) {\n\t\tthis.radius = radius;\n\t\tthis.phi = phi; // polar angle\n\n\t\tthis.theta = theta; // azimuthal angle\n\n\t\treturn this;\n\t}\n\n\tset(radius, phi, theta) {\n\t\tthis.radius = radius;\n\t\tthis.phi = phi;\n\t\tthis.theta = theta;\n\t\treturn this;\n\t}\n\n\tcopy(other) {\n\t\tthis.radius = other.radius;\n\t\tthis.phi = other.phi;\n\t\tthis.theta = other.theta;\n\t\treturn this;\n\t} // restrict phi to be between EPS and PI-EPS\n\n\n\tmakeSafe() {\n\t\tconst EPS = 0.000001;\n\t\tthis.phi = Math.max(EPS, Math.min(Math.PI - EPS, this.phi));\n\t\treturn this;\n\t}\n\n\tsetFromVector3(v) {\n\t\treturn this.setFromCartesianCoords(v.x, v.y, v.z);\n\t}\n\n\tsetFromCartesianCoords(x, y, z) {\n\t\tthis.radius = Math.sqrt(x * x + y * y + z * z);\n\n\t\tif (this.radius === 0) {\n\t\t\tthis.theta = 0;\n\t\t\tthis.phi = 0;\n\t\t} else {\n\t\t\tthis.theta = Math.atan2(x, z);\n\t\t\tthis.phi = Math.acos(clamp(y / this.radius, -1, 1));\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\treturn new this.constructor().copy(this);\n\t}\n\n}\n\n/**\n * Ref: https://en.wikipedia.org/wiki/Cylindrical_coordinate_system\n */\nclass Cylindrical {\n\tconstructor(radius = 1, theta = 0, y = 0) {\n\t\tthis.radius = radius; // distance from the origin to a point in the x-z plane\n\n\t\tthis.theta = theta; // counterclockwise angle in the x-z plane measured in radians from the positive z-axis\n\n\t\tthis.y = y; // height above the x-z plane\n\n\t\treturn this;\n\t}\n\n\tset(radius, theta, y) {\n\t\tthis.radius = radius;\n\t\tthis.theta = theta;\n\t\tthis.y = y;\n\t\treturn this;\n\t}\n\n\tcopy(other) {\n\t\tthis.radius = other.radius;\n\t\tthis.theta = other.theta;\n\t\tthis.y = other.y;\n\t\treturn this;\n\t}\n\n\tsetFromVector3(v) {\n\t\treturn this.setFromCartesianCoords(v.x, v.y, v.z);\n\t}\n\n\tsetFromCartesianCoords(x, y, z) {\n\t\tthis.radius = Math.sqrt(x * x + z * z);\n\t\tthis.theta = Math.atan2(x, z);\n\t\tthis.y = y;\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\treturn new this.constructor().copy(this);\n\t}\n\n}\n\nconst _vector$4 = /*@__PURE__*/new Vector2();\n\nclass Box2 {\n\tconstructor(min = new Vector2(+Infinity, +Infinity), max = new Vector2(-Infinity, -Infinity)) {\n\t\tthis.isBox2 = true;\n\t\tthis.min = min;\n\t\tthis.max = max;\n\t}\n\n\tset(min, max) {\n\t\tthis.min.copy(min);\n\t\tthis.max.copy(max);\n\t\treturn this;\n\t}\n\n\tsetFromPoints(points) {\n\t\tthis.makeEmpty();\n\n\t\tfor (let i = 0, il = points.length; i < il; i++) {\n\t\t\tthis.expandByPoint(points[i]);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tsetFromCenterAndSize(center, size) {\n\t\tconst halfSize = _vector$4.copy(size).multiplyScalar(0.5);\n\n\t\tthis.min.copy(center).sub(halfSize);\n\t\tthis.max.copy(center).add(halfSize);\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\treturn new this.constructor().copy(this);\n\t}\n\n\tcopy(box) {\n\t\tthis.min.copy(box.min);\n\t\tthis.max.copy(box.max);\n\t\treturn this;\n\t}\n\n\tmakeEmpty() {\n\t\tthis.min.x = this.min.y = +Infinity;\n\t\tthis.max.x = this.max.y = -Infinity;\n\t\treturn this;\n\t}\n\n\tisEmpty() {\n\t\t// this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes\n\t\treturn this.max.x < this.min.x || this.max.y < this.min.y;\n\t}\n\n\tgetCenter(target) {\n\t\treturn this.isEmpty() ? target.set(0, 0) : target.addVectors(this.min, this.max).multiplyScalar(0.5);\n\t}\n\n\tgetSize(target) {\n\t\treturn this.isEmpty() ? target.set(0, 0) : target.subVectors(this.max, this.min);\n\t}\n\n\texpandByPoint(point) {\n\t\tthis.min.min(point);\n\t\tthis.max.max(point);\n\t\treturn this;\n\t}\n\n\texpandByVector(vector) {\n\t\tthis.min.sub(vector);\n\t\tthis.max.add(vector);\n\t\treturn this;\n\t}\n\n\texpandByScalar(scalar) {\n\t\tthis.min.addScalar(-scalar);\n\t\tthis.max.addScalar(scalar);\n\t\treturn this;\n\t}\n\n\tcontainsPoint(point) {\n\t\treturn point.x < this.min.x || point.x > this.max.x || point.y < this.min.y || point.y > this.max.y ? false : true;\n\t}\n\n\tcontainsBox(box) {\n\t\treturn this.min.x <= box.min.x && box.max.x <= this.max.x && this.min.y <= box.min.y && box.max.y <= this.max.y;\n\t}\n\n\tgetParameter(point, target) {\n\t\t// This can potentially have a divide by zero if the box\n\t\t// has a size dimension of 0.\n\t\treturn target.set((point.x - this.min.x) / (this.max.x - this.min.x), (point.y - this.min.y) / (this.max.y - this.min.y));\n\t}\n\n\tintersectsBox(box) {\n\t\t// using 4 splitting planes to rule out intersections\n\t\treturn box.max.x < this.min.x || box.min.x > this.max.x || box.max.y < this.min.y || box.min.y > this.max.y ? false : true;\n\t}\n\n\tclampPoint(point, target) {\n\t\treturn target.copy(point).clamp(this.min, this.max);\n\t}\n\n\tdistanceToPoint(point) {\n\t\tconst clampedPoint = _vector$4.copy(point).clamp(this.min, this.max);\n\n\t\treturn clampedPoint.sub(point).length();\n\t}\n\n\tintersect(box) {\n\t\tthis.min.max(box.min);\n\t\tthis.max.min(box.max);\n\t\treturn this;\n\t}\n\n\tunion(box) {\n\t\tthis.min.min(box.min);\n\t\tthis.max.max(box.max);\n\t\treturn this;\n\t}\n\n\ttranslate(offset) {\n\t\tthis.min.add(offset);\n\t\tthis.max.add(offset);\n\t\treturn this;\n\t}\n\n\tequals(box) {\n\t\treturn box.min.equals(this.min) && box.max.equals(this.max);\n\t}\n\n}\n\nconst _startP = /*@__PURE__*/new Vector3();\n\nconst _startEnd = /*@__PURE__*/new Vector3();\n\nclass Line3 {\n\tconstructor(start = new Vector3(), end = new Vector3()) {\n\t\tthis.start = start;\n\t\tthis.end = end;\n\t}\n\n\tset(start, end) {\n\t\tthis.start.copy(start);\n\t\tthis.end.copy(end);\n\t\treturn this;\n\t}\n\n\tcopy(line) {\n\t\tthis.start.copy(line.start);\n\t\tthis.end.copy(line.end);\n\t\treturn this;\n\t}\n\n\tgetCenter(target) {\n\t\treturn target.addVectors(this.start, this.end).multiplyScalar(0.5);\n\t}\n\n\tdelta(target) {\n\t\treturn target.subVectors(this.end, this.start);\n\t}\n\n\tdistanceSq() {\n\t\treturn this.start.distanceToSquared(this.end);\n\t}\n\n\tdistance() {\n\t\treturn this.start.distanceTo(this.end);\n\t}\n\n\tat(t, target) {\n\t\treturn this.delta(target).multiplyScalar(t).add(this.start);\n\t}\n\n\tclosestPointToPointParameter(point, clampToLine) {\n\t\t_startP.subVectors(point, this.start);\n\n\t\t_startEnd.subVectors(this.end, this.start);\n\n\t\tconst startEnd2 = _startEnd.dot(_startEnd);\n\n\t\tconst startEnd_startP = _startEnd.dot(_startP);\n\n\t\tlet t = startEnd_startP / startEnd2;\n\n\t\tif (clampToLine) {\n\t\t\tt = clamp(t, 0, 1);\n\t\t}\n\n\t\treturn t;\n\t}\n\n\tclosestPointToPoint(point, clampToLine, target) {\n\t\tconst t = this.closestPointToPointParameter(point, clampToLine);\n\t\treturn this.delta(target).multiplyScalar(t).add(this.start);\n\t}\n\n\tapplyMatrix4(matrix) {\n\t\tthis.start.applyMatrix4(matrix);\n\t\tthis.end.applyMatrix4(matrix);\n\t\treturn this;\n\t}\n\n\tequals(line) {\n\t\treturn line.start.equals(this.start) && line.end.equals(this.end);\n\t}\n\n\tclone() {\n\t\treturn new this.constructor().copy(this);\n\t}\n\n}\n\nconst _vector$3 = /*@__PURE__*/new Vector3();\n\nclass SpotLightHelper extends Object3D {\n\tconstructor(light, color) {\n\t\tsuper();\n\t\tthis.light = light;\n\t\tthis.light.updateMatrixWorld();\n\t\tthis.matrix = light.matrixWorld;\n\t\tthis.matrixAutoUpdate = false;\n\t\tthis.color = color;\n\t\tconst geometry = new BufferGeometry();\n\t\tconst positions = [0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, -1, 1];\n\n\t\tfor (let i = 0, j = 1, l = 32; i < l; i++, j++) {\n\t\t\tconst p1 = i / l * Math.PI * 2;\n\t\t\tconst p2 = j / l * Math.PI * 2;\n\t\t\tpositions.push(Math.cos(p1), Math.sin(p1), 1, Math.cos(p2), Math.sin(p2), 1);\n\t\t}\n\n\t\tgeometry.setAttribute('position', new Float32BufferAttribute(positions, 3));\n\t\tconst material = new LineBasicMaterial({\n\t\t\tfog: false,\n\t\t\ttoneMapped: false\n\t\t});\n\t\tthis.cone = new LineSegments(geometry, material);\n\t\tthis.add(this.cone);\n\t\tthis.update();\n\t}\n\n\tdispose() {\n\t\tthis.cone.geometry.dispose();\n\t\tthis.cone.material.dispose();\n\t}\n\n\tupdate() {\n\t\tthis.light.updateMatrixWorld();\n\t\tconst coneLength = this.light.distance ? this.light.distance : 1000;\n\t\tconst coneWidth = coneLength * Math.tan(this.light.angle);\n\t\tthis.cone.scale.set(coneWidth, coneWidth, coneLength);\n\n\t\t_vector$3.setFromMatrixPosition(this.light.target.matrixWorld);\n\n\t\tthis.cone.lookAt(_vector$3);\n\n\t\tif (this.color !== undefined) {\n\t\t\tthis.cone.material.color.set(this.color);\n\t\t} else {\n\t\t\tthis.cone.material.color.copy(this.light.color);\n\t\t}\n\t}\n\n}\n\nconst _vector$2 = /*@__PURE__*/new Vector3();\n\nconst _boneMatrix = /*@__PURE__*/new Matrix4();\n\nconst _matrixWorldInv = /*@__PURE__*/new Matrix4();\n\nclass SkeletonHelper extends LineSegments {\n\tconstructor(object) {\n\t\tconst bones = getBoneList(object);\n\t\tconst geometry = new BufferGeometry();\n\t\tconst vertices = [];\n\t\tconst colors = [];\n\t\tconst color1 = new Color(0, 0, 1);\n\t\tconst color2 = new Color(0, 1, 0);\n\n\t\tfor (let i = 0; i < bones.length; i++) {\n\t\t\tconst bone = bones[i];\n\n\t\t\tif (bone.parent && bone.parent.isBone) {\n\t\t\t\tvertices.push(0, 0, 0);\n\t\t\t\tvertices.push(0, 0, 0);\n\t\t\t\tcolors.push(color1.r, color1.g, color1.b);\n\t\t\t\tcolors.push(color2.r, color2.g, color2.b);\n\t\t\t}\n\t\t}\n\n\t\tgeometry.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\tgeometry.setAttribute('color', new Float32BufferAttribute(colors, 3));\n\t\tconst material = new LineBasicMaterial({\n\t\t\tvertexColors: true,\n\t\t\tdepthTest: false,\n\t\t\tdepthWrite: false,\n\t\t\ttoneMapped: false,\n\t\t\ttransparent: true\n\t\t});\n\t\tsuper(geometry, material);\n\t\tthis.isSkeletonHelper = true;\n\t\tthis.type = 'SkeletonHelper';\n\t\tthis.root = object;\n\t\tthis.bones = bones;\n\t\tthis.matrix = object.matrixWorld;\n\t\tthis.matrixAutoUpdate = false;\n\t}\n\n\tupdateMatrixWorld(force) {\n\t\tconst bones = this.bones;\n\t\tconst geometry = this.geometry;\n\t\tconst position = geometry.getAttribute('position');\n\n\t\t_matrixWorldInv.copy(this.root.matrixWorld).invert();\n\n\t\tfor (let i = 0, j = 0; i < bones.length; i++) {\n\t\t\tconst bone = bones[i];\n\n\t\t\tif (bone.parent && bone.parent.isBone) {\n\t\t\t\t_boneMatrix.multiplyMatrices(_matrixWorldInv, bone.matrixWorld);\n\n\t\t\t\t_vector$2.setFromMatrixPosition(_boneMatrix);\n\n\t\t\t\tposition.setXYZ(j, _vector$2.x, _vector$2.y, _vector$2.z);\n\n\t\t\t\t_boneMatrix.multiplyMatrices(_matrixWorldInv, bone.parent.matrixWorld);\n\n\t\t\t\t_vector$2.setFromMatrixPosition(_boneMatrix);\n\n\t\t\t\tposition.setXYZ(j + 1, _vector$2.x, _vector$2.y, _vector$2.z);\n\t\t\t\tj += 2;\n\t\t\t}\n\t\t}\n\n\t\tgeometry.getAttribute('position').needsUpdate = true;\n\t\tsuper.updateMatrixWorld(force);\n\t}\n\n\tdispose() {\n\t\tthis.geometry.dispose();\n\t\tthis.material.dispose();\n\t}\n\n}\n\nfunction getBoneList(object) {\n\tconst boneList = [];\n\n\tif (object.isBone === true) {\n\t\tboneList.push(object);\n\t}\n\n\tfor (let i = 0; i < object.children.length; i++) {\n\t\tboneList.push.apply(boneList, getBoneList(object.children[i]));\n\t}\n\n\treturn boneList;\n}\n\nclass PointLightHelper extends Mesh {\n\tconstructor(light, sphereSize, color) {\n\t\tconst geometry = new SphereGeometry(sphereSize, 4, 2);\n\t\tconst material = new MeshBasicMaterial({\n\t\t\twireframe: true,\n\t\t\tfog: false,\n\t\t\ttoneMapped: false\n\t\t});\n\t\tsuper(geometry, material);\n\t\tthis.light = light;\n\t\tthis.light.updateMatrixWorld();\n\t\tthis.color = color;\n\t\tthis.type = 'PointLightHelper';\n\t\tthis.matrix = this.light.matrixWorld;\n\t\tthis.matrixAutoUpdate = false;\n\t\tthis.update();\n\t\t/*\n\t\t// TODO: delete this comment?\n\t\tconst distanceGeometry = new THREE.IcosahedronGeometry( 1, 2 );\n\t\tconst distanceMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false, wireframe: true, opacity: 0.1, transparent: true } );\n\t\tthis.lightSphere = new THREE.Mesh( bulbGeometry, bulbMaterial );\n\t\tthis.lightDistance = new THREE.Mesh( distanceGeometry, distanceMaterial );\n\t\tconst d = light.distance;\n\t\tif ( d === 0.0 ) {\n\t\t\tthis.lightDistance.visible = false;\n\t\t} else {\n\t\t\tthis.lightDistance.scale.set( d, d, d );\n\t\t}\n\t\tthis.add( this.lightDistance );\n\t\t*/\n\t}\n\n\tdispose() {\n\t\tthis.geometry.dispose();\n\t\tthis.material.dispose();\n\t}\n\n\tupdate() {\n\t\tif (this.color !== undefined) {\n\t\t\tthis.material.color.set(this.color);\n\t\t} else {\n\t\t\tthis.material.color.copy(this.light.color);\n\t\t}\n\t\t/*\n\t\tconst d = this.light.distance;\n\t\t\tif ( d === 0.0 ) {\n\t\t\t\tthis.lightDistance.visible = false;\n\t\t\t} else {\n\t\t\t\tthis.lightDistance.visible = true;\n\t\t\tthis.lightDistance.scale.set( d, d, d );\n\t\t\t}\n\t\t*/\n\n\t}\n\n}\n\nconst _vector$1 = /*@__PURE__*/new Vector3();\n\nconst _color1 = /*@__PURE__*/new Color();\n\nconst _color2 = /*@__PURE__*/new Color();\n\nclass HemisphereLightHelper extends Object3D {\n\tconstructor(light, size, color) {\n\t\tsuper();\n\t\tthis.light = light;\n\t\tthis.light.updateMatrixWorld();\n\t\tthis.matrix = light.matrixWorld;\n\t\tthis.matrixAutoUpdate = false;\n\t\tthis.color = color;\n\t\tconst geometry = new OctahedronGeometry(size);\n\t\tgeometry.rotateY(Math.PI * 0.5);\n\t\tthis.material = new MeshBasicMaterial({\n\t\t\twireframe: true,\n\t\t\tfog: false,\n\t\t\ttoneMapped: false\n\t\t});\n\t\tif (this.color === undefined) this.material.vertexColors = true;\n\t\tconst position = geometry.getAttribute('position');\n\t\tconst colors = new Float32Array(position.count * 3);\n\t\tgeometry.setAttribute('color', new BufferAttribute(colors, 3));\n\t\tthis.add(new Mesh(geometry, this.material));\n\t\tthis.update();\n\t}\n\n\tdispose() {\n\t\tthis.children[0].geometry.dispose();\n\t\tthis.children[0].material.dispose();\n\t}\n\n\tupdate() {\n\t\tconst mesh = this.children[0];\n\n\t\tif (this.color !== undefined) {\n\t\t\tthis.material.color.set(this.color);\n\t\t} else {\n\t\t\tconst colors = mesh.geometry.getAttribute('color');\n\n\t\t\t_color1.copy(this.light.color);\n\n\t\t\t_color2.copy(this.light.groundColor);\n\n\t\t\tfor (let i = 0, l = colors.count; i < l; i++) {\n\t\t\t\tconst color = i < l / 2 ? _color1 : _color2;\n\t\t\t\tcolors.setXYZ(i, color.r, color.g, color.b);\n\t\t\t}\n\n\t\t\tcolors.needsUpdate = true;\n\t\t}\n\n\t\tmesh.lookAt(_vector$1.setFromMatrixPosition(this.light.matrixWorld).negate());\n\t}\n\n}\n\nclass GridHelper extends LineSegments {\n\tconstructor(size = 10, divisions = 10, color1 = 0x444444, color2 = 0x888888) {\n\t\tcolor1 = new Color(color1);\n\t\tcolor2 = new Color(color2);\n\t\tconst center = divisions / 2;\n\t\tconst step = size / divisions;\n\t\tconst halfSize = size / 2;\n\t\tconst vertices = [],\n\t\t\t\t\tcolors = [];\n\n\t\tfor (let i = 0, j = 0, k = -halfSize; i <= divisions; i++, k += step) {\n\t\t\tvertices.push(-halfSize, 0, k, halfSize, 0, k);\n\t\t\tvertices.push(k, 0, -halfSize, k, 0, halfSize);\n\t\t\tconst color = i === center ? color1 : color2;\n\t\t\tcolor.toArray(colors, j);\n\t\t\tj += 3;\n\t\t\tcolor.toArray(colors, j);\n\t\t\tj += 3;\n\t\t\tcolor.toArray(colors, j);\n\t\t\tj += 3;\n\t\t\tcolor.toArray(colors, j);\n\t\t\tj += 3;\n\t\t}\n\n\t\tconst geometry = new BufferGeometry();\n\t\tgeometry.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\tgeometry.setAttribute('color', new Float32BufferAttribute(colors, 3));\n\t\tconst material = new LineBasicMaterial({\n\t\t\tvertexColors: true,\n\t\t\ttoneMapped: false\n\t\t});\n\t\tsuper(geometry, material);\n\t\tthis.type = 'GridHelper';\n\t}\n\n\tdispose() {\n\t\tthis.geometry.dispose();\n\t\tthis.material.dispose();\n\t}\n\n}\n\nclass PolarGridHelper extends LineSegments {\n\tconstructor(radius = 10, sectors = 16, rings = 8, divisions = 64, color1 = 0x444444, color2 = 0x888888) {\n\t\tcolor1 = new Color(color1);\n\t\tcolor2 = new Color(color2);\n\t\tconst vertices = [];\n\t\tconst colors = []; // create the sectors\n\n\t\tif (sectors > 1) {\n\t\t\tfor (let i = 0; i < sectors; i++) {\n\t\t\t\tconst v = i / sectors * (Math.PI * 2);\n\t\t\t\tconst x = Math.sin(v) * radius;\n\t\t\t\tconst z = Math.cos(v) * radius;\n\t\t\t\tvertices.push(0, 0, 0);\n\t\t\t\tvertices.push(x, 0, z);\n\t\t\t\tconst color = i & 1 ? color1 : color2;\n\t\t\t\tcolors.push(color.r, color.g, color.b);\n\t\t\t\tcolors.push(color.r, color.g, color.b);\n\t\t\t}\n\t\t} // create the rings\n\n\n\t\tfor (let i = 0; i < rings; i++) {\n\t\t\tconst color = i & 1 ? color1 : color2;\n\t\t\tconst r = radius - radius / rings * i;\n\n\t\t\tfor (let j = 0; j < divisions; j++) {\n\t\t\t\t// first vertex\n\t\t\t\tlet v = j / divisions * (Math.PI * 2);\n\t\t\t\tlet x = Math.sin(v) * r;\n\t\t\t\tlet z = Math.cos(v) * r;\n\t\t\t\tvertices.push(x, 0, z);\n\t\t\t\tcolors.push(color.r, color.g, color.b); // second vertex\n\n\t\t\t\tv = (j + 1) / divisions * (Math.PI * 2);\n\t\t\t\tx = Math.sin(v) * r;\n\t\t\t\tz = Math.cos(v) * r;\n\t\t\t\tvertices.push(x, 0, z);\n\t\t\t\tcolors.push(color.r, color.g, color.b);\n\t\t\t}\n\t\t}\n\n\t\tconst geometry = new BufferGeometry();\n\t\tgeometry.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\tgeometry.setAttribute('color', new Float32BufferAttribute(colors, 3));\n\t\tconst material = new LineBasicMaterial({\n\t\t\tvertexColors: true,\n\t\t\ttoneMapped: false\n\t\t});\n\t\tsuper(geometry, material);\n\t\tthis.type = 'PolarGridHelper';\n\t}\n\n\tdispose() {\n\t\tthis.geometry.dispose();\n\t\tthis.material.dispose();\n\t}\n\n}\n\nconst _v1 = /*@__PURE__*/new Vector3();\n\nconst _v2 = /*@__PURE__*/new Vector3();\n\nconst _v3 = /*@__PURE__*/new Vector3();\n\nclass DirectionalLightHelper extends Object3D {\n\tconstructor(light, size, color) {\n\t\tsuper();\n\t\tthis.light = light;\n\t\tthis.light.updateMatrixWorld();\n\t\tthis.matrix = light.matrixWorld;\n\t\tthis.matrixAutoUpdate = false;\n\t\tthis.color = color;\n\t\tif (size === undefined) size = 1;\n\t\tlet geometry = new BufferGeometry();\n\t\tgeometry.setAttribute('position', new Float32BufferAttribute([-size, size, 0, size, size, 0, size, -size, 0, -size, -size, 0, -size, size, 0], 3));\n\t\tconst material = new LineBasicMaterial({\n\t\t\tfog: false,\n\t\t\ttoneMapped: false\n\t\t});\n\t\tthis.lightPlane = new Line(geometry, material);\n\t\tthis.add(this.lightPlane);\n\t\tgeometry = new BufferGeometry();\n\t\tgeometry.setAttribute('position', new Float32BufferAttribute([0, 0, 0, 0, 0, 1], 3));\n\t\tthis.targetLine = new Line(geometry, material);\n\t\tthis.add(this.targetLine);\n\t\tthis.update();\n\t}\n\n\tdispose() {\n\t\tthis.lightPlane.geometry.dispose();\n\t\tthis.lightPlane.material.dispose();\n\t\tthis.targetLine.geometry.dispose();\n\t\tthis.targetLine.material.dispose();\n\t}\n\n\tupdate() {\n\t\t_v1.setFromMatrixPosition(this.light.matrixWorld);\n\n\t\t_v2.setFromMatrixPosition(this.light.target.matrixWorld);\n\n\t\t_v3.subVectors(_v2, _v1);\n\n\t\tthis.lightPlane.lookAt(_v2);\n\n\t\tif (this.color !== undefined) {\n\t\t\tthis.lightPlane.material.color.set(this.color);\n\t\t\tthis.targetLine.material.color.set(this.color);\n\t\t} else {\n\t\t\tthis.lightPlane.material.color.copy(this.light.color);\n\t\t\tthis.targetLine.material.color.copy(this.light.color);\n\t\t}\n\n\t\tthis.targetLine.lookAt(_v2);\n\t\tthis.targetLine.scale.z = _v3.length();\n\t}\n\n}\n\nconst _vector = /*@__PURE__*/new Vector3();\n\nconst _camera = /*@__PURE__*/new Camera();\n/**\n *\t- shows frustum, line of sight and up of the camera\n *\t- suitable for fast updates\n * \t- based on frustum visualization in lightgl.js shadowmap example\n *\t\thttps://github.com/evanw/lightgl.js/blob/master/tests/shadowmap.html\n */\n\n\nclass CameraHelper extends LineSegments {\n\tconstructor(camera) {\n\t\tconst geometry = new BufferGeometry();\n\t\tconst material = new LineBasicMaterial({\n\t\t\tcolor: 0xffffff,\n\t\t\tvertexColors: true,\n\t\t\ttoneMapped: false\n\t\t});\n\t\tconst vertices = [];\n\t\tconst colors = [];\n\t\tconst pointMap = {}; // near\n\n\t\taddLine('n1', 'n2');\n\t\taddLine('n2', 'n4');\n\t\taddLine('n4', 'n3');\n\t\taddLine('n3', 'n1'); // far\n\n\t\taddLine('f1', 'f2');\n\t\taddLine('f2', 'f4');\n\t\taddLine('f4', 'f3');\n\t\taddLine('f3', 'f1'); // sides\n\n\t\taddLine('n1', 'f1');\n\t\taddLine('n2', 'f2');\n\t\taddLine('n3', 'f3');\n\t\taddLine('n4', 'f4'); // cone\n\n\t\taddLine('p', 'n1');\n\t\taddLine('p', 'n2');\n\t\taddLine('p', 'n3');\n\t\taddLine('p', 'n4'); // up\n\n\t\taddLine('u1', 'u2');\n\t\taddLine('u2', 'u3');\n\t\taddLine('u3', 'u1'); // target\n\n\t\taddLine('c', 't');\n\t\taddLine('p', 'c'); // cross\n\n\t\taddLine('cn1', 'cn2');\n\t\taddLine('cn3', 'cn4');\n\t\taddLine('cf1', 'cf2');\n\t\taddLine('cf3', 'cf4');\n\n\t\tfunction addLine(a, b) {\n\t\t\taddPoint(a);\n\t\t\taddPoint(b);\n\t\t}\n\n\t\tfunction addPoint(id) {\n\t\t\tvertices.push(0, 0, 0);\n\t\t\tcolors.push(0, 0, 0);\n\n\t\t\tif (pointMap[id] === undefined) {\n\t\t\t\tpointMap[id] = [];\n\t\t\t}\n\n\t\t\tpointMap[id].push(vertices.length / 3 - 1);\n\t\t}\n\n\t\tgeometry.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\tgeometry.setAttribute('color', new Float32BufferAttribute(colors, 3));\n\t\tsuper(geometry, material);\n\t\tthis.type = 'CameraHelper';\n\t\tthis.camera = camera;\n\t\tif (this.camera.updateProjectionMatrix) this.camera.updateProjectionMatrix();\n\t\tthis.matrix = camera.matrixWorld;\n\t\tthis.matrixAutoUpdate = false;\n\t\tthis.pointMap = pointMap;\n\t\tthis.update(); // colors\n\n\t\tconst colorFrustum = new Color(0xffaa00);\n\t\tconst colorCone = new Color(0xff0000);\n\t\tconst colorUp = new Color(0x00aaff);\n\t\tconst colorTarget = new Color(0xffffff);\n\t\tconst colorCross = new Color(0x333333);\n\t\tthis.setColors(colorFrustum, colorCone, colorUp, colorTarget, colorCross);\n\t}\n\n\tsetColors(frustum, cone, up, target, cross) {\n\t\tconst geometry = this.geometry;\n\t\tconst colorAttribute = geometry.getAttribute('color'); // near\n\n\t\tcolorAttribute.setXYZ(0, frustum.r, frustum.g, frustum.b);\n\t\tcolorAttribute.setXYZ(1, frustum.r, frustum.g, frustum.b); // n1, n2\n\n\t\tcolorAttribute.setXYZ(2, frustum.r, frustum.g, frustum.b);\n\t\tcolorAttribute.setXYZ(3, frustum.r, frustum.g, frustum.b); // n2, n4\n\n\t\tcolorAttribute.setXYZ(4, frustum.r, frustum.g, frustum.b);\n\t\tcolorAttribute.setXYZ(5, frustum.r, frustum.g, frustum.b); // n4, n3\n\n\t\tcolorAttribute.setXYZ(6, frustum.r, frustum.g, frustum.b);\n\t\tcolorAttribute.setXYZ(7, frustum.r, frustum.g, frustum.b); // n3, n1\n\t\t// far\n\n\t\tcolorAttribute.setXYZ(8, frustum.r, frustum.g, frustum.b);\n\t\tcolorAttribute.setXYZ(9, frustum.r, frustum.g, frustum.b); // f1, f2\n\n\t\tcolorAttribute.setXYZ(10, frustum.r, frustum.g, frustum.b);\n\t\tcolorAttribute.setXYZ(11, frustum.r, frustum.g, frustum.b); // f2, f4\n\n\t\tcolorAttribute.setXYZ(12, frustum.r, frustum.g, frustum.b);\n\t\tcolorAttribute.setXYZ(13, frustum.r, frustum.g, frustum.b); // f4, f3\n\n\t\tcolorAttribute.setXYZ(14, frustum.r, frustum.g, frustum.b);\n\t\tcolorAttribute.setXYZ(15, frustum.r, frustum.g, frustum.b); // f3, f1\n\t\t// sides\n\n\t\tcolorAttribute.setXYZ(16, frustum.r, frustum.g, frustum.b);\n\t\tcolorAttribute.setXYZ(17, frustum.r, frustum.g, frustum.b); // n1, f1\n\n\t\tcolorAttribute.setXYZ(18, frustum.r, frustum.g, frustum.b);\n\t\tcolorAttribute.setXYZ(19, frustum.r, frustum.g, frustum.b); // n2, f2\n\n\t\tcolorAttribute.setXYZ(20, frustum.r, frustum.g, frustum.b);\n\t\tcolorAttribute.setXYZ(21, frustum.r, frustum.g, frustum.b); // n3, f3\n\n\t\tcolorAttribute.setXYZ(22, frustum.r, frustum.g, frustum.b);\n\t\tcolorAttribute.setXYZ(23, frustum.r, frustum.g, frustum.b); // n4, f4\n\t\t// cone\n\n\t\tcolorAttribute.setXYZ(24, cone.r, cone.g, cone.b);\n\t\tcolorAttribute.setXYZ(25, cone.r, cone.g, cone.b); // p, n1\n\n\t\tcolorAttribute.setXYZ(26, cone.r, cone.g, cone.b);\n\t\tcolorAttribute.setXYZ(27, cone.r, cone.g, cone.b); // p, n2\n\n\t\tcolorAttribute.setXYZ(28, cone.r, cone.g, cone.b);\n\t\tcolorAttribute.setXYZ(29, cone.r, cone.g, cone.b); // p, n3\n\n\t\tcolorAttribute.setXYZ(30, cone.r, cone.g, cone.b);\n\t\tcolorAttribute.setXYZ(31, cone.r, cone.g, cone.b); // p, n4\n\t\t// up\n\n\t\tcolorAttribute.setXYZ(32, up.r, up.g, up.b);\n\t\tcolorAttribute.setXYZ(33, up.r, up.g, up.b); // u1, u2\n\n\t\tcolorAttribute.setXYZ(34, up.r, up.g, up.b);\n\t\tcolorAttribute.setXYZ(35, up.r, up.g, up.b); // u2, u3\n\n\t\tcolorAttribute.setXYZ(36, up.r, up.g, up.b);\n\t\tcolorAttribute.setXYZ(37, up.r, up.g, up.b); // u3, u1\n\t\t// target\n\n\t\tcolorAttribute.setXYZ(38, target.r, target.g, target.b);\n\t\tcolorAttribute.setXYZ(39, target.r, target.g, target.b); // c, t\n\n\t\tcolorAttribute.setXYZ(40, cross.r, cross.g, cross.b);\n\t\tcolorAttribute.setXYZ(41, cross.r, cross.g, cross.b); // p, c\n\t\t// cross\n\n\t\tcolorAttribute.setXYZ(42, cross.r, cross.g, cross.b);\n\t\tcolorAttribute.setXYZ(43, cross.r, cross.g, cross.b); // cn1, cn2\n\n\t\tcolorAttribute.setXYZ(44, cross.r, cross.g, cross.b);\n\t\tcolorAttribute.setXYZ(45, cross.r, cross.g, cross.b); // cn3, cn4\n\n\t\tcolorAttribute.setXYZ(46, cross.r, cross.g, cross.b);\n\t\tcolorAttribute.setXYZ(47, cross.r, cross.g, cross.b); // cf1, cf2\n\n\t\tcolorAttribute.setXYZ(48, cross.r, cross.g, cross.b);\n\t\tcolorAttribute.setXYZ(49, cross.r, cross.g, cross.b); // cf3, cf4\n\n\t\tcolorAttribute.needsUpdate = true;\n\t}\n\n\tupdate() {\n\t\tconst geometry = this.geometry;\n\t\tconst pointMap = this.pointMap;\n\t\tconst w = 1,\n\t\t\t\t\th = 1; // we need just camera projection matrix inverse\n\t\t// world matrix must be identity\n\n\t\t_camera.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse); // center / target\n\n\n\t\tsetPoint('c', pointMap, geometry, _camera, 0, 0, -1);\n\t\tsetPoint('t', pointMap, geometry, _camera, 0, 0, 1); // near\n\n\t\tsetPoint('n1', pointMap, geometry, _camera, -w, -h, -1);\n\t\tsetPoint('n2', pointMap, geometry, _camera, w, -h, -1);\n\t\tsetPoint('n3', pointMap, geometry, _camera, -w, h, -1);\n\t\tsetPoint('n4', pointMap, geometry, _camera, w, h, -1); // far\n\n\t\tsetPoint('f1', pointMap, geometry, _camera, -w, -h, 1);\n\t\tsetPoint('f2', pointMap, geometry, _camera, w, -h, 1);\n\t\tsetPoint('f3', pointMap, geometry, _camera, -w, h, 1);\n\t\tsetPoint('f4', pointMap, geometry, _camera, w, h, 1); // up\n\n\t\tsetPoint('u1', pointMap, geometry, _camera, w * 0.7, h * 1.1, -1);\n\t\tsetPoint('u2', pointMap, geometry, _camera, -w * 0.7, h * 1.1, -1);\n\t\tsetPoint('u3', pointMap, geometry, _camera, 0, h * 2, -1); // cross\n\n\t\tsetPoint('cf1', pointMap, geometry, _camera, -w, 0, 1);\n\t\tsetPoint('cf2', pointMap, geometry, _camera, w, 0, 1);\n\t\tsetPoint('cf3', pointMap, geometry, _camera, 0, -h, 1);\n\t\tsetPoint('cf4', pointMap, geometry, _camera, 0, h, 1);\n\t\tsetPoint('cn1', pointMap, geometry, _camera, -w, 0, -1);\n\t\tsetPoint('cn2', pointMap, geometry, _camera, w, 0, -1);\n\t\tsetPoint('cn3', pointMap, geometry, _camera, 0, -h, -1);\n\t\tsetPoint('cn4', pointMap, geometry, _camera, 0, h, -1);\n\t\tgeometry.getAttribute('position').needsUpdate = true;\n\t}\n\n\tdispose() {\n\t\tthis.geometry.dispose();\n\t\tthis.material.dispose();\n\t}\n\n}\n\nfunction setPoint(point, pointMap, geometry, camera, x, y, z) {\n\t_vector.set(x, y, z).unproject(camera);\n\n\tconst points = pointMap[point];\n\n\tif (points !== undefined) {\n\t\tconst position = geometry.getAttribute('position');\n\n\t\tfor (let i = 0, l = points.length; i < l; i++) {\n\t\t\tposition.setXYZ(points[i], _vector.x, _vector.y, _vector.z);\n\t\t}\n\t}\n}\n\nconst _box = /*@__PURE__*/new Box3();\n\nclass BoxHelper extends LineSegments {\n\tconstructor(object, color = 0xffff00) {\n\t\tconst indices = new Uint16Array([0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7]);\n\t\tconst positions = new Float32Array(8 * 3);\n\t\tconst geometry = new BufferGeometry();\n\t\tgeometry.setIndex(new BufferAttribute(indices, 1));\n\t\tgeometry.setAttribute('position', new BufferAttribute(positions, 3));\n\t\tsuper(geometry, new LineBasicMaterial({\n\t\t\tcolor: color,\n\t\t\ttoneMapped: false\n\t\t}));\n\t\tthis.object = object;\n\t\tthis.type = 'BoxHelper';\n\t\tthis.matrixAutoUpdate = false;\n\t\tthis.update();\n\t}\n\n\tupdate(object) {\n\t\tif (object !== undefined) {\n\t\t\tconsole.warn('THREE.BoxHelper: .update() has no longer arguments.');\n\t\t}\n\n\t\tif (this.object !== undefined) {\n\t\t\t_box.setFromObject(this.object);\n\t\t}\n\n\t\tif (_box.isEmpty()) return;\n\t\tconst min = _box.min;\n\t\tconst max = _box.max;\n\t\t/*\n\t\t\t5____4\n\t\t1/___0/|\n\t\t| 6__|_7\n\t\t2/___3/\n\t\t\t0: max.x, max.y, max.z\n\t\t1: min.x, max.y, max.z\n\t\t2: min.x, min.y, max.z\n\t\t3: max.x, min.y, max.z\n\t\t4: max.x, max.y, min.z\n\t\t5: min.x, max.y, min.z\n\t\t6: min.x, min.y, min.z\n\t\t7: max.x, min.y, min.z\n\t\t*/\n\n\t\tconst position = this.geometry.attributes.position;\n\t\tconst array = position.array;\n\t\tarray[0] = max.x;\n\t\tarray[1] = max.y;\n\t\tarray[2] = max.z;\n\t\tarray[3] = min.x;\n\t\tarray[4] = max.y;\n\t\tarray[5] = max.z;\n\t\tarray[6] = min.x;\n\t\tarray[7] = min.y;\n\t\tarray[8] = max.z;\n\t\tarray[9] = max.x;\n\t\tarray[10] = min.y;\n\t\tarray[11] = max.z;\n\t\tarray[12] = max.x;\n\t\tarray[13] = max.y;\n\t\tarray[14] = min.z;\n\t\tarray[15] = min.x;\n\t\tarray[16] = max.y;\n\t\tarray[17] = min.z;\n\t\tarray[18] = min.x;\n\t\tarray[19] = min.y;\n\t\tarray[20] = min.z;\n\t\tarray[21] = max.x;\n\t\tarray[22] = min.y;\n\t\tarray[23] = min.z;\n\t\tposition.needsUpdate = true;\n\t\tthis.geometry.computeBoundingSphere();\n\t}\n\n\tsetFromObject(object) {\n\t\tthis.object = object;\n\t\tthis.update();\n\t\treturn this;\n\t}\n\n\tcopy(source, recursive) {\n\t\tsuper.copy(source, recursive);\n\t\tthis.object = source.object;\n\t\treturn this;\n\t}\n\n\tdispose() {\n\t\tthis.geometry.dispose();\n\t\tthis.material.dispose();\n\t}\n\n}\n\nclass Box3Helper extends LineSegments {\n\tconstructor(box, color = 0xffff00) {\n\t\tconst indices = new Uint16Array([0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7]);\n\t\tconst positions = [1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1];\n\t\tconst geometry = new BufferGeometry();\n\t\tgeometry.setIndex(new BufferAttribute(indices, 1));\n\t\tgeometry.setAttribute('position', new Float32BufferAttribute(positions, 3));\n\t\tsuper(geometry, new LineBasicMaterial({\n\t\t\tcolor: color,\n\t\t\ttoneMapped: false\n\t\t}));\n\t\tthis.box = box;\n\t\tthis.type = 'Box3Helper';\n\t\tthis.geometry.computeBoundingSphere();\n\t}\n\n\tupdateMatrixWorld(force) {\n\t\tconst box = this.box;\n\t\tif (box.isEmpty()) return;\n\t\tbox.getCenter(this.position);\n\t\tbox.getSize(this.scale);\n\t\tthis.scale.multiplyScalar(0.5);\n\t\tsuper.updateMatrixWorld(force);\n\t}\n\n\tdispose() {\n\t\tthis.geometry.dispose();\n\t\tthis.material.dispose();\n\t}\n\n}\n\nclass PlaneHelper extends Line {\n\tconstructor(plane, size = 1, hex = 0xffff00) {\n\t\tconst color = hex;\n\t\tconst positions = [1, -1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0];\n\t\tconst geometry = new BufferGeometry();\n\t\tgeometry.setAttribute('position', new Float32BufferAttribute(positions, 3));\n\t\tgeometry.computeBoundingSphere();\n\t\tsuper(geometry, new LineBasicMaterial({\n\t\t\tcolor: color,\n\t\t\ttoneMapped: false\n\t\t}));\n\t\tthis.type = 'PlaneHelper';\n\t\tthis.plane = plane;\n\t\tthis.size = size;\n\t\tconst positions2 = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0];\n\t\tconst geometry2 = new BufferGeometry();\n\t\tgeometry2.setAttribute('position', new Float32BufferAttribute(positions2, 3));\n\t\tgeometry2.computeBoundingSphere();\n\t\tthis.add(new Mesh(geometry2, new MeshBasicMaterial({\n\t\t\tcolor: color,\n\t\t\topacity: 0.2,\n\t\t\ttransparent: true,\n\t\t\tdepthWrite: false,\n\t\t\ttoneMapped: false\n\t\t})));\n\t}\n\n\tupdateMatrixWorld(force) {\n\t\tthis.position.set(0, 0, 0);\n\t\tthis.scale.set(0.5 * this.size, 0.5 * this.size, 1);\n\t\tthis.lookAt(this.plane.normal);\n\t\tthis.translateZ(-this.plane.constant);\n\t\tsuper.updateMatrixWorld(force);\n\t}\n\n\tdispose() {\n\t\tthis.geometry.dispose();\n\t\tthis.material.dispose();\n\t\tthis.children[0].geometry.dispose();\n\t\tthis.children[0].material.dispose();\n\t}\n\n}\n\nconst _axis = /*@__PURE__*/new Vector3();\n\nlet _lineGeometry, _coneGeometry;\n\nclass ArrowHelper extends Object3D {\n\t// dir is assumed to be normalized\n\tconstructor(dir = new Vector3(0, 0, 1), origin = new Vector3(0, 0, 0), length = 1, color = 0xffff00, headLength = length * 0.2, headWidth = headLength * 0.2) {\n\t\tsuper();\n\t\tthis.type = 'ArrowHelper';\n\n\t\tif (_lineGeometry === undefined) {\n\t\t\t_lineGeometry = new BufferGeometry();\n\n\t\t\t_lineGeometry.setAttribute('position', new Float32BufferAttribute([0, 0, 0, 0, 1, 0], 3));\n\n\t\t\t_coneGeometry = new CylinderGeometry(0, 0.5, 1, 5, 1);\n\n\t\t\t_coneGeometry.translate(0, -0.5, 0);\n\t\t}\n\n\t\tthis.position.copy(origin);\n\t\tthis.line = new Line(_lineGeometry, new LineBasicMaterial({\n\t\t\tcolor: color,\n\t\t\ttoneMapped: false\n\t\t}));\n\t\tthis.line.matrixAutoUpdate = false;\n\t\tthis.add(this.line);\n\t\tthis.cone = new Mesh(_coneGeometry, new MeshBasicMaterial({\n\t\t\tcolor: color,\n\t\t\ttoneMapped: false\n\t\t}));\n\t\tthis.cone.matrixAutoUpdate = false;\n\t\tthis.add(this.cone);\n\t\tthis.setDirection(dir);\n\t\tthis.setLength(length, headLength, headWidth);\n\t}\n\n\tsetDirection(dir) {\n\t\t// dir is assumed to be normalized\n\t\tif (dir.y > 0.99999) {\n\t\t\tthis.quaternion.set(0, 0, 0, 1);\n\t\t} else if (dir.y < -0.99999) {\n\t\t\tthis.quaternion.set(1, 0, 0, 0);\n\t\t} else {\n\t\t\t_axis.set(dir.z, 0, -dir.x).normalize();\n\n\t\t\tconst radians = Math.acos(dir.y);\n\t\t\tthis.quaternion.setFromAxisAngle(_axis, radians);\n\t\t}\n\t}\n\n\tsetLength(length, headLength = length * 0.2, headWidth = headLength * 0.2) {\n\t\tthis.line.scale.set(1, Math.max(0.0001, length - headLength), 1); // see #17458\n\n\t\tthis.line.updateMatrix();\n\t\tthis.cone.scale.set(headWidth, headLength, headWidth);\n\t\tthis.cone.position.y = length;\n\t\tthis.cone.updateMatrix();\n\t}\n\n\tsetColor(color) {\n\t\tthis.line.material.color.set(color);\n\t\tthis.cone.material.color.set(color);\n\t}\n\n\tcopy(source) {\n\t\tsuper.copy(source, false);\n\t\tthis.line.copy(source.line);\n\t\tthis.cone.copy(source.cone);\n\t\treturn this;\n\t}\n\n\tdispose() {\n\t\tthis.line.geometry.dispose();\n\t\tthis.line.material.dispose();\n\t\tthis.cone.geometry.dispose();\n\t\tthis.cone.material.dispose();\n\t}\n\n}\n\nclass AxesHelper extends LineSegments {\n\tconstructor(size = 1) {\n\t\tconst vertices = [0, 0, 0, size, 0, 0, 0, 0, 0, 0, size, 0, 0, 0, 0, 0, 0, size];\n\t\tconst colors = [1, 0, 0, 1, 0.6, 0, 0, 1, 0, 0.6, 1, 0, 0, 0, 1, 0, 0.6, 1];\n\t\tconst geometry = new BufferGeometry();\n\t\tgeometry.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\tgeometry.setAttribute('color', new Float32BufferAttribute(colors, 3));\n\t\tconst material = new LineBasicMaterial({\n\t\t\tvertexColors: true,\n\t\t\ttoneMapped: false\n\t\t});\n\t\tsuper(geometry, material);\n\t\tthis.type = 'AxesHelper';\n\t}\n\n\tsetColors(xAxisColor, yAxisColor, zAxisColor) {\n\t\tconst color = new Color();\n\t\tconst array = this.geometry.attributes.color.array;\n\t\tcolor.set(xAxisColor);\n\t\tcolor.toArray(array, 0);\n\t\tcolor.toArray(array, 3);\n\t\tcolor.set(yAxisColor);\n\t\tcolor.toArray(array, 6);\n\t\tcolor.toArray(array, 9);\n\t\tcolor.set(zAxisColor);\n\t\tcolor.toArray(array, 12);\n\t\tcolor.toArray(array, 15);\n\t\tthis.geometry.attributes.color.needsUpdate = true;\n\t\treturn this;\n\t}\n\n\tdispose() {\n\t\tthis.geometry.dispose();\n\t\tthis.material.dispose();\n\t}\n\n}\n\nclass ShapePath {\n\tconstructor() {\n\t\tthis.type = 'ShapePath';\n\t\tthis.color = new Color();\n\t\tthis.subPaths = [];\n\t\tthis.currentPath = null;\n\t}\n\n\tmoveTo(x, y) {\n\t\tthis.currentPath = new Path();\n\t\tthis.subPaths.push(this.currentPath);\n\t\tthis.currentPath.moveTo(x, y);\n\t\treturn this;\n\t}\n\n\tlineTo(x, y) {\n\t\tthis.currentPath.lineTo(x, y);\n\t\treturn this;\n\t}\n\n\tquadraticCurveTo(aCPx, aCPy, aX, aY) {\n\t\tthis.currentPath.quadraticCurveTo(aCPx, aCPy, aX, aY);\n\t\treturn this;\n\t}\n\n\tbezierCurveTo(aCP1x, aCP1y, aCP2x, aCP2y, aX, aY) {\n\t\tthis.currentPath.bezierCurveTo(aCP1x, aCP1y, aCP2x, aCP2y, aX, aY);\n\t\treturn this;\n\t}\n\n\tsplineThru(pts) {\n\t\tthis.currentPath.splineThru(pts);\n\t\treturn this;\n\t}\n\n\ttoShapes(isCCW) {\n\t\tfunction toShapesNoHoles(inSubpaths) {\n\t\t\tconst shapes = [];\n\n\t\t\tfor (let i = 0, l = inSubpaths.length; i < l; i++) {\n\t\t\t\tconst tmpPath = inSubpaths[i];\n\t\t\t\tconst tmpShape = new Shape();\n\t\t\t\ttmpShape.curves = tmpPath.curves;\n\t\t\t\tshapes.push(tmpShape);\n\t\t\t}\n\n\t\t\treturn shapes;\n\t\t}\n\n\t\tfunction isPointInsidePolygon(inPt, inPolygon) {\n\t\t\tconst polyLen = inPolygon.length; // inPt on polygon contour => immediate success\t\tor\n\t\t\t// toggling of inside/outside at every single! intersection point of an edge\n\t\t\t//\twith the horizontal line through inPt, left of inPt\n\t\t\t//\tnot counting lowerY endpoints of edges and whole edges on that line\n\n\t\t\tlet inside = false;\n\n\t\t\tfor (let p = polyLen - 1, q = 0; q < polyLen; p = q++) {\n\t\t\t\tlet edgeLowPt = inPolygon[p];\n\t\t\t\tlet edgeHighPt = inPolygon[q];\n\t\t\t\tlet edgeDx = edgeHighPt.x - edgeLowPt.x;\n\t\t\t\tlet edgeDy = edgeHighPt.y - edgeLowPt.y;\n\n\t\t\t\tif (Math.abs(edgeDy) > Number.EPSILON) {\n\t\t\t\t\t// not parallel\n\t\t\t\t\tif (edgeDy < 0) {\n\t\t\t\t\t\tedgeLowPt = inPolygon[q];\n\t\t\t\t\t\tedgeDx = -edgeDx;\n\t\t\t\t\t\tedgeHighPt = inPolygon[p];\n\t\t\t\t\t\tedgeDy = -edgeDy;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (inPt.y < edgeLowPt.y || inPt.y > edgeHighPt.y) continue;\n\n\t\t\t\t\tif (inPt.y === edgeLowPt.y) {\n\t\t\t\t\t\tif (inPt.x === edgeLowPt.x) return true; // inPt is on contour ?\n\t\t\t\t\t\t// continue;\t\t\t\t// no intersection or edgeLowPt => doesn't count !!!\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst perpEdge = edgeDy * (inPt.x - edgeLowPt.x) - edgeDx * (inPt.y - edgeLowPt.y);\n\t\t\t\t\t\tif (perpEdge === 0) return true; // inPt is on contour ?\n\n\t\t\t\t\t\tif (perpEdge < 0) continue;\n\t\t\t\t\t\tinside = !inside; // true intersection left of inPt\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// parallel or collinear\n\t\t\t\t\tif (inPt.y !== edgeLowPt.y) continue; // parallel\n\t\t\t\t\t// edge lies on the same horizontal line as inPt\n\n\t\t\t\t\tif (edgeHighPt.x <= inPt.x && inPt.x <= edgeLowPt.x || edgeLowPt.x <= inPt.x && inPt.x <= edgeHighPt.x) return true; // inPt: Point on contour !\n\t\t\t\t\t// continue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn inside;\n\t\t}\n\n\t\tconst isClockWise = ShapeUtils.isClockWise;\n\t\tconst subPaths = this.subPaths;\n\t\tif (subPaths.length === 0) return [];\n\t\tlet solid, tmpPath, tmpShape;\n\t\tconst shapes = [];\n\n\t\tif (subPaths.length === 1) {\n\t\t\ttmpPath = subPaths[0];\n\t\t\ttmpShape = new Shape();\n\t\t\ttmpShape.curves = tmpPath.curves;\n\t\t\tshapes.push(tmpShape);\n\t\t\treturn shapes;\n\t\t}\n\n\t\tlet holesFirst = !isClockWise(subPaths[0].getPoints());\n\t\tholesFirst = isCCW ? !holesFirst : holesFirst; // console.log(\"Holes first\", holesFirst);\n\n\t\tconst betterShapeHoles = [];\n\t\tconst newShapes = [];\n\t\tlet newShapeHoles = [];\n\t\tlet mainIdx = 0;\n\t\tlet tmpPoints;\n\t\tnewShapes[mainIdx] = undefined;\n\t\tnewShapeHoles[mainIdx] = [];\n\n\t\tfor (let i = 0, l = subPaths.length; i < l; i++) {\n\t\t\ttmpPath = subPaths[i];\n\t\t\ttmpPoints = tmpPath.getPoints();\n\t\t\tsolid = isClockWise(tmpPoints);\n\t\t\tsolid = isCCW ? !solid : solid;\n\n\t\t\tif (solid) {\n\t\t\t\tif (!holesFirst && newShapes[mainIdx]) mainIdx++;\n\t\t\t\tnewShapes[mainIdx] = {\n\t\t\t\t\ts: new Shape(),\n\t\t\t\t\tp: tmpPoints\n\t\t\t\t};\n\t\t\t\tnewShapes[mainIdx].s.curves = tmpPath.curves;\n\t\t\t\tif (holesFirst) mainIdx++;\n\t\t\t\tnewShapeHoles[mainIdx] = []; //console.log('cw', i);\n\t\t\t} else {\n\t\t\t\tnewShapeHoles[mainIdx].push({\n\t\t\t\t\th: tmpPath,\n\t\t\t\t\tp: tmpPoints[0]\n\t\t\t\t}); //console.log('ccw', i);\n\t\t\t}\n\t\t} // only Holes? -> probably all Shapes with wrong orientation\n\n\n\t\tif (!newShapes[0]) return toShapesNoHoles(subPaths);\n\n\t\tif (newShapes.length > 1) {\n\t\t\tlet ambiguous = false;\n\t\t\tlet toChange = 0;\n\n\t\t\tfor (let sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx++) {\n\t\t\t\tbetterShapeHoles[sIdx] = [];\n\t\t\t}\n\n\t\t\tfor (let sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx++) {\n\t\t\t\tconst sho = newShapeHoles[sIdx];\n\n\t\t\t\tfor (let hIdx = 0; hIdx < sho.length; hIdx++) {\n\t\t\t\t\tconst ho = sho[hIdx];\n\t\t\t\t\tlet hole_unassigned = true;\n\n\t\t\t\t\tfor (let s2Idx = 0; s2Idx < newShapes.length; s2Idx++) {\n\t\t\t\t\t\tif (isPointInsidePolygon(ho.p, newShapes[s2Idx].p)) {\n\t\t\t\t\t\t\tif (sIdx !== s2Idx) toChange++;\n\n\t\t\t\t\t\t\tif (hole_unassigned) {\n\t\t\t\t\t\t\t\thole_unassigned = false;\n\t\t\t\t\t\t\t\tbetterShapeHoles[s2Idx].push(ho);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tambiguous = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (hole_unassigned) {\n\t\t\t\t\t\tbetterShapeHoles[sIdx].push(ho);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (toChange > 0 && ambiguous === false) {\n\t\t\t\tnewShapeHoles = betterShapeHoles;\n\t\t\t}\n\t\t}\n\n\t\tlet tmpHoles;\n\n\t\tfor (let i = 0, il = newShapes.length; i < il; i++) {\n\t\t\ttmpShape = newShapes[i].s;\n\t\t\tshapes.push(tmpShape);\n\t\t\ttmpHoles = newShapeHoles[i];\n\n\t\t\tfor (let j = 0, jl = tmpHoles.length; j < jl; j++) {\n\t\t\t\ttmpShape.holes.push(tmpHoles[j].h);\n\t\t\t}\n\t\t} //console.log(\"shape\", shapes);\n\n\n\t\treturn shapes;\n\t}\n\n}\n\nconst _tables = /*@__PURE__*/_generateTables();\n\nfunction _generateTables() {\n\t// float32 to float16 helpers\n\tconst buffer = new ArrayBuffer(4);\n\tconst floatView = new Float32Array(buffer);\n\tconst uint32View = new Uint32Array(buffer);\n\tconst baseTable = new Uint32Array(512);\n\tconst shiftTable = new Uint32Array(512);\n\n\tfor (let i = 0; i < 256; ++i) {\n\t\tconst e = i - 127; // very small number (0, -0)\n\n\t\tif (e < -27) {\n\t\t\tbaseTable[i] = 0x0000;\n\t\t\tbaseTable[i | 0x100] = 0x8000;\n\t\t\tshiftTable[i] = 24;\n\t\t\tshiftTable[i | 0x100] = 24; // small number (denorm)\n\t\t} else if (e < -14) {\n\t\t\tbaseTable[i] = 0x0400 >> -e - 14;\n\t\t\tbaseTable[i | 0x100] = 0x0400 >> -e - 14 | 0x8000;\n\t\t\tshiftTable[i] = -e - 1;\n\t\t\tshiftTable[i | 0x100] = -e - 1; // normal number\n\t\t} else if (e <= 15) {\n\t\t\tbaseTable[i] = e + 15 << 10;\n\t\t\tbaseTable[i | 0x100] = e + 15 << 10 | 0x8000;\n\t\t\tshiftTable[i] = 13;\n\t\t\tshiftTable[i | 0x100] = 13; // large number (Infinity, -Infinity)\n\t\t} else if (e < 128) {\n\t\t\tbaseTable[i] = 0x7c00;\n\t\t\tbaseTable[i | 0x100] = 0xfc00;\n\t\t\tshiftTable[i] = 24;\n\t\t\tshiftTable[i | 0x100] = 24; // stay (NaN, Infinity, -Infinity)\n\t\t} else {\n\t\t\tbaseTable[i] = 0x7c00;\n\t\t\tbaseTable[i | 0x100] = 0xfc00;\n\t\t\tshiftTable[i] = 13;\n\t\t\tshiftTable[i | 0x100] = 13;\n\t\t}\n\t} // float16 to float32 helpers\n\n\n\tconst mantissaTable = new Uint32Array(2048);\n\tconst exponentTable = new Uint32Array(64);\n\tconst offsetTable = new Uint32Array(64);\n\n\tfor (let i = 1; i < 1024; ++i) {\n\t\tlet m = i << 13; // zero pad mantissa bits\n\n\t\tlet e = 0; // zero exponent\n\t\t// normalized\n\n\t\twhile ((m & 0x00800000) === 0) {\n\t\t\tm <<= 1;\n\t\t\te -= 0x00800000; // decrement exponent\n\t\t}\n\n\t\tm &= ~0x00800000; // clear leading 1 bit\n\n\t\te += 0x38800000; // adjust bias\n\n\t\tmantissaTable[i] = m | e;\n\t}\n\n\tfor (let i = 1024; i < 2048; ++i) {\n\t\tmantissaTable[i] = 0x38000000 + (i - 1024 << 13);\n\t}\n\n\tfor (let i = 1; i < 31; ++i) {\n\t\texponentTable[i] = i << 23;\n\t}\n\n\texponentTable[31] = 0x47800000;\n\texponentTable[32] = 0x80000000;\n\n\tfor (let i = 33; i < 63; ++i) {\n\t\texponentTable[i] = 0x80000000 + (i - 32 << 23);\n\t}\n\n\texponentTable[63] = 0xc7800000;\n\n\tfor (let i = 1; i < 64; ++i) {\n\t\tif (i !== 32) {\n\t\t\toffsetTable[i] = 1024;\n\t\t}\n\t}\n\n\treturn {\n\t\tfloatView: floatView,\n\t\tuint32View: uint32View,\n\t\tbaseTable: baseTable,\n\t\tshiftTable: shiftTable,\n\t\tmantissaTable: mantissaTable,\n\t\texponentTable: exponentTable,\n\t\toffsetTable: offsetTable\n\t};\n} // float32 to float16\n\n\nfunction toHalfFloat(val) {\n\tif (Math.abs(val) > 65504) console.warn('THREE.DataUtils.toHalfFloat(): Value out of range.');\n\tval = clamp(val, -65504, 65504);\n\t_tables.floatView[0] = val;\n\tconst f = _tables.uint32View[0];\n\tconst e = f >> 23 & 0x1ff;\n\treturn _tables.baseTable[e] + ((f & 0x007fffff) >> _tables.shiftTable[e]);\n} // float16 to float32\n\n\nfunction fromHalfFloat(val) {\n\tconst m = val >> 10;\n\t_tables.uint32View[0] = _tables.mantissaTable[_tables.offsetTable[m] + (val & 0x3ff)] + _tables.exponentTable[m];\n\treturn _tables.floatView[0];\n}\n\nvar DataUtils = /*#__PURE__*/Object.freeze({\n\t__proto__: null,\n\ttoHalfFloat: toHalfFloat,\n\tfromHalfFloat: fromHalfFloat\n});\n\nfunction ImmediateRenderObject() {\n\tconsole.error('THREE.ImmediateRenderObject has been removed.');\n} // r138, 48b05d3500acc084df50be9b4c90781ad9b8cb17\n\nclass WebGLMultisampleRenderTarget extends WebGLRenderTarget {\n\tconstructor(width, height, options) {\n\t\tconsole.error('THREE.WebGLMultisampleRenderTarget has been removed. Use a normal render target and set the \"samples\" property to greater 0 to enable multisampling.');\n\t\tsuper(width, height, options);\n\t\tthis.samples = 4;\n\t}\n\n} // r138, f9cd9cab03b7b64244e304900a3a2eeaa3a588ce\n\nclass DataTexture2DArray extends DataArrayTexture {\n\tconstructor(data, width, height, depth) {\n\t\tconsole.warn('THREE.DataTexture2DArray has been renamed to DataArrayTexture.');\n\t\tsuper(data, width, height, depth);\n\t}\n\n} // r138, f9cd9cab03b7b64244e304900a3a2eeaa3a588ce\n\nclass DataTexture3D extends Data3DTexture {\n\tconstructor(data, width, height, depth) {\n\t\tconsole.warn('THREE.DataTexture3D has been renamed to Data3DTexture.');\n\t\tsuper(data, width, height, depth);\n\t}\n\n} // r144\n\nclass BoxBufferGeometry extends BoxGeometry {\n\tconstructor(width, height, depth, widthSegments, heightSegments, depthSegments) {\n\t\tconsole.warn('THREE.BoxBufferGeometry has been renamed to THREE.BoxGeometry.');\n\t\tsuper(width, height, depth, widthSegments, heightSegments, depthSegments);\n\t}\n\n} // r144\n\nclass CapsuleBufferGeometry extends CapsuleGeometry {\n\tconstructor(radius, length, capSegments, radialSegments) {\n\t\tconsole.warn('THREE.CapsuleBufferGeometry has been renamed to THREE.CapsuleGeometry.');\n\t\tsuper(radius, length, capSegments, radialSegments);\n\t}\n\n} // r144\n\nclass CircleBufferGeometry extends CircleGeometry {\n\tconstructor(radius, segments, thetaStart, thetaLength) {\n\t\tconsole.warn('THREE.CircleBufferGeometry has been renamed to THREE.CircleGeometry.');\n\t\tsuper(radius, segments, thetaStart, thetaLength);\n\t}\n\n} // r144\n\nclass ConeBufferGeometry extends ConeGeometry {\n\tconstructor(radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength) {\n\t\tconsole.warn('THREE.ConeBufferGeometry has been renamed to THREE.ConeGeometry.');\n\t\tsuper(radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength);\n\t}\n\n} // r144\n\nclass CylinderBufferGeometry extends CylinderGeometry {\n\tconstructor(radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength) {\n\t\tconsole.warn('THREE.CylinderBufferGeometry has been renamed to THREE.CylinderGeometry.');\n\t\tsuper(radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength);\n\t}\n\n} // r144\n\nclass DodecahedronBufferGeometry extends DodecahedronGeometry {\n\tconstructor(radius, detail) {\n\t\tconsole.warn('THREE.DodecahedronBufferGeometry has been renamed to THREE.DodecahedronGeometry.');\n\t\tsuper(radius, detail);\n\t}\n\n} // r144\n\nclass ExtrudeBufferGeometry extends ExtrudeGeometry {\n\tconstructor(shapes, options) {\n\t\tconsole.warn('THREE.ExtrudeBufferGeometry has been renamed to THREE.ExtrudeGeometry.');\n\t\tsuper(shapes, options);\n\t}\n\n} // r144\n\nclass IcosahedronBufferGeometry extends IcosahedronGeometry {\n\tconstructor(radius, detail) {\n\t\tconsole.warn('THREE.IcosahedronBufferGeometry has been renamed to THREE.IcosahedronGeometry.');\n\t\tsuper(radius, detail);\n\t}\n\n} // r144\n\nclass LatheBufferGeometry extends LatheGeometry {\n\tconstructor(points, segments, phiStart, phiLength) {\n\t\tconsole.warn('THREE.LatheBufferGeometry has been renamed to THREE.LatheGeometry.');\n\t\tsuper(points, segments, phiStart, phiLength);\n\t}\n\n} // r144\n\nclass OctahedronBufferGeometry extends OctahedronGeometry {\n\tconstructor(radius, detail) {\n\t\tconsole.warn('THREE.OctahedronBufferGeometry has been renamed to THREE.OctahedronGeometry.');\n\t\tsuper(radius, detail);\n\t}\n\n} // r144\n\nclass PlaneBufferGeometry extends PlaneGeometry {\n\tconstructor(width, height, widthSegments, heightSegments) {\n\t\tconsole.warn('THREE.PlaneBufferGeometry has been renamed to THREE.PlaneGeometry.');\n\t\tsuper(width, height, widthSegments, heightSegments);\n\t}\n\n} // r144\n\nclass PolyhedronBufferGeometry extends PolyhedronGeometry {\n\tconstructor(vertices, indices, radius, detail) {\n\t\tconsole.warn('THREE.PolyhedronBufferGeometry has been renamed to THREE.PolyhedronGeometry.');\n\t\tsuper(vertices, indices, radius, detail);\n\t}\n\n} // r144\n\nclass RingBufferGeometry extends RingGeometry {\n\tconstructor(innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength) {\n\t\tconsole.warn('THREE.RingBufferGeometry has been renamed to THREE.RingGeometry.');\n\t\tsuper(innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength);\n\t}\n\n} // r144\n\nclass ShapeBufferGeometry extends ShapeGeometry {\n\tconstructor(shapes, curveSegments) {\n\t\tconsole.warn('THREE.ShapeBufferGeometry has been renamed to THREE.ShapeGeometry.');\n\t\tsuper(shapes, curveSegments);\n\t}\n\n} // r144\n\nclass SphereBufferGeometry extends SphereGeometry {\n\tconstructor(radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength) {\n\t\tconsole.warn('THREE.SphereBufferGeometry has been renamed to THREE.SphereGeometry.');\n\t\tsuper(radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength);\n\t}\n\n} // r144\n\nclass TetrahedronBufferGeometry extends TetrahedronGeometry {\n\tconstructor(radius, detail) {\n\t\tconsole.warn('THREE.TetrahedronBufferGeometry has been renamed to THREE.TetrahedronGeometry.');\n\t\tsuper(radius, detail);\n\t}\n\n} // r144\n\nclass TorusBufferGeometry extends TorusGeometry {\n\tconstructor(radius, tube, radialSegments, tubularSegments, arc) {\n\t\tconsole.warn('THREE.TorusBufferGeometry has been renamed to THREE.TorusGeometry.');\n\t\tsuper(radius, tube, radialSegments, tubularSegments, arc);\n\t}\n\n} // r144\n\nclass TorusKnotBufferGeometry extends TorusKnotGeometry {\n\tconstructor(radius, tube, tubularSegments, radialSegments, p, q) {\n\t\tconsole.warn('THREE.TorusKnotBufferGeometry has been renamed to THREE.TorusKnotGeometry.');\n\t\tsuper(radius, tube, tubularSegments, radialSegments, p, q);\n\t}\n\n} // r144\n\nclass TubeBufferGeometry extends TubeGeometry {\n\tconstructor(path, tubularSegments, radius, radialSegments, closed) {\n\t\tconsole.warn('THREE.TubeBufferGeometry has been renamed to THREE.TubeGeometry.');\n\t\tsuper(path, tubularSegments, radius, radialSegments, closed);\n\t}\n\n}\n\nif (typeof __THREE_DEVTOOLS__ !== 'undefined') {\n\t__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('register', {\n\t\tdetail: {\n\t\t\trevision: REVISION\n\t\t}\n\t}));\n}\n\nif (typeof window !== 'undefined') {\n\tif (window.__THREE__) {\n\t\tconsole.warn('WARNING: Multiple instances of Three.js being imported.');\n\t} else {\n\t\twindow.__THREE__ = REVISION;\n\t}\n}\n\nexports.ACESFilmicToneMapping = ACESFilmicToneMapping;\nexports.AddEquation = AddEquation;\nexports.AddOperation = AddOperation;\nexports.AdditiveAnimationBlendMode = AdditiveAnimationBlendMode;\nexports.AdditiveBlending = AdditiveBlending;\nexports.AlphaFormat = AlphaFormat;\nexports.AlwaysDepth = AlwaysDepth;\nexports.AlwaysStencilFunc = AlwaysStencilFunc;\nexports.AmbientLight = AmbientLight;\nexports.AmbientLightProbe = AmbientLightProbe;\nexports.AnimationClip = AnimationClip;\nexports.AnimationLoader = AnimationLoader;\nexports.AnimationMixer = AnimationMixer;\nexports.AnimationObjectGroup = AnimationObjectGroup;\nexports.AnimationUtils = AnimationUtils;\nexports.ArcCurve = ArcCurve;\nexports.ArrayCamera = ArrayCamera;\nexports.ArrowHelper = ArrowHelper;\nexports.Audio = Audio;\nexports.AudioAnalyser = AudioAnalyser;\nexports.AudioContext = AudioContext;\nexports.AudioListener = AudioListener;\nexports.AudioLoader = AudioLoader;\nexports.AxesHelper = AxesHelper;\nexports.BackSide = BackSide;\nexports.BasicDepthPacking = BasicDepthPacking;\nexports.BasicShadowMap = BasicShadowMap;\nexports.Bone = Bone;\nexports.BooleanKeyframeTrack = BooleanKeyframeTrack;\nexports.Box2 = Box2;\nexports.Box3 = Box3;\nexports.Box3Helper = Box3Helper;\nexports.BoxBufferGeometry = BoxBufferGeometry;\nexports.BoxGeometry = BoxGeometry;\nexports.BoxHelper = BoxHelper;\nexports.BufferAttribute = BufferAttribute;\nexports.BufferGeometry = BufferGeometry;\nexports.BufferGeometryLoader = BufferGeometryLoader;\nexports.ByteType = ByteType;\nexports.Cache = Cache;\nexports.Camera = Camera;\nexports.CameraHelper = CameraHelper;\nexports.CanvasTexture = CanvasTexture;\nexports.CapsuleBufferGeometry = CapsuleBufferGeometry;\nexports.CapsuleGeometry = CapsuleGeometry;\nexports.CatmullRomCurve3 = CatmullRomCurve3;\nexports.CineonToneMapping = CineonToneMapping;\nexports.CircleBufferGeometry = CircleBufferGeometry;\nexports.CircleGeometry = CircleGeometry;\nexports.ClampToEdgeWrapping = ClampToEdgeWrapping;\nexports.Clock = Clock;\nexports.Color = Color;\nexports.ColorKeyframeTrack = ColorKeyframeTrack;\nexports.ColorManagement = ColorManagement;\nexports.CompressedTexture = CompressedTexture;\nexports.CompressedTextureLoader = CompressedTextureLoader;\nexports.ConeBufferGeometry = ConeBufferGeometry;\nexports.ConeGeometry = ConeGeometry;\nexports.CubeCamera = CubeCamera;\nexports.CubeReflectionMapping = CubeReflectionMapping;\nexports.CubeRefractionMapping = CubeRefractionMapping;\nexports.CubeTexture = CubeTexture;\nexports.CubeTextureLoader = CubeTextureLoader;\nexports.CubeUVReflectionMapping = CubeUVReflectionMapping;\nexports.CubicBezierCurve = CubicBezierCurve;\nexports.CubicBezierCurve3 = CubicBezierCurve3;\nexports.CubicInterpolant = CubicInterpolant;\nexports.CullFaceBack = CullFaceBack;\nexports.CullFaceFront = CullFaceFront;\nexports.CullFaceFrontBack = CullFaceFrontBack;\nexports.CullFaceNone = CullFaceNone;\nexports.Curve = Curve;\nexports.CurvePath = CurvePath;\nexports.CustomBlending = CustomBlending;\nexports.CustomToneMapping = CustomToneMapping;\nexports.CylinderBufferGeometry = CylinderBufferGeometry;\nexports.CylinderGeometry = CylinderGeometry;\nexports.Cylindrical = Cylindrical;\nexports.Data3DTexture = Data3DTexture;\nexports.DataArrayTexture = DataArrayTexture;\nexports.DataTexture = DataTexture;\nexports.DataTexture2DArray = DataTexture2DArray;\nexports.DataTexture3D = DataTexture3D;\nexports.DataTextureLoader = DataTextureLoader;\nexports.DataUtils = DataUtils;\nexports.DecrementStencilOp = DecrementStencilOp;\nexports.DecrementWrapStencilOp = DecrementWrapStencilOp;\nexports.DefaultLoadingManager = DefaultLoadingManager;\nexports.DepthFormat = DepthFormat;\nexports.DepthStencilFormat = DepthStencilFormat;\nexports.DepthTexture = DepthTexture;\nexports.DirectionalLight = DirectionalLight;\nexports.DirectionalLightHelper = DirectionalLightHelper;\nexports.DiscreteInterpolant = DiscreteInterpolant;\nexports.DodecahedronBufferGeometry = DodecahedronBufferGeometry;\nexports.DodecahedronGeometry = DodecahedronGeometry;\nexports.DoubleSide = DoubleSide;\nexports.DstAlphaFactor = DstAlphaFactor;\nexports.DstColorFactor = DstColorFactor;\nexports.DynamicCopyUsage = DynamicCopyUsage;\nexports.DynamicDrawUsage = DynamicDrawUsage;\nexports.DynamicReadUsage = DynamicReadUsage;\nexports.EdgesGeometry = EdgesGeometry;\nexports.EllipseCurve = EllipseCurve;\nexports.EqualDepth = EqualDepth;\nexports.EqualStencilFunc = EqualStencilFunc;\nexports.EquirectangularReflectionMapping = EquirectangularReflectionMapping;\nexports.EquirectangularRefractionMapping = EquirectangularRefractionMapping;\nexports.Euler = Euler;\nexports.EventDispatcher = EventDispatcher;\nexports.ExtrudeBufferGeometry = ExtrudeBufferGeometry;\nexports.ExtrudeGeometry = ExtrudeGeometry;\nexports.FileLoader = FileLoader;\nexports.Float16BufferAttribute = Float16BufferAttribute;\nexports.Float32BufferAttribute = Float32BufferAttribute;\nexports.Float64BufferAttribute = Float64BufferAttribute;\nexports.FloatType = FloatType;\nexports.Fog = Fog;\nexports.FogExp2 = FogExp2;\nexports.FramebufferTexture = FramebufferTexture;\nexports.FrontSide = FrontSide;\nexports.Frustum = Frustum;\nexports.GLBufferAttribute = GLBufferAttribute;\nexports.GLSL1 = GLSL1;\nexports.GLSL3 = GLSL3;\nexports.GreaterDepth = GreaterDepth;\nexports.GreaterEqualDepth = GreaterEqualDepth;\nexports.GreaterEqualStencilFunc = GreaterEqualStencilFunc;\nexports.GreaterStencilFunc = GreaterStencilFunc;\nexports.GridHelper = GridHelper;\nexports.Group = Group;\nexports.HalfFloatType = HalfFloatType;\nexports.HemisphereLight = HemisphereLight;\nexports.HemisphereLightHelper = HemisphereLightHelper;\nexports.HemisphereLightProbe = HemisphereLightProbe;\nexports.IcosahedronBufferGeometry = IcosahedronBufferGeometry;\nexports.IcosahedronGeometry = IcosahedronGeometry;\nexports.ImageBitmapLoader = ImageBitmapLoader;\nexports.ImageLoader = ImageLoader;\nexports.ImageUtils = ImageUtils;\nexports.ImmediateRenderObject = ImmediateRenderObject;\nexports.IncrementStencilOp = IncrementStencilOp;\nexports.IncrementWrapStencilOp = IncrementWrapStencilOp;\nexports.InstancedBufferAttribute = InstancedBufferAttribute;\nexports.InstancedBufferGeometry = InstancedBufferGeometry;\nexports.InstancedInterleavedBuffer = InstancedInterleavedBuffer;\nexports.InstancedMesh = InstancedMesh;\nexports.Int16BufferAttribute = Int16BufferAttribute;\nexports.Int32BufferAttribute = Int32BufferAttribute;\nexports.Int8BufferAttribute = Int8BufferAttribute;\nexports.IntType = IntType;\nexports.InterleavedBuffer = InterleavedBuffer;\nexports.InterleavedBufferAttribute = InterleavedBufferAttribute;\nexports.Interpolant = Interpolant;\nexports.InterpolateDiscrete = InterpolateDiscrete;\nexports.InterpolateLinear = InterpolateLinear;\nexports.InterpolateSmooth = InterpolateSmooth;\nexports.InvertStencilOp = InvertStencilOp;\nexports.KeepStencilOp = KeepStencilOp;\nexports.KeyframeTrack = KeyframeTrack;\nexports.LOD = LOD;\nexports.LatheBufferGeometry = LatheBufferGeometry;\nexports.LatheGeometry = LatheGeometry;\nexports.Layers = Layers;\nexports.LessDepth = LessDepth;\nexports.LessEqualDepth = LessEqualDepth;\nexports.LessEqualStencilFunc = LessEqualStencilFunc;\nexports.LessStencilFunc = LessStencilFunc;\nexports.Light = Light;\nexports.LightProbe = LightProbe;\nexports.Line = Line;\nexports.Line3 = Line3;\nexports.LineBasicMaterial = LineBasicMaterial;\nexports.LineCurve = LineCurve;\nexports.LineCurve3 = LineCurve3;\nexports.LineDashedMaterial = LineDashedMaterial;\nexports.LineLoop = LineLoop;\nexports.LineSegments = LineSegments;\nexports.LinearEncoding = LinearEncoding;\nexports.LinearFilter = LinearFilter;\nexports.LinearInterpolant = LinearInterpolant;\nexports.LinearMipMapLinearFilter = LinearMipMapLinearFilter;\nexports.LinearMipMapNearestFilter = LinearMipMapNearestFilter;\nexports.LinearMipmapLinearFilter = LinearMipmapLinearFilter;\nexports.LinearMipmapNearestFilter = LinearMipmapNearestFilter;\nexports.LinearSRGBColorSpace = LinearSRGBColorSpace;\nexports.LinearToneMapping = LinearToneMapping;\nexports.Loader = Loader;\nexports.LoaderUtils = LoaderUtils;\nexports.LoadingManager = LoadingManager;\nexports.LoopOnce = LoopOnce;\nexports.LoopPingPong = LoopPingPong;\nexports.LoopRepeat = LoopRepeat;\nexports.LuminanceAlphaFormat = LuminanceAlphaFormat;\nexports.LuminanceFormat = LuminanceFormat;\nexports.MOUSE = MOUSE;\nexports.Material = Material;\nexports.MaterialLoader = MaterialLoader;\nexports.MathUtils = MathUtils;\nexports.Matrix3 = Matrix3;\nexports.Matrix4 = Matrix4;\nexports.MaxEquation = MaxEquation;\nexports.Mesh = Mesh;\nexports.MeshBasicMaterial = MeshBasicMaterial;\nexports.MeshDepthMaterial = MeshDepthMaterial;\nexports.MeshDistanceMaterial = MeshDistanceMaterial;\nexports.MeshLambertMaterial = MeshLambertMaterial;\nexports.MeshMatcapMaterial = MeshMatcapMaterial;\nexports.MeshNormalMaterial = MeshNormalMaterial;\nexports.MeshPhongMaterial = MeshPhongMaterial;\nexports.MeshPhysicalMaterial = MeshPhysicalMaterial;\nexports.MeshStandardMaterial = MeshStandardMaterial;\nexports.MeshToonMaterial = MeshToonMaterial;\nexports.MinEquation = MinEquation;\nexports.MirroredRepeatWrapping = MirroredRepeatWrapping;\nexports.MixOperation = MixOperation;\nexports.MultiplyBlending = MultiplyBlending;\nexports.MultiplyOperation = MultiplyOperation;\nexports.NearestFilter = NearestFilter;\nexports.NearestMipMapLinearFilter = NearestMipMapLinearFilter;\nexports.NearestMipMapNearestFilter = NearestMipMapNearestFilter;\nexports.NearestMipmapLinearFilter = NearestMipmapLinearFilter;\nexports.NearestMipmapNearestFilter = NearestMipmapNearestFilter;\nexports.NeverDepth = NeverDepth;\nexports.NeverStencilFunc = NeverStencilFunc;\nexports.NoBlending = NoBlending;\nexports.NoColorSpace = NoColorSpace;\nexports.NoToneMapping = NoToneMapping;\nexports.NormalAnimationBlendMode = NormalAnimationBlendMode;\nexports.NormalBlending = NormalBlending;\nexports.NotEqualDepth = NotEqualDepth;\nexports.NotEqualStencilFunc = NotEqualStencilFunc;\nexports.NumberKeyframeTrack = NumberKeyframeTrack;\nexports.Object3D = Object3D;\nexports.ObjectLoader = ObjectLoader;\nexports.ObjectSpaceNormalMap = ObjectSpaceNormalMap;\nexports.OctahedronBufferGeometry = OctahedronBufferGeometry;\nexports.OctahedronGeometry = OctahedronGeometry;\nexports.OneFactor = OneFactor;\nexports.OneMinusDstAlphaFactor = OneMinusDstAlphaFactor;\nexports.OneMinusDstColorFactor = OneMinusDstColorFactor;\nexports.OneMinusSrcAlphaFactor = OneMinusSrcAlphaFactor;\nexports.OneMinusSrcColorFactor = OneMinusSrcColorFactor;\nexports.OrthographicCamera = OrthographicCamera;\nexports.PCFShadowMap = PCFShadowMap;\nexports.PCFSoftShadowMap = PCFSoftShadowMap;\nexports.PMREMGenerator = PMREMGenerator;\nexports.Path = Path;\nexports.PerspectiveCamera = PerspectiveCamera;\nexports.Plane = Plane;\nexports.PlaneBufferGeometry = PlaneBufferGeometry;\nexports.PlaneGeometry = PlaneGeometry;\nexports.PlaneHelper = PlaneHelper;\nexports.PointLight = PointLight;\nexports.PointLightHelper = PointLightHelper;\nexports.Points = Points;\nexports.PointsMaterial = PointsMaterial;\nexports.PolarGridHelper = PolarGridHelper;\nexports.PolyhedronBufferGeometry = PolyhedronBufferGeometry;\nexports.PolyhedronGeometry = PolyhedronGeometry;\nexports.PositionalAudio = PositionalAudio;\nexports.PropertyBinding = PropertyBinding;\nexports.PropertyMixer = PropertyMixer;\nexports.QuadraticBezierCurve = QuadraticBezierCurve;\nexports.QuadraticBezierCurve3 = QuadraticBezierCurve3;\nexports.Quaternion = Quaternion;\nexports.QuaternionKeyframeTrack = QuaternionKeyframeTrack;\nexports.QuaternionLinearInterpolant = QuaternionLinearInterpolant;\nexports.REVISION = REVISION;\nexports.RGBADepthPacking = RGBADepthPacking;\nexports.RGBAFormat = RGBAFormat;\nexports.RGBAIntegerFormat = RGBAIntegerFormat;\nexports.RGBA_ASTC_10x10_Format = RGBA_ASTC_10x10_Format;\nexports.RGBA_ASTC_10x5_Format = RGBA_ASTC_10x5_Format;\nexports.RGBA_ASTC_10x6_Format = RGBA_ASTC_10x6_Format;\nexports.RGBA_ASTC_10x8_Format = RGBA_ASTC_10x8_Format;\nexports.RGBA_ASTC_12x10_Format = RGBA_ASTC_12x10_Format;\nexports.RGBA_ASTC_12x12_Format = RGBA_ASTC_12x12_Format;\nexports.RGBA_ASTC_4x4_Format = RGBA_ASTC_4x4_Format;\nexports.RGBA_ASTC_5x4_Format = RGBA_ASTC_5x4_Format;\nexports.RGBA_ASTC_5x5_Format = RGBA_ASTC_5x5_Format;\nexports.RGBA_ASTC_6x5_Format = RGBA_ASTC_6x5_Format;\nexports.RGBA_ASTC_6x6_Format = RGBA_ASTC_6x6_Format;\nexports.RGBA_ASTC_8x5_Format = RGBA_ASTC_8x5_Format;\nexports.RGBA_ASTC_8x6_Format = RGBA_ASTC_8x6_Format;\nexports.RGBA_ASTC_8x8_Format = RGBA_ASTC_8x8_Format;\nexports.RGBA_BPTC_Format = RGBA_BPTC_Format;\nexports.RGBA_ETC2_EAC_Format = RGBA_ETC2_EAC_Format;\nexports.RGBA_PVRTC_2BPPV1_Format = RGBA_PVRTC_2BPPV1_Format;\nexports.RGBA_PVRTC_4BPPV1_Format = RGBA_PVRTC_4BPPV1_Format;\nexports.RGBA_S3TC_DXT1_Format = RGBA_S3TC_DXT1_Format;\nexports.RGBA_S3TC_DXT3_Format = RGBA_S3TC_DXT3_Format;\nexports.RGBA_S3TC_DXT5_Format = RGBA_S3TC_DXT5_Format;\nexports.RGBFormat = RGBFormat;\nexports.RGB_ETC1_Format = RGB_ETC1_Format;\nexports.RGB_ETC2_Format = RGB_ETC2_Format;\nexports.RGB_PVRTC_2BPPV1_Format = RGB_PVRTC_2BPPV1_Format;\nexports.RGB_PVRTC_4BPPV1_Format = RGB_PVRTC_4BPPV1_Format;\nexports.RGB_S3TC_DXT1_Format = RGB_S3TC_DXT1_Format;\nexports.RGFormat = RGFormat;\nexports.RGIntegerFormat = RGIntegerFormat;\nexports.RawShaderMaterial = RawShaderMaterial;\nexports.Ray = Ray;\nexports.Raycaster = Raycaster;\nexports.RectAreaLight = RectAreaLight;\nexports.RedFormat = RedFormat;\nexports.RedIntegerFormat = RedIntegerFormat;\nexports.ReinhardToneMapping = ReinhardToneMapping;\nexports.RepeatWrapping = RepeatWrapping;\nexports.ReplaceStencilOp = ReplaceStencilOp;\nexports.ReverseSubtractEquation = ReverseSubtractEquation;\nexports.RingBufferGeometry = RingBufferGeometry;\nexports.RingGeometry = RingGeometry;\nexports.SRGBColorSpace = SRGBColorSpace;\nexports.Scene = Scene;\nexports.ShaderChunk = ShaderChunk;\nexports.ShaderLib = ShaderLib;\nexports.ShaderMaterial = ShaderMaterial;\nexports.ShadowMaterial = ShadowMaterial;\nexports.Shape = Shape;\nexports.ShapeBufferGeometry = ShapeBufferGeometry;\nexports.ShapeGeometry = ShapeGeometry;\nexports.ShapePath = ShapePath;\nexports.ShapeUtils = ShapeUtils;\nexports.ShortType = ShortType;\nexports.Skeleton = Skeleton;\nexports.SkeletonHelper = SkeletonHelper;\nexports.SkinnedMesh = SkinnedMesh;\nexports.Source = Source;\nexports.Sphere = Sphere;\nexports.SphereBufferGeometry = SphereBufferGeometry;\nexports.SphereGeometry = SphereGeometry;\nexports.Spherical = Spherical;\nexports.SphericalHarmonics3 = SphericalHarmonics3;\nexports.SplineCurve = SplineCurve;\nexports.SpotLight = SpotLight;\nexports.SpotLightHelper = SpotLightHelper;\nexports.Sprite = Sprite;\nexports.SpriteMaterial = SpriteMaterial;\nexports.SrcAlphaFactor = SrcAlphaFactor;\nexports.SrcAlphaSaturateFactor = SrcAlphaSaturateFactor;\nexports.SrcColorFactor = SrcColorFactor;\nexports.StaticCopyUsage = StaticCopyUsage;\nexports.StaticDrawUsage = StaticDrawUsage;\nexports.StaticReadUsage = StaticReadUsage;\nexports.StereoCamera = StereoCamera;\nexports.StreamCopyUsage = StreamCopyUsage;\nexports.StreamDrawUsage = StreamDrawUsage;\nexports.StreamReadUsage = StreamReadUsage;\nexports.StringKeyframeTrack = StringKeyframeTrack;\nexports.SubtractEquation = SubtractEquation;\nexports.SubtractiveBlending = SubtractiveBlending;\nexports.TOUCH = TOUCH;\nexports.TangentSpaceNormalMap = TangentSpaceNormalMap;\nexports.TetrahedronBufferGeometry = TetrahedronBufferGeometry;\nexports.TetrahedronGeometry = TetrahedronGeometry;\nexports.Texture = Texture;\nexports.TextureLoader = TextureLoader;\nexports.TorusBufferGeometry = TorusBufferGeometry;\nexports.TorusGeometry = TorusGeometry;\nexports.TorusKnotBufferGeometry = TorusKnotBufferGeometry;\nexports.TorusKnotGeometry = TorusKnotGeometry;\nexports.Triangle = Triangle;\nexports.TriangleFanDrawMode = TriangleFanDrawMode;\nexports.TriangleStripDrawMode = TriangleStripDrawMode;\nexports.TrianglesDrawMode = TrianglesDrawMode;\nexports.TubeBufferGeometry = TubeBufferGeometry;\nexports.TubeGeometry = TubeGeometry;\nexports.UVMapping = UVMapping;\nexports.Uint16BufferAttribute = Uint16BufferAttribute;\nexports.Uint32BufferAttribute = Uint32BufferAttribute;\nexports.Uint8BufferAttribute = Uint8BufferAttribute;\nexports.Uint8ClampedBufferAttribute = Uint8ClampedBufferAttribute;\nexports.Uniform = Uniform;\nexports.UniformsGroup = UniformsGroup;\nexports.UniformsLib = UniformsLib;\nexports.UniformsUtils = UniformsUtils;\nexports.UnsignedByteType = UnsignedByteType;\nexports.UnsignedInt248Type = UnsignedInt248Type;\nexports.UnsignedIntType = UnsignedIntType;\nexports.UnsignedShort4444Type = UnsignedShort4444Type;\nexports.UnsignedShort5551Type = UnsignedShort5551Type;\nexports.UnsignedShortType = UnsignedShortType;\nexports.VSMShadowMap = VSMShadowMap;\nexports.Vector2 = Vector2;\nexports.Vector3 = Vector3;\nexports.Vector4 = Vector4;\nexports.VectorKeyframeTrack = VectorKeyframeTrack;\nexports.VideoTexture = VideoTexture;\nexports.WebGL1Renderer = WebGL1Renderer;\nexports.WebGL3DRenderTarget = WebGL3DRenderTarget;\nexports.WebGLArrayRenderTarget = WebGLArrayRenderTarget;\nexports.WebGLCubeRenderTarget = WebGLCubeRenderTarget;\nexports.WebGLMultipleRenderTargets = WebGLMultipleRenderTargets;\nexports.WebGLMultisampleRenderTarget = WebGLMultisampleRenderTarget;\nexports.WebGLRenderTarget = WebGLRenderTarget;\nexports.WebGLRenderer = WebGLRenderer;\nexports.WebGLUtils = WebGLUtils;\nexports.WireframeGeometry = WireframeGeometry;\nexports.WrapAroundEnding = WrapAroundEnding;\nexports.ZeroCurvatureEnding = ZeroCurvatureEnding;\nexports.ZeroFactor = ZeroFactor;\nexports.ZeroSlopeEnding = ZeroSlopeEnding;\nexports.ZeroStencilOp = ZeroStencilOp;\nexports._SRGBAFormat = _SRGBAFormat;\nexports.sRGBEncoding = sRGBEncoding;\n\n\n//# sourceURL=webpack://@c-frame/aframe-physics-system/./node_modules/three/build/three.cjs?"); + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = __webpack_modules__; +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/define property getters */ +/******/ (() => { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = (exports, definition) => { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ (() => { +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ (() => { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = (exports) => { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ })(); +/******/ +/************************************************************************/ +/******/ +/******/ // module factories are used so entry inlining is disabled +/******/ // startup +/******/ // Load entry module and return exports +/******/ var __webpack_exports__ = __webpack_require__("./index.js"); +/******/ +/******/ })() +; \ No newline at end of file diff --git a/dist/aframe-physics-system.min.js b/dist/aframe-physics-system.min.js index 4c42e79f..9bec8d6e 100644 --- a/dist/aframe-physics-system.min.js +++ b/dist/aframe-physics-system.min.js @@ -1 +1,2 @@ -!function(){return function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){return o(e[i][1][r]||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i{const counterValue=document.createElement("div");counterValue.classList.add("rs-counter-value"),counterValue.innerHTML="...",this.counter.appendChild(counterValue),this.counterValues[property]=counterValue}),this.updateData=this.updateData.bind(this),this.el.addEventListener(this.data.event,this.updateData),this.splitCache={}):console.warn(`Couldn't find stats group ${groupComponentName}`)},updateData(e){this.data.properties.forEach(property=>{const split=this.splitDot(property);let value=e.detail;for(i=0;i{this.outputDetail[property]={}}),this.statsReceived=this.statsReceived.bind(this),this.el.addEventListener(this.data.inEvent,this.statsReceived)},resetData(){this.counter=0,this.data.properties.forEach(property=>{this.statsData[property]=[]})},statsReceived(e){this.updateData(e.detail),this.counter++,this.counter===this.data.outputFrequency&&(this.outputData(),this.resetData())},updateData(detail){this.data.properties.forEach(property=>{let value=detail;value=value[property],this.statsData[property].push(value)})},outputData(){this.data.properties.forEach(property=>{this.data.outputs.forEach(output=>{this.outputDetail[property][output]=this.computeOutput(output,this.statsData[property])})}),this.data.outEvent&&this.el.emit(this.data.outEvent,this.outputDetail),this.data.outputToConsole&&console.log(this.data.outputToConsole,this.outputDetail)},computeOutput(outputInstruction,data){const outputInstructions=outputInstruction.split("__");let output;switch(outputInstructions[0]){case"mean":output=data.reduce((a,b)=>a+b,0)/data.length;break;case"max":output=Math.max(...data);break;case"min":output=Math.min(...data);break;case"percentile":const sorted=data.sort((a,b)=>a-b),proportion=+outputInstructions[1].replace("_",".")/100,position=(data.length-1)*proportion,base=Math.floor(position),delta=position-base;output=void 0!==sorted[base+1]?sorted[base]+delta*(sorted[base+1]-sorted[base]):sorted[base]}return output.toFixed(2)}})},{}],4:[function(require,module,exports){THREE.AmmoDebugConstants={NoDebug:0,DrawWireframe:1,DrawAabb:2,DrawFeaturesText:4,DrawContactPoints:8,NoDeactivation:16,NoHelpText:32,DrawText:64,ProfileTimings:128,EnableSatComparison:256,DisableBulletLCP:512,EnableCCD:1024,DrawConstraints:2048,DrawConstraintLimits:4096,FastWireframe:8192,DrawNormals:16384,DrawOnTop:32768,MAX_DEBUG_DRAW_MODE:4294967295},THREE.AmmoDebugDrawer=function(scene,world,options){this.scene=scene,this.world=world,options=options||{},this.debugDrawMode=options.debugDrawMode||THREE.AmmoDebugConstants.DrawWireframe;var drawOnTop=this.debugDrawMode&THREE.AmmoDebugConstants.DrawOnTop||!1,maxBufferSize=options.maxBufferSize||1e6;this.geometry=new THREE.BufferGeometry;var vertices=new Float32Array(3*maxBufferSize),colors=new Float32Array(3*maxBufferSize);this.geometry.addAttribute("position",new THREE.BufferAttribute(vertices,3).setDynamic(!0)),this.geometry.addAttribute("color",new THREE.BufferAttribute(colors,3).setDynamic(!0)),this.index=0;var material=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors,depthTest:!drawOnTop});this.mesh=new THREE.LineSegments(this.geometry,material),drawOnTop&&(this.mesh.renderOrder=999),this.mesh.frustumCulled=!1,this.enabled=!1,this.debugDrawer=new Ammo.DebugDrawer,this.debugDrawer.drawLine=this.drawLine.bind(this),this.debugDrawer.drawContactPoint=this.drawContactPoint.bind(this),this.debugDrawer.reportErrorWarning=this.reportErrorWarning.bind(this),this.debugDrawer.draw3dText=this.draw3dText.bind(this),this.debugDrawer.setDebugMode=this.setDebugMode.bind(this),this.debugDrawer.getDebugMode=this.getDebugMode.bind(this),this.debugDrawer.enable=this.enable.bind(this),this.debugDrawer.disable=this.disable.bind(this),this.debugDrawer.update=this.update.bind(this),this.world.setDebugDrawer(this.debugDrawer)},THREE.AmmoDebugDrawer.prototype=function(){return this.debugDrawer},THREE.AmmoDebugDrawer.prototype.enable=function(){this.enabled=!0,this.scene.add(this.mesh)},THREE.AmmoDebugDrawer.prototype.disable=function(){this.enabled=!1,this.scene.remove(this.mesh)},THREE.AmmoDebugDrawer.prototype.update=function(){this.enabled&&(0!=this.index&&(this.geometry.attributes.position.needsUpdate=!0,this.geometry.attributes.color.needsUpdate=!0),this.index=0,this.world.debugDrawWorld(),this.geometry.setDrawRange(0,this.index))},THREE.AmmoDebugDrawer.prototype.drawLine=function(from,to,color){const heap=Ammo.HEAPF32,r=heap[(color+0)/4],g=heap[(color+4)/4],b=heap[(color+8)/4],fromX=heap[(from+0)/4],fromY=heap[(from+4)/4],fromZ=heap[(from+8)/4];this.geometry.attributes.position.setXYZ(this.index,fromX,fromY,fromZ),this.geometry.attributes.color.setXYZ(this.index++,r,g,b);const toX=heap[(to+0)/4],toY=heap[(to+4)/4],toZ=heap[(to+8)/4];this.geometry.attributes.position.setXYZ(this.index,toX,toY,toZ),this.geometry.attributes.color.setXYZ(this.index++,r,g,b)},THREE.AmmoDebugDrawer.prototype.drawContactPoint=function(pointOnB,normalOnB,distance,lifeTime,color){const heap=Ammo.HEAPF32,r=heap[(color+0)/4],g=heap[(color+4)/4],b=heap[(color+8)/4],x=heap[(pointOnB+0)/4],y=heap[(pointOnB+4)/4],z=heap[(pointOnB+8)/4];this.geometry.attributes.position.setXYZ(this.index,x,y,z),this.geometry.attributes.color.setXYZ(this.index++,r,g,b);const dx=heap[(normalOnB+0)/4]*distance,dy=heap[(normalOnB+4)/4]*distance,dz=heap[(normalOnB+8)/4]*distance;this.geometry.attributes.position.setXYZ(this.index,x+dx,y+dy,z+dz),this.geometry.attributes.color.setXYZ(this.index++,r,g,b)},THREE.AmmoDebugDrawer.prototype.reportErrorWarning=function(warningString){Ammo.hasOwnProperty("Pointer_stringify")?console.warn(Ammo.Pointer_stringify(warningString)):this.warnedOnce||(this.warnedOnce=!0,console.warn("Cannot print warningString, please rebuild Ammo.js using 'debug' flag"))},THREE.AmmoDebugDrawer.prototype.draw3dText=function(location,textString){console.warn("TODO: draw3dText")},THREE.AmmoDebugDrawer.prototype.setDebugMode=function(debugMode){this.debugDrawMode=debugMode},THREE.AmmoDebugDrawer.prototype.getDebugMode=function(){return this.debugDrawMode}},{}],5:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var ObjectCollisionMatrix=function(){function ObjectCollisionMatrix(){this.matrix={}}var _proto=ObjectCollisionMatrix.prototype;return _proto.get=function(bi,bj){var i=bi.id,j=bj.id;if(j>i){var temp=j;j=i,i=temp}return i+"-"+j in this.matrix},_proto.set=function(bi,bj,value){var i=bi.id,j=bj.id;if(j>i){var temp=j;j=i,i=temp}value?this.matrix[i+"-"+j]=!0:delete this.matrix[i+"-"+j]},_proto.reset=function(){this.matrix={}},_proto.setNumObjects=function(n){},ObjectCollisionMatrix}(),Mat3=function(){function Mat3(elements){void 0===elements&&(elements=[0,0,0,0,0,0,0,0,0]),this.elements=elements}var _proto=Mat3.prototype;return _proto.identity=function(){var e=this.elements;e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1},_proto.setZero=function(){var e=this.elements;e[0]=0,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e[8]=0},_proto.setTrace=function(vector){var e=this.elements;e[0]=vector.x,e[4]=vector.y,e[8]=vector.z},_proto.getTrace=function(target){void 0===target&&(target=new Vec3);var e=this.elements;target.x=e[0],target.y=e[4],target.z=e[8]},_proto.vmult=function(v,target){void 0===target&&(target=new Vec3);var e=this.elements,x=v.x,y=v.y,z=v.z;return target.x=e[0]*x+e[1]*y+e[2]*z,target.y=e[3]*x+e[4]*y+e[5]*z,target.z=e[6]*x+e[7]*y+e[8]*z,target},_proto.smult=function(s){for(var i=0;i0){var invN=1/n;this.x*=invN,this.y*=invN,this.z*=invN}else this.x=0,this.y=0,this.z=0;return n},_proto.unit=function(target){void 0===target&&(target=new Vec3);var x=this.x,y=this.y,z=this.z,ninv=Math.sqrt(x*x+y*y+z*z);return ninv>0?(ninv=1/ninv,target.x=x*ninv,target.y=y*ninv,target.z=z*ninv):(target.x=1,target.y=0,target.z=0),target},_proto.length=function(){var x=this.x,y=this.y,z=this.z;return Math.sqrt(x*x+y*y+z*z)},_proto.lengthSquared=function(){return this.dot(this)},_proto.distanceTo=function(p){var x=this.x,y=this.y,z=this.z,px=p.x,py=p.y,pz=p.z;return Math.sqrt((px-x)*(px-x)+(py-y)*(py-y)+(pz-z)*(pz-z))},_proto.distanceSquared=function(p){var x=this.x,y=this.y,z=this.z,px=p.x,py=p.y,pz=p.z;return(px-x)*(px-x)+(py-y)*(py-y)+(pz-z)*(pz-z)},_proto.scale=function(scalar,target){void 0===target&&(target=new Vec3);var x=this.x,y=this.y,z=this.z;return target.x=scalar*x,target.y=scalar*y,target.z=scalar*z,target},_proto.vmul=function(vector,target){return void 0===target&&(target=new Vec3),target.x=vector.x*this.x,target.y=vector.y*this.y,target.z=vector.z*this.z,target},_proto.addScaledVector=function(scalar,vector,target){return void 0===target&&(target=new Vec3),target.x=this.x+scalar*vector.x,target.y=this.y+scalar*vector.y,target.z=this.z+scalar*vector.z,target},_proto.dot=function(vector){return this.x*vector.x+this.y*vector.y+this.z*vector.z},_proto.isZero=function(){return 0===this.x&&0===this.y&&0===this.z},_proto.negate=function(target){return void 0===target&&(target=new Vec3),target.x=-this.x,target.y=-this.y,target.z=-this.z,target},_proto.tangents=function(t1,t2){var norm=this.length();if(norm>0){var n=Vec3_tangents_n,inorm=1/norm;n.set(this.x*inorm,this.y*inorm,this.z*inorm);var randVec=Vec3_tangents_randVec;Math.abs(n.x)<.9?(randVec.set(1,0,0),n.cross(randVec,t1)):(randVec.set(0,1,0),n.cross(randVec,t1)),n.cross(t1,t2)}else t1.set(1,0,0),t2.set(0,1,0)},_proto.toString=function(){return this.x+","+this.y+","+this.z},_proto.toArray=function(){return[this.x,this.y,this.z]},_proto.copy=function(vector){return this.x=vector.x,this.y=vector.y,this.z=vector.z,this},_proto.lerp=function(vector,t,target){var x=this.x,y=this.y,z=this.z;target.x=x+(vector.x-x)*t,target.y=y+(vector.y-y)*t,target.z=z+(vector.z-z)*t},_proto.almostEquals=function(vector,precision){return void 0===precision&&(precision=1e-6),!(Math.abs(this.x-vector.x)>precision||Math.abs(this.y-vector.y)>precision||Math.abs(this.z-vector.z)>precision)},_proto.almostZero=function(precision){return void 0===precision&&(precision=1e-6),!(Math.abs(this.x)>precision||Math.abs(this.y)>precision||Math.abs(this.z)>precision)},_proto.isAntiparallelTo=function(vector,precision){return this.negate(antip_neg),antip_neg.almostEquals(vector,precision)},_proto.clone=function(){return new Vec3(this.x,this.y,this.z)},Vec3}();Vec3.ZERO=new Vec3(0,0,0),Vec3.UNIT_X=new Vec3(1,0,0),Vec3.UNIT_Y=new Vec3(0,1,0),Vec3.UNIT_Z=new Vec3(0,0,1);var Vec3_tangents_n=new Vec3,Vec3_tangents_randVec=new Vec3,antip_neg=new Vec3,AABB=function(){function AABB(options){void 0===options&&(options={}),this.lowerBound=new Vec3,this.upperBound=new Vec3,options.lowerBound&&this.lowerBound.copy(options.lowerBound),options.upperBound&&this.upperBound.copy(options.upperBound)}var _proto=AABB.prototype;return _proto.setFromPoints=function(points,position,quaternion,skinSize){var l=this.lowerBound,u=this.upperBound,q=quaternion;l.copy(points[0]),q&&q.vmult(l,l),u.copy(l);for(var i=1;iu.x&&(u.x=p.x),p.xu.y&&(u.y=p.y),p.yu.z&&(u.z=p.z),p.z=u2.x&&l1.y<=l2.y&&u1.y>=u2.y&&l1.z<=l2.z&&u1.z>=u2.z},_proto.getCorners=function(a,b,c,d,e,f,g,h){var l=this.lowerBound,u=this.upperBound;a.copy(l),b.set(u.x,l.y,l.z),c.set(u.x,u.y,l.z),d.set(l.x,u.y,u.z),e.set(u.x,l.y,u.z),f.set(l.x,u.y,l.z),g.set(l.x,l.y,u.z),h.copy(u)},_proto.toLocalFrame=function(frame,target){var corners=transformIntoFrame_corners,a=corners[0],b=corners[1],c=corners[2],d=corners[3],e=corners[4],f=corners[5],g=corners[6],h=corners[7];this.getCorners(a,b,c,d,e,f,g,h);for(var i=0;8!==i;i++){var corner=corners[i];frame.pointToLocal(corner,corner)}return target.setFromPoints(corners)},_proto.toWorldFrame=function(frame,target){var corners=transformIntoFrame_corners,a=corners[0],b=corners[1],c=corners[2],d=corners[3],e=corners[4],f=corners[5],g=corners[6],h=corners[7];this.getCorners(a,b,c,d,e,f,g,h);for(var i=0;8!==i;i++){var corner=corners[i];frame.pointToWorld(corner,corner)}return target.setFromPoints(corners)},_proto.overlapsRay=function(ray){var direction=ray.direction,from=ray.from,dirFracX=1/direction.x,dirFracY=1/direction.y,dirFracZ=1/direction.z,t1=(this.lowerBound.x-from.x)*dirFracX,t2=(this.upperBound.x-from.x)*dirFracX,t3=(this.lowerBound.y-from.y)*dirFracY,t4=(this.upperBound.y-from.y)*dirFracY,t5=(this.lowerBound.z-from.z)*dirFracZ,t6=(this.upperBound.z-from.z)*dirFracZ,tmin=Math.max(Math.max(Math.min(t1,t2),Math.min(t3,t4)),Math.min(t5,t6)),tmax=Math.min(Math.min(Math.max(t1,t2),Math.max(t3,t4)),Math.max(t5,t6));return!(tmax<0)&&!(tmin>tmax)},AABB}(),tmp=new Vec3,transformIntoFrame_corners=[new Vec3,new Vec3,new Vec3,new Vec3,new Vec3,new Vec3,new Vec3,new Vec3],ArrayCollisionMatrix=function(){function ArrayCollisionMatrix(){this.matrix=[]}var _proto=ArrayCollisionMatrix.prototype;return _proto.get=function(bi,bj){var i=bi.index,j=bj.index;if(j>i){var temp=j;j=i,i=temp}return this.matrix[(i*(i+1)>>1)+j-1]},_proto.set=function(bi,bj,value){var i=bi.index,j=bj.index;if(j>i){var temp=j;j=i,i=temp}this.matrix[(i*(i+1)>>1)+j-1]=value?1:0},_proto.reset=function(){for(var i=0,l=this.matrix.length;i!==l;i++)this.matrix[i]=0},_proto.setNumObjects=function(n){this.matrix.length=n*(n-1)>>1},ArrayCollisionMatrix}();function _inheritsLoose(subClass,superClass){subClass.prototype=Object.create(superClass.prototype),subClass.prototype.constructor=subClass,subClass.__proto__=superClass}function _assertThisInitialized(self){if(void 0===self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return self}var EventTarget=function(){function EventTarget(){}var _proto=EventTarget.prototype;return _proto.addEventListener=function(type,listener){void 0===this._listeners&&(this._listeners={});var listeners=this._listeners;return void 0===listeners[type]&&(listeners[type]=[]),listeners[type].includes(listener)||listeners[type].push(listener),this},_proto.hasEventListener=function(type,listener){if(void 0===this._listeners)return!1;var listeners=this._listeners;return!(void 0===listeners[type]||!listeners[type].includes(listener))},_proto.hasAnyEventListener=function(type){return void 0!==this._listeners&&void 0!==this._listeners[type]},_proto.removeEventListener=function(type,listener){if(void 0===this._listeners)return this;var listeners=this._listeners;if(void 0===listeners[type])return this;var index=listeners[type].indexOf(listener);return-1!==index&&listeners[type].splice(index,1),this},_proto.dispatchEvent=function(event){if(void 0===this._listeners)return this;var listenerArray=this._listeners[event.type];if(void 0!==listenerArray){event.target=this;for(var i=0,l=listenerArray.length;i.499&&(heading=2*Math.atan2(x,w),attitude=Math.PI/2,bank=0),test<-.499&&(heading=-2*Math.atan2(x,w),attitude=-Math.PI/2,bank=0),void 0===heading){var sqx=x*x,sqy=y*y,sqz=z*z;heading=Math.atan2(2*y*w-2*x*z,1-2*sqy-2*sqz),attitude=Math.asin(2*test),bank=Math.atan2(2*x*w-2*y*z,1-2*sqx-2*sqz)}break;default:throw new Error("Euler order "+order+" not supported yet.")}target.y=heading,target.z=attitude,target.x=bank},_proto.setFromEuler=function(x,y,z,order){void 0===order&&(order="XYZ");var c1=Math.cos(x/2),c2=Math.cos(y/2),c3=Math.cos(z/2),s1=Math.sin(x/2),s2=Math.sin(y/2),s3=Math.sin(z/2);return"XYZ"===order?(this.x=s1*c2*c3+c1*s2*s3,this.y=c1*s2*c3-s1*c2*s3,this.z=c1*c2*s3+s1*s2*c3,this.w=c1*c2*c3-s1*s2*s3):"YXZ"===order?(this.x=s1*c2*c3+c1*s2*s3,this.y=c1*s2*c3-s1*c2*s3,this.z=c1*c2*s3-s1*s2*c3,this.w=c1*c2*c3+s1*s2*s3):"ZXY"===order?(this.x=s1*c2*c3-c1*s2*s3,this.y=c1*s2*c3+s1*c2*s3,this.z=c1*c2*s3+s1*s2*c3,this.w=c1*c2*c3-s1*s2*s3):"ZYX"===order?(this.x=s1*c2*c3-c1*s2*s3,this.y=c1*s2*c3+s1*c2*s3,this.z=c1*c2*s3-s1*s2*c3,this.w=c1*c2*c3+s1*s2*s3):"YZX"===order?(this.x=s1*c2*c3+c1*s2*s3,this.y=c1*s2*c3+s1*c2*s3,this.z=c1*c2*s3-s1*s2*c3,this.w=c1*c2*c3-s1*s2*s3):"XZY"===order&&(this.x=s1*c2*c3-c1*s2*s3,this.y=c1*s2*c3-s1*c2*s3,this.z=c1*c2*s3+s1*s2*c3,this.w=c1*c2*c3+s1*s2*s3),this},_proto.clone=function(){return new Quaternion(this.x,this.y,this.z,this.w)},_proto.slerp=function(toQuat,t,target){void 0===target&&(target=new Quaternion);var omega,cosom,sinom,scale0,scale1,ax=this.x,ay=this.y,az=this.z,aw=this.w,bx=toQuat.x,by=toQuat.y,bz=toQuat.z,bw=toQuat.w;return(cosom=ax*bx+ay*by+az*bz+aw*bw)<0&&(cosom=-cosom,bx=-bx,by=-by,bz=-bz,bw=-bw),1-cosom>1e-6?(omega=Math.acos(cosom),sinom=Math.sin(omega),scale0=Math.sin((1-t)*omega)/sinom,scale1=Math.sin(t*omega)/sinom):(scale0=1-t,scale1=t),target.x=scale0*ax+scale1*bx,target.y=scale0*ay+scale1*by,target.z=scale0*az+scale1*bz,target.w=scale0*aw+scale1*bw,target},_proto.integrate=function(angularVelocity,dt,angularFactor,target){void 0===target&&(target=new Quaternion);var ax=angularVelocity.x*angularFactor.x,ay=angularVelocity.y*angularFactor.y,az=angularVelocity.z*angularFactor.z,bx=this.x,by=this.y,bz=this.z,bw=this.w,half_dt=.5*dt;return target.x+=half_dt*(ax*bw+ay*bz-az*by),target.y+=half_dt*(ay*bw+az*bx-ax*bz),target.z+=half_dt*(az*bw+ax*by-ay*bx),target.w+=half_dt*(-ax*bx-ay*by-az*bz),target},Quaternion}(),sfv_t1=new Vec3,sfv_t2=new Vec3,SHAPE_TYPES={SPHERE:1,PLANE:2,BOX:4,COMPOUND:8,CONVEXPOLYHEDRON:16,HEIGHTFIELD:32,PARTICLE:64,CYLINDER:128,TRIMESH:256},Shape=function(){function Shape(options){void 0===options&&(options={}),this.id=Shape.idCounter++,this.type=options.type||0,this.boundingSphereRadius=0,this.collisionResponse=!options.collisionResponse||options.collisionResponse,this.collisionFilterGroup=void 0!==options.collisionFilterGroup?options.collisionFilterGroup:1,this.collisionFilterMask=void 0!==options.collisionFilterMask?options.collisionFilterMask:-1,this.material=options.material?options.material:null,this.body=null}var _proto=Shape.prototype;return _proto.updateBoundingSphereRadius=function(){throw"computeBoundingSphereRadius() not implemented for shape type "+this.type},_proto.volume=function(){throw"volume() not implemented for shape type "+this.type},_proto.calculateLocalInertia=function(mass,target){throw"calculateLocalInertia() not implemented for shape type "+this.type},_proto.calculateWorldAABB=function(pos,quat,min,max){throw"calculateWorldAABB() not implemented for shape type "+this.type},Shape}();Shape.idCounter=0,Shape.types=SHAPE_TYPES;var Transform=function(){function Transform(options){void 0===options&&(options={}),this.position=new Vec3,this.quaternion=new Quaternion,options.position&&this.position.copy(options.position),options.quaternion&&this.quaternion.copy(options.quaternion)}var _proto=Transform.prototype;return _proto.pointToLocal=function(worldPoint,result){return Transform.pointToLocalFrame(this.position,this.quaternion,worldPoint,result)},_proto.pointToWorld=function(localPoint,result){return Transform.pointToWorldFrame(this.position,this.quaternion,localPoint,result)},_proto.vectorToWorldFrame=function(localVector,result){return void 0===result&&(result=new Vec3),this.quaternion.vmult(localVector,result),result},Transform.pointToLocalFrame=function(position,quaternion,worldPoint,result){return void 0===result&&(result=new Vec3),worldPoint.vsub(position,result),quaternion.conjugate(tmpQuat),tmpQuat.vmult(result,result),result},Transform.pointToWorldFrame=function(position,quaternion,localPoint,result){return void 0===result&&(result=new Vec3),quaternion.vmult(localPoint,result),result.vadd(position,result),result},Transform.vectorToWorldFrame=function(quaternion,localVector,result){return void 0===result&&(result=new Vec3),quaternion.vmult(localVector,result),result},Transform.vectorToLocalFrame=function(position,quaternion,worldVector,result){return void 0===result&&(result=new Vec3),quaternion.w*=-1,quaternion.vmult(worldVector,result),quaternion.w*=-1,result},Transform}(),tmpQuat=new Quaternion,ConvexPolyhedron=function(_Shape){function ConvexPolyhedron(props){var _this;void 0===props&&(props={});var _props=props,_props$vertices=_props.vertices,vertices=void 0===_props$vertices?[]:_props$vertices,_props$faces=_props.faces,faces=void 0===_props$faces?[]:_props$faces,_props$normals=_props.normals,normals=void 0===_props$normals?[]:_props$normals,axes=_props.axes,boundingSphereRadius=_props.boundingSphereRadius;return(_this=_Shape.call(this,{type:Shape.types.CONVEXPOLYHEDRON})||this).vertices=vertices,_this.faces=faces,_this.faceNormals=normals,0===_this.faceNormals.length&&_this.computeNormals(),boundingSphereRadius?_this.boundingSphereRadius=boundingSphereRadius:_this.updateBoundingSphereRadius(),_this.worldVertices=[],_this.worldVerticesNeedsUpdate=!0,_this.worldFaceNormals=[],_this.worldFaceNormalsNeedsUpdate=!0,_this.uniqueAxes=axes?axes.slice():null,_this.uniqueEdges=[],_this.computeEdges(),_this}_inheritsLoose(ConvexPolyhedron,_Shape);var _proto=ConvexPolyhedron.prototype;return _proto.computeEdges=function(){var faces=this.faces,vertices=this.vertices,edges=this.uniqueEdges;edges.length=0;for(var edge=new Vec3,i=0;i!==faces.length;i++)for(var face=faces[i],numVertices=face.length,j=0;j!==numVertices;j++){var k=(j+1)%numVertices;vertices[face[j]].vsub(vertices[face[k]],edge),edge.normalize();for(var found=!1,p=0;p!==edges.length;p++)if(edges[p].almostEquals(edge)||edges[p].almostEquals(edge)){found=!0;break}found||edges.push(edge.clone())}},_proto.computeNormals=function(){this.faceNormals.length=this.faces.length;for(var i=0;idmax&&(dmax=d,closestFaceB=face)}for(var worldVertsB1=[],i=0;i=0&&this.clipFaceAgainstHull(separatingNormal,posA,quatA,worldVertsB1,minDist,maxDist,result)},_proto.findSeparatingAxis=function(hullB,posA,quatA,posB,quatB,target,faceListA,faceListB){var faceANormalWS3=new Vec3,Worldnormal1=new Vec3,deltaC=new Vec3,worldEdge0=new Vec3,worldEdge1=new Vec3,Cross=new Vec3,dmin=Number.MAX_VALUE;if(this.uniqueAxes)for(var _i=0;_i!==this.uniqueAxes.length;_i++){quatA.vmult(this.uniqueAxes[_i],faceANormalWS3);var _d=this.testSepAxis(faceANormalWS3,hullB,posA,quatA,posB,quatB);if(!1===_d)return!1;_d0&&target.negate(target),!0},_proto.testSepAxis=function(axis,hullB,posA,quatA,posB,quatB){ConvexPolyhedron.project(this,axis,posA,quatA,maxminA),ConvexPolyhedron.project(hullB,axis,posB,quatB,maxminB);var maxA=maxminA[0],minA=maxminA[1],maxB=maxminB[0],minB=maxminB[1];if(maxA0?1/mass:0,_this.material=options.material||null,_this.linearDamping="number"==typeof options.linearDamping?options.linearDamping:.01,_this.type=mass<=0?Body.STATIC:Body.DYNAMIC,typeof options.type==typeof Body.STATIC&&(_this.type=options.type),_this.allowSleep=void 0===options.allowSleep||options.allowSleep,_this.sleepState=0,_this.sleepSpeedLimit=void 0!==options.sleepSpeedLimit?options.sleepSpeedLimit:.1,_this.sleepTimeLimit=void 0!==options.sleepTimeLimit?options.sleepTimeLimit:1,_this.timeLastSleepy=0,_this.wakeUpAfterNarrowphase=!1,_this.torque=new Vec3,_this.quaternion=new Quaternion,_this.initQuaternion=new Quaternion,_this.previousQuaternion=new Quaternion,_this.interpolatedQuaternion=new Quaternion,options.quaternion&&(_this.quaternion.copy(options.quaternion),_this.initQuaternion.copy(options.quaternion),_this.previousQuaternion.copy(options.quaternion),_this.interpolatedQuaternion.copy(options.quaternion)),_this.angularVelocity=new Vec3,options.angularVelocity&&_this.angularVelocity.copy(options.angularVelocity),_this.initAngularVelocity=new Vec3,_this.shapes=[],_this.shapeOffsets=[],_this.shapeOrientations=[],_this.inertia=new Vec3,_this.invInertia=new Vec3,_this.invInertiaWorld=new Mat3,_this.invMassSolve=0,_this.invInertiaSolve=new Vec3,_this.invInertiaWorldSolve=new Mat3,_this.fixedRotation=void 0!==options.fixedRotation&&options.fixedRotation,_this.angularDamping=void 0!==options.angularDamping?options.angularDamping:.01,_this.linearFactor=new Vec3(1,1,1),options.linearFactor&&_this.linearFactor.copy(options.linearFactor),_this.angularFactor=new Vec3(1,1,1),options.angularFactor&&_this.angularFactor.copy(options.angularFactor),_this.aabb=new AABB,_this.aabbNeedsUpdate=!0,_this.boundingRadius=0,_this.wlambda=new Vec3,options.shape&&_this.addShape(options.shape),_this.updateMassProperties(),_this}_inheritsLoose(Body,_EventTarget);var _proto=Body.prototype;return _proto.wakeUp=function(){var prevState=this.sleepState;this.sleepState=0,this.wakeUpAfterNarrowphase=!1,prevState===Body.SLEEPING&&this.dispatchEvent(Body.wakeupEvent)},_proto.sleep=function(){this.sleepState=Body.SLEEPING,this.velocity.set(0,0,0),this.angularVelocity.set(0,0,0),this.wakeUpAfterNarrowphase=!1},_proto.sleepTick=function(time){if(this.allowSleep){var sleepState=this.sleepState,speedSquared=this.velocity.lengthSquared()+this.angularVelocity.lengthSquared(),speedLimitSquared=Math.pow(this.sleepSpeedLimit,2);sleepState===Body.AWAKE&&speedSquaredspeedLimitSquared?this.wakeUp():sleepState===Body.SLEEPY&&time-this.timeLastSleepy>this.sleepTimeLimit&&(this.sleep(),this.dispatchEvent(Body.sleepEvent))}},_proto.updateSolveMassProperties=function(){this.sleepState===Body.SLEEPING||this.type===Body.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve.setZero(),this.invInertiaWorldSolve.setZero()):(this.invMassSolve=this.invMass,this.invInertiaSolve.copy(this.invInertia),this.invInertiaWorldSolve.copy(this.invInertiaWorld))},_proto.pointToLocalFrame=function(worldPoint,result){return void 0===result&&(result=new Vec3),worldPoint.vsub(this.position,result),this.quaternion.conjugate().vmult(result,result),result},_proto.vectorToLocalFrame=function(worldVector,result){return void 0===result&&(result=new Vec3),this.quaternion.conjugate().vmult(worldVector,result),result},_proto.pointToWorldFrame=function(localPoint,result){return void 0===result&&(result=new Vec3),this.quaternion.vmult(localPoint,result),result.vadd(this.position,result),result},_proto.vectorToWorldFrame=function(localVector,result){return void 0===result&&(result=new Vec3),this.quaternion.vmult(localVector,result),result},_proto.addShape=function(shape,_offset,_orientation){var offset=new Vec3,orientation=new Quaternion;return _offset&&offset.copy(_offset),_orientation&&orientation.copy(_orientation),this.shapes.push(shape),this.shapeOffsets.push(offset),this.shapeOrientations.push(orientation),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0,shape.body=this,this},_proto.updateBoundingRadius=function(){for(var shapes=this.shapes,shapeOffsets=this.shapeOffsets,N=shapes.length,radius=0,i=0;i!==N;i++){var shape=shapes[i];shape.updateBoundingSphereRadius();var offset=shapeOffsets[i].length(),r=shape.boundingSphereRadius;offset+r>radius&&(radius=offset+r)}this.boundingRadius=radius},_proto.computeAABB=function(){for(var shapes=this.shapes,shapeOffsets=this.shapeOffsets,shapeOrientations=this.shapeOrientations,N=shapes.length,offset=tmpVec,orientation=tmpQuat$1,bodyQuat=this.quaternion,aabb=this.aabb,shapeAABB=computeAABB_shapeAABB,i=0;i!==N;i++){var shape=shapes[i];bodyQuat.vmult(shapeOffsets[i],offset),offset.vadd(this.position,offset),bodyQuat.mult(shapeOrientations[i],orientation),shape.calculateWorldAABB(offset,orientation,shapeAABB.lowerBound,shapeAABB.upperBound),0===i?aabb.copy(shapeAABB):aabb.extend(shapeAABB)}this.aabbNeedsUpdate=!1},_proto.updateInertiaWorld=function(force){var I=this.invInertia;if(I.x!==I.y||I.y!==I.z||force){var m1=uiw_m1,m2=uiw_m2;m1.setRotationFromQuaternion(this.quaternion),m1.transpose(m2),m1.scale(I,m1),m1.mmult(m2,this.invInertiaWorld)}else;},_proto.applyForce=function(force,relativePoint){if(this.type===Body.DYNAMIC){var rotForce=Body_applyForce_rotForce;relativePoint.cross(force,rotForce),this.force.vadd(force,this.force),this.torque.vadd(rotForce,this.torque)}},_proto.applyLocalForce=function(localForce,localPoint){if(this.type===Body.DYNAMIC){var worldForce=Body_applyLocalForce_worldForce,relativePointWorld=Body_applyLocalForce_relativePointWorld;this.vectorToWorldFrame(localForce,worldForce),this.vectorToWorldFrame(localPoint,relativePointWorld),this.applyForce(worldForce,relativePointWorld)}},_proto.applyImpulse=function(impulse,relativePoint){if(this.type===Body.DYNAMIC){var r=relativePoint,velo=Body_applyImpulse_velo;velo.copy(impulse),velo.scale(this.invMass,velo),this.velocity.vadd(velo,this.velocity);var rotVelo=Body_applyImpulse_rotVelo;r.cross(impulse,rotVelo),this.invInertiaWorld.vmult(rotVelo,rotVelo),this.angularVelocity.vadd(rotVelo,this.angularVelocity)}},_proto.applyLocalImpulse=function(localImpulse,localPoint){if(this.type===Body.DYNAMIC){var worldImpulse=Body_applyLocalImpulse_worldImpulse,relativePointWorld=Body_applyLocalImpulse_relativePoint;this.vectorToWorldFrame(localImpulse,worldImpulse),this.vectorToWorldFrame(localPoint,relativePointWorld),this.applyImpulse(worldImpulse,relativePointWorld)}},_proto.updateMassProperties=function(){var halfExtents=Body_updateMassProperties_halfExtents;this.invMass=this.mass>0?1/this.mass:0;var I=this.inertia,fixed=this.fixedRotation;this.computeAABB(),halfExtents.set((this.aabb.upperBound.x-this.aabb.lowerBound.x)/2,(this.aabb.upperBound.y-this.aabb.lowerBound.y)/2,(this.aabb.upperBound.z-this.aabb.lowerBound.z)/2),Box.calculateInertia(halfExtents,this.mass,I),this.invInertia.set(I.x>0&&!fixed?1/I.x:0,I.y>0&&!fixed?1/I.y:0,I.z>0&&!fixed?1/I.z:0),this.updateInertiaWorld(!0)},_proto.getVelocityAtWorldPoint=function(worldPoint,result){var r=new Vec3;return worldPoint.vsub(this.position,r),this.angularVelocity.cross(r,result),this.velocity.vadd(result,result),result},_proto.integrate=function(dt,quatNormalize,quatNormalizeFast){if(this.previousPosition.copy(this.position),this.previousQuaternion.copy(this.quaternion),(this.type===Body.DYNAMIC||this.type===Body.KINEMATIC)&&this.sleepState!==Body.SLEEPING){var velo=this.velocity,angularVelo=this.angularVelocity,pos=this.position,force=this.force,torque=this.torque,quat=this.quaternion,invMass=this.invMass,invInertia=this.invInertiaWorld,linearFactor=this.linearFactor,iMdt=invMass*dt;velo.x+=force.x*iMdt*linearFactor.x,velo.y+=force.y*iMdt*linearFactor.y,velo.z+=force.z*iMdt*linearFactor.z;var e=invInertia.elements,angularFactor=this.angularFactor,tx=torque.x*angularFactor.x,ty=torque.y*angularFactor.y,tz=torque.z*angularFactor.z;angularVelo.x+=dt*(e[0]*tx+e[1]*ty+e[2]*tz),angularVelo.y+=dt*(e[3]*tx+e[4]*ty+e[5]*tz),angularVelo.z+=dt*(e[6]*tx+e[7]*ty+e[8]*tz),pos.x+=velo.x*dt,pos.y+=velo.y*dt,pos.z+=velo.z*dt,quat.integrate(this.angularVelocity,dt,this.angularFactor,quat),quatNormalize&&(quatNormalizeFast?quat.normalizeFast():quat.normalize()),this.aabbNeedsUpdate=!0,this.updateInertiaWorld()}},Body}(EventTarget);Body.COLLIDE_EVENT_NAME="collide",Body.DYNAMIC=1,Body.STATIC=2,Body.KINEMATIC=4,Body.AWAKE=BODY_SLEEP_STATES.AWAKE,Body.SLEEPY=BODY_SLEEP_STATES.SLEEPY,Body.SLEEPING=BODY_SLEEP_STATES.SLEEPING,Body.idCounter=0,Body.wakeupEvent={type:"wakeup"},Body.sleepyEvent={type:"sleepy"},Body.sleepEvent={type:"sleep"};var tmpVec=new Vec3,tmpQuat$1=new Quaternion,computeAABB_shapeAABB=new AABB,uiw_m1=new Mat3,uiw_m2=new Mat3,Body_applyForce_rotForce=(new Mat3,new Vec3),Body_applyLocalForce_worldForce=new Vec3,Body_applyLocalForce_relativePointWorld=new Vec3,Body_applyImpulse_velo=new Vec3,Body_applyImpulse_rotVelo=new Vec3,Body_applyLocalImpulse_worldImpulse=new Vec3,Body_applyLocalImpulse_relativePoint=new Vec3,Body_updateMassProperties_halfExtents=new Vec3,Broadphase=function(){function Broadphase(){this.world=null,this.useBoundingBoxes=!1,this.dirty=!0}var _proto=Broadphase.prototype;return _proto.collisionPairs=function(world,p1,p2){throw new Error("collisionPairs not implemented for this BroadPhase class!")},_proto.needBroadphaseCollision=function(bodyA,bodyB){return 0!=(bodyA.collisionFilterGroup&bodyB.collisionFilterMask)&&0!=(bodyB.collisionFilterGroup&bodyA.collisionFilterMask)&&(0==(bodyA.type&Body.STATIC)&&bodyA.sleepState!==Body.SLEEPING||0==(bodyB.type&Body.STATIC)&&bodyB.sleepState!==Body.SLEEPING)},_proto.intersectionTest=function(bodyA,bodyB,pairs1,pairs2){this.useBoundingBoxes?this.doBoundingBoxBroadphase(bodyA,bodyB,pairs1,pairs2):this.doBoundingSphereBroadphase(bodyA,bodyB,pairs1,pairs2)},_proto.doBoundingSphereBroadphase=function(bodyA,bodyB,pairs1,pairs2){var r=Broadphase_collisionPairs_r;bodyB.position.vsub(bodyA.position,r);var boundingRadiusSum2=Math.pow(bodyA.boundingRadius+bodyB.boundingRadius,2);r.lengthSquared()dist.lengthSquared()};var GridBroadphase=function(_Broadphase){function GridBroadphase(aabbMin,aabbMax,nx,ny,nz){var _this;void 0===aabbMin&&(aabbMin=new Vec3(100,100,100)),void 0===aabbMax&&(aabbMax=new Vec3(-100,-100,-100)),void 0===nx&&(nx=10),void 0===ny&&(ny=10),void 0===nz&&(nz=10),(_this=_Broadphase.call(this)||this).nx=nx,_this.ny=ny,_this.nz=nz,_this.aabbMin=aabbMin,_this.aabbMax=aabbMax;var nbins=_this.nx*_this.ny*_this.nz;if(nbins<=0)throw"GridBroadphase: Each dimension's n must be >0";_this.bins=[],_this.binLengths=[],_this.bins.length=nbins,_this.binLengths.length=nbins;for(var i=0;i=nx&&(xoff0=nx-1),yoff0<0?yoff0=0:yoff0>=ny&&(yoff0=ny-1),zoff0<0?zoff0=0:zoff0>=nz&&(zoff0=nz-1),xoff1<0?xoff1=0:xoff1>=nx&&(xoff1=nx-1),yoff1<0?yoff1=0:yoff1>=ny&&(yoff1=ny-1),zoff1<0?zoff1=0:zoff1>=nz&&(zoff1=nz-1),yoff0*=ystep,zoff0*=zstep,xoff1*=xstep,yoff1*=ystep,zoff1*=zstep;for(var xoff=xoff0*=xstep;xoff<=xoff1;xoff+=xstep)for(var yoff=yoff0;yoff<=yoff1;yoff+=ystep)for(var zoff=zoff0;zoff<=zoff1;zoff+=zstep){var idx=xoff+yoff+zoff;bins[idx][binLengths[idx]++]=bi}}for(var _i=0;_i!==N;_i++){var bi=bodies[_i],si=bi.shapes[0];switch(si.type){case SPHERE:var shape=si,x=bi.position.x,y=bi.position.y,z=bi.position.z,r=shape.radius;addBoxToBins(x-r,y-r,z-r,x+r,y+r,z+r,bi);break;case PLANE:var _shape=si;_shape.worldNormalNeedsUpdate&&_shape.computeWorldNormal(bi.quaternion);var planeNormal=_shape.worldNormal,xreset=xmin+.5*binsizeX-bi.position.x,yreset=ymin+.5*binsizeY-bi.position.y,zreset=zmin+.5*binsizeZ-bi.position.z,d=GridBroadphase_collisionPairs_d;d.set(xreset,yreset,zreset);for(var xi=0,xoff=0;xi!==nx;xi++,xoff+=xstep,d.y=yreset,d.x+=binsizeX)for(var yi=0,yoff=0;yi!==ny;yi++,yoff+=ystep,d.z=zreset,d.y+=binsizeY)for(var zi=0,zoff=0;zi!==nz;zi++,zoff+=zstep,d.z+=binsizeZ)if(d.dot(planeNormal)1)for(var bin=bins[_i2],_xi=0;_xi!==binLength;_xi++)for(var _bi=bin[_xi],_yi=0;_yi!==_xi;_yi++){var bj=bin[_yi];this.needBroadphaseCollision(_bi,bj)&&this.intersectionTest(_bi,bj,pairs1,pairs2)}}this.makePairsUnique(pairs1,pairs2)},GridBroadphase}(Broadphase),GridBroadphase_collisionPairs_d=new Vec3,NaiveBroadphase=(new Vec3,function(_Broadphase){function NaiveBroadphase(){return _Broadphase.call(this)||this}_inheritsLoose(NaiveBroadphase,_Broadphase);var _proto=NaiveBroadphase.prototype;return _proto.collisionPairs=function(world,pairs1,pairs2){for(var bi,bj,bodies=world.bodies,n=bodies.length,i=0;i!==n;i++)for(var j=0;j!==i;j++)bi=bodies[i],bj=bodies[j],this.needBroadphaseCollision(bi,bj)&&this.intersectionTest(bi,bj,pairs1,pairs2)},_proto.aabbQuery=function(world,aabb,result){void 0===result&&(result=[]);for(var i=0;ishape.boundingSphereRadius)){var intersectMethod=this[shape.type];intersectMethod&&intersectMethod.call(this,shape,quat,position,body,shape)}},_proto._intersectBox=function(box,quat,position,body,reportedShape){return this._intersectConvex(box.convexPolyhedronRepresentation,quat,position,body,reportedShape)},_proto._intersectPlane=function(shape,quat,position,body,reportedShape){var from=this.from,to=this.to,direction=this.direction,worldNormal=new Vec3(0,0,1);quat.vmult(worldNormal,worldNormal);var len=new Vec3;from.vsub(position,len);var planeToFrom=len.dot(worldNormal);if(to.vsub(position,len),!(planeToFrom*len.dot(worldNormal)>0||from.distanceTo(to)=0&&d1<=1&&(from.lerp(to,d1,intersectionPoint),intersectionPoint.vsub(position,normal),normal.normalize(),this.reportIntersection(normal,intersectionPoint,reportedShape,body,-1)),this.result.shouldStop)return;d2>=0&&d2<=1&&(from.lerp(to,d2,intersectionPoint),intersectionPoint.vsub(position,normal),normal.normalize(),this.reportIntersection(normal,intersectionPoint,reportedShape,body,-1))}},_proto._intersectConvex=function(shape,quat,position,body,reportedShape,options){for(var normal=intersectConvex_normal,vector=intersectConvex_vector,faceList=options&&options.faceList||null,faces=shape.faces,vertices=shape.vertices,normals=shape.faceNormals,direction=this.direction,from=this.from,to=this.to,fromToDistance=from.distanceTo(to),Nfaces=faceList?faceList.length:faces.length,result=this.result,j=0;!result.shouldStop&&jfromToDistance||this.reportIntersection(normal,intersectPoint,reportedShape,body,fi)}}}}},_proto._intersectTrimesh=function(mesh,quat,position,body,reportedShape,options){var normal=intersectTrimesh_normal,triangles=intersectTrimesh_triangles,treeTransform=intersectTrimesh_treeTransform,vector=intersectConvex_vector,localDirection=intersectTrimesh_localDirection,localFrom=intersectTrimesh_localFrom,localTo=intersectTrimesh_localTo,worldIntersectPoint=intersectTrimesh_worldIntersectPoint,worldNormal=intersectTrimesh_worldNormal,indices=(options&&options.faceList,mesh.indices),from=(mesh.vertices,this.from),to=this.to,direction=this.direction;treeTransform.position.copy(position),treeTransform.quaternion.copy(quat),Transform.vectorToLocalFrame(position,quat,direction,localDirection),Transform.pointToLocalFrame(position,quat,from,localFrom),Transform.pointToLocalFrame(position,quat,to,localTo),localTo.x*=mesh.scale.x,localTo.y*=mesh.scale.y,localTo.z*=mesh.scale.z,localFrom.x*=mesh.scale.x,localFrom.y*=mesh.scale.y,localFrom.z*=mesh.scale.z,localTo.vsub(localFrom,localDirection),localDirection.normalize();var fromToDistanceSquared=localFrom.distanceSquared(localTo);mesh.tree.rayQuery(this,treeTransform,triangles);for(var i=0,N=triangles.length;!this.result.shouldStop&&i!==N;i++){var trianglesIndex=triangles[i];mesh.getNormal(trianglesIndex,normal),mesh.getVertex(indices[3*trianglesIndex],a),a.vsub(localFrom,vector);var dot=localDirection.dot(normal),scalar=normal.dot(vector)/dot;if(!(scalar<0)){localDirection.scale(scalar,intersectPoint),intersectPoint.vadd(localFrom,intersectPoint),mesh.getVertex(indices[3*trianglesIndex+1],b),mesh.getVertex(indices[3*trianglesIndex+2],c);var squaredDistance=intersectPoint.distanceSquared(localFrom);!pointInTriangle(intersectPoint,b,a,c)&&!pointInTriangle(intersectPoint,a,b,c)||squaredDistance>fromToDistanceSquared||(Transform.vectorToWorldFrame(quat,normal,worldNormal),Transform.pointToWorldFrame(position,quat,intersectPoint,worldIntersectPoint),this.reportIntersection(worldNormal,worldIntersectPoint,reportedShape,body,trianglesIndex))}}triangles.length=0},_proto.reportIntersection=function(normal,hitPointWorld,shape,body,hitFaceIndex){var from=this.from,to=this.to,distance=from.distanceTo(hitPointWorld),result=this.result;if(!(this.skipBackfaces&&normal.dot(this.direction)>0))switch(result.hitFaceIndex=void 0!==hitFaceIndex?hitFaceIndex:-1,this.mode){case Ray.ALL:this.hasHit=!0,result.set(from,to,normal,hitPointWorld,shape,body,distance),result.hasHit=!0,this.callback(result);break;case Ray.CLOSEST:(distance=0&&(v=dot00*dot12-dot01*dot02)>=0&&u+vvarianceY?varianceX>varianceZ?0:2:varianceY>varianceZ?1:2},_proto.aabbQuery=function(world,aabb,result){void 0===result&&(result=[]),this.dirty&&(this.sortList(),this.dirty=!1);var axisIndex=this.axisIndex,axis="x";1===axisIndex&&(axis="y"),2===axisIndex&&(axis="z");for(var axisList=this.axisList,i=(aabb.lowerBound[axis],aabb.upperBound[axis],0);i=0&&!(a[j].aabb.lowerBound.x<=v.aabb.lowerBound.x);j--)a[j+1]=a[j];a[j+1]=v}return a},SAPBroadphase.insertionSortY=function(a){for(var i=1,l=a.length;i=0&&!(a[j].aabb.lowerBound.y<=v.aabb.lowerBound.y);j--)a[j+1]=a[j];a[j+1]=v}return a},SAPBroadphase.insertionSortZ=function(a){for(var i=1,l=a.length;i=0&&!(a[j].aabb.lowerBound.z<=v.aabb.lowerBound.z);j--)a[j+1]=a[j];a[j+1]=v}return a},SAPBroadphase.checkBounds=function(bi,bj,axisIndex){var biPos,bjPos;0===axisIndex?(biPos=bi.position.x,bjPos=bj.position.x):1===axisIndex?(biPos=bi.position.y,bjPos=bj.position.y):2===axisIndex&&(biPos=bi.position.z,bjPos=bj.position.z);var ri=bi.boundingRadius;return bjPos-bj.boundingRadius=-.1)this.suspensionRelativeVelocity=0,this.clippedInvContactDotSuspension=10;else{var inv=-1/project;this.suspensionRelativeVelocity=projVel*inv,this.clippedInvContactDotSuspension=inv}}else raycastResult.suspensionLength=this.suspensionRestLength,this.suspensionRelativeVelocity=0,raycastResult.directionWorld.scale(-1,raycastResult.hitNormalWorld),this.clippedInvContactDotSuspension=1},WheelInfo}(),chassis_velocity_at_contactPoint=new Vec3,relpos=new Vec3,RaycastVehicle=function(){function RaycastVehicle(options){this.chassisBody=options.chassisBody,this.wheelInfos=[],this.sliding=!1,this.world=null,this.indexRightAxis=void 0!==options.indexRightAxis?options.indexRightAxis:1,this.indexForwardAxis=void 0!==options.indexForwardAxis?options.indexForwardAxis:0,this.indexUpAxis=void 0!==options.indexUpAxis?options.indexUpAxis:2,this.constraints=[],this.preStepCallback=function(){},this.currentVehicleSpeedKmHour=0}var _proto=RaycastVehicle.prototype;return _proto.addWheel=function(options){void 0===options&&(options={});var info=new WheelInfo(options),index=this.wheelInfos.length;return this.wheelInfos.push(info),index},_proto.setSteeringValue=function(value,wheelIndex){this.wheelInfos[wheelIndex].steering=value},_proto.applyEngineForce=function(value,wheelIndex){this.wheelInfos[wheelIndex].engineForce=value},_proto.setBrake=function(brake,wheelIndex){this.wheelInfos[wheelIndex].brake=brake},_proto.addToWorld=function(world){this.constraints;world.addBody(this.chassisBody);var that=this;this.preStepCallback=function(){that.updateVehicle(world.dt)},world.addEventListener("preStep",this.preStepCallback),this.world=world},_proto.getVehicleAxisWorld=function(axisIndex,result){result.set(0===axisIndex?1:0,1===axisIndex?1:0,2===axisIndex?1:0),this.chassisBody.vectorToWorldFrame(result,result)},_proto.updateVehicle=function(timeStep){for(var wheelInfos=this.wheelInfos,numWheels=wheelInfos.length,chassisBody=this.chassisBody,i=0;iwheel.maxSuspensionForce&&(suspensionForce=wheel.maxSuspensionForce),wheel.raycastResult.hitNormalWorld.scale(suspensionForce*timeStep,impulse),wheel.raycastResult.hitPointWorld.vsub(chassisBody.position,relpos),chassisBody.applyImpulse(impulse,relpos)}this.updateFriction(timeStep);for(var hitNormalWorldScaledWithProj=new Vec3,fwd=new Vec3,vel=new Vec3,_i3=0;_i30?1:-1)*_wheel.customSlidingRotationalSpeed*timeStep),Math.abs(_wheel.brake)>Math.abs(_wheel.engineForce)&&(_wheel.deltaRotation=0),_wheel.rotation+=_wheel.deltaRotation,_wheel.deltaRotation*=.99}},_proto.updateSuspension=function(deltaTime){for(var chassisMass=this.chassisBody.mass,wheelInfos=this.wheelInfos,numWheels=wheelInfos.length,w_it=0;w_itmaxSuspensionLength&&(wheel.suspensionLength=maxSuspensionLength,wheel.raycastResult.reset());var denominator=wheel.raycastResult.hitNormalWorld.dot(wheel.directionWorld),chassis_velocity_at_contactPoint=new Vec3;chassisBody.getVelocityAtWorldPoint(wheel.raycastResult.hitPointWorld,chassis_velocity_at_contactPoint);var projVel=wheel.raycastResult.hitNormalWorld.dot(chassis_velocity_at_contactPoint);if(denominator>=-.1)wheel.suspensionRelativeVelocity=0,wheel.clippedInvContactDotSuspension=10;else{var inv=-1/denominator;wheel.suspensionRelativeVelocity=projVel*inv,wheel.clippedInvContactDotSuspension=inv}}else wheel.suspensionLength=wheel.suspensionRestLength+0*wheel.maxSuspensionTravel,wheel.suspensionRelativeVelocity=0,wheel.directionWorld.scale(-1,wheel.raycastResult.hitNormalWorld),wheel.clippedInvContactDotSuspension=1;return depth},_proto.updateWheelTransformWorld=function(wheel){wheel.isInContact=!1;var chassisBody=this.chassisBody;chassisBody.pointToWorldFrame(wheel.chassisConnectionPointLocal,wheel.chassisConnectionPointWorld),chassisBody.vectorToWorldFrame(wheel.directionLocal,wheel.directionWorld),chassisBody.vectorToWorldFrame(wheel.axleLocal,wheel.axleWorld)},_proto.updateWheelTransform=function(wheelIndex){var up=tmpVec4,right=tmpVec5,fwd=tmpVec6,wheel=this.wheelInfos[wheelIndex];this.updateWheelTransformWorld(wheel),wheel.directionLocal.scale(-1,up),right.copy(wheel.axleLocal),up.cross(right,fwd),fwd.normalize(),right.normalize();var steering=wheel.steering,steeringOrn=new Quaternion;steeringOrn.setFromAxisAngle(up,steering);var rotatingOrn=new Quaternion;rotatingOrn.setFromAxisAngle(right,wheel.rotation);var q=wheel.worldTransform.quaternion;this.chassisBody.quaternion.mult(steeringOrn,q),q.mult(rotatingOrn,q),q.normalize();var p=wheel.worldTransform.position;p.copy(wheel.directionWorld),p.scale(wheel.suspensionLength,p),p.vadd(wheel.chassisConnectionPointWorld,p)},_proto.getWheelTransformWorld=function(wheelIndex){return this.wheelInfos[wheelIndex].worldTransform},_proto.updateFriction=function(timeStep){for(var surfNormalWS_scaled_proj=updateFriction_surfNormalWS_scaled_proj,wheelInfos=this.wheelInfos,numWheels=wheelInfos.length,chassisBody=this.chassisBody,forwardWS=updateFriction_forwardWS,axle=updateFriction_axle,i=0;imaximpSquared){this.sliding=!0,_wheel3.sliding=!0;var _factor=maximp/Math.sqrt(impulseSquared);_wheel3.skidInfo*=_factor}}}if(this.sliding)for(var _i6=0;_i61.1)return 0;var vel1=resolveSingleBilateral_vel1,vel2=resolveSingleBilateral_vel2,vel=resolveSingleBilateral_vel;body1.getVelocityAtWorldPoint(pos1,vel1),body2.getVelocityAtWorldPoint(pos2,vel2),vel1.vsub(vel2,vel);return-.2*normal.dot(vel)*(1/(body1.invMass+body2.invMass))}var Sphere=function(_Shape){function Sphere(radius){var _this;if((_this=_Shape.call(this,{type:Shape.types.SPHERE})||this).radius=void 0!==radius?radius:1,_this.radius<0)throw new Error("The sphere radius cannot be negative.");return _this.updateBoundingSphereRadius(),_this}_inheritsLoose(Sphere,_Shape);var _proto=Sphere.prototype;return _proto.calculateLocalInertia=function(mass,target){void 0===target&&(target=new Vec3);var I=2*mass*this.radius*this.radius/5;return target.x=I,target.y=I,target.z=I,target},_proto.volume=function(){return 4*Math.PI*Math.pow(this.radius,3)/3},_proto.updateBoundingSphereRadius=function(){this.boundingSphereRadius=this.radius},_proto.calculateWorldAABB=function(pos,quat,min,max){for(var r=this.radius,axes=["x","y","z"],i=0;ithis.particles.length&&this.neighbors.pop())},_proto.getNeighbors=function(particle,neighbors){for(var N=this.particles.length,id=particle.id,R2=this.smoothingRadius*this.smoothingRadius,dist=SPHSystem_getNeighbors_dist,i=0;i!==N;i++){var p=this.particles[i];p.position.vsub(particle.position,dist),id!==p.id&&dist.lengthSquared()maxValue&&(maxValue=v)}this.maxValue=maxValue},_proto.setHeightValueAtIndex=function(xi,yi,value){this.data[xi][yi]=value,this.clearCachedConvexTrianglePillar(xi,yi,!1),xi>0&&(this.clearCachedConvexTrianglePillar(xi-1,yi,!0),this.clearCachedConvexTrianglePillar(xi-1,yi,!1)),yi>0&&(this.clearCachedConvexTrianglePillar(xi,yi-1,!0),this.clearCachedConvexTrianglePillar(xi,yi-1,!1)),yi>0&&xi>0&&this.clearCachedConvexTrianglePillar(xi-1,yi-1,!0)},_proto.getRectMinMax=function(iMinX,iMinY,iMaxX,iMaxY,result){void 0===result&&(result=[]);for(var data=this.data,max=this.minValue,i=iMinX;i<=iMaxX;i++)for(var j=iMinY;j<=iMaxY;j++){var height=data[i][j];height>max&&(max=height)}result[0]=this.minValue,result[1]=max},_proto.getIndexOfPosition=function(x,y,result,clamp){var w=this.elementSize,data=this.data,xi=Math.floor(x/w),yi=Math.floor(y/w);return result[0]=xi,result[1]=yi,clamp&&(xi<0&&(xi=0),yi<0&&(yi=0),xi>=data.length-1&&(xi=data.length-1),yi>=data[0].length-1&&(yi=data[0].length-1)),!(xi<0||yi<0||xi>=data.length-1||yi>=data[0].length-1)},_proto.getTriangleAt=function(x,y,edgeClamp,a,b,c){var idx=getHeightAt_idx;this.getIndexOfPosition(x,y,idx,edgeClamp);var xi=idx[0],yi=idx[1],data=this.data;edgeClamp&&(xi=Math.min(data.length-2,Math.max(0,xi)),yi=Math.min(data[0].length-2,Math.max(0,yi)));var elementSize=this.elementSize,upper=Math.pow(x/elementSize-xi,2)+Math.pow(y/elementSize-yi,2)>Math.pow(x/elementSize-(xi+1),2)+Math.pow(y/elementSize-(yi+1),2);return this.getTriangle(xi,yi,upper,a,b,c),upper},_proto.getNormalAt=function(x,y,edgeClamp,result){var a=getNormalAt_a,b=getNormalAt_b,c=getNormalAt_c,e0=getNormalAt_e0,e1=getNormalAt_e1;this.getTriangleAt(x,y,edgeClamp,a,b,c),b.vsub(a,e0),c.vsub(a,e1),e0.cross(e1,result),result.normalize()},_proto.getAabbAtIndex=function(xi,yi,_ref){var lowerBound=_ref.lowerBound,upperBound=_ref.upperBound,data=this.data,elementSize=this.elementSize;lowerBound.set(xi*elementSize,yi*elementSize,data[xi][yi]),upperBound.set((xi+1)*elementSize,(yi+1)*elementSize,data[xi+1][yi+1])},_proto.getHeightAt=function(x,y,edgeClamp){var data=this.data,a=getHeightAt_a,b=getHeightAt_b,c=getHeightAt_c,idx=getHeightAt_idx;this.getIndexOfPosition(x,y,idx,edgeClamp);var xi=idx[0],yi=idx[1];edgeClamp&&(xi=Math.min(data.length-2,Math.max(0,xi)),yi=Math.min(data[0].length-2,Math.max(0,yi)));var upper=this.getTriangleAt(x,y,edgeClamp,a,b,c);!function(x,y,ax,ay,bx,by,cx,cy,result){result.x=((by-cy)*(x-cx)+(cx-bx)*(y-cy))/((by-cy)*(ax-cx)+(cx-bx)*(ay-cy)),result.y=((cy-ay)*(x-cx)+(ax-cx)*(y-cy))/((by-cy)*(ax-cx)+(cx-bx)*(ay-cy)),result.z=1-result.x-result.y}(x,y,a.x,a.y,b.x,b.y,c.x,c.y,getHeightAt_weights);var w=getHeightAt_weights;return upper?data[xi+1][yi+1]*w.x+data[xi][yi+1]*w.y+data[xi+1][yi]*w.z:data[xi][yi]*w.x+data[xi+1][yi]*w.y+data[xi][yi+1]*w.z},_proto.getCacheConvexTrianglePillarKey=function(xi,yi,getUpperTriangle){return xi+"_"+yi+"_"+(getUpperTriangle?1:0)},_proto.getCachedConvexTrianglePillar=function(xi,yi,getUpperTriangle){return this._cachedPillars[this.getCacheConvexTrianglePillarKey(xi,yi,getUpperTriangle)]},_proto.setCachedConvexTrianglePillar=function(xi,yi,getUpperTriangle,convex,offset){this._cachedPillars[this.getCacheConvexTrianglePillarKey(xi,yi,getUpperTriangle)]={convex:convex,offset:offset}},_proto.clearCachedConvexTrianglePillar=function(xi,yi,getUpperTriangle){delete this._cachedPillars[this.getCacheConvexTrianglePillarKey(xi,yi,getUpperTriangle)]},_proto.getTriangle=function(xi,yi,upper,a,b,c){var data=this.data,elementSize=this.elementSize;upper?(a.set((xi+1)*elementSize,(yi+1)*elementSize,data[xi+1][yi+1]),b.set(xi*elementSize,(yi+1)*elementSize,data[xi][yi+1]),c.set((xi+1)*elementSize,yi*elementSize,data[xi+1][yi])):(a.set(xi*elementSize,yi*elementSize,data[xi][yi]),b.set((xi+1)*elementSize,yi*elementSize,data[xi+1][yi]),c.set(xi*elementSize,(yi+1)*elementSize,data[xi][yi+1]))},_proto.getConvexTrianglePillar=function(xi,yi,getUpperTriangle){var result=this.pillarConvex,offsetResult=this.pillarOffset;if(this.cacheEnabled){var _data=this.getCachedConvexTrianglePillar(xi,yi,getUpperTriangle);if(_data)return this.pillarConvex=_data.convex,void(this.pillarOffset=_data.offset);result=new ConvexPolyhedron,offsetResult=new Vec3,this.pillarConvex=result,this.pillarOffset=offsetResult}var data=this.data,elementSize=this.elementSize,faces=result.faces;result.vertices.length=6;for(var i=0;i<6;i++)result.vertices[i]||(result.vertices[i]=new Vec3);faces.length=5;for(var _i=0;_i<5;_i++)faces[_i]||(faces[_i]=[]);var verts=result.vertices,h=(Math.min(data[xi][yi],data[xi+1][yi],data[xi][yi+1],data[xi+1][yi+1])-this.minValue)/2+this.minValue;getUpperTriangle?(offsetResult.set((xi+.75)*elementSize,(yi+.75)*elementSize,h),verts[0].set(.25*elementSize,.25*elementSize,data[xi+1][yi+1]-h),verts[1].set(-.75*elementSize,.25*elementSize,data[xi][yi+1]-h),verts[2].set(.25*elementSize,-.75*elementSize,data[xi+1][yi]-h),verts[3].set(.25*elementSize,.25*elementSize,-h-1),verts[4].set(-.75*elementSize,.25*elementSize,-h-1),verts[5].set(.25*elementSize,-.75*elementSize,-h-1),faces[0][0]=0,faces[0][1]=1,faces[0][2]=2,faces[1][0]=5,faces[1][1]=4,faces[1][2]=3,faces[2][0]=2,faces[2][1]=5,faces[2][2]=3,faces[2][3]=0,faces[3][0]=3,faces[3][1]=4,faces[3][2]=1,faces[3][3]=0,faces[4][0]=1,faces[4][1]=4,faces[4][2]=5,faces[4][3]=2):(offsetResult.set((xi+.25)*elementSize,(yi+.25)*elementSize,h),verts[0].set(-.25*elementSize,-.25*elementSize,data[xi][yi]-h),verts[1].set(.75*elementSize,-.25*elementSize,data[xi+1][yi]-h),verts[2].set(-.25*elementSize,.75*elementSize,data[xi][yi+1]-h),verts[3].set(-.25*elementSize,-.25*elementSize,-h-1),verts[4].set(.75*elementSize,-.25*elementSize,-h-1),verts[5].set(-.25*elementSize,.75*elementSize,-h-1),faces[0][0]=0,faces[0][1]=1,faces[0][2]=2,faces[1][0]=5,faces[1][1]=4,faces[1][2]=3,faces[2][0]=0,faces[2][1]=2,faces[2][2]=5,faces[2][3]=3,faces[3][0]=1,faces[3][1]=0,faces[3][2]=3,faces[3][3]=4,faces[4][0]=4,faces[4][1]=5,faces[4][2]=2,faces[4][3]=1),result.computeNormals(),result.computeEdges(),result.updateBoundingSphereRadius(),this.setCachedConvexTrianglePillar(xi,yi,getUpperTriangle,result,offsetResult)},_proto.calculateLocalInertia=function(mass,target){return void 0===target&&(target=new Vec3),target.set(0,0,0),target},_proto.volume=function(){return Number.MAX_VALUE},_proto.calculateWorldAABB=function(pos,quat,min,max){min.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),max.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},_proto.updateBoundingSphereRadius=function(){var data=this.data,s=this.elementSize;this.boundingSphereRadius=new Vec3(data.length*s,data[0].length*s,Math.max(Math.abs(this.maxValue),Math.abs(this.minValue))).length()},_proto.setHeightsFromImage=function(image,scale){var x=scale.x,z=scale.z,y=scale.y,canvas=document.createElement("canvas");canvas.width=image.width,canvas.height=image.height;var context=canvas.getContext("2d");context.drawImage(image,0,0);var imageData=context.getImageData(0,0,image.width,image.height),matrix=this.data;matrix.length=0,this.elementSize=Math.abs(x)/imageData.width;for(var i=0;i=0;i--)this.children[i].removeEmptyNodes(),this.children[i].children.length||this.children[i].data.length||this.children.splice(i,1)},OctreeNode}()),halfDiagonal=new Vec3,tmpAABB$1=new AABB,Trimesh=function(_Shape){function Trimesh(vertices,indices){var _this;return(_this=_Shape.call(this,{type:Shape.types.TRIMESH})||this).vertices=new Float32Array(vertices),_this.indices=new Int16Array(indices),_this.normals=new Float32Array(indices.length),_this.aabb=new AABB,_this.edges=null,_this.scale=new Vec3(1,1,1),_this.tree=new Octree,_this.updateEdges(),_this.updateNormals(),_this.updateAABB(),_this.updateBoundingSphereRadius(),_this.updateTree(),_this}_inheritsLoose(Trimesh,_Shape);var _proto=Trimesh.prototype;return _proto.updateTree=function(){var tree=this.tree;tree.reset(),tree.aabb.copy(this.aabb);var scale=this.scale;tree.aabb.lowerBound.x*=1/scale.x,tree.aabb.lowerBound.y*=1/scale.y,tree.aabb.lowerBound.z*=1/scale.z,tree.aabb.upperBound.x*=1/scale.x,tree.aabb.upperBound.y*=1/scale.y,tree.aabb.upperBound.z*=1/scale.z;for(var triangleAABB=new AABB,a=new Vec3,b=new Vec3,c=new Vec3,points=[a,b,c],i=0;iu.x&&(u.x=v.x),v.yu.y&&(u.y=v.y),v.zu.z&&(u.z=v.z)},_proto.updateAABB=function(){this.computeLocalAABB(this.aabb)},_proto.updateBoundingSphereRadius=function(){for(var max2=0,vertices=this.vertices,v=new Vec3,i=0,N=vertices.length/3;i!==N;i++){this.getVertex(i,v);var norm2=v.lengthSquared();norm2>max2&&(max2=norm2)}this.boundingSphereRadius=Math.sqrt(max2)},_proto.calculateWorldAABB=function(pos,quat,min,max){var frame=calculateWorldAABB_frame,result=calculateWorldAABB_aabb;frame.position=pos,frame.quaternion=quat,this.aabb.toWorldFrame(frame,result),min.copy(result.lowerBound),max.copy(result.upperBound)},_proto.volume=function(){return 4*Math.PI*this.boundingSphereRadius/3},Trimesh}(Shape),computeNormals_n=new Vec3,unscaledAABB=new AABB,getEdgeVector_va=new Vec3,getEdgeVector_vb=new Vec3,cb=new Vec3,ab=new Vec3;Trimesh.computeNormal=function(va,vb,vc,target){vb.vsub(va,ab),vc.vsub(vb,cb),cb.cross(ab,target),target.isZero()||target.normalize()};var va=new Vec3,vb=new Vec3,vc=new Vec3,cli_aabb=new AABB,computeLocalAABB_worldVert=new Vec3,calculateWorldAABB_frame=new Transform,calculateWorldAABB_aabb=new AABB;Trimesh.createTorus=function(radius,tube,radialSegments,tubularSegments,arc){void 0===radius&&(radius=1),void 0===tube&&(tube=.5),void 0===radialSegments&&(radialSegments=8),void 0===tubularSegments&&(tubularSegments=6),void 0===arc&&(arc=2*Math.PI);for(var vertices=[],indices=[],j=0;j<=radialSegments;j++)for(var i=0;i<=tubularSegments;i++){var u=i/tubularSegments*arc,v=j/radialSegments*Math.PI*2,x=(radius+tube*Math.cos(v))*Math.cos(u),y=(radius+tube*Math.cos(v))*Math.sin(u),z=tube*Math.sin(v);vertices.push(x,y,z)}for(var _j=1;_j<=radialSegments;_j++)for(var _i2=1;_i2<=tubularSegments;_i2++){var a=(tubularSegments+1)*_j+_i2-1,b=(tubularSegments+1)*(_j-1)+_i2-1,c=(tubularSegments+1)*(_j-1)+_i2,d=(tubularSegments+1)*_j+_i2;indices.push(a,b,d),indices.push(b,c,d)}return new Trimesh(vertices,indices)};var Solver=function(){function Solver(){this.equations=[]}var _proto=Solver.prototype;return _proto.solve=function(dt,world){return 0},_proto.addEquation=function(eq){eq.enabled&&this.equations.push(eq)},_proto.removeEquation=function(eq){var eqs=this.equations,i=eqs.indexOf(eq);-1!==i&&eqs.splice(i,1)},_proto.removeAllEquations=function(){this.equations.length=0},Solver}(),GSSolver=function(_Solver){function GSSolver(){var _this;return(_this=_Solver.call(this)||this).iterations=10,_this.tolerance=1e-7,_this}return _inheritsLoose(GSSolver,_Solver),GSSolver.prototype.solve=function(dt,world){var B,invC,deltalambda,deltalambdaTot,lambdaj,iter=0,maxIter=this.iterations,tolSquared=this.tolerance*this.tolerance,equations=this.equations,Neq=equations.length,bodies=world.bodies,Nbodies=bodies.length,h=dt;if(0!==Neq)for(var i=0;i!==Nbodies;i++)bodies[i].updateSolveMassProperties();var invCs=GSSolver_solve_invCs,Bs=GSSolver_solve_Bs,lambda=GSSolver_solve_lambda;invCs.length=Neq,Bs.length=Neq,lambda.length=Neq;for(var _i=0;_i!==Neq;_i++){var c=equations[_i];lambda[_i]=0,Bs[_i]=c.computeB(h),invCs[_i]=1/c.computeC()}if(0!==Neq){for(var _i2=0;_i2!==Nbodies;_i2++){var b=bodies[_i2],vlambda=b.vlambda,wlambda=b.wlambda;vlambda.set(0,0,0),wlambda.set(0,0,0)}for(iter=0;iter!==maxIter;iter++){deltalambdaTot=0;for(var j=0;j!==Neq;j++){var _c=equations[j];B=Bs[j],invC=invCs[j],(lambdaj=lambda[j])+(deltalambda=invC*(B-_c.computeGWlambda()-_c.eps*lambdaj))<_c.minForce?deltalambda=_c.minForce-lambdaj:lambdaj+deltalambda>_c.maxForce&&(deltalambda=_c.maxForce-lambdaj),lambda[j]+=deltalambda,deltalambdaTot+=deltalambda>0?deltalambda:-deltalambda,_c.addToWlambda(deltalambda)}if(deltalambdaTot*deltalambdaTotsize;)objects.pop();for(;objects.length=0&&matB.restitution>=0&&(c.restitution=matA.restitution*matB.restitution),c.si=overrideShapeA||si,c.sj=overrideShapeB||sj,c},_proto.createFrictionEquationsFromContact=function(contactEquation,outArray){var bodyA=contactEquation.bi,bodyB=contactEquation.bj,shapeA=contactEquation.si,shapeB=contactEquation.sj,world=this.world,cm=this.currentContactMaterial,friction=cm.friction,matA=shapeA.material||bodyA.material,matB=shapeB.material||bodyB.material;if(matA&&matB&&matA.friction>=0&&matB.friction>=0&&(friction=matA.friction*matB.friction),friction>0){var mug=friction*world.gravity.length(),reducedMass=bodyA.invMass+bodyB.invMass;reducedMass>0&&(reducedMass=1/reducedMass);var pool=this.frictionEquationPool,c1=pool.length?pool.pop():new FrictionEquation(bodyA,bodyB,mug*reducedMass),c2=pool.length?pool.pop():new FrictionEquation(bodyA,bodyB,mug*reducedMass);return c1.bi=c2.bi=bodyA,c1.bj=c2.bj=bodyB,c1.minForce=c2.minForce=-mug*reducedMass,c1.maxForce=c2.maxForce=mug*reducedMass,c1.ri.copy(contactEquation.ri),c1.rj.copy(contactEquation.rj),c2.ri.copy(contactEquation.ri),c2.rj.copy(contactEquation.rj),contactEquation.ni.tangents(c1.t,c2.t),c1.setSpookParams(cm.frictionEquationStiffness,cm.frictionEquationRelaxation,world.dt),c2.setSpookParams(cm.frictionEquationStiffness,cm.frictionEquationRelaxation,world.dt),c1.enabled=c2.enabled=contactEquation.enabled,outArray.push(c1,c2),!0}return!1},_proto.createFrictionFromAverage=function(numContacts){var c=this.result[this.result.length-1];if(this.createFrictionEquationsFromContact(c,this.frictionResult)&&1!==numContacts){var f1=this.frictionResult[this.frictionResult.length-2],f2=this.frictionResult[this.frictionResult.length-1];averageNormal.setZero(),averageContactPointA.setZero(),averageContactPointB.setZero();for(var bodyA=c.bi,i=(c.bj,0);i!==numContacts;i++)(c=this.result[this.result.length-1-i]).bi!==bodyA?(averageNormal.vadd(c.ni,averageNormal),averageContactPointA.vadd(c.ri,averageContactPointA),averageContactPointB.vadd(c.rj,averageContactPointB)):(averageNormal.vsub(c.ni,averageNormal),averageContactPointA.vadd(c.rj,averageContactPointA),averageContactPointB.vadd(c.ri,averageContactPointB));var invNumContacts=1/numContacts;averageContactPointA.scale(invNumContacts,f1.ri),averageContactPointB.scale(invNumContacts,f1.rj),f2.ri.copy(f1.ri),f2.rj.copy(f1.rj),averageNormal.normalize(),averageNormal.tangents(f1.t,f2.t)}},_proto.getContacts=function(p1,p2,world,result,oldcontacts,frictionResult,frictionPool){this.contactPointPool=oldcontacts,this.frictionEquationPool=frictionPool,this.result=result,this.frictionResult=frictionResult;for(var qi=tmpQuat1,qj=tmpQuat2,xi=tmpVec1$3,xj=tmpVec2$3,k=0,N=p1.length;k!==N;k++){var bi=p1[k],bj=p2[k],bodyContactMaterial=null;bi.material&&bj.material&&(bodyContactMaterial=world.getContactMaterial(bi.material,bj.material)||null);for(var justTest=bi.type&Body.KINEMATIC&&bj.type&Body.STATIC||bi.type&Body.STATIC&&bj.type&Body.KINEMATIC||bi.type&Body.KINEMATIC&&bj.type&Body.KINEMATIC,i=0;isi.boundingSphereRadius+sj.boundingSphereRadius)){var shapeContactMaterial=null;si.material&&sj.material&&(shapeContactMaterial=world.getContactMaterial(si.material,sj.material)||null),this.currentContactMaterial=shapeContactMaterial||bodyContactMaterial||world.defaultContactMaterial;var resolver=this[si.type|sj.type];if(resolver){(si.type0){var ns1=sphereBox_ns1,ns2=sphereBox_ns2;ns1.copy(sides[(idx+1)%3]),ns2.copy(sides[(idx+2)%3]);var h1=ns1.length(),h2=ns2.length();ns1.normalize(),ns2.normalize();var dot1=box_to_sphere.dot(ns1),dot2=box_to_sphere.dot(ns2);if(dot1-h1&&dot2-h2){var _dist=Math.abs(dot-h-R);if((null===side_distance||_distsi.boundingSphereRadius+sj.boundingSphereRadius)&&si.findSeparatingAxis(sj,xi,qi,xj,qj,sepAxis,faceListA,faceListB)){var res=[],q=convexConvex_q;si.clipAgainstHull(xi,qi,sj,xj,qj,sepAxis,-100,100,res);for(var numContacts=0,j=0;j!==res.length;j++){if(justTest)return!0;var r=this.createContactEquation(bi,bj,si,sj,rsi,rsj),ri=r.ri,rj=r.rj;sepAxis.negate(r.ni),res[j].normal.negate(q),q.scale(res[j].depth,q),res[j].point.vadd(q,ri),rj.copy(res[j].point),ri.vsub(xi,ri),rj.vsub(xj,rj),ri.vadd(xi,ri),ri.vsub(bi.position,ri),rj.vadd(xj,rj),rj.vsub(bj.position,rj),this.result.push(r),numContacts++,this.enableFrictionReduction||this.createFrictionEquationsFromContact(r,this.frictionResult)}this.enableFrictionReduction&&numContacts&&this.createFrictionFromAverage(numContacts)}},_proto.sphereConvex=function(si,sj,xi,xj,qi,qj,bi,bj,rsi,rsj,justTest){var v3pool=this.v3pool;xi.vsub(xj,convex_to_sphere);for(var normals=sj.faceNormals,faces=sj.faces,verts=sj.vertices,R=si.radius,found=!1,i=0;i!==verts.length;i++){var v=verts[i],worldCorner=sphereConvex_worldCorner;qj.vmult(v,worldCorner),xj.vadd(worldCorner,worldCorner);var sphere_to_corner=sphereConvex_sphereToCorner;if(worldCorner.vsub(xi,sphere_to_corner),sphere_to_corner.lengthSquared()0){for(var faceVerts=[],j=0,Nverts=face.length;j!==Nverts;j++){var worldVertex=v3pool.get();qj.vmult(verts[face[j]],worldVertex),xj.vadd(worldVertex,worldVertex),faceVerts.push(worldVertex)}if(pointInPolygon(faceVerts,worldNormal,xi)){if(justTest)return!0;found=!0;var _r3=this.createContactEquation(bi,bj,si,sj,rsi,rsj);worldNormal.scale(-R,_r3.ri),worldNormal.negate(_r3.ni);var penetrationVec2=v3pool.get();worldNormal.scale(-penetration,penetrationVec2);var penetrationSpherePoint=v3pool.get();worldNormal.scale(-R,penetrationSpherePoint),xi.vsub(xj,_r3.rj),_r3.rj.vadd(penetrationSpherePoint,_r3.rj),_r3.rj.vadd(penetrationVec2,_r3.rj),_r3.rj.vadd(xj,_r3.rj),_r3.rj.vsub(bj.position,_r3.rj),_r3.ri.vadd(xi,_r3.ri),_r3.ri.vsub(bi.position,_r3.ri),v3pool.release(penetrationVec2),v3pool.release(penetrationSpherePoint),this.result.push(_r3),this.createFrictionEquationsFromContact(_r3,this.frictionResult);for(var _j2=0,Nfaceverts=faceVerts.length;_j2!==Nfaceverts;_j2++)v3pool.release(faceVerts[_j2]);return}for(var _j3=0;_j3!==face.length;_j3++){var v1=v3pool.get(),v2=v3pool.get();qj.vmult(verts[face[(_j3+1)%face.length]],v1),qj.vmult(verts[face[(_j3+2)%face.length]],v2),xj.vadd(v1,v1),xj.vadd(v2,v2);var edge=sphereConvex_edge;v2.vsub(v1,edge);var edgeUnit=sphereConvex_edgeUnit;edge.unit(edgeUnit);var p=v3pool.get(),v1_to_xi=v3pool.get();xi.vsub(v1,v1_to_xi);var dot=v1_to_xi.dot(edgeUnit);edgeUnit.scale(dot,p),p.vadd(v1,p);var xi_to_p=v3pool.get();if(p.vsub(xi,xi_to_p),dot>0&&dot*dotdata.length||iMinY>data[0].length)){iMinX<0&&(iMinX=0),iMaxX<0&&(iMaxX=0),iMinY<0&&(iMinY=0),iMaxY<0&&(iMaxY=0),iMinX>=data.length&&(iMinX=data.length-1),iMaxX>=data.length&&(iMaxX=data.length-1),iMaxY>=data[0].length&&(iMaxY=data[0].length-1),iMinY>=data[0].length&&(iMinY=data[0].length-1);var minMax=[];hfShape.getRectMinMax(iMinX,iMinY,iMaxX,iMaxY,minMax);var min=minMax[0],max=minMax[1];if(!(localSpherePos.z-radius>max||localSpherePos.z+radius2)return}}},_proto.boxHeightfield=function(si,sj,xi,xj,qi,qj,bi,bj,rsi,rsj,justTest){return si.convexPolyhedronRepresentation.material=si.material,si.convexPolyhedronRepresentation.collisionResponse=si.collisionResponse,this.convexHeightfield(si.convexPolyhedronRepresentation,sj,xi,xj,qi,qj,bi,bj,si,sj,justTest)},_proto.convexHeightfield=function(convexShape,hfShape,convexPos,hfPos,convexQuat,hfQuat,convexBody,hfBody,rsi,rsj,justTest){var data=hfShape.data,w=hfShape.elementSize,radius=convexShape.boundingSphereRadius,worldPillarOffset=convexHeightfield_tmp2,faceList=convexHeightfield_faceList,localConvexPos=convexHeightfield_tmp1;Transform.pointToLocalFrame(hfPos,hfQuat,convexPos,localConvexPos);var iMinX=Math.floor((localConvexPos.x-radius)/w)-1,iMaxX=Math.ceil((localConvexPos.x+radius)/w)+1,iMinY=Math.floor((localConvexPos.y-radius)/w)-1,iMaxY=Math.ceil((localConvexPos.y+radius)/w)+1;if(!(iMaxX<0||iMaxY<0||iMinX>data.length||iMinY>data[0].length)){iMinX<0&&(iMinX=0),iMaxX<0&&(iMaxX=0),iMinY<0&&(iMinY=0),iMaxY<0&&(iMaxY=0),iMinX>=data.length&&(iMinX=data.length-1),iMaxX>=data.length&&(iMaxX=data.length-1),iMaxY>=data[0].length&&(iMaxY=data[0].length-1),iMinY>=data[0].length&&(iMinY=data[0].length-1);var minMax=[];hfShape.getRectMinMax(iMinX,iMinY,iMaxX,iMaxY,minMax);var min=minMax[0],max=minMax[1];if(!(localConvexPos.z-radius>max||localConvexPos.z+radius0&&positionAlongEdgeB<0)if(localSpherePos.vsub(edgeVertexA,tmp),edgeVectorUnit.copy(edgeVector),edgeVectorUnit.normalize(),positionAlongEdgeA=tmp.dot(edgeVectorUnit),edgeVectorUnit.scale(positionAlongEdgeA,tmp),tmp.vadd(edgeVertexA,tmp),tmp.distanceTo(localSpherePos)0&&!0===positiveResult||r<=0&&!1===positiveResult))return!1;null===positiveResult&&(positiveResult=r>0)}return!0}var box_to_sphere=new Vec3,sphereBox_ns=new Vec3,sphereBox_ns1=new Vec3,sphereBox_ns2=new Vec3,sphereBox_sides=[new Vec3,new Vec3,new Vec3,new Vec3,new Vec3,new Vec3],sphereBox_sphere_to_corner=new Vec3,sphereBox_side_ns=new Vec3,sphereBox_side_ns1=new Vec3,sphereBox_side_ns2=new Vec3;Narrowphase.prototype[COLLISION_TYPES.sphereBox]=Narrowphase.prototype.sphereBox;var convex_to_sphere=new Vec3,sphereConvex_edge=new Vec3,sphereConvex_edgeUnit=new Vec3,sphereConvex_sphereToCorner=new Vec3,sphereConvex_worldCorner=new Vec3,sphereConvex_worldNormal=new Vec3,sphereConvex_worldPoint=new Vec3,sphereConvex_worldSpherePointClosestToPlane=new Vec3,sphereConvex_penetrationVec=new Vec3,sphereConvex_sphereToWorldPoint=new Vec3;Narrowphase.prototype[COLLISION_TYPES.sphereConvex]=Narrowphase.prototype.sphereConvex;new Vec3,new Vec3;Narrowphase.prototype[COLLISION_TYPES.planeBox]=Narrowphase.prototype.planeBox;var planeConvex_v=new Vec3,planeConvex_normal=new Vec3,planeConvex_relpos=new Vec3,planeConvex_projected=new Vec3;Narrowphase.prototype[COLLISION_TYPES.planeConvex]=Narrowphase.prototype.planeConvex;var convexConvex_sepAxis=new Vec3,convexConvex_q=new Vec3;Narrowphase.prototype[COLLISION_TYPES.convexConvex]=Narrowphase.prototype.convexConvex;var particlePlane_normal=new Vec3,particlePlane_relpos=new Vec3,particlePlane_projected=new Vec3;Narrowphase.prototype[COLLISION_TYPES.planeParticle]=Narrowphase.prototype.planeParticle;var particleSphere_normal=new Vec3;Narrowphase.prototype[COLLISION_TYPES.sphereParticle]=Narrowphase.prototype.sphereParticle;var cqj=new Quaternion,convexParticle_local=new Vec3,convexParticle_penetratedFaceNormal=(new Vec3,new Vec3),convexParticle_vertexToParticle=new Vec3,convexParticle_worldPenetrationVec=new Vec3;Narrowphase.prototype[COLLISION_TYPES.convexParticle]=Narrowphase.prototype.convexParticle,Narrowphase.prototype[COLLISION_TYPES.boxHeightfield]=Narrowphase.prototype.boxHeightfield;var convexHeightfield_tmp1=new Vec3,convexHeightfield_tmp2=new Vec3,convexHeightfield_faceList=[0];Narrowphase.prototype[COLLISION_TYPES.convexHeightfield]=Narrowphase.prototype.convexHeightfield;var sphereHeightfield_tmp1=new Vec3,sphereHeightfield_tmp2=new Vec3;Narrowphase.prototype[COLLISION_TYPES.sphereHeightfield]=Narrowphase.prototype.sphereHeightfield;var OverlapKeeper=function(){function OverlapKeeper(){this.current=[],this.previous=[]}var _proto=OverlapKeeper.prototype;return _proto.getKey=function(i,j){if(jcurrent[index];)index++;if(key!==current[index]){for(var _j=current.length-1;_j>=index;_j--)current[_j+1]=current[_j];current[index]=key}},_proto.tick=function(){var tmp=this.current;this.current=this.previous,this.previous=tmp,this.current.length=0},_proto.getDiff=function(additions,removals){for(var a=this.current,b=this.previous,al=a.length,bl=b.length,j=0,i=0;ib[j];)j++;keyA===b[j]||unpackAndPush(additions,keyA)}j=0;for(var _i=0;_ia[j];)j++;a[j]===keyB||unpackAndPush(removals,keyB)}},OverlapKeeper}();function unpackAndPush(array,key){array.push((4294901760&key)>>16,65535&key)}var TupleDictionary=function(){function TupleDictionary(){this.data={keys:[]}}var _proto=TupleDictionary.prototype;return _proto.get=function(i,j){if(i>j){var temp=j;j=i,i=temp}return this.data[i+"-"+j]},_proto.set=function(i,j,value){if(i>j){var temp=j;j=i,i=temp}var key=i+"-"+j;this.get(i,j)||this.data.keys.push(key),this.data[key]=value},_proto.reset=function(){for(var data=this.data,keys=data.keys;keys.length>0;){delete data[keys.pop()]}},TupleDictionary}(),World=function(_EventTarget){function World(options){var _this;return void 0===options&&(options={}),(_this=_EventTarget.call(this)||this).dt=-1,_this.allowSleep=!!options.allowSleep,_this.contacts=[],_this.frictionEquations=[],_this.quatNormalizeSkip=void 0!==options.quatNormalizeSkip?options.quatNormalizeSkip:0,_this.quatNormalizeFast=void 0!==options.quatNormalizeFast&&options.quatNormalizeFast,_this.time=0,_this.stepnumber=0,_this.default_dt=1/60,_this.nextId=0,_this.gravity=new Vec3,options.gravity&&_this.gravity.copy(options.gravity),_this.broadphase=void 0!==options.broadphase?options.broadphase:new NaiveBroadphase,_this.bodies=[],_this.hasActiveBodies=!1,_this.solver=void 0!==options.solver?options.solver:new GSSolver,_this.constraints=[],_this.narrowphase=new Narrowphase(_assertThisInitialized(_this)),_this.collisionMatrix=new ArrayCollisionMatrix,_this.collisionMatrixPrevious=new ArrayCollisionMatrix,_this.bodyOverlapKeeper=new OverlapKeeper,_this.shapeOverlapKeeper=new OverlapKeeper,_this.materials=[],_this.contactmaterials=[],_this.contactMaterialTable=new TupleDictionary,_this.defaultMaterial=new Material("default"),_this.defaultContactMaterial=new ContactMaterial(_this.defaultMaterial,_this.defaultMaterial,{friction:.3,restitution:0}),_this.doProfiling=!1,_this.profile={solve:0,makeContactConstraints:0,broadphase:0,integrate:0,narrowphase:0},_this.accumulator=0,_this.subsystems=[],_this.addBodyEvent={type:"addBody",body:null},_this.removeBodyEvent={type:"removeBody",body:null},_this.idToBodyMap={},_this.broadphase.setWorld(_assertThisInitialized(_this)),_this}_inheritsLoose(World,_EventTarget);var _proto=World.prototype;return _proto.getContactMaterial=function(m1,m2){return this.contactMaterialTable.get(m1.id,m2.id)},_proto.numObjects=function(){return this.bodies.length},_proto.collisionMatrixTick=function(){var temp=this.collisionMatrixPrevious;this.collisionMatrixPrevious=this.collisionMatrix,this.collisionMatrix=temp,this.collisionMatrix.reset(),this.bodyOverlapKeeper.tick(),this.shapeOverlapKeeper.tick()},_proto.addConstraint=function(c){this.constraints.push(c)},_proto.removeConstraint=function(c){var idx=this.constraints.indexOf(c);-1!==idx&&this.constraints.splice(idx,1)},_proto.rayTest=function(from,to,result){result instanceof RaycastResult?this.raycastClosest(from,to,{skipBackfaces:!0},result):this.raycastAll(from,to,{skipBackfaces:!0},result)},_proto.raycastAll=function(from,to,options,callback){return void 0===options&&(options={}),options.mode=Ray.ALL,options.from=from,options.to=to,options.callback=callback,tmpRay$1.intersectWorld(this,options)},_proto.raycastAny=function(from,to,options,result){return void 0===options&&(options={}),options.mode=Ray.ANY,options.from=from,options.to=to,options.result=result,tmpRay$1.intersectWorld(this,options)},_proto.raycastClosest=function(from,to,options,result){return void 0===options&&(options={}),options.mode=Ray.CLOSEST,options.from=from,options.to=to,options.result=result,tmpRay$1.intersectWorld(this,options)},_proto.addBody=function(body){this.bodies.includes(body)||(body.index=this.bodies.length,this.bodies.push(body),body.world=this,body.initPosition.copy(body.position),body.initVelocity.copy(body.velocity),body.timeLastSleepy=this.time,body instanceof Body&&(body.initAngularVelocity.copy(body.angularVelocity),body.initQuaternion.copy(body.quaternion)),this.collisionMatrix.setNumObjects(this.bodies.length),this.addBodyEvent.body=body,this.idToBodyMap[body.id]=body,this.dispatchEvent(this.addBodyEvent))},_proto.removeBody=function(body){body.world=null;var n=this.bodies.length-1,bodies=this.bodies,idx=bodies.indexOf(body);if(-1!==idx){bodies.splice(idx,1);for(var i=0;i!==bodies.length;i++)bodies[i].index=i;this.collisionMatrix.setNumObjects(n),this.removeBodyEvent.body=body,delete this.idToBodyMap[body.id],this.dispatchEvent(this.removeBodyEvent)}},_proto.getBodyById=function(id){return this.idToBodyMap[id]},_proto.getShapeById=function(id){for(var bodies=this.bodies,i=0,bl=bodies.length;i=dt&&substeps=0;j-=1)(c.bodyA===p1[j]&&c.bodyB===p2[j]||c.bodyB===p1[j]&&c.bodyA===p2[j])&&(p1.splice(j,1),p2.splice(j,1))}this.collisionMatrixTick(),doProfiling&&(profilingStart=performance.now());var oldcontacts=World_step_oldContacts,NoldContacts=contacts.length;for(i=0;i!==NoldContacts;i++)oldcontacts.push(contacts[i]);contacts.length=0;var NoldFrictionEquations=this.frictionEquations.length;for(i=0;i!==NoldFrictionEquations;i++)frictionEquationPool.push(this.frictionEquations[i]);for(this.frictionEquations.length=0,this.narrowphase.getContacts(p1,p2,this,contacts,oldcontacts,this.frictionEquations,frictionEquationPool),doProfiling&&(profile.narrowphase=performance.now()-profilingStart),doProfiling&&(profilingStart=performance.now()),i=0;i=0&&bj.material.friction>=0&&_bi.material.friction*bj.material.friction,_bi.material.restitution>=0&&bj.material.restitution>=0&&(_c.restitution=_bi.material.restitution*bj.material.restitution)),solver.addEquation(_c),_bi.allowSleep&&_bi.type===Body.DYNAMIC&&_bi.sleepState===Body.SLEEPING&&bj.sleepState===Body.AWAKE&&bj.type!==Body.STATIC)bj.velocity.lengthSquared()+bj.angularVelocity.lengthSquared()>=2*Math.pow(bj.sleepSpeedLimit,2)&&(_bi.wakeUpAfterNarrowphase=!0);if(bj.allowSleep&&bj.type===Body.DYNAMIC&&bj.sleepState===Body.SLEEPING&&_bi.sleepState===Body.AWAKE&&_bi.type!==Body.STATIC)_bi.velocity.lengthSquared()+_bi.angularVelocity.lengthSquared()>=2*Math.pow(_bi.sleepSpeedLimit,2)&&(bj.wakeUpAfterNarrowphase=!0);this.collisionMatrix.set(_bi,bj,!0),this.collisionMatrixPrevious.get(_bi,bj)||(World_step_collideEvent.body=bj,World_step_collideEvent.contact=_c,_bi.dispatchEvent(World_step_collideEvent),World_step_collideEvent.body=_bi,bj.dispatchEvent(World_step_collideEvent)),this.bodyOverlapKeeper.set(_bi.id,bj.id),this.shapeOverlapKeeper.set(si.id,sj.id)}for(this.emitContactEvents(),doProfiling&&(profile.makeContactConstraints=performance.now()-profilingStart,profilingStart=performance.now()),i=0;i!==N;i++){var _bi2=bodies[i];_bi2.wakeUpAfterNarrowphase&&(_bi2.wakeUp(),_bi2.wakeUpAfterNarrowphase=!1)}for(Nconstraints=constraints.length,i=0;i!==Nconstraints;i++){var _c2=constraints[i];_c2.update();for(var _j=0,Neq=_c2.equations.length;_j!==Neq;_j++){var eq=_c2.equations[_j];solver.addEquation(eq)}}solver.solve(dt,this),doProfiling&&(profile.solve=performance.now()-profilingStart),solver.removeAllEquations();var pow=Math.pow;for(i=0;i!==N;i++){var _bi3=bodies[i];if(_bi3.type&DYNAMIC){var ld=pow(1-_bi3.linearDamping,dt),v=_bi3.velocity;v.scale(ld,v);var av=_bi3.angularVelocity;if(av){var ad=pow(1-_bi3.angularDamping,dt);av.scale(ad,av)}}}for(this.dispatchEvent(World_step_preStepEvent),i=0;i!==N;i++){var _bi4=bodies[i];_bi4.preStep&&_bi4.preStep.call(_bi4)}doProfiling&&(profilingStart=performance.now());var quatNormalize=this.stepnumber%(this.quatNormalizeSkip+1)==0,quatNormalizeFast=this.quatNormalizeFast;for(i=0;i!==N;i++)bodies[i].integrate(dt,quatNormalize,quatNormalizeFast);for(this.clearForces(),this.broadphase.dirty=!0,doProfiling&&(profile.integrate=performance.now()-profilingStart),this.time+=dt,this.stepnumber+=1,this.dispatchEvent(World_step_postStepEvent),i=0;i!==N;i++){var _bi5=bodies[i],postStep=_bi5.postStep;postStep&&postStep.call(_bi5)}var hasActiveBodies=!0;if(this.allowSleep)for(hasActiveBodies=!1,i=0;i!==N;i++){var _bi6=bodies[i];_bi6.sleepTick(this.time),_bi6.sleepState!==Body.SLEEPING&&(hasActiveBodies=!0)}this.hasActiveBodies=hasActiveBodies},_proto.clearForces=function(){for(var bodies=this.bodies,N=bodies.length,i=0;i!==N;i++){var b=bodies[i];b.force,b.torque;b.force.set(0,0,0),b.torque.set(0,0,0)}},World}(EventTarget),tmpRay$1=(new AABB,new Ray);if("undefined"==typeof performance&&(performance={}),!performance.now){var nowOffset=Date.now();performance.timing&&performance.timing.navigationStart&&(nowOffset=performance.timing.navigationStart),performance.now=function(){return Date.now()-nowOffset}}new Vec3;var additions,removals,beginContactEvent,endContactEvent,beginShapeContactEvent,endShapeContactEvent,World_step_postStepEvent={type:"postStep"},World_step_preStepEvent={type:"preStep"},World_step_collideEvent={type:Body.COLLIDE_EVENT_NAME,body:null,contact:null},World_step_oldContacts=[],World_step_frictionEquationPool=[],World_step_p1=[],World_step_p2=[];World.prototype.emitContactEvents=(additions=[],removals=[],beginContactEvent={type:"beginContact",bodyA:null,bodyB:null},endContactEvent={type:"endContact",bodyA:null,bodyB:null},beginShapeContactEvent={type:"beginShapeContact",bodyA:null,bodyB:null,shapeA:null,shapeB:null},endShapeContactEvent={type:"endShapeContact",bodyA:null,bodyB:null,shapeA:null,shapeB:null},function(){var hasBeginContact=this.hasAnyEventListener("beginContact"),hasEndContact=this.hasAnyEventListener("endContact");if((hasBeginContact||hasEndContact)&&this.bodyOverlapKeeper.getDiff(additions,removals),hasBeginContact){for(var i=0,l=additions.length;i{switch(options.cylinderAxis){case"y":return new Ammo.btCylinderShape(btHalfExtents);case"x":return new Ammo.btCylinderShapeX(btHalfExtents);case"z":return new Ammo.btCylinderShapeZ(btHalfExtents)}return null})();return Ammo.destroy(btHalfExtents),_finishCollisionShape(collisionShape,options,_computeScale(root,options)),collisionShape},exports.createCapsuleShape=function(root,options){options.type=TYPE.CAPSULE,_setOptions(options),options.fit===FIT.ALL&&(options.halfExtents=_computeHalfExtents(root,_computeBounds(root,options),options.minHalfExtent,options.maxHalfExtent));const{x:x,y:y,z:z}=options.halfExtents,collisionShape=(()=>{switch(options.cylinderAxis){case"y":return new Ammo.btCapsuleShape(Math.max(x,z),2*y);case"x":return new Ammo.btCapsuleShapeX(Math.max(y,z),2*x);case"z":return new Ammo.btCapsuleShapeZ(Math.max(x,y),2*z)}return null})();return _finishCollisionShape(collisionShape,options,_computeScale(root,options)),collisionShape},exports.createConeShape=function(root,options){options.type=TYPE.CONE,_setOptions(options),options.fit===FIT.ALL&&(options.halfExtents=_computeHalfExtents(root,_computeBounds(root,options),options.minHalfExtent,options.maxHalfExtent));const{x:x,y:y,z:z}=options.halfExtents,collisionShape=(()=>{switch(options.cylinderAxis){case"y":return new Ammo.btConeShape(Math.max(x,z),2*y);case"x":return new Ammo.btConeShapeX(Math.max(y,z),2*x);case"z":return new Ammo.btConeShapeZ(Math.max(x,y),2*z)}return null})();return _finishCollisionShape(collisionShape,options,_computeScale(root,options)),collisionShape},exports.createSphereShape=function(root,options){let radius;options.type=TYPE.SPHERE,_setOptions(options),radius=options.fit!==FIT.MANUAL||isNaN(options.sphereRadius)?_computeRadius(root,options,_computeBounds(root,options)):options.sphereRadius;const collisionShape=new Ammo.btSphereShape(radius);return _finishCollisionShape(collisionShape,options,_computeScale(root,options)),collisionShape},exports.createHullShape=function(){const vertex=new THREE.Vector3,center=new THREE.Vector3;return function(root,options){if(options.type=TYPE.HULL,_setOptions(options),options.fit===FIT.MANUAL)return console.warn("cannot use fit: manual with type: hull"),null;const bounds=_computeBounds(root,options),btVertex=new Ammo.btVector3,originalHull=new Ammo.btConvexHullShape;originalHull.setMargin(options.margin),center.addVectors(bounds.max,bounds.min).multiplyScalar(.5);let vertexCount=0;_iterateGeometries(root,options,geo=>{vertexCount+=geo.attributes.position.array.length/3});const maxVertices=options.hullMaxVertices||1e5;vertexCount>maxVertices&&console.warn(`too many vertices for hull shape; sampling ~${maxVertices} from ~${vertexCount} vertices`);const p=Math.min(1,maxVertices/vertexCount);_iterateGeometries(root,options,(geo,transform)=>{const components=geo.attributes.position.array;for(let i=0;i=100){const shapeHull=new Ammo.btShapeHull(originalHull);shapeHull.buildHull(options.margin),Ammo.destroy(originalHull),collisionShape=new Ammo.btConvexHullShape(Ammo.getPointer(shapeHull.getVertexPointer()),shapeHull.numVertices()),Ammo.destroy(shapeHull)}return Ammo.destroy(btVertex),_finishCollisionShape(collisionShape,options,_computeScale(root,options)),collisionShape}}(),exports.createHACDShapes=function(){const v=new THREE.Vector3,center=new THREE.Vector3;return function(root,options){if(options.type=TYPE.HACD,_setOptions(options),options.fit===FIT.MANUAL)return console.warn("cannot use fit: manual with type: hacd"),[];if(!Ammo.hasOwnProperty("HACD"))return console.warn("HACD unavailable in included build of Ammo.js. Visit https://github.com/mozillareality/ammo.js for the latest version."),[];const bounds=_computeBounds(root),scale=_computeScale(root,options);let vertexCount=0,triCount=0;center.addVectors(bounds.max,bounds.min).multiplyScalar(.5),_iterateGeometries(root,options,geo=>{vertexCount+=geo.attributes.position.array.length/3,geo.index?triCount+=geo.index.array.length/3:triCount+=geo.attributes.position.array.length/9});const hacd=new Ammo.HACD;options.hasOwnProperty("compacityWeight")&&hacd.SetCompacityWeight(options.compacityWeight),options.hasOwnProperty("volumeWeight")&&hacd.SetVolumeWeight(options.volumeWeight),options.hasOwnProperty("nClusters")&&hacd.SetNClusters(options.nClusters),options.hasOwnProperty("nVerticesPerCH")&&hacd.SetNVerticesPerCH(options.nVerticesPerCH),options.hasOwnProperty("concavity")&&hacd.SetConcavity(options.concavity);const points=Ammo._malloc(3*vertexCount*8),triangles=Ammo._malloc(3*triCount*4);hacd.SetPoints(points),hacd.SetTriangles(triangles),hacd.SetNPoints(vertexCount),hacd.SetNTriangles(triCount);const pptr=points/8,tptr=triangles/4;_iterateGeometries(root,options,(geo,transform)=>{const components=geo.attributes.position.array,indices=geo.index?geo.index.array:null;for(let i=0;i{vertexCount+=geo.attributes.position.count,geo.index?triCount+=geo.index.count/3:triCount+=geo.attributes.position.count/3});const vhacd=new Ammo.VHACD,params=new Ammo.Parameters;options.hasOwnProperty("resolution")&¶ms.set_m_resolution(options.resolution),options.hasOwnProperty("depth")&¶ms.set_m_depth(options.depth),options.hasOwnProperty("concavity")&¶ms.set_m_concavity(options.concavity),options.hasOwnProperty("planeDownsampling")&¶ms.set_m_planeDownsampling(options.planeDownsampling),options.hasOwnProperty("convexhullDownsampling")&¶ms.set_m_convexhullDownsampling(options.convexhullDownsampling),options.hasOwnProperty("alpha")&¶ms.set_m_alpha(options.alpha),options.hasOwnProperty("beta")&¶ms.set_m_beta(options.beta),options.hasOwnProperty("gamma")&¶ms.set_m_gamma(options.gamma),options.hasOwnProperty("pca")&¶ms.set_m_pca(options.pca),options.hasOwnProperty("mode")&¶ms.set_m_mode(options.mode),options.hasOwnProperty("maxNumVerticesPerCH")&¶ms.set_m_maxNumVerticesPerCH(options.maxNumVerticesPerCH),options.hasOwnProperty("minVolumePerCH")&¶ms.set_m_minVolumePerCH(options.minVolumePerCH),options.hasOwnProperty("convexhullApproximation")&¶ms.set_m_convexhullApproximation(options.convexhullApproximation),options.hasOwnProperty("oclAcceleration")&¶ms.set_m_oclAcceleration(options.oclAcceleration);const points=Ammo._malloc(3*vertexCount*8),triangles=Ammo._malloc(3*triCount*4);let pptr=points/8,tptr=triangles/4;_iterateGeometries(root,options,(geo,transform)=>{const components=geo.attributes.position.array,indices=geo.index?geo.index.array:null;for(let i=0;i{const components=geo.attributes.position.array;if(geo.index)for(let i=0;i{switch(options.heightDataType){case"short":return Ammo.PHY_SHORT;case"float":default:return Ammo.PHY_FLOAT}})(),flipQuadEdges=!options.hasOwnProperty("flipQuadEdges")||options.flipQuadEdges,heightStickLength=heightfieldData.length,heightStickWidth=heightStickLength>0?heightfieldData[0].length:0,data=Ammo._malloc(heightStickLength*heightStickWidth*4),ptr=data/4;let minHeight=Number.POSITIVE_INFINITY,maxHeight=Number.NEGATIVE_INFINITY,index=0;for(let l=0;l{for(let res of collisionShape.resources||[])Ammo.destroy(res);collisionShape.heightfieldData&&Ammo._free(collisionShape.heightfieldData),Ammo.destroy(collisionShape)});const localTransform=new Ammo.btTransform,rotation=new Ammo.btQuaternion;if(localTransform.setIdentity(),localTransform.getOrigin().setValue(options.offset.x,options.offset.y,options.offset.z),rotation.setValue(options.orientation.x,options.orientation.y,options.orientation.z,options.orientation.w),localTransform.setRotation(rotation),Ammo.destroy(rotation),scale){const localScale=new Ammo.btVector3(scale.x,scale.y,scale.z);collisionShape.setLocalScaling(localScale),Ammo.destroy(localScale)}collisionShape.localTransform=localTransform},_iterateGeometries=function(){const transform=new THREE.Matrix4,inverse=new THREE.Matrix4,bufferGeometry=new THREE.BufferGeometry;return function(root,options,cb){inverse.getInverse(root.matrixWorld),root.traverse(mesh=>{!mesh.isMesh||THREE.Sky&&mesh.__proto__==THREE.Sky.prototype||!(options.includeInvisible||mesh.el&&mesh.el.object3D.visible||mesh.visible)||(mesh===root?transform.identity():(hasUpdateMatricesFunction&&mesh.updateMatrices(),transform.multiplyMatrices(inverse,mesh.matrixWorld)),cb(mesh.geometry.isBufferGeometry?mesh.geometry:bufferGeometry.fromGeometry(mesh.geometry),transform))})}}(),_computeScale=function(root,options){const scale=new THREE.Vector3(1,1,1);return options.fit===FIT.ALL&&scale.setFromMatrixScale(root.matrixWorld),scale},_computeRadius=function(){const v=new THREE.Vector3,center=new THREE.Vector3;return function(root,options,bounds){let maxRadiusSq=0,{x:cx,y:cy,z:cz}=bounds.getCenter(center);return _iterateGeometries(root,options,(geo,transform)=>{const components=geo.attributes.position.array;for(let i=0;i{const components=geo.attributes.position.array;for(let i=0;imaxX&&(maxX=v.x),v.y>maxY&&(maxY=v.y),v.z>maxZ&&(maxZ=v.z)}),bounds.min.set(minX,minY,minZ),bounds.max.set(maxX,maxY,maxZ),bounds}}()},{}],7:[function(require,module,exports){(function(global){var cannonEs=require("cannon-es"),three="undefined"!=typeof window?window.THREE:void 0!==global?global.THREE:null,ConvexHull=function(){var line3,plane,closestPoint,triangle,Visible=0,v1=new three.Vector3;function ConvexHull(){this.tolerance=-1,this.faces=[],this.newFaces=[],this.assigned=new VertexList,this.unassigned=new VertexList,this.vertices=[]}function Face(){this.normal=new three.Vector3,this.midpoint=new three.Vector3,this.area=0,this.constant=0,this.outside=null,this.mark=Visible,this.edge=null}function HalfEdge(vertex,face){this.vertex=vertex,this.prev=null,this.next=null,this.twin=null,this.face=face}function VertexNode(point){this.point=point,this.prev=null,this.next=null,this.face=null}function VertexList(){this.head=null,this.tail=null}return Object.assign(ConvexHull.prototype,{setFromPoints:function(points){!0!==Array.isArray(points)&&console.error("THREE.ConvexHull: Points parameter is not an array."),points.length<4&&console.error("THREE.ConvexHull: The algorithm needs at least four points."),this.makeEmpty();for(var i=0,l=points.length;ithis.tolerance)return!1}return!0},intersectRay:function(ray,target){for(var faces=this.faces,tNear=-1/0,tFar=1/0,i=0,l=faces.length;i0&&vD>=0)return null;var t=0!==vD?-vN/vD:0;if(!(t<=0)&&(vD>0?tFar=Math.min(t,tFar):tNear=Math.max(t,tNear),tNear>tFar))return null}return tNear!==-1/0?ray.at(tNear,target):ray.at(tFar,target),target},intersectsRay:function(ray){return null!==this.intersectRay(ray,v1)},makeEmpty:function(){return this.faces=[],this.vertices=[],this},addVertexToFace:function(vertex,face){return vertex.face=face,null===face.outside?this.assigned.append(vertex):this.assigned.insertBefore(face.outside,vertex),face.outside=vertex,this},removeVertexFromFace:function(vertex,face){return vertex===face.outside&&(null!==vertex.next&&vertex.next.face===face?face.outside=vertex.next:face.outside=null),this.assigned.remove(vertex),this},removeAllVerticesFromFace:function(face){if(null!==face.outside){for(var start=face.outside,end=face.outside;null!==end.next&&end.next.face===face;)end=end.next;return this.assigned.removeSubList(start,end),start.prev=end.next=null,face.outside=null,start}},deleteFaceVertices:function(face,absorbingFace){var faceVertices=this.removeAllVerticesFromFace(face);if(void 0!==faceVertices)if(void 0===absorbingFace)this.unassigned.appendChain(faceVertices);else{var vertex=faceVertices;do{var nextVertex=vertex.next;absorbingFace.distanceToPoint(vertex.point)>this.tolerance?this.addVertexToFace(vertex,absorbingFace):this.unassigned.append(vertex),vertex=nextVertex}while(null!==vertex)}return this},resolveUnassignedPoints:function(newFaces){if(!1===this.unassigned.isEmpty()){var vertex=this.unassigned.first();do{for(var nextVertex=vertex.next,maxDistance=this.tolerance,maxFace=null,i=0;imaxDistance&&(maxDistance=distance,maxFace=face),maxDistance>1e3*this.tolerance)break}}null!==maxFace&&this.addVertexToFace(vertex,maxFace),vertex=nextVertex}while(null!==vertex)}return this},computeExtremes:function(){var i,l,j,min=new three.Vector3,max=new three.Vector3,minVertices=[],maxVertices=[];for(i=0;i<3;i++)minVertices[i]=maxVertices[i]=this.vertices[0];for(min.copy(this.vertices[0].point),max.copy(this.vertices[0].point),i=0,l=this.vertices.length;imax.getComponent(j)&&(max.setComponent(j,point.getComponent(j)),maxVertices[j]=vertex)}return this.tolerance=3*Number.EPSILON*(Math.max(Math.abs(min.x),Math.abs(max.x))+Math.max(Math.abs(min.y),Math.abs(max.y))+Math.max(Math.abs(min.z),Math.abs(max.z))),{min:minVertices,max:maxVertices}},computeInitialHull:function(){void 0===line3&&(line3=new three.Line3,plane=new three.Plane,closestPoint=new three.Vector3);var vertex,v0,v1,v2,v3,i,l,j,distance,vertices=this.vertices,extremes=this.computeExtremes(),min=extremes.min,max=extremes.max,maxDistance=0,index=0;for(i=0;i<3;i++)(distance=max[i].point.getComponent(i)-min[i].point.getComponent(i))>maxDistance&&(maxDistance=distance,index=i);for(v0=min[index],v1=max[index],maxDistance=0,line3.set(v0.point,v1.point),i=0,l=this.vertices.length;imaxDistance&&(maxDistance=distance,v2=vertex));for(maxDistance=-1,plane.setFromCoplanarPoints(v0.point,v1.point,v2.point),i=0,l=this.vertices.length;imaxDistance&&(maxDistance=distance,v3=vertex);var faces=[];if(plane.distanceToPoint(v3.point)<0)for(faces.push(Face.create(v0,v1,v2),Face.create(v3,v1,v0),Face.create(v3,v2,v1),Face.create(v3,v0,v2)),i=0;i<3;i++)j=(i+1)%3,faces[i+1].getEdge(2).setTwin(faces[0].getEdge(j)),faces[i+1].getEdge(1).setTwin(faces[j+1].getEdge(0));else for(faces.push(Face.create(v0,v2,v1),Face.create(v3,v0,v1),Face.create(v3,v1,v2),Face.create(v3,v2,v0)),i=0;i<3;i++)j=(i+1)%3,faces[i+1].getEdge(2).setTwin(faces[0].getEdge((3-i)%3)),faces[i+1].getEdge(0).setTwin(faces[j+1].getEdge(1));for(i=0;i<4;i++)this.faces.push(faces[i]);for(i=0,l=vertices.length;imaxDistance&&(maxDistance=distance,maxFace=this.faces[j]);null!==maxFace&&this.addVertexToFace(vertex,maxFace)}return this},reindexFaces:function(){for(var activeFaces=[],i=0;imaxDistance&&(maxDistance=distance,eyeVertex=vertex),vertex=vertex.next}while(null!==vertex&&vertex.face===eyeFace);return eyeVertex}},computeHorizon:function(eyePoint,crossEdge,face,horizon){var edge;this.deleteFaceVertices(face),face.mark=1,edge=null===crossEdge?crossEdge=face.getEdge(0):crossEdge.next;do{var twinEdge=edge.twin,oppositeFace=twinEdge.face;oppositeFace.mark===Visible&&(oppositeFace.distanceToPoint(eyePoint)>this.tolerance?this.computeHorizon(eyePoint,twinEdge,oppositeFace,horizon):horizon.push(edge)),edge=edge.next}while(edge!==crossEdge);return this},addAdjoiningFace:function(eyeVertex,horizonEdge){var face=Face.create(eyeVertex,horizonEdge.tail(),horizonEdge.head());return this.faces.push(face),face.getEdge(-1).setTwin(horizonEdge.twin),face.getEdge(0)},addNewFaces:function(eyeVertex,horizon){this.newFaces=[];for(var firstSideEdge=null,previousSideEdge=null,i=0;i0;)edge=edge.next,i--;for(;i<0;)edge=edge.prev,i++;return edge},compute:function(){void 0===triangle&&(triangle=new three.Triangle);var a=this.edge.tail(),b=this.edge.head(),c=this.edge.next.head();return triangle.set(a.point,b.point,c.point),triangle.getNormal(this.normal),triangle.getMidpoint(this.midpoint),this.area=triangle.getArea(),this.constant=this.normal.dot(this.midpoint),this},distanceToPoint:function(point){return this.normal.dot(point)-this.constant}}),Object.assign(HalfEdge.prototype,{head:function(){return this.vertex},tail:function(){return this.prev?this.prev.vertex:null},length:function(){var head=this.head(),tail=this.tail();return null!==tail?tail.point.distanceTo(head.point):-1},lengthSquared:function(){var head=this.head(),tail=this.tail();return null!==tail?tail.point.distanceToSquared(head.point):-1},setTwin:function(edge){return this.twin=edge,edge.twin=this,this}}),Object.assign(VertexList.prototype,{first:function(){return this.head},last:function(){return this.tail},clear:function(){return this.head=this.tail=null,this},insertBefore:function(target,vertex){return vertex.prev=target.prev,vertex.next=target,null===vertex.prev?this.head=vertex:vertex.prev.next=vertex,target.prev=vertex,this},insertAfter:function(target,vertex){return vertex.prev=target,vertex.next=target.next,null===vertex.next?this.tail=vertex:vertex.next.prev=vertex,target.next=vertex,this},append:function(vertex){return null===this.head?this.head=vertex:this.tail.next=vertex,vertex.prev=this.tail,vertex.next=null,this.tail=vertex,this},appendChain:function(vertex){for(null===this.head?this.head=vertex:this.tail.next=vertex,vertex.prev=this.tail;null!==vertex.next;)vertex=vertex.next;return this.tail=vertex,this},remove:function(vertex){return null===vertex.prev?this.head=vertex.next:vertex.prev.next=vertex.next,null===vertex.next?this.tail=vertex.prev:vertex.next.prev=vertex.prev,this},removeSubList:function(a,b){return null===a.prev?this.head=b.next:a.prev.next=b.next,null===b.next?this.tail=a.prev:b.next.prev=a.prev,this},isEmpty:function(){return null===this.head}}),ConvexHull}();const _v1=new three.Vector3,_v2=new three.Vector3,_q1=new three.Quaternion;function getGeometry(object){const meshes=function(object){const meshes=[];return object.traverse(function(o){o.isMesh&&meshes.push(o)}),meshes}(object);if(0===meshes.length)return null;if(1===meshes.length)return normalizeGeometry(meshes[0]);let mesh;const geometries=[];for(;mesh=meshes.pop();)geometries.push(simplifyGeometry(normalizeGeometry(mesh)));return function(geometries){let vertexCount=0;for(let i=0;i{this.loadedEventFired=!0},{once:!0}),this.system.initialized&&this.loadedEventFired&&this.initBody()},initBody:function(){const pos=new THREE.Vector3,quat=new THREE.Quaternion;new THREE.Box3;return function(){const el=this.el,data=this.data;this.localScaling=new Ammo.btVector3;const obj=this.el.object3D;obj.getWorldPosition(pos),obj.getWorldQuaternion(quat),this.prevScale=new THREE.Vector3(1,1,1),this.prevNumChildShapes=0,this.msTransform=new Ammo.btTransform,this.msTransform.setIdentity(),this.rotation=new Ammo.btQuaternion(quat.x,quat.y,quat.z,quat.w),this.msTransform.getOrigin().setValue(pos.x,pos.y,pos.z),this.msTransform.setRotation(this.rotation),this.motionState=new Ammo.btDefaultMotionState(this.msTransform),this.localInertia=new Ammo.btVector3(0,0,0),this.compoundShape=new Ammo.btCompoundShape(!0),this.rbInfo=new Ammo.btRigidBodyConstructionInfo(data.mass,this.motionState,this.compoundShape,this.localInertia),this.rbInfo.m_restitution=((num,min,max)=>Math.min(Math.max(num,min),max))(this.data.restitution,0,1),this.body=new Ammo.btRigidBody(this.rbInfo),this.body.setActivationState(ACTIVATION_STATES.indexOf(data.activationState)+1),this.body.setSleepingThresholds(data.linearSleepingThreshold,data.angularSleepingThreshold),this.body.setDamping(data.linearDamping,data.angularDamping);const angularFactor=new Ammo.btVector3(data.angularFactor.x,data.angularFactor.y,data.angularFactor.z);this.body.setAngularFactor(angularFactor),Ammo.destroy(angularFactor);const gravity=new Ammo.btVector3(data.gravity.x,data.gravity.y,data.gravity.z);almostEqualsBtVector3(.001,gravity,this.system.driver.physicsWorld.getGravity())||(this.body.setGravity(gravity),this.body.setFlags(RIGID_BODY_FLAGS_DISABLE_WORLD_GRAVITY)),Ammo.destroy(gravity),this.updateCollisionFlags(),this.el.body=this.body,this.body.el=el,this.isLoaded=!0,this.el.emit("body-loaded",{body:this.el.body}),this._addToSystem()}}(),tick:function(){this.system.initialized&&!this.isLoaded&&this.loadedEventFired&&this.initBody()},_updateShapes:function(){const needsPolyhedralInitialization=[SHAPE.HULL,SHAPE.HACD,SHAPE.VHACD];return function(){let updated=!1;const obj=this.el.object3D;if(this.data.scaleAutoUpdate&&this.prevScale&&!almostEqualsVector3(.001,obj.scale,this.prevScale)&&(this.prevScale.copy(obj.scale),updated=!0,this.localScaling.setValue(this.prevScale.x,this.prevScale.y,this.prevScale.z),this.compoundShape.setLocalScaling(this.localScaling)),this.shapeComponentsChanged){this.shapeComponentsChanged=!1,updated=!0;for(let i=0;i0;){const collisionShape=this.collisionShapes.pop();collisionShape.destroy(),Ammo.destroy(collisionShape.localTransform)}}};module.exports.definition=AmmoShape,module.exports.Component=AFRAME.registerComponent("ammo-shape",AmmoShape)},{"../../constants":20,"three-to-ammo":6}],18:[function(require,module,exports){var CANNON=require("cannon-es"),Shape={schema:{shape:{default:"box",oneOf:["box","sphere","cylinder"]},offset:{type:"vec3",default:{x:0,y:0,z:0}},orientation:{type:"vec4",default:{x:0,y:0,z:0,w:1}},radius:{type:"number",default:1,if:{shape:["sphere"]}},halfExtents:{type:"vec3",default:{x:.5,y:.5,z:.5},if:{shape:["box"]}},radiusTop:{type:"number",default:1,if:{shape:["cylinder"]}},radiusBottom:{type:"number",default:1,if:{shape:["cylinder"]}},height:{type:"number",default:1,if:{shape:["cylinder"]}},numSegments:{type:"int",default:8,if:{shape:["cylinder"]}}},multiple:!0,init:function(){this.el.sceneEl.hasLoaded?this.initShape():this.el.sceneEl.addEventListener("loaded",this.initShape.bind(this))},initShape:function(){this.bodyEl=this.el;for(var bodyType=this._findType(this.bodyEl),data=this.data;!bodyType&&this.bodyEl.parentNode!=this.el.sceneEl;)this.bodyEl=this.bodyEl.parentNode,bodyType=this._findType(this.bodyEl);if(bodyType){var shape,offset,orientation,scale=new THREE.Vector3;switch(this.bodyEl.object3D.getWorldScale(scale),data.hasOwnProperty("offset")&&(offset=new CANNON.Vec3(data.offset.x*scale.x,data.offset.y*scale.y,data.offset.z*scale.z)),data.hasOwnProperty("orientation")&&(orientation=new CANNON.Quaternion).copy(data.orientation),data.shape){case"sphere":shape=new CANNON.Sphere(data.radius*scale.x);break;case"box":var halfExtents=new CANNON.Vec3(data.halfExtents.x*scale.x,data.halfExtents.y*scale.y,data.halfExtents.z*scale.z);shape=new CANNON.Box(halfExtents);break;case"cylinder":shape=new CANNON.Cylinder(data.radiusTop*scale.x,data.radiusBottom*scale.x,data.height*scale.y,data.numSegments);var quat=new CANNON.Quaternion;quat.setFromEuler(90*THREE.Math.DEG2RAD,0,0,"XYZ").normalize(),orientation.mult(quat,orientation);break;default:return void console.warn(data.shape+" shape not supported")}this.bodyEl.body?this.bodyEl.components[bodyType].addShape(shape,offset,orientation):this.bodyEl.addEventListener("body-loaded",function(){this.bodyEl.components[bodyType].addShape(shape,offset,orientation)},{once:!0})}else console.warn("body not found")},_findType:function(el){return el.hasAttribute("body")?"body":el.hasAttribute("dynamic-body")?"dynamic-body":el.hasAttribute("static-body")?"static-body":null},remove:function(){this.bodyEl.parentNode&&console.warn("removing shape component not currently supported")}};module.exports.definition=Shape,module.exports.Component=AFRAME.registerComponent("shape",Shape)},{"cannon-es":5}],19:[function(require,module,exports){var CANNON=require("cannon-es");module.exports=AFRAME.registerComponent("spring",{multiple:!0,schema:{target:{type:"selector"},restLength:{default:1,min:0},stiffness:{default:100,min:0},damping:{default:1,min:0},localAnchorA:{type:"vec3",default:{x:0,y:0,z:0}},localAnchorB:{type:"vec3",default:{x:0,y:0,z:0}}},init:function(){this.system=this.el.sceneEl.systems.physics,this.system.addComponent(this),this.isActive=!0,this.spring=null},update:function(oldData){var el=this.el,data=this.data;data.target?el.body&&data.target.body?(this.createSpring(),this.updateSpring(oldData)):(el.body?data.target:el).addEventListener("body-loaded",this.update.bind(this,{})):console.warn("Spring: invalid target specified.")},updateSpring:function(oldData){if(this.spring){var data=this.data,spring=this.spring;Object.keys(data).forEach(function(attr){if(data[attr]!==oldData[attr]){if("target"===attr)return void(spring.bodyB=data.target.body);spring[attr]=data[attr]}})}else console.warn("Spring: Component attempted to change spring before its created. No changes made.")},createSpring:function(){this.spring||(this.spring=new CANNON.Spring(this.el.body))},step:function(t,dt){return this.spring&&this.isActive?this.spring.applyForce():void 0},play:function(){this.isActive=!0},pause:function(){this.isActive=!1},remove:function(){this.spring&&delete this.spring,this.spring=null}})},{"cannon-es":5}],20:[function(require,module,exports){module.exports={GRAVITY:-9.8,MAX_INTERVAL:4/60,ITERATIONS:10,CONTACT_MATERIAL:{friction:.01,restitution:.3,contactEquationStiffness:1e8,contactEquationRelaxation:3,frictionEquationStiffness:1e8,frictionEquationRegularization:3},ACTIVATION_STATE:{ACTIVE_TAG:"active",ISLAND_SLEEPING:"islandSleeping",WANTS_DEACTIVATION:"wantsDeactivation",DISABLE_DEACTIVATION:"disableDeactivation",DISABLE_SIMULATION:"disableSimulation"},COLLISION_FLAG:{STATIC_OBJECT:1,KINEMATIC_OBJECT:2,NO_CONTACT_RESPONSE:4,CUSTOM_MATERIAL_CALLBACK:8,CHARACTER_OBJECT:16,DISABLE_VISUALIZE_OBJECT:32,DISABLE_SPU_COLLISION_PROCESSING:64},TYPE:{STATIC:"static",DYNAMIC:"dynamic",KINEMATIC:"kinematic"},SHAPE:{BOX:"box",CYLINDER:"cylinder",SPHERE:"sphere",CAPSULE:"capsule",CONE:"cone",HULL:"hull",HACD:"hacd",VHACD:"vhacd",MESH:"mesh",HEIGHTFIELD:"heightfield"},FIT:{ALL:"all",MANUAL:"manual"},CONSTRAINT:{LOCK:"lock",FIXED:"fixed",SPRING:"spring",SLIDER:"slider",HINGE:"hinge",CONE_TWIST:"coneTwist",POINT_TO_POINT:"pointToPoint"}}},{}],21:[function(require,module,exports){const Driver=require("./driver");"undefined"!=typeof window&&(window.AmmoModule=window.Ammo,window.Ammo=null);function AmmoDriver(){this.collisionConfiguration=null,this.dispatcher=null,this.broadphase=null,this.solver=null,this.physicsWorld=null,this.debugDrawer=null,this.els=new Map,this.eventListeners=[],this.collisions=new Map,this.collisionKeys=[],this.currentCollisions=new Map}AmmoDriver.prototype=new Driver,AmmoDriver.prototype.constructor=AmmoDriver,module.exports=AmmoDriver,AmmoDriver.prototype.init=function(worldConfig){return new Promise(resolve=>{AmmoModule().then(result=>{Ammo=result,this.epsilon=worldConfig.epsilon||1e-5,this.debugDrawMode=worldConfig.debugDrawMode||THREE.AmmoDebugConstants.NoDebug,this.maxSubSteps=worldConfig.maxSubSteps||4,this.fixedTimeStep=worldConfig.fixedTimeStep||1/60,this.collisionConfiguration=new Ammo.btDefaultCollisionConfiguration,this.dispatcher=new Ammo.btCollisionDispatcher(this.collisionConfiguration),this.broadphase=new Ammo.btDbvtBroadphase,this.solver=new Ammo.btSequentialImpulseConstraintSolver,this.physicsWorld=new Ammo.btDiscreteDynamicsWorld(this.dispatcher,this.broadphase,this.solver,this.collisionConfiguration),this.physicsWorld.setForceUpdateAllAabbs(!1),this.physicsWorld.setGravity(new Ammo.btVector3(0,worldConfig.hasOwnProperty("gravity")?worldConfig.gravity:-9.8,0)),this.physicsWorld.getSolverInfo().set_m_numIterations(worldConfig.solverIterations),resolve()})})},AmmoDriver.prototype.addBody=function(body,group,mask){this.physicsWorld.addRigidBody(body,group,mask),this.els.set(Ammo.getPointer(body),body.el)},AmmoDriver.prototype.removeBody=function(body){this.physicsWorld.removeRigidBody(body),this.removeEventListener(body);const bodyptr=Ammo.getPointer(body);this.els.delete(bodyptr),this.collisions.delete(bodyptr),this.collisionKeys.splice(this.collisionKeys.indexOf(bodyptr),1),this.currentCollisions.delete(bodyptr)},AmmoDriver.prototype.updateBody=function(body){this.els.has(Ammo.getPointer(body))&&this.physicsWorld.updateSingleAabb(body)},AmmoDriver.prototype.step=function(deltaTime){this.physicsWorld.stepSimulation(deltaTime,this.maxSubSteps,this.fixedTimeStep);const numManifolds=this.dispatcher.getNumManifolds();for(let i=0;i=0;j--){const body1ptr=body1ptrs[j];this.currentCollisions.get(body0ptr).has(body1ptr)||(-1!==this.eventListeners.indexOf(body0ptr)&&this.els.get(body0ptr).emit("collideend",{targetEl:this.els.get(body1ptr)}),-1!==this.eventListeners.indexOf(body1ptr)&&this.els.get(body1ptr).emit("collideend",{targetEl:this.els.get(body0ptr)}),body1ptrs.splice(j,1))}this.currentCollisions.get(body0ptr).clear()}this.debugDrawer&&this.debugDrawer.update()},AmmoDriver.prototype.addConstraint=function(constraint){this.physicsWorld.addConstraint(constraint,!1)},AmmoDriver.prototype.removeConstraint=function(constraint){this.physicsWorld.removeConstraint(constraint)},AmmoDriver.prototype.addEventListener=function(body){this.eventListeners.push(Ammo.getPointer(body))},AmmoDriver.prototype.removeEventListener=function(body){const ptr=Ammo.getPointer(body);-1!==this.eventListeners.indexOf(ptr)&&this.eventListeners.splice(this.eventListeners.indexOf(ptr),1)},AmmoDriver.prototype.destroy=function(){Ammo.destroy(this.collisionConfiguration),Ammo.destroy(this.dispatcher),Ammo.destroy(this.broadphase),Ammo.destroy(this.solver),Ammo.destroy(this.physicsWorld),Ammo.destroy(this.debugDrawer)},AmmoDriver.prototype.getDebugDrawer=function(scene,options){return this.debugDrawer||((options=options||{}).debugDrawMode=options.debugDrawMode||this.debugDrawMode,this.debugDrawer=new THREE.AmmoDebugDrawer(scene,this.physicsWorld,options)),this.debugDrawer}},{"./driver":22}],22:[function(require,module,exports){function Driver(){}function abstractMethod(){throw new Error("Method not implemented.")}module.exports=Driver,Driver.prototype.init=abstractMethod,Driver.prototype.step=abstractMethod,Driver.prototype.destroy=abstractMethod,Driver.prototype.addBody=abstractMethod,Driver.prototype.removeBody=abstractMethod,Driver.prototype.applyBodyMethod=abstractMethod,Driver.prototype.updateBodyProperties=abstractMethod,Driver.prototype.addMaterial=abstractMethod,Driver.prototype.addContactMaterial=abstractMethod,Driver.prototype.addConstraint=abstractMethod,Driver.prototype.removeConstraint=abstractMethod,Driver.prototype.getContacts=abstractMethod},{}],23:[function(require,module,exports){module.exports={INIT:"init",STEP:"step",ADD_BODY:"add-body",REMOVE_BODY:"remove-body",APPLY_BODY_METHOD:"apply-body-method",UPDATE_BODY_PROPERTIES:"update-body-properties",ADD_MATERIAL:"add-material",ADD_CONTACT_MATERIAL:"add-contact-material",ADD_CONSTRAINT:"add-constraint",REMOVE_CONSTRAINT:"remove-constraint",COLLIDE:"collide"}},{}],24:[function(require,module,exports){var CANNON=require("cannon-es"),Driver=require("./driver");function LocalDriver(){this.world=null,this.materials={},this.contactMaterial=null}LocalDriver.prototype=new Driver,LocalDriver.prototype.constructor=LocalDriver,module.exports=LocalDriver,LocalDriver.prototype.init=function(worldConfig){var world=new CANNON.World;world.quatNormalizeSkip=worldConfig.quatNormalizeSkip,world.quatNormalizeFast=worldConfig.quatNormalizeFast,world.solver.iterations=worldConfig.solverIterations,world.gravity.set(0,worldConfig.gravity,0),world.broadphase=new CANNON.NaiveBroadphase,this.world=world},LocalDriver.prototype.step=function(deltaMS){this.world.step(deltaMS)},LocalDriver.prototype.destroy=function(){delete this.world,delete this.contactMaterial,this.materials={}},LocalDriver.prototype.addBody=function(body){this.world.addBody(body)},LocalDriver.prototype.removeBody=function(body){this.world.removeBody(body)},LocalDriver.prototype.applyBodyMethod=function(body,methodName,args){body["__"+methodName].apply(body,args)},LocalDriver.prototype.updateBodyProperties=function(){},LocalDriver.prototype.getMaterial=function(name){return this.materials[name]},LocalDriver.prototype.addMaterial=function(materialConfig){this.materials[materialConfig.name]=new CANNON.Material(materialConfig),this.materials[materialConfig.name].name=materialConfig.name},LocalDriver.prototype.addContactMaterial=function(matName1,matName2,contactMaterialConfig){var mat1=this.materials[matName1],mat2=this.materials[matName2];this.contactMaterial=new CANNON.ContactMaterial(mat1,mat2,contactMaterialConfig),this.world.addContactMaterial(this.contactMaterial)},LocalDriver.prototype.addConstraint=function(constraint){constraint.type||(constraint instanceof CANNON.LockConstraint?constraint.type="LockConstraint":constraint instanceof CANNON.DistanceConstraint?constraint.type="DistanceConstraint":constraint instanceof CANNON.HingeConstraint?constraint.type="HingeConstraint":constraint instanceof CANNON.ConeTwistConstraint?constraint.type="ConeTwistConstraint":constraint instanceof CANNON.PointToPointConstraint&&(constraint.type="PointToPointConstraint")),this.world.addConstraint(constraint)},LocalDriver.prototype.removeConstraint=function(constraint){this.world.removeConstraint(constraint)},LocalDriver.prototype.getContacts=function(){return this.world.contacts}},{"./driver":22,"cannon-es":5}],25:[function(require,module,exports){var Driver=require("./driver");function NetworkDriver(){throw new Error("[NetworkDriver] Driver not implemented.")}NetworkDriver.prototype=new Driver,NetworkDriver.prototype.constructor=NetworkDriver,module.exports=NetworkDriver},{"./driver":22}],26:[function(require,module,exports){function EventTarget(){this.listeners=[]}module.exports=function(worker){var targetA=new EventTarget,targetB=new EventTarget;return targetA.setTarget(targetB),targetB.setTarget(targetA),worker(targetA),targetB},EventTarget.prototype.setTarget=function(target){this.target=target},EventTarget.prototype.addEventListener=function(type,fn){this.listeners.push(fn)},EventTarget.prototype.dispatchEvent=function(type,event){for(var i=0;ithis.frameDelay;)this.frameBuffer.shift(),prevFrame=this.frameBuffer[0],nextFrame=this.frameBuffer[1];if(prevFrame&&nextFrame){var mix=(timestamp-prevFrame.timestamp)/this.frameDelay;for(var id in mix=(mix-(1-1/this.interpBufferSize))*this.interpBufferSize,prevFrame.bodies)prevFrame.bodies.hasOwnProperty(id)&&nextFrame.bodies.hasOwnProperty(id)&&protocol.deserializeInterpBodyUpdate(prevFrame.bodies[id],nextFrame.bodies[id],this.bodies[id],mix)}}},WorkerDriver.prototype.destroy=function(){this.worker.terminate(),delete this.worker},WorkerDriver.prototype._onMessage=function(event){if(event.data.type===Event.STEP){var bodies=event.data.bodies;if(this.contacts=event.data.contacts,this.interpolate)this.frameBuffer.push({timestamp:performance.now(),bodies:bodies});else for(var id in bodies)bodies.hasOwnProperty(id)&&protocol.deserializeBodyUpdate(bodies[id],this.bodies[id])}else{if(event.data.type!==Event.COLLIDE)throw new Error("[WorkerDriver] Unexpected message type.");var body=this.bodies[event.data.bodyID],target=this.bodies[event.data.targetID],contact=protocol.deserializeContact(event.data.contact,this.bodies);if(!body._listeners||!body._listeners.collide)return;for(var i=0;ithis.countBodiesAmmo(),local:()=>this.countBodiesCannon(!1),worker:()=>this.countBodiesCannon(!0)},this.bodyTypeToStatsPropertyMap={ammo:{[TYPE.STATIC]:"staticBodies",[TYPE.KINEMATIC]:"kinematicBodies",[TYPE.DYNAMIC]:"dynamicBodies"},cannon:{[CANNON.Body.STATIC]:"staticBodies",[CANNON.Body.DYNAMIC]:"dynamicBodies"}},this.el.sceneEl.setAttribute("stats-collector","inEvent: physics-tick-data;\n properties: before, after, engine, total;\n outputFrequency: 100;\n outEvent: physics-tick-summary;\n outputs: percentile__50, percentile__90, max")}if(this.statsToPanel){const scene=this.el.sceneEl,space="   ";scene.setAttribute("stats-panel",""),scene.setAttribute("stats-group__bodies","label: Physics Bodies"),scene.setAttribute("stats-row__b1","group: bodies;\n event:physics-body-data;\n properties: staticBodies;\n label: Static"),scene.setAttribute("stats-row__b2","group: bodies;\n event:physics-body-data;\n properties: dynamicBodies;\n label: Dynamic"),"local"===this.data.driver||"worker"===this.data.driver?scene.setAttribute("stats-row__b3","group: bodies;\n event:physics-body-data;\n properties: contacts;\n label: Contacts"):"ammo"===this.data.driver&&(scene.setAttribute("stats-row__b3","group: bodies;\n event:physics-body-data;\n properties: kinematicBodies;\n label: Kinematic"),scene.setAttribute("stats-row__b4","group: bodies;\n event: physics-body-data;\n properties: manifolds;\n label: Manifolds"),scene.setAttribute("stats-row__b5","group: bodies;\n event: physics-body-data;\n properties: manifoldContacts;\n label: Contacts"),scene.setAttribute("stats-row__b6","group: bodies;\n event: physics-body-data;\n properties: collisions;\n label: Collisions"),scene.setAttribute("stats-row__b7","group: bodies;\n event: physics-body-data;\n properties: collisionKeys;\n label: Coll Keys")),scene.setAttribute("stats-group__tick",`label: Physics Ticks: Median${space}90th%${space}99th%`),scene.setAttribute("stats-row__1","group: tick;\n event:physics-tick-summary;\n properties: before.percentile__50, \n before.percentile__90, \n before.max;\n label: Before"),scene.setAttribute("stats-row__2","group: tick;\n event:physics-tick-summary;\n properties: after.percentile__50, \n after.percentile__90, \n after.max; \n label: After"),scene.setAttribute("stats-row__3","group: tick; \n event:physics-tick-summary; \n properties: engine.percentile__50, \n engine.percentile__90, \n engine.max;\n label: Engine"),scene.setAttribute("stats-row__4","group: tick;\n event:physics-tick-summary;\n properties: total.percentile__50, \n total.percentile__90, \n total.max;\n label: Total")}},tick:function(t,dt){if(!this.initialized||!dt)return;const beforeStartTime=performance.now();var i,callbacks=this.callbacks;for(i=0;i{const property=this.bodyTypeToStatsPropertyMap.ammo[(el=el,el.components["ammo-body"].data.type)];statsData[property]++})},countBodiesCannon(worker){const statsData=this.statsBodyData;statsData.contacts=worker?this.driver.contacts.length:this.driver.world.contacts.length,statsData.staticBodies=0,statsData.dynamicBodies=0,(worker?Object.values(this.driver.bodies):this.driver.world.bodies).forEach(body=>{const property=this.bodyTypeToStatsPropertyMap.cannon[body.type];statsData[property]++})},setDebug:function(debug){this.debug=debug,"ammo"===this.data.driver&&this.initialized&&(debug&&!this.debugDrawer?(this.debugDrawer=this.driver.getDebugDrawer(this.el.object3D),this.debugDrawer.enable()):this.debugDrawer&&(this.debugDrawer.disable(),this.debugDrawer=null))},addBody:function(body,group,mask){var driver=this.driver;"local"===this.data.driver&&(body.__applyImpulse=body.applyImpulse,body.applyImpulse=function(){driver.applyBodyMethod(body,"applyImpulse",arguments)},body.__applyForce=body.applyForce,body.applyForce=function(){driver.applyBodyMethod(body,"applyForce",arguments)},body.updateProperties=function(){driver.updateBodyProperties(body)},this.listeners[body.id]=function(e){body.el.emit("collide",e)},body.addEventListener("collide",this.listeners[body.id])),this.driver.addBody(body,group,mask)},removeBody:function(body){this.driver.removeBody(body),"local"!==this.data.driver&&"worker"!==this.data.driver||(body.removeEventListener("collide",this.listeners[body.id]),delete this.listeners[body.id],body.applyImpulse=body.__applyImpulse,delete body.__applyImpulse,body.applyForce=body.__applyForce,delete body.__applyForce,delete body.updateProperties)},addConstraint:function(constraint){this.driver.addConstraint(constraint)},removeConstraint:function(constraint){this.driver.removeConstraint(constraint)},addComponent:function(component){var callbacks=this.callbacks;component.beforeStep&&callbacks.beforeStep.push(component),component.step&&callbacks.step.push(component),component.afterStep&&callbacks.afterStep.push(component)},removeComponent:function(component){var callbacks=this.callbacks;component.beforeStep&&callbacks.beforeStep.splice(callbacks.beforeStep.indexOf(component),1),component.step&&callbacks.step.splice(callbacks.step.indexOf(component),1),component.afterStep&&callbacks.afterStep.splice(callbacks.afterStep.indexOf(component),1)},getContacts:function(){return this.driver.getContacts()},getMaterial:function(name){return this.driver.getMaterial(name)}})},{"./constants":20,"./drivers/ammo-driver":21,"./drivers/local-driver":24,"./drivers/network-driver":25,"./drivers/worker-driver":27,"aframe-stats-panel":3,"cannon-es":5}],30:[function(require,module,exports){module.exports.slerp=function(a,b,t){if(t<=0)return a;if(t>=1)return b;var x=a[0],y=a[1],z=a[2],w=a[3],cosHalfTheta=w*b[3]+x*b[0]+y*b[1]+z*b[2];if(!(cosHalfTheta<0))return b;if((a=a.slice())[3]=-b[3],a[0]=-b[0],a[1]=-b[1],a[2]=-b[2],(cosHalfTheta=-cosHalfTheta)>=1)return a[3]=w,a[0]=x,a[1]=y,a[2]=z,this;var sinHalfTheta=Math.sqrt(1-cosHalfTheta*cosHalfTheta);if(Math.abs(sinHalfTheta)<.001)return a[3]=.5*(w+a[3]),a[0]=.5*(x+a[0]),a[1]=.5*(y+a[1]),a[2]=.5*(z+a[2]),this;var halfTheta=Math.atan2(sinHalfTheta,cosHalfTheta),ratioA=Math.sin((1-t)*halfTheta)/sinHalfTheta,ratioB=Math.sin(t*halfTheta)/sinHalfTheta;return a[3]=w*ratioA+a[3]*ratioB,a[0]=x*ratioA+a[0]*ratioB,a[1]=y*ratioA+a[1]*ratioB,a[2]=z*ratioA+a[2]*ratioB,a}},{}],31:[function(require,module,exports){var CANNON=require("cannon-es"),mathUtils=require("./math"),ID="__id";module.exports.ID=ID;var nextID={};function serializeShape(shape){var shapeMsg={type:shape.type};if(shape.type===CANNON.Shape.types.BOX)shapeMsg.halfExtents=serializeVec3(shape.halfExtents);else if(shape.type===CANNON.Shape.types.SPHERE)shapeMsg.radius=shape.radius;else{if(shape._type!==CANNON.Shape.types.CYLINDER)throw new Error("Unimplemented shape type: %s",shape.type);shapeMsg.type=CANNON.Shape.types.CYLINDER,shapeMsg.radiusTop=shape.radiusTop,shapeMsg.radiusBottom=shape.radiusBottom,shapeMsg.height=shape.height,shapeMsg.numSegments=shape.numSegments}return shapeMsg}function deserializeShape(message){var shape;if(message.type===CANNON.Shape.types.BOX)shape=new CANNON.Box(deserializeVec3(message.halfExtents));else if(message.type===CANNON.Shape.types.SPHERE)shape=new CANNON.Sphere(message.radius);else{if(message.type!==CANNON.Shape.types.CYLINDER)throw new Error("Unimplemented shape type: %s",message.type);(shape=new CANNON.Cylinder(message.radiusTop,message.radiusBottom,message.height,message.numSegments))._type=CANNON.Shape.types.CYLINDER}return shape}function serializeVec3(vec3){return vec3.toArray()}function deserializeVec3(message){return new CANNON.Vec3(message[0],message[1],message[2])}function serializeQuaternion(quat){return quat.toArray()}function deserializeQuaternion(message){return new CANNON.Quaternion(message[0],message[1],message[2],message[3])}module.exports.assignID=function(prefix,object){object[ID]||(nextID[prefix]=nextID[prefix]||1,object[ID]=prefix+"_"+nextID[prefix]++)},module.exports.serializeBody=function(body){return{shapes:body.shapes.map(serializeShape),shapeOffsets:body.shapeOffsets.map(serializeVec3),shapeOrientations:body.shapeOrientations.map(serializeQuaternion),position:serializeVec3(body.position),quaternion:body.quaternion.toArray(),velocity:serializeVec3(body.velocity),angularVelocity:serializeVec3(body.angularVelocity),id:body[ID],mass:body.mass,linearDamping:body.linearDamping,angularDamping:body.angularDamping,fixedRotation:body.fixedRotation,allowSleep:body.allowSleep,sleepSpeedLimit:body.sleepSpeedLimit,sleepTimeLimit:body.sleepTimeLimit}},module.exports.deserializeBodyUpdate=function(message,body){return body.position.set(message.position[0],message.position[1],message.position[2]),body.quaternion.set(message.quaternion[0],message.quaternion[1],message.quaternion[2],message.quaternion[3]),body.velocity.set(message.velocity[0],message.velocity[1],message.velocity[2]),body.angularVelocity.set(message.angularVelocity[0],message.angularVelocity[1],message.angularVelocity[2]),body.linearDamping=message.linearDamping,body.angularDamping=message.angularDamping,body.fixedRotation=message.fixedRotation,body.allowSleep=message.allowSleep,body.sleepSpeedLimit=message.sleepSpeedLimit,body.sleepTimeLimit=message.sleepTimeLimit,body.mass!==message.mass&&(body.mass=message.mass,body.updateMassProperties()),body},module.exports.deserializeInterpBodyUpdate=function(message1,message2,body,mix){var weight1=1-mix,weight2=mix;body.position.set(message1.position[0]*weight1+message2.position[0]*weight2,message1.position[1]*weight1+message2.position[1]*weight2,message1.position[2]*weight1+message2.position[2]*weight2);var quaternion=mathUtils.slerp(message1.quaternion,message2.quaternion,mix);return body.quaternion.set(quaternion[0],quaternion[1],quaternion[2],quaternion[3]),body.velocity.set(message1.velocity[0]*weight1+message2.velocity[0]*weight2,message1.velocity[1]*weight1+message2.velocity[1]*weight2,message1.velocity[2]*weight1+message2.velocity[2]*weight2),body.angularVelocity.set(message1.angularVelocity[0]*weight1+message2.angularVelocity[0]*weight2,message1.angularVelocity[1]*weight1+message2.angularVelocity[1]*weight2,message1.angularVelocity[2]*weight1+message2.angularVelocity[2]*weight2),body.linearDamping=message2.linearDamping,body.angularDamping=message2.angularDamping,body.fixedRotation=message2.fixedRotation,body.allowSleep=message2.allowSleep,body.sleepSpeedLimit=message2.sleepSpeedLimit,body.sleepTimeLimit=message2.sleepTimeLimit,body.mass!==message2.mass&&(body.mass=message2.mass,body.updateMassProperties()),body},module.exports.deserializeBody=function(message){for(var shapeMsg,body=new CANNON.Body({mass:message.mass,position:deserializeVec3(message.position),quaternion:deserializeQuaternion(message.quaternion),velocity:deserializeVec3(message.velocity),angularVelocity:deserializeVec3(message.angularVelocity),linearDamping:message.linearDamping,angularDamping:message.angularDamping,fixedRotation:message.fixedRotation,allowSleep:message.allowSleep,sleepSpeedLimit:message.sleepSpeedLimit,sleepTimeLimit:message.sleepTimeLimit}),i=0;shapeMsg=message.shapes[i];i++)body.addShape(deserializeShape(shapeMsg),deserializeVec3(message.shapeOffsets[i]),deserializeQuaternion(message.shapeOrientations[i]));return body[ID]=message.id,body},module.exports.serializeShape=serializeShape,module.exports.deserializeShape=deserializeShape,module.exports.serializeConstraint=function(constraint){var message={id:constraint[ID],type:constraint.type,maxForce:constraint.maxForce,bodyA:constraint.bodyA[ID],bodyB:constraint.bodyB[ID]};switch(constraint.type){case"LockConstraint":break;case"DistanceConstraint":message.distance=constraint.distance;break;case"HingeConstraint":case"ConeTwistConstraint":message.axisA=serializeVec3(constraint.axisA),message.axisB=serializeVec3(constraint.axisB),message.pivotA=serializeVec3(constraint.pivotA),message.pivotB=serializeVec3(constraint.pivotB);break;case"PointToPointConstraint":message.pivotA=serializeVec3(constraint.pivotA),message.pivotB=serializeVec3(constraint.pivotB);break;default:throw new Error("Unexpected constraint type: "+constraint.type+'. You may need to manually set `constraint.type = "FooConstraint";`.')}return message},module.exports.deserializeConstraint=function(message,bodies){var constraint,TypedConstraint=CANNON[message.type],bodyA=bodies[message.bodyA],bodyB=bodies[message.bodyB];switch(message.type){case"LockConstraint":constraint=new CANNON.LockConstraint(bodyA,bodyB,message);break;case"DistanceConstraint":constraint=new CANNON.DistanceConstraint(bodyA,bodyB,message.distance,message.maxForce);break;case"HingeConstraint":case"ConeTwistConstraint":constraint=new TypedConstraint(bodyA,bodyB,{pivotA:deserializeVec3(message.pivotA),pivotB:deserializeVec3(message.pivotB),axisA:deserializeVec3(message.axisA),axisB:deserializeVec3(message.axisB),maxForce:message.maxForce});break;case"PointToPointConstraint":constraint=new CANNON.PointToPointConstraint(bodyA,deserializeVec3(message.pivotA),bodyB,deserializeVec3(message.pivotB),message.maxForce);break;default:throw new Error("Unexpected constraint type: "+message.type)}return constraint[ID]=message.id,constraint},module.exports.serializeContact=function(contact){return{bi:contact.bi[ID],bj:contact.bj[ID],ni:serializeVec3(contact.ni),ri:serializeVec3(contact.ri),rj:serializeVec3(contact.rj)}},module.exports.deserializeContact=function(message,bodies){return{bi:bodies[message.bi],bj:bodies[message.bj],ni:deserializeVec3(message.ni),ri:deserializeVec3(message.ri),rj:deserializeVec3(message.rj)}},module.exports.serializeVec3=serializeVec3,module.exports.deserializeVec3=deserializeVec3,module.exports.serializeQuaternion=serializeQuaternion,module.exports.deserializeQuaternion=deserializeQuaternion},{"./math":30,"cannon-es":5}]},{},[1]); \ No newline at end of file +/*! For license information please see aframe-physics-system.min.js.LICENSE.txt */ +(()=>{var t={10:(t,e,i)=>{var n=i(687);i(421),i(854),i(344),i(775),i(838),i(404),i(938),i(592),i(696),i(890),i(855),t.exports={registerAll:function(){console.warn("registerAll() is deprecated. Components are automatically registered.")}},window.CANNON=window.CANNON||n},503:(t,e,i)=>{var n=i(687);n.shape2mesh=function(t){var e=new THREE.Object3D;function i(t,e){var i=new THREE.BufferGeometry;return i.setAttribute("position",new THREE.Float32BufferAttribute(t,3)),i.setIndex(e),i.computeBoundingSphere(),i}for(var s=0;s{AFRAME.registerComponent("stats-panel",{schema:{merge:{type:"boolean",default:!0}},init(){const t=document.querySelector(".rs-container");if(t&&this.data.merge)return void(this.container=t);this.base=document.createElement("div"),this.base.classList.add("rs-base");const e=document.body||document.getElementsByTagName("body")[0];t&&!this.data.merge&&(this.base.style.top="auto",this.base.style.bottom="20px"),e.appendChild(this.base),this.container=document.createElement("div"),this.container.classList.add("rs-container"),this.base.appendChild(this.container)}}),AFRAME.registerComponent("stats-group",{multiple:!0,schema:{label:{type:"string"}},init(){let t;const e=this.el.components["stats-panel"];t=e?e.container:document.querySelector(".rs-container"),t?(this.groupHeader=document.createElement("h1"),this.groupHeader.innerHTML=this.data.label,t.appendChild(this.groupHeader),this.group=document.createElement("div"),this.group.classList.add("rs-group"),this.group.style.flexDirection="column",this.group.style.webKitFlexDirection="column",t.appendChild(this.group)):console.warn("Couldn't find stats container to add stats to.\n Add either stats or stats-panel component to a-scene")}}),AFRAME.registerComponent("stats-row",{multiple:!0,schema:{group:{type:"string"},event:{type:"string"},properties:{type:"array"},label:{type:"string"}},init(){const t="stats-group__"+this.data.group,e=this.el.components[t]||this.el.sceneEl.components[t]||this.el.components["stats-group"]||this.el.sceneEl.components["stats-group"];e?(this.counter=document.createElement("div"),this.counter.classList.add("rs-counter-base"),e.group.appendChild(this.counter),this.counterId=document.createElement("div"),this.counterId.classList.add("rs-counter-id"),this.counterId.innerHTML=this.data.label,this.counter.appendChild(this.counterId),this.counterValues={},this.data.properties.forEach((t=>{const e=document.createElement("div");e.classList.add("rs-counter-value"),e.innerHTML="...",this.counter.appendChild(e),this.counterValues[t]=e})),this.updateData=this.updateData.bind(this),this.el.addEventListener(this.data.event,this.updateData),this.splitCache={}):console.warn(`Couldn't find stats group ${t}`)},updateData(t){this.data.properties.forEach((e=>{const n=this.splitDot(e);let s=t.detail;for(i=0;i{this.outputDetail[t]={}})),this.statsReceived=this.statsReceived.bind(this),this.el.addEventListener(this.data.inEvent,this.statsReceived)},resetData(){this.counter=0,this.data.properties.forEach((t=>{this.statsData[t]=[]}))},statsReceived(t){this.updateData(t.detail),this.counter++,this.counter===this.data.outputFrequency&&(this.outputData(),this.resetData())},updateData(t){this.data.properties.forEach((e=>{let i=t;i=i[e],this.statsData[e].push(i)}))},outputData(){this.data.properties.forEach((t=>{this.data.outputs.forEach((e=>{this.outputDetail[t][e]=this.computeOutput(e,this.statsData[t])}))})),this.data.outEvent&&this.el.emit(this.data.outEvent,this.outputDetail),this.data.outputToConsole&&console.log(this.data.outputToConsole,this.outputDetail)},computeOutput(t,e){const i=t.split("__");let n;switch(i[0]){case"mean":n=e.reduce(((t,e)=>t+e),0)/e.length;break;case"max":n=Math.max(...e);break;case"min":n=Math.min(...e);break;case"percentile":const t=e.sort(((t,e)=>t-e)),s=+i[1].replace("_",".")/100,r=(e.length-1)*s,o=Math.floor(r),a=r-o;n=void 0!==t[o+1]?t[o]+a*(t[o+1]-t[o]):t[o]}return n.toFixed(2)}})},694:()=>{THREE.AmmoDebugConstants={NoDebug:0,DrawWireframe:1,DrawAabb:2,DrawFeaturesText:4,DrawContactPoints:8,NoDeactivation:16,NoHelpText:32,DrawText:64,ProfileTimings:128,EnableSatComparison:256,DisableBulletLCP:512,EnableCCD:1024,DrawConstraints:2048,DrawConstraintLimits:4096,FastWireframe:8192,DrawNormals:16384,DrawOnTop:32768,MAX_DEBUG_DRAW_MODE:4294967295},THREE.AmmoDebugDrawer=function(t,e,i){this.scene=t,this.world=e,i=i||{},this.debugDrawMode=i.debugDrawMode||THREE.AmmoDebugConstants.DrawWireframe;var n=this.debugDrawMode&THREE.AmmoDebugConstants.DrawOnTop||!1,s=i.maxBufferSize||1e6;this.geometry=new THREE.BufferGeometry;var r=new Float32Array(3*s),o=new Float32Array(3*s);this.geometry.addAttribute("position",new THREE.BufferAttribute(r,3).setDynamic(!0)),this.geometry.addAttribute("color",new THREE.BufferAttribute(o,3).setDynamic(!0)),this.index=0;var a=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors,depthTest:!n});this.mesh=new THREE.LineSegments(this.geometry,a),n&&(this.mesh.renderOrder=999),this.mesh.frustumCulled=!1,this.enabled=!1,this.debugDrawer=new Ammo.DebugDrawer,this.debugDrawer.drawLine=this.drawLine.bind(this),this.debugDrawer.drawContactPoint=this.drawContactPoint.bind(this),this.debugDrawer.reportErrorWarning=this.reportErrorWarning.bind(this),this.debugDrawer.draw3dText=this.draw3dText.bind(this),this.debugDrawer.setDebugMode=this.setDebugMode.bind(this),this.debugDrawer.getDebugMode=this.getDebugMode.bind(this),this.debugDrawer.enable=this.enable.bind(this),this.debugDrawer.disable=this.disable.bind(this),this.debugDrawer.update=this.update.bind(this),this.world.setDebugDrawer(this.debugDrawer)},THREE.AmmoDebugDrawer.prototype=function(){return this.debugDrawer},THREE.AmmoDebugDrawer.prototype.enable=function(){this.enabled=!0,this.scene.add(this.mesh)},THREE.AmmoDebugDrawer.prototype.disable=function(){this.enabled=!1,this.scene.remove(this.mesh)},THREE.AmmoDebugDrawer.prototype.update=function(){this.enabled&&(0!=this.index&&(this.geometry.attributes.position.needsUpdate=!0,this.geometry.attributes.color.needsUpdate=!0),this.index=0,this.world.debugDrawWorld(),this.geometry.setDrawRange(0,this.index))},THREE.AmmoDebugDrawer.prototype.drawLine=function(t,e,i){const n=Ammo.HEAPF32,s=n[(i+0)/4],r=n[(i+4)/4],o=n[(i+8)/4],a=n[(t+0)/4],l=n[(t+4)/4],c=n[(t+8)/4];this.geometry.attributes.position.setXYZ(this.index,a,l,c),this.geometry.attributes.color.setXYZ(this.index++,s,r,o);const h=n[(e+0)/4],u=n[(e+4)/4],d=n[(e+8)/4];this.geometry.attributes.position.setXYZ(this.index,h,u,d),this.geometry.attributes.color.setXYZ(this.index++,s,r,o)},THREE.AmmoDebugDrawer.prototype.drawContactPoint=function(t,e,i,n,s){const r=Ammo.HEAPF32,o=r[(s+0)/4],a=r[(s+4)/4],l=r[(s+8)/4],c=r[(t+0)/4],h=r[(t+4)/4],u=r[(t+8)/4];this.geometry.attributes.position.setXYZ(this.index,c,h,u),this.geometry.attributes.color.setXYZ(this.index++,o,a,l);const d=r[(e+0)/4]*i,p=r[(e+4)/4]*i,m=r[(e+8)/4]*i;this.geometry.attributes.position.setXYZ(this.index,c+d,h+p,u+m),this.geometry.attributes.color.setXYZ(this.index++,o,a,l)},THREE.AmmoDebugDrawer.prototype.reportErrorWarning=function(t){Ammo.hasOwnProperty("Pointer_stringify")?console.warn(Ammo.Pointer_stringify(t)):this.warnedOnce||(this.warnedOnce=!0,console.warn("Cannot print warningString, please rebuild Ammo.js using 'debug' flag"))},THREE.AmmoDebugDrawer.prototype.draw3dText=function(t,e){console.warn("TODO: draw3dText")},THREE.AmmoDebugDrawer.prototype.setDebugMode=function(t){this.debugDrawMode=t},THREE.AmmoDebugDrawer.prototype.getDebugMode=function(){return this.debugDrawMode}},687:(t,e,i)=>{"use strict";i.r(e),i.d(e,{AABB:()=>c,ArrayCollisionMatrix:()=>d,BODY_SLEEP_STATES:()=>C,BODY_TYPES:()=>A,Body:()=>R,Box:()=>S,Broadphase:()=>G,COLLISION_TYPES:()=>ln,ConeTwistConstraint:()=>ie,Constraint:()=>Pt,ContactEquation:()=>Ht,ContactMaterial:()=>de,ConvexPolyhedron:()=>b,Cylinder:()=>ui,DistanceConstraint:()=>ne,Equation:()=>Dt,EventTarget:()=>p,FrictionEquation:()=>ce,GSSolver:()=>qi,GridBroadphase:()=>Y,Heightfield:()=>fi,HingeConstraint:()=>oe,JacobianElement:()=>It,LockConstraint:()=>se,Mat3:()=>s,Material:()=>pe,NaiveBroadphase:()=>J,Narrowphase:()=>cn,ObjectCollisionMatrix:()=>n,Particle:()=>di,Plane:()=>pi,PointToPointConstraint:()=>Zt,Pool:()=>on,Quaternion:()=>m,RAY_MODES:()=>Q,Ray:()=>$,RaycastResult:()=>K,RaycastVehicle:()=>Re,RigidVehicle:()=>ti,RotationalEquation:()=>$t,RotationalMotorEquation:()=>re,SAPBroadphase:()=>Rt,SHAPE_TYPES:()=>y,SPHSystem:()=>ni,Shape:()=>v,Solver:()=>Wi,Sphere:()=>$e,SplitSolver:()=>Zi,Spring:()=>me,Transform:()=>x,Trimesh:()=>Li,Vec3:()=>r,Vec3Pool:()=>an,World:()=>Rs});class n{constructor(){this.matrix={}}get(t,e){let{id:i}=t,{id:n}=e;if(n>i){const t=n;n=i,i=t}return i+"-"+n in this.matrix}set(t,e,i){let{id:n}=t,{id:s}=e;if(s>n){const t=s;s=n,n=t}i?this.matrix[n+"-"+s]=!0:delete this.matrix[n+"-"+s]}reset(){this.matrix={}}setNumObjects(t){}}class s{constructor(t=[0,0,0,0,0,0,0,0,0]){this.elements=t}identity(){const t=this.elements;t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1}setZero(){const t=this.elements;t[0]=0,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t[8]=0}setTrace(t){const e=this.elements;e[0]=t.x,e[4]=t.y,e[8]=t.z}getTrace(t=new r){const e=this.elements;t.x=e[0],t.y=e[4],t.z=e[8]}vmult(t,e=new r){const i=this.elements,n=t.x,s=t.y,o=t.z;return e.x=i[0]*n+i[1]*s+i[2]*o,e.y=i[3]*n+i[4]*s+i[5]*o,e.z=i[6]*n+i[7]*s+i[8]*o,e}smult(t){for(let e=0;e0){const t=1/n;this.x*=t,this.y*=t,this.z*=t}else this.x=0,this.y=0,this.z=0;return n}unit(t=new r){const e=this.x,i=this.y,n=this.z;let s=Math.sqrt(e*e+i*i+n*n);return s>0?(s=1/s,t.x=e*s,t.y=i*s,t.z=n*s):(t.x=1,t.y=0,t.z=0),t}length(){const t=this.x,e=this.y,i=this.z;return Math.sqrt(t*t+e*e+i*i)}lengthSquared(){return this.dot(this)}distanceTo(t){const e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z;return Math.sqrt((s-e)*(s-e)+(r-i)*(r-i)+(o-n)*(o-n))}distanceSquared(t){const e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z;return(s-e)*(s-e)+(r-i)*(r-i)+(o-n)*(o-n)}scale(t,e=new r){const i=this.x,n=this.y,s=this.z;return e.x=t*i,e.y=t*n,e.z=t*s,e}vmul(t,e=new r){return e.x=t.x*this.x,e.y=t.y*this.y,e.z=t.z*this.z,e}addScaledVector(t,e,i=new r){return i.x=this.x+t*e.x,i.y=this.y+t*e.y,i.z=this.z+t*e.z,i}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}isZero(){return 0===this.x&&0===this.y&&0===this.z}negate(t=new r){return t.x=-this.x,t.y=-this.y,t.z=-this.z,t}tangents(t,e){const i=this.length();if(i>0){const n=o,s=1/i;n.set(this.x*s,this.y*s,this.z*s);const r=a;Math.abs(n.x)<.9?(r.set(1,0,0),n.cross(r,t)):(r.set(0,1,0),n.cross(r,t)),n.cross(t,e)}else t.set(1,0,0),e.set(0,1,0)}toString(){return this.x+","+this.y+","+this.z}toArray(){return[this.x,this.y,this.z]}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}lerp(t,e,i){const n=this.x,s=this.y,r=this.z;i.x=n+(t.x-n)*e,i.y=s+(t.y-s)*e,i.z=r+(t.z-r)*e}almostEquals(t,e=1e-6){return!(Math.abs(this.x-t.x)>e||Math.abs(this.y-t.y)>e||Math.abs(this.z-t.z)>e)}almostZero(t=1e-6){return!(Math.abs(this.x)>t||Math.abs(this.y)>t||Math.abs(this.z)>t)}isAntiparallelTo(t,e){return this.negate(l),l.almostEquals(t,e)}clone(){return new r(this.x,this.y,this.z)}}r.ZERO=new r(0,0,0),r.UNIT_X=new r(1,0,0),r.UNIT_Y=new r(0,1,0),r.UNIT_Z=new r(0,0,1);const o=new r,a=new r,l=new r;class c{constructor(t={}){this.lowerBound=new r,this.upperBound=new r,t.lowerBound&&this.lowerBound.copy(t.lowerBound),t.upperBound&&this.upperBound.copy(t.upperBound)}setFromPoints(t,e,i,n){const s=this.lowerBound,r=this.upperBound,o=i;s.copy(t[0]),o&&o.vmult(s,s),r.copy(s);for(let e=1;er.x&&(r.x=i.x),i.xr.y&&(r.y=i.y),i.yr.z&&(r.z=i.z),i.z=s.x&&e.y<=n.y&&i.y>=s.y&&e.z<=n.z&&i.z>=s.z}getCorners(t,e,i,n,s,r,o,a){const l=this.lowerBound,c=this.upperBound;t.copy(l),e.set(c.x,l.y,l.z),i.set(c.x,c.y,l.z),n.set(l.x,c.y,c.z),s.set(c.x,l.y,c.z),r.set(l.x,c.y,l.z),o.set(l.x,l.y,c.z),a.copy(c)}toLocalFrame(t,e){const i=u,n=i[0],s=i[1],r=i[2],o=i[3],a=i[4],l=i[5],c=i[6],h=i[7];this.getCorners(n,s,r,o,a,l,c,h);for(let e=0;8!==e;e++){const n=i[e];t.pointToLocal(n,n)}return e.setFromPoints(i)}toWorldFrame(t,e){const i=u,n=i[0],s=i[1],r=i[2],o=i[3],a=i[4],l=i[5],c=i[6],h=i[7];this.getCorners(n,s,r,o,a,l,c,h);for(let e=0;8!==e;e++){const n=i[e];t.pointToWorld(n,n)}return e.setFromPoints(i)}overlapsRay(t){const{direction:e,from:i}=t,n=1/e.x,s=1/e.y,r=1/e.z,o=(this.lowerBound.x-i.x)*n,a=(this.upperBound.x-i.x)*n,l=(this.lowerBound.y-i.y)*s,c=(this.upperBound.y-i.y)*s,h=(this.lowerBound.z-i.z)*r,u=(this.upperBound.z-i.z)*r,d=Math.max(Math.max(Math.min(o,a),Math.min(l,c)),Math.min(h,u)),p=Math.min(Math.min(Math.max(o,a),Math.max(l,c)),Math.max(h,u));return!(p<0||d>p)}}const h=new r,u=[new r,new r,new r,new r,new r,new r,new r,new r];class d{constructor(){this.matrix=[]}get(t,e){let{index:i}=t,{index:n}=e;if(n>i){const t=n;n=i,i=t}return this.matrix[(i*(i+1)>>1)+n-1]}set(t,e,i){let{index:n}=t,{index:s}=e;if(s>n){const t=s;s=n,n=t}this.matrix[(n*(n+1)>>1)+s-1]=i?1:0}reset(){for(let t=0,e=this.matrix.length;t!==e;t++)this.matrix[t]=0}setNumObjects(t){this.matrix.length=t*(t-1)>>1}}class p{constructor(){}addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const i=this._listeners;return void 0===i[t]&&(i[t]=[]),i[t].includes(e)||i[t].push(e),this}hasEventListener(t,e){if(void 0===this._listeners)return!1;const i=this._listeners;return!(void 0===i[t]||!i[t].includes(e))}hasAnyEventListener(t){return void 0!==this._listeners&&void 0!==this._listeners[t]}removeEventListener(t,e){if(void 0===this._listeners)return this;const i=this._listeners;if(void 0===i[t])return this;const n=i[t].indexOf(e);return-1!==n&&i[t].splice(n,1),this}dispatchEvent(t){if(void 0===this._listeners)return this;const e=this._listeners[t.type];if(void 0!==e){t.target=this;for(let i=0,n=e.length;i.499&&(i=2*Math.atan2(r,l),n=Math.PI/2,s=0),t<-.499&&(i=-2*Math.atan2(r,l),n=-Math.PI/2,s=0),void 0===i){const e=r*r,c=o*o,h=a*a;i=Math.atan2(2*o*l-2*r*a,1-2*c-2*h),n=Math.asin(2*t),s=Math.atan2(2*r*l-2*o*a,1-2*e-2*h)}}t.y=i,t.z=n,t.x=s}setFromEuler(t,e,i,n="XYZ"){const s=Math.cos(t/2),r=Math.cos(e/2),o=Math.cos(i/2),a=Math.sin(t/2),l=Math.sin(e/2),c=Math.sin(i/2);return"XYZ"===n?(this.x=a*r*o+s*l*c,this.y=s*l*o-a*r*c,this.z=s*r*c+a*l*o,this.w=s*r*o-a*l*c):"YXZ"===n?(this.x=a*r*o+s*l*c,this.y=s*l*o-a*r*c,this.z=s*r*c-a*l*o,this.w=s*r*o+a*l*c):"ZXY"===n?(this.x=a*r*o-s*l*c,this.y=s*l*o+a*r*c,this.z=s*r*c+a*l*o,this.w=s*r*o-a*l*c):"ZYX"===n?(this.x=a*r*o-s*l*c,this.y=s*l*o+a*r*c,this.z=s*r*c-a*l*o,this.w=s*r*o+a*l*c):"YZX"===n?(this.x=a*r*o+s*l*c,this.y=s*l*o+a*r*c,this.z=s*r*c-a*l*o,this.w=s*r*o-a*l*c):"XZY"===n&&(this.x=a*r*o-s*l*c,this.y=s*l*o-a*r*c,this.z=s*r*c+a*l*o,this.w=s*r*o+a*l*c),this}clone(){return new m(this.x,this.y,this.z,this.w)}slerp(t,e,i=new m){const n=this.x,s=this.y,r=this.z,o=this.w;let a,l,c,h,u,d=t.x,p=t.y,f=t.z,g=t.w;return l=n*d+s*p+r*f+o*g,l<0&&(l=-l,d=-d,p=-p,f=-f,g=-g),1-l>1e-6?(a=Math.acos(l),c=Math.sin(a),h=Math.sin((1-e)*a)/c,u=Math.sin(e*a)/c):(h=1-e,u=e),i.x=h*n+u*d,i.y=h*s+u*p,i.z=h*r+u*f,i.w=h*o+u*g,i}integrate(t,e,i,n=new m){const s=t.x*i.x,r=t.y*i.y,o=t.z*i.z,a=this.x,l=this.y,c=this.z,h=this.w,u=.5*e;return n.x+=u*(s*h+r*c-o*l),n.y+=u*(r*h+o*a-s*c),n.z+=u*(o*h+s*l-r*a),n.w+=u*(-s*a-r*l-o*c),n}}const f=new r,g=new r,y={SPHERE:1,PLANE:2,BOX:4,COMPOUND:8,CONVEXPOLYHEDRON:16,HEIGHTFIELD:32,PARTICLE:64,CYLINDER:128,TRIMESH:256};class v{constructor(t={}){this.id=v.idCounter++,this.type=t.type||0,this.boundingSphereRadius=0,this.collisionResponse=!t.collisionResponse||t.collisionResponse,this.collisionFilterGroup=void 0!==t.collisionFilterGroup?t.collisionFilterGroup:1,this.collisionFilterMask=void 0!==t.collisionFilterMask?t.collisionFilterMask:-1,this.material=t.material?t.material:null,this.body=null}updateBoundingSphereRadius(){throw"computeBoundingSphereRadius() not implemented for shape type "+this.type}volume(){throw"volume() not implemented for shape type "+this.type}calculateLocalInertia(t,e){throw"calculateLocalInertia() not implemented for shape type "+this.type}calculateWorldAABB(t,e,i,n){throw"calculateWorldAABB() not implemented for shape type "+this.type}}v.idCounter=0,v.types=y;class x{constructor(t={}){this.position=new r,this.quaternion=new m,t.position&&this.position.copy(t.position),t.quaternion&&this.quaternion.copy(t.quaternion)}pointToLocal(t,e){return x.pointToLocalFrame(this.position,this.quaternion,t,e)}pointToWorld(t,e){return x.pointToWorldFrame(this.position,this.quaternion,t,e)}vectorToWorldFrame(t,e=new r){return this.quaternion.vmult(t,e),e}static pointToLocalFrame(t,e,i,n=new r){return i.vsub(t,n),e.conjugate(_),_.vmult(n,n),n}static pointToWorldFrame(t,e,i,n=new r){return e.vmult(i,n),n.vadd(t,n),n}static vectorToWorldFrame(t,e,i=new r){return t.vmult(e,i),i}static vectorToLocalFrame(t,e,i,n=new r){return e.w*=-1,e.vmult(i,n),e.w*=-1,n}}const _=new m;class b extends v{constructor(t={}){const{vertices:e=[],faces:i=[],normals:n=[],axes:s,boundingSphereRadius:r}=t;super({type:v.types.CONVEXPOLYHEDRON}),this.vertices=e,this.faces=i,this.faceNormals=n,0===this.faceNormals.length&&this.computeNormals(),r?this.boundingSphereRadius=r:this.updateBoundingSphereRadius(),this.worldVertices=[],this.worldVerticesNeedsUpdate=!0,this.worldFaceNormals=[],this.worldFaceNormalsNeedsUpdate=!0,this.uniqueAxes=s?s.slice():null,this.uniqueEdges=[],this.computeEdges()}computeEdges(){const t=this.faces,e=this.vertices,i=this.uniqueEdges;i.length=0;const n=new r;for(let s=0;s!==t.length;s++){const r=t[s],o=r.length;for(let t=0;t!==o;t++){const s=(t+1)%o;e[r[t]].vsub(e[r[s]],n),n.normalize();let a=!1;for(let t=0;t!==i.length;t++)if(i[t].almostEquals(n)||i[t].almostEquals(n)){a=!0;break}a||i.push(n.clone())}}}computeNormals(){this.faceNormals.length=this.faces.length;for(let t=0;td&&(d=e,u=t)}const p=[];for(let t=0;t=0&&this.clipFaceAgainstHull(o,t,e,p,a,l,c)}findSeparatingAxis(t,e,i,n,s,o,a,l){const c=new r,h=new r,u=new r,d=new r,p=new r,m=new r;let f=Number.MAX_VALUE;const g=this;if(g.uniqueAxes)for(let r=0;r!==g.uniqueAxes.length;r++){i.vmult(g.uniqueAxes[r],c);const a=g.testSepAxis(c,t,e,i,n,s);if(!1===a)return!1;a0&&o.negate(o),!0}testSepAxis(t,e,i,n,s,r){b.project(this,t,i,n,w),b.project(e,t,s,r,M);const o=w[0],a=w[1],l=M[0],c=M[1];if(o0?1/e:0,this.material=t.material||null,this.linearDamping="number"==typeof t.linearDamping?t.linearDamping:.01,this.type=e<=0?R.STATIC:R.DYNAMIC,typeof t.type==typeof R.STATIC&&(this.type=t.type),this.allowSleep=void 0===t.allowSleep||t.allowSleep,this.sleepState=0,this.sleepSpeedLimit=void 0!==t.sleepSpeedLimit?t.sleepSpeedLimit:.1,this.sleepTimeLimit=void 0!==t.sleepTimeLimit?t.sleepTimeLimit:1,this.timeLastSleepy=0,this.wakeUpAfterNarrowphase=!1,this.torque=new r,this.quaternion=new m,this.initQuaternion=new m,this.previousQuaternion=new m,this.interpolatedQuaternion=new m,t.quaternion&&(this.quaternion.copy(t.quaternion),this.initQuaternion.copy(t.quaternion),this.previousQuaternion.copy(t.quaternion),this.interpolatedQuaternion.copy(t.quaternion)),this.angularVelocity=new r,t.angularVelocity&&this.angularVelocity.copy(t.angularVelocity),this.initAngularVelocity=new r,this.shapes=[],this.shapeOffsets=[],this.shapeOrientations=[],this.inertia=new r,this.invInertia=new r,this.invInertiaWorld=new s,this.invMassSolve=0,this.invInertiaSolve=new r,this.invInertiaWorldSolve=new s,this.fixedRotation=void 0!==t.fixedRotation&&t.fixedRotation,this.angularDamping=void 0!==t.angularDamping?t.angularDamping:.01,this.linearFactor=new r(1,1,1),t.linearFactor&&this.linearFactor.copy(t.linearFactor),this.angularFactor=new r(1,1,1),t.angularFactor&&this.angularFactor.copy(t.angularFactor),this.aabb=new c,this.aabbNeedsUpdate=!0,this.boundingRadius=0,this.wlambda=new r,t.shape&&this.addShape(t.shape),this.updateMassProperties()}wakeUp(){const t=this.sleepState;this.sleepState=0,this.wakeUpAfterNarrowphase=!1,t===R.SLEEPING&&this.dispatchEvent(R.wakeupEvent)}sleep(){this.sleepState=R.SLEEPING,this.velocity.set(0,0,0),this.angularVelocity.set(0,0,0),this.wakeUpAfterNarrowphase=!1}sleepTick(t){if(this.allowSleep){const e=this.sleepState,i=this.velocity.lengthSquared()+this.angularVelocity.lengthSquared(),n=this.sleepSpeedLimit**2;e===R.AWAKE&&in?this.wakeUp():e===R.SLEEPY&&t-this.timeLastSleepy>this.sleepTimeLimit&&(this.sleep(),this.dispatchEvent(R.sleepEvent))}}updateSolveMassProperties(){this.sleepState===R.SLEEPING||this.type===R.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve.setZero(),this.invInertiaWorldSolve.setZero()):(this.invMassSolve=this.invMass,this.invInertiaSolve.copy(this.invInertia),this.invInertiaWorldSolve.copy(this.invInertiaWorld))}pointToLocalFrame(t,e=new r){return t.vsub(this.position,e),this.quaternion.conjugate().vmult(e,e),e}vectorToLocalFrame(t,e=new r){return this.quaternion.conjugate().vmult(t,e),e}pointToWorldFrame(t,e=new r){return this.quaternion.vmult(t,e),e.vadd(this.position,e),e}vectorToWorldFrame(t,e=new r){return this.quaternion.vmult(t,e),e}addShape(t,e,i){const n=new r,s=new m;return e&&n.copy(e),i&&s.copy(i),this.shapes.push(t),this.shapeOffsets.push(n),this.shapeOrientations.push(s),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0,t.body=this,this}updateBoundingRadius(){const t=this.shapes,e=this.shapeOffsets,i=t.length;let n=0;for(let s=0;s!==i;s++){const i=t[s];i.updateBoundingSphereRadius();const r=e[s].length(),o=i.boundingSphereRadius;r+o>n&&(n=r+o)}this.boundingRadius=n}computeAABB(){const t=this.shapes,e=this.shapeOffsets,i=this.shapeOrientations,n=t.length,s=L,r=P,o=this.quaternion,a=this.aabb,l=I;for(let c=0;c!==n;c++){const n=t[c];o.vmult(e[c],s),s.vadd(this.position,s),o.mult(i[c],r),n.calculateWorldAABB(s,r,l.lowerBound,l.upperBound),0===c?a.copy(l):a.extend(l)}this.aabbNeedsUpdate=!1}updateInertiaWorld(t){const e=this.invInertia;if(e.x!==e.y||e.y!==e.z||t){const t=D,i=N;t.setRotationFromQuaternion(this.quaternion),t.transpose(i),t.scale(e,t),t.mmult(i,this.invInertiaWorld)}}applyForce(t,e){if(this.type!==R.DYNAMIC)return;const i=B;e.cross(t,i),this.force.vadd(t,this.force),this.torque.vadd(i,this.torque)}applyLocalForce(t,e){if(this.type!==R.DYNAMIC)return;const i=F,n=O;this.vectorToWorldFrame(t,i),this.vectorToWorldFrame(e,n),this.applyForce(i,n)}applyImpulse(t,e){if(this.type!==R.DYNAMIC)return;const i=e,n=z;n.copy(t),n.scale(this.invMass,n),this.velocity.vadd(n,this.velocity);const s=U;i.cross(t,s),this.invInertiaWorld.vmult(s,s),this.angularVelocity.vadd(s,this.angularVelocity)}applyLocalImpulse(t,e){if(this.type!==R.DYNAMIC)return;const i=H,n=V;this.vectorToWorldFrame(t,i),this.vectorToWorldFrame(e,n),this.applyImpulse(i,n)}updateMassProperties(){const t=k;this.invMass=this.mass>0?1/this.mass:0;const e=this.inertia,i=this.fixedRotation;this.computeAABB(),t.set((this.aabb.upperBound.x-this.aabb.lowerBound.x)/2,(this.aabb.upperBound.y-this.aabb.lowerBound.y)/2,(this.aabb.upperBound.z-this.aabb.lowerBound.z)/2),S.calculateInertia(t,this.mass,e),this.invInertia.set(e.x>0&&!i?1/e.x:0,e.y>0&&!i?1/e.y:0,e.z>0&&!i?1/e.z:0),this.updateInertiaWorld(!0)}getVelocityAtWorldPoint(t,e){const i=new r;return t.vsub(this.position,i),this.angularVelocity.cross(i,e),this.velocity.vadd(e,e),e}integrate(t,e,i){if(this.previousPosition.copy(this.position),this.previousQuaternion.copy(this.quaternion),this.type!==R.DYNAMIC&&this.type!==R.KINEMATIC||this.sleepState===R.SLEEPING)return;const n=this.velocity,s=this.angularVelocity,r=this.position,o=this.force,a=this.torque,l=this.quaternion,c=this.invMass,h=this.invInertiaWorld,u=this.linearFactor,d=c*t;n.x+=o.x*d*u.x,n.y+=o.y*d*u.y,n.z+=o.z*d*u.z;const p=h.elements,m=this.angularFactor,f=a.x*m.x,g=a.y*m.y,y=a.z*m.z;s.x+=t*(p[0]*f+p[1]*g+p[2]*y),s.y+=t*(p[3]*f+p[4]*g+p[5]*y),s.z+=t*(p[6]*f+p[7]*g+p[8]*y),r.x+=n.x*t,r.y+=n.y*t,r.z+=n.z*t,l.integrate(this.angularVelocity,t,this.angularFactor,l),e&&(i?l.normalizeFast():l.normalize()),this.aabbNeedsUpdate=!0,this.updateInertiaWorld()}}R.COLLIDE_EVENT_NAME="collide",R.DYNAMIC=1,R.STATIC=2,R.KINEMATIC=4,R.AWAKE=C.AWAKE,R.SLEEPY=C.SLEEPY,R.SLEEPING=C.SLEEPING,R.idCounter=0,R.wakeupEvent={type:"wakeup"},R.sleepyEvent={type:"sleepy"},R.sleepEvent={type:"sleep"};const L=new r,P=new m,I=new c,D=new s,N=new s,B=new r,F=new r,O=new r,z=new r,U=new r,H=new r,V=new r,k=new r;class G{constructor(){this.world=null,this.useBoundingBoxes=!1,this.dirty=!0}collisionPairs(t,e,i){throw new Error("collisionPairs not implemented for this BroadPhase class!")}needBroadphaseCollision(t,e){return 0!=(t.collisionFilterGroup&e.collisionFilterMask)&&0!=(e.collisionFilterGroup&t.collisionFilterMask)&&(0==(t.type&R.STATIC)&&t.sleepState!==R.SLEEPING||0==(e.type&R.STATIC)&&e.sleepState!==R.SLEEPING)}intersectionTest(t,e,i,n){this.useBoundingBoxes?this.doBoundingBoxBroadphase(t,e,i,n):this.doBoundingSphereBroadphase(t,e,i,n)}doBoundingSphereBroadphase(t,e,i,n){const s=W;e.position.vsub(t.position,s);const r=(t.boundingRadius+e.boundingRadius)**2;s.lengthSquared(){const i=new r;t.position.vsub(e.position,i);const n=t.shapes[0],s=e.shapes[0];return Math.pow(n.boundingSphereRadius+s.boundingSphereRadius,2)>i.lengthSquared()};class Y extends G{constructor(t=new r(100,100,100),e=new r(-100,-100,-100),i=10,n=10,s=10){super(),this.nx=i,this.ny=n,this.nz=s,this.aabbMin=t,this.aabbMax=e;const o=this.nx*this.ny*this.nz;if(o<=0)throw"GridBroadphase: Each dimension's n must be >0";this.bins=[],this.binLengths=[],this.bins.length=o,this.binLengths.length=o;for(let t=0;t=a&&(d=a-1),p<0?p=0:p>=l&&(p=l-1),m<0?m=0:m>=c&&(m=c-1),v<0?v=0:v>=a&&(v=a-1),w<0?w=0:w>=l&&(w=l-1),M<0?M=0:M>=c&&(M=c-1),d*=h,p*=u,m*=1,v*=h,w*=u,M*=1;for(let t=d;t<=v;t+=h)for(let e=p;e<=w;e+=u)for(let i=m;i<=M;i+=1){const n=t+e+i;R[n][L[n]++]=o}}for(let t=0;t!==n;t++){const e=s[t],i=e.shapes[0];switch(i.type){case A:{const t=i,n=e.position.x,s=e.position.y,r=e.position.z,o=t.radius;D(n-o,s-o,r-o,n+o,s+o,r+o,e);break}case C:{const t=i;t.worldNormalNeedsUpdate&&t.computeWorldNormal(e.quaternion);const n=t.worldNormal,s=f+.5*w-e.position.x,r=g+.5*M-e.position.y,o=y+.5*S-e.position.z,d=Z;d.set(s,r,o);for(let t=0,i=0;t!==a;t++,i+=h,d.y=r,d.x+=w)for(let t=0,s=0;t!==l;t++,s+=u,d.z=o,d.y+=M)for(let t=0,r=0;t!==c;t++,r+=1,d.z+=S)if(d.dot(n)1){const s=R[t];for(let t=0;t!==n;t++){const n=s[t];for(let r=0;r!==t;r++){const t=s[r];this.needBroadphaseCollision(n,t)&&this.intersectionTest(n,t,e,i)}}}}this.makePairsUnique(e,i)}}const Z=new r;class J extends G{constructor(){super()}collisionPairs(t,e,i){const n=t.bodies,s=n.length;let r,o;for(let t=0;t!==s;t++)for(let s=0;s!==t;s++)r=n[t],o=n[s],this.needBroadphaseCollision(r,o)&&this.intersectionTest(r,o,e,i)}aabbQuery(t,e,i=[]){for(let n=0;n{}}intersectWorld(t,e){return this.mode=e.mode||$.ANY,this.result=e.result||new K,this.skipBackfaces=!!e.skipBackfaces,this.collisionFilterMask=void 0!==e.collisionFilterMask?e.collisionFilterMask:-1,this.collisionFilterGroup=void 0!==e.collisionFilterGroup?e.collisionFilterGroup:-1,this.checkCollisionResponse=void 0===e.checkCollisionResponse||e.checkCollisionResponse,e.from&&this.from.copy(e.from),e.to&&this.to.copy(e.to),this.callback=e.callback||(()=>{}),this.hasHit=!1,this.result.reset(),this.updateDirection(),this.getAABB(tt),et.length=0,t.broadphase.aabbQuery(t,tt,et),this.intersectBodies(et),this.hasHit}intersectBody(t,e){e&&(this.result=e,this.updateDirection());const i=this.checkCollisionResponse;if(i&&!t.collisionResponse)return;if(0==(this.collisionFilterGroup&t.collisionFilterMask)||0==(t.collisionFilterGroup&this.collisionFilterMask))return;const n=rt,s=ot;for(let e=0,r=t.shapes.length;et.boundingSphereRadius)return;const r=this[t.type];r&&r.call(this,t,e,i,n,t)}_intersectBox(t,e,i,n,s){return this._intersectConvex(t.convexPolyhedronRepresentation,e,i,n,s)}_intersectPlane(t,e,i,n,s){const o=this.from,a=this.to,l=this.direction,c=new r(0,0,1);e.vmult(c,c);const h=new r;o.vsub(i,h);const u=h.dot(c);if(a.vsub(i,h),u*h.dot(c)>0)return;if(o.distanceTo(a)=0&&t<=1&&(r.lerp(o,t,u),u.vsub(i,d),d.normalize(),this.reportIntersection(d,u,s,n,-1)),this.result.shouldStop)return;e>=0&&e<=1&&(r.lerp(o,e,u),u.vsub(i,d),d.normalize(),this.reportIntersection(d,u,s,n,-1))}}_intersectConvex(t,e,i,n,s,r){const o=yt,a=vt,l=r&&r.faceList||null,c=t.faces,h=t.vertices,u=t.faceNormals,d=this.direction,p=this.from,m=this.to,f=p.distanceTo(m),g=l?l.length:c.length,y=this.result;for(let t=0;!y.shouldStop&&tf||this.reportIntersection(o,at,s,n,r)}}}}_intersectTrimesh(t,e,i,n,s,r){const o=xt,a=Et,l=Tt,c=vt,h=_t,u=bt,d=wt,p=St,m=Mt,f=(r&&r.faceList,t.indices),g=(t.vertices,this.from),y=this.to,v=this.direction;l.position.copy(i),l.quaternion.copy(e),x.vectorToLocalFrame(i,e,v,h),x.pointToLocalFrame(i,e,g,u),x.pointToLocalFrame(i,e,y,d),d.x*=t.scale.x,d.y*=t.scale.y,d.z*=t.scale.z,u.x*=t.scale.x,u.y*=t.scale.y,u.z*=t.scale.z,d.vsub(u,h),h.normalize();const _=u.distanceSquared(d);t.tree.rayQuery(this,l,a);for(let r=0,l=a.length;!this.result.shouldStop&&r!==l;r++){const l=a[r];t.getNormal(l,o),t.getVertex(f[3*l],lt),lt.vsub(u,c);const d=h.dot(o),g=o.dot(c)/d;if(g<0)continue;h.scale(g,at),at.vadd(u,at),t.getVertex(f[3*l+1],ct),t.getVertex(f[3*l+2],ht);const y=at.distanceSquared(u);!st(at,ct,lt,ht)&&!st(at,lt,ct,ht)||y>_||(x.vectorToWorldFrame(e,o,m),x.pointToWorldFrame(i,e,at,p),this.reportIntersection(m,p,s,n,l))}a.length=0}reportIntersection(t,e,i,n,s){const r=this.from,o=this.to,a=r.distanceTo(e),l=this.result;if(!(this.skipBackfaces&&t.dot(this.direction)>0))switch(l.hitFaceIndex=void 0!==s?s:-1,this.mode){case $.ALL:this.hasHit=!0,l.set(r,o,t,e,i,n,a),l.hasHit=!0,this.callback(l);break;case $.CLOSEST:(a=0&&(h=s*l-r*o)>=0&&c+h{e.push(t.body)},this._removeBodyHandler=t=>{const i=e.indexOf(t.body);-1!==i&&e.splice(i,1)},t&&this.setWorld(t)}setWorld(t){this.axisList.length=0;for(let e=0;eh?c>u?0:2:h>u?1:2}aabbQuery(t,e,i=[]){this.dirty&&(this.sortList(),this.dirty=!1);const n=this.axisIndex;let s="x";1===n&&(s="y"),2===n&&(s="z");const r=this.axisList;e.lowerBound[s],e.upperBound[s];for(let t=0;t{for(let e=1,i=t.length;e=0&&!(t[n].aabb.lowerBound.x<=i.aabb.lowerBound.x);n--)t[n+1]=t[n];t[n+1]=i}return t},Rt.insertionSortY=t=>{for(let e=1,i=t.length;e=0&&!(t[n].aabb.lowerBound.y<=i.aabb.lowerBound.y);n--)t[n+1]=t[n];t[n+1]=i}return t},Rt.insertionSortZ=t=>{for(let e=1,i=t.length;e=0&&!(t[n].aabb.lowerBound.z<=i.aabb.lowerBound.z);n--)t[n+1]=t[n];t[n+1]=i}return t},Rt.checkBounds=(t,e,i)=>{let n,s;0===i?(n=t.position.x,s=e.position.x):1===i?(n=t.position.y,s=e.position.y):2===i&&(n=t.position.z,s=e.position.z);const r=t.boundingRadius;return s-e.boundingRadius{for(let i in e)i in t||(t[i]=e[i]);return t};class Pt{constructor(t,e,i={}){i=Lt.defaults(i,{collideConnected:!0,wakeUpBodies:!0}),this.equations=[],this.bodyA=t,this.bodyB=e,this.id=Pt.idCounter++,this.collideConnected=i.collideConnected,i.wakeUpBodies&&(t&&t.wakeUp(),e&&e.wakeUp())}update(){throw new Error("method update() not implmemented in this Constraint subclass!")}enable(){const t=this.equations;for(let e=0;e=-.1)this.suspensionRelativeVelocity=0,this.clippedInvContactDotSuspension=10;else{const t=-1/i;this.suspensionRelativeVelocity=n*t,this.clippedInvContactDotSuspension=t}}else e.suspensionLength=this.suspensionRestLength,this.suspensionRelativeVelocity=0,e.directionWorld.scale(-1,e.hitNormalWorld),this.clippedInvContactDotSuspension=1}}const Ae=new r,Ce=new r;class Re{constructor(t){this.chassisBody=t.chassisBody,this.wheelInfos=[],this.sliding=!1,this.world=null,this.indexRightAxis=void 0!==t.indexRightAxis?t.indexRightAxis:1,this.indexForwardAxis=void 0!==t.indexForwardAxis?t.indexForwardAxis:0,this.indexUpAxis=void 0!==t.indexUpAxis?t.indexUpAxis:2,this.constraints=[],this.preStepCallback=()=>{},this.currentVehicleSpeedKmHour=0}addWheel(t={}){const e=new Te(t),i=this.wheelInfos.length;return this.wheelInfos.push(e),i}setSteeringValue(t,e){this.wheelInfos[e].steering=t}applyEngineForce(t,e){this.wheelInfos[e].engineForce=t}setBrake(t,e){this.wheelInfos[e].brake=t}addToWorld(t){this.constraints,t.addBody(this.chassisBody);const e=this;this.preStepCallback=()=>{e.updateVehicle(t.dt)},t.addEventListener("preStep",this.preStepCallback),this.world=t}getVehicleAxisWorld(t,e){e.set(0===t?1:0,1===t?1:0,2===t?1:0),this.chassisBody.vectorToWorldFrame(e,e)}updateVehicle(t){const e=this.wheelInfos,i=e.length,n=this.chassisBody;for(let t=0;ti.maxSuspensionForce&&(r=i.maxSuspensionForce),i.raycastResult.hitNormalWorld.scale(r*t,o),i.raycastResult.hitPointWorld.vsub(n.position,a),n.applyImpulse(o,a)}this.updateFriction(t);const l=new r,c=new r,h=new r;for(let s=0;s0?1:-1)*i.customSlidingRotationalSpeed*t),Math.abs(i.brake)>Math.abs(i.engineForce)&&(i.deltaRotation=0),i.rotation+=i.deltaRotation,i.deltaRotation*=.99}}updateSuspension(t){const e=this.chassisBody.mass,i=this.wheelInfos,n=i.length;for(let t=0;to&&(t.suspensionLength=o,t.raycastResult.reset());const a=t.raycastResult.hitNormalWorld.dot(t.directionWorld),c=new r;n.getVelocityAtWorldPoint(t.raycastResult.hitPointWorld,c);const h=t.raycastResult.hitNormalWorld.dot(c);if(a>=-.1)t.suspensionRelativeVelocity=0,t.clippedInvContactDotSuspension=10;else{const e=-1/a;t.suspensionRelativeVelocity=h*e,t.clippedInvContactDotSuspension=e}}else t.suspensionLength=t.suspensionRestLength+0*t.maxSuspensionTravel,t.suspensionRelativeVelocity=0,t.directionWorld.scale(-1,t.raycastResult.hitNormalWorld),t.clippedInvContactDotSuspension=1;return s}updateWheelTransformWorld(t){t.isInContact=!1;const e=this.chassisBody;e.pointToWorldFrame(t.chassisConnectionPointLocal,t.chassisConnectionPointWorld),e.vectorToWorldFrame(t.directionLocal,t.directionWorld),e.vectorToWorldFrame(t.axleLocal,t.axleWorld)}updateWheelTransform(t){const e=Le,i=Pe,n=Ie,s=this.wheelInfos[t];this.updateWheelTransformWorld(s),s.directionLocal.scale(-1,e),i.copy(s.axleLocal),e.cross(i,n),n.normalize(),i.normalize();const r=s.steering,o=new m;o.setFromAxisAngle(e,r);const a=new m;a.setFromAxisAngle(i,s.rotation);const l=s.worldTransform.quaternion;this.chassisBody.quaternion.mult(o,l),l.mult(a,l),l.normalize();const c=s.worldTransform.position;c.copy(s.directionWorld),c.scale(s.suspensionLength,c),c.vadd(s.chassisConnectionPointWorld,c)}getWheelTransformWorld(t){return this.wheelInfos[t].worldTransform}updateFriction(t){const e=Fe,i=this.wheelInfos,n=i.length,s=this.chassisBody,o=ze,a=Oe;for(let t=0;ti){this.sliding=!0,n.sliding=!0;const t=e/Math.sqrt(o);n.skidInfo*=t}}}if(this.sliding)for(let t=0;t1.1)return 0;const r=Ze,o=Je,a=Ke;return t.getVelocityAtWorldPoint(e,r),i.getVelocityAtWorldPoint(n,o),r.vsub(o,a),-.2*s.dot(a)*(1/(t.invMass+i.invMass))}class $e extends v{constructor(t){if(super({type:v.types.SPHERE}),this.radius=void 0!==t?t:1,this.radius<0)throw new Error("The sphere radius cannot be negative.");this.updateBoundingSphereRadius()}calculateLocalInertia(t,e=new r){const i=2*t*this.radius*this.radius/5;return e.x=i,e.y=i,e.z=i,e}volume(){return 4*Math.PI*Math.pow(this.radius,3)/3}updateBoundingSphereRadius(){this.boundingSphereRadius=this.radius}calculateWorldAABB(t,e,i,n){const s=this.radius,r=["x","y","z"];for(let e=0;ethis.particles.length&&this.neighbors.pop())}getNeighbors(t,e){const i=this.particles.length,n=t.id,s=this.smoothingRadius*this.smoothingRadius,r=si;for(let o=0;o!==i;o++){const i=this.particles[o];i.position.vsub(t.position,r),n!==i.id&&r.lengthSquared()e&&(e=s)}this.maxValue=e}setHeightValueAtIndex(t,e,i){this.data[t][e]=i,this.clearCachedConvexTrianglePillar(t,e,!1),t>0&&(this.clearCachedConvexTrianglePillar(t-1,e,!0),this.clearCachedConvexTrianglePillar(t-1,e,!1)),e>0&&(this.clearCachedConvexTrianglePillar(t,e-1,!0),this.clearCachedConvexTrianglePillar(t,e-1,!1)),e>0&&t>0&&this.clearCachedConvexTrianglePillar(t-1,e-1,!0)}getRectMinMax(t,e,i,n,s=[]){const r=this.data;let o=this.minValue;for(let s=t;s<=i;s++)for(let t=e;t<=n;t++){const e=r[s][t];e>o&&(o=e)}s[0]=this.minValue,s[1]=o}getIndexOfPosition(t,e,i,n){const s=this.elementSize,r=this.data;let o=Math.floor(t/s),a=Math.floor(e/s);return i[0]=o,i[1]=a,n&&(o<0&&(o=0),a<0&&(a=0),o>=r.length-1&&(o=r.length-1),a>=r[0].length-1&&(a=r[0].length-1)),!(o<0||a<0||o>=r.length-1||a>=r[0].length-1)}getTriangleAt(t,e,i,n,s,r){const o=gi;this.getIndexOfPosition(t,e,o,i);let a=o[0],l=o[1];const c=this.data;i&&(a=Math.min(c.length-2,Math.max(0,a)),l=Math.min(c[0].length-2,Math.max(0,l)));const h=this.elementSize,u=(t/h-a)**2+(e/h-l)**2>(t/h-(a+1))**2+(e/h-(l+1))**2;return this.getTriangle(a,l,u,n,s,r),u}getNormalAt(t,e,i,n){const s=bi,r=wi,o=Mi,a=Si,l=Ei;this.getTriangleAt(t,e,i,s,r,o),r.vsub(s,a),o.vsub(s,l),a.cross(l,n),n.normalize()}getAabbAtIndex(t,e,{lowerBound:i,upperBound:n}){const s=this.data,r=this.elementSize;i.set(t*r,e*r,s[t][e]),n.set((t+1)*r,(e+1)*r,s[t+1][e+1])}getHeightAt(t,e,i){const n=this.data,s=vi,r=xi,o=_i,a=gi;this.getIndexOfPosition(t,e,a,i);let l=a[0],c=a[1];i&&(l=Math.min(n.length-2,Math.max(0,l)),c=Math.min(n[0].length-2,Math.max(0,c)));const h=this.getTriangleAt(t,e,i,s,r,o);!function(t,e,i,n,s,r,o,a,l){l.x=((r-a)*(t-o)+(o-s)*(e-a))/((r-a)*(i-o)+(o-s)*(n-a)),l.y=((a-n)*(t-o)+(i-o)*(e-a))/((r-a)*(i-o)+(o-s)*(n-a)),l.z=1-l.x-l.y}(t,e,s.x,s.y,r.x,r.y,o.x,o.y,yi);const u=yi;return h?n[l+1][c+1]*u.x+n[l][c+1]*u.y+n[l+1][c]*u.z:n[l][c]*u.x+n[l+1][c]*u.y+n[l][c+1]*u.z}getCacheConvexTrianglePillarKey(t,e,i){return t+"_"+e+"_"+(i?1:0)}getCachedConvexTrianglePillar(t,e,i){return this._cachedPillars[this.getCacheConvexTrianglePillarKey(t,e,i)]}setCachedConvexTrianglePillar(t,e,i,n,s){this._cachedPillars[this.getCacheConvexTrianglePillarKey(t,e,i)]={convex:n,offset:s}}clearCachedConvexTrianglePillar(t,e,i){delete this._cachedPillars[this.getCacheConvexTrianglePillarKey(t,e,i)]}getTriangle(t,e,i,n,s,r){const o=this.data,a=this.elementSize;i?(n.set((t+1)*a,(e+1)*a,o[t+1][e+1]),s.set(t*a,(e+1)*a,o[t][e+1]),r.set((t+1)*a,e*a,o[t+1][e])):(n.set(t*a,e*a,o[t][e]),s.set((t+1)*a,e*a,o[t+1][e]),r.set(t*a,(e+1)*a,o[t][e+1]))}getConvexTrianglePillar(t,e,i){let n=this.pillarConvex,s=this.pillarOffset;if(this.cacheEnabled){const o=this.getCachedConvexTrianglePillar(t,e,i);if(o)return this.pillarConvex=o.convex,void(this.pillarOffset=o.offset);n=new b,s=new r,this.pillarConvex=n,this.pillarOffset=s}const o=this.data,a=this.elementSize,l=n.faces;n.vertices.length=6;for(let t=0;t<6;t++)n.vertices[t]||(n.vertices[t]=new r);l.length=5;for(let t=0;t<5;t++)l[t]||(l[t]=[]);const c=n.vertices,h=(Math.min(o[t][e],o[t+1][e],o[t][e+1],o[t+1][e+1])-this.minValue)/2+this.minValue;i?(s.set((t+.75)*a,(e+.75)*a,h),c[0].set(.25*a,.25*a,o[t+1][e+1]-h),c[1].set(-.75*a,.25*a,o[t][e+1]-h),c[2].set(.25*a,-.75*a,o[t+1][e]-h),c[3].set(.25*a,.25*a,-h-1),c[4].set(-.75*a,.25*a,-h-1),c[5].set(.25*a,-.75*a,-h-1),l[0][0]=0,l[0][1]=1,l[0][2]=2,l[1][0]=5,l[1][1]=4,l[1][2]=3,l[2][0]=2,l[2][1]=5,l[2][2]=3,l[2][3]=0,l[3][0]=3,l[3][1]=4,l[3][2]=1,l[3][3]=0,l[4][0]=1,l[4][1]=4,l[4][2]=5,l[4][3]=2):(s.set((t+.25)*a,(e+.25)*a,h),c[0].set(-.25*a,-.25*a,o[t][e]-h),c[1].set(.75*a,-.25*a,o[t+1][e]-h),c[2].set(-.25*a,.75*a,o[t][e+1]-h),c[3].set(-.25*a,-.25*a,-h-1),c[4].set(.75*a,-.25*a,-h-1),c[5].set(-.25*a,.75*a,-h-1),l[0][0]=0,l[0][1]=1,l[0][2]=2,l[1][0]=5,l[1][1]=4,l[1][2]=3,l[2][0]=0,l[2][1]=2,l[2][2]=5,l[2][3]=3,l[3][0]=1,l[3][1]=0,l[3][2]=3,l[3][3]=4,l[4][0]=4,l[4][1]=5,l[4][2]=2,l[4][3]=1),n.computeNormals(),n.computeEdges(),n.updateBoundingSphereRadius(),this.setCachedConvexTrianglePillar(t,e,i,n,s)}calculateLocalInertia(t,e=new r){return e.set(0,0,0),e}volume(){return Number.MAX_VALUE}calculateWorldAABB(t,e,i,n){i.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),n.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)}updateBoundingSphereRadius(){const t=this.data,e=this.elementSize;this.boundingSphereRadius=new r(t.length*e,t[0].length*e,Math.max(Math.abs(this.maxValue),Math.abs(this.minValue))).length()}setHeightsFromImage(t,e){const{x:i,z:n,y:s}=e,r=document.createElement("canvas");r.width=t.width,r.height=t.height;const o=r.getContext("2d");o.drawImage(t,0,0);const a=o.getImageData(0,0,t.width,t.height),l=this.data;l.length=0,this.elementSize=Math.abs(i)/a.width;for(let t=0;t=0;t--)this.children[t].removeEmptyNodes(),this.children[t].children.length||this.children[t].data.length||this.children.splice(t,1)}}class Ai extends Ti{constructor(t,e={}){super({root:null,aabb:t}),this.maxDepth=void 0!==e.maxDepth?e.maxDepth:8}}const Ci=new r,Ri=new c;class Li extends v{constructor(t,e){super({type:v.types.TRIMESH}),this.vertices=new Float32Array(t),this.indices=new Int16Array(e),this.normals=new Float32Array(e.length),this.aabb=new c,this.edges=null,this.scale=new r(1,1,1),this.tree=new Ai,this.updateEdges(),this.updateNormals(),this.updateAABB(),this.updateBoundingSphereRadius(),this.updateTree()}updateTree(){const t=this.tree;t.reset(),t.aabb.copy(this.aabb);const e=this.scale;t.aabb.lowerBound.x*=1/e.x,t.aabb.lowerBound.y*=1/e.y,t.aabb.lowerBound.z*=1/e.z,t.aabb.upperBound.x*=1/e.x,t.aabb.upperBound.y*=1/e.y,t.aabb.upperBound.z*=1/e.z;const i=new c,n=new r,s=new r,o=new r,a=[n,s,o];for(let e=0;e{t[ei.x&&(i.x=s.x),s.yi.y&&(i.y=s.y),s.zi.z&&(i.z=s.z)}updateAABB(){this.computeLocalAABB(this.aabb)}updateBoundingSphereRadius(){let t=0;const e=this.vertices,i=new r;for(let n=0,s=e.length/3;n!==s;n++){this.getVertex(n,i);const e=i.lengthSquared();e>t&&(t=e)}this.boundingSphereRadius=Math.sqrt(t)}calculateWorldAABB(t,e,i,n){const s=ki,r=Gi;s.position=t,s.quaternion=e,this.aabb.toWorldFrame(s,r),i.copy(r.lowerBound),n.copy(r.upperBound)}volume(){return 4*Math.PI*this.boundingSphereRadius/3}}const Pi=new r,Ii=new c,Di=new r,Ni=new r,Bi=new r,Fi=new r;Li.computeNormal=(t,e,i,n)=>{e.vsub(t,Fi),i.vsub(e,Bi),Bi.cross(Fi,n),n.isZero()||n.normalize()};const Oi=new r,zi=new r,Ui=new r,Hi=new c,Vi=new r,ki=new x,Gi=new c;Li.createTorus=(t=1,e=.5,i=8,n=6,s=2*Math.PI)=>{const r=[],o=[];for(let o=0;o<=i;o++)for(let a=0;a<=n;a++){const l=a/n*s,c=o/i*Math.PI*2,h=(t+e*Math.cos(c))*Math.cos(l),u=(t+e*Math.cos(c))*Math.sin(l),d=e*Math.sin(c);r.push(h,u,d)}for(let t=1;t<=i;t++)for(let e=1;e<=n;e++){const i=(n+1)*t+e-1,s=(n+1)*(t-1)+e-1,r=(n+1)*(t-1)+e,a=(n+1)*t+e;o.push(i,s,a),o.push(s,r,a)}return new Li(r,o)};class Wi{constructor(){this.equations=[]}solve(t,e){return 0}addEquation(t){t.enabled&&this.equations.push(t)}removeEquation(t){const e=this.equations,i=e.indexOf(t);-1!==i&&e.splice(i,1)}removeAllEquations(){this.equations.length=0}}class qi extends Wi{constructor(){super(),this.iterations=10,this.tolerance=1e-7}solve(t,e){let i=0;const n=this.iterations,s=this.tolerance*this.tolerance,r=this.equations,o=r.length,a=e.bodies,l=a.length,c=t;let h,u,d,p,m,f;if(0!==o)for(let t=0;t!==l;t++)a[t].updateSolveMassProperties();const g=Xi,y=Yi,v=ji;g.length=o,y.length=o,v.length=o;for(let t=0;t!==o;t++){const e=r[t];v[t]=0,y[t]=e.computeB(c),g[t]=1/e.computeC()}if(0!==o){for(let t=0;t!==l;t++){const e=a[t],i=e.vlambda,n=e.wlambda;i.set(0,0,0),n.set(0,0,0)}for(i=0;i!==n;i++){p=0;for(let t=0;t!==o;t++){const e=r[t];h=y[t],u=g[t],f=v[t],m=e.computeGWlambda(),d=u*(h-m-e.eps*f),f+de.maxForce&&(d=e.maxForce-f),v[t]+=d,p+=d>0?d:-d,e.addToWlambda(d)}if(p*pt;)e.pop();for(;e.length=0&&c.restitution>=0&&(o.restitution=l.restitution*c.restitution),o.si=s||i,o.sj=r||n,o}createFrictionEquationsFromContact(t,e){const i=t.bi,n=t.bj,s=t.si,r=t.sj,o=this.world,a=this.currentContactMaterial;let l=a.friction;const c=s.material||i.material,h=r.material||n.material;if(c&&h&&c.friction>=0&&h.friction>=0&&(l=c.friction*h.friction),l>0){const s=l*o.gravity.length();let r=i.invMass+n.invMass;r>0&&(r=1/r);const c=this.frictionEquationPool,h=c.length?c.pop():new ce(i,n,s*r),u=c.length?c.pop():new ce(i,n,s*r);return h.bi=u.bi=i,h.bj=u.bj=n,h.minForce=u.minForce=-s*r,h.maxForce=u.maxForce=s*r,h.ri.copy(t.ri),h.rj.copy(t.rj),u.ri.copy(t.ri),u.rj.copy(t.rj),t.ni.tangents(h.t,u.t),h.setSpookParams(a.frictionEquationStiffness,a.frictionEquationRelaxation,o.dt),u.setSpookParams(a.frictionEquationStiffness,a.frictionEquationRelaxation,o.dt),h.enabled=u.enabled=t.enabled,e.push(h,u),!0}return!1}createFrictionFromAverage(t){let e=this.result[this.result.length-1];if(!this.createFrictionEquationsFromContact(e,this.frictionResult)||1===t)return;const i=this.frictionResult[this.frictionResult.length-2],n=this.frictionResult[this.frictionResult.length-1];hn.setZero(),un.setZero(),dn.setZero();const s=e.bi;e.bj;for(let i=0;i!==t;i++)e=this.result[this.result.length-1-i],e.bi!==s?(hn.vadd(e.ni,hn),un.vadd(e.ri,un),dn.vadd(e.rj,dn)):(hn.vsub(e.ni,hn),un.vadd(e.rj,un),dn.vadd(e.ri,dn));const r=1/t;un.scale(r,i.ri),dn.scale(r,i.rj),n.ri.copy(i.ri),n.rj.copy(i.rj),hn.normalize(),hn.tangents(i.t,n.t)}getContacts(t,e,i,n,s,r,o){this.contactPointPool=s,this.frictionEquationPool=o,this.result=n,this.frictionResult=r;const a=fn,l=gn,c=pn,h=mn;for(let n=0,s=t.length;n!==s;n++){const s=t[n],r=e[n];let o=null;s.material&&r.material&&(o=i.getContactMaterial(s.material,r.material)||null);const u=s.type&R.KINEMATIC&&r.type&R.STATIC||s.type&R.STATIC&&r.type&R.KINEMATIC||s.type&R.KINEMATIC&&r.type&R.KINEMATIC;for(let t=0;te.boundingSphereRadius+n.boundingSphereRadius)continue;let d=null;e.material&&n.material&&(d=i.getContactMaterial(e.material,n.material)||null),this.currentContactMaterial=d||o||i.defaultContactMaterial;const p=this[e.type|n.type];if(p){let t=!1;t=e.type0){const s=Gn,r=Wn;s.copy(d[(t+1)%3]),r.copy(d[(t+2)%3]);const o=s.length(),a=r.length();s.normalize(),r.normalize();const l=Vn.dot(s),c=Vn.dot(r);if(l-o&&c-a){const t=Math.abs(n-i-p);if((null===w||tt.boundingSphereRadius+e.boundingSphereRadius)&&t.findSeparatingAxis(e,i,s,n,r,p,u,d)){const u=[],d=us;t.clipAgainstHull(i,s,e,n,r,p,-100,100,u);let m=0;for(let s=0;s!==u.length;s++){if(h)return!0;const r=this.createContactEquation(o,a,t,e,l,c),f=r.ri,g=r.rj;p.negate(r.ni),u[s].normal.negate(d),d.scale(u[s].depth,d),u[s].point.vadd(d,f),g.copy(u[s].point),f.vsub(i,f),g.vsub(n,g),f.vadd(i,f),f.vsub(o.position,f),g.vadd(n,g),g.vsub(a.position,g),this.result.push(r),m++,this.enableFrictionReduction||this.createFrictionEquationsFromContact(r,this.frictionResult)}this.enableFrictionReduction&&m&&this.createFrictionFromAverage(m)}}sphereConvex(t,e,i,n,s,r,o,a,l,c,h){const u=this.v3pool;i.vsub(n,Jn);const d=e.faceNormals,p=e.faces,m=e.vertices,f=t.radius;let g=!1;for(let s=0;s!==m.length;s++){const u=m[s],d=ts;r.vmult(u,d),n.vadd(d,d);const p=$n;if(d.vsub(i,p),p.lengthSquared()0){const s=[];for(let t=0,e=v.length;t!==e;t++){const e=u.get();r.vmult(m[v[t]],e),n.vadd(e,e),s.push(e)}if(Hn(s,x,i)){if(h)return!0;g=!0;const r=this.createContactEquation(o,a,t,e,l,c);x.scale(-f,r.ri),x.negate(r.ni);const d=u.get();x.scale(-M,d);const p=u.get();x.scale(-f,p),i.vsub(n,r.rj),r.rj.vadd(p,r.rj),r.rj.vadd(d,r.rj),r.rj.vadd(n,r.rj),r.rj.vsub(a.position,r.rj),r.ri.vadd(i,r.ri),r.ri.vsub(o.position,r.ri),u.release(d),u.release(p),this.result.push(r),this.createFrictionEquationsFromContact(r,this.frictionResult);for(let t=0,e=s.length;t!==e;t++)u.release(s[t]);return}for(let d=0;d!==v.length;d++){const p=u.get(),g=u.get();r.vmult(m[v[(d+1)%v.length]],p),r.vmult(m[v[(d+2)%v.length]],g),n.vadd(p,p),n.vadd(g,g);const y=Kn;g.vsub(p,y);const x=Qn;y.unit(x);const _=u.get(),b=u.get();i.vsub(p,b);const w=b.dot(x);x.scale(w,_),_.vadd(p,_);const M=u.get();if(_.vsub(i,M),w>0&&w*wu.length||v>u[0].length)return;g<0&&(g=0),y<0&&(y=0),v<0&&(v=0),_<0&&(_=0),g>=u.length&&(g=u.length-1),y>=u.length&&(y=u.length-1),_>=u[0].length&&(_=u[0].length-1),v>=u[0].length&&(v=u[0].length-1);const b=[];e.getRectMinMax(g,v,y,_,b);const w=b[0],M=b[1];if(f.z-d>M||f.z+d2)return}}boxHeightfield(t,e,i,n,s,r,o,a,l,c,h){return t.convexPolyhedronRepresentation.material=t.material,t.convexPolyhedronRepresentation.collisionResponse=t.collisionResponse,this.convexHeightfield(t.convexPolyhedronRepresentation,e,i,n,s,r,o,a,t,e,h)}convexHeightfield(t,e,i,n,s,r,o,a,l,c,h){const u=e.data,d=e.elementSize,p=t.boundingSphereRadius,m=ws,f=Ms,g=bs;x.pointToLocalFrame(n,r,i,g);let y=Math.floor((g.x-p)/d)-1,v=Math.ceil((g.x+p)/d)+1,_=Math.floor((g.y-p)/d)-1,b=Math.ceil((g.y+p)/d)+1;if(v<0||b<0||y>u.length||_>u[0].length)return;y<0&&(y=0),v<0&&(v=0),_<0&&(_=0),b<0&&(b=0),y>=u.length&&(y=u.length-1),v>=u.length&&(v=u.length-1),b>=u[0].length&&(b=u[0].length-1),_>=u[0].length&&(_=u[0].length-1);const w=[];e.getRectMinMax(y,_,v,b,w);const M=w[0],S=w[1];if(!(g.z-p>S||g.z+p0&&v<0&&(f.vsub(u,g),m.copy(p),m.normalize(),_=g.dot(m),m.scale(_,g),g.vadd(u,g),g.distanceTo(f)0&&!0===n||h<=0&&!1===n))return!1;null===n&&(n=h>0)}return!0}const Vn=new r,kn=new r,Gn=new r,Wn=new r,qn=[new r,new r,new r,new r,new r,new r],jn=new r,Xn=new r,Yn=new r,Zn=new r;cn.prototype[ln.sphereBox]=cn.prototype.sphereBox;const Jn=new r,Kn=new r,Qn=new r,$n=new r,ts=new r,es=new r,is=new r,ns=new r,ss=new r,rs=new r;cn.prototype[ln.sphereConvex]=cn.prototype.sphereConvex,cn.prototype[ln.planeBox]=cn.prototype.planeBox;const os=new r,as=new r,ls=new r,cs=new r;cn.prototype[ln.planeConvex]=cn.prototype.planeConvex;const hs=new r,us=new r;cn.prototype[ln.convexConvex]=cn.prototype.convexConvex;const ds=new r,ps=new r,ms=new r;cn.prototype[ln.planeParticle]=cn.prototype.planeParticle;const fs=new r;cn.prototype[ln.sphereParticle]=cn.prototype.sphereParticle;const gs=new m,ys=new r,vs=new r,xs=new r,_s=new r;cn.prototype[ln.convexParticle]=cn.prototype.convexParticle,cn.prototype[ln.boxHeightfield]=cn.prototype.boxHeightfield;const bs=new r,ws=new r,Ms=[0];cn.prototype[ln.convexHeightfield]=cn.prototype.convexHeightfield;const Ss=new r,Es=new r;cn.prototype[ln.sphereHeightfield]=cn.prototype.sphereHeightfield;class Ts{constructor(){this.current=[],this.previous=[]}getKey(t,e){if(en[s];)s++;if(i!==n[s]){for(let t=n.length-1;t>=s;t--)n[t+1]=n[t];n[s]=i}}tick(){const t=this.current;this.current=this.previous,this.previous=t,this.current.length=0}getDiff(t,e){const i=this.current,n=this.previous,s=i.length,r=n.length;let o=0;for(let e=0;en[o];)o++;s=r===n[o],s||As(t,r)}o=0;for(let t=0;ti[o];)o++;s=i[o]===r,s||As(e,r)}}}function As(t,e){t.push((4294901760&e)>>16,65535&e)}class Cs{constructor(){this.data={keys:[]}}get(t,e){if(t>e){const i=e;e=t,t=i}return this.data[t+"-"+e]}set(t,e,i){if(t>e){const i=e;e=t,t=i}const n=t+"-"+e;this.get(t,e)||this.data.keys.push(n),this.data[n]=i}reset(){const t=this.data,e=t.keys;for(;e.length>0;)delete t[e.pop()]}}class Rs extends p{constructor(t={}){super(),this.dt=-1,this.allowSleep=!!t.allowSleep,this.contacts=[],this.frictionEquations=[],this.quatNormalizeSkip=void 0!==t.quatNormalizeSkip?t.quatNormalizeSkip:0,this.quatNormalizeFast=void 0!==t.quatNormalizeFast&&t.quatNormalizeFast,this.time=0,this.stepnumber=0,this.default_dt=1/60,this.nextId=0,this.gravity=new r,t.gravity&&this.gravity.copy(t.gravity),this.broadphase=void 0!==t.broadphase?t.broadphase:new J,this.bodies=[],this.hasActiveBodies=!1,this.solver=void 0!==t.solver?t.solver:new qi,this.constraints=[],this.narrowphase=new cn(this),this.collisionMatrix=new d,this.collisionMatrixPrevious=new d,this.bodyOverlapKeeper=new Ts,this.shapeOverlapKeeper=new Ts,this.materials=[],this.contactmaterials=[],this.contactMaterialTable=new Cs,this.defaultMaterial=new pe("default"),this.defaultContactMaterial=new de(this.defaultMaterial,this.defaultMaterial,{friction:.3,restitution:0}),this.doProfiling=!1,this.profile={solve:0,makeContactConstraints:0,broadphase:0,integrate:0,narrowphase:0},this.accumulator=0,this.subsystems=[],this.addBodyEvent={type:"addBody",body:null},this.removeBodyEvent={type:"removeBody",body:null},this.idToBodyMap={},this.broadphase.setWorld(this)}getContactMaterial(t,e){return this.contactMaterialTable.get(t.id,e.id)}numObjects(){return this.bodies.length}collisionMatrixTick(){const t=this.collisionMatrixPrevious;this.collisionMatrixPrevious=this.collisionMatrix,this.collisionMatrix=t,this.collisionMatrix.reset(),this.bodyOverlapKeeper.tick(),this.shapeOverlapKeeper.tick()}addConstraint(t){this.constraints.push(t)}removeConstraint(t){const e=this.constraints.indexOf(t);-1!==e&&this.constraints.splice(e,1)}rayTest(t,e,i){i instanceof K?this.raycastClosest(t,e,{skipBackfaces:!0},i):this.raycastAll(t,e,{skipBackfaces:!0},i)}raycastAll(t,e,i={},n){return i.mode=$.ALL,i.from=t,i.to=e,i.callback=n,Ls.intersectWorld(this,i)}raycastAny(t,e,i={},n){return i.mode=$.ANY,i.from=t,i.to=e,i.result=n,Ls.intersectWorld(this,i)}raycastClosest(t,e,i={},n){return i.mode=$.CLOSEST,i.from=t,i.to=e,i.result=n,Ls.intersectWorld(this,i)}addBody(t){this.bodies.includes(t)||(t.index=this.bodies.length,this.bodies.push(t),t.world=this,t.initPosition.copy(t.position),t.initVelocity.copy(t.velocity),t.timeLastSleepy=this.time,t instanceof R&&(t.initAngularVelocity.copy(t.angularVelocity),t.initQuaternion.copy(t.quaternion)),this.collisionMatrix.setNumObjects(this.bodies.length),this.addBodyEvent.body=t,this.idToBodyMap[t.id]=t,this.dispatchEvent(this.addBodyEvent))}removeBody(t){t.world=null;const e=this.bodies.length-1,i=this.bodies,n=i.indexOf(t);if(-1!==n){i.splice(n,1);for(let t=0;t!==i.length;t++)i[t].index=t;this.collisionMatrix.setNumObjects(e),this.removeBodyEvent.body=t,delete this.idToBodyMap[t.id],this.dispatchEvent(this.removeBodyEvent)}}getBodyById(t){return this.idToBodyMap[t]}getShapeById(t){const e=this.bodies;for(let i=0,n=e.length;i=t&&n=0;e-=1)(t.bodyA===i[e]&&t.bodyB===n[e]||t.bodyB===i[e]&&t.bodyA===n[e])&&(i.splice(e,1),n.splice(e,1))}this.collisionMatrixTick(),l&&(u=performance.now());const x=Ns,_=e.length;for(y=0;y!==_;y++)x.push(e[y]);e.length=0;const b=this.frictionEquations.length;for(y=0;y!==b;y++)p.push(this.frictionEquations[y]);for(this.frictionEquations.length=0,this.narrowphase.getContacts(i,n,this,e,x,this.frictionEquations,p),l&&(c.narrowphase=performance.now()-u),l&&(u=performance.now()),y=0;y=0&&s.material.friction>=0&&(c=n.material.friction*s.material.friction),n.material.restitution>=0&&s.material.restitution>=0&&(i.restitution=n.material.restitution*s.material.restitution)),o.addEquation(i),n.allowSleep&&n.type===R.DYNAMIC&&n.sleepState===R.SLEEPING&&s.sleepState===R.AWAKE&&s.type!==R.STATIC&&s.velocity.lengthSquared()+s.angularVelocity.lengthSquared()>=2*s.sleepSpeedLimit**2&&(n.wakeUpAfterNarrowphase=!0),s.allowSleep&&s.type===R.DYNAMIC&&s.sleepState===R.SLEEPING&&n.sleepState===R.AWAKE&&n.type!==R.STATIC&&n.velocity.lengthSquared()+n.angularVelocity.lengthSquared()>=2*n.sleepSpeedLimit**2&&(s.wakeUpAfterNarrowphase=!0),this.collisionMatrix.set(n,s,!0),this.collisionMatrixPrevious.get(n,s)||(Ds.body=s,Ds.contact=i,n.dispatchEvent(Ds),Ds.body=n,s.dispatchEvent(Ds)),this.bodyOverlapKeeper.set(n.id,s.id),this.shapeOverlapKeeper.set(r.id,a.id)}for(this.emitContactEvents(),l&&(c.makeContactConstraints=performance.now()-u,u=performance.now()),y=0;y!==s;y++){const t=r[y];t.wakeUpAfterNarrowphase&&(t.wakeUp(),t.wakeUpAfterNarrowphase=!1)}for(v=d.length,y=0;y!==v;y++){const t=d[y];t.update();for(let e=0,i=t.equations.length;e!==i;e++){const i=t.equations[e];o.addEquation(i)}}o.solve(t,this),l&&(c.solve=performance.now()-u),o.removeAllEquations();const M=Math.pow;for(y=0;y!==s;y++){const e=r[y];if(e.type&h){const i=M(1-e.linearDamping,t),n=e.velocity;n.scale(i,n);const s=e.angularVelocity;if(s){const i=M(1-e.angularDamping,t);s.scale(i,s)}}}for(this.dispatchEvent(Is),y=0;y!==s;y++){const t=r[y];t.preStep&&t.preStep.call(t)}l&&(u=performance.now());const S=this.stepnumber%(this.quatNormalizeSkip+1)==0,E=this.quatNormalizeFast;for(y=0;y!==s;y++)r[y].integrate(t,S,E);for(this.clearForces(),this.broadphase.dirty=!0,l&&(c.integrate=performance.now()-u),this.time+=t,this.stepnumber+=1,this.dispatchEvent(Ps),y=0;y!==s;y++){const t=r[y],e=t.postStep;e&&e.call(t)}let T=!0;if(this.allowSleep)for(T=!1,y=0;y!==s;y++){const t=r[y];t.sleepTick(this.time),t.sleepState!==R.SLEEPING&&(T=!0)}this.hasActiveBodies=T}clearForces(){const t=this.bodies,e=t.length;for(let i=0;i!==e;i++){const e=t[i];e.force,e.torque,e.force.set(0,0,0),e.torque.set(0,0,0)}}}new c;const Ls=new $;if("undefined"==typeof performance&&(performance={}),!performance.now){let t=Date.now();performance.timing&&performance.timing.navigationStart&&(t=performance.timing.navigationStart),performance.now=()=>Date.now()-t}const Ps={type:"postStep"},Is={type:"preStep"},Ds={type:R.COLLIDE_EVENT_NAME,body:null,contact:null},Ns=[],Bs=[],Fs=[],Os=[];Rs.prototype.emitContactEvents=(()=>{const t=[],e=[],i={type:"beginContact",bodyA:null,bodyB:null},n={type:"endContact",bodyA:null,bodyB:null},s={type:"beginShapeContact",bodyA:null,bodyB:null,shapeA:null,shapeB:null},r={type:"endShapeContact",bodyA:null,bodyB:null,shapeA:null,shapeB:null};return function(){const o=this.hasAnyEventListener("beginContact"),a=this.hasAnyEventListener("endContact");if((o||a)&&this.bodyOverlapKeeper.getDiff(t,e),o){for(let e=0,n=t.length;e{"use strict";const i=e.TYPE={BOX:"box",CYLINDER:"cylinder",SPHERE:"sphere",CAPSULE:"capsule",CONE:"cone",HULL:"hull",HACD:"hacd",VHACD:"vhacd",MESH:"mesh",HEIGHTFIELD:"heightfield"},n=e.FIT={ALL:"all",MANUAL:"manual"},s=(e.HEIGHTFIELD_DATA_TYPE={short:"short",float:"float"},THREE.Object3D.prototype.hasOwnProperty("updateMatrices"));function r(t){t.fit=t.hasOwnProperty("fit")?t.fit:n.ALL,t.type=t.type||i.HULL,t.minHalfExtent=t.hasOwnProperty("minHalfExtent")?t.minHalfExtent:0,t.maxHalfExtent=t.hasOwnProperty("maxHalfExtent")?t.maxHalfExtent:Number.POSITIVE_INFINITY,t.cylinderAxis=t.cylinderAxis||"y",t.margin=t.hasOwnProperty("margin")?t.margin:.01,t.includeInvisible=!!t.hasOwnProperty("includeInvisible")&&t.includeInvisible,t.offset||(t.offset=new THREE.Vector3),t.orientation||(t.orientation=new THREE.Quaternion)}e.createCollisionShapes=function(t,e){switch(e.type){case i.BOX:return[this.createBoxShape(t,e)];case i.CYLINDER:return[this.createCylinderShape(t,e)];case i.CAPSULE:return[this.createCapsuleShape(t,e)];case i.CONE:return[this.createConeShape(t,e)];case i.SPHERE:return[this.createSphereShape(t,e)];case i.HULL:return[this.createHullShape(t,e)];case i.HACD:return this.createHACDShapes(t,e);case i.VHACD:return this.createVHACDShapes(t,e);case i.MESH:return[this.createTriMeshShape(t,e)];case i.HEIGHTFIELD:return[this.createHeightfieldTerrainShape(t,e)];default:return console.warn(e.type+" is not currently supported"),[]}},e.createBoxShape=function(t,e){e.type=i.BOX,r(e),e.fit===n.ALL&&(e.halfExtents=h(t,u(t,e),e.minHalfExtent,e.maxHalfExtent));const s=new Ammo.btVector3(e.halfExtents.x,e.halfExtents.y,e.halfExtents.z),a=new Ammo.btBoxShape(s);return Ammo.destroy(s),o(a,e,l(t,e)),a},e.createCylinderShape=function(t,e){e.type=i.CYLINDER,r(e),e.fit===n.ALL&&(e.halfExtents=h(t,u(t,e),e.minHalfExtent,e.maxHalfExtent));const s=new Ammo.btVector3(e.halfExtents.x,e.halfExtents.y,e.halfExtents.z),a=(()=>{switch(e.cylinderAxis){case"y":return new Ammo.btCylinderShape(s);case"x":return new Ammo.btCylinderShapeX(s);case"z":return new Ammo.btCylinderShapeZ(s)}return null})();return Ammo.destroy(s),o(a,e,l(t,e)),a},e.createCapsuleShape=function(t,e){e.type=i.CAPSULE,r(e),e.fit===n.ALL&&(e.halfExtents=h(t,u(t,e),e.minHalfExtent,e.maxHalfExtent));const{x:s,y:a,z:c}=e.halfExtents,d=(()=>{switch(e.cylinderAxis){case"y":return new Ammo.btCapsuleShape(Math.max(s,c),2*a);case"x":return new Ammo.btCapsuleShapeX(Math.max(a,c),2*s);case"z":return new Ammo.btCapsuleShapeZ(Math.max(s,a),2*c)}return null})();return o(d,e,l(t,e)),d},e.createConeShape=function(t,e){e.type=i.CONE,r(e),e.fit===n.ALL&&(e.halfExtents=h(t,u(t,e),e.minHalfExtent,e.maxHalfExtent));const{x:s,y:a,z:c}=e.halfExtents,d=(()=>{switch(e.cylinderAxis){case"y":return new Ammo.btConeShape(Math.max(s,c),2*a);case"x":return new Ammo.btConeShapeX(Math.max(a,c),2*s);case"z":return new Ammo.btConeShapeZ(Math.max(s,a),2*c)}return null})();return o(d,e,l(t,e)),d},e.createSphereShape=function(t,e){let s;e.type=i.SPHERE,r(e),s=e.fit!==n.MANUAL||isNaN(e.sphereRadius)?c(t,e,u(t,e)):e.sphereRadius;const a=new Ammo.btSphereShape(s);return o(a,e,l(t,e)),a},e.createHullShape=function(){const t=new THREE.Vector3,e=new THREE.Vector3;return function(s,c){if(c.type=i.HULL,r(c),c.fit===n.MANUAL)return console.warn("cannot use fit: manual with type: hull"),null;const h=u(s,c),d=new Ammo.btVector3,p=new Ammo.btConvexHullShape;p.setMargin(c.margin),e.addVectors(h.max,h.min).multiplyScalar(.5);let m=0;a(s,c,(t=>{m+=t.attributes.position.array.length/3}));const f=c.hullMaxVertices||1e5;m>f&&console.warn(`too many vertices for hull shape; sampling ~${f} from ~${m} vertices`);const g=Math.min(1,f/m);a(s,c,((i,n)=>{const s=i.attributes.position.array;for(let i=0;i=100){const t=new Ammo.btShapeHull(p);t.buildHull(c.margin),Ammo.destroy(p),y=new Ammo.btConvexHullShape(Ammo.getPointer(t.getVertexPointer()),t.numVertices()),Ammo.destroy(t)}return Ammo.destroy(d),o(y,c,l(s,c)),y}}(),e.createHACDShapes=function(){const t=new THREE.Vector3,e=new THREE.Vector3;return function(s,c){if(c.type=i.HACD,r(c),c.fit===n.MANUAL)return console.warn("cannot use fit: manual with type: hacd"),[];if(!Ammo.hasOwnProperty("HACD"))return console.warn("HACD unavailable in included build of Ammo.js. Visit https://github.com/mozillareality/ammo.js for the latest version."),[];const h=u(s),d=l(s,c);let p=0,m=0;e.addVectors(h.max,h.min).multiplyScalar(.5),a(s,c,(t=>{p+=t.attributes.position.array.length/3,t.index?m+=t.index.array.length/3:m+=t.attributes.position.array.length/9}));const f=new Ammo.HACD;c.hasOwnProperty("compacityWeight")&&f.SetCompacityWeight(c.compacityWeight),c.hasOwnProperty("volumeWeight")&&f.SetVolumeWeight(c.volumeWeight),c.hasOwnProperty("nClusters")&&f.SetNClusters(c.nClusters),c.hasOwnProperty("nVerticesPerCH")&&f.SetNVerticesPerCH(c.nVerticesPerCH),c.hasOwnProperty("concavity")&&f.SetConcavity(c.concavity);const g=Ammo._malloc(3*p*8),y=Ammo._malloc(3*m*4);f.SetPoints(g),f.SetTriangles(y),f.SetNPoints(p),f.SetNTriangles(m);const v=g/8,x=y/4;a(s,c,((i,n)=>{const s=i.attributes.position.array,r=i.index?i.index.array:null;for(let i=0;i{p+=t.attributes.position.count,t.index?m+=t.index.count/3:m+=t.attributes.position.count/3}));const f=new Ammo.VHACD,g=new Ammo.Parameters;c.hasOwnProperty("resolution")&&g.set_m_resolution(c.resolution),c.hasOwnProperty("depth")&&g.set_m_depth(c.depth),c.hasOwnProperty("concavity")&&g.set_m_concavity(c.concavity),c.hasOwnProperty("planeDownsampling")&&g.set_m_planeDownsampling(c.planeDownsampling),c.hasOwnProperty("convexhullDownsampling")&&g.set_m_convexhullDownsampling(c.convexhullDownsampling),c.hasOwnProperty("alpha")&&g.set_m_alpha(c.alpha),c.hasOwnProperty("beta")&&g.set_m_beta(c.beta),c.hasOwnProperty("gamma")&&g.set_m_gamma(c.gamma),c.hasOwnProperty("pca")&&g.set_m_pca(c.pca),c.hasOwnProperty("mode")&&g.set_m_mode(c.mode),c.hasOwnProperty("maxNumVerticesPerCH")&&g.set_m_maxNumVerticesPerCH(c.maxNumVerticesPerCH),c.hasOwnProperty("minVolumePerCH")&&g.set_m_minVolumePerCH(c.minVolumePerCH),c.hasOwnProperty("convexhullApproximation")&&g.set_m_convexhullApproximation(c.convexhullApproximation),c.hasOwnProperty("oclAcceleration")&&g.set_m_oclAcceleration(c.oclAcceleration);const y=Ammo._malloc(3*p*8),v=Ammo._malloc(3*m*4);let x=y/8,_=v/4;a(s,c,((i,n)=>{const s=i.attributes.position.array,r=i.index?i.index.array:null;for(let i=0;i{const r=i.attributes.position.array;if(i.index)for(let o=0;o0?s[0].length:0,p=Ammo._malloc(u*d*4),m=p/4;let f=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,y=0;for(let t=0;t{for(let e of t.resources||[])Ammo.destroy(e);t.heightfieldData&&Ammo._free(t.heightfieldData),Ammo.destroy(t)};const n=new Ammo.btTransform,s=new Ammo.btQuaternion;if(n.setIdentity(),n.getOrigin().setValue(e.offset.x,e.offset.y,e.offset.z),s.setValue(e.orientation.x,e.orientation.y,e.orientation.z,e.orientation.w),n.setRotation(s),Ammo.destroy(s),i){const e=new Ammo.btVector3(i.x,i.y,i.z);t.setLocalScaling(e),Ammo.destroy(e)}t.localTransform=n},a=function(){const t=new THREE.Matrix4,e=new THREE.Matrix4,i=new THREE.BufferGeometry;return function(n,r,o){e.copy(n.matrixWorld).invert(),n.traverse((a=>{!a.isMesh||THREE.Sky&&a.__proto__==THREE.Sky.prototype||!(r.includeInvisible||a.el&&a.el.object3D.visible||a.visible)||(a===n?t.identity():(s&&a.updateMatrices(),t.multiplyMatrices(e,a.matrixWorld)),o(a.geometry.isBufferGeometry?a.geometry:i.fromGeometry(a.geometry),t))}))}}(),l=function(t,e){const i=new THREE.Vector3(1,1,1);return e.fit===n.ALL&&i.setFromMatrixScale(t.matrixWorld),i},c=function(){const t=new THREE.Vector3,e=new THREE.Vector3;return function(i,n,s){let r=0,{x:o,y:l,z:c}=s.getCenter(e);return a(i,n,((e,i)=>{const n=e.attributes.position.array;for(let e=0;e{const n=e.attributes.position.array;for(let e=0;el&&(l=t.x),t.y>c&&(c=t.y),t.z>h&&(h=t.z)})),n.min.set(s,r,o),n.max.set(l,c,h),n}}()},122:(t,e,i)=>{function n(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}i.m=t,i.c=e,i.i=function(t){return t},i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="/",i.oe=function(t){throw console.error(t),t};var n=i(i.s=ENTRY_MODULE);return n.default||n}var s="[\\.|\\-|\\+|\\w|/|@]+",r="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+s+").*?\\)";function o(t){return(t+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function a(t,e,n){var a={};a[n]=[];var l=e.toString(),c=l.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!c)return a;for(var h,u=c[1],d=new RegExp("(\\\\n|\\W)"+o(u)+r,"g");h=d.exec(l);)"dll-reference"!==h[3]&&a[n].push(h[3]);for(d=new RegExp("\\("+o(u)+'\\("(dll-reference\\s('+s+'))"\\)\\)'+r,"g");h=d.exec(l);)t[h[2]]||(a[n].push(h[1]),t[h[2]]=i(h[1]).m),a[h[2]]=a[h[2]]||[],a[h[2]].push(h[4]);for(var p,m=Object.keys(a),f=0;f0}),!1)}t.exports=function(t,e){e=e||{};var s={main:i.m},r=e.all?{main:Object.keys(s.main)}:function(t,e){for(var i={main:[e]},n={main:[]},s={main:{}};l(i);)for(var r=Object.keys(i),o=0;o{const n=i(279).CONSTRAINT;t.exports=AFRAME.registerComponent("ammo-constraint",{multiple:!0,schema:{type:{default:n.LOCK,oneOf:[n.LOCK,n.FIXED,n.SPRING,n.SLIDER,n.HINGE,n.CONE_TWIST,n.POINT_TO_POINT]},target:{type:"selector"},pivot:{type:"vec3"},targetPivot:{type:"vec3"},axis:{type:"vec3",default:{x:0,y:0,z:1}},targetAxis:{type:"vec3",default:{x:0,y:0,z:1}},damping:{type:"number",default:1},stiffness:{type:"number",default:100}},init:function(){this.system=this.el.sceneEl.systems.physics,this.constraint=null},remove:function(){this.constraint&&(this.system.removeConstraint(this.constraint),this.constraint=null)},update:function(){const t=this.el,e=this.data;this.remove(),t.body&&e.target.body?(this.constraint=this.createConstraint(),this.system.addConstraint(this.constraint)):(t.body?e.target:t).addEventListener("body-loaded",this.update.bind(this,{}),{once:!0})},createConstraint:function(){let t;const e=this.data,i=this.el.body,s=e.target.body,r=i.getCenterOfMassTransform().inverse().op_mul(s.getWorldTransform()),o=new Ammo.btTransform;switch(o.setIdentity(),e.type){case n.LOCK:{t=new Ammo.btGeneric6DofConstraint(i,s,r,o,!0);const e=new Ammo.btVector3(0,0,0);t.setLinearLowerLimit(e),t.setLinearUpperLimit(e),t.setAngularLowerLimit(e),t.setAngularUpperLimit(e),Ammo.destroy(e);break}case n.FIXED:r.setRotation(i.getWorldTransform().getRotation()),o.setRotation(s.getWorldTransform().getRotation()),t=new Ammo.btFixedConstraint(i,s,r,o);break;case n.SPRING:{for(var a in t=new Ammo.btGeneric6DofSpringConstraint(i,s,r,o,!0),[0,1,2,3,4,5])t.enableSpring(1,!0),t.setStiffness(1,this.data.stiffness),t.setDamping(1,this.data.damping);const e=new Ammo.btVector3(-1,-1,-1),n=new Ammo.btVector3(1,1,1);t.setLinearUpperLimit(e),t.setLinearLowerLimit(n),Ammo.destroy(e),Ammo.destroy(n);break}case n.SLIDER:t=new Ammo.btSliderConstraint(i,s,r,o,!0),t.setLowerLinLimit(-1),t.setUpperLinLimit(1);break;case n.HINGE:{const n=new Ammo.btVector3(e.pivot.x,e.pivot.y,e.pivot.z),r=new Ammo.btVector3(e.targetPivot.x,e.targetPivot.y,e.targetPivot.z),o=new Ammo.btVector3(e.axis.x,e.axis.y,e.axis.z),a=new Ammo.btVector3(e.targetAxis.x,e.targetAxis.y,e.targetAxis.z);t=new Ammo.btHingeConstraint(i,s,n,r,o,a,!0),Ammo.destroy(n),Ammo.destroy(r),Ammo.destroy(o),Ammo.destroy(a);break}case n.CONE_TWIST:{const n=new Ammo.btTransform;n.setIdentity(),n.getOrigin().setValue(e.pivot.x,e.pivot.y,e.pivot.z);const r=new Ammo.btTransform;r.setIdentity(),r.getOrigin().setValue(e.targetPivot.x,e.targetPivot.y,e.targetPivot.z),t=new Ammo.btConeTwistConstraint(i,s,n,r),Ammo.destroy(n),Ammo.destroy(r);break}case n.POINT_TO_POINT:{const n=new Ammo.btVector3(e.pivot.x,e.pivot.y,e.pivot.z),r=new Ammo.btVector3(e.targetPivot.x,e.targetPivot.y,e.targetPivot.z);t=new Ammo.btPoint2PointConstraint(i,s,n,r),Ammo.destroy(n),Ammo.destroy(r);break}default:throw new Error("[constraint] Unexpected type: "+e.type)}return Ammo.destroy(r),Ammo.destroy(o),t}})},854:(t,e,i)=>{i(694);const n=i(406),s=i(279),r=s.ACTIVATION_STATE,o=s.COLLISION_FLAG,a=s.SHAPE,l=s.TYPE,c=(s.FIT,[r.ACTIVE_TAG,r.ISLAND_SLEEPING,r.WANTS_DEACTIVATION,r.DISABLE_DEACTIVATION,r.DISABLE_SIMULATION]);function h(t,e,i){return Math.abs(e.x-i.x){this.loadedEventFired=!0}),{once:!0}),this.system.initialized&&this.loadedEventFired&&this.initBody()},initBody:function(){const t=new THREE.Vector3,e=new THREE.Quaternion;return new THREE.Box3,function(){const i=this.el,n=this.data;this.localScaling=new Ammo.btVector3;const s=this.el.object3D;var r;s.getWorldPosition(t),s.getWorldQuaternion(e),this.prevScale=new THREE.Vector3(1,1,1),this.prevNumChildShapes=0,this.msTransform=new Ammo.btTransform,this.msTransform.setIdentity(),this.rotation=new Ammo.btQuaternion(e.x,e.y,e.z,e.w),this.msTransform.getOrigin().setValue(t.x,t.y,t.z),this.msTransform.setRotation(this.rotation),this.motionState=new Ammo.btDefaultMotionState(this.msTransform),this.localInertia=new Ammo.btVector3(0,0,0),this.compoundShape=new Ammo.btCompoundShape(!0),this.rbInfo=new Ammo.btRigidBodyConstructionInfo(n.mass,this.motionState,this.compoundShape,this.localInertia),this.rbInfo.m_restitution=(r=this.data.restitution,0,1,Math.min(Math.max(r,0),1)),this.body=new Ammo.btRigidBody(this.rbInfo),this.body.setActivationState(c.indexOf(n.activationState)+1),this.body.setSleepingThresholds(n.linearSleepingThreshold,n.angularSleepingThreshold),this.body.setDamping(n.linearDamping,n.angularDamping);const o=new Ammo.btVector3(n.angularFactor.x,n.angularFactor.y,n.angularFactor.z);this.body.setAngularFactor(o),Ammo.destroy(o);const a=new Ammo.btVector3(n.gravity.x,n.gravity.y,n.gravity.z);u(.001,a,this.system.driver.physicsWorld.getGravity())||(this.body.setGravity(a),this.body.setFlags(1)),Ammo.destroy(a),this.updateCollisionFlags(),this.el.body=this.body,this.body.el=i,this.isLoaded=!0,this.el.emit("body-loaded",{body:this.el.body}),this._addToSystem()}}(),tick:function(){this.system.initialized&&!this.isLoaded&&this.loadedEventFired&&this.initBody()},_updateShapes:function(){const t=[a.HULL,a.HACD,a.VHACD];return function(){let e=!1;const i=this.el.object3D;if(this.data.scaleAutoUpdate&&this.prevScale&&!h(.001,i.scale,this.prevScale)&&(this.prevScale.copy(i.scale),e=!0,this.localScaling.setValue(this.prevScale.x,this.prevScale.y,this.prevScale.z),this.compoundShape.setLocalScaling(this.localScaling)),this.shapeComponentsChanged){this.shapeComponentsChanged=!1,e=!0;for(let t=0;t{var n=i(687);const{threeToCannon:s,ShapeType:r}=i(264);new THREE.Quaternion,i(503);var o,a,l={dependencies:["velocity"],schema:{mass:{default:5,if:{type:"dynamic"}},linearDamping:{default:.01,if:{type:"dynamic"}},angularDamping:{default:.01,if:{type:"dynamic"}},shape:{default:"auto",oneOf:["auto","box","cylinder","sphere","hull","mesh","none"]},cylinderAxis:{default:"y",oneOf:["x","y","z"]},sphereRadius:{default:NaN},type:{default:"dynamic",oneOf:["static","dynamic"]}},init:function(){this.system=this.el.sceneEl.systems.physics,this.el.sceneEl.hasLoaded?this.initBody():this.el.sceneEl.addEventListener("loaded",this.initBody.bind(this))},initBody:function(){var t=this.el,e=this.data,i=this.el.object3D,o=i.position,a=i.quaternion;if(this.body=new n.Body({mass:"static"===e.type?0:e.mass||0,material:this.system.getMaterial("defaultMaterial"),position:new n.Vec3(o.x,o.y,o.z),quaternion:new n.Quaternion(a.x,a.y,a.z,a.w),linearDamping:e.linearDamping,angularDamping:e.angularDamping,type:"dynamic"===e.type?n.Body.DYNAMIC:n.Body.STATIC}),this.el.object3D.updateMatrixWorld(!0),"none"!==e.shape){var l="auto"===e.shape?void 0:AFRAME.utils.extend({},this.data,{type:r[e.shape.toUpperCase()]}),{shape:c,offset:h,orientation:u}=function(t,e){return s(t,e)}(this.el.object3D,l);if(!c)return void t.addEventListener("object3dset",this.initBody.bind(this));this.body.addShape(c,h,u),this.system.debug&&(this.shouldUpdateWireframe=!0),this.isLoaded=!0}this.el.body=this.body,this.body.el=t,this.isPlaying&&this._play(),this.isLoaded&&this.el.emit("body-loaded",{body:this.el.body})},addShape:function(t,e,i){"none"===this.data.shape?t?this.body?(this.body.addShape(t,e,i),this.system.debug&&(this.shouldUpdateWireframe=!0),this.shouldUpdateBody=!0):console.warn("shape cannot be added before body is loaded"):console.warn("shape cannot be null"):console.warn("shape can only be added if shape property is none")},tick:function(){this.shouldUpdateBody&&(this.isLoaded=!0,this._play(),this.el.emit("body-loaded",{body:this.el.body}),this.shouldUpdateBody=!1),this.shouldUpdateWireframe&&(this.createWireframe(this.body),this.shouldUpdateWireframe=!1)},play:function(){this.isLoaded&&this._play()},_play:function(){this.syncToPhysics(),this.system.addComponent(this),this.system.addBody(this.body),this.wireframe&&this.el.sceneEl.object3D.add(this.wireframe)},pause:function(){this.isLoaded&&this._pause()},_pause:function(){this.system.removeComponent(this),this.body&&this.system.removeBody(this.body),this.wireframe&&this.el.sceneEl.object3D.remove(this.wireframe)},update:function(t){if(this.body){var e=this.data;null!=t.type&&e.type!=t.type&&(this.body.type="dynamic"===e.type?n.Body.DYNAMIC:n.Body.STATIC),this.body.mass=e.mass||0,"dynamic"===e.type&&(this.body.linearDamping=e.linearDamping,this.body.angularDamping=e.angularDamping),e.mass!==t.mass&&this.body.updateMassProperties(),this.body.updateProperties&&this.body.updateProperties()}},remove:function(){this.body&&(delete this.body.el,delete this.body),delete this.el.body,delete this.wireframe},beforeStep:function(){0===this.body.mass&&this.syncToPhysics()},step:function(){0!==this.body.mass&&this.syncFromPhysics()},createWireframe:function(t){var e,i;this.wireframe&&(this.el.sceneEl.object3D.remove(this.wireframe),delete this.wireframe),this.wireframe=new THREE.Object3D,this.el.sceneEl.object3D.add(this.wireframe);for(var s=new THREE.Quaternion,r=0;r{var n=i(344),s=AFRAME.utils.extend({},n.definition);t.exports=AFRAME.registerComponent("dynamic-body",s)},838:(t,e,i)=>{var n=i(344),s=AFRAME.utils.extend({},n.definition);s.schema=AFRAME.utils.extend({},n.definition.schema,{type:{default:"static",oneOf:["static","dynamic"]},mass:{default:0}}),t.exports=AFRAME.registerComponent("static-body",s)},696:(t,e,i)=>{var n=i(687);t.exports=AFRAME.registerComponent("constraint",{multiple:!0,schema:{type:{default:"lock",oneOf:["coneTwist","distance","hinge","lock","pointToPoint"]},target:{type:"selector"},maxForce:{default:1e6,min:0},collideConnected:{default:!0},wakeUpBodies:{default:!0},distance:{default:0,min:0},pivot:{type:"vec3"},targetPivot:{type:"vec3"},axis:{type:"vec3",default:{x:0,y:0,z:1}},targetAxis:{type:"vec3",default:{x:0,y:0,z:1}}},init:function(){this.system=this.el.sceneEl.systems.physics,this.constraint=null},remove:function(){this.constraint&&(this.system.removeConstraint(this.constraint),this.constraint=null)},update:function(){var t=this.el,e=this.data;this.remove(),t.body&&e.target.body?(this.constraint=this.createConstraint(),this.system.addConstraint(this.constraint)):(t.body?e.target:t).addEventListener("body-loaded",this.update.bind(this,{}))},createConstraint:function(){var t,e=this.data,i=new n.Vec3(e.pivot.x,e.pivot.y,e.pivot.z),s=new n.Vec3(e.targetPivot.x,e.targetPivot.y,e.targetPivot.z),r=new n.Vec3(e.axis.x,e.axis.y,e.axis.z),o=new n.Vec3(e.targetAxis.x,e.targetAxis.y,e.targetAxis.z);switch(e.type){case"lock":(t=new n.LockConstraint(this.el.body,e.target.body,{maxForce:e.maxForce})).type="LockConstraint";break;case"distance":(t=new n.DistanceConstraint(this.el.body,e.target.body,e.distance,e.maxForce)).type="DistanceConstraint";break;case"hinge":(t=new n.HingeConstraint(this.el.body,e.target.body,{pivotA:i,pivotB:s,axisA:r,axisB:o,maxForce:e.maxForce})).type="HingeConstraint";break;case"coneTwist":(t=new n.ConeTwistConstraint(this.el.body,e.target.body,{pivotA:i,pivotB:s,axisA:r,axisB:o,maxForce:e.maxForce})).type="ConeTwistConstraint";break;case"pointToPoint":(t=new n.PointToPointConstraint(this.el.body,i,e.target.body,s,e.maxForce)).type="PointToPointConstraint";break;default:throw new Error("[constraint] Unexpected type: "+e.type)}return t.collideConnected=e.collideConnected,t}})},421:(t,e,i)=>{t.exports={velocity:i(496),registerAll:function(t){this._registered||((t=t||window.AFRAME).components.velocity||t.registerComponent("velocity",this.velocity),this._registered=!0)}}},496:t=>{t.exports=AFRAME.registerComponent("velocity",{schema:{type:"vec3"},init:function(){this.system=this.el.sceneEl.systems.physics,this.system&&this.system.addComponent(this)},remove:function(){this.system&&this.system.removeComponent(this)},tick:function(t,e){e&&(this.system||this.afterStep(t,e))},afterStep:function(t,e){if(e){var i=this.el.sceneEl.systems.physics||{data:{maxInterval:1/60}},n=this.el.getAttribute("velocity")||{x:0,y:0,z:0},s=this.el.object3D.position||{x:0,y:0,z:0};e=Math.min(e,1e3*i.data.maxInterval),this.el.object3D.position.set(s.x+n.x*e/1e3,s.y+n.y*e/1e3,s.z+n.z*e/1e3)}}})},938:(t,e,i)=>{i(406);const n=i(279),s=n.SHAPE,r=n.FIT;var o={schema:{type:{default:s.HULL,oneOf:[s.BOX,s.CYLINDER,s.SPHERE,s.CAPSULE,s.CONE,s.HULL,s.HACD,s.VHACD,s.MESH,s.HEIGHTFIELD]},fit:{default:r.ALL,oneOf:[r.ALL,r.MANUAL]},halfExtents:{type:"vec3",default:{x:1,y:1,z:1}},minHalfExtent:{default:0},maxHalfExtent:{default:Number.POSITIVE_INFINITY},sphereRadius:{default:NaN},cylinderAxis:{default:"y",oneOf:["x","y","z"]},margin:{default:.01},offset:{type:"vec3",default:{x:0,y:0,z:0}},orientation:{type:"vec4",default:{x:0,y:0,z:0,w:1}},heightfieldData:{default:[]},heightfieldDistance:{default:1},includeInvisible:{default:!1}},multiple:!0,init:function(){this.system=this.el.sceneEl.systems.physics,this.collisionShapes=[];let t=this.el;for(this.body=t.components["ammo-body"]||null;!this.body&&t.parentNode!=this.el.sceneEl;)t=t.parentNode,t.components["ammo-body"]&&(this.body=t.components["ammo-body"]);if(this.body){if(this.data.fit!==r.MANUAL){if(!this.el.object3DMap.mesh)return void console.error("Cannot use FIT.ALL without object3DMap.mesh");this.mesh=this.el.object3DMap.mesh}this.body.addShapeComponent(this)}else console.warn("body not found")},getMesh:function(){return this.mesh||null},addShapes:function(t){this.collisionShapes=t},getShapes:function(){return this.collisionShapes},remove:function(){if(this.body)for(this.body.removeShapeComponent(this);this.collisionShapes.length>0;){const t=this.collisionShapes.pop();t.destroy(),Ammo.destroy(t.localTransform)}}};t.exports.definition=o,t.exports.Component=AFRAME.registerComponent("ammo-shape",o)},404:(t,e,i)=>{var n=i(687),s={schema:{shape:{default:"box",oneOf:["box","sphere","cylinder"]},offset:{type:"vec3",default:{x:0,y:0,z:0}},orientation:{type:"vec4",default:{x:0,y:0,z:0,w:1}},radius:{type:"number",default:1,if:{shape:["sphere"]}},halfExtents:{type:"vec3",default:{x:.5,y:.5,z:.5},if:{shape:["box"]}},radiusTop:{type:"number",default:1,if:{shape:["cylinder"]}},radiusBottom:{type:"number",default:1,if:{shape:["cylinder"]}},height:{type:"number",default:1,if:{shape:["cylinder"]}},numSegments:{type:"int",default:8,if:{shape:["cylinder"]}}},multiple:!0,init:function(){this.el.sceneEl.hasLoaded?this.initShape():this.el.sceneEl.addEventListener("loaded",this.initShape.bind(this))},initShape:function(){this.bodyEl=this.el;for(var t=this._findType(this.bodyEl),e=this.data;!t&&this.bodyEl.parentNode!=this.el.sceneEl;)this.bodyEl=this.bodyEl.parentNode,t=this._findType(this.bodyEl);if(t){var i,s,r,o=new THREE.Vector3;switch(this.bodyEl.object3D.getWorldScale(o),e.hasOwnProperty("offset")&&(s=new n.Vec3(e.offset.x*o.x,e.offset.y*o.y,e.offset.z*o.z)),e.hasOwnProperty("orientation")&&(r=new n.Quaternion).copy(e.orientation),e.shape){case"sphere":i=new n.Sphere(e.radius*o.x);break;case"box":var a=new n.Vec3(e.halfExtents.x*o.x,e.halfExtents.y*o.y,e.halfExtents.z*o.z);i=new n.Box(a);break;case"cylinder":i=new n.Cylinder(e.radiusTop*o.x,e.radiusBottom*o.x,e.height*o.y,e.numSegments);var l=new n.Quaternion;l.setFromEuler(90*THREE.Math.DEG2RAD,0,0,"XYZ").normalize(),r.mult(l,r);break;default:return void console.warn(e.shape+" shape not supported")}this.bodyEl.body?this.bodyEl.components[t].addShape(i,s,r):this.bodyEl.addEventListener("body-loaded",(function(){this.bodyEl.components[t].addShape(i,s,r)}),{once:!0})}else console.warn("body not found")},_findType:function(t){return t.hasAttribute("body")?"body":t.hasAttribute("dynamic-body")?"dynamic-body":t.hasAttribute("static-body")?"static-body":null},remove:function(){this.bodyEl.parentNode&&console.warn("removing shape component not currently supported")}};t.exports.definition=s,t.exports.Component=AFRAME.registerComponent("shape",s)},890:(t,e,i)=>{var n=i(687);t.exports=AFRAME.registerComponent("spring",{multiple:!0,schema:{target:{type:"selector"},restLength:{default:1,min:0},stiffness:{default:100,min:0},damping:{default:1,min:0},localAnchorA:{type:"vec3",default:{x:0,y:0,z:0}},localAnchorB:{type:"vec3",default:{x:0,y:0,z:0}}},init:function(){this.system=this.el.sceneEl.systems.physics,this.system.addComponent(this),this.isActive=!0,this.spring=null},update:function(t){var e=this.el,i=this.data;i.target?e.body&&i.target.body?(this.createSpring(),this.updateSpring(t)):(e.body?i.target:e).addEventListener("body-loaded",this.update.bind(this,{})):console.warn("Spring: invalid target specified.")},updateSpring:function(t){if(this.spring){var e=this.data,i=this.spring;Object.keys(e).forEach((function(n){if(e[n]!==t[n]){if("target"===n)return void(i.bodyB=e.target.body);i[n]=e[n]}}))}else console.warn("Spring: Component attempted to change spring before its created. No changes made.")},createSpring:function(){this.spring||(this.spring=new n.Spring(this.el.body))},step:function(t,e){return this.spring&&this.isActive?this.spring.applyForce():void 0},play:function(){this.isActive=!0},pause:function(){this.isActive=!1},remove:function(){this.spring&&delete this.spring,this.spring=null}})},279:t=>{t.exports={GRAVITY:-9.8,MAX_INTERVAL:4/60,ITERATIONS:10,CONTACT_MATERIAL:{friction:.01,restitution:.3,contactEquationStiffness:1e8,contactEquationRelaxation:3,frictionEquationStiffness:1e8,frictionEquationRegularization:3},ACTIVATION_STATE:{ACTIVE_TAG:"active",ISLAND_SLEEPING:"islandSleeping",WANTS_DEACTIVATION:"wantsDeactivation",DISABLE_DEACTIVATION:"disableDeactivation",DISABLE_SIMULATION:"disableSimulation"},COLLISION_FLAG:{STATIC_OBJECT:1,KINEMATIC_OBJECT:2,NO_CONTACT_RESPONSE:4,CUSTOM_MATERIAL_CALLBACK:8,CHARACTER_OBJECT:16,DISABLE_VISUALIZE_OBJECT:32,DISABLE_SPU_COLLISION_PROCESSING:64},TYPE:{STATIC:"static",DYNAMIC:"dynamic",KINEMATIC:"kinematic"},SHAPE:{BOX:"box",CYLINDER:"cylinder",SPHERE:"sphere",CAPSULE:"capsule",CONE:"cone",HULL:"hull",HACD:"hacd",VHACD:"vhacd",MESH:"mesh",HEIGHTFIELD:"heightfield"},FIT:{ALL:"all",MANUAL:"manual"},CONSTRAINT:{LOCK:"lock",FIXED:"fixed",SPRING:"spring",SLIDER:"slider",HINGE:"hinge",CONE_TWIST:"coneTwist",POINT_TO_POINT:"pointToPoint"}}},589:(t,e,i)=>{const n=i(766);function s(){this.collisionConfiguration=null,this.dispatcher=null,this.broadphase=null,this.solver=null,this.physicsWorld=null,this.debugDrawer=null,this.els=new Map,this.eventListeners=[],this.collisions=new Map,this.collisionKeys=[],this.currentCollisions=new Map}"undefined"!=typeof window&&(window.AmmoModule=window.Ammo,window.Ammo=null),s.prototype=new n,s.prototype.constructor=s,t.exports=s,s.prototype.init=function(t){return new Promise((e=>{AmmoModule().then((i=>{Ammo=i,this.epsilon=t.epsilon||1e-5,this.debugDrawMode=t.debugDrawMode||THREE.AmmoDebugConstants.NoDebug,this.maxSubSteps=t.maxSubSteps||4,this.fixedTimeStep=t.fixedTimeStep||1/60,this.collisionConfiguration=new Ammo.btDefaultCollisionConfiguration,this.dispatcher=new Ammo.btCollisionDispatcher(this.collisionConfiguration),this.broadphase=new Ammo.btDbvtBroadphase,this.solver=new Ammo.btSequentialImpulseConstraintSolver,this.physicsWorld=new Ammo.btDiscreteDynamicsWorld(this.dispatcher,this.broadphase,this.solver,this.collisionConfiguration),this.physicsWorld.setForceUpdateAllAabbs(!1),this.physicsWorld.setGravity(new Ammo.btVector3(0,t.hasOwnProperty("gravity")?t.gravity:-9.8,0)),this.physicsWorld.getSolverInfo().set_m_numIterations(t.solverIterations),e()}))}))},s.prototype.addBody=function(t,e,i){this.physicsWorld.addRigidBody(t,e,i),this.els.set(Ammo.getPointer(t),t.el)},s.prototype.removeBody=function(t){this.physicsWorld.removeRigidBody(t),this.removeEventListener(t);const e=Ammo.getPointer(t);this.els.delete(e),this.collisions.delete(e),this.collisionKeys.splice(this.collisionKeys.indexOf(e),1),this.currentCollisions.delete(e)},s.prototype.updateBody=function(t){this.els.has(Ammo.getPointer(t))&&this.physicsWorld.updateSingleAabb(t)},s.prototype.step=function(t){this.physicsWorld.stepSimulation(t,this.maxSubSteps,this.fixedTimeStep);const e=this.dispatcher.getNumManifolds();for(let t=0;t=0;t--){const n=i[t];this.currentCollisions.get(e).has(n)||(-1!==this.eventListeners.indexOf(e)&&this.els.get(e).emit("collideend",{targetEl:this.els.get(n)}),-1!==this.eventListeners.indexOf(n)&&this.els.get(n).emit("collideend",{targetEl:this.els.get(e)}),i.splice(t,1))}this.currentCollisions.get(e).clear()}this.debugDrawer&&this.debugDrawer.update()},s.prototype.addConstraint=function(t){this.physicsWorld.addConstraint(t,!1)},s.prototype.removeConstraint=function(t){this.physicsWorld.removeConstraint(t)},s.prototype.addEventListener=function(t){this.eventListeners.push(Ammo.getPointer(t))},s.prototype.removeEventListener=function(t){const e=Ammo.getPointer(t);-1!==this.eventListeners.indexOf(e)&&this.eventListeners.splice(this.eventListeners.indexOf(e),1)},s.prototype.destroy=function(){Ammo.destroy(this.collisionConfiguration),Ammo.destroy(this.dispatcher),Ammo.destroy(this.broadphase),Ammo.destroy(this.solver),Ammo.destroy(this.physicsWorld),Ammo.destroy(this.debugDrawer)},s.prototype.getDebugDrawer=function(t,e){return this.debugDrawer||((e=e||{}).debugDrawMode=e.debugDrawMode||this.debugDrawMode,this.debugDrawer=new THREE.AmmoDebugDrawer(t,this.physicsWorld,e)),this.debugDrawer}},766:t=>{function e(){}function i(){throw new Error("Method not implemented.")}t.exports=e,e.prototype.init=i,e.prototype.step=i,e.prototype.destroy=i,e.prototype.addBody=i,e.prototype.removeBody=i,e.prototype.applyBodyMethod=i,e.prototype.updateBodyProperties=i,e.prototype.addMaterial=i,e.prototype.addContactMaterial=i,e.prototype.addConstraint=i,e.prototype.removeConstraint=i,e.prototype.getContacts=i},437:t=>{t.exports={INIT:"init",STEP:"step",ADD_BODY:"add-body",REMOVE_BODY:"remove-body",APPLY_BODY_METHOD:"apply-body-method",UPDATE_BODY_PROPERTIES:"update-body-properties",ADD_MATERIAL:"add-material",ADD_CONTACT_MATERIAL:"add-contact-material",ADD_CONSTRAINT:"add-constraint",REMOVE_CONSTRAINT:"remove-constraint",COLLIDE:"collide"}},369:(t,e,i)=>{var n=i(687),s=i(766);function r(){this.world=null,this.materials={},this.contactMaterial=null}r.prototype=new s,r.prototype.constructor=r,t.exports=r,r.prototype.init=function(t){var e=new n.World;e.quatNormalizeSkip=t.quatNormalizeSkip,e.quatNormalizeFast=t.quatNormalizeFast,e.solver.iterations=t.solverIterations,e.gravity.set(0,t.gravity,0),e.broadphase=new n.NaiveBroadphase,this.world=e},r.prototype.step=function(t){this.world.step(t)},r.prototype.destroy=function(){delete this.world,delete this.contactMaterial,this.materials={}},r.prototype.addBody=function(t){this.world.addBody(t)},r.prototype.removeBody=function(t){this.world.removeBody(t)},r.prototype.applyBodyMethod=function(t,e,i){t["__"+e].apply(t,i)},r.prototype.updateBodyProperties=function(){},r.prototype.getMaterial=function(t){return this.materials[t]},r.prototype.addMaterial=function(t){this.materials[t.name]=new n.Material(t),this.materials[t.name].name=t.name},r.prototype.addContactMaterial=function(t,e,i){var s=this.materials[t],r=this.materials[e];this.contactMaterial=new n.ContactMaterial(s,r,i),this.world.addContactMaterial(this.contactMaterial)},r.prototype.addConstraint=function(t){t.type||(t instanceof n.LockConstraint?t.type="LockConstraint":t instanceof n.DistanceConstraint?t.type="DistanceConstraint":t instanceof n.HingeConstraint?t.type="HingeConstraint":t instanceof n.ConeTwistConstraint?t.type="ConeTwistConstraint":t instanceof n.PointToPointConstraint&&(t.type="PointToPointConstraint")),this.world.addConstraint(t)},r.prototype.removeConstraint=function(t){this.world.removeConstraint(t)},r.prototype.getContacts=function(){return this.world.contacts}},444:(t,e,i)=>{var n=i(766);function s(){throw new Error("[NetworkDriver] Driver not implemented.")}s.prototype=new n,s.prototype.constructor=s,t.exports=s},751:t=>{function e(){this.listeners=[]}t.exports=function(t){var i=new e,n=new e;return i.setTarget(n),n.setTarget(i),t(i),n},e.prototype.setTarget=function(t){this.target=t},e.prototype.addEventListener=function(t,e){this.listeners.push(e)},e.prototype.dispatchEvent=function(t,e){for(var i=0;i{var n=i(122),s=i(751),r=i(766),o=i(437),a=i(705),l=i(459),c=l.ID;function h(t){this.fps=t.fps,this.engine=t.engine,this.interpolate=t.interpolate,this.interpBufferSize=t.interpolationBufferSize,this.debug=t.debug,this.bodies={},this.contacts=[],this.frameDelay=1e3*this.interpBufferSize/this.fps,this.frameBuffer=[],this.worker=this.debug?s(a):n(a),this.worker.addEventListener("message",this._onMessage.bind(this))}h.prototype=new r,h.prototype.constructor=h,t.exports=h,h.prototype.init=function(t){this.worker.postMessage({type:o.INIT,worldConfig:t,fps:this.fps,engine:this.engine})},h.prototype.step=function(){if(this.interpolate){for(var t=this.frameBuffer[0],e=this.frameBuffer[1],i=performance.now();t&&e&&i-t.timestamp>this.frameDelay;)this.frameBuffer.shift(),t=this.frameBuffer[0],e=this.frameBuffer[1];if(t&&e){var n=(i-t.timestamp)/this.frameDelay;for(var s in n=(n-(1-1/this.interpBufferSize))*this.interpBufferSize,t.bodies)t.bodies.hasOwnProperty(s)&&e.bodies.hasOwnProperty(s)&&l.deserializeInterpBodyUpdate(t.bodies[s],e.bodies[s],this.bodies[s],n)}}},h.prototype.destroy=function(){this.worker.terminate(),delete this.worker},h.prototype._onMessage=function(t){if(t.data.type===o.STEP){var e=t.data.bodies;if(this.contacts=t.data.contacts,this.interpolate)this.frameBuffer.push({timestamp:performance.now(),bodies:e});else for(var i in e)e.hasOwnProperty(i)&&l.deserializeBodyUpdate(e[i],this.bodies[i])}else{if(t.data.type!==o.COLLIDE)throw new Error("[WorkerDriver] Unexpected message type.");var n=this.bodies[t.data.bodyID],s=this.bodies[t.data.targetID],r=l.deserializeContact(t.data.contact,this.bodies);if(!n._listeners||!n._listeners.collide)return;for(var a=0;a{var n=i(437),s=i(369),r=i(589),o=i(459),a=o.ID;t.exports=function(t){var e,i=null,l={},c={};function h(){i.step(e);var s={};Object.keys(l).forEach((function(t){s[t]=o.serializeBody(l[t])})),t.postMessage({type:n.STEP,bodies:s,contacts:i.getContacts().map(o.serializeContact)})}t.addEventListener("message",(function(u){var d=u.data;switch(d.type){case n.INIT:(i="cannon"===d.engine?new s:new r).init(d.worldConfig),e=1/d.fps,setInterval(h,1e3/d.fps);break;case n.ADD_BODY:var p=o.deserializeBody(d.body);p.material=i.getMaterial("defaultMaterial"),l[p[a]]=p,p.addEventListener("collide",(function(e){var i={type:n.COLLIDE,bodyID:e.target[a],targetID:e.body[a],contact:o.serializeContact(e.contact)};t.postMessage(i)})),i.addBody(p);break;case n.REMOVE_BODY:i.removeBody(l[d.bodyID]),delete l[d.bodyID];break;case n.APPLY_BODY_METHOD:l[d.bodyID][d.methodName](o.deserializeVec3(d.args[0]),o.deserializeVec3(d.args[1]));break;case n.UPDATE_BODY_PROPERTIES:o.deserializeBodyUpdate(d.body,l[d.body.id]);break;case n.ADD_MATERIAL:i.addMaterial(d.materialConfig);break;case n.ADD_CONTACT_MATERIAL:i.addContactMaterial(d.materialName1,d.materialName2,d.contactMaterialConfig);break;case n.ADD_CONSTRAINT:var m=o.deserializeConstraint(d.constraint,l);c[m[a]]=m,i.addConstraint(m);break;case n.REMOVE_CONSTRAINT:i.removeConstraint(c[d.constraintID]),delete c[d.constraintID];break;default:throw new Error("[Worker] Unexpected event type: %s",d.type)}}))}},855:(t,e,i)=>{var n=i(687),s=i(279),r=s.GRAVITY,o=s.CONTACT_MATERIAL;const{TYPE:a}=i(279);var l=i(369),c=i(220),h=i(444),u=i(589);i(261),t.exports=AFRAME.registerSystem("physics",{schema:{driver:{default:"local",oneOf:["local","worker","network","ammo"]},networkUrl:{default:"",if:{driver:"network"}},workerFps:{default:60,if:{driver:"worker"}},workerInterpolate:{default:!0,if:{driver:"worker"}},workerInterpBufferSize:{default:2,if:{driver:"worker"}},workerEngine:{default:"cannon",if:{driver:"worker"},oneOf:["cannon"]},workerDebug:{default:!1,if:{driver:"worker"}},gravity:{default:r},iterations:{default:s.ITERATIONS},friction:{default:o.friction},restitution:{default:o.restitution},contactEquationStiffness:{default:o.contactEquationStiffness},contactEquationRelaxation:{default:o.contactEquationRelaxation},frictionEquationStiffness:{default:o.frictionEquationStiffness},frictionEquationRegularization:{default:o.frictionEquationRegularization},maxInterval:{default:4/60},debug:{default:!1},debugDrawMode:{default:THREE.AmmoDebugConstants.NoDebug},maxSubSteps:{default:4},fixedTimeStep:{default:1/60},stats:{type:"array",default:[]}},async init(){var t=this.data;switch(this.debug=t.debug,this.initStats(),this.callbacks={beforeStep:[],step:[],afterStep:[]},this.listeners={},this.driver=null,t.driver){case"local":this.driver=new l;break;case"ammo":this.driver=new u;break;case"network":this.driver=new h(t.networkUrl);break;case"worker":this.driver=new c({fps:t.workerFps,engine:t.workerEngine,interpolate:t.workerInterpolate,interpolationBufferSize:t.workerInterpBufferSize,debug:t.workerDebug});break;default:throw new Error('[physics] Driver not recognized: "%s".',t.driver)}"ammo"!==t.driver?(await this.driver.init({quatNormalizeSkip:0,quatNormalizeFast:!1,solverIterations:t.iterations,gravity:t.gravity}),this.driver.addMaterial({name:"defaultMaterial"}),this.driver.addMaterial({name:"staticMaterial"}),this.driver.addContactMaterial("defaultMaterial","defaultMaterial",{friction:t.friction,restitution:t.restitution,contactEquationStiffness:t.contactEquationStiffness,contactEquationRelaxation:t.contactEquationRelaxation,frictionEquationStiffness:t.frictionEquationStiffness,frictionEquationRegularization:t.frictionEquationRegularization}),this.driver.addContactMaterial("staticMaterial","defaultMaterial",{friction:1,restitution:0,contactEquationStiffness:t.contactEquationStiffness,contactEquationRelaxation:t.contactEquationRelaxation,frictionEquationStiffness:t.frictionEquationStiffness,frictionEquationRegularization:t.frictionEquationRegularization})):await this.driver.init({gravity:t.gravity,debugDrawMode:t.debugDrawMode,solverIterations:t.iterations,maxSubSteps:t.maxSubSteps,fixedTimeStep:t.fixedTimeStep}),this.initialized=!0,this.debug&&this.setDebug(!0)},initStats(){if(this.statsToConsole=this.data.stats.includes("console"),this.statsToEvents=this.data.stats.includes("events"),this.statsToPanel=this.data.stats.includes("panel"),(this.statsToConsole||this.statsToEvents||this.statsToPanel)&&(this.trackPerf=!0,this.tickCounter=0,this.statsTickData={},this.statsBodyData={},this.countBodies={ammo:()=>this.countBodiesAmmo(),local:()=>this.countBodiesCannon(!1),worker:()=>this.countBodiesCannon(!0)},this.bodyTypeToStatsPropertyMap={ammo:{[a.STATIC]:"staticBodies",[a.KINEMATIC]:"kinematicBodies",[a.DYNAMIC]:"dynamicBodies"},cannon:{[n.Body.STATIC]:"staticBodies",[n.Body.DYNAMIC]:"dynamicBodies"}},this.el.sceneEl.setAttribute("stats-collector","inEvent: physics-tick-data;\n properties: before, after, engine, total;\n outputFrequency: 100;\n outEvent: physics-tick-summary;\n outputs: percentile__50, percentile__90, max")),this.statsToPanel){const t=this.el.sceneEl,e="   ";t.setAttribute("stats-panel",""),t.setAttribute("stats-group__bodies","label: Physics Bodies"),t.setAttribute("stats-row__b1","group: bodies;\n event:physics-body-data;\n properties: staticBodies;\n label: Static"),t.setAttribute("stats-row__b2","group: bodies;\n event:physics-body-data;\n properties: dynamicBodies;\n label: Dynamic"),"local"===this.data.driver||"worker"===this.data.driver?t.setAttribute("stats-row__b3","group: bodies;\n event:physics-body-data;\n properties: contacts;\n label: Contacts"):"ammo"===this.data.driver&&(t.setAttribute("stats-row__b3","group: bodies;\n event:physics-body-data;\n properties: kinematicBodies;\n label: Kinematic"),t.setAttribute("stats-row__b4","group: bodies;\n event: physics-body-data;\n properties: manifolds;\n label: Manifolds"),t.setAttribute("stats-row__b5","group: bodies;\n event: physics-body-data;\n properties: manifoldContacts;\n label: Contacts"),t.setAttribute("stats-row__b6","group: bodies;\n event: physics-body-data;\n properties: collisions;\n label: Collisions"),t.setAttribute("stats-row__b7","group: bodies;\n event: physics-body-data;\n properties: collisionKeys;\n label: Coll Keys")),t.setAttribute("stats-group__tick",`label: Physics Ticks: Median${e}90th%${e}99th%`),t.setAttribute("stats-row__1","group: tick;\n event:physics-tick-summary;\n properties: before.percentile__50, \n before.percentile__90, \n before.max;\n label: Before"),t.setAttribute("stats-row__2","group: tick;\n event:physics-tick-summary;\n properties: after.percentile__50, \n after.percentile__90, \n after.max; \n label: After"),t.setAttribute("stats-row__3","group: tick; \n event:physics-tick-summary; \n properties: engine.percentile__50, \n engine.percentile__90, \n engine.max;\n label: Engine"),t.setAttribute("stats-row__4","group: tick;\n event:physics-tick-summary;\n properties: total.percentile__50, \n total.percentile__90, \n total.max;\n label: Total")}},tick:function(t,e){if(!this.initialized||!e)return;const i=performance.now();var n,s=this.callbacks;for(n=0;n{const i=this.bodyTypeToStatsPropertyMap.ammo[function(t){return t.components["ammo-body"].data.type}(e)];t[i]++}))},countBodiesCannon(t){const e=this.statsBodyData;e.contacts=t?this.driver.contacts.length:this.driver.world.contacts.length,e.staticBodies=0,e.dynamicBodies=0,(t?Object.values(this.driver.bodies):this.driver.world.bodies).forEach((t=>{const i=this.bodyTypeToStatsPropertyMap.cannon[t.type];e[i]++}))},setDebug:function(t){this.debug=t,"ammo"===this.data.driver&&this.initialized&&(t&&!this.debugDrawer?(this.debugDrawer=this.driver.getDebugDrawer(this.el.object3D),this.debugDrawer.enable()):this.debugDrawer&&(this.debugDrawer.disable(),this.debugDrawer=null))},addBody:function(t,e,i){var n=this.driver;"local"===this.data.driver&&(t.__applyImpulse=t.applyImpulse,t.applyImpulse=function(){n.applyBodyMethod(t,"applyImpulse",arguments)},t.__applyForce=t.applyForce,t.applyForce=function(){n.applyBodyMethod(t,"applyForce",arguments)},t.updateProperties=function(){n.updateBodyProperties(t)},this.listeners[t.id]=function(e){t.el.emit("collide",e)},t.addEventListener("collide",this.listeners[t.id])),this.driver.addBody(t,e,i)},removeBody:function(t){this.driver.removeBody(t),"local"!==this.data.driver&&"worker"!==this.data.driver||(t.removeEventListener("collide",this.listeners[t.id]),delete this.listeners[t.id],t.applyImpulse=t.__applyImpulse,delete t.__applyImpulse,t.applyForce=t.__applyForce,delete t.__applyForce,delete t.updateProperties)},addConstraint:function(t){this.driver.addConstraint(t)},removeConstraint:function(t){this.driver.removeConstraint(t)},addComponent:function(t){var e=this.callbacks;t.beforeStep&&e.beforeStep.push(t),t.step&&e.step.push(t),t.afterStep&&e.afterStep.push(t)},removeComponent:function(t){var e=this.callbacks;t.beforeStep&&e.beforeStep.splice(e.beforeStep.indexOf(t),1),t.step&&e.step.splice(e.step.indexOf(t),1),t.afterStep&&e.afterStep.splice(e.afterStep.indexOf(t),1)},getContacts:function(){return this.driver.getContacts()},getMaterial:function(t){return this.driver.getMaterial(t)}})},229:t=>{t.exports.slerp=function(t,e,i){if(i<=0)return t;if(i>=1)return e;var n=t[0],s=t[1],r=t[2],o=t[3],a=o*e[3]+n*e[0]+s*e[1]+r*e[2];if(!(a<0))return e;if((t=t.slice())[3]=-e[3],t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],(a=-a)>=1)return t[3]=o,t[0]=n,t[1]=s,t[2]=r,this;var l=Math.sqrt(1-a*a);if(Math.abs(l)<.001)return t[3]=.5*(o+t[3]),t[0]=.5*(n+t[0]),t[1]=.5*(s+t[1]),t[2]=.5*(r+t[2]),this;var c=Math.atan2(l,a),h=Math.sin((1-i)*c)/l,u=Math.sin(i*c)/l;return t[3]=o*h+t[3]*u,t[0]=n*h+t[0]*u,t[1]=s*h+t[1]*u,t[2]=r*h+t[2]*u,t}},459:(t,e,i)=>{var n=i(687),s=i(229),r="__id";t.exports.ID=r;var o={};function a(t){var e={type:t.type};if(t.type===n.Shape.types.BOX)e.halfExtents=c(t.halfExtents);else if(t.type===n.Shape.types.SPHERE)e.radius=t.radius;else{if(t._type!==n.Shape.types.CYLINDER)throw new Error("Unimplemented shape type: %s",t.type);e.type=n.Shape.types.CYLINDER,e.radiusTop=t.radiusTop,e.radiusBottom=t.radiusBottom,e.height=t.height,e.numSegments=t.numSegments}return e}function l(t){var e;if(t.type===n.Shape.types.BOX)e=new n.Box(h(t.halfExtents));else if(t.type===n.Shape.types.SPHERE)e=new n.Sphere(t.radius);else{if(t.type!==n.Shape.types.CYLINDER)throw new Error("Unimplemented shape type: %s",t.type);(e=new n.Cylinder(t.radiusTop,t.radiusBottom,t.height,t.numSegments))._type=n.Shape.types.CYLINDER}return e}function c(t){return t.toArray()}function h(t){return new n.Vec3(t[0],t[1],t[2])}function u(t){return t.toArray()}function d(t){return new n.Quaternion(t[0],t[1],t[2],t[3])}t.exports.assignID=function(t,e){e[r]||(o[t]=o[t]||1,e[r]=t+"_"+o[t]++)},t.exports.serializeBody=function(t){return{shapes:t.shapes.map(a),shapeOffsets:t.shapeOffsets.map(c),shapeOrientations:t.shapeOrientations.map(u),position:c(t.position),quaternion:t.quaternion.toArray(),velocity:c(t.velocity),angularVelocity:c(t.angularVelocity),id:t[r],mass:t.mass,linearDamping:t.linearDamping,angularDamping:t.angularDamping,fixedRotation:t.fixedRotation,allowSleep:t.allowSleep,sleepSpeedLimit:t.sleepSpeedLimit,sleepTimeLimit:t.sleepTimeLimit}},t.exports.deserializeBodyUpdate=function(t,e){return e.position.set(t.position[0],t.position[1],t.position[2]),e.quaternion.set(t.quaternion[0],t.quaternion[1],t.quaternion[2],t.quaternion[3]),e.velocity.set(t.velocity[0],t.velocity[1],t.velocity[2]),e.angularVelocity.set(t.angularVelocity[0],t.angularVelocity[1],t.angularVelocity[2]),e.linearDamping=t.linearDamping,e.angularDamping=t.angularDamping,e.fixedRotation=t.fixedRotation,e.allowSleep=t.allowSleep,e.sleepSpeedLimit=t.sleepSpeedLimit,e.sleepTimeLimit=t.sleepTimeLimit,e.mass!==t.mass&&(e.mass=t.mass,e.updateMassProperties()),e},t.exports.deserializeInterpBodyUpdate=function(t,e,i,n){var r=1-n,o=n;i.position.set(t.position[0]*r+e.position[0]*o,t.position[1]*r+e.position[1]*o,t.position[2]*r+e.position[2]*o);var a=s.slerp(t.quaternion,e.quaternion,n);return i.quaternion.set(a[0],a[1],a[2],a[3]),i.velocity.set(t.velocity[0]*r+e.velocity[0]*o,t.velocity[1]*r+e.velocity[1]*o,t.velocity[2]*r+e.velocity[2]*o),i.angularVelocity.set(t.angularVelocity[0]*r+e.angularVelocity[0]*o,t.angularVelocity[1]*r+e.angularVelocity[1]*o,t.angularVelocity[2]*r+e.angularVelocity[2]*o),i.linearDamping=e.linearDamping,i.angularDamping=e.angularDamping,i.fixedRotation=e.fixedRotation,i.allowSleep=e.allowSleep,i.sleepSpeedLimit=e.sleepSpeedLimit,i.sleepTimeLimit=e.sleepTimeLimit,i.mass!==e.mass&&(i.mass=e.mass,i.updateMassProperties()),i},t.exports.deserializeBody=function(t){for(var e,i=new n.Body({mass:t.mass,position:h(t.position),quaternion:d(t.quaternion),velocity:h(t.velocity),angularVelocity:h(t.angularVelocity),linearDamping:t.linearDamping,angularDamping:t.angularDamping,fixedRotation:t.fixedRotation,allowSleep:t.allowSleep,sleepSpeedLimit:t.sleepSpeedLimit,sleepTimeLimit:t.sleepTimeLimit}),s=0;e=t.shapes[s];s++)i.addShape(l(e),h(t.shapeOffsets[s]),d(t.shapeOrientations[s]));return i[r]=t.id,i},t.exports.serializeShape=a,t.exports.deserializeShape=l,t.exports.serializeConstraint=function(t){var e={id:t[r],type:t.type,maxForce:t.maxForce,bodyA:t.bodyA[r],bodyB:t.bodyB[r]};switch(t.type){case"LockConstraint":break;case"DistanceConstraint":e.distance=t.distance;break;case"HingeConstraint":case"ConeTwistConstraint":e.axisA=c(t.axisA),e.axisB=c(t.axisB),e.pivotA=c(t.pivotA),e.pivotB=c(t.pivotB);break;case"PointToPointConstraint":e.pivotA=c(t.pivotA),e.pivotB=c(t.pivotB);break;default:throw new Error("Unexpected constraint type: "+t.type+'. You may need to manually set `constraint.type = "FooConstraint";`.')}return e},t.exports.deserializeConstraint=function(t,e){var i,s=n[t.type],o=e[t.bodyA],a=e[t.bodyB];switch(t.type){case"LockConstraint":i=new n.LockConstraint(o,a,t);break;case"DistanceConstraint":i=new n.DistanceConstraint(o,a,t.distance,t.maxForce);break;case"HingeConstraint":case"ConeTwistConstraint":i=new s(o,a,{pivotA:h(t.pivotA),pivotB:h(t.pivotB),axisA:h(t.axisA),axisB:h(t.axisB),maxForce:t.maxForce});break;case"PointToPointConstraint":i=new n.PointToPointConstraint(o,h(t.pivotA),a,h(t.pivotB),t.maxForce);break;default:throw new Error("Unexpected constraint type: "+t.type)}return i[r]=t.id,i},t.exports.serializeContact=function(t){return{bi:t.bi[r],bj:t.bj[r],ni:c(t.ni),ri:c(t.ri),rj:c(t.rj)}},t.exports.deserializeContact=function(t,e){return{bi:e[t.bi],bj:e[t.bj],ni:h(t.ni),ri:h(t.ri),rj:h(t.rj)}},t.exports.serializeVec3=c,t.exports.deserializeVec3=h,t.exports.serializeQuaternion=u,t.exports.deserializeQuaternion=d},264:(t,e,i)=>{var n=i(687),s=i(232),r=function(){var t,e,i,n,r=new s.Vector3;function o(){this.tolerance=-1,this.faces=[],this.newFaces=[],this.assigned=new h,this.unassigned=new h,this.vertices=[]}function a(){this.normal=new s.Vector3,this.midpoint=new s.Vector3,this.area=0,this.constant=0,this.outside=null,this.mark=0,this.edge=null}function l(t,e){this.vertex=t,this.prev=null,this.next=null,this.twin=null,this.face=e}function c(t){this.point=t,this.prev=null,this.next=null,this.face=null}function h(){this.head=null,this.tail=null}return Object.assign(o.prototype,{setFromPoints:function(t){!0!==Array.isArray(t)&&console.error("THREE.ConvexHull: Points parameter is not an array."),t.length<4&&console.error("THREE.ConvexHull: The algorithm needs at least four points."),this.makeEmpty();for(var e=0,i=t.length;ethis.tolerance)return!1;return!0},intersectRay:function(t,e){for(var i=this.faces,n=-1/0,s=1/0,r=0,o=i.length;r0&&c>=0)return null;var h=0!==c?-l/c:0;if(!(h<=0)&&(c>0?s=Math.min(h,s):n=Math.max(h,n),n>s))return null}return n!==-1/0?t.at(n,e):t.at(s,e),e},intersectsRay:function(t){return null!==this.intersectRay(t,r)},makeEmpty:function(){return this.faces=[],this.vertices=[],this},addVertexToFace:function(t,e){return t.face=e,null===e.outside?this.assigned.append(t):this.assigned.insertBefore(e.outside,t),e.outside=t,this},removeVertexFromFace:function(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:function(t){if(null!==t.outside){for(var e=t.outside,i=t.outside;null!==i.next&&i.next.face===t;)i=i.next;return this.assigned.removeSubList(e,i),e.prev=i.next=null,t.outside=null,e}},deleteFaceVertices:function(t,e){var i=this.removeAllVerticesFromFace(t);if(void 0!==i)if(void 0===e)this.unassigned.appendChain(i);else{var n=i;do{var s=n.next;e.distanceToPoint(n.point)>this.tolerance?this.addVertexToFace(n,e):this.unassigned.append(n),n=s}while(null!==n)}return this},resolveUnassignedPoints:function(t){if(!1===this.unassigned.isEmpty()){var e=this.unassigned.first();do{for(var i=e.next,n=this.tolerance,s=null,r=0;rn&&(n=a,s=o),n>1e3*this.tolerance)break}}null!==s&&this.addVertexToFace(e,s),e=i}while(null!==e)}return this},computeExtremes:function(){var t,e,i,n=new s.Vector3,r=new s.Vector3,o=[],a=[];for(t=0;t<3;t++)o[t]=a[t]=this.vertices[0];for(n.copy(this.vertices[0].point),r.copy(this.vertices[0].point),t=0,e=this.vertices.length;tr.getComponent(i)&&(r.setComponent(i,c.getComponent(i)),a[i]=l)}return this.tolerance=3*Number.EPSILON*(Math.max(Math.abs(n.x),Math.abs(r.x))+Math.max(Math.abs(n.y),Math.abs(r.y))+Math.max(Math.abs(n.z),Math.abs(r.z))),{min:o,max:a}},computeInitialHull:function(){void 0===t&&(t=new s.Line3,e=new s.Plane,i=new s.Vector3);var n,r,o,l,c,h,u,d,p,m=this.vertices,f=this.computeExtremes(),g=f.min,y=f.max,v=0,x=0;for(h=0;h<3;h++)(p=y[h].point.getComponent(h)-g[h].point.getComponent(h))>v&&(v=p,x=h);for(r=g[x],o=y[x],v=0,t.set(r.point,o.point),h=0,u=this.vertices.length;hv&&(v=p,l=n));for(v=-1,e.setFromCoplanarPoints(r.point,o.point,l.point),h=0,u=this.vertices.length;hv&&(v=p,c=n);var _=[];if(e.distanceToPoint(c.point)<0)for(_.push(a.create(r,o,l),a.create(c,o,r),a.create(c,l,o),a.create(c,r,l)),h=0;h<3;h++)d=(h+1)%3,_[h+1].getEdge(2).setTwin(_[0].getEdge(d)),_[h+1].getEdge(1).setTwin(_[d+1].getEdge(0));else for(_.push(a.create(r,l,o),a.create(c,r,o),a.create(c,o,l),a.create(c,l,r)),h=0;h<3;h++)d=(h+1)%3,_[h+1].getEdge(2).setTwin(_[0].getEdge((3-h)%3)),_[h+1].getEdge(0).setTwin(_[d+1].getEdge(1));for(h=0;h<4;h++)this.faces.push(_[h]);for(h=0,u=m.length;hv&&(v=p,b=this.faces[d]);null!==b&&this.addVertexToFace(n,b)}return this},reindexFaces:function(){for(var t=[],e=0;ee&&(e=s,t=n),n=n.next}while(null!==n&&n.face===i);return t}},computeHorizon:function(t,e,i,n){var s;this.deleteFaceVertices(i),i.mark=1,s=null===e?e=i.getEdge(0):e.next;do{var r=s.twin,o=r.face;0===o.mark&&(o.distanceToPoint(t)>this.tolerance?this.computeHorizon(t,r,o,n):n.push(s)),s=s.next}while(s!==e);return this},addAdjoiningFace:function(t,e){var i=a.create(t,e.tail(),e.head());return this.faces.push(i),i.getEdge(-1).setTwin(e.twin),i.getEdge(0)},addNewFaces:function(t,e){this.newFaces=[];for(var i=null,n=null,s=0;s0;)e=e.next,t--;for(;t<0;)e=e.prev,t++;return e},compute:function(){void 0===n&&(n=new s.Triangle);var t=this.edge.tail(),e=this.edge.head(),i=this.edge.next.head();return n.set(t.point,e.point,i.point),n.getNormal(this.normal),n.getMidpoint(this.midpoint),this.area=n.getArea(),this.constant=this.normal.dot(this.midpoint),this},distanceToPoint:function(t){return this.normal.dot(t)-this.constant}}),Object.assign(l.prototype,{head:function(){return this.vertex},tail:function(){return this.prev?this.prev.vertex:null},length:function(){var t=this.head(),e=this.tail();return null!==e?e.point.distanceTo(t.point):-1},lengthSquared:function(){var t=this.head(),e=this.tail();return null!==e?e.point.distanceToSquared(t.point):-1},setTwin:function(t){return this.twin=t,t.twin=this,this}}),Object.assign(h.prototype,{first:function(){return this.head},last:function(){return this.tail},clear:function(){return this.head=this.tail=null,this},insertBefore:function(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:function(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:function(t){return null===this.head?this.head=t:this.tail.next=t,t.prev=this.tail,t.next=null,this.tail=t,this},appendChain:function(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:function(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:function(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:function(){return null===this.head}}),o}();const o=new s.Vector3,a=new s.Vector3,l=new s.Quaternion;function c(t){const e=function(t){const e=[];return t.traverse((function(t){t.isMesh&&e.push(t)})),e}(t);if(0===e.length)return null;if(1===e.length)return h(e[0]);let i;const n=[];for(;i=e.pop();)n.push(p(h(i)));return function(t){let e=0;for(let i=0;i{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const i="145",n=100,s=300,r=301,o=302,a=303,l=304,c=306,h=1e3,u=1001,d=1002,p=1003,m=1004,f=1005,g=1006,y=1007,v=1008,x=1009,_=1012,b=1014,w=1015,M=1016,S=1020,E=1023,T=1026,A=1027,C=33776,R=33777,L=33778,P=33779,I=35840,D=35841,N=35842,B=35843,F=37492,O=37496,z=37808,U=37809,H=37810,V=37811,k=37812,G=37813,W=37814,q=37815,j=37816,X=37817,Y=37818,Z=37819,J=37820,K=37821,Q=36492,$=2300,tt=2301,et=2302,it=2400,nt=2401,st=2402,rt=2501,ot=3e3,at=3001,lt="srgb",ct="srgb-linear",ht=7680,ut=35044,dt="300 es",pt=1035;class mt{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const i=this._listeners;return void 0!==i[t]&&-1!==i[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const i=this._listeners[t];if(void 0!==i){const t=i.indexOf(e);-1!==t&&i.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 i=e.slice(0);for(let e=0,n=i.length;e>8&255]+ft[t>>16&255]+ft[t>>24&255]+"-"+ft[255&e]+ft[e>>8&255]+"-"+ft[e>>16&15|64]+ft[e>>24&255]+"-"+ft[63&i|128]+ft[i>>8&255]+"-"+ft[i>>16&255]+ft[i>>24&255]+ft[255&n]+ft[n>>8&255]+ft[n>>16&255]+ft[n>>24&255]).toLowerCase()}function _t(t,e,i){return Math.max(e,Math.min(i,t))}function bt(t,e){return(t%e+e)%e}function wt(t,e,i){return(1-i)*t+i*e}function Mt(t){return 0==(t&t-1)&&0!==t}function St(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function Et(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function Tt(t,e){switch(e.constructor){case Float32Array:return t;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function At(t,e){switch(e.constructor){case Float32Array:return t;case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}var Ct=Object.freeze({__proto__:null,DEG2RAD:yt,RAD2DEG:vt,generateUUID:xt,clamp:_t,euclideanModulo:bt,mapLinear:function(t,e,i,n,s){return n+(t-e)*(s-n)/(i-e)},inverseLerp:function(t,e,i){return t!==e?(i-t)/(e-t):0},lerp:wt,damp:function(t,e,i,n){return wt(t,e,1-Math.exp(-i*n))},pingpong:function(t,e=1){return e-Math.abs(bt(t,2*e)-e)},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(gt=t);let e=gt+=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*yt},radToDeg:function(t){return t*vt},isPowerOfTwo:Mt,ceilPowerOfTwo:St,floorPowerOfTwo:Et,setQuaternionFromProperEuler:function(t,e,i,n,s){const r=Math.cos,o=Math.sin,a=r(i/2),l=o(i/2),c=r((e+n)/2),h=o((e+n)/2),u=r((e-n)/2),d=o((e-n)/2),p=r((n-e)/2),m=o((n-e)/2);switch(s){case"XYX":t.set(a*h,l*u,l*d,a*c);break;case"YZY":t.set(l*d,a*h,l*u,a*c);break;case"ZXZ":t.set(l*u,l*d,a*h,a*c);break;case"XZX":t.set(a*h,l*m,l*p,a*c);break;case"YXY":t.set(l*p,a*h,l*m,a*c);break;case"ZYZ":t.set(l*m,l*p,a*h,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}},normalize:At,denormalize:Tt});class Rt{constructor(t=0,e=0){Rt.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,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[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=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){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}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,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 i=Math.cos(e),n=Math.sin(e),s=this.x-t.x,r=this.y-t.y;return this.x=s*i-r*n+t.x,this.y=s*n+r*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Lt{constructor(){Lt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(t,e,i,n,s,r,o,a,l){const c=this.elements;return c[0]=t,c[1]=n,c[2]=o,c[3]=e,c[4]=s,c[5]=a,c[6]=i,c[7]=r,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.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 i=t.elements,n=e.elements,s=this.elements,r=i[0],o=i[3],a=i[6],l=i[1],c=i[4],h=i[7],u=i[2],d=i[5],p=i[8],m=n[0],f=n[3],g=n[6],y=n[1],v=n[4],x=n[7],_=n[2],b=n[5],w=n[8];return s[0]=r*m+o*y+a*_,s[3]=r*f+o*v+a*b,s[6]=r*g+o*x+a*w,s[1]=l*m+c*y+h*_,s[4]=l*f+c*v+h*b,s[7]=l*g+c*x+h*w,s[2]=u*m+d*y+p*_,s[5]=u*f+d*v+p*b,s[8]=u*g+d*x+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],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],l=t[7],c=t[8];return e*r*c-e*o*l-i*s*c+i*o*a+n*s*l-n*r*a}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],l=t[7],c=t[8],h=c*r-o*l,u=o*a-c*s,d=l*s-r*a,p=e*h+i*u+n*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=h*m,t[1]=(n*l-c*i)*m,t[2]=(o*i-n*r)*m,t[3]=u*m,t[4]=(c*e-n*a)*m,t[5]=(n*s-o*e)*m,t[6]=d*m,t[7]=(i*a-l*e)*m,t[8]=(r*e-i*s)*m,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,i,n,s,r,o){const a=Math.cos(s),l=Math.sin(s);return this.set(i*a,i*l,-i*(a*r+l*o)+r+t,-n*l,n*a,-n*(-l*r+a*o)+o+e,0,0,1),this}scale(t,e){const i=this.elements;return i[0]*=t,i[3]*=t,i[6]*=t,i[1]*=e,i[4]*=e,i[7]*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),n=this.elements,s=n[0],r=n[3],o=n[6],a=n[1],l=n[4],c=n[7];return n[0]=e*s+i*a,n[3]=e*r+i*l,n[6]=e*o+i*c,n[1]=-i*s+e*a,n[4]=-i*r+e*l,n[7]=-i*o+e*c,this}translate(t,e){const i=this.elements;return i[0]+=t*i[2],i[3]+=t*i[5],i[6]+=t*i[8],i[1]+=e*i[2],i[4]+=e*i[5],i[7]+=e*i[8],this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<9;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}function Pt(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}const It={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Dt(t,e){return new It[t](e)}function Nt(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Bt(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Ft(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}const Ot={[lt]:{[ct]:Bt},[ct]:{[lt]:Ft}},zt={legacyMode:!0,get workingColorSpace(){return ct},set workingColorSpace(t){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(t,e,i){if(this.legacyMode||e===i||!e||!i)return t;if(Ot[e]&&void 0!==Ot[e][i]){const n=Ot[e][i];return t.r=n(t.r),t.g=n(t.g),t.b=n(t.b),t}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this.workingColorSpace)}},Ut={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},Ht={r:0,g:0,b:0},Vt={h:0,s:0,l:0},kt={h:0,s:0,l:0};function Gt(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}function Wt(t,e){return e.r=t.r,e.g=t.g,e.b=t.b,e}class qt{constructor(t,e,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,void 0===e&&void 0===i?this.set(t):this.setRGB(t,e,i)}set(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=lt){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,zt.toWorkingColorSpace(this,e),this}setRGB(t,e,i,n=ct){return this.r=t,this.g=e,this.b=i,zt.toWorkingColorSpace(this,n),this}setHSL(t,e,i,n=ct){if(t=bt(t,1),e=_t(e,0,1),i=_t(i,0,1),0===e)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+e):i+e-i*e,s=2*i-n;this.r=Gt(s,n,t+1/3),this.g=Gt(s,n,t),this.b=Gt(s,n,t-1/3)}return zt.toWorkingColorSpace(this,n),this}setStyle(t,e=lt){function i(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let t;const s=n[1],r=n[2];switch(s){case"rgb":case"rgba":if(t=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(255,parseInt(t[1],10))/255,this.g=Math.min(255,parseInt(t[2],10))/255,this.b=Math.min(255,parseInt(t[3],10))/255,zt.toWorkingColorSpace(this,e),i(t[4]),this;if(t=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(100,parseInt(t[1],10))/100,this.g=Math.min(100,parseInt(t[2],10))/100,this.b=Math.min(100,parseInt(t[3],10))/100,zt.toWorkingColorSpace(this,e),i(t[4]),this;break;case"hsl":case"hsla":if(t=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r)){const n=parseFloat(t[1])/360,s=parseFloat(t[2])/100,r=parseFloat(t[3])/100;return i(t[4]),this.setHSL(n,s,r,e)}}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const t=n[1],i=t.length;if(3===i)return this.r=parseInt(t.charAt(0)+t.charAt(0),16)/255,this.g=parseInt(t.charAt(1)+t.charAt(1),16)/255,this.b=parseInt(t.charAt(2)+t.charAt(2),16)/255,zt.toWorkingColorSpace(this,e),this;if(6===i)return this.r=parseInt(t.charAt(0)+t.charAt(1),16)/255,this.g=parseInt(t.charAt(2)+t.charAt(3),16)/255,this.b=parseInt(t.charAt(4)+t.charAt(5),16)/255,zt.toWorkingColorSpace(this,e),this}return t&&t.length>0?this.setColorName(t,e):this}setColorName(t,e=lt){const i=Ut[t.toLowerCase()];return void 0!==i?this.setHex(i,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=Bt(t.r),this.g=Bt(t.g),this.b=Bt(t.b),this}copyLinearToSRGB(t){return this.r=Ft(t.r),this.g=Ft(t.g),this.b=Ft(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=lt){return zt.fromWorkingColorSpace(Wt(this,Ht),t),_t(255*Ht.r,0,255)<<16^_t(255*Ht.g,0,255)<<8^_t(255*Ht.b,0,255)<<0}getHexString(t=lt){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=ct){zt.fromWorkingColorSpace(Wt(this,Ht),e);const i=Ht.r,n=Ht.g,s=Ht.b,r=Math.max(i,n,s),o=Math.min(i,n,s);let a,l;const c=(o+r)/2;if(o===r)a=0,l=0;else{const t=r-o;switch(l=c<=.5?t/(r+o):t/(2-r-o),r){case i:a=(n-s)/t+(n2048||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=Nt("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const n=i.getImageData(0,0,t.width,t.height),s=n.data;for(let t=0;t1)switch(this.wrapS){case h:t.x=t.x-Math.floor(t.x);break;case u:t.x=t.x<0?0:1;break;case d: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 h:t.y=t.y-Math.floor(t.y);break;case u:t.y=t.y<0?0:1;break;case d: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)}}Kt.DEFAULT_IMAGE=null,Kt.DEFAULT_MAPPING=s;class Qt{constructor(t=0,e=0,i=0,n=1){Qt.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=n}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,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,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,i=this.y,n=this.z,s=this.w,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n+r[12]*s,this.y=r[1]*e+r[5]*i+r[9]*n+r[13]*s,this.z=r[2]*e+r[6]*i+r[10]*n+r[14]*s,this.w=r[3]*e+r[7]*i+r[11]*n+r[15]*s,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,i,n,s;const r=.01,o=.1,a=t.elements,l=a[0],c=a[4],h=a[8],u=a[1],d=a[5],p=a[9],m=a[2],f=a[6],g=a[10];if(Math.abs(c-u)a&&t>y?ty?a=0?1:-1,n=1-e*e;if(n>Number.EPSILON){const s=Math.sqrt(n),r=Math.atan2(s,e*i);t=Math.sin(t*r)/s,o=Math.sin(o*r)/s}const s=o*i;if(a=a*t+u*s,l=l*t+d*s,c=c*t+p*s,h=h*t+m*s,t===1-o){const t=1/Math.sqrt(a*a+l*l+c*c+h*h);a*=t,l*=t,c*=t,h*=t}}t[e]=a,t[e+1]=l,t[e+2]=c,t[e+3]=h}static multiplyQuaternionsFlat(t,e,i,n,s,r){const o=i[n],a=i[n+1],l=i[n+2],c=i[n+3],h=s[r],u=s[r+1],d=s[r+2],p=s[r+3];return t[e]=o*p+c*h+a*d-l*u,t[e+1]=a*p+c*u+l*h-o*d,t[e+2]=l*p+c*d+o*u-a*h,t[e+3]=c*p-o*h-a*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,i,n){return this._x=t,this._y=e,this._z=i,this._w=n,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){const i=t._x,n=t._y,s=t._z,r=t._order,o=Math.cos,a=Math.sin,l=o(i/2),c=o(n/2),h=o(s/2),u=a(i/2),d=a(n/2),p=a(s/2);switch(r){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: "+r)}return!1!==e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],n=e[4],s=e[8],r=e[1],o=e[5],a=e[9],l=e[2],c=e[6],h=e[10],u=i+o+h;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(c-a)*t,this._y=(s-l)*t,this._z=(r-n)*t}else if(i>o&&i>h){const t=2*Math.sqrt(1+i-o-h);this._w=(c-a)/t,this._x=.25*t,this._y=(n+r)/t,this._z=(s+l)/t}else if(o>h){const t=2*Math.sqrt(1+o-i-h);this._w=(s-l)/t,this._x=(n+r)/t,this._y=.25*t,this._z=(a+c)/t}else{const t=2*Math.sqrt(1+h-i-o);this._w=(r-n)/t,this._x=(s+l)/t,this._y=(a+c)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return iMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(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=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(_t(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(0===i)return this;const n=Math.min(1,e/i);return this.slerp(t,n),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 i=t._x,n=t._y,s=t._z,r=t._w,o=e._x,a=e._y,l=e._z,c=e._w;return this._x=i*c+r*o+n*l-s*a,this._y=n*c+r*a+s*o-i*l,this._z=s*c+r*l+i*a-n*o,this._w=r*c-i*o-n*a-s*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const i=this._x,n=this._y,s=this._z,r=this._w;let o=r*t._w+i*t._x+n*t._y+s*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=r,this._x=i,this._y=n,this._z=s,this;const a=1-o*o;if(a<=Number.EPSILON){const t=1-e;return this._w=t*r+e*this._w,this._x=t*i+e*this._x,this._y=t*n+e*this._y,this._z=t*s+e*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(a),c=Math.atan2(l,o),h=Math.sin((1-e)*c)/l,u=Math.sin(e*c)/l;return this._w=r*h+this._w*u,this._x=i*h+this._x*u,this._y=n*h+this._y*u,this._z=s*h+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=Math.random(),e=Math.sqrt(1-t),i=Math.sqrt(t),n=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(e*Math.cos(n),i*Math.sin(s),i*Math.cos(s),e*Math.sin(n))}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}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class ne{constructor(t=0,e=0,i=0){ne.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return void 0===i&&(i=this.z),this.x=t,this.y=e,this.z=i,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(re.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(re.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,n=this.z,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6]*n,this.y=s[1]*e+s[4]*i+s[7]*n,this.z=s[2]*e+s[5]*i+s[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,s=t.elements,r=1/(s[3]*e+s[7]*i+s[11]*n+s[15]);return this.x=(s[0]*e+s[4]*i+s[8]*n+s[12])*r,this.y=(s[1]*e+s[5]*i+s[9]*n+s[13])*r,this.z=(s[2]*e+s[6]*i+s[10]*n+s[14])*r,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z,a=t.w,l=a*e+r*n-o*i,c=a*i+o*e-s*n,h=a*n+s*i-r*e,u=-s*e-r*i-o*n;return this.x=l*a+u*-s+c*-o-h*-r,this.y=c*a+u*-r+h*-s-l*-o,this.z=h*a+u*-o+l*-r-c*-s,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,i=this.y,n=this.z,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*n,this.y=s[1]*e+s[5]*i+s[9]*n,this.z=s[2]*e+s[6]*i+s[10]*n,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=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,n=t.y,s=t.z,r=e.x,o=e.y,a=e.z;return this.x=n*a-s*o,this.y=s*r-i*a,this.z=i*o-n*r,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return se.copy(this).projectOnVector(t),this.sub(se)}reflect(t){return this.sub(se.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 i=this.dot(t)/e;return Math.acos(_t(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}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,i){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,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(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,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}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=2*(Math.random()-.5),e=Math.random()*Math.PI*2,i=Math.sqrt(1-t**2);return this.x=i*Math.cos(e),this.y=i*Math.sin(e),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const se=new ne,re=new ie;class oe{constructor(t=new ne(1/0,1/0,1/0),e=new ne(-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){let e=1/0,i=1/0,n=1/0,s=-1/0,r=-1/0,o=-1/0;for(let a=0,l=t.length;as&&(s=l),c>r&&(r=c),h>o&&(o=h)}return this.min.set(e,i,n),this.max.set(s,r,o),this}setFromBufferAttribute(t){let e=1/0,i=1/0,n=1/0,s=-1/0,r=-1/0,o=-1/0;for(let a=0,l=t.count;as&&(s=l),c>r&&(r=c),h>o&&(o=h)}return this.min.set(e,i,n),this.max.set(s,r,o),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;ethis.max.x||t.ythis.max.y||t.zthis.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.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,le),le.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(ge),ye.subVectors(this.max,ge),he.subVectors(t.a,ge),ue.subVectors(t.b,ge),de.subVectors(t.c,ge),pe.subVectors(ue,he),me.subVectors(de,ue),fe.subVectors(he,de);let e=[0,-pe.z,pe.y,0,-me.z,me.y,0,-fe.z,fe.y,pe.z,0,-pe.x,me.z,0,-me.x,fe.z,0,-fe.x,-pe.y,pe.x,0,-me.y,me.x,0,-fe.y,fe.x,0];return!!_e(e,he,ue,de,ye)&&(e=[1,0,0,0,1,0,0,0,1],!!_e(e,he,ue,de,ye)&&(ve.crossVectors(pe,me),e=[ve.x,ve.y,ve.z],_e(e,he,ue,de,ye)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return le.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return this.getCenter(t.center),t.radius=.5*this.getSize(le).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()||(ae[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ae[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ae[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ae[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ae[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ae[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ae[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ae[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ae)),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 ae=[new ne,new ne,new ne,new ne,new ne,new ne,new ne,new ne],le=new ne,ce=new oe,he=new ne,ue=new ne,de=new ne,pe=new ne,me=new ne,fe=new ne,ge=new ne,ye=new ne,ve=new ne,xe=new ne;function _e(t,e,i,n,s){for(let r=0,o=t.length-3;r<=o;r+=3){xe.fromArray(t,r);const o=s.x*Math.abs(xe.x)+s.y*Math.abs(xe.y)+s.z*Math.abs(xe.z),a=e.dot(xe),l=i.dot(xe),c=n.dot(xe);if(Math.max(-Math.max(a,l,c),Math.min(a,l,c))>o)return!1}return!0}const be=new oe,we=new ne,Me=new ne,Se=new ne;class Ee{constructor(t=new ne,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const i=this.center;void 0!==e?i.copy(e):be.setFromPoints(t).getCenter(i);let n=0;for(let e=0,s=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;Se.subVectors(t,this.center);const e=Se.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),i=.5*(t-this.radius);this.center.add(Se.multiplyScalar(i/t)),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?Me.set(0,0,1).multiplyScalar(t.radius):Me.subVectors(t.center,this.center).normalize().multiplyScalar(t.radius),this.expandByPoint(we.copy(t.center).add(Me)),this.expandByPoint(we.copy(t.center).sub(Me)),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Te=new ne,Ae=new ne,Ce=new ne,Re=new ne,Le=new ne,Pe=new ne,Ie=new ne;class De{constructor(t=new ne,e=new ne(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.direction).multiplyScalar(t).add(this.origin)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Te)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(i).add(this.origin)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Te.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Te.copy(this.direction).multiplyScalar(e).add(this.origin),Te.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){Ae.copy(t).add(e).multiplyScalar(.5),Ce.copy(e).sub(t).normalize(),Re.copy(this.origin).sub(Ae);const s=.5*t.distanceTo(e),r=-this.direction.dot(Ce),o=Re.dot(this.direction),a=-Re.dot(Ce),l=Re.lengthSq(),c=Math.abs(1-r*r);let h,u,d,p;if(c>0)if(h=r*a-o,u=r*o-a,p=s*c,h>=0)if(u>=-p)if(u<=p){const t=1/c;h*=t,u*=t,d=h*(h+r*u+2*o)+u*(r*h+u+2*a)+l}else u=s,h=Math.max(0,-(r*u+o)),d=-h*h+u*(u+2*a)+l;else u=-s,h=Math.max(0,-(r*u+o)),d=-h*h+u*(u+2*a)+l;else u<=-p?(h=Math.max(0,-(-r*s+o)),u=h>0?-s:Math.min(Math.max(-s,-a),s),d=-h*h+u*(u+2*a)+l):u<=p?(h=0,u=Math.min(Math.max(-s,-a),s),d=u*(u+2*a)+l):(h=Math.max(0,-(r*s+o)),u=h>0?s:Math.min(Math.max(-s,-a),s),d=-h*h+u*(u+2*a)+l);else u=r>0?-s:s,h=Math.max(0,-(r*u+o)),d=-h*h+u*(u+2*a)+l;return i&&i.copy(this.direction).multiplyScalar(h).add(this.origin),n&&n.copy(Ce).multiplyScalar(u).add(Ae),d}intersectSphere(t,e){Te.subVectors(t.center,this.origin);const i=Te.dot(this.direction),n=Te.dot(Te)-i*i,s=t.radius*t.radius;if(n>s)return null;const r=Math.sqrt(s-n),o=i-r,a=i+r;return o<0&&a<0?null:o<0?this.at(a,e):this.at(o,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 i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return null===i?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,n,s,r,o,a;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,u=this.origin;return l>=0?(i=(t.min.x-u.x)*l,n=(t.max.x-u.x)*l):(i=(t.max.x-u.x)*l,n=(t.min.x-u.x)*l),c>=0?(s=(t.min.y-u.y)*c,r=(t.max.y-u.y)*c):(s=(t.max.y-u.y)*c,r=(t.min.y-u.y)*c),i>r||s>n?null:((s>i||i!=i)&&(i=s),(r=0?(o=(t.min.z-u.z)*h,a=(t.max.z-u.z)*h):(o=(t.max.z-u.z)*h,a=(t.min.z-u.z)*h),i>a||o>n?null:((o>i||i!=i)&&(i=o),(a=0?i:n,e)))}intersectsBox(t){return null!==this.intersectBox(t,Te)}intersectTriangle(t,e,i,n,s){Le.subVectors(e,t),Pe.subVectors(i,t),Ie.crossVectors(Le,Pe);let r,o=this.direction.dot(Ie);if(o>0){if(n)return null;r=1}else{if(!(o<0))return null;r=-1,o=-o}Re.subVectors(this.origin,t);const a=r*this.direction.dot(Pe.crossVectors(Re,Pe));if(a<0)return null;const l=r*this.direction.dot(Le.cross(Re));if(l<0)return null;if(a+l>o)return null;const c=-r*Re.dot(Ie);return c<0?null:this.at(c/o,s)}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 Ne{constructor(){Ne.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(t,e,i,n,s,r,o,a,l,c,h,u,d,p,m,f){const g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=n,g[1]=s,g[5]=r,g[9]=o,g[13]=a,g[2]=l,g[6]=c,g[10]=h,g[14]=u,g[3]=d,g[7]=p,g[11]=m,g[15]=f,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 Ne).fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[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,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,n=1/Be.setFromMatrixColumn(t,0).length(),s=1/Be.setFromMatrixColumn(t,1).length(),r=1/Be.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*s,e[5]=i[5]*s,e[6]=i[6]*s,e[7]=0,e[8]=i[8]*r,e[9]=i[9]*r,e[10]=i[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,n=t.y,s=t.z,r=Math.cos(i),o=Math.sin(i),a=Math.cos(n),l=Math.sin(n),c=Math.cos(s),h=Math.sin(s);if("XYZ"===t.order){const t=r*c,i=r*h,n=o*c,s=o*h;e[0]=a*c,e[4]=-a*h,e[8]=l,e[1]=i+n*l,e[5]=t-s*l,e[9]=-o*a,e[2]=s-t*l,e[6]=n+i*l,e[10]=r*a}else if("YXZ"===t.order){const t=a*c,i=a*h,n=l*c,s=l*h;e[0]=t+s*o,e[4]=n*o-i,e[8]=r*l,e[1]=r*h,e[5]=r*c,e[9]=-o,e[2]=i*o-n,e[6]=s+t*o,e[10]=r*a}else if("ZXY"===t.order){const t=a*c,i=a*h,n=l*c,s=l*h;e[0]=t-s*o,e[4]=-r*h,e[8]=n+i*o,e[1]=i+n*o,e[5]=r*c,e[9]=s-t*o,e[2]=-r*l,e[6]=o,e[10]=r*a}else if("ZYX"===t.order){const t=r*c,i=r*h,n=o*c,s=o*h;e[0]=a*c,e[4]=n*l-i,e[8]=t*l+s,e[1]=a*h,e[5]=s*l+t,e[9]=i*l-n,e[2]=-l,e[6]=o*a,e[10]=r*a}else if("YZX"===t.order){const t=r*a,i=r*l,n=o*a,s=o*l;e[0]=a*c,e[4]=s-t*h,e[8]=n*h+i,e[1]=h,e[5]=r*c,e[9]=-o*c,e[2]=-l*c,e[6]=i*h+n,e[10]=t-s*h}else if("XZY"===t.order){const t=r*a,i=r*l,n=o*a,s=o*l;e[0]=a*c,e[4]=-h,e[8]=l*c,e[1]=t*h+s,e[5]=r*c,e[9]=i*h-n,e[2]=n*h-i,e[6]=o*c,e[10]=s*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(Oe,t,ze)}lookAt(t,e,i){const n=this.elements;return Ve.subVectors(t,e),0===Ve.lengthSq()&&(Ve.z=1),Ve.normalize(),Ue.crossVectors(i,Ve),0===Ue.lengthSq()&&(1===Math.abs(i.z)?Ve.x+=1e-4:Ve.z+=1e-4,Ve.normalize(),Ue.crossVectors(i,Ve)),Ue.normalize(),He.crossVectors(Ve,Ue),n[0]=Ue.x,n[4]=He.x,n[8]=Ve.x,n[1]=Ue.y,n[5]=He.y,n[9]=Ve.y,n[2]=Ue.z,n[6]=He.z,n[10]=Ve.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,s=this.elements,r=i[0],o=i[4],a=i[8],l=i[12],c=i[1],h=i[5],u=i[9],d=i[13],p=i[2],m=i[6],f=i[10],g=i[14],y=i[3],v=i[7],x=i[11],_=i[15],b=n[0],w=n[4],M=n[8],S=n[12],E=n[1],T=n[5],A=n[9],C=n[13],R=n[2],L=n[6],P=n[10],I=n[14],D=n[3],N=n[7],B=n[11],F=n[15];return s[0]=r*b+o*E+a*R+l*D,s[4]=r*w+o*T+a*L+l*N,s[8]=r*M+o*A+a*P+l*B,s[12]=r*S+o*C+a*I+l*F,s[1]=c*b+h*E+u*R+d*D,s[5]=c*w+h*T+u*L+d*N,s[9]=c*M+h*A+u*P+d*B,s[13]=c*S+h*C+u*I+d*F,s[2]=p*b+m*E+f*R+g*D,s[6]=p*w+m*T+f*L+g*N,s[10]=p*M+m*A+f*P+g*B,s[14]=p*S+m*C+f*I+g*F,s[3]=y*b+v*E+x*R+_*D,s[7]=y*w+v*T+x*L+_*N,s[11]=y*M+v*A+x*P+_*B,s[15]=y*S+v*C+x*I+_*F,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],i=t[4],n=t[8],s=t[12],r=t[1],o=t[5],a=t[9],l=t[13],c=t[2],h=t[6],u=t[10],d=t[14];return t[3]*(+s*a*h-n*l*h-s*o*u+i*l*u+n*o*d-i*a*d)+t[7]*(+e*a*d-e*l*u+s*r*u-n*r*d+n*l*c-s*a*c)+t[11]*(+e*l*h-e*o*d-s*r*h+i*r*d+s*o*c-i*l*c)+t[15]*(-n*o*c-e*a*h+e*o*u+n*r*h-i*r*u+i*a*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,i){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],l=t[7],c=t[8],h=t[9],u=t[10],d=t[11],p=t[12],m=t[13],f=t[14],g=t[15],y=h*f*l-m*u*l+m*a*d-o*f*d-h*a*g+o*u*g,v=p*u*l-c*f*l-p*a*d+r*f*d+c*a*g-r*u*g,x=c*m*l-p*h*l+p*o*d-r*m*d-c*o*g+r*h*g,_=p*h*a-c*m*a-p*o*u+r*m*u+c*o*f-r*h*f,b=e*y+i*v+n*x+s*_;if(0===b)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/b;return t[0]=y*w,t[1]=(m*u*s-h*f*s-m*n*d+i*f*d+h*n*g-i*u*g)*w,t[2]=(o*f*s-m*a*s+m*n*l-i*f*l-o*n*g+i*a*g)*w,t[3]=(h*a*s-o*u*s-h*n*l+i*u*l+o*n*d-i*a*d)*w,t[4]=v*w,t[5]=(c*f*s-p*u*s+p*n*d-e*f*d-c*n*g+e*u*g)*w,t[6]=(p*a*s-r*f*s-p*n*l+e*f*l+r*n*g-e*a*g)*w,t[7]=(r*u*s-c*a*s+c*n*l-e*u*l-r*n*d+e*a*d)*w,t[8]=x*w,t[9]=(p*h*s-c*m*s-p*i*d+e*m*d+c*i*g-e*h*g)*w,t[10]=(r*m*s-p*o*s+p*i*l-e*m*l-r*i*g+e*o*g)*w,t[11]=(c*o*s-r*h*s-c*i*l+e*h*l+r*i*d-e*o*d)*w,t[12]=_*w,t[13]=(c*m*n-p*h*n+p*i*u-e*m*u-c*i*f+e*h*f)*w,t[14]=(p*o*n-r*m*n-p*i*a+e*m*a+r*i*f-e*o*f)*w,t[15]=(r*h*n-c*o*n+c*i*a-e*h*a-r*i*u+e*o*u)*w,this}scale(t){const e=this.elements,i=t.x,n=t.y,s=t.z;return e[0]*=i,e[4]*=n,e[8]*=s,e[1]*=i,e[5]*=n,e[9]*=s,e[2]*=i,e[6]*=n,e[10]*=s,e[3]*=i,e[7]*=n,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,n))}makeTranslation(t,e,i){return this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),n=Math.sin(e),s=1-i,r=t.x,o=t.y,a=t.z,l=s*r,c=s*o;return this.set(l*r+i,l*o-n*a,l*a+n*o,0,l*o+n*a,c*o+i,c*a-n*r,0,l*a-n*o,c*a+n*r,s*a*a+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,n,s,r){return this.set(1,i,s,0,t,1,r,0,e,n,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,s=e._x,r=e._y,o=e._z,a=e._w,l=s+s,c=r+r,h=o+o,u=s*l,d=s*c,p=s*h,m=r*c,f=r*h,g=o*h,y=a*l,v=a*c,x=a*h,_=i.x,b=i.y,w=i.z;return n[0]=(1-(m+g))*_,n[1]=(d+x)*_,n[2]=(p-v)*_,n[3]=0,n[4]=(d-x)*b,n[5]=(1-(u+g))*b,n[6]=(f+y)*b,n[7]=0,n[8]=(p+v)*w,n[9]=(f-y)*w,n[10]=(1-(u+m))*w,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,i){const n=this.elements;let s=Be.set(n[0],n[1],n[2]).length();const r=Be.set(n[4],n[5],n[6]).length(),o=Be.set(n[8],n[9],n[10]).length();this.determinant()<0&&(s=-s),t.x=n[12],t.y=n[13],t.z=n[14],Fe.copy(this);const a=1/s,l=1/r,c=1/o;return Fe.elements[0]*=a,Fe.elements[1]*=a,Fe.elements[2]*=a,Fe.elements[4]*=l,Fe.elements[5]*=l,Fe.elements[6]*=l,Fe.elements[8]*=c,Fe.elements[9]*=c,Fe.elements[10]*=c,e.setFromRotationMatrix(Fe),i.x=s,i.y=r,i.z=o,this}makePerspective(t,e,i,n,s,r){const o=this.elements,a=2*s/(e-t),l=2*s/(i-n),c=(e+t)/(e-t),h=(i+n)/(i-n),u=-(r+s)/(r-s),d=-2*r*s/(r-s);return o[0]=a,o[4]=0,o[8]=c,o[12]=0,o[1]=0,o[5]=l,o[9]=h,o[13]=0,o[2]=0,o[6]=0,o[10]=u,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,i,n,s,r){const o=this.elements,a=1/(e-t),l=1/(i-n),c=1/(r-s),h=(e+t)*a,u=(i+n)*l,d=(r+s)*c;return o[0]=2*a,o[4]=0,o[8]=0,o[12]=-h,o[1]=0,o[5]=2*l,o[9]=0,o[13]=-u,o[2]=0,o[6]=0,o[10]=-2*c,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<16;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const Be=new ne,Fe=new Ne,Oe=new ne(0,0,0),ze=new ne(1,1,1),Ue=new ne,He=new ne,Ve=new ne,ke=new Ne,Ge=new ie;class We{constructor(t=0,e=0,i=0,n=We.DefaultOrder){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=n}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,i,n=this._order){return this._x=t,this._y=e,this._z=i,this._order=n,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,i=!0){const n=t.elements,s=n[0],r=n[4],o=n[8],a=n[1],l=n[5],c=n[9],h=n[2],u=n[6],d=n[10];switch(e){case"XYZ":this._y=Math.asin(_t(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-r,s)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-_t(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(a,l)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(_t(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-r,l)):(this._y=0,this._z=Math.atan2(a,s));break;case"ZYX":this._y=Math.asin(-_t(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(a,s)):(this._x=0,this._z=Math.atan2(-r,l));break;case"YZX":this._z=Math.asin(_t(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-_t(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(o,s)):(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===i&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return ke.makeRotationFromQuaternion(t),this.setFromRotationMatrix(ke,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Ge.setFromEuler(this),this.setFromQuaternion(Ge,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}toVector3(){console.error("THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead")}}We.DefaultOrder="XYZ",We.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class qe{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){n.children=[];for(let e=0;e0){n.animations=[];for(let e=0;e0&&(i.geometries=e),n.length>0&&(i.materials=n),s.length>0&&(i.textures=s),o.length>0&&(i.images=o),a.length>0&&(i.shapes=a),l.length>0&&(i.skeletons=l),c.length>0&&(i.animations=c),h.length>0&&(i.nodes=h)}return i.object=n,i;function r(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}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.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e0?n.multiplyScalar(1/Math.sqrt(s)):n.set(0,0,0)}static getBarycoord(t,e,i,n,s){oi.subVectors(n,e),ai.subVectors(i,e),li.subVectors(t,e);const r=oi.dot(oi),o=oi.dot(ai),a=oi.dot(li),l=ai.dot(ai),c=ai.dot(li),h=r*l-o*o;if(0===h)return s.set(-2,-1,-1);const u=1/h,d=(l*a-o*c)*u,p=(r*c-o*a)*u;return s.set(1-d-p,p,d)}static containsPoint(t,e,i,n){return this.getBarycoord(t,e,i,n,ci),ci.x>=0&&ci.y>=0&&ci.x+ci.y<=1}static getUV(t,e,i,n,s,r,o,a){return this.getBarycoord(t,e,i,n,ci),a.set(0,0),a.addScaledVector(s,ci.x),a.addScaledVector(r,ci.y),a.addScaledVector(o,ci.z),a}static isFrontFacing(t,e,i,n){return oi.subVectors(i,e),ai.subVectors(t,e),oi.cross(ai).dot(n)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,n){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[n]),this}setFromAttributeAndIndices(t,e,i,n){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,n),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 oi.subVectors(this.c,this.b),ai.subVectors(this.a,this.b),.5*oi.cross(ai).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return gi.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return gi.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,i,n,s){return gi.getUV(t,this.a,this.b,this.c,e,i,n,s)}containsPoint(t){return gi.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return gi.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const i=this.a,n=this.b,s=this.c;let r,o;hi.subVectors(n,i),ui.subVectors(s,i),pi.subVectors(t,i);const a=hi.dot(pi),l=ui.dot(pi);if(a<=0&&l<=0)return e.copy(i);mi.subVectors(t,n);const c=hi.dot(mi),h=ui.dot(mi);if(c>=0&&h<=c)return e.copy(n);const u=a*h-c*l;if(u<=0&&a>=0&&c<=0)return r=a/(a-c),e.copy(i).addScaledVector(hi,r);fi.subVectors(t,s);const d=hi.dot(fi),p=ui.dot(fi);if(p>=0&&d<=p)return e.copy(s);const m=d*l-a*p;if(m<=0&&l>=0&&p<=0)return o=l/(l-p),e.copy(i).addScaledVector(ui,o);const f=c*p-d*h;if(f<=0&&h-c>=0&&d-p>=0)return di.subVectors(s,n),o=(h-c)/(h-c+(d-p)),e.copy(n).addScaledVector(di,o);const g=1/(f+m+u);return r=m*g,o=u*g,e.copy(i).addScaledVector(hi,r).addScaledVector(ui,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}let yi=0;class vi extends mt{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:yi++}),this.uuid=xt(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=n,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ht,this.stencilZFail=ht,this.stencilZPass=ht,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const i=t[e];if(void 0===i){console.warn("THREE.Material: '"+e+"' parameter is undefined.");continue}const n=this[e];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function n(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),void 0!==this.sheen&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(i.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(i.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(i.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),0!==this.side&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,void 0!==this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(i.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=this.flatShading),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),!1===this.fog&&(i.fog=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),e){const e=n(t.textures),s=n(t.images);e.length>0&&(i.textures=e),s.length>0&&(i.images=s)}return i}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.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 i=null;if(null!==e){const t=e.length;i=new Array(t);for(let n=0;n!==t;++n)i[n]=e[n].clone()}return this.clippingPlanes=i,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.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,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++}}class xi extends vi{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new qt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,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.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 _i=new ne,bi=new Rt;class wi{constructor(t,e,i){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=!0===i,this.usage=ut,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}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}copyAt(t,e,i){t*=this.itemSize,i*=e.itemSize;for(let n=0,s=this.itemSize;n0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const i in e)void 0!==e[i]&&(t[i]=e[i]);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 i=this.attributes;for(const e in i){const n=i[e];t.data.attributes[e]=n.toJSON(t.data)}const n={};let s=!1;for(const e in this.morphAttributes){const i=this.morphAttributes[e],r=[];for(let e=0,n=i.length;e0&&(n[e]=r,s=!0)}s&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));const o=this.boundingSphere;return null!==o&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.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 i=t.index;null!==i&&this.setIndex(i.clone(e));const n=t.attributes;for(const t in n){const i=n[t];this.setAttribute(t,i.clone(e))}const s=t.morphAttributes;for(const t in s){const i=[],n=s[t];for(let t=0,s=n.length;t0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;ti.far?null:{distance:c,point:Ji.clone(),object:t}}(t,e,i,n,Oi,zi,Ui,Zi);if(p){a&&(ji.fromBufferAttribute(a,c),Xi.fromBufferAttribute(a,h),Yi.fromBufferAttribute(a,u),p.uv=gi.getUV(Zi,Oi,zi,Ui,ji,Xi,Yi,new Rt)),l&&(ji.fromBufferAttribute(l,c),Xi.fromBufferAttribute(l,h),Yi.fromBufferAttribute(l,u),p.uv2=gi.getUV(Zi,Oi,zi,Ui,ji,Xi,Yi,new Rt));const t={a:c,b:h,c:u,normal:new ne,materialIndex:0};gi.getNormal(Oi,zi,Ui,t.normal),p.face=t}return p}class $i extends Di{constructor(t=1,e=1,i=1,n=1,s=1,r=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:n,heightSegments:s,depthSegments:r};const o=this;n=Math.floor(n),s=Math.floor(s),r=Math.floor(r);const a=[],l=[],c=[],h=[];let u=0,d=0;function p(t,e,i,n,s,r,p,m,f,g,y){const v=r/f,x=p/g,_=r/2,b=p/2,w=m/2,M=f+1,S=g+1;let E=0,T=0;const A=new ne;for(let r=0;r0?1:-1,c.push(A.x,A.y,A.z),h.push(a/f),h.push(1-r/g),E+=1}}for(let t=0;t0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;const i={};for(const t in this.extensions)!0===this.extensions[t]&&(i[t]=!0);return Object.keys(i).length>0&&(e.extensions=i),e}}class rn extends ri{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ne,this.projectionMatrix=new Ne,this.projectionMatrixInverse=new Ne}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()}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)}}class on extends rn{constructor(t=50,e=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=n,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*vt*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*yt*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*vt*Math.atan(Math.tan(.5*yt*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,i,n,s,r){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*yt*this.fov)/this.zoom,i=2*e,n=this.aspect*i,s=-.5*n;const r=this.view;if(null!==this.view&&this.view.enabled){const t=r.fullWidth,o=r.fullHeight;s+=r.offsetX*n/t,e-=r.offsetY*i/o,n*=r.width/t,i*=r.height/o}const o=this.filmOffset;0!==o&&(s+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+n,e,e-i,t,this.far),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 an=90;class ln extends ri{constructor(t,e,i){super(),this.type="CubeCamera",this.renderTarget=i;const n=new on(an,1,t,e);n.layers=this.layers,n.up.set(0,-1,0),n.lookAt(new ne(1,0,0)),this.add(n);const s=new on(an,1,t,e);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new ne(-1,0,0)),this.add(s);const r=new on(an,1,t,e);r.layers=this.layers,r.up.set(0,0,1),r.lookAt(new ne(0,1,0)),this.add(r);const o=new on(an,1,t,e);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new ne(0,-1,0)),this.add(o);const a=new on(an,1,t,e);a.layers=this.layers,a.up.set(0,-1,0),a.lookAt(new ne(0,0,1)),this.add(a);const l=new on(an,1,t,e);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new ne(0,0,-1)),this.add(l)}update(t,e){null===this.parent&&this.updateMatrixWorld();const i=this.renderTarget,[n,s,r,o,a,l]=this.children,c=t.getRenderTarget(),h=t.toneMapping,u=t.xr.enabled;t.toneMapping=0,t.xr.enabled=!1;const d=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,t.setRenderTarget(i,0),t.render(e,n),t.setRenderTarget(i,1),t.render(e,s),t.setRenderTarget(i,2),t.render(e,r),t.setRenderTarget(i,3),t.render(e,o),t.setRenderTarget(i,4),t.render(e,a),i.texture.generateMipmaps=d,t.setRenderTarget(i,5),t.render(e,l),t.setRenderTarget(c),t.toneMapping=h,t.xr.enabled=u,i.texture.needsPMREMUpdate=!0}}class cn extends Kt{constructor(t,e,i,n,s,o,a,l,c,h){super(t=void 0!==t?t:[],e=void 0!==e?e:r,i,n,s,o,a,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class hn extends $t{constructor(t,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const i={width:t,height:t,depth:1},n=[i,i,i,i,i,i];this.texture=new cn(n,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:g}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.encoding=e.encoding,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const i={tEquirect:{value:null}},n="\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",s="\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",r=new $i(5,5,5),o=new sn({name:"CubemapFromEquirect",uniforms:tn(i),vertexShader:n,fragmentShader:s,side:1,blending:0});o.uniforms.tEquirect.value=e;const a=new Ki(r,o),l=e.minFilter;return e.minFilter===v&&(e.minFilter=g),new ln(1,10,this).update(t,a),e.minFilter=l,a.geometry.dispose(),a.material.dispose(),this}clear(t,e,i,n){const s=t.getRenderTarget();for(let s=0;s<6;s++)t.setRenderTarget(this,s),t.clear(e,i,n);t.setRenderTarget(s)}}const un=new ne,dn=new ne,pn=new Lt;class mn{constructor(t=new ne(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,i,n){return this.normal.set(t,e,i),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const n=un.subVectors(i,e).cross(dn.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)}intersectLine(t,e){const i=t.delta(un),n=this.normal.dot(i);if(0===n)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const s=-(t.start.dot(this.normal)+this.constant)/n;return s<0||s>1?null:e.copy(i).multiplyScalar(s).add(t.start)}intersectsLine(t){const e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<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 i=e||pn.getNormalMatrix(t),n=this.coplanarPoint(un).applyMatrix4(t),s=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(s),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 fn=new Ee,gn=new ne;class yn{constructor(t=new mn,e=new mn,i=new mn,n=new mn,s=new mn,r=new mn){this.planes=[t,e,i,n,s,r]}set(t,e,i,n,s,r){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(i),o[3].copy(n),o[4].copy(s),o[5].copy(r),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t){const e=this.planes,i=t.elements,n=i[0],s=i[1],r=i[2],o=i[3],a=i[4],l=i[5],c=i[6],h=i[7],u=i[8],d=i[9],p=i[10],m=i[11],f=i[12],g=i[13],y=i[14],v=i[15];return e[0].setComponents(o-n,h-a,m-u,v-f).normalize(),e[1].setComponents(o+n,h+a,m+u,v+f).normalize(),e[2].setComponents(o+s,h+l,m+d,v+g).normalize(),e[3].setComponents(o-s,h-l,m-d,v-g).normalize(),e[4].setComponents(o-r,h-c,m-p,v-y).normalize(),e[5].setComponents(o+r,h+c,m+p,v+y).normalize(),this}intersectsObject(t){const e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),fn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(fn)}intersectsSprite(t){return fn.center.set(0,0,0),fn.radius=.7071067811865476,fn.applyMatrix4(t.matrixWorld),this.intersectsSphere(fn)}intersectsSphere(t){const e=this.planes,i=t.center,n=-t.radius;for(let t=0;t<6;t++)if(e[t].distanceToPoint(i)0?t.max.x:t.min.x,gn.y=n.normal.y>0?t.max.y:t.min.y,gn.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(gn)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function vn(){let t=null,e=!1,i=null,n=null;function s(e,r){i(e,r),n=t.requestAnimationFrame(s)}return{start:function(){!0!==e&&null!==i&&(n=t.requestAnimationFrame(s),e=!0)},stop:function(){t.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(t){i=t},setContext:function(e){t=e}}}function xn(t,e){const i=e.isWebGL2,n=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),n.get(t)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);const i=n.get(e);i&&(t.deleteBuffer(i.buffer),n.delete(e))},update:function(e,s){if(e.isGLBufferAttribute){const t=n.get(e);return void((!t||t.version 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}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\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",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660,\t0.0556434,\n\t\t-1.5371385,\t1.8760108, -0.2040259,\n\t\t-0.4985314,\t0.0415560,\t1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\t return vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat R21 = R12;\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos.xyz );\n\t\tvec3 vSigmaY = dFdy( surf_pos.xyz );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\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 )\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 )\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",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};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\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}",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\tvec2 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_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\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_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 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, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.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, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\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\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:"#if defined( USE_ENVMAP )\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, 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#if defined( 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, 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#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_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",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 GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, 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 GeometricContext geometry, 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\n#define Material_LightProbeLOD( material )\t(0)",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\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\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\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, const in GeometricContext geometry, 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 GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\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 GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\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 GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, 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\n#define Material_LightProbeLOD( material )\t(0)",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 GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\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 SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARCOLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vUv ).rgb;\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, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).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_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).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_SHEENCOLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;\n\t#endif\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\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};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.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(\t\t0, 1,\t\t0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\treflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness );\n\t#else\n\t\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, 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( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometry.normal, geometry.viewDir, 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:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\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, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( 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\t\tRE_Direct( directLight, geometry, 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, geometry, 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 *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, 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, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, 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, geometry, 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\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\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 ], geometry.normal );\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, vUv2 );\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( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\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\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\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_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\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, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\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\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\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 = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).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( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\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 OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 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 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\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",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha + 0.1;\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.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( 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( 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 linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",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_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, vUv );\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 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 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 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 shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\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\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t\tf.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\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t\tf.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 shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",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 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 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 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_SPOT_LIGHT_COORDS > 0 )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_COORDS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#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\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\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.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.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.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\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\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, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\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 toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\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(\t1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108,\t1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605,\t1.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}\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, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmission.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\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 framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef texture2DLodEXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\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 ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 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_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;\nvarying vec2 vUv;\nvoid main() {\n\tgl_FragColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tgl_FragColor = vec4( mix( pow( gl_FragColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), gl_FragColor.rgb * 0.0773993808, vec3( lessThanEqual( gl_FragColor.rgb, vec3( 0.04045 ) ) ) ), gl_FragColor.w );\n\t#endif\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:"#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\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 \nvarying vec2 vHighPrecisionZW;\nvoid main() {\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 \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\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#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\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 \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\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 \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}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\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#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\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\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\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\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + 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 \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\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 \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\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( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\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#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\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\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\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\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\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\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\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 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 SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARCOLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\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_SHEENCOLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\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 \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\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 + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * 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\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\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\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 \nvoid main() {\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 \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\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 \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}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\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 * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\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 \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},wn={common:{diffuse:{value:new qt(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new Lt},uv2Transform:{value:new Lt},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new Rt(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new qt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{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 qt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Lt}},sprite:{diffuse:{value:new qt(16777215)},opacity:{value:1},center:{value:new Rt(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Lt}}},Mn={basic:{uniforms:en([wn.common,wn.specularmap,wn.envmap,wn.aomap,wn.lightmap,wn.fog]),vertexShader:bn.meshbasic_vert,fragmentShader:bn.meshbasic_frag},lambert:{uniforms:en([wn.common,wn.specularmap,wn.envmap,wn.aomap,wn.lightmap,wn.emissivemap,wn.bumpmap,wn.normalmap,wn.displacementmap,wn.fog,wn.lights,{emissive:{value:new qt(0)}}]),vertexShader:bn.meshlambert_vert,fragmentShader:bn.meshlambert_frag},phong:{uniforms:en([wn.common,wn.specularmap,wn.envmap,wn.aomap,wn.lightmap,wn.emissivemap,wn.bumpmap,wn.normalmap,wn.displacementmap,wn.fog,wn.lights,{emissive:{value:new qt(0)},specular:{value:new qt(1118481)},shininess:{value:30}}]),vertexShader:bn.meshphong_vert,fragmentShader:bn.meshphong_frag},standard:{uniforms:en([wn.common,wn.envmap,wn.aomap,wn.lightmap,wn.emissivemap,wn.bumpmap,wn.normalmap,wn.displacementmap,wn.roughnessmap,wn.metalnessmap,wn.fog,wn.lights,{emissive:{value:new qt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:bn.meshphysical_vert,fragmentShader:bn.meshphysical_frag},toon:{uniforms:en([wn.common,wn.aomap,wn.lightmap,wn.emissivemap,wn.bumpmap,wn.normalmap,wn.displacementmap,wn.gradientmap,wn.fog,wn.lights,{emissive:{value:new qt(0)}}]),vertexShader:bn.meshtoon_vert,fragmentShader:bn.meshtoon_frag},matcap:{uniforms:en([wn.common,wn.bumpmap,wn.normalmap,wn.displacementmap,wn.fog,{matcap:{value:null}}]),vertexShader:bn.meshmatcap_vert,fragmentShader:bn.meshmatcap_frag},points:{uniforms:en([wn.points,wn.fog]),vertexShader:bn.points_vert,fragmentShader:bn.points_frag},dashed:{uniforms:en([wn.common,wn.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:bn.linedashed_vert,fragmentShader:bn.linedashed_frag},depth:{uniforms:en([wn.common,wn.displacementmap]),vertexShader:bn.depth_vert,fragmentShader:bn.depth_frag},normal:{uniforms:en([wn.common,wn.bumpmap,wn.normalmap,wn.displacementmap,{opacity:{value:1}}]),vertexShader:bn.meshnormal_vert,fragmentShader:bn.meshnormal_frag},sprite:{uniforms:en([wn.sprite,wn.fog]),vertexShader:bn.sprite_vert,fragmentShader:bn.sprite_frag},background:{uniforms:{uvTransform:{value:new Lt},t2D:{value:null}},vertexShader:bn.background_vert,fragmentShader:bn.background_frag},cube:{uniforms:en([wn.envmap,{opacity:{value:1}}]),vertexShader:bn.cube_vert,fragmentShader:bn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:bn.equirect_vert,fragmentShader:bn.equirect_frag},distanceRGBA:{uniforms:en([wn.common,wn.displacementmap,{referencePosition:{value:new ne},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:bn.distanceRGBA_vert,fragmentShader:bn.distanceRGBA_frag},shadow:{uniforms:en([wn.lights,wn.fog,{color:{value:new qt(0)},opacity:{value:1}}]),vertexShader:bn.shadow_vert,fragmentShader:bn.shadow_frag}};function Sn(t,e,i,n,s,r){const o=new qt(0);let a,l,h=!0===s?0:1,u=null,d=0,p=null;function m(t,e){i.buffers.color.setClear(t.r,t.g,t.b,e,r)}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(i,s){let r=!1,f=!0===s.isScene?s.background:null;f&&f.isTexture&&(f=e.get(f));const g=t.xr,y=g.getSession&&g.getSession();y&&"additive"===y.environmentBlendMode&&(f=null),null===f?m(o,h):f&&f.isColor&&(m(f,1),r=!0),(t.autoClear||r)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),f&&(f.isCubeTexture||f.mapping===c)?(void 0===l&&(l=new Ki(new $i(1,1,1),new sn({name:"BackgroundCubeMaterial",uniforms:tn(Mn.cube.uniforms),vertexShader:Mn.cube.vertexShader,fragmentShader:Mn.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(t,e,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=f,l.material.uniforms.flipEnvMap.value=f.isCubeTexture&&!1===f.isRenderTargetTexture?-1:1,u===f&&d===f.version&&p===t.toneMapping||(l.material.needsUpdate=!0,u=f,d=f.version,p=t.toneMapping),l.layers.enableAll(),i.unshift(l,l.geometry,l.material,0,0,null)):f&&f.isTexture&&(void 0===a&&(a=new Ki(new _n(2,2),new sn({name:"BackgroundMaterial",uniforms:tn(Mn.background.uniforms),vertexShader:Mn.background.vertexShader,fragmentShader:Mn.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),a.geometry.deleteAttribute("normal"),Object.defineProperty(a.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(a)),a.material.uniforms.t2D.value=f,!0===f.matrixAutoUpdate&&f.updateMatrix(),a.material.uniforms.uvTransform.value.copy(f.matrix),u===f&&d===f.version&&p===t.toneMapping||(a.material.needsUpdate=!0,u=f,d=f.version,p=t.toneMapping),a.layers.enableAll(),i.unshift(a,a.geometry,a.material,0,0,null))}}}function En(t,e,i,n){const s=t.getParameter(t.MAX_VERTEX_ATTRIBS),r=n.isWebGL2?null:e.get("OES_vertex_array_object"),o=n.isWebGL2||null!==r,a={},l=p(null);let c=l,h=!1;function u(e){return n.isWebGL2?t.bindVertexArray(e):r.bindVertexArrayOES(e)}function d(e){return n.isWebGL2?t.deleteVertexArray(e):r.deleteVertexArrayOES(e)}function p(t){const e=[],i=[],n=[];for(let t=0;t=0){const i=s[e];let n=r[e];if(void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor)),void 0===i)return!0;if(i.attribute!==n)return!0;if(n&&i.data!==n.data)return!0;o++}return c.attributesNum!==o||c.index!==n}(s,x,d,_),b&&function(t,e,i,n){const s={},r=e.attributes;let o=0;const a=i.getAttributes();for(const e in a)if(a[e].location>=0){let i=r[e];void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor));const n={};n.attribute=i,i&&i.data&&(n.data=i.data),s[e]=n,o++}c.attributes=s,c.attributesNum=o,c.index=n}(s,x,d,_)}else{const t=!0===l.wireframe;c.geometry===x.id&&c.program===d.id&&c.wireframe===t||(c.geometry=x.id,c.program=d.id,c.wireframe=t,b=!0)}null!==_&&i.update(_,t.ELEMENT_ARRAY_BUFFER),(b||h)&&(h=!1,function(s,r,o,a){if(!1===n.isWebGL2&&(s.isInstancedMesh||a.isInstancedBufferGeometry)&&null===e.get("ANGLE_instanced_arrays"))return;m();const l=a.attributes,c=o.getAttributes(),h=r.defaultAttributeValues;for(const e in c){const n=c[e];if(n.location>=0){let r=l[e];if(void 0===r&&("instanceMatrix"===e&&s.instanceMatrix&&(r=s.instanceMatrix),"instanceColor"===e&&s.instanceColor&&(r=s.instanceColor)),void 0!==r){const e=r.normalized,o=r.itemSize,l=i.get(r);if(void 0===l)continue;const c=l.buffer,h=l.type,u=l.bytesPerElement;if(r.isInterleavedBufferAttribute){const i=r.data,l=i.stride,d=r.offset;if(i.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"}const r="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext;let o=void 0!==i.precision?i.precision:"highp";const a=s(o);a!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",a,"instead."),o=a);const l=r||e.has("WEBGL_draw_buffers"),c=!0===i.logarithmicDepthBuffer,h=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),u=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=t.getParameter(t.MAX_TEXTURE_SIZE),p=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),m=t.getParameter(t.MAX_VERTEX_ATTRIBS),f=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),g=t.getParameter(t.MAX_VARYING_VECTORS),y=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),v=u>0,x=r||e.has("OES_texture_float");return{isWebGL2:r,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==n)return n;if(!0===e.has("EXT_texture_filter_anisotropic")){const i=e.get("EXT_texture_filter_anisotropic");n=t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n},getMaxPrecision:s,precision:o,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:f,maxVaryings:g,maxFragmentUniforms:y,vertexTextures:v,floatFragmentTextures:x,floatVertexTextures:v&&x,maxSamples:r?t.getParameter(t.MAX_SAMPLES):0}}function Cn(t){const e=this;let i=null,n=0,s=!1,r=!1;const o=new mn,a=new Lt,l={value:null,needsUpdate:!1};function c(){l.value!==i&&(l.value=i,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(t,i,n,s){const r=null!==t?t.length:0;let c=null;if(0!==r){if(c=l.value,!0!==s||null===c){const e=n+4*r,s=i.matrixWorldInverse;a.getNormalMatrix(s),(null===c||c.length0){const o=new hn(r.height/2);return o.fromEquirectangularTexture(t,s),e.set(s,o),s.addEventListener("dispose",n),i(o.texture,s.mapping)}return null}}}return s},dispose:function(){e=new WeakMap}}}Mn.physical={uniforms:en([Mn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new Rt(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new qt(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new Rt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new qt(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new qt(1,1,1)},specularColorMap:{value:null}}]),vertexShader:bn.meshphysical_vert,fragmentShader:bn.meshphysical_frag};class Ln extends rn{constructor(t=-1,e=1,i=1,n=-1,s=.1,r=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=n,this.near=s,this.far=r,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,i,n,s,r){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let s=i-t,r=i+t,o=n+e,a=n-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=t*this.view.offsetX,r=s+t*this.view.width,o-=e*this.view.offsetY,a=o-e*this.view.height}this.projectionMatrix.makeOrthographic(s,r,o,a,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}const Pn=[.125,.215,.35,.446,.526,.582],In=new Ln,Dn=new qt;let Nn=null;const Bn=(1+Math.sqrt(5))/2,Fn=1/Bn,On=[new ne(1,1,1),new ne(-1,1,1),new ne(1,1,-1),new ne(-1,1,-1),new ne(0,Bn,Fn),new ne(0,Bn,-Fn),new ne(Fn,0,Bn),new ne(-Fn,0,Bn),new ne(Bn,Fn,0),new ne(-Bn,Fn,0)];class zn{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,i=.1,n=100){Nn=this._renderer.getRenderTarget(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(t,i,n,s),e>0&&this._blur(s,0,0,e),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=kn(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Vn(),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?a=Pn[o-t+4-1]:0===o&&(a=0),n.push(a);const l=1/(r-2),c=-l,h=1+l,u=[c,c,h,c,h,h,c,c,h,h,c,h],d=6,p=6,m=3,f=2,g=1,y=new Float32Array(m*p*d),v=new Float32Array(f*p*d),x=new Float32Array(g*p*d);for(let t=0;t2?0:-1,n=[e,i,0,e+2/3,i,0,e+2/3,i+1,0,e,i,0,e+2/3,i+1,0,e,i+1,0];y.set(n,m*p*t),v.set(u,f*p*t);const s=[t,t,t,t,t,t];x.set(s,g*p*t)}const _=new Di;_.setAttribute("position",new wi(y,m)),_.setAttribute("uv",new wi(v,f)),_.setAttribute("faceIndex",new wi(x,g)),e.push(_),s>4&&s--}return{lodPlanes:e,sizeLods:i,sigmas:n}}(n)),this._blurMaterial=function(t,e,i){const n=new Float32Array(20),s=new ne(0,1,0);return new sn({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},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:0,depthTest:!1,depthWrite:!1})}(n,t,e)}return n}_compileMaterial(t){const e=new Ki(this._lodPlanes[0],t);this._renderer.compile(e,In)}_sceneToCubeUV(t,e,i,n){const s=new on(90,1,e,i),r=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],a=this._renderer,l=a.autoClear,c=a.toneMapping;a.getClearColor(Dn),a.toneMapping=0,a.autoClear=!1;const h=new xi({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),u=new Ki(new $i,h);let d=!1;const p=t.background;p?p.isColor&&(h.color.copy(p),t.background=null,d=!0):(h.color.copy(Dn),d=!0);for(let e=0;e<6;e++){const i=e%3;0===i?(s.up.set(0,r[e],0),s.lookAt(o[e],0,0)):1===i?(s.up.set(0,0,r[e]),s.lookAt(0,o[e],0)):(s.up.set(0,r[e],0),s.lookAt(0,0,o[e]));const l=this._cubeSize;Hn(n,i*l,e>2?l:0,l,l),a.setRenderTarget(n),d&&a.render(u,s),a.render(t,s)}u.geometry.dispose(),u.material.dispose(),a.toneMapping=c,a.autoClear=l,t.background=p}_textureToCubeUV(t,e){const i=this._renderer,n=t.mapping===r||t.mapping===o;n?(null===this._cubemapMaterial&&(this._cubemapMaterial=kn()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Vn());const s=n?this._cubemapMaterial:this._equirectMaterial,a=new Ki(this._lodPlanes[0],s);s.uniforms.envMap.value=t;const l=this._cubeSize;Hn(e,0,0,3*l,2*l),i.setRenderTarget(e),i.render(a,In)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;for(let e=1;e20&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const f=[];let g=0;for(let t=0;t<20;++t){const e=t/p,i=Math.exp(-e*e/2);f.push(i),0===t?g+=i:ty-4?n-y+4:0),4*(this._cubeSize-v),3*v,2*v),a.setRenderTarget(e),a.render(c,In)}}function Un(t,e,i){const n=new $t(t,e,i);return n.texture.mapping=c,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Hn(t,e,i,n,s){t.viewport.set(e,i,n,s),t.scissor.set(e,i,n,s)}function Vn(){return new sn({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:0,depthTest:!1,depthWrite:!1})}function kn(){return new sn({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:0,depthTest:!1,depthWrite:!1})}function Gn(t){let e=new WeakMap,i=null;function n(t){const i=t.target;i.removeEventListener("dispose",n);const s=e.get(i);void 0!==s&&(e.delete(i),s.dispose())}return{get:function(s){if(s&&s.isTexture){const c=s.mapping,h=c===a||c===l,u=c===r||c===o;if(h||u){if(s.isRenderTargetTexture&&!0===s.needsPMREMUpdate){s.needsPMREMUpdate=!1;let n=e.get(s);return null===i&&(i=new zn(t)),n=h?i.fromEquirectangular(s,n):i.fromCubemap(s,n),e.set(s,n),n.texture}if(e.has(s))return e.get(s).texture;{const r=s.image;if(h&&r&&r.height>0||u&&r&&function(t){let e=0;for(let i=0;i<6;i++)void 0!==t[i]&&e++;return 6===e}(r)){null===i&&(i=new zn(t));const r=h?i.fromEquirectangular(s):i.fromCubemap(s);return e.set(s,r),s.addEventListener("dispose",n),r.texture}return null}}}return s},dispose:function(){e=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function Wn(t){const e={};function i(i){if(void 0!==e[i])return e[i];let n;switch(i){case"WEBGL_depth_texture":n=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=t.getExtension(i)}return e[i]=n,n}return{has:function(t){return null!==i(t)},init:function(t){t.isWebGL2?i("EXT_color_buffer_float"):(i("WEBGL_depth_texture"),i("OES_texture_float"),i("OES_texture_half_float"),i("OES_texture_half_float_linear"),i("OES_standard_derivatives"),i("OES_element_index_uint"),i("OES_vertex_array_object"),i("ANGLE_instanced_arrays")),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture")},get:function(t){const e=i(t);return null===e&&console.warn("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function qn(t,e,i,n){const s={},r=new WeakMap;function o(t){const a=t.target;null!==a.index&&e.remove(a.index);for(const t in a.attributes)e.remove(a.attributes[t]);a.removeEventListener("dispose",o),delete s[a.id];const l=r.get(a);l&&(e.remove(l),r.delete(a)),n.releaseStatesOfGeometry(a),!0===a.isInstancedBufferGeometry&&delete a._maxInstanceCount,i.memory.geometries--}function a(t){const i=[],n=t.index,s=t.attributes.position;let o=0;if(null!==n){const t=n.array;o=n.version;for(let e=0,n=t.length;ee.maxTextureSize&&(A=Math.ceil(T/e.maxTextureSize),T=e.maxTextureSize);const C=new Float32Array(T*A*4*m),R=new te(C,T,A,m);R.type=w,R.needsUpdate=!0;const L=4*E;for(let I=0;I0)return t;const s=e*i;let r=is[s];if(void 0===r&&(r=new Float32Array(s),is[s]=r),0!==e){n.toArray(r,0);for(let n=1,s=0;n!==e;++n)s+=i,t[n].toArray(r,s)}return r}function ls(t,e){if(t.length!==e.length)return!1;for(let i=0,n=t.length;i":" "} ${s}: ${i[t]}`)}return n.join("\n")}(t.getShaderSource(e),n)}return s}function rr(t,e){const i=function(t){switch(t){case ot:return["Linear","( value )"];case at:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",t),["Linear","( value )"]}}(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}function or(t,e){let i;switch(e){case 1:i="Linear";break;case 2:i="Reinhard";break;case 3:i="OptimizedCineon";break;case 4:i="ACESFilmic";break;case 5:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),i="Linear"}return"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function ar(t){return""!==t}function lr(t,e){const i=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,i).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 cr(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const hr=/^[ \t]*#include +<([\w\d./]+)>/gm;function ur(t){return t.replace(hr,dr)}function dr(t,e){const i=bn[e];if(void 0===i)throw new Error("Can not resolve #include <"+e+">");return ur(i)}const pr=/#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 mr(t){return t.replace(pr,fr)}function fr(t,e,i,n){let s="";for(let t=parseInt(e);t0&&(x+="\n"),_=[g,y].filter(ar).join("\n"),_.length>0&&(_+="\n")):(x=[gr(i),"#define SHADER_NAME "+i.shaderName,y,i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.supportsVertexTextures?"#define VERTEX_TEXTURES":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+p:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.displacementMap&&i.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",i.specularColorMap?"#define USE_SPECULARCOLORMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEENCOLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.morphColors&&i.isWebGL2?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+u:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","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","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(ar).join("\n"),_=[g,gr(i),"#define SHADER_NAME "+i.shaderName,y,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+d:"",i.envMap?"#define "+p:"",i.envMap?"#define "+m:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",i.specularColorMap?"#define USE_SPECULARCOLORMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEENCOLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+u:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?bn.tonemapping_pars_fragment:"",0!==i.toneMapping?or("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",bn.encodings_pars_fragment,rr("linearToOutputTexel",i.outputEncoding),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(ar).join("\n")),l=ur(l),l=lr(l,i),l=cr(l,i),h=ur(h),h=lr(h,i),h=cr(h,i),l=mr(l),h=mr(h),i.isWebGL2&&!0!==i.isRawShaderMaterial&&(b="#version 300 es\n",x=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+x,_=["#define varying in",i.glslVersion===dt?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===dt?"":"#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"+_);const w=b+x+l,M=b+_+h,S=ir(s,s.VERTEX_SHADER,w),E=ir(s,s.FRAGMENT_SHADER,M);if(s.attachShader(v,S),s.attachShader(v,E),void 0!==i.index0AttributeName?s.bindAttribLocation(v,0,i.index0AttributeName):!0===i.morphTargets&&s.bindAttribLocation(v,0,"position"),s.linkProgram(v),t.debug.checkShaderErrors){const t=s.getProgramInfoLog(v).trim(),e=s.getShaderInfoLog(S).trim(),i=s.getShaderInfoLog(E).trim();let n=!0,r=!0;if(!1===s.getProgramParameter(v,s.LINK_STATUS)){n=!1;const e=sr(s,S,"vertex"),i=sr(s,E,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(v,s.VALIDATE_STATUS)+"\n\nProgram Info Log: "+t+"\n"+e+"\n"+i)}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):""!==e&&""!==i||(r=!1);r&&(this.diagnostics={runnable:n,programLog:t,vertexShader:{log:e,prefix:x},fragmentShader:{log:i,prefix:_}})}let T,A;return s.deleteShader(S),s.deleteShader(E),this.getUniforms=function(){return void 0===T&&(T=new er(s,v)),T},this.getAttributes=function(){return void 0===A&&(A=function(t,e){const i={},n=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let s=0;s0,D=r.clearcoat>0,N=r.iridescence>0;return{isWebGL2:u,shaderID:M,shaderName:r.type,vertexShader:T,fragmentShader:A,defines:r.defines,customVertexShaderID:C,customFragmentShaderID:R,isRawShaderMaterial:!0===r.isRawShaderMaterial,glslVersion:r.glslVersion,precision:m,instancing:!0===y.isInstancedMesh,instancingColor:!0===y.isInstancedMesh&&null!==y.instanceColor,supportsVertexTextures:p,outputEncoding:null===P?t.outputEncoding:!0===P.isXRRenderTarget?P.texture.encoding:ot,map:!!r.map,matcap:!!r.matcap,envMap:!!b,envMapMode:b&&b.mapping,envMapCubeUVHeight:w,lightMap:!!r.lightMap,aoMap:!!r.aoMap,emissiveMap:!!r.emissiveMap,bumpMap:!!r.bumpMap,normalMap:!!r.normalMap,objectSpaceNormalMap:1===r.normalMapType,tangentSpaceNormalMap:0===r.normalMapType,decodeVideoTexture:!!r.map&&!0===r.map.isVideoTexture&&r.map.encoding===at,clearcoat:D,clearcoatMap:D&&!!r.clearcoatMap,clearcoatRoughnessMap:D&&!!r.clearcoatRoughnessMap,clearcoatNormalMap:D&&!!r.clearcoatNormalMap,iridescence:N,iridescenceMap:N&&!!r.iridescenceMap,iridescenceThicknessMap:N&&!!r.iridescenceThicknessMap,displacementMap:!!r.displacementMap,roughnessMap:!!r.roughnessMap,metalnessMap:!!r.metalnessMap,specularMap:!!r.specularMap,specularIntensityMap:!!r.specularIntensityMap,specularColorMap:!!r.specularColorMap,opaque:!1===r.transparent&&1===r.blending,alphaMap:!!r.alphaMap,alphaTest:I,gradientMap:!!r.gradientMap,sheen:r.sheen>0,sheenColorMap:!!r.sheenColorMap,sheenRoughnessMap:!!r.sheenRoughnessMap,transmission:r.transmission>0,transmissionMap:!!r.transmissionMap,thicknessMap:!!r.thicknessMap,combine:r.combine,vertexTangents:!!r.normalMap&&!!x.attributes.tangent,vertexColors:r.vertexColors,vertexAlphas:!0===r.vertexColors&&!!x.attributes.color&&4===x.attributes.color.itemSize,vertexUvs:!!(r.map||r.bumpMap||r.normalMap||r.specularMap||r.alphaMap||r.emissiveMap||r.roughnessMap||r.metalnessMap||r.clearcoatMap||r.clearcoatRoughnessMap||r.clearcoatNormalMap||r.iridescenceMap||r.iridescenceThicknessMap||r.displacementMap||r.transmissionMap||r.thicknessMap||r.specularIntensityMap||r.specularColorMap||r.sheenColorMap||r.sheenRoughnessMap),uvsVertexOnly:!(r.map||r.bumpMap||r.normalMap||r.specularMap||r.alphaMap||r.emissiveMap||r.roughnessMap||r.metalnessMap||r.clearcoatNormalMap||r.iridescenceMap||r.iridescenceThicknessMap||r.transmission>0||r.transmissionMap||r.thicknessMap||r.specularIntensityMap||r.specularColorMap||r.sheen>0||r.sheenColorMap||r.sheenRoughnessMap||!r.displacementMap),fog:!!v,useFog:!0===r.fog,fogExp2:v&&v.isFogExp2,flatShading:!!r.flatShading,sizeAttenuation:r.sizeAttenuation,logarithmicDepthBuffer:d,skinning:!0===y.isSkinnedMesh,morphTargets:void 0!==x.morphAttributes.position,morphNormals:void 0!==x.morphAttributes.normal,morphColors:void 0!==x.morphAttributes.color,morphTargetsCount:E,morphTextureStride:L,numDirLights:a.directional.length,numPointLights:a.point.length,numSpotLights:a.spot.length,numSpotLightMaps:a.spotLightMap.length,numRectAreaLights:a.rectArea.length,numHemiLights:a.hemi.length,numDirLightShadows:a.directionalShadowMap.length,numPointLightShadows:a.pointShadowMap.length,numSpotLightShadows:a.spotShadowMap.length,numSpotLightShadowsWithMaps:a.numSpotLightShadowsWithMaps,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:r.dithering,shadowMapEnabled:t.shadowMap.enabled&&h.length>0,shadowMapType:t.shadowMap.type,toneMapping:r.toneMapped?t.toneMapping:0,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:r.premultipliedAlpha,doubleSided:2===r.side,flipSided:1===r.side,useDepthPacking:!!r.depthPacking,depthPacking:r.depthPacking||0,index0AttributeName:r.index0AttributeName,extensionDerivatives:r.extensions&&r.extensions.derivatives,extensionFragDepth:r.extensions&&r.extensions.fragDepth,extensionDrawBuffers:r.extensions&&r.extensions.drawBuffers,extensionShaderTextureLOD:r.extensions&&r.extensions.shaderTextureLOD,rendererExtensionFragDepth:u||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||n.has("EXT_shader_texture_lod"),customProgramCacheKey:r.customProgramCacheKey()}},getProgramCacheKey:function(e){const i=[];if(e.shaderID?i.push(e.shaderID):(i.push(e.customVertexShaderID),i.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)i.push(t),i.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(function(t,e){t.push(e.precision),t.push(e.outputEncoding),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.combine),t.push(e.vertexUvs),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.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(i,e),function(t,e){a.disableAll(),e.isWebGL2&&a.enable(0),e.supportsVertexTextures&&a.enable(1),e.instancing&&a.enable(2),e.instancingColor&&a.enable(3),e.map&&a.enable(4),e.matcap&&a.enable(5),e.envMap&&a.enable(6),e.lightMap&&a.enable(7),e.aoMap&&a.enable(8),e.emissiveMap&&a.enable(9),e.bumpMap&&a.enable(10),e.normalMap&&a.enable(11),e.objectSpaceNormalMap&&a.enable(12),e.tangentSpaceNormalMap&&a.enable(13),e.clearcoat&&a.enable(14),e.clearcoatMap&&a.enable(15),e.clearcoatRoughnessMap&&a.enable(16),e.clearcoatNormalMap&&a.enable(17),e.iridescence&&a.enable(18),e.iridescenceMap&&a.enable(19),e.iridescenceThicknessMap&&a.enable(20),e.displacementMap&&a.enable(21),e.specularMap&&a.enable(22),e.roughnessMap&&a.enable(23),e.metalnessMap&&a.enable(24),e.gradientMap&&a.enable(25),e.alphaMap&&a.enable(26),e.alphaTest&&a.enable(27),e.vertexColors&&a.enable(28),e.vertexAlphas&&a.enable(29),e.vertexUvs&&a.enable(30),e.vertexTangents&&a.enable(31),e.uvsVertexOnly&&a.enable(32),t.push(a.mask),a.disableAll(),e.fog&&a.enable(0),e.useFog&&a.enable(1),e.flatShading&&a.enable(2),e.logarithmicDepthBuffer&&a.enable(3),e.skinning&&a.enable(4),e.morphTargets&&a.enable(5),e.morphNormals&&a.enable(6),e.morphColors&&a.enable(7),e.premultipliedAlpha&&a.enable(8),e.shadowMapEnabled&&a.enable(9),e.physicallyCorrectLights&&a.enable(10),e.doubleSided&&a.enable(11),e.flipSided&&a.enable(12),e.useDepthPacking&&a.enable(13),e.dithering&&a.enable(14),e.specularIntensityMap&&a.enable(15),e.specularColorMap&&a.enable(16),e.transmission&&a.enable(17),e.transmissionMap&&a.enable(18),e.thicknessMap&&a.enable(19),e.sheen&&a.enable(20),e.sheenColorMap&&a.enable(21),e.sheenRoughnessMap&&a.enable(22),e.decodeVideoTexture&&a.enable(23),e.opaque&&a.enable(24),t.push(a.mask)}(i,e),i.push(t.outputEncoding)),i.push(e.customProgramCacheKey),i.join()},getUniforms:function(t){const e=f[t.type];let i;if(e){const t=Mn[e];i=nn.clone(t.uniforms)}else i=t.uniforms;return i},acquireProgram:function(e,i){let n;for(let t=0,e=h.length;t0?n.push(h):!0===o.transparent?s.push(h):i.push(h)},unshift:function(t,e,o,a,l,c){const h=r(t,e,o,a,l,c);o.transmission>0?n.unshift(h):!0===o.transparent?s.unshift(h):i.unshift(h)},finish:function(){for(let i=e,n=t.length;i1&&i.sort(t||Mr),n.length>1&&n.sort(e||Sr),s.length>1&&s.sort(e||Sr)}}}function Tr(){let t=new WeakMap;return{get:function(e,i){const n=t.get(e);let s;return void 0===n?(s=new Er,t.set(e,[s])):i>=n.length?(s=new Er,n.push(s)):s=n[i],s},dispose:function(){t=new WeakMap}}}function Ar(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":i={direction:new ne,color:new qt};break;case"SpotLight":i={position:new ne,direction:new ne,color:new qt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new ne,color:new qt,distance:0,decay:0};break;case"HemisphereLight":i={direction:new ne,skyColor:new qt,groundColor:new qt};break;case"RectAreaLight":i={color:new qt,position:new ne,halfWidth:new ne,halfHeight:new ne}}return t[e.id]=i,i}}}let Cr=0;function Rr(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Lr(t,e){const i=new Ar,n=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Rt};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Rt,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=i,i}}}(),s={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-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};for(let t=0;t<9;t++)s.probe.push(new ne);const r=new ne,o=new Ne,a=new Ne;return{setup:function(r,o){let a=0,l=0,c=0;for(let t=0;t<9;t++)s.probe[t].set(0,0,0);let h=0,u=0,d=0,p=0,m=0,f=0,g=0,y=0,v=0,x=0;r.sort(Rr);const _=!0!==o?Math.PI:1;for(let t=0,e=r.length;t0&&(e.isWebGL2||!0===t.has("OES_texture_float_linear")?(s.rectAreaLTC1=wn.LTC_FLOAT_1,s.rectAreaLTC2=wn.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")?(s.rectAreaLTC1=wn.LTC_HALF_1,s.rectAreaLTC2=wn.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),s.ambient[0]=a,s.ambient[1]=l,s.ambient[2]=c;const b=s.hash;b.directionalLength===h&&b.pointLength===u&&b.spotLength===d&&b.rectAreaLength===p&&b.hemiLength===m&&b.numDirectionalShadows===f&&b.numPointShadows===g&&b.numSpotShadows===y&&b.numSpotMaps===v||(s.directional.length=h,s.spot.length=d,s.rectArea.length=p,s.point.length=u,s.hemi.length=m,s.directionalShadow.length=f,s.directionalShadowMap.length=f,s.pointShadow.length=g,s.pointShadowMap.length=g,s.spotShadow.length=y,s.spotShadowMap.length=y,s.directionalShadowMatrix.length=f,s.pointShadowMatrix.length=g,s.spotLightMatrix.length=y+v-x,s.spotLightMap.length=v,s.numSpotLightShadowsWithMaps=x,b.directionalLength=h,b.pointLength=u,b.spotLength=d,b.rectAreaLength=p,b.hemiLength=m,b.numDirectionalShadows=f,b.numPointShadows=g,b.numSpotShadows=y,b.numSpotMaps=v,s.version=Cr++)},setupView:function(t,e){let i=0,n=0,l=0,c=0,h=0;const u=e.matrixWorldInverse;for(let e=0,d=t.length;e=r.length?(o=new Pr(t,e),r.push(o)):o=r[s],o},dispose:function(){i=new WeakMap}}}class Dr extends vi{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,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 Nr extends vi{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new ne,this.nearDistance=1,this.farDistance=1e3,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.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}function Br(t,e,i){let n=new yn;const s=new Rt,r=new Rt,o=new Qt,a=new Dr({depthPacking:3201}),l=new Nr,c={},h=i.maxTextureSize,u={0:1,1:0,2:2},d=new sn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Rt},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}"}),m=d.clone();m.defines.HORIZONTAL_PASS=1;const f=new Di;f.setAttribute("position",new wi(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const g=new Ki(f,d),y=this;function v(i,n){const r=e.update(g);d.defines.VSM_SAMPLES!==i.blurSamples&&(d.defines.VSM_SAMPLES=i.blurSamples,m.defines.VSM_SAMPLES=i.blurSamples,d.needsUpdate=!0,m.needsUpdate=!0),null===i.mapPass&&(i.mapPass=new $t(s.x,s.y)),d.uniforms.shadow_pass.value=i.map.texture,d.uniforms.resolution.value=i.mapSize,d.uniforms.radius.value=i.radius,t.setRenderTarget(i.mapPass),t.clear(),t.renderBufferDirect(n,null,r,d,g,null),m.uniforms.shadow_pass.value=i.mapPass.texture,m.uniforms.resolution.value=i.mapSize,m.uniforms.radius.value=i.radius,t.setRenderTarget(i.map),t.clear(),t.renderBufferDirect(n,null,r,m,g,null)}function x(e,i,n,s,r,o){let h=null;const d=!0===n.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(h=void 0!==d?d:!0===n.isPointLight?l:a,t.localClippingEnabled&&!0===i.clipShadows&&Array.isArray(i.clippingPlanes)&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0){const t=h.uuid,e=i.uuid;let n=c[t];void 0===n&&(n={},c[t]=n);let s=n[e];void 0===s&&(s=h.clone(),n[e]=s),h=s}return h.visible=i.visible,h.wireframe=i.wireframe,h.side=3===o?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:u[i.side],h.alphaMap=i.alphaMap,h.alphaTest=i.alphaTest,h.clipShadows=i.clipShadows,h.clippingPlanes=i.clippingPlanes,h.clipIntersection=i.clipIntersection,h.displacementMap=i.displacementMap,h.displacementScale=i.displacementScale,h.displacementBias=i.displacementBias,h.wireframeLinewidth=i.wireframeLinewidth,h.linewidth=i.linewidth,!0===n.isPointLight&&!0===h.isMeshDistanceMaterial&&(h.referencePosition.setFromMatrixPosition(n.matrixWorld),h.nearDistance=s,h.farDistance=r),h}function _(i,s,r,o,a){if(!1===i.visible)return;if(i.layers.test(s.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===a)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,i.matrixWorld);const n=e.update(i),s=i.material;if(Array.isArray(s)){const e=n.groups;for(let l=0,c=e.length;lh||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/m.x),s.x=r.x*m.x,u.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/m.y),s.y=r.y*m.y,u.mapSize.y=r.y)),null===u.map){const t=3!==this.type?{minFilter:p,magFilter:p}:{};u.map=new $t(s.x,s.y,t),u.map.texture.name=c.name+".shadowMap",u.camera.updateProjectionMatrix()}t.setRenderTarget(u.map),t.clear();const f=u.getViewportCount();for(let t=0;t=1):-1!==I.indexOf("OpenGL ES")&&(P=parseFloat(/^OpenGL ES (\d)/.exec(I)[1]),L=P>=2);let D=null,N={};const B=t.getParameter(t.SCISSOR_BOX),F=t.getParameter(t.VIEWPORT),O=(new Qt).fromArray(B),z=(new Qt).fromArray(F);function U(e,i,n){const s=new Uint8Array(4),r=t.createTexture();t.bindTexture(e,r),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let e=0;en||t.height>n)&&(s=n/Math.max(t.width,t.height)),s<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const n=e?Et:Math.floor,r=n(s*t.width),o=n(s*t.height);void 0===D&&(D=F(r,o));const a=i?F(r,o):D;return a.width=r,a.height=o,a.getContext("2d").drawImage(t,0,0,r,o),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+r+"x"+o+")."),a}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function z(t){return Mt(t.width)&&Mt(t.height)}function U(t,e){return t.generateMipmaps&&e&&t.minFilter!==p&&t.minFilter!==g}function H(e){t.generateMipmap(e)}function V(i,n,s,r,o=!1){if(!1===a)return n;if(null!==i){if(void 0!==t[i])return t[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let l=n;return n===t.RED&&(s===t.FLOAT&&(l=t.R32F),s===t.HALF_FLOAT&&(l=t.R16F),s===t.UNSIGNED_BYTE&&(l=t.R8)),n===t.RG&&(s===t.FLOAT&&(l=t.RG32F),s===t.HALF_FLOAT&&(l=t.RG16F),s===t.UNSIGNED_BYTE&&(l=t.RG8)),n===t.RGBA&&(s===t.FLOAT&&(l=t.RGBA32F),s===t.HALF_FLOAT&&(l=t.RGBA16F),s===t.UNSIGNED_BYTE&&(l=r===at&&!1===o?t.SRGB8_ALPHA8:t.RGBA8),s===t.UNSIGNED_SHORT_4_4_4_4&&(l=t.RGBA4),s===t.UNSIGNED_SHORT_5_5_5_1&&(l=t.RGB5_A1)),l!==t.R16F&&l!==t.R32F&&l!==t.RG16F&&l!==t.RG32F&&l!==t.RGBA16F&&l!==t.RGBA32F||e.get("EXT_color_buffer_float"),l}function k(t,e,i){return!0===U(t,i)||t.isFramebufferTexture&&t.minFilter!==p&&t.minFilter!==g?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 G(e){return e===p||e===m||e===f?t.NEAREST:t.LINEAR}function W(t){const e=t.target;e.removeEventListener("dispose",W),function(t){const e=n.get(t);if(void 0===e.__webglInit)return;const i=t.source,s=N.get(i);if(s){const n=s[e.__cacheKey];n.usedTimes--,0===n.usedTimes&&j(t),0===Object.keys(s).length&&N.delete(i)}n.remove(t)}(e),e.isVideoTexture&&I.delete(e)}function q(e){const i=e.target;i.removeEventListener("dispose",q),function(e){const i=e.texture,s=n.get(e),r=n.get(i);if(void 0!==r.__webglTexture&&(t.deleteTexture(r.__webglTexture),o.memory.textures--),e.depthTexture&&e.depthTexture.dispose(),e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++)t.deleteFramebuffer(s.__webglFramebuffer[e]),s.__webglDepthbuffer&&t.deleteRenderbuffer(s.__webglDepthbuffer[e]);else{if(t.deleteFramebuffer(s.__webglFramebuffer),s.__webglDepthbuffer&&t.deleteRenderbuffer(s.__webglDepthbuffer),s.__webglMultisampledFramebuffer&&t.deleteFramebuffer(s.__webglMultisampledFramebuffer),s.__webglColorRenderbuffer)for(let e=0;e0&&r.__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 $(r,e,s);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}i.bindTexture(t.TEXTURE_2D,r.__webglTexture,t.TEXTURE0+s)}const Z={[h]:t.REPEAT,[u]:t.CLAMP_TO_EDGE,[d]:t.MIRRORED_REPEAT},J={[p]:t.NEAREST,[m]:t.NEAREST_MIPMAP_NEAREST,[f]:t.NEAREST_MIPMAP_LINEAR,[g]:t.LINEAR,[y]:t.LINEAR_MIPMAP_NEAREST,[v]:t.LINEAR_MIPMAP_LINEAR};function K(i,r,o){if(o?(t.texParameteri(i,t.TEXTURE_WRAP_S,Z[r.wrapS]),t.texParameteri(i,t.TEXTURE_WRAP_T,Z[r.wrapT]),i!==t.TEXTURE_3D&&i!==t.TEXTURE_2D_ARRAY||t.texParameteri(i,t.TEXTURE_WRAP_R,Z[r.wrapR]),t.texParameteri(i,t.TEXTURE_MAG_FILTER,J[r.magFilter]),t.texParameteri(i,t.TEXTURE_MIN_FILTER,J[r.minFilter])):(t.texParameteri(i,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(i,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),i!==t.TEXTURE_3D&&i!==t.TEXTURE_2D_ARRAY||t.texParameteri(i,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),r.wrapS===u&&r.wrapT===u||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(i,t.TEXTURE_MAG_FILTER,G(r.magFilter)),t.texParameteri(i,t.TEXTURE_MIN_FILTER,G(r.minFilter)),r.minFilter!==p&&r.minFilter!==g&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),!0===e.has("EXT_texture_filter_anisotropic")){const o=e.get("EXT_texture_filter_anisotropic");if(r.type===w&&!1===e.has("OES_texture_float_linear"))return;if(!1===a&&r.type===M&&!1===e.has("OES_texture_half_float_linear"))return;(r.anisotropy>1||n.get(r).__currentAnisotropy)&&(t.texParameterf(i,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(r.anisotropy,s.getMaxAnisotropy())),n.get(r).__currentAnisotropy=r.anisotropy)}}function Q(e,i){let n=!1;void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",W));const s=i.source;let r=N.get(s);void 0===r&&(r={},N.set(s,r));const a=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),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.encoding),e.join()}(i);if(a!==e.__cacheKey){void 0===r[a]&&(r[a]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,n=!0),r[a].usedTimes++;const s=r[e.__cacheKey];void 0!==s&&(r[e.__cacheKey].usedTimes--,0===s.usedTimes&&j(i)),e.__cacheKey=a,e.__webglTexture=r[a].texture}return n}function $(e,s,o){let l=t.TEXTURE_2D;s.isDataArrayTexture&&(l=t.TEXTURE_2D_ARRAY),s.isData3DTexture&&(l=t.TEXTURE_3D);const c=Q(e,s),h=s.source;i.bindTexture(l,e.__webglTexture,t.TEXTURE0+o);const d=n.get(h);if(h.version!==d.__version||!0===c){i.activeTexture(t.TEXTURE0+o),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,s.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,s.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE);const e=function(t){return!a&&(t.wrapS!==u||t.wrapT!==u||t.minFilter!==p&&t.minFilter!==g)}(s)&&!1===z(s.image);let n=O(s.image,e,!1,C);n=rt(s,n);const m=z(n)||a,f=r.convert(s.format,s.encoding);let y,v=r.convert(s.type),x=V(s.internalFormat,f,v,s.encoding,s.isVideoTexture);K(l,s,m);const M=s.mipmaps,R=a&&!0!==s.isVideoTexture,L=void 0===d.__version||!0===c,P=k(s,n,m);if(s.isDepthTexture)x=t.DEPTH_COMPONENT,a?x=s.type===w?t.DEPTH_COMPONENT32F:s.type===b?t.DEPTH_COMPONENT24:s.type===S?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT16:s.type===w&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),s.format===T&&x===t.DEPTH_COMPONENT&&s.type!==_&&s.type!==b&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),s.type=b,v=r.convert(s.type)),s.format===A&&x===t.DEPTH_COMPONENT&&(x=t.DEPTH_STENCIL,s.type!==S&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),s.type=S,v=r.convert(s.type))),L&&(R?i.texStorage2D(t.TEXTURE_2D,1,x,n.width,n.height):i.texImage2D(t.TEXTURE_2D,0,x,n.width,n.height,0,f,v,null));else if(s.isDataTexture)if(M.length>0&&m){R&&L&&i.texStorage2D(t.TEXTURE_2D,P,x,M[0].width,M[0].height);for(let e=0,n=M.length;e>=1,s>>=1}}else if(M.length>0&&m){R&&L&&i.texStorage2D(t.TEXTURE_2D,P,x,M[0].width,M[0].height);for(let e=0,n=M.length;e0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==i.__useRenderToTexture}function rt(t,i){const n=t.encoding,s=t.format,r=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||t.format===pt||n!==ot&&(n===at?!1===a?!0===e.has("EXT_sRGB")&&s===E?(t.format=pt,t.minFilter=g,t.generateMipmaps=!1):i=Xt.sRGBToLinear(i):s===E&&r===x||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",n)),i}this.allocateTextureUnit=function(){const t=X;return t>=l&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+l),X+=1,t},this.resetTextureUnits=function(){X=0},this.setTexture2D=Y,this.setTexture2DArray=function(e,s){const r=n.get(e);e.version>0&&r.__version!==e.version?$(r,e,s):i.bindTexture(t.TEXTURE_2D_ARRAY,r.__webglTexture,t.TEXTURE0+s)},this.setTexture3D=function(e,s){const r=n.get(e);e.version>0&&r.__version!==e.version?$(r,e,s):i.bindTexture(t.TEXTURE_3D,r.__webglTexture,t.TEXTURE0+s)},this.setTextureCube=function(e,s){const o=n.get(e);e.version>0&&o.__version!==e.version?function(e,s,o){if(6!==s.image.length)return;const l=Q(e,s),h=s.source;i.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+o);const u=n.get(h);if(h.version!==u.__version||!0===l){i.activeTexture(t.TEXTURE0+o),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,s.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,s.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE);const e=s.isCompressedTexture||s.image[0].isCompressedTexture,n=s.image[0]&&s.image[0].isDataTexture,d=[];for(let t=0;t<6;t++)d[t]=e||n?n?s.image[t].image:s.image[t]:O(s.image[t],!1,!0,c),d[t]=rt(s,d[t]);const p=d[0],m=z(p)||a,f=r.convert(s.format,s.encoding),g=r.convert(s.type),y=V(s.internalFormat,f,g,s.encoding),v=a&&!0!==s.isVideoTexture,x=void 0===u.__version||!0===l;let _,b=k(s,p,m);if(K(t.TEXTURE_CUBE_MAP,s,m),e){v&&x&&i.texStorage2D(t.TEXTURE_CUBE_MAP,b,y,p.width,p.height);for(let e=0;e<6;e++){_=d[e].mipmaps;for(let n=0;n<_.length;n++){const r=_[n];s.format!==E?null!==f?v?i.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,r.width,r.height,f,r.data):i.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,y,r.width,r.height,0,r.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):v?i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,r.width,r.height,f,g,r.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,y,r.width,r.height,0,f,g,r.data)}}}else{_=s.mipmaps,v&&x&&(_.length>0&&b++,i.texStorage2D(t.TEXTURE_CUBE_MAP,b,y,d[0].width,d[0].height));for(let e=0;e<6;e++)if(n){v?i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,d[e].width,d[e].height,f,g,d[e].data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,y,d[e].width,d[e].height,0,f,g,d[e].data);for(let n=0;n<_.length;n++){const s=_[n].image[e].image;v?i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,s.width,s.height,f,g,s.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,y,s.width,s.height,0,f,g,s.data)}}else{v?i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,f,g,d[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,y,f,g,d[e]);for(let n=0;n<_.length;n++){const s=_[n];v?i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,f,g,s.image[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,y,f,g,s.image[e])}}}U(s,m)&&H(t.TEXTURE_CUBE_MAP),u.__version=h.version,s.onUpdate&&s.onUpdate(s)}e.__version=s.version}(o,e,s):i.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture,t.TEXTURE0+s)},this.rebindTextures=function(e,i,s){const r=n.get(e);void 0!==i&&tt(r.__webglFramebuffer,e,e.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),void 0!==s&&it(e)},this.setupRenderTarget=function(e){const l=e.texture,c=n.get(e),h=n.get(l);e.addEventListener("dispose",q),!0!==e.isWebGLMultipleRenderTargets&&(void 0===h.__webglTexture&&(h.__webglTexture=t.createTexture()),h.__version=l.version,o.memory.textures++);const u=!0===e.isWebGLCubeRenderTarget,d=!0===e.isWebGLMultipleRenderTargets,p=z(e)||a;if(u){c.__webglFramebuffer=[];for(let e=0;e<6;e++)c.__webglFramebuffer[e]=t.createFramebuffer()}else{if(c.__webglFramebuffer=t.createFramebuffer(),d)if(s.drawBuffers){const i=e.texture;for(let e=0,s=i.length;e0&&!1===st(e)){const n=d?l:[l];c.__webglMultisampledFramebuffer=t.createFramebuffer(),c.__webglColorRenderbuffer=[],i.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer);for(let i=0;i0&&!1===st(e)){const s=e.isWebGLMultipleRenderTargets?e.texture:[e.texture],r=e.width,o=e.height;let a=t.COLOR_BUFFER_BIT;const l=[],c=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,h=n.get(e),u=!0===e.isWebGLMultipleRenderTargets;if(u)for(let e=0;ea+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&o<=a-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==a&&t.gripSpace&&(s=e.getPose(t.gripSpace,i),null!==s&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),s.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(s.linearVelocity)):a.hasLinearVelocity=!1,s.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(s.angularVelocity)):a.hasAngularVelocity=!1));null!==o&&(n=e.getPose(t.targetRaySpace,i),null===n&&null!==s&&(n=s),null!==n&&(o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),n.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(n.linearVelocity)):o.hasLinearVelocity=!1,n.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(n.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Vr)))}return null!==o&&(o.visible=null!==n),null!==a&&(a.visible=null!==s),null!==l&&(l.visible=null!==r),this}}class Gr extends Kt{constructor(t,e,i,n,s,r,o,a,l,c){if((c=void 0!==c?c:T)!==T&&c!==A)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&c===T&&(i=b),void 0===i&&c===A&&(i=S),super(null,n,s,r,o,a,c,i,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=void 0!==o?o:p,this.minFilter=void 0!==a?a:p,this.flipY=!1,this.generateMipmaps=!1}}class Wr extends mt{constructor(t,e){super();const i=this;let n=null,s=1,r=null,o="local-floor",a=null,l=null,c=null,h=null,u=null,d=null;const p=e.getContextAttributes();let m=null,f=null;const g=[],y=[],v=new on;v.layers.enable(1),v.viewport=new Qt;const _=new on;_.layers.enable(2),_.viewport=new Qt;const w=[v,_],M=new Ur;M.layers.enable(1),M.layers.enable(2);let C=null,R=null;function L(t){const e=y.indexOf(t.inputSource);if(-1===e)return;const i=g[e];void 0!==i&&i.dispatchEvent({type:t.type,data:t.inputSource})}function P(){n.removeEventListener("select",L),n.removeEventListener("selectstart",L),n.removeEventListener("selectend",L),n.removeEventListener("squeeze",L),n.removeEventListener("squeezestart",L),n.removeEventListener("squeezeend",L),n.removeEventListener("end",P),n.removeEventListener("inputsourceschange",I);for(let t=0;t=0&&(y[n]=null,g[n].dispatchEvent({type:"disconnected",data:i}))}for(let e=0;e=y.length){y.push(i),n=t;break}if(null===y[t]){y[t]=i,n=t;break}}if(-1===n)break}const s=g[n];s&&s.dispatchEvent({type:"connected",data:i})}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=g[t];return void 0===e&&(e=new kr,g[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=g[t];return void 0===e&&(e=new kr,g[t]=e),e.getGripSpace()},this.getHand=function(t){let e=g[t];return void 0===e&&(e=new kr,g[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){s=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){o=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return a||r},this.setReferenceSpace=function(t){a=t},this.getBaseLayer=function(){return null!==h?h:u},this.getBinding=function(){return c},this.getFrame=function(){return d},this.getSession=function(){return n},this.setSession=async function(l){if(n=l,null!==n){if(m=t.getRenderTarget(),n.addEventListener("select",L),n.addEventListener("selectstart",L),n.addEventListener("selectend",L),n.addEventListener("squeeze",L),n.addEventListener("squeezestart",L),n.addEventListener("squeezeend",L),n.addEventListener("end",P),n.addEventListener("inputsourceschange",I),!0!==p.xrCompatible&&await e.makeXRCompatible(),void 0===n.renderState.layers||!1===t.capabilities.isWebGL2){const i={antialias:void 0!==n.renderState.layers||p.antialias,alpha:p.alpha,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:s};u=new XRWebGLLayer(n,e,i),n.updateRenderState({baseLayer:u}),f=new $t(u.framebufferWidth,u.framebufferHeight,{format:E,type:x,encoding:t.outputEncoding,stencilBuffer:p.stencil})}else{let i=null,r=null,o=null;p.depth&&(o=p.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,i=p.stencil?A:T,r=p.stencil?S:b);const a={colorFormat:e.RGBA8,depthFormat:o,scaleFactor:s};c=new XRWebGLBinding(n,e),h=c.createProjectionLayer(a),n.updateRenderState({layers:[h]}),f=new $t(h.textureWidth,h.textureHeight,{format:E,type:x,depthTexture:new Gr(h.textureWidth,h.textureHeight,r,void 0,void 0,void 0,void 0,void 0,void 0,i),stencilBuffer:p.stencil,encoding:t.outputEncoding,samples:p.antialias?4:0}),t.properties.get(f).__ignoreDepthValues=h.ignoreDepthValues}f.isXRRenderTarget=!0,this.setFoveation(1),a=null,r=await n.requestReferenceSpace(o),O.setContext(n),O.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};const D=new ne,N=new ne;function B(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===n)return;M.near=_.near=v.near=t.near,M.far=_.far=v.far=t.far,C===M.near&&R===M.far||(n.updateRenderState({depthNear:M.near,depthFar:M.far}),C=M.near,R=M.far);const e=t.parent,i=M.cameras;B(M,e);for(let t=0;t0&&(i.alphaTest.value=n.alphaTest);const s=e.get(n).envMap;if(s&&(i.envMap.value=s,i.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,i.reflectivity.value=n.reflectivity,i.ior.value=n.ior,i.refractionRatio.value=n.refractionRatio),n.lightMap){i.lightMap.value=n.lightMap;const e=!0!==t.physicallyCorrectLights?Math.PI:1;i.lightMapIntensity.value=n.lightMapIntensity*e}let r,o;n.aoMap&&(i.aoMap.value=n.aoMap,i.aoMapIntensity.value=n.aoMapIntensity),n.map?r=n.map:n.specularMap?r=n.specularMap:n.displacementMap?r=n.displacementMap:n.normalMap?r=n.normalMap:n.bumpMap?r=n.bumpMap:n.roughnessMap?r=n.roughnessMap:n.metalnessMap?r=n.metalnessMap:n.alphaMap?r=n.alphaMap:n.emissiveMap?r=n.emissiveMap:n.clearcoatMap?r=n.clearcoatMap:n.clearcoatNormalMap?r=n.clearcoatNormalMap:n.clearcoatRoughnessMap?r=n.clearcoatRoughnessMap:n.iridescenceMap?r=n.iridescenceMap:n.iridescenceThicknessMap?r=n.iridescenceThicknessMap:n.specularIntensityMap?r=n.specularIntensityMap:n.specularColorMap?r=n.specularColorMap:n.transmissionMap?r=n.transmissionMap:n.thicknessMap?r=n.thicknessMap:n.sheenColorMap?r=n.sheenColorMap:n.sheenRoughnessMap&&(r=n.sheenRoughnessMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),!0===r.matrixAutoUpdate&&r.updateMatrix(),i.uvTransform.value.copy(r.matrix)),n.aoMap?o=n.aoMap:n.lightMap&&(o=n.lightMap),void 0!==o&&(o.isWebGLRenderTarget&&(o=o.texture),!0===o.matrixAutoUpdate&&o.updateMatrix(),i.uv2Transform.value.copy(o.matrix))}return{refreshFogUniforms:function(t,e){t.fogColor.value.copy(e.color),e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)},refreshMaterialUniforms:function(t,n,s,r,o){n.isMeshBasicMaterial||n.isMeshLambertMaterial?i(t,n):n.isMeshToonMaterial?(i(t,n),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,n)):n.isMeshPhongMaterial?(i(t,n),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,n)):n.isMeshStandardMaterial?(i(t,n),function(t,i){t.roughness.value=i.roughness,t.metalness.value=i.metalness,i.roughnessMap&&(t.roughnessMap.value=i.roughnessMap),i.metalnessMap&&(t.metalnessMap.value=i.metalnessMap);e.get(i).envMap&&(t.envMapIntensity.value=i.envMapIntensity)}(t,n),n.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),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap)),e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap),e.clearcoatNormalMap&&(t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),t.clearcoatNormalMap.value=e.clearcoatNormalMap,1===e.side&&t.clearcoatNormalScale.value.negate())),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),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap)),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),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor)),t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap)}(t,n,o)):n.isMeshMatcapMaterial?(i(t,n),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,n)):n.isMeshDepthMaterial?i(t,n):n.isMeshDistanceMaterial?(i(t,n),function(t,e){t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(t,n)):n.isMeshNormalMaterial?i(t,n):n.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}(t,n),n.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,n)):n.isPointsMaterial?function(t,e,i,n){let s;t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*i,t.scale.value=.5*n,e.map&&(t.map.value=e.map),e.alphaMap&&(t.alphaMap.value=e.alphaMap),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest),e.map?s=e.map:e.alphaMap&&(s=e.alphaMap),void 0!==s&&(!0===s.matrixAutoUpdate&&s.updateMatrix(),t.uvTransform.value.copy(s.matrix))}(t,n,s,r):n.isSpriteMaterial?function(t,e){let i;t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map),e.alphaMap&&(t.alphaMap.value=e.alphaMap),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest),e.map?i=e.map:e.alphaMap&&(i=e.alphaMap),void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),t.uvTransform.value.copy(i.matrix))}(t,n):n.isShadowMaterial?(t.color.value.copy(n.color),t.opacity.value=n.opacity):n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)}}}function jr(t,e,i,n){let s={},r={},o=[];const a=i.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(t,e,i){const n=t.value;if(void 0===i[e])return i[e]="number"==typeof n?n:n.clone(),!0;if("number"==typeof n){if(i[e]!==n)return i[e]=n,!0}else{const t=i[e];if(!1===t.equals(n))return t.copy(n),!0}return!1}function c(t){const e=t.value,i={boundary:0,storage:0};return"number"==typeof e?(i.boundary=4,i.storage=4):e.isVector2?(i.boundary=8,i.storage=8):e.isVector3||e.isColor?(i.boundary=16,i.storage=12):e.isVector4?(i.boundary=16,i.storage=16):e.isMatrix3?(i.boundary=48,i.storage=48):e.isMatrix4?(i.boundary=64,i.storage=64):e.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",e),i}function h(e){const i=e.target;i.removeEventListener("dispose",h);const n=o.indexOf(i.__bindingPointIndex);o.splice(n,1),t.deleteBuffer(s[i.id]),delete s[i.id],delete r[i.id]}return{bind:function(t,e){const i=e.program;n.uniformBlockBinding(t,i)},update:function(i,u){let d=s[i.id];void 0===d&&(function(t){const e=t.uniforms;let i=0;let n=0;for(let t=0,s=e.length;t0&&(n=i%16,0!==n&&16-n-r.boundary<0&&(i+=16-n,s.__offset=i)),i+=r.storage}n=i%16,n>0&&(i+=16-n),t.__size=i,t.__cache={}}(i),d=function(e){const i=function(){for(let t=0;t0&&function(t,e,i){const n=Z.isWebGL2;null===k&&(k=new $t(1,1,{generateMipmaps:!0,type:Y.has("EXT_color_buffer_half_float")?M:x,minFilter:v,samples:n&&!0===o?4:0})),g.getDrawingBufferSize(W),n?k.setSize(W.x,W.y):k.setSize(Et(W.x),Et(W.y));const s=g.getRenderTarget();g.setRenderTarget(k),g.clear();const r=g.toneMapping;g.toneMapping=0,Ft(t,e,i),g.toneMapping=r,$.updateMultisampleRenderTarget(k),$.updateRenderTargetMipmap(k),g.setRenderTarget(s)}(s,e,i),n&&J.viewport(C.copy(n)),s.length>0&&Ft(s,e,i),r.length>0&&Ft(r,e,i),a.length>0&&Ft(a,e,i),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function Ft(t,e,i){const n=!0===e.isScene?e.overrideMaterial:null;for(let s=0,r=t.length;s0?f[f.length-1]:null,m.pop(),d=m.length>0?m[m.length-1]:null},this.getActiveCubeFace=function(){return _},this.getActiveMipmapLevel=function(){return b},this.getRenderTarget=function(){return S},this.setRenderTargetTextures=function(t,e,i){Q.get(t.texture).__webglTexture=e,Q.get(t.depthTexture).__webglTexture=i;const n=Q.get(t);n.__hasExternalTextures=!0,n.__hasExternalTextures&&(n.__autoAllocateDepthBuffer=void 0===i,n.__autoAllocateDepthBuffer||!0===Y.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),n.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(t,e){const i=Q.get(t);i.__webglFramebuffer=e,i.__useDefaultFramebuffer=void 0===e},this.setRenderTarget=function(t,e=0,i=0){S=t,_=e,b=i;let n=!0;if(t){const e=Q.get(t);void 0!==e.__useDefaultFramebuffer?(J.bindFramebuffer(xt.FRAMEBUFFER,null),n=!1):void 0===e.__webglFramebuffer?$.setupRenderTarget(t):e.__hasExternalTextures&&$.rebindTextures(t,Q.get(t.texture).__webglTexture,Q.get(t.depthTexture).__webglTexture)}let s=null,r=!1,o=!1;if(t){const i=t.texture;(i.isData3DTexture||i.isDataArrayTexture)&&(o=!0);const n=Q.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(s=n[e],r=!0):s=Z.isWebGL2&&t.samples>0&&!1===$.useMultisampledRTT(t)?Q.get(t).__webglMultisampledFramebuffer:n,C.copy(t.viewport),R.copy(t.scissor),L=t.scissorTest}else C.copy(F).multiplyScalar(D).floor(),R.copy(O).multiplyScalar(D).floor(),L=z;if(J.bindFramebuffer(xt.FRAMEBUFFER,s)&&Z.drawBuffers&&n&&J.drawBuffers(t,s),J.viewport(C),J.scissor(R),J.setScissorTest(L),r){const n=Q.get(t.texture);xt.framebufferTexture2D(xt.FRAMEBUFFER,xt.COLOR_ATTACHMENT0,xt.TEXTURE_CUBE_MAP_POSITIVE_X+e,n.__webglTexture,i)}else if(o){const n=Q.get(t.texture),s=e||0;xt.framebufferTextureLayer(xt.FRAMEBUFFER,xt.COLOR_ATTACHMENT0,n.__webglTexture,i||0,s)}T=-1},this.readRenderTargetPixels=function(t,e,i,n,s,r,o){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let a=Q.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==o&&(a=a[o]),a){J.bindFramebuffer(xt.FRAMEBUFFER,a);try{const o=t.texture,a=o.format,l=o.type;if(a!==E&>.convert(a)!==xt.getParameter(xt.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===M&&(Y.has("EXT_color_buffer_half_float")||Z.isWebGL2&&Y.has("EXT_color_buffer_float"));if(!(l===x||gt.convert(l)===xt.getParameter(xt.IMPLEMENTATION_COLOR_READ_TYPE)||l===w&&(Z.isWebGL2||Y.has("OES_texture_float")||Y.has("WEBGL_color_buffer_float"))||c))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-n&&i>=0&&i<=t.height-s&&xt.readPixels(e,i,n,s,gt.convert(a),gt.convert(l),r)}finally{const t=null!==S?Q.get(S).__webglFramebuffer:null;J.bindFramebuffer(xt.FRAMEBUFFER,t)}}},this.copyFramebufferToTexture=function(t,e,i=0){const n=Math.pow(2,-i),s=Math.floor(e.image.width*n),r=Math.floor(e.image.height*n);$.setTexture2D(e,0),xt.copyTexSubImage2D(xt.TEXTURE_2D,i,0,0,t.x,t.y,s,r),J.unbindTexture()},this.copyTextureToTexture=function(t,e,i,n=0){const s=e.image.width,r=e.image.height,o=gt.convert(i.format),a=gt.convert(i.type);$.setTexture2D(i,0),xt.pixelStorei(xt.UNPACK_FLIP_Y_WEBGL,i.flipY),xt.pixelStorei(xt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),xt.pixelStorei(xt.UNPACK_ALIGNMENT,i.unpackAlignment),e.isDataTexture?xt.texSubImage2D(xt.TEXTURE_2D,n,t.x,t.y,s,r,o,a,e.image.data):e.isCompressedTexture?xt.compressedTexSubImage2D(xt.TEXTURE_2D,n,t.x,t.y,e.mipmaps[0].width,e.mipmaps[0].height,o,e.mipmaps[0].data):xt.texSubImage2D(xt.TEXTURE_2D,n,t.x,t.y,o,a,e.image),0===n&&i.generateMipmaps&&xt.generateMipmap(xt.TEXTURE_2D),J.unbindTexture()},this.copyTextureToTexture3D=function(t,e,i,n,s=0){if(g.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const r=t.max.x-t.min.x+1,o=t.max.y-t.min.y+1,a=t.max.z-t.min.z+1,l=gt.convert(n.format),c=gt.convert(n.type);let h;if(n.isData3DTexture)$.setTexture3D(n,0),h=xt.TEXTURE_3D;else{if(!n.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");$.setTexture2DArray(n,0),h=xt.TEXTURE_2D_ARRAY}xt.pixelStorei(xt.UNPACK_FLIP_Y_WEBGL,n.flipY),xt.pixelStorei(xt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),xt.pixelStorei(xt.UNPACK_ALIGNMENT,n.unpackAlignment);const u=xt.getParameter(xt.UNPACK_ROW_LENGTH),d=xt.getParameter(xt.UNPACK_IMAGE_HEIGHT),p=xt.getParameter(xt.UNPACK_SKIP_PIXELS),m=xt.getParameter(xt.UNPACK_SKIP_ROWS),f=xt.getParameter(xt.UNPACK_SKIP_IMAGES),y=i.isCompressedTexture?i.mipmaps[0]:i.image;xt.pixelStorei(xt.UNPACK_ROW_LENGTH,y.width),xt.pixelStorei(xt.UNPACK_IMAGE_HEIGHT,y.height),xt.pixelStorei(xt.UNPACK_SKIP_PIXELS,t.min.x),xt.pixelStorei(xt.UNPACK_SKIP_ROWS,t.min.y),xt.pixelStorei(xt.UNPACK_SKIP_IMAGES,t.min.z),i.isDataTexture||i.isData3DTexture?xt.texSubImage3D(h,s,e.x,e.y,e.z,r,o,a,l,c,y.data):i.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),xt.compressedTexSubImage3D(h,s,e.x,e.y,e.z,r,o,a,l,y.data)):xt.texSubImage3D(h,s,e.x,e.y,e.z,r,o,a,l,c,y),xt.pixelStorei(xt.UNPACK_ROW_LENGTH,u),xt.pixelStorei(xt.UNPACK_IMAGE_HEIGHT,d),xt.pixelStorei(xt.UNPACK_SKIP_PIXELS,p),xt.pixelStorei(xt.UNPACK_SKIP_ROWS,m),xt.pixelStorei(xt.UNPACK_SKIP_IMAGES,f),0===s&&n.generateMipmaps&&xt.generateMipmap(h),J.unbindTexture()},this.initTexture=function(t){t.isCubeTexture?$.setTextureCube(t,0):t.isData3DTexture?$.setTexture3D(t,0):t.isDataArrayTexture?$.setTexture2DArray(t,0):$.setTexture2D(t,0),J.unbindTexture()},this.resetState=function(){_=0,b=0,S=null,J.reset(),yt.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class Yr extends Xr{}Yr.prototype.isWebGL1Renderer=!0;class Zr{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new qt(t),this.density=e}clone(){return new Zr(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class Jr{constructor(t,e=1,i=1e3){this.isFog=!0,this.name="",this.color=new qt(t),this.near=e,this.far=i}clone(){return new Jr(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class Kr extends ri{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,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()),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()),e}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(t){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=t}}class Qr{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=ut,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=xt()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}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,i){t*=this.stride,i*=e.stride;for(let n=0,s=this.stride;nt.far||e.push({distance:a,point:no.clone(),uv:gi.getUV(no,co,ho,uo,po,mo,fo,new Rt),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 yo(t,e,i,n,s,r){oo.subVectors(t,i).addScalar(.5).multiply(n),void 0!==s?(ao.x=r*oo.x-s*oo.y,ao.y=s*oo.x+r*oo.y):ao.copy(oo),t.copy(e),t.x+=ao.x,t.y+=ao.y,t.applyMatrix4(lo)}const vo=new ne,xo=new ne;class _o extends ri{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,i=e.length;t0){let i,n;for(i=1,n=e.length;i0){vo.setFromMatrixPosition(this.matrixWorld);const i=t.ray.origin.distanceTo(vo);this.getObjectForDistance(i).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){vo.setFromMatrixPosition(t.matrixWorld),xo.setFromMatrixPosition(this.matrixWorld);const i=vo.distanceTo(xo)/t.zoom;let n,s;for(e[0].object.visible=!0,n=1,s=e.length;n=e[n].distance;n++)e[n-1].object.visible=!1,e[n].object.visible=!0;for(this._currentLevel=n-1;na)continue;u.applyMatrix4(this.matrixWorld);const r=t.ray.origin.distanceTo(u);rt.far||e.push({distance:r,point:h.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}else for(let i=Math.max(0,r.start),n=Math.min(m.count,r.start+r.count)-1;ia)continue;u.applyMatrix4(this.matrixWorld);const n=t.ray.origin.distanceTo(u);nt.far||e.push({distance:n,point:h.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;t0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;ts.far)return;r.push({distance:l,distanceToRay:Math.sqrt(a),point:i,index:e,face:null,object:o})}}class ia extends Kt{constructor(t,e,i,n,s,r,o,a,l,c,h,u){super(null,r,o,a,l,c,n,s,h,u),this.isCompressedTexture=!0,this.image={width:e,height:i},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class na{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){const i=this.getUtoTmapping(t);return this.getPoint(i,e)}getPoints(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return e}getSpacedPoints(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPointAt(i/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 i,n=this.getPoint(0),s=0;e.push(0);for(let r=1;r<=t;r++)i=this.getPoint(r/t),s+=i.distanceTo(n),e.push(s),n=i;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const i=this.getLengths();let n=0;const s=i.length;let r;r=e||t*i[s-1];let o,a=0,l=s-1;for(;a<=l;)if(n=Math.floor(a+(l-a)/2),o=i[n]-r,o<0)a=n+1;else{if(!(o>0)){l=n;break}l=n-1}if(n=l,i[n]===r)return n/(s-1);const c=i[n];return(n+(r-c)/(i[n+1]-c))/(s-1)}getTangent(t,e){const i=1e-4;let n=t-i,s=t+i;n<0&&(n=0),s>1&&(s=1);const r=this.getPoint(n),o=this.getPoint(s),a=e||(r.isVector2?new Rt:new ne);return a.copy(o).sub(r).normalize(),a}getTangentAt(t,e){const i=this.getUtoTmapping(t);return this.getTangent(i,e)}computeFrenetFrames(t,e){const i=new ne,n=[],s=[],r=[],o=new ne,a=new Ne;for(let e=0;e<=t;e++){const i=e/t;n[e]=this.getTangentAt(i,new ne)}s[0]=new ne,r[0]=new ne;let l=Number.MAX_VALUE;const c=Math.abs(n[0].x),h=Math.abs(n[0].y),u=Math.abs(n[0].z);c<=l&&(l=c,i.set(1,0,0)),h<=l&&(l=h,i.set(0,1,0)),u<=l&&i.set(0,0,1),o.crossVectors(n[0],i).normalize(),s[0].crossVectors(n[0],o),r[0].crossVectors(n[0],s[0]);for(let e=1;e<=t;e++){if(s[e]=s[e-1].clone(),r[e]=r[e-1].clone(),o.crossVectors(n[e-1],n[e]),o.length()>Number.EPSILON){o.normalize();const t=Math.acos(_t(n[e-1].dot(n[e]),-1,1));s[e].applyMatrix4(a.makeRotationAxis(o,t))}r[e].crossVectors(n[e],s[e])}if(!0===e){let e=Math.acos(_t(s[0].dot(s[t]),-1,1));e/=t,n[0].dot(o.crossVectors(s[0],s[t]))>0&&(e=-e);for(let i=1;i<=t;i++)s[i].applyMatrix4(a.makeRotationAxis(n[i],e*i)),r[i].crossVectors(n[i],s[i])}return{tangents:n,normals:s,binormals:r}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class sa extends na{constructor(t=0,e=0,i=1,n=1,s=0,r=2*Math.PI,o=!1,a=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=i,this.yRadius=n,this.aStartAngle=s,this.aEndAngle=r,this.aClockwise=o,this.aRotation=a}getPoint(t,e){const i=e||new Rt,n=2*Math.PI;let s=this.aEndAngle-this.aStartAngle;const r=Math.abs(s)n;)s-=n;s0?0:(Math.floor(Math.abs(l)/s)+1)*s:0===c&&l===s-1&&(l=s-2,c=1),this.closed||l>0?o=n[(l-1)%s]:(aa.subVectors(n[0],n[1]).add(n[0]),o=aa);const h=n[l%s],u=n[(l+1)%s];if(this.closed||l+2n.length-2?n.length-1:r+1],h=n[r>n.length-3?n.length-1:r+2];return i.set(da(o,a.x,l.x,c.x,h.x),da(o,a.y,l.y,c.y,h.y)),i}copy(t){super.copy(t),this.points=[];for(let e=0,i=t.points.length;e=i){const t=n[s]-i,r=this.curves[s],o=r.getLength(),a=0===o?0:1-t/o;return r.getPointAt(a,e)}s++}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 i=0,n=this.curves.length;i1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,i=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 Ea extends Di{constructor(t=[new Rt(0,-.5),new Rt(.5,0),new Rt(0,.5)],e=12,i=0,n=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:i,phiLength:n},e=Math.floor(e),n=_t(n,0,2*Math.PI);const s=[],r=[],o=[],a=[],l=[],c=1/e,h=new ne,u=new Rt,d=new ne,p=new ne,m=new ne;let f=0,g=0;for(let e=0;e<=t.length-1;e++)switch(e){case 0:f=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,d.x=1*g,d.y=-f,d.z=0*g,m.copy(d),d.normalize(),a.push(d.x,d.y,d.z);break;case t.length-1:a.push(m.x,m.y,m.z);break;default:f=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,d.x=1*g,d.y=-f,d.z=0*g,p.copy(d),d.x+=m.x,d.y+=m.y,d.z+=m.z,d.normalize(),a.push(d.x,d.y,d.z),m.copy(p)}for(let s=0;s<=e;s++){const d=i+s*c*n,p=Math.sin(d),m=Math.cos(d);for(let i=0;i<=t.length-1;i++){h.x=t[i].x*p,h.y=t[i].y,h.z=t[i].x*m,r.push(h.x,h.y,h.z),u.x=s/e,u.y=i/(t.length-1),o.push(u.x,u.y);const n=a[3*i+0]*p,c=a[3*i+1],d=a[3*i+0]*m;l.push(n,c,d)}}for(let i=0;i0&&y(!0),e>0&&y(!1)),this.setIndex(c),this.setAttribute("position",new Ei(h,3)),this.setAttribute("normal",new Ei(u,3)),this.setAttribute("uv",new Ei(d,2))}static fromJSON(t){return new Ca(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Ra extends Ca{constructor(t=1,e=1,i=8,n=1,s=!1,r=0,o=2*Math.PI){super(0,t,e,i,n,s,r,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:n,openEnded:s,thetaStart:r,thetaLength:o}}static fromJSON(t){return new Ra(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class La extends Di{constructor(t=[],e=[],i=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:n};const s=[],r=[];function o(t,e,i,n){const s=n+1,r=[];for(let n=0;n<=s;n++){r[n]=[];const o=t.clone().lerp(i,n/s),a=e.clone().lerp(i,n/s),l=s-n;for(let t=0;t<=l;t++)r[n][t]=0===t&&n===s?o:o.clone().lerp(a,t/l)}for(let t=0;t.9&&o<.1&&(e<.2&&(r[t+0]+=1),i<.2&&(r[t+2]+=1),n<.2&&(r[t+4]+=1))}}()}(),this.setAttribute("position",new Ei(s,3)),this.setAttribute("normal",new Ei(s.slice(),3)),this.setAttribute("uv",new Ei(r,2)),0===n?this.computeVertexNormals():this.normalizeNormals()}static fromJSON(t){return new La(t.vertices,t.indices,t.radius,t.details)}}class Pa extends La{constructor(t=1,e=0){const i=(1+Math.sqrt(5))/2,n=1/i;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,-n,-i,0,-n,i,0,n,-i,0,n,i,-n,-i,0,-n,i,0,n,-i,0,n,i,0,-i,0,-n,i,0,-n,-i,0,n,i,0,n],[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 Pa(t.radius,t.detail)}}const Ia=new ne,Da=new ne,Na=new ne,Ba=new gi;class Fa extends Di{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},null!==t){const i=4,n=Math.pow(10,i),s=Math.cos(yt*e),r=t.getIndex(),o=t.getAttribute("position"),a=r?r.count:o.count,l=[0,0,0],c=["a","b","c"],h=new Array(3),u={},d=[];for(let t=0;t0)for(r=e;r=e;r-=n)o=rl(r,t[r],t[r+1],o);return o&&$a(o,o.next)&&(ol(o),o=o.next),o}function Ua(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!$a(n,n.next)&&0!==Qa(n.prev,n,n.next))n=n.next;else{if(ol(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function Ha(t,e,i,n,s,r,o){if(!t)return;!o&&r&&function(t,e,i,n){let s=t;do{null===s.z&&(s.z=Ya(s.x,s.y,e,i,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){let e,i,n,s,r,o,a,l,c=1;do{for(i=t,t=null,r=null,o=0;i;){for(o++,n=i,a=0,e=0;e0||l>0&&n;)0!==a&&(0===l||!n||i.z<=n.z)?(s=i,i=i.nextZ,a--):(s=n,n=n.nextZ,l--),r?r.nextZ=s:t=s,s.prevZ=r,r=s;i=n}r.nextZ=null,c*=2}while(o>1)}(s)}(t,n,s,r);let a,l,c=t;for(;t.prev!==t.next;)if(a=t.prev,l=t.next,r?ka(t,n,s,r):Va(t))e.push(a.i/i),e.push(t.i/i),e.push(l.i/i),ol(t),t=l.next,c=l.next;else if((t=l)===c){o?1===o?Ha(t=Ga(Ua(t),e,i),e,i,n,s,r,2):2===o&&Wa(t,e,i,n,s,r):Ha(Ua(t),e,i,n,s,r,1);break}}function Va(t){const e=t.prev,i=t,n=t.next;if(Qa(e,i,n)>=0)return!1;let s=t.next.next;for(;s!==t.prev;){if(Ja(e.x,e.y,i.x,i.y,n.x,n.y,s.x,s.y)&&Qa(s.prev,s,s.next)>=0)return!1;s=s.next}return!0}function ka(t,e,i,n){const s=t.prev,r=t,o=t.next;if(Qa(s,r,o)>=0)return!1;const a=s.xr.x?s.x>o.x?s.x:o.x:r.x>o.x?r.x:o.x,h=s.y>r.y?s.y>o.y?s.y:o.y:r.y>o.y?r.y:o.y,u=Ya(a,l,e,i,n),d=Ya(c,h,e,i,n);let p=t.prevZ,m=t.nextZ;for(;p&&p.z>=u&&m&&m.z<=d;){if(p!==t.prev&&p!==t.next&&Ja(s.x,s.y,r.x,r.y,o.x,o.y,p.x,p.y)&&Qa(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,m!==t.prev&&m!==t.next&&Ja(s.x,s.y,r.x,r.y,o.x,o.y,m.x,m.y)&&Qa(m.prev,m,m.next)>=0)return!1;m=m.nextZ}for(;p&&p.z>=u;){if(p!==t.prev&&p!==t.next&&Ja(s.x,s.y,r.x,r.y,o.x,o.y,p.x,p.y)&&Qa(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;m&&m.z<=d;){if(m!==t.prev&&m!==t.next&&Ja(s.x,s.y,r.x,r.y,o.x,o.y,m.x,m.y)&&Qa(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function Ga(t,e,i){let n=t;do{const s=n.prev,r=n.next.next;!$a(s,r)&&tl(s,n,n.next,r)&&nl(s,r)&&nl(r,s)&&(e.push(s.i/i),e.push(n.i/i),e.push(r.i/i),ol(n),ol(n.next),n=t=r),n=n.next}while(n!==t);return Ua(n)}function Wa(t,e,i,n,s,r){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&Ka(o,t)){let a=sl(o,t);return o=Ua(o,o.next),a=Ua(a,a.next),Ha(o,e,i,n,s,r),void Ha(a,e,i,n,s,r)}t=t.next}o=o.next}while(o!==t)}function qa(t,e){return t.x-e.x}function ja(t,e){if(e=function(t,e){let i=e;const n=t.x,s=t.y;let r,o=-1/0;do{if(s<=i.y&&s>=i.next.y&&i.next.y!==i.y){const t=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=n&&t>o){if(o=t,t===n){if(s===i.y)return i;if(s===i.next.y)return i.next}r=i.x=i.x&&i.x>=l&&n!==i.x&&Ja(sr.x||i.x===r.x&&Xa(r,i)))&&(r=i,u=h)),i=i.next}while(i!==a);return r}(t,e),e){const i=sl(e,t);Ua(e,e.next),Ua(i,i.next)}}function Xa(t,e){return Qa(t.prev,t,e.prev)<0&&Qa(e.next,t,t.next)<0}function Ya(t,e,i,n,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*s)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*s)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Za(t){let e=t,i=t;do{(e.x=0&&(t-o)*(n-a)-(i-o)*(e-a)>=0&&(i-o)*(r-a)-(s-o)*(n-a)>=0}function Ka(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&tl(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(nl(t,e)&&nl(e,t)&&function(t,e){let i=t,n=!1;const s=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&s<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)&&(Qa(t.prev,t,e.prev)||Qa(t,e.prev,e))||$a(t,e)&&Qa(t.prev,t,t.next)>0&&Qa(e.prev,e,e.next)>0)}function Qa(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function $a(t,e){return t.x===e.x&&t.y===e.y}function tl(t,e,i,n){const s=il(Qa(t,e,i)),r=il(Qa(t,e,n)),o=il(Qa(i,n,t)),a=il(Qa(i,n,e));return s!==r&&o!==a||!(0!==s||!el(t,i,e))||!(0!==r||!el(t,n,e))||!(0!==o||!el(i,t,n))||!(0!==a||!el(i,e,n))}function el(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function il(t){return t>0?1:t<0?-1:0}function nl(t,e){return Qa(t.prev,t,t.next)<0?Qa(t,e,t.next)>=0&&Qa(t,t.prev,e)>=0:Qa(t,e,t.prev)<0||Qa(t,t.next,e)<0}function sl(t,e){const i=new al(t.i,t.x,t.y),n=new al(e.i,e.x,e.y),s=t.next,r=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,n.next=i,i.prev=n,r.next=n,n.prev=r,n}function rl(t,e,i,n){const s=new al(t,e,i);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function ol(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 al(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}class ll{static area(t){const e=t.length;let i=0;for(let n=e-1,s=0;s80*i){a=c=t[0],l=h=t[1];for(let e=i;ec&&(c=u),d>h&&(h=d);p=Math.max(c-a,h-l),p=0!==p?1/p:0}return Ha(r,o,i,a,l,p),o}(i,n);for(let t=0;t2&&t[e-1].equals(t[0])&&t.pop()}function hl(t,e){for(let i=0;iNumber.EPSILON){const u=Math.sqrt(h),d=Math.sqrt(l*l+c*c),p=e.x-a/u,m=e.y+o/u,f=((i.x-c/d-p)*c-(i.y+l/d-m)*l)/(o*c-a*l);n=p+o*f-t.x,s=m+a*f-t.y;const g=n*n+s*s;if(g<=2)return new Rt(n,s);r=Math.sqrt(g/2)}else{let t=!1;o>Number.EPSILON?l>Number.EPSILON&&(t=!0):o<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(a)===Math.sign(c)&&(t=!0),t?(n=-a,s=o,r=Math.sqrt(h)):(n=o,s=a,r=Math.sqrt(h/2))}return new Rt(n/r,s/r)}const P=[];for(let t=0,e=T.length,i=e-1,n=t+1;t=0;t--){const e=t/p,i=h*Math.cos(e*Math.PI/2),n=u*Math.sin(e*Math.PI/2)+d;for(let t=0,e=T.length;t=0;){const n=i;let s=i-1;s<0&&(s=t.length-1);for(let t=0,i=a+2*p;t0)&&d.push(e,s,l),(t!==i-1||a0!=t>0&&this.version++,this._sheen=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 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.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.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 Rl extends vi{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new qt(16777215),this.specular=new qt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Rt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,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.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 Ll extends vi{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new qt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Rt(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 Pl extends vi{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Rt(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 Il extends vi{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new qt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Rt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,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.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 Dl extends vi{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new qt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Rt(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 Nl extends zo{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 Bl(t,e,i){return Ol(t)?new t.constructor(t.subarray(e,void 0!==i?i:t.length)):t.slice(e,i)}function Fl(t,e,i){return!t||!i&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)}function Ol(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function zl(t){const e=t.length,i=new Array(e);for(let t=0;t!==e;++t)i[t]=t;return i.sort((function(e,i){return t[e]-t[i]})),i}function Ul(t,e,i){const n=t.length,s=new t.constructor(n);for(let r=0,o=0;o!==n;++r){const n=i[r]*e;for(let i=0;i!==e;++i)s[o++]=t[n+i]}return s}function Hl(t,e,i,n){let s=1,r=t[0];for(;void 0!==r&&void 0===r[n];)r=t[s++];if(void 0===r)return;let o=r[n];if(void 0!==o)if(Array.isArray(o))do{o=r[n],void 0!==o&&(e.push(r.time),i.push.apply(i,o)),r=t[s++]}while(void 0!==r);else if(void 0!==o.toArray)do{o=r[n],void 0!==o&&(e.push(r.time),o.toArray(i,i.length)),r=t[s++]}while(void 0!==r);else do{o=r[n],void 0!==o&&(e.push(r.time),i.push(o)),r=t[s++]}while(void 0!==r)}var Vl=Object.freeze({__proto__:null,arraySlice:Bl,convertArray:Fl,isTypedArray:Ol,getKeyframeOrder:zl,sortedArray:Ul,flattenJSON:Hl,subclip:function(t,e,i,n,s=30){const r=t.clone();r.name=e;const o=[];for(let t=0;t=n)){l.push(e.times[t]);for(let i=0;ir.tracks[t].times[0]&&(a=r.tracks[t].times[0]);for(let t=0;t=n.times[u]){const t=u*l+a,e=t+l-a;d=Bl(n.values,t,e)}else{const t=n.createInterpolant(),e=a,i=l-a;t.evaluate(r),d=Bl(t.resultBuffer,e,i)}"quaternion"===s&&(new ie).fromArray(d).normalize().conjugate().toArray(d);const p=o.times.length;for(let t=0;t=s)break t;{const o=e[1];t=s)break e}r=i,i=0}}for(;i>>1;te;)--r;if(++r,0!==s||r!==n){s>=r&&(r=Math.max(r,1),s=r-1);const t=this.getValueSize();this.times=Bl(i,s,r),this.values=Bl(this.values,s*t,r*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 i=this.times,n=this.values,s=i.length;0===s&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let r=null;for(let e=0;e!==s;e++){const n=i[e];if("number"==typeof n&&isNaN(n)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,n),t=!1;break}if(null!==r&&r>n){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,n,r),t=!1;break}r=n}if(void 0!==n&&Ol(n))for(let e=0,i=n.length;e!==i;++e){const i=n[e];if(isNaN(i)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,i),t=!1;break}}return t}optimize(){const t=Bl(this.times),e=Bl(this.values),i=this.getValueSize(),n=this.getInterpolation()===et,s=t.length-1;let r=1;for(let o=1;o0){t[r]=t[s];for(let t=s*i,n=r*i,o=0;o!==i;++o)e[n+o]=e[t+o];++r}return r!==t.length?(this.times=Bl(t,0,r),this.values=Bl(e,0,r*i)):(this.times=t,this.values=e),this}clone(){const t=Bl(this.times,0),e=Bl(this.values,0),i=new(0,this.constructor)(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}jl.prototype.TimeBufferType=Float32Array,jl.prototype.ValueBufferType=Float32Array,jl.prototype.DefaultInterpolation=tt;class Xl extends jl{}Xl.prototype.ValueTypeName="bool",Xl.prototype.ValueBufferType=Array,Xl.prototype.DefaultInterpolation=$,Xl.prototype.InterpolantFactoryMethodLinear=void 0,Xl.prototype.InterpolantFactoryMethodSmooth=void 0;class Yl extends jl{}Yl.prototype.ValueTypeName="color";class Zl extends jl{}Zl.prototype.ValueTypeName="number";class Jl extends kl{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t,e,i,n){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,a=(i-e)/(n-e);let l=t*o;for(let t=l+o;l!==t;l+=4)ie.slerpFlat(s,0,r,l-o,r,l,a);return s}}class Kl extends jl{InterpolantFactoryMethodLinear(t){return new Jl(this.times,this.values,this.getValueSize(),t)}}Kl.prototype.ValueTypeName="quaternion",Kl.prototype.DefaultInterpolation=tt,Kl.prototype.InterpolantFactoryMethodSmooth=void 0;class Ql extends jl{}Ql.prototype.ValueTypeName="string",Ql.prototype.ValueBufferType=Array,Ql.prototype.DefaultInterpolation=$,Ql.prototype.InterpolantFactoryMethodLinear=void 0,Ql.prototype.InterpolantFactoryMethodSmooth=void 0;class $l extends jl{}$l.prototype.ValueTypeName="vector";class tc{constructor(t,e=-1,i,n=2500){this.name=t,this.tracks=i,this.duration=e,this.blendMode=n,this.uuid=xt(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],i=t.tracks,n=1/(t.fps||1);for(let t=0,s=i.length;t!==s;++t)e.push(ec(i[t]).scale(n));const s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){const e=[],i=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,n=i.length;t!==n;++t)e.push(jl.toJSON(i[t]));return n}static CreateFromMorphTargetSequence(t,e,i,n){const s=e.length,r=[];for(let t=0;t1){const t=r[1];let e=n[t];e||(n[t]=e=[]),e.push(i)}}const r=[];for(const t in n)r.push(this.CreateFromMorphTargetSequence(t,n[t],e,i));return r}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(t,e,i,n,s){if(0!==i.length){const r=[],o=[];Hl(i,r,o,n),0!==r.length&&s.push(new t(e,r,o))}},n=[],s=t.name||"default",r=t.fps||30,o=t.blendMode;let a=t.length||-1;const l=t.hierarchy||[];for(let t=0;t{e&&e(s),this.manager.itemEnd(t)}),0),s;if(void 0!==oc[t])return void oc[t].push({onLoad:e,onProgress:i,onError:n});oc[t]=[],oc[t].push({onLoad:e,onProgress:i,onError:n});const r=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,a=this.responseType;fetch(r).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 i=oc[t],n=e.body.getReader(),s=e.headers.get("Content-Length"),r=s?parseInt(s):0,o=0!==r;let a=0;const l=new ReadableStream({start(t){!function e(){n.read().then((({done:n,value:s})=>{if(n)t.close();else{a+=s.byteLength;const n=new ProgressEvent("progress",{lengthComputable:o,loaded:a,total:r});for(let t=0,e=i.length;t{switch(a){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then((t=>(new DOMParser).parseFromString(t,o)));case"json":return t.json();default:if(void 0===o)return t.text();{const e=/charset="?([^;"\s]*)"?/i.exec(o),i=e&&e[1]?e[1].toLowerCase():void 0,n=new TextDecoder(i);return t.arrayBuffer().then((t=>n.decode(t)))}}})).then((e=>{ic.add(t,e);const i=oc[t];delete oc[t];for(let t=0,n=i.length;t{const i=oc[t];if(void 0===i)throw this.manager.itemError(t),e;delete oc[t];for(let t=0,n=i.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 cc extends rc{constructor(t){super(t)}load(t,e,i,n){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,r=ic.get(t);if(void 0!==r)return s.manager.itemStart(t),setTimeout((function(){e&&e(r),s.manager.itemEnd(t)}),0),r;const o=Nt("img");function a(){c(),ic.add(t,this),e&&e(this),s.manager.itemEnd(t)}function l(e){c(),n&&n(e),s.manager.itemError(t),s.manager.itemEnd(t)}function c(){o.removeEventListener("load",a,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",a,!1),o.addEventListener("error",l,!1),"data:"!==t.slice(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),s.manager.itemStart(t),o.src=t,o}}class hc extends ri{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new qt(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}class uc extends hc{constructor(t,e,i){super(t,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ri.DefaultUp),this.updateMatrix(),this.groundColor=new qt(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}}const dc=new Ne,pc=new ne,mc=new ne;class fc{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Rt(512,512),this.map=null,this.mapPass=null,this.matrix=new Ne,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new yn,this._frameExtents=new Rt(1,1),this._viewportCount=1,this._viewports=[new Qt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,i=this.matrix;pc.setFromMatrixPosition(t.matrixWorld),e.position.copy(pc),mc.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(mc),e.updateMatrixWorld(),dc.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(dc),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(dc)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const t={};return 0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class gc extends fc{constructor(){super(new on(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){const e=this.camera,i=2*vt*t.angle*this.focus,n=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;i===e.fov&&n===e.aspect&&s===e.far||(e.fov=i,e.aspect=n,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class yc extends hc{constructor(t,e,i=0,n=Math.PI/3,s=0,r=1){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ri.DefaultUp),this.updateMatrix(),this.target=new ri,this.distance=i,this.angle=n,this.penumbra=s,this.decay=r,this.map=null,this.shadow=new gc}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}const vc=new Ne,xc=new ne,_c=new ne;class bc extends fc{constructor(){super(new on(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Rt(4,2),this._viewportCount=6,this._viewports=[new Qt(2,1,1,1),new Qt(0,1,1,1),new Qt(3,1,1,1),new Qt(1,1,1,1),new Qt(3,0,1,1),new Qt(1,0,1,1)],this._cubeDirections=[new ne(1,0,0),new ne(-1,0,0),new ne(0,0,1),new ne(0,0,-1),new ne(0,1,0),new ne(0,-1,0)],this._cubeUps=[new ne(0,1,0),new ne(0,1,0),new ne(0,1,0),new ne(0,1,0),new ne(0,0,1),new ne(0,0,-1)]}updateMatrices(t,e=0){const i=this.camera,n=this.matrix,s=t.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),xc.setFromMatrixPosition(t.matrixWorld),i.position.copy(xc),_c.copy(i.position),_c.add(this._cubeDirections[e]),i.up.copy(this._cubeUps[e]),i.lookAt(_c),i.updateMatrixWorld(),n.makeTranslation(-xc.x,-xc.y,-xc.z),vc.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(vc)}}class wc extends hc{constructor(t,e,i=0,n=1){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new bc}get power(){return 4*this.intensity*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class Mc extends fc{constructor(){super(new Ln(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Sc extends hc{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ri.DefaultUp),this.updateMatrix(),this.target=new ri,this.shadow=new Mc}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class Ec extends hc{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class Tc extends hc{constructor(t,e,i=10,n=10){super(t,e),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=n}get power(){return this.intensity*this.width*this.height*Math.PI}set power(t){this.intensity=t/(this.width*this.height*Math.PI)}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){const e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}}class Ac{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new ne)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const i=t.x,n=t.y,s=t.z,r=this.coefficients;return e.copy(r[0]).multiplyScalar(.282095),e.addScaledVector(r[1],.488603*n),e.addScaledVector(r[2],.488603*s),e.addScaledVector(r[3],.488603*i),e.addScaledVector(r[4],i*n*1.092548),e.addScaledVector(r[5],n*s*1.092548),e.addScaledVector(r[6],.315392*(3*s*s-1)),e.addScaledVector(r[7],i*s*1.092548),e.addScaledVector(r[8],.546274*(i*i-n*n)),e}getIrradianceAt(t,e){const i=t.x,n=t.y,s=t.z,r=this.coefficients;return e.copy(r[0]).multiplyScalar(.886227),e.addScaledVector(r[1],1.023328*n),e.addScaledVector(r[2],1.023328*s),e.addScaledVector(r[3],1.023328*i),e.addScaledVector(r[4],.858086*i*n),e.addScaledVector(r[5],.858086*n*s),e.addScaledVector(r[6],.743125*s*s-.247708),e.addScaledVector(r[7],.858086*i*s),e.addScaledVector(r[8],.429043*(i*i-n*n)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(t.coefficients[i],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let i=0;i<9;i++)this.coefficients[i].lerp(t.coefficients[i],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(t,e=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].fromArray(t,e+3*n);return this}toArray(t=[],e=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].toArray(t,e+3*n);return t}static getBasisAt(t,e){const i=t.x,n=t.y,s=t.z;e[0]=.282095,e[1]=.488603*n,e[2]=.488603*s,e[3]=.488603*i,e[4]=1.092548*i*n,e[5]=1.092548*n*s,e[6]=.315392*(3*s*s-1),e[7]=1.092548*i*s,e[8]=.546274*(i*i-n*n)}}class Cc extends hc{constructor(t=new Ac,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}fromJSON(t){return this.intensity=t.intensity,this.sh.fromArray(t.sh),this}toJSON(t){const e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}}class Rc extends rc{constructor(t){super(t),this.textures={}}load(t,e,i,n){const s=this,r=new lc(s.manager);r.setPath(s.path),r.setRequestHeader(s.requestHeader),r.setWithCredentials(s.withCredentials),r.load(t,(function(i){try{e(s.parse(JSON.parse(i)))}catch(e){n?n(e):console.error(e),s.manager.itemError(t)}}),i,n)}parse(t){const e=this.textures;function i(t){return void 0===e[t]&&console.warn("THREE.MaterialLoader: Undefined texture",t),e[t]}const n=Rc.createMaterialFromType(t.type);if(void 0!==t.uuid&&(n.uuid=t.uuid),void 0!==t.name&&(n.name=t.name),void 0!==t.color&&void 0!==n.color&&n.color.setHex(t.color),void 0!==t.roughness&&(n.roughness=t.roughness),void 0!==t.metalness&&(n.metalness=t.metalness),void 0!==t.sheen&&(n.sheen=t.sheen),void 0!==t.sheenColor&&(n.sheenColor=(new qt).setHex(t.sheenColor)),void 0!==t.sheenRoughness&&(n.sheenRoughness=t.sheenRoughness),void 0!==t.emissive&&void 0!==n.emissive&&n.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==n.specular&&n.specular.setHex(t.specular),void 0!==t.specularIntensity&&(n.specularIntensity=t.specularIntensity),void 0!==t.specularColor&&void 0!==n.specularColor&&n.specularColor.setHex(t.specularColor),void 0!==t.shininess&&(n.shininess=t.shininess),void 0!==t.clearcoat&&(n.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(n.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.iridescence&&(n.iridescence=t.iridescence),void 0!==t.iridescenceIOR&&(n.iridescenceIOR=t.iridescenceIOR),void 0!==t.iridescenceThicknessRange&&(n.iridescenceThicknessRange=t.iridescenceThicknessRange),void 0!==t.transmission&&(n.transmission=t.transmission),void 0!==t.thickness&&(n.thickness=t.thickness),void 0!==t.attenuationDistance&&(n.attenuationDistance=t.attenuationDistance),void 0!==t.attenuationColor&&void 0!==n.attenuationColor&&n.attenuationColor.setHex(t.attenuationColor),void 0!==t.fog&&(n.fog=t.fog),void 0!==t.flatShading&&(n.flatShading=t.flatShading),void 0!==t.blending&&(n.blending=t.blending),void 0!==t.combine&&(n.combine=t.combine),void 0!==t.side&&(n.side=t.side),void 0!==t.shadowSide&&(n.shadowSide=t.shadowSide),void 0!==t.opacity&&(n.opacity=t.opacity),void 0!==t.transparent&&(n.transparent=t.transparent),void 0!==t.alphaTest&&(n.alphaTest=t.alphaTest),void 0!==t.depthTest&&(n.depthTest=t.depthTest),void 0!==t.depthWrite&&(n.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(n.colorWrite=t.colorWrite),void 0!==t.stencilWrite&&(n.stencilWrite=t.stencilWrite),void 0!==t.stencilWriteMask&&(n.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(n.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(n.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(n.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(n.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(n.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(n.stencilZPass=t.stencilZPass),void 0!==t.wireframe&&(n.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(n.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(n.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(n.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(n.rotation=t.rotation),1!==t.linewidth&&(n.linewidth=t.linewidth),void 0!==t.dashSize&&(n.dashSize=t.dashSize),void 0!==t.gapSize&&(n.gapSize=t.gapSize),void 0!==t.scale&&(n.scale=t.scale),void 0!==t.polygonOffset&&(n.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(n.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(n.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.dithering&&(n.dithering=t.dithering),void 0!==t.alphaToCoverage&&(n.alphaToCoverage=t.alphaToCoverage),void 0!==t.premultipliedAlpha&&(n.premultipliedAlpha=t.premultipliedAlpha),void 0!==t.visible&&(n.visible=t.visible),void 0!==t.toneMapped&&(n.toneMapped=t.toneMapped),void 0!==t.userData&&(n.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?n.vertexColors=t.vertexColors>0:n.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const s=t.uniforms[e];switch(n.uniforms[e]={},s.type){case"t":n.uniforms[e].value=i(s.value);break;case"c":n.uniforms[e].value=(new qt).setHex(s.value);break;case"v2":n.uniforms[e].value=(new Rt).fromArray(s.value);break;case"v3":n.uniforms[e].value=(new ne).fromArray(s.value);break;case"v4":n.uniforms[e].value=(new Qt).fromArray(s.value);break;case"m3":n.uniforms[e].value=(new Lt).fromArray(s.value);break;case"m4":n.uniforms[e].value=(new Ne).fromArray(s.value);break;default:n.uniforms[e].value=s.value}}if(void 0!==t.defines&&(n.defines=t.defines),void 0!==t.vertexShader&&(n.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(n.fragmentShader=t.fragmentShader),void 0!==t.glslVersion&&(n.glslVersion=t.glslVersion),void 0!==t.extensions)for(const e in t.extensions)n.extensions[e]=t.extensions[e];if(void 0!==t.size&&(n.size=t.size),void 0!==t.sizeAttenuation&&(n.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(n.map=i(t.map)),void 0!==t.matcap&&(n.matcap=i(t.matcap)),void 0!==t.alphaMap&&(n.alphaMap=i(t.alphaMap)),void 0!==t.bumpMap&&(n.bumpMap=i(t.bumpMap)),void 0!==t.bumpScale&&(n.bumpScale=t.bumpScale),void 0!==t.normalMap&&(n.normalMap=i(t.normalMap)),void 0!==t.normalMapType&&(n.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),n.normalScale=(new Rt).fromArray(e)}return void 0!==t.displacementMap&&(n.displacementMap=i(t.displacementMap)),void 0!==t.displacementScale&&(n.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(n.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(n.roughnessMap=i(t.roughnessMap)),void 0!==t.metalnessMap&&(n.metalnessMap=i(t.metalnessMap)),void 0!==t.emissiveMap&&(n.emissiveMap=i(t.emissiveMap)),void 0!==t.emissiveIntensity&&(n.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(n.specularMap=i(t.specularMap)),void 0!==t.specularIntensityMap&&(n.specularIntensityMap=i(t.specularIntensityMap)),void 0!==t.specularColorMap&&(n.specularColorMap=i(t.specularColorMap)),void 0!==t.envMap&&(n.envMap=i(t.envMap)),void 0!==t.envMapIntensity&&(n.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(n.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(n.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(n.lightMap=i(t.lightMap)),void 0!==t.lightMapIntensity&&(n.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(n.aoMap=i(t.aoMap)),void 0!==t.aoMapIntensity&&(n.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(n.gradientMap=i(t.gradientMap)),void 0!==t.clearcoatMap&&(n.clearcoatMap=i(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(n.clearcoatRoughnessMap=i(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(n.clearcoatNormalMap=i(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(n.clearcoatNormalScale=(new Rt).fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(n.iridescenceMap=i(t.iridescenceMap)),void 0!==t.iridescenceThicknessMap&&(n.iridescenceThicknessMap=i(t.iridescenceThicknessMap)),void 0!==t.transmissionMap&&(n.transmissionMap=i(t.transmissionMap)),void 0!==t.thicknessMap&&(n.thicknessMap=i(t.thicknessMap)),void 0!==t.sheenColorMap&&(n.sheenColorMap=i(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(n.sheenRoughnessMap=i(t.sheenRoughnessMap)),n}setTextures(t){return this.textures=t,this}static createMaterialFromType(t){return new{ShadowMaterial:El,SpriteMaterial:eo,RawShaderMaterial:Tl,ShaderMaterial:sn,PointsMaterial:Zo,MeshPhysicalMaterial:Cl,MeshStandardMaterial:Al,MeshPhongMaterial:Rl,MeshToonMaterial:Ll,MeshNormalMaterial:Pl,MeshLambertMaterial:Il,MeshDepthMaterial:Dr,MeshDistanceMaterial:Nr,MeshBasicMaterial:xi,MeshMatcapMaterial:Dl,LineDashedMaterial:Nl,LineBasicMaterial:zo,Material:vi}[t]}}class Lc{static decodeText(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let i=0,n=t.length;i0){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(i,n,this._addIndex*e,1,e);for(let t=e,s=e+e;t!==s;++t)if(i[t]!==i[t+e]){o.setValue(i,n);break}}saveOriginalState(){const t=this.binding,e=this.buffer,i=this.valueSize,n=i*this._origIndex;t.getValue(e,n);for(let t=i,s=n;t!==s;++t)e[t]=e[n+t%i];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 i=t;i=.5)for(let n=0;n!==s;++n)t[e+n]=t[i+n]}_slerp(t,e,i,n){ie.slerpFlat(t,e,t,e,t,i,n)}_slerpAdditive(t,e,i,n,s){const r=this._workIndex*s;ie.multiplyQuaternionsFlat(t,r,t,e,t,i),ie.slerpFlat(t,e,t,e,t,r,n)}_lerp(t,e,i,n,s){const r=1-n;for(let o=0;o!==s;++o){const s=e+o;t[s]=t[s]*r+t[i+o]*n}}_lerpAdditive(t,e,i,n,s){for(let r=0;r!==s;++r){const s=e+r;t[s]=t[s]+t[i+r]*n}}}const $c="\\[\\]\\.:\\/",th=new RegExp("["+$c+"]","g"),eh="[^"+$c+"]",ih="[^"+$c.replace("\\.","")+"]",nh=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",eh)+/(WCOD+)?/.source.replace("WCOD",ih)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",eh)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",eh)+"$"),sh=["material","materials","bones","map"];class rh{constructor(t,e,i){this.path=e,this.parsedPath=i||rh.parseTrackName(e),this.node=rh.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,i){return t&&t.isAnimationObjectGroup?new rh.Composite(t,e,i):new rh(t,e,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(th,"")}static parseTrackName(t){const e=nh.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){const t=i.nodeName.substring(n+1);-1!==sh.indexOf(t)&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=t)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return i}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const i=t.skeleton.getBoneByName(e);if(void 0!==i)return i}if(t.children){const i=function(t){for(let n=0;n0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===rt)for(let i=0,n=t.length;i!==n;++i)t[i].evaluate(r),e[i].accumulateAdditive(o);else for(let i=0,s=t.length;i!==s;++i)t[i].evaluate(r),e[i].accumulate(n,o)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const i=this._weightInterpolant;if(null!==i){const n=i.evaluate(t)[0];e*=n,t>i.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const i=this._timeScaleInterpolant;null!==i&&(e*=i.evaluate(t)[0],t>i.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e))}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,i=this.loop;let n=this.time+t,s=this._loopCount;const r=2202===i;if(0===t)return-1===s?n:r&&1==(1&s)?e-n:n;if(2200===i){-1===s&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(n>=e)n=e;else{if(!(n<0)){this.time=n;break t}n=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===s&&(t>=0?(s=0,this._setEndings(!0,0===this.repetitions,r)):this._setEndings(0===this.repetitions,!0,r)),n>=e||n<0){const i=Math.floor(n/e);n-=e*i,s+=Math.abs(i);const o=this.repetitions-s;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=t>0?e:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===o){const e=t<0;this._setEndings(e,!e,r)}else this._setEndings(!1,!1,r);this._loopCount=s,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=n;if(r&&1==(1&s))return e-n}return n}_setEndings(t,e,i){const n=this._interpolantSettings;i?(n.endingStart=nt,n.endingEnd=nt):(n.endingStart=t?this.zeroSlopeAtStart?nt:it:st,n.endingEnd=e?this.zeroSlopeAtEnd?nt:it:st)}_scheduleFading(t,e,i){const n=this._mixer,s=n.time;let r=this._weightInterpolant;null===r&&(r=n._lendControlInterpolant(),this._weightInterpolant=r);const o=r.parameterPositions,a=r.sampleValues;return o[0]=s,a[0]=e,o[1]=s+t,a[1]=i,this}}const ah=new Float32Array(1);class lh{constructor(t){this.value=t}clone(){return new lh(void 0===this.value.clone?this.value:this.value.clone())}}let ch=0;function hh(t,e){return t.distance-e.distance}function uh(t,e,i,n){if(t.layers.test(e.layers)&&t.raycast(e,i),!0===n){const n=t.children;for(let t=0,s=n.length;t>-e-14,n[256|t]=1024>>-e-14|32768,s[t]=-e-1,s[256|t]=-e-1):e<=15?(n[t]=e+15<<10,n[256|t]=e+15<<10|32768,s[t]=13,s[256|t]=13):e<128?(n[t]=31744,n[256|t]=64512,s[t]=24,s[256|t]=24):(n[t]=31744,n[256|t]=64512,s[t]=13,s[256|t]=13)}const r=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let t=1;t<1024;++t){let e=t<<13,i=0;for(;0==(8388608&e);)e<<=1,i-=8388608;e&=-8388609,i+=947912704,r[t]=e|i}for(let t=1024;t<2048;++t)r[t]=939524096+(t-1024<<13);for(let t=1;t<31;++t)o[t]=t<<23;o[31]=1199570944,o[32]=2147483648;for(let t=33;t<63;++t)o[t]=2147483648+(t-32<<23);o[63]=3347054592;for(let t=1;t<64;++t)32!==t&&(a[t]=1024);return{floatView:e,uint32View:i,baseTable:n,shiftTable:s,mantissaTable:r,exponentTable:o,offsetTable:a}}var Bh=Object.freeze({__proto__:null,toHalfFloat:function(t){Math.abs(t)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),t=_t(t,-65504,65504),Dh.floatView[0]=t;const e=Dh.uint32View[0],i=e>>23&511;return Dh.baseTable[i]+((8388607&e)>>Dh.shiftTable[i])},fromHalfFloat:function(t){const e=t>>10;return Dh.uint32View[0]=Dh.mantissaTable[Dh.offsetTable[e]+(1023&t)]+Dh.exponentTable[e],Dh.floatView[0]}});"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:i}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=i),e.ACESFilmicToneMapping=4,e.AddEquation=n,e.AddOperation=2,e.AdditiveAnimationBlendMode=rt,e.AdditiveBlending=2,e.AlphaFormat=1021,e.AlwaysDepth=1,e.AlwaysStencilFunc=519,e.AmbientLight=Ec,e.AmbientLightProbe=class extends Cc{constructor(t,e=1){super(void 0,e),this.isAmbientLightProbe=!0;const i=(new qt).set(t);this.sh.coefficients[0].set(i.r,i.g,i.b).multiplyScalar(2*Math.sqrt(Math.PI))}},e.AnimationClip=tc,e.AnimationLoader=class extends rc{constructor(t){super(t)}load(t,e,i,n){const s=this,r=new lc(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(t,(function(i){try{e(s.parse(JSON.parse(i)))}catch(e){n?n(e):console.error(e),s.manager.itemError(t)}}),i,n)}parse(t){const e=[];for(let i=0;i=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,n=this.time+=t,s=Math.sign(t),r=this._accuIndex^=1;for(let o=0;o!==i;++o)e[o]._update(n,t,s,r);const o=this._bindings,a=this._nActiveBindings;for(let t=0;t!==a;++t)o[t].apply(r);return this}setTime(t){this.time=0;for(let t=0;t=s){const r=s++,c=t[r];e[c.uuid]=l,t[l]=c,e[a]=r,t[r]=o;for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[r],s=e[l];e[l]=n,e[r]=s}}}this.nCachedObjects_=s}uncache(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let s=this.nCachedObjects_,r=t.length;for(let o=0,a=arguments.length;o!==a;++o){const a=arguments[o].uuid,l=e[a];if(void 0!==l)if(delete e[a],l0&&(e[o.uuid]=l),t[l]=o,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t];e[l]=e[s],e.pop()}}}this.nCachedObjects_=s}subscribe_(t,e){const i=this._bindingsIndicesByPath;let n=i[t];const s=this._bindings;if(void 0!==n)return s[n];const r=this._paths,o=this._parsedPaths,a=this._objects,l=a.length,c=this.nCachedObjects_,h=new Array(l);n=s.length,i[t]=n,r.push(t),o.push(e),s.push(h);for(let i=c,n=a.length;i!==n;++i){const n=a[i];h[i]=new rh(n,t,e)}return h}unsubscribe_(t){const e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){const n=this._paths,s=this._parsedPaths,r=this._bindings,o=r.length-1,a=r[o];e[t[o]]=i,r[i]=a,r.pop(),s[i]=s[o],s.pop(),n[i]=n[o],n.pop()}}},e.AnimationUtils=Vl,e.ArcCurve=ra,e.ArrayCamera=Ur,e.ArrowHelper=class extends ri{constructor(t=new ne(0,0,1),e=new ne(0,0,0),i=1,n=16776960,s=.2*i,r=.2*s){super(),this.type="ArrowHelper",void 0===Ph&&(Ph=new Di,Ph.setAttribute("position",new Ei([0,0,0,0,1,0],3)),Ih=new Ca(0,.5,1,5,1),Ih.translate(0,-.5,0)),this.position.copy(e),this.line=new Wo(Ph,new zo({color:n,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ki(Ih,new xi({color:n,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(i,s,r)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{Lh.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(Lh,e)}}setLength(t,e=.2*t,i=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),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()}},e.Audio=Xc,e.AudioAnalyser=class{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let i=0;ithis.max.x||t.ythis.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.xthis.max.x||t.max.ythis.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return dh.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),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)}},e.Box3=oe,e.Box3Helper=class extends Xo{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Di;n.setIndex(new wi(i,1)),n.setAttribute("position",new Ei([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(n,new zo({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}},e.BoxBufferGeometry=class extends $i{constructor(t,e,i,n,s,r){console.warn("THREE.BoxBufferGeometry has been renamed to THREE.BoxGeometry."),super(t,e,i,n,s,r)}},e.BoxGeometry=$i,e.BoxHelper=class extends Xo{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Float32Array(24),s=new Di;s.setIndex(new wi(i,1)),s.setAttribute("position",new wi(n,3)),super(s,new zo({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(t){if(void 0!==t&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&Rh.setFromObject(this.object),Rh.isEmpty())return;const e=Rh.min,i=Rh.max,n=this.geometry.attributes.position,s=n.array;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[3]=e.x,s[4]=i.y,s[5]=i.z,s[6]=e.x,s[7]=e.y,s[8]=i.z,s[9]=i.x,s[10]=e.y,s[11]=i.z,s[12]=i.x,s[13]=i.y,s[14]=e.z,s[15]=e.x,s[16]=i.y,s[17]=e.z,s[18]=e.x,s[19]=e.y,s[20]=e.z,s[21]=i.x,s[22]=e.y,s[23]=e.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t,e){return super.copy(t,e),this.object=t.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},e.BufferAttribute=wi,e.BufferGeometry=Di,e.BufferGeometryLoader=Ic,e.ByteType=1010,e.Cache=ic,e.Camera=rn,e.CameraHelper=class extends Xo{constructor(t){const e=new Di,i=new zo({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],s=[],r={};function o(t,e){a(t),a(e)}function a(t){n.push(0,0,0),s.push(0,0,0),void 0===r[t]&&(r[t]=[]),r[t].push(n.length/3-1)}o("n1","n2"),o("n2","n4"),o("n4","n3"),o("n3","n1"),o("f1","f2"),o("f2","f4"),o("f4","f3"),o("f3","f1"),o("n1","f1"),o("n2","f2"),o("n3","f3"),o("n4","f4"),o("p","n1"),o("p","n2"),o("p","n3"),o("p","n4"),o("u1","u2"),o("u2","u3"),o("u3","u1"),o("c","t"),o("p","c"),o("cn1","cn2"),o("cn3","cn4"),o("cf1","cf2"),o("cf3","cf4"),e.setAttribute("position",new Ei(n,3)),e.setAttribute("color",new Ei(s,3)),super(e,i),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=r,this.update();const l=new qt(16755200),c=new qt(16711680),h=new qt(43775),u=new qt(16777215),d=new qt(3355443);this.setColors(l,c,h,u,d)}setColors(t,e,i,n,s){const r=this.geometry.getAttribute("color");r.setXYZ(0,t.r,t.g,t.b),r.setXYZ(1,t.r,t.g,t.b),r.setXYZ(2,t.r,t.g,t.b),r.setXYZ(3,t.r,t.g,t.b),r.setXYZ(4,t.r,t.g,t.b),r.setXYZ(5,t.r,t.g,t.b),r.setXYZ(6,t.r,t.g,t.b),r.setXYZ(7,t.r,t.g,t.b),r.setXYZ(8,t.r,t.g,t.b),r.setXYZ(9,t.r,t.g,t.b),r.setXYZ(10,t.r,t.g,t.b),r.setXYZ(11,t.r,t.g,t.b),r.setXYZ(12,t.r,t.g,t.b),r.setXYZ(13,t.r,t.g,t.b),r.setXYZ(14,t.r,t.g,t.b),r.setXYZ(15,t.r,t.g,t.b),r.setXYZ(16,t.r,t.g,t.b),r.setXYZ(17,t.r,t.g,t.b),r.setXYZ(18,t.r,t.g,t.b),r.setXYZ(19,t.r,t.g,t.b),r.setXYZ(20,t.r,t.g,t.b),r.setXYZ(21,t.r,t.g,t.b),r.setXYZ(22,t.r,t.g,t.b),r.setXYZ(23,t.r,t.g,t.b),r.setXYZ(24,e.r,e.g,e.b),r.setXYZ(25,e.r,e.g,e.b),r.setXYZ(26,e.r,e.g,e.b),r.setXYZ(27,e.r,e.g,e.b),r.setXYZ(28,e.r,e.g,e.b),r.setXYZ(29,e.r,e.g,e.b),r.setXYZ(30,e.r,e.g,e.b),r.setXYZ(31,e.r,e.g,e.b),r.setXYZ(32,i.r,i.g,i.b),r.setXYZ(33,i.r,i.g,i.b),r.setXYZ(34,i.r,i.g,i.b),r.setXYZ(35,i.r,i.g,i.b),r.setXYZ(36,i.r,i.g,i.b),r.setXYZ(37,i.r,i.g,i.b),r.setXYZ(38,n.r,n.g,n.b),r.setXYZ(39,n.r,n.g,n.b),r.setXYZ(40,s.r,s.g,s.b),r.setXYZ(41,s.r,s.g,s.b),r.setXYZ(42,s.r,s.g,s.b),r.setXYZ(43,s.r,s.g,s.b),r.setXYZ(44,s.r,s.g,s.b),r.setXYZ(45,s.r,s.g,s.b),r.setXYZ(46,s.r,s.g,s.b),r.setXYZ(47,s.r,s.g,s.b),r.setXYZ(48,s.r,s.g,s.b),r.setXYZ(49,s.r,s.g,s.b),r.needsUpdate=!0}update(){const t=this.geometry,e=this.pointMap;Ah.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Ch("c",e,t,Ah,0,0,-1),Ch("t",e,t,Ah,0,0,1),Ch("n1",e,t,Ah,-1,-1,-1),Ch("n2",e,t,Ah,1,-1,-1),Ch("n3",e,t,Ah,-1,1,-1),Ch("n4",e,t,Ah,1,1,-1),Ch("f1",e,t,Ah,-1,-1,1),Ch("f2",e,t,Ah,1,-1,1),Ch("f3",e,t,Ah,-1,1,1),Ch("f4",e,t,Ah,1,1,1),Ch("u1",e,t,Ah,.7,1.1,-1),Ch("u2",e,t,Ah,-.7,1.1,-1),Ch("u3",e,t,Ah,0,2,-1),Ch("cf1",e,t,Ah,-1,0,1),Ch("cf2",e,t,Ah,1,0,1),Ch("cf3",e,t,Ah,0,-1,1),Ch("cf4",e,t,Ah,0,1,1),Ch("cn1",e,t,Ah,-1,0,-1),Ch("cn2",e,t,Ah,1,0,-1),Ch("cn3",e,t,Ah,0,-1,-1),Ch("cn4",e,t,Ah,0,1,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},e.CanvasTexture=class extends Kt{constructor(t,e,i,n,s,r,o,a,l){super(t,e,i,n,s,r,o,a,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},e.CapsuleBufferGeometry=class extends Ta{constructor(t,e,i,n){console.warn("THREE.CapsuleBufferGeometry has been renamed to THREE.CapsuleGeometry."),super(t,e,i,n)}},e.CapsuleGeometry=Ta,e.CatmullRomCurve3=ua,e.CineonToneMapping=3,e.CircleBufferGeometry=class extends Aa{constructor(t,e,i,n){console.warn("THREE.CircleBufferGeometry has been renamed to THREE.CircleGeometry."),super(t,e,i,n)}},e.CircleGeometry=Aa,e.ClampToEdgeWrapping=u,e.Clock=Vc,e.Color=qt,e.ColorKeyframeTrack=Yl,e.ColorManagement=zt,e.CompressedTexture=ia,e.CompressedTextureLoader=class extends rc{constructor(t){super(t)}load(t,e,i,n){const s=this,r=[],o=new ia,a=new lc(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(s.withCredentials);let l=0;function c(c){a.load(t[c],(function(t){const i=s.parse(t,!0);r[c]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},l+=1,6===l&&(1===i.mipmapCount&&(o.minFilter=g),o.image=r,o.format=i.format,o.needsUpdate=!0,e&&e(o))}),i,n)}if(Array.isArray(t))for(let e=0,i=t.length;e0){const i=new nc(e);s=new cc(i),s.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e0){n=new cc(this.manager),n.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e1)for(let i=0;iNumber.EPSILON){if(l<0&&(i=e[r],a=-a,o=e[s],l=-l),t.yo.y)continue;if(t.y===i.y){if(t.x===i.x)return!0}else{const e=l*(t.x-i.x)-a*(t.y-i.y);if(0===e)return!0;if(e<0)continue;n=!n}}else{if(t.y!==i.y)continue;if(o.x<=t.x&&t.x<=i.x||i.x<=t.x&&t.x<=o.x)return!0}}return n}const i=ll.isClockWise,n=this.subPaths;if(0===n.length)return[];let s,r,o;const a=[];if(1===n.length)return r=n[0],o=new Oa,o.curves=r.curves,a.push(o),a;let l=!i(n[0].getPoints());l=t?!l:l;const c=[],h=[];let u,d,p=[],m=0;h[m]=void 0,p[m]=[];for(let e=0,o=n.length;e1){let t=!1,i=0;for(let t=0,e=h.length;t0&&!1===t&&(p=c)}for(let t=0,e=h.length;t=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},e.WebGL1Renderer=Yr,e.WebGL3DRenderTarget=class extends $t{constructor(t,e,i){super(t,e),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new ee(null,t,e,i),this.texture.isRenderTargetTexture=!0}},e.WebGLArrayRenderTarget=class extends $t{constructor(t,e,i){super(t,e),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new te(null,t,e,i),this.texture.isRenderTargetTexture=!0}},e.WebGLCubeRenderTarget=hn,e.WebGLMultipleRenderTargets=class extends $t{constructor(t,e,i,n={}){super(t,e,n),this.isWebGLMultipleRenderTargets=!0;const s=this.texture;this.texture=[];for(let t=0;t{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n(10)})(); \ No newline at end of file diff --git a/dist/aframe-physics-system.min.js.LICENSE.txt b/dist/aframe-physics-system.min.js.LICENSE.txt new file mode 100644 index 00000000..276aaa18 --- /dev/null +++ b/dist/aframe-physics-system.min.js.LICENSE.txt @@ -0,0 +1,5 @@ +/** + * @license + * Copyright 2010-2022 Three.js Authors + * SPDX-License-Identifier: MIT + */ From b24855039d8de7a123076474d76307393d7b0ade Mon Sep 17 00:00:00 2001 From: diarmidmackenzie Date: Thu, 22 Dec 2022 11:24:58 +0000 Subject: [PATCH 6/6] Fix karma to work with webpack Following work done on a-frame here: https://github.com/aframevr/aframe/pull/5116/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519 --- package-lock.json | 5587 +------------------------------------------ package.json | 2 +- tests/karma.conf.js | 11 +- 3 files changed, 97 insertions(+), 5503 deletions(-) diff --git a/package-lock.json b/package-lock.json index b173ef00..c31168bf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,7 +24,6 @@ "chai-shallow-deep-equal": "^1.4.6", "envify": "^4.1.0", "karma": "^4.4.1", - "karma-browserify": "^6.1.0", "karma-chai-shallow-deep-equal": "0.0.4", "karma-chrome-launcher": "^2.2.0", "karma-env-preprocessor": "^0.1.1", @@ -32,6 +31,7 @@ "karma-mocha": "^1.3.0", "karma-mocha-reporter": "^2.2.5", "karma-sinon-chai": "^1.3.4", + "karma-webpack": "^5.0.0", "mocha": "^6.2.3", "replace": "^1.2.0", "sinon": "^2.4.1", @@ -478,51 +478,6 @@ "node": ">= 0.6" } }, - "node_modules/acorn": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.2.0.tgz", - "integrity": "sha512-apwXVmYVpQ34m/i71vrApRrRKCWQnZZF1+npOD0WV5xZFfwWOmKGQ2RWlfdy9vWITsenisM8M0Qeq8agcFHNiQ==", - "dev": true, - "peer": true, - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/acorn-node": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.8.2.tgz", - "integrity": "sha512-8mt+fslDufLYntIoPAaIMUe/lrbrehIiwmR3t2k9LljIzoigEPF27eLk2hy8zSGzmR/ogr7zbRKINMo1u0yh5A==", - "dev": true, - "peer": true, - "dependencies": { - "acorn": "^7.0.0", - "acorn-walk": "^7.0.0", - "xtend": "^4.0.2" - } - }, - "node_modules/acorn-node/node_modules/xtend": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", - "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.4" - } - }, - "node_modules/acorn-walk": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.1.1.tgz", - "integrity": "sha512-wdlPY2tm/9XBr7QkKlq0WQVgiuGTX6YWPyRyBviSoScBuLfTVQhvwg6wJ369GJ/1nPfTLMfnrFIfjqVg6d+jQQ==", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/aframe": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/aframe/-/aframe-1.1.0.tgz", @@ -655,30 +610,6 @@ "ansi-html": "bin/ansi-html" } }, - "node_modules/anymatch": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", - "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", - "dev": true, - "peer": true, - "dependencies": { - "micromatch": "^3.1.4", - "normalize-path": "^2.1.1" - } - }, - "node_modules/anymatch/node_modules/normalize-path": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", - "dev": true, - "peer": true, - "dependencies": { - "remove-trailing-separator": "^1.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -688,36 +619,6 @@ "sprintf-js": "~1.0.2" } }, - "node_modules/arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/arr-flatten": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/arr-union": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", - "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/array-flatten": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-2.1.2.tgz", @@ -732,16 +633,6 @@ "node": ">=0.10.0" } }, - "node_modules/array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/arraybuffer.slice": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz", @@ -754,53 +645,6 @@ "integrity": "sha512-HkI/zLo2AbSRO4fqVkmyf3hms0bJDs3iboHqTrNuwTiCRvdYXM7HFhfhB6Dk51anV2LM/IMB83mtK9mHw4FlAg==", "dev": true }, - "node_modules/asn1.js": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", - "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", - "dev": true, - "peer": true, - "dependencies": { - "bn.js": "^4.0.0", - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0" - } - }, - "node_modules/asn1.js/node_modules/bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true, - "peer": true - }, - "node_modules/assert": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/assert/-/assert-1.5.0.tgz", - "integrity": "sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA==", - "dev": true, - "peer": true, - "dependencies": { - "object-assign": "^4.1.1", - "util": "0.10.3" - } - }, - "node_modules/assert/node_modules/inherits": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", - "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", - "dev": true, - "peer": true - }, - "node_modules/assert/node_modules/util": { - "version": "0.10.3", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", - "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", - "dev": true, - "peer": true, - "dependencies": { - "inherits": "2.0.1" - } - }, "node_modules/assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", @@ -810,16 +654,6 @@ "node": "*" } }, - "node_modules/assign-symbols": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", - "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/async": { "version": "2.6.3", "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", @@ -829,32 +663,12 @@ "lodash": "^4.17.14" } }, - "node_modules/async-each": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", - "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==", - "dev": true, - "peer": true - }, "node_modules/async-limiter": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==", "dev": true }, - "node_modules/atob": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", - "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", - "dev": true, - "peer": true, - "bin": { - "atob": "bin/atob.js" - }, - "engines": { - "node": ">= 4.5.0" - } - }, "node_modules/backo2": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", @@ -866,79 +680,6 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, - "node_modules/base": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", - "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", - "dev": true, - "peer": true, - "dependencies": { - "cache-base": "^1.0.1", - "class-utils": "^0.3.5", - "component-emitter": "^1.2.1", - "define-property": "^1.0.0", - "isobject": "^3.0.1", - "mixin-deep": "^1.2.0", - "pascalcase": "^0.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/base/node_modules/define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "peer": true, - "dependencies": { - "is-descriptor": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/base/node_modules/is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "peer": true, - "dependencies": { - "kind-of": "^6.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/base/node_modules/is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "peer": true, - "dependencies": { - "kind-of": "^6.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/base/node_modules/is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "peer": true, - "dependencies": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/base64-arraybuffer": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz", @@ -948,13 +689,6 @@ "node": ">= 0.6.0" } }, - "node_modules/base64-js": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", - "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==", - "dev": true, - "peer": true - }, "node_modules/base64id": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/base64id/-/base64id-1.0.0.tgz", @@ -981,27 +715,6 @@ "node": "*" } }, - "node_modules/binary-extensions": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", - "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "dev": true, - "optional": true, - "peer": true, - "dependencies": { - "file-uri-to-path": "1.0.0" - } - }, "node_modules/blob": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz", @@ -1014,13 +727,6 @@ "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", "dev": true }, - "node_modules/bn.js": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.1.1.tgz", - "integrity": "sha512-IUTD/REb78Z2eodka1QZyyEk66pciRcP6Sroka0aI3tG/iwIdYLrBD62RsubR7vqdt3WyX8p4jxeatzmRSphtA==", - "dev": true, - "peer": true - }, "node_modules/body-parser": { "version": "1.20.1", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", @@ -1075,269 +781,12 @@ "concat-map": "0.0.1" } }, - "node_modules/braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "dev": true, - "peer": true, - "dependencies": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/braces/node_modules/extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "peer": true, - "dependencies": { - "is-extendable": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/brorand": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", - "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", - "dev": true, - "peer": true - }, - "node_modules/browser-pack": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.1.0.tgz", - "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==", - "dev": true, - "peer": true, - "dependencies": { - "combine-source-map": "~0.8.0", - "defined": "^1.0.0", - "JSONStream": "^1.0.3", - "safe-buffer": "^5.1.1", - "through2": "^2.0.0", - "umd": "^3.0.0" - }, - "bin": { - "browser-pack": "bin/cmd.js" - } - }, - "node_modules/browser-resolve": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.3.tgz", - "integrity": "sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ==", - "dev": true, - "peer": true, - "dependencies": { - "resolve": "1.1.7" - } - }, - "node_modules/browser-resolve/node_modules/resolve": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", - "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", - "dev": true, - "peer": true - }, "node_modules/browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, - "node_modules/browserify": { - "version": "16.5.1", - "resolved": "https://registry.npmjs.org/browserify/-/browserify-16.5.1.tgz", - "integrity": "sha512-EQX0h59Pp+0GtSRb5rL6OTfrttlzv+uyaUVlK6GX3w11SQ0jKPKyjC/54RhPR2ib2KmfcELM06e8FxcI5XNU2A==", - "dev": true, - "peer": true, - "dependencies": { - "assert": "^1.4.0", - "browser-pack": "^6.0.1", - "browser-resolve": "^1.11.0", - "browserify-zlib": "~0.2.0", - "buffer": "~5.2.1", - "cached-path-relative": "^1.0.0", - "concat-stream": "^1.6.0", - "console-browserify": "^1.1.0", - "constants-browserify": "~1.0.0", - "crypto-browserify": "^3.0.0", - "defined": "^1.0.0", - "deps-sort": "^2.0.0", - "domain-browser": "^1.2.0", - "duplexer2": "~0.1.2", - "events": "^2.0.0", - "glob": "^7.1.0", - "has": "^1.0.0", - "htmlescape": "^1.1.0", - "https-browserify": "^1.0.0", - "inherits": "~2.0.1", - "insert-module-globals": "^7.0.0", - "JSONStream": "^1.0.3", - "labeled-stream-splicer": "^2.0.0", - "mkdirp-classic": "^0.5.2", - "module-deps": "^6.0.0", - "os-browserify": "~0.3.0", - "parents": "^1.0.1", - "path-browserify": "~0.0.0", - "process": "~0.11.0", - "punycode": "^1.3.2", - "querystring-es3": "~0.2.0", - "read-only-stream": "^2.0.0", - "readable-stream": "^2.0.2", - "resolve": "^1.1.4", - "shasum": "^1.0.0", - "shell-quote": "^1.6.1", - "stream-browserify": "^2.0.0", - "stream-http": "^3.0.0", - "string_decoder": "^1.1.1", - "subarg": "^1.0.0", - "syntax-error": "^1.1.1", - "through2": "^2.0.0", - "timers-browserify": "^1.0.1", - "tty-browserify": "0.0.1", - "url": "~0.11.0", - "util": "~0.10.1", - "vm-browserify": "^1.0.0", - "xtend": "^4.0.0" - }, - "bin": { - "browserify": "bin/cmd.js" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/browserify-aes": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", - "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", - "dev": true, - "peer": true, - "dependencies": { - "buffer-xor": "^1.0.3", - "cipher-base": "^1.0.0", - "create-hash": "^1.1.0", - "evp_bytestokey": "^1.0.3", - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - } - }, - "node_modules/browserify-cipher": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", - "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", - "dev": true, - "peer": true, - "dependencies": { - "browserify-aes": "^1.0.4", - "browserify-des": "^1.0.0", - "evp_bytestokey": "^1.0.0" - } - }, - "node_modules/browserify-des": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", - "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", - "dev": true, - "peer": true, - "dependencies": { - "cipher-base": "^1.0.1", - "des.js": "^1.0.0", - "inherits": "^2.0.1", - "safe-buffer": "^5.1.2" - } - }, - "node_modules/browserify-rsa": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", - "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", - "dev": true, - "peer": true, - "dependencies": { - "bn.js": "^4.1.0", - "randombytes": "^2.0.1" - } - }, - "node_modules/browserify-rsa/node_modules/bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true, - "peer": true - }, - "node_modules/browserify-sign": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.1.0.tgz", - "integrity": "sha512-VYxo7cDCeYUoBZ0ZCy4UyEUCP3smyBd4DRQM5nrFS1jJjPJjX7rP3oLRpPoWfkhQfyJ0I9ZbHbKafrFD/SGlrg==", - "dev": true, - "peer": true, - "dependencies": { - "bn.js": "^5.1.1", - "browserify-rsa": "^4.0.1", - "create-hash": "^1.2.0", - "create-hmac": "^1.1.7", - "elliptic": "^6.5.2", - "inherits": "^2.0.4", - "parse-asn1": "^5.1.5", - "readable-stream": "^3.6.0" - } - }, - "node_modules/browserify-sign/node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true, - "peer": true - }, - "node_modules/browserify-sign/node_modules/readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, - "peer": true, - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/browserify-zlib": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", - "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", - "dev": true, - "peer": true, - "dependencies": { - "pako": "~1.0.5" - } - }, - "node_modules/browserify/node_modules/process": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", - "dev": true, - "peer": true, - "engines": { - "node": ">= 0.6.0" - } - }, "node_modules/browserslist": { "version": "4.21.4", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.4.tgz", @@ -1365,17 +814,6 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, - "node_modules/buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", - "integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==", - "dev": true, - "peer": true, - "dependencies": { - "base64-js": "^1.0.2", - "ieee754": "^1.1.4" - } - }, "node_modules/buffer-alloc": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", @@ -1418,20 +856,6 @@ "integrity": "sha512-3dthu5CYiVB1DEJp61FtApNnNndTckcqe4pFcLdvHtrpG+kcyekCJKg4MRiDcFW7A6AODnXB9U4dwQiCW5kzJQ==", "dev": true }, - "node_modules/buffer-xor": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", - "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", - "dev": true, - "peer": true - }, - "node_modules/builtin-status-codes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", - "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", - "dev": true, - "peer": true - }, "node_modules/bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -1440,34 +864,6 @@ "node": ">= 0.8" } }, - "node_modules/cache-base": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", - "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", - "dev": true, - "peer": true, - "dependencies": { - "collection-visit": "^1.0.0", - "component-emitter": "^1.2.1", - "get-value": "^2.0.6", - "has-value": "^1.0.0", - "isobject": "^3.0.1", - "set-value": "^2.0.0", - "to-object-path": "^0.3.0", - "union-value": "^1.0.0", - "unset-value": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/cached-path-relative": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.0.2.tgz", - "integrity": "sha512-5r2GqsoEb4qMTTN9J+WzXfjov+hjxT+j3u5K+kIVNIwAd99DLCJE9pBIMP1qVeybV6JiijL385Oz0DcYxfbOIg==", - "dev": true, - "peer": true - }, "node_modules/call-bind": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", @@ -1555,50 +951,6 @@ "chai": ">= 1.9.0" } }, - "node_modules/chokidar": { - "version": "2.1.8", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", - "integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==", - "deprecated": "Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies", - "dev": true, - "peer": true, - "dependencies": { - "anymatch": "^2.0.0", - "async-each": "^1.0.1", - "braces": "^2.3.2", - "glob-parent": "^3.1.0", - "inherits": "^2.0.3", - "is-binary-path": "^1.0.0", - "is-glob": "^4.0.0", - "normalize-path": "^3.0.0", - "path-is-absolute": "^1.0.0", - "readdirp": "^2.2.1", - "upath": "^1.1.1" - }, - "optionalDependencies": { - "fsevents": "^1.2.7" - } - }, - "node_modules/chokidar/node_modules/fsevents": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", - "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", - "deprecated": "fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.", - "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "peer": true, - "dependencies": { - "bindings": "^1.5.0", - "nan": "^2.12.1" - }, - "engines": { - "node": ">= 4.0" - } - }, "node_modules/chrome-trace-event": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz", @@ -1607,46 +959,6 @@ "node": ">=6.0" } }, - "node_modules/cipher-base": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", - "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", - "dev": true, - "peer": true, - "dependencies": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - } - }, - "node_modules/class-utils": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", - "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", - "dev": true, - "peer": true, - "dependencies": { - "arr-union": "^3.1.0", - "define-property": "^0.2.5", - "isobject": "^3.0.0", - "static-extend": "^0.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/class-utils/node_modules/define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "peer": true, - "dependencies": { - "is-descriptor": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/cliui": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", @@ -1701,24 +1013,10 @@ "dependencies": { "is-plain-object": "^2.0.4", "kind-of": "^6.0.2", - "shallow-clone": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/collection-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", - "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", - "dev": true, - "peer": true, - "dependencies": { - "map-visit": "^1.0.0", - "object-visit": "^1.0.0" + "shallow-clone": "^3.0.0" }, "engines": { - "node": ">=0.10.0" + "node": ">=6" } }, "node_modules/color-convert": { @@ -1750,19 +1048,6 @@ "node": ">=0.1.90" } }, - "node_modules/combine-source-map": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.8.0.tgz", - "integrity": "sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos=", - "dev": true, - "peer": true, - "dependencies": { - "convert-source-map": "~1.1.0", - "inline-source-map": "~0.6.0", - "lodash.memoize": "~3.0.3", - "source-map": "~0.5.3" - } - }, "node_modules/commander": { "version": "2.13.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.13.0.tgz", @@ -1775,13 +1060,6 @@ "integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E=", "dev": true }, - "node_modules/component-emitter": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", - "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", - "dev": true, - "peer": true - }, "node_modules/component-inherit": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz", @@ -1834,22 +1112,6 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, - "node_modules/concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "dev": true, - "engines": [ - "node >= 0.8" - ], - "peer": true, - "dependencies": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^2.2.2", - "typedarray": "^0.0.6" - } - }, "node_modules/connect": { "version": "3.7.0", "resolved": "https://registry.npmjs.org/connect/-/connect-3.7.0.tgz", @@ -1873,20 +1135,6 @@ "node": ">=0.8" } }, - "node_modules/console-browserify": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.2.0.tgz", - "integrity": "sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA==", - "dev": true, - "peer": true - }, - "node_modules/constants-browserify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", - "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=", - "dev": true, - "peer": true - }, "node_modules/content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", @@ -1906,12 +1154,6 @@ "node": ">= 0.6" } }, - "node_modules/convert-source-map": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz", - "integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=", - "dev": true - }, "node_modules/cookie": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", @@ -1926,91 +1168,11 @@ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" }, - "node_modules/copy-descriptor": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", - "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, - "node_modules/create-ecdh": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", - "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", - "dev": true, - "peer": true, - "dependencies": { - "bn.js": "^4.1.0", - "elliptic": "^6.0.0" - } - }, - "node_modules/create-ecdh/node_modules/bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true, - "peer": true - }, - "node_modules/create-hash": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", - "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", - "dev": true, - "peer": true, - "dependencies": { - "cipher-base": "^1.0.1", - "inherits": "^2.0.1", - "md5.js": "^1.3.4", - "ripemd160": "^2.0.1", - "sha.js": "^2.4.0" - } - }, - "node_modules/create-hmac": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", - "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", - "dev": true, - "peer": true, - "dependencies": { - "cipher-base": "^1.0.3", - "create-hash": "^1.1.0", - "inherits": "^2.0.1", - "ripemd160": "^2.0.0", - "safe-buffer": "^5.0.1", - "sha.js": "^2.4.8" - } - }, - "node_modules/crypto-browserify": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", - "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", - "dev": true, - "peer": true, - "dependencies": { - "browserify-cipher": "^1.0.0", - "browserify-sign": "^4.0.0", - "create-ecdh": "^4.0.0", - "create-hash": "^1.1.0", - "create-hmac": "^1.1.0", - "diffie-hellman": "^5.0.0", - "inherits": "^2.0.1", - "pbkdf2": "^3.0.3", - "public-encrypt": "^4.0.0", - "randombytes": "^2.0.0", - "randomfill": "^1.0.3" - }, - "engines": { - "node": "*" - } - }, "node_modules/custom-event": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz", @@ -2023,13 +1185,6 @@ "integrity": "sha512-TDDkd5DkaZxZFM8p+1I3yAlvM3rSr1wbrOliG4yJiwinMZN8z/iGL7BTlDkrJcYTmgUSb4ywVCc3ZaUtOtC76w==", "dev": true }, - "node_modules/dash-ast": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/dash-ast/-/dash-ast-1.0.0.tgz", - "integrity": "sha512-Vy4dx7gquTeMcQR/hDkYLGUnwVil6vk4FOOct+djUnHOUWt+zJPJAaRIXaAFkPXtJjvlY7o3rfRu0/3hpnwoUA==", - "dev": true, - "peer": true - }, "node_modules/date-format": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/date-format/-/date-format-2.1.0.tgz", @@ -2131,68 +1286,6 @@ "node": ">= 0.4" } }, - "node_modules/define-property": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", - "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", - "dev": true, - "peer": true, - "dependencies": { - "is-descriptor": "^1.0.2", - "isobject": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/define-property/node_modules/is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "peer": true, - "dependencies": { - "kind-of": "^6.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/define-property/node_modules/is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "peer": true, - "dependencies": { - "kind-of": "^6.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/define-property/node_modules/is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "peer": true, - "dependencies": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/defined": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", - "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", - "dev": true, - "peer": true - }, "node_modules/depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", @@ -2201,33 +1294,6 @@ "node": ">= 0.8" } }, - "node_modules/deps-sort": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-2.0.1.tgz", - "integrity": "sha512-1orqXQr5po+3KI6kQb9A4jnXT1PBwggGl2d7Sq2xsnOeI9GPcE/tGcF9UiSZtZBM7MukY4cAh7MemS6tZYipfw==", - "dev": true, - "peer": true, - "dependencies": { - "JSONStream": "^1.0.3", - "shasum-object": "^1.0.0", - "subarg": "^1.0.0", - "through2": "^2.0.0" - }, - "bin": { - "deps-sort": "bin/cmd.js" - } - }, - "node_modules/des.js": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz", - "integrity": "sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA==", - "dev": true, - "peer": true, - "dependencies": { - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0" - } - }, "node_modules/destroy": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", @@ -2242,24 +1308,6 @@ "resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.1.0.tgz", "integrity": "sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==" }, - "node_modules/detective": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/detective/-/detective-5.2.0.tgz", - "integrity": "sha512-6SsIx+nUUbuK0EthKjv0zrdnajCCXVYGmbYYiYjFVpzcjwEs/JMDZ8tPRG29J/HhN56t3GJp2cGSWDRjjot8Pg==", - "dev": true, - "peer": true, - "dependencies": { - "acorn-node": "^1.6.1", - "defined": "^1.0.0", - "minimist": "^1.1.1" - }, - "bin": { - "detective": "bin/detective.js" - }, - "engines": { - "node": ">=0.8.0" - } - }, "node_modules/di": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/di/-/di-0.0.1.tgz", @@ -2275,25 +1323,6 @@ "node": ">=0.3.1" } }, - "node_modules/diffie-hellman": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", - "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", - "dev": true, - "peer": true, - "dependencies": { - "bn.js": "^4.1.0", - "miller-rabin": "^4.0.0", - "randombytes": "^2.0.0" - } - }, - "node_modules/diffie-hellman/node_modules/bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true, - "peer": true - }, "node_modules/dns-equal": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/dns-equal/-/dns-equal-1.0.0.tgz", @@ -2335,17 +1364,6 @@ "integrity": "sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w==", "dev": true }, - "node_modules/domain-browser": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", - "integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.4", - "npm": ">=1.2" - } - }, "node_modules/dtype": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/dtype/-/dtype-2.0.0.tgz", @@ -2355,16 +1373,6 @@ "node": ">= 0.8.0" } }, - "node_modules/duplexer2": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", - "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", - "dev": true, - "peer": true, - "dependencies": { - "readable-stream": "^2.0.2" - } - }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -2375,29 +1383,6 @@ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.284.tgz", "integrity": "sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA==" }, - "node_modules/elliptic": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz", - "integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==", - "dev": true, - "peer": true, - "dependencies": { - "bn.js": "^4.4.0", - "brorand": "^1.0.1", - "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.0", - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0", - "minimalistic-crypto-utils": "^1.0.0" - } - }, - "node_modules/elliptic/node_modules/bn.js": { - "version": "4.11.9", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz", - "integrity": "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==", - "dev": true, - "peer": true - }, "node_modules/emoji-regex": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", @@ -2693,72 +1678,6 @@ "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.0.tgz", "integrity": "sha512-qerSRB0p+UDEssxTtm6EDKcE7W4OaoisfIMl4CngyEhjpYglocpNg6UEqCvemdGhosAsg4sO2dXJOdyBifPGCg==" }, - "node_modules/events": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/events/-/events-2.1.0.tgz", - "integrity": "sha512-3Zmiobend8P9DjmKAty0Era4jV8oJ0yGYe2nJJAxgymF9+N8F2m0hhZiMoWtcfepExzNKZumFU3ksdQbInGWCg==", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.4.x" - } - }, - "node_modules/evp_bytestokey": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", - "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", - "dev": true, - "peer": true, - "dependencies": { - "md5.js": "^1.3.4", - "safe-buffer": "^5.1.1" - } - }, - "node_modules/expand-brackets": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "dev": true, - "peer": true, - "dependencies": { - "debug": "^2.3.3", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "posix-character-classes": "^0.1.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/expand-brackets/node_modules/define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "peer": true, - "dependencies": { - "is-descriptor": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/expand-brackets/node_modules/extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "peer": true, - "dependencies": { - "is-extendable": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/express": { "version": "4.18.2", "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", @@ -2844,136 +1763,22 @@ "node_modules/express/node_modules/path-to-regexp": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" - }, - "node_modules/express/node_modules/statuses": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", - "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", - "dev": true - }, - "node_modules/extend-shallow": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", - "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", - "dev": true, - "peer": true, - "dependencies": { - "assign-symbols": "^1.0.0", - "is-extendable": "^1.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/extend-shallow/node_modules/is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, - "peer": true, - "dependencies": { - "is-plain-object": "^2.0.4" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/extglob": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", - "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "dev": true, - "peer": true, - "dependencies": { - "array-unique": "^0.3.2", - "define-property": "^1.0.0", - "expand-brackets": "^2.1.4", - "extend-shallow": "^2.0.1", - "fragment-cache": "^0.2.1", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/extglob/node_modules/define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "peer": true, - "dependencies": { - "is-descriptor": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/extglob/node_modules/extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "peer": true, - "dependencies": { - "is-extendable": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/extglob/node_modules/is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "peer": true, - "dependencies": { - "kind-of": "^6.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/extglob/node_modules/is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "peer": true, - "dependencies": { - "kind-of": "^6.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/extglob/node_modules/is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "peer": true, - "dependencies": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - }, + "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" + }, + "node_modules/express/node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", "engines": { - "node": ">=0.10.0" + "node": ">= 0.8" } }, + "node_modules/extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -2984,13 +1789,6 @@ "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" }, - "node_modules/fast-safe-stringify": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz", - "integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==", - "dev": true, - "peer": true - }, "node_modules/fastest-levenshtein": { "version": "1.0.16", "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz", @@ -3011,43 +1809,6 @@ "node": ">=0.8.0" } }, - "node_modules/file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", - "dev": true, - "optional": true, - "peer": true - }, - "node_modules/fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "dev": true, - "peer": true, - "dependencies": { - "extend-shallow": "^2.0.1", - "is-number": "^3.0.0", - "repeat-string": "^1.6.1", - "to-regex-range": "^2.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/fill-range/node_modules/extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "peer": true, - "dependencies": { - "is-extendable": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/finalhandler": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", @@ -3140,16 +1901,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, - "node_modules/for-in": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/formatio": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/formatio/-/formatio-1.2.0.tgz", @@ -3168,19 +1919,6 @@ "node": ">= 0.6" } }, - "node_modules/fragment-cache": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", - "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", - "dev": true, - "peer": true, - "dependencies": { - "map-cache": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", @@ -3243,13 +1981,6 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, - "node_modules/get-assigned-identifiers": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz", - "integrity": "sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ==", - "dev": true, - "peer": true - }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -3272,16 +2003,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/get-value": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", - "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/gl-preserve-state": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/gl-preserve-state/-/gl-preserve-state-1.0.0.tgz", @@ -3307,30 +2028,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/glob-parent": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", - "dev": true, - "peer": true, - "dependencies": { - "is-glob": "^3.1.0", - "path-dirname": "^1.0.0" - } - }, - "node_modules/glob-parent/node_modules/is-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "dev": true, - "peer": true, - "dependencies": { - "is-extglob": "^2.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/glob-to-regexp": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", @@ -3417,105 +2114,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/has-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", - "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", - "dev": true, - "peer": true, - "dependencies": { - "get-value": "^2.0.6", - "has-values": "^1.0.0", - "isobject": "^3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/has-values": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", - "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", - "dev": true, - "peer": true, - "dependencies": { - "is-number": "^3.0.0", - "kind-of": "^4.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/has-values/node_modules/kind-of": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", - "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", - "dev": true, - "peer": true, - "dependencies": { - "is-buffer": "^1.1.5" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/hash-base": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz", - "integrity": "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==", - "dev": true, - "peer": true, - "dependencies": { - "inherits": "^2.0.4", - "readable-stream": "^3.6.0", - "safe-buffer": "^5.2.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/hash-base/node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true, - "peer": true - }, - "node_modules/hash-base/node_modules/readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, - "peer": true, - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/hash.js": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", - "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", - "dev": true, - "peer": true, - "dependencies": { - "inherits": "^2.0.3", - "minimalistic-assert": "^1.0.1" - } - }, - "node_modules/hat": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/hat/-/hat-0.0.3.tgz", - "integrity": "sha1-uwFKnmSzeIrtgAWRdBPU/z1QLYo=", - "dev": true, - "engines": { - "node": "*" - } - }, "node_modules/he": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", @@ -3525,18 +2123,6 @@ "he": "bin/he" } }, - "node_modules/hmac-drbg": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", - "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", - "dev": true, - "peer": true, - "dependencies": { - "hash.js": "^1.0.3", - "minimalistic-assert": "^1.0.0", - "minimalistic-crypto-utils": "^1.0.1" - } - }, "node_modules/hpack.js": { "version": "2.1.6", "resolved": "https://registry.npmjs.org/hpack.js/-/hpack.js-2.1.6.tgz", @@ -3553,16 +2139,6 @@ "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.3.3.tgz", "integrity": "sha512-DV5Ln36z34NNTDgnz0EWGBLZENelNAtkiFA4kyNOG2tDI6Mz1uSWiq1wAKdyjnJwyDiDO7Fa2SO1CTxPXL8VxA==" }, - "node_modules/htmlescape": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz", - "integrity": "sha1-OgPtwiFLyjtmQko+eVk0lQnLA1E=", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10" - } - }, "node_modules/http-deceiver": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/http-deceiver/-/http-deceiver-1.2.7.tgz", @@ -3690,13 +2266,6 @@ "node": ">=8.0" } }, - "node_modules/https-browserify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", - "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", - "dev": true, - "peer": true - }, "node_modules/human-signals": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", @@ -3716,13 +2285,6 @@ "node": ">=0.10.0" } }, - "node_modules/ieee754": { - "version": "1.1.13", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", - "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==", - "dev": true, - "peer": true - }, "node_modules/import-local": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", @@ -3762,48 +2324,6 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, - "node_modules/inline-source-map": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.6.2.tgz", - "integrity": "sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU=", - "dev": true, - "peer": true, - "dependencies": { - "source-map": "~0.5.3" - } - }, - "node_modules/insert-module-globals": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.2.0.tgz", - "integrity": "sha512-VE6NlW+WGn2/AeOMd496AHFYmE7eLKkUY6Ty31k4og5vmA3Fjuwe9v6ifH6Xx/Hz27QvdoMoviw1/pqWRB09Sw==", - "dev": true, - "peer": true, - "dependencies": { - "acorn-node": "^1.5.2", - "combine-source-map": "^0.8.0", - "concat-stream": "^1.6.1", - "is-buffer": "^1.1.0", - "JSONStream": "^1.0.3", - "path-is-absolute": "^1.0.1", - "process": "~0.11.0", - "through2": "^2.0.0", - "undeclared-identifiers": "^1.1.2", - "xtend": "^4.0.0" - }, - "bin": { - "insert-module-globals": "bin/cmd.js" - } - }, - "node_modules/insert-module-globals/node_modules/process": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", - "dev": true, - "peer": true, - "engines": { - "node": ">= 0.6.0" - } - }, "node_modules/interpret": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/interpret/-/interpret-3.1.1.tgz", @@ -3821,45 +2341,6 @@ "node": ">= 0.10" } }, - "node_modules/is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "peer": true, - "dependencies": { - "kind-of": "^3.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-accessor-descriptor/node_modules/kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "peer": true, - "dependencies": { - "is-buffer": "^1.1.5" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-binary-path": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", - "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", - "dev": true, - "peer": true, - "dependencies": { - "binary-extensions": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-buffer": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", @@ -3891,32 +2372,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "peer": true, - "dependencies": { - "kind-of": "^3.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-data-descriptor/node_modules/kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "peer": true, - "dependencies": { - "is-buffer": "^1.1.5" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-date-object": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", @@ -3929,31 +2384,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "peer": true, - "dependencies": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-descriptor/node_modules/kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-docker": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", @@ -3968,16 +2398,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -4012,32 +2432,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "peer": true, - "dependencies": { - "kind-of": "^3.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-number/node_modules/kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "peer": true, - "dependencies": { - "is-buffer": "^1.1.5" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-obj": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", @@ -4100,16 +2494,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-windows": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", - "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-wsl": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", @@ -4187,15 +2571,6 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, - "node_modules/js-string-escape": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/js-string-escape/-/js-string-escape-1.0.1.tgz", - "integrity": "sha1-4mJbrbwNZ8dTPp7cEGjFh65BN+8=", - "dev": true, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/js-yaml": { "version": "3.13.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", @@ -4219,16 +2594,6 @@ "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" }, - "node_modules/json-stable-stringify": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz", - "integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=", - "dev": true, - "peer": true, - "dependencies": { - "jsonify": "~0.0.0" - } - }, "node_modules/jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", @@ -4238,43 +2603,6 @@ "graceful-fs": "^4.1.6" } }, - "node_modules/jsonify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", - "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", - "dev": true, - "peer": true, - "engines": { - "node": "*" - } - }, - "node_modules/jsonparse": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", - "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", - "dev": true, - "engines": [ - "node >= 0.2.0" - ], - "peer": true - }, - "node_modules/JSONStream": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", - "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", - "dev": true, - "peer": true, - "dependencies": { - "jsonparse": "^1.2.0", - "through": ">=2.2.7 <3" - }, - "bin": { - "JSONStream": "bin.js" - }, - "engines": { - "node": "*" - } - }, "node_modules/karma": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/karma/-/karma-4.4.1.tgz", @@ -4315,29 +2643,6 @@ "node": ">= 8" } }, - "node_modules/karma-browserify": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/karma-browserify/-/karma-browserify-6.1.0.tgz", - "integrity": "sha512-FWOuATeil6dbm2nwWIbSFG0Ad8w3PcuBNs05zcqnMiuXEdwos/o6B26HF+NcYwTt3o7LTOGWiuXK9cuuhoPeaw==", - "dev": true, - "dependencies": { - "convert-source-map": "^1.1.3", - "hat": "^0.0.3", - "js-string-escape": "^1.0.0", - "lodash": "^4.17.14", - "minimatch": "^3.0.0", - "os-shim": "^0.1.3" - }, - "engines": { - "node": ">=6", - "npm": ">=2" - }, - "peerDependencies": { - "browserify": ">=10 <17", - "karma": ">=3", - "watchify": ">=3 <4" - } - }, "node_modules/karma-chai-shallow-deep-equal": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/karma-chai-shallow-deep-equal/-/karma-chai-shallow-deep-equal-0.0.4.tgz", @@ -4479,6 +2784,32 @@ "sinon-chai": ">=2.9.0 <4" } }, + "node_modules/karma-webpack": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/karma-webpack/-/karma-webpack-5.0.0.tgz", + "integrity": "sha512-+54i/cd3/piZuP3dr54+NcFeKOPnys5QeM1IY+0SPASwrtHsliXUiCL50iW+K9WWA7RvamC4macvvQ86l3KtaA==", + "dev": true, + "dependencies": { + "glob": "^7.1.3", + "minimatch": "^3.0.4", + "webpack-merge": "^4.1.5" + }, + "engines": { + "node": ">= 6" + }, + "peerDependencies": { + "webpack": "^5.0.0" + } + }, + "node_modules/karma-webpack/node_modules/webpack-merge": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-4.2.2.tgz", + "integrity": "sha512-TUE1UGoTX2Cd42j3krGYqObZbOD+xF7u28WB7tfUordytSjbWTIjK/8V0amkBfTYN4/pB/GIDlJZZ657BGG19g==", + "dev": true, + "dependencies": { + "lodash": "^4.17.15" + } + }, "node_modules/karma/node_modules/anymatch": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", @@ -4648,17 +2979,6 @@ "node": ">=0.10.0" } }, - "node_modules/labeled-stream-splicer": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.2.tgz", - "integrity": "sha512-Ca4LSXFFZUjPScRaqOcFxneA0VpKZr4MMYCljyQr4LIewTLb3Y0IUTIsnBBsVubIeEfxeSZpSjSsRM8APEQaAw==", - "dev": true, - "peer": true, - "dependencies": { - "inherits": "^2.0.1", - "stream-splicer": "^2.0.0" - } - }, "node_modules/layout-bmfont-text": { "version": "1.3.4", "resolved": "https://registry.npmjs.org/layout-bmfont-text/-/layout-bmfont-text-1.3.4.tgz", @@ -4713,13 +3033,6 @@ "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==", "dev": true }, - "node_modules/lodash.memoize": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz", - "integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=", - "dev": true, - "peer": true - }, "node_modules/log-symbols": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", @@ -4819,16 +3132,6 @@ "yallist": "^2.1.2" } }, - "node_modules/map-cache": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", - "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/map-limit": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/map-limit/-/map-limit-0.0.1.tgz", @@ -4847,31 +3150,6 @@ "wrappy": "1" } }, - "node_modules/map-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", - "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", - "dev": true, - "peer": true, - "dependencies": { - "object-visit": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/md5.js": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", - "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", - "dev": true, - "peer": true, - "dependencies": { - "hash-base": "^3.0.0", - "inherits": "^2.0.1", - "safe-buffer": "^5.1.2" - } - }, "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -4909,52 +3187,6 @@ "node": ">= 0.6" } }, - "node_modules/micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "dev": true, - "peer": true, - "dependencies": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/miller-rabin": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", - "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", - "dev": true, - "peer": true, - "dependencies": { - "bn.js": "^4.0.0", - "brorand": "^1.0.1" - }, - "bin": { - "miller-rabin": "bin/miller-rabin" - } - }, - "node_modules/miller-rabin/node_modules/bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true, - "peer": true - }, "node_modules/mime": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", @@ -5016,13 +3248,6 @@ "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" }, - "node_modules/minimalistic-crypto-utils": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", - "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=", - "dev": true, - "peer": true - }, "node_modules/minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -5040,33 +3265,6 @@ "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "dev": true }, - "node_modules/mixin-deep": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", - "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", - "dev": true, - "peer": true, - "dependencies": { - "for-in": "^1.0.2", - "is-extendable": "^1.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/mixin-deep/node_modules/is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, - "peer": true, - "dependencies": { - "is-plain-object": "^2.0.4" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/mkdirp": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.4.tgz", @@ -5080,13 +3278,6 @@ "mkdirp": "bin/cmd.js" } }, - "node_modules/mkdirp-classic": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", - "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", - "dev": true, - "peer": true - }, "node_modules/mocha": { "version": "6.2.3", "resolved": "https://registry.npmjs.org/mocha/-/mocha-6.2.3.tgz", @@ -5170,36 +3361,6 @@ "node": ">=6" } }, - "node_modules/module-deps": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-6.2.2.tgz", - "integrity": "sha512-a9y6yDv5u5I4A+IPHTnqFxcaKr4p50/zxTjcQJaX2ws9tN/W6J6YXnEKhqRyPhl494dkcxx951onSKVezmI+3w==", - "dev": true, - "peer": true, - "dependencies": { - "browser-resolve": "^1.7.0", - "cached-path-relative": "^1.0.2", - "concat-stream": "~1.6.0", - "defined": "^1.0.0", - "detective": "^5.2.0", - "duplexer2": "^0.1.2", - "inherits": "^2.0.1", - "JSONStream": "^1.0.3", - "parents": "^1.0.0", - "readable-stream": "^2.0.2", - "resolve": "^1.4.0", - "stream-combiner2": "^1.1.1", - "subarg": "^1.0.0", - "through2": "^2.0.0", - "xtend": "^4.0.0" - }, - "bin": { - "module-deps": "bin/cmd.js" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -5217,37 +3378,6 @@ "multicast-dns": "cli.js" } }, - "node_modules/nan": { - "version": "2.17.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz", - "integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==", - "dev": true, - "optional": true, - "peer": true - }, - "node_modules/nanomatch": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", - "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", - "dev": true, - "peer": true, - "dependencies": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "fragment-cache": "^0.2.1", - "is-windows": "^1.0.2", - "kind-of": "^6.0.2", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/native-promise-only": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/native-promise-only/-/native-promise-only-0.8.1.tgz", @@ -5349,47 +3479,6 @@ "integrity": "sha1-8MaapQ78lbhmwYb0AKM3acsvEpE=", "dev": true }, - "node_modules/object-copy": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", - "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", - "dev": true, - "peer": true, - "dependencies": { - "copy-descriptor": "^0.1.0", - "define-property": "^0.2.5", - "kind-of": "^3.0.3" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-copy/node_modules/define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "peer": true, - "dependencies": { - "is-descriptor": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-copy/node_modules/kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "peer": true, - "dependencies": { - "is-buffer": "^1.1.5" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/object-inspect": { "version": "1.12.2", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz", @@ -5407,19 +3496,6 @@ "node": ">= 0.4" } }, - "node_modules/object-visit": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", - "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", - "dev": true, - "peer": true, - "dependencies": { - "isobject": "^3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/object.assign": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", @@ -5451,19 +3527,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/object.pick": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", - "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", - "dev": true, - "peer": true, - "dependencies": { - "isobject": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/obuf": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/obuf/-/obuf-1.1.2.tgz", @@ -5543,22 +3606,6 @@ "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", "dev": true }, - "node_modules/os-browserify": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", - "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=", - "dev": true, - "peer": true - }, - "node_modules/os-shim": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/os-shim/-/os-shim-0.1.3.tgz", - "integrity": "sha1-a2LDeRz3kJ6jXtRuF2WLtBfLORc=", - "dev": true, - "engines": { - "node": ">= 0.4.0" - } - }, "node_modules/os-tmpdir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", @@ -5568,16 +3615,6 @@ "node": ">=0.10.0" } }, - "node_modules/outpipe": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/outpipe/-/outpipe-1.1.1.tgz", - "integrity": "sha1-UM+GFjZeh+Ax4ppeyTOaPaRyX6I=", - "dev": true, - "peer": true, - "dependencies": { - "shell-quote": "^1.4.2" - } - }, "node_modules/p-limit": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", @@ -5626,38 +3663,6 @@ "node": ">=6" } }, - "node_modules/pako": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", - "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", - "dev": true, - "peer": true - }, - "node_modules/parents": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz", - "integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=", - "dev": true, - "peer": true, - "dependencies": { - "path-platform": "~0.11.15" - } - }, - "node_modules/parse-asn1": { - "version": "5.1.5", - "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.5.tgz", - "integrity": "sha512-jkMYn1dcJqF6d5CpU689bq7w/b5ALS9ROVSpQDPrZsqqesUJii9qutvoT5ltGedNXMO2e16YUWIghG9KxaViTQ==", - "dev": true, - "peer": true, - "dependencies": { - "asn1.js": "^4.0.0", - "browserify-aes": "^1.0.0", - "create-hash": "^1.1.0", - "evp_bytestokey": "^1.0.0", - "pbkdf2": "^3.0.3", - "safe-buffer": "^5.1.1" - } - }, "node_modules/parse-bmfont-ascii": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/parse-bmfont-ascii/-/parse-bmfont-ascii-1.0.6.tgz", @@ -5712,30 +3717,6 @@ "node": ">= 0.8" } }, - "node_modules/pascalcase": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", - "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/path-browserify": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", - "integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==", - "dev": true, - "peer": true - }, - "node_modules/path-dirname": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", - "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", - "dev": true, - "peer": true - }, "node_modules/path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", @@ -5759,16 +3740,6 @@ "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, - "node_modules/path-platform": { - "version": "0.11.15", - "resolved": "https://registry.npmjs.org/path-platform/-/path-platform-0.11.15.tgz", - "integrity": "sha1-6GQhf3TDaFDwhSt43Hv31KVyG/I=", - "dev": true, - "peer": true, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/path-to-regexp": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", @@ -5784,23 +3755,6 @@ "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", "dev": true }, - "node_modules/pbkdf2": { - "version": "3.0.17", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", - "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", - "dev": true, - "peer": true, - "dependencies": { - "create-hash": "^1.1.2", - "create-hmac": "^1.1.4", - "ripemd160": "^2.0.1", - "safe-buffer": "^5.0.1", - "sha.js": "^2.4.8" - }, - "engines": { - "node": ">=0.12" - } - }, "node_modules/phin": { "version": "2.9.3", "resolved": "https://registry.npmjs.org/phin/-/phin-2.9.3.tgz", @@ -5881,16 +3835,6 @@ "node": ">=8" } }, - "node_modules/posix-character-classes": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", - "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/present": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/present/-/present-0.0.6.tgz", @@ -5935,35 +3879,6 @@ "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", "dev": true }, - "node_modules/public-encrypt": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", - "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", - "dev": true, - "peer": true, - "dependencies": { - "bn.js": "^4.1.0", - "browserify-rsa": "^4.0.0", - "create-hash": "^1.1.0", - "parse-asn1": "^5.0.0", - "randombytes": "^2.0.1", - "safe-buffer": "^5.1.2" - } - }, - "node_modules/public-encrypt/node_modules/bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true, - "peer": true - }, - "node_modules/punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", - "dev": true, - "peer": true - }, "node_modules/qjobs": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/qjobs/-/qjobs-1.2.0.tgz", @@ -6011,44 +3926,12 @@ "engines": { "node": ">=0.10.0" } - }, - "node_modules/querystring": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", - "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", - "deprecated": "The querystring API is considered Legacy. new code should use the URLSearchParams API instead.", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.4.x" - } - }, - "node_modules/querystring-es3": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", - "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.4.x" - } - }, - "node_modules/randombytes": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", - "dependencies": { - "safe-buffer": "^5.1.0" - } - }, - "node_modules/randomfill": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", - "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", - "dev": true, - "peer": true, + }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", "dependencies": { - "randombytes": "^2.0.5", "safe-buffer": "^5.1.0" } }, @@ -6074,16 +3957,6 @@ "node": ">= 0.8" } }, - "node_modules/read-only-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-2.0.0.tgz", - "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=", - "dev": true, - "peer": true, - "dependencies": { - "readable-stream": "^2.0.2" - } - }, "node_modules/readable-stream": { "version": "2.3.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", @@ -6111,21 +3984,6 @@ "safe-buffer": "~5.1.0" } }, - "node_modules/readdirp": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", - "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", - "dev": true, - "peer": true, - "dependencies": { - "graceful-fs": "^4.1.11", - "micromatch": "^3.1.10", - "readable-stream": "^2.0.2" - }, - "engines": { - "node": ">=0.10" - } - }, "node_modules/rechoir": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.8.0.tgz", @@ -6138,47 +3996,6 @@ "node": ">= 10.13.0" } }, - "node_modules/regex-not": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", - "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", - "dev": true, - "peer": true, - "dependencies": { - "extend-shallow": "^3.0.2", - "safe-regex": "^1.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/remove-trailing-separator": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", - "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", - "dev": true, - "peer": true - }, - "node_modules/repeat-element": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", - "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/repeat-string": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10" - } - }, "node_modules/replace": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/replace/-/replace-1.2.0.tgz", @@ -6491,24 +4308,6 @@ "node": ">=8" } }, - "node_modules/resolve-url": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", - "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", - "deprecated": "https://github.com/lydell/resolve-url#deprecated", - "dev": true, - "peer": true - }, - "node_modules/ret": { - "version": "0.1.15", - "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", - "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.12" - } - }, "node_modules/retry": { "version": "0.13.1", "resolved": "https://registry.npmjs.org/retry/-/retry-0.13.1.tgz", @@ -6535,17 +4334,6 @@ "rimraf": "bin.js" } }, - "node_modules/ripemd160": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", - "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", - "dev": true, - "peer": true, - "dependencies": { - "hash-base": "^3.0.0", - "inherits": "^2.0.1" - } - }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -6565,16 +4353,6 @@ } ] }, - "node_modules/safe-regex": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", - "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", - "dev": true, - "peer": true, - "dependencies": { - "ret": "~0.1.10" - } - }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", @@ -6754,54 +4532,11 @@ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true }, - "node_modules/set-value": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", - "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", - "dev": true, - "peer": true, - "dependencies": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.3", - "split-string": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/set-value/node_modules/extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "peer": true, - "dependencies": { - "is-extendable": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/setprototypeof": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, - "node_modules/sha.js": { - "version": "2.4.11", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", - "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", - "dev": true, - "peer": true, - "dependencies": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - }, - "bin": { - "sha.js": "bin.js" - } - }, "node_modules/shallow-clone": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz", @@ -6814,34 +4549,6 @@ "node": ">=8" } }, - "node_modules/shasum": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/shasum/-/shasum-1.0.2.tgz", - "integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=", - "dev": true, - "peer": true, - "dependencies": { - "json-stable-stringify": "~0.0.0", - "sha.js": "~2.4.4" - } - }, - "node_modules/shasum-object": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shasum-object/-/shasum-object-1.0.0.tgz", - "integrity": "sha512-Iqo5rp/3xVi6M4YheapzZhhGPVs0yZwHj7wvwQ1B9z8H6zk+FEnI7y3Teq7qwnekfEhu8WmG2z0z4iWZaxLWVg==", - "dev": true, - "peer": true, - "dependencies": { - "fast-safe-stringify": "^2.0.7" - } - }, - "node_modules/shell-quote": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.2.tgz", - "integrity": "sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==", - "dev": true, - "peer": true - }, "node_modules/side-channel": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", @@ -6915,147 +4622,6 @@ "node": ">=4" } }, - "node_modules/snapdragon": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", - "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", - "dev": true, - "peer": true, - "dependencies": { - "base": "^0.11.1", - "debug": "^2.2.0", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "map-cache": "^0.2.2", - "source-map": "^0.5.6", - "source-map-resolve": "^0.5.0", - "use": "^3.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon-node": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", - "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", - "dev": true, - "peer": true, - "dependencies": { - "define-property": "^1.0.0", - "isobject": "^3.0.0", - "snapdragon-util": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon-node/node_modules/define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "peer": true, - "dependencies": { - "is-descriptor": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon-node/node_modules/is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "peer": true, - "dependencies": { - "kind-of": "^6.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon-node/node_modules/is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "peer": true, - "dependencies": { - "kind-of": "^6.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon-node/node_modules/is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "peer": true, - "dependencies": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon-util": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", - "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", - "dev": true, - "peer": true, - "dependencies": { - "kind-of": "^3.2.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon-util/node_modules/kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "peer": true, - "dependencies": { - "is-buffer": "^1.1.5" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon/node_modules/define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "peer": true, - "dependencies": { - "is-descriptor": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/snapdragon/node_modules/extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "peer": true, - "dependencies": { - "is-extendable": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/socket.io": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.1.1.tgz", @@ -7164,31 +4730,6 @@ "websocket-driver": "^0.7.4" } }, - "node_modules/source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/source-map-resolve": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz", - "integrity": "sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==", - "deprecated": "See https://github.com/lydell/source-map-resolve#deprecated", - "dev": true, - "peer": true, - "dependencies": { - "atob": "^2.1.2", - "decode-uri-component": "^0.2.0", - "resolve-url": "^0.2.1", - "source-map-url": "^0.4.0", - "urix": "^0.1.0" - } - }, "node_modules/source-map-support": { "version": "0.5.21", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", @@ -7206,14 +4747,6 @@ "node": ">=0.10.0" } }, - "node_modules/source-map-url": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", - "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", - "deprecated": "See https://github.com/lydell/source-map-url#deprecated", - "dev": true, - "peer": true - }, "node_modules/spdy": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/spdy/-/spdy-4.0.2.tgz", @@ -7297,52 +4830,12 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, - "node_modules/split-string": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", - "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", - "dev": true, - "peer": true, - "dependencies": { - "extend-shallow": "^3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, - "node_modules/static-extend": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", - "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", - "dev": true, - "peer": true, - "dependencies": { - "define-property": "^0.2.5", - "object-copy": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/static-extend/node_modules/define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "peer": true, - "dependencies": { - "is-descriptor": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", @@ -7351,84 +4844,6 @@ "node": ">= 0.6" } }, - "node_modules/stream-browserify": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.2.tgz", - "integrity": "sha512-nX6hmklHs/gr2FuxYDltq8fJA1GDlxKQCz8O/IM4atRqBH8OORmBNgfvW5gG10GT/qQ9u0CzIvr2X5Pkt6ntqg==", - "dev": true, - "peer": true, - "dependencies": { - "inherits": "~2.0.1", - "readable-stream": "^2.0.2" - } - }, - "node_modules/stream-combiner2": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", - "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", - "dev": true, - "peer": true, - "dependencies": { - "duplexer2": "~0.1.0", - "readable-stream": "^2.0.2" - } - }, - "node_modules/stream-http": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-3.1.1.tgz", - "integrity": "sha512-S7OqaYu0EkFpgeGFb/NPOoPLxFko7TPqtEeFg5DXPB4v/KETHG0Ln6fRFrNezoelpaDKmycEmmZ81cC9DAwgYg==", - "dev": true, - "peer": true, - "dependencies": { - "builtin-status-codes": "^3.0.0", - "inherits": "^2.0.4", - "readable-stream": "^3.6.0", - "xtend": "^4.0.2" - } - }, - "node_modules/stream-http/node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true, - "peer": true - }, - "node_modules/stream-http/node_modules/readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, - "peer": true, - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/stream-http/node_modules/xtend": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", - "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.4" - } - }, - "node_modules/stream-splicer": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.1.tgz", - "integrity": "sha512-Xizh4/NPuYSyAXyT7g8IvdJ9HJpxIGL9PjyhtywCZvvP0OPIdqyrr4dMikeuvY8xahpdKEBlBTySe583totajg==", - "dev": true, - "peer": true, - "dependencies": { - "inherits": "^2.0.1", - "readable-stream": "^2.0.2" - } - }, "node_modules/streamroller": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-1.0.6.tgz", @@ -7590,16 +5005,6 @@ "node": ">=0.10.0" } }, - "node_modules/subarg": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz", - "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=", - "dev": true, - "peer": true, - "dependencies": { - "minimist": "^1.1.0" - } - }, "node_modules/super-animejs": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/super-animejs/-/super-animejs-3.1.0.tgz", @@ -7624,16 +5029,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/syntax-error": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz", - "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==", - "dev": true, - "peer": true, - "dependencies": { - "acorn-node": "^1.2.0" - } - }, "node_modules/tapable": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", @@ -7769,17 +5164,6 @@ "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, - "node_modules/through2": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", - "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", - "dev": true, - "peer": true, - "dependencies": { - "readable-stream": "~2.3.6", - "xtend": "~4.0.1" - } - }, "node_modules/thunky": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz", @@ -7794,29 +5178,6 @@ "node": ">=0.10.0" } }, - "node_modules/timers-browserify": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz", - "integrity": "sha1-ycWLV1voQHN1y14kYtrO50NZ9B0=", - "dev": true, - "peer": true, - "dependencies": { - "process": "~0.11.0" - }, - "engines": { - "node": ">=0.6.0" - } - }, - "node_modules/timers-browserify/node_modules/process": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", - "dev": true, - "peer": true, - "engines": { - "node": ">= 0.6.0" - } - }, "node_modules/tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", @@ -7835,62 +5196,6 @@ "integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=", "dev": true }, - "node_modules/to-object-path": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", - "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", - "dev": true, - "peer": true, - "dependencies": { - "kind-of": "^3.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/to-object-path/node_modules/kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "peer": true, - "dependencies": { - "is-buffer": "^1.1.5" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/to-regex": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", - "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", - "dev": true, - "peer": true, - "dependencies": { - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "regex-not": "^1.0.2", - "safe-regex": "^1.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/to-regex-range": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", - "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", - "dev": true, - "peer": true, - "dependencies": { - "is-number": "^3.0.0", - "repeat-string": "^1.6.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/toidentifier": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", @@ -7899,13 +5204,6 @@ "node": ">=0.6" } }, - "node_modules/tty-browserify": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", - "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==", - "dev": true, - "peer": true - }, "node_modules/type-detect": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-1.0.0.tgz", @@ -7927,13 +5225,6 @@ "node": ">= 0.6" } }, - "node_modules/typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", - "dev": true, - "peer": true - }, "node_modules/uglify-es": { "version": "3.3.9", "resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.3.9.tgz", @@ -7966,49 +5257,6 @@ "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==", "dev": true }, - "node_modules/umd": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz", - "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==", - "dev": true, - "peer": true, - "bin": { - "umd": "bin/cli.js" - } - }, - "node_modules/undeclared-identifiers": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/undeclared-identifiers/-/undeclared-identifiers-1.1.3.tgz", - "integrity": "sha512-pJOW4nxjlmfwKApE4zvxLScM/njmwj/DiUBv7EabwE4O8kRUy+HIwxQtZLBPll/jx1LJyBcqNfB3/cpv9EZwOw==", - "dev": true, - "peer": true, - "dependencies": { - "acorn-node": "^1.3.0", - "dash-ast": "^1.0.0", - "get-assigned-identifiers": "^1.2.0", - "simple-concat": "^1.0.0", - "xtend": "^4.0.1" - }, - "bin": { - "undeclared-identifiers": "bin.js" - } - }, - "node_modules/union-value": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", - "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", - "dev": true, - "peer": true, - "dependencies": { - "arr-union": "^3.1.0", - "get-value": "^2.0.6", - "is-extendable": "^0.1.1", - "set-value": "^2.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/universalify": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", @@ -8026,69 +5274,6 @@ "node": ">= 0.8" } }, - "node_modules/unset-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", - "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", - "dev": true, - "peer": true, - "dependencies": { - "has-value": "^0.3.1", - "isobject": "^3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/unset-value/node_modules/has-value": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", - "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", - "dev": true, - "peer": true, - "dependencies": { - "get-value": "^2.0.3", - "has-values": "^0.1.4", - "isobject": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/unset-value/node_modules/has-value/node_modules/isobject": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true, - "peer": true, - "dependencies": { - "isarray": "1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/unset-value/node_modules/has-values": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", - "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/upath": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz", - "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==", - "dev": true, - "peer": true, - "engines": { - "node": ">=4", - "yarn": "*" - } - }, "node_modules/update-browserslist-db": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz", @@ -8130,48 +5315,12 @@ "node": ">=6" } }, - "node_modules/urix": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", - "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", - "deprecated": "Please see https://github.com/lydell/urix#deprecated", - "dev": true, - "peer": true - }, - "node_modules/url": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", - "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", - "dev": true, - "peer": true, - "dependencies": { - "punycode": "1.3.2", - "querystring": "0.2.0" - } - }, "node_modules/url-set-query": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/url-set-query/-/url-set-query-1.0.0.tgz", "integrity": "sha512-3AChu4NiXquPfeckE5R5cGdiHCMWJx1dwCWOmWIL4KHAziJNOFIYJlpGFeKDvwLPHovZRCxK3cYlwzqI9Vp+Gg==", "dev": true }, - "node_modules/url/node_modules/punycode": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", - "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", - "dev": true, - "peer": true - }, - "node_modules/use": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", - "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", - "dev": true, - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/useragent": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/useragent/-/useragent-2.3.0.tgz", @@ -8182,16 +5331,6 @@ "tmp": "0.0.x" } }, - "node_modules/util": { - "version": "0.10.4", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", - "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", - "dev": true, - "peer": true, - "dependencies": { - "inherits": "2.0.3" - } - }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -8221,13 +5360,6 @@ "node": ">= 0.8" } }, - "node_modules/vm-browserify": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz", - "integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==", - "dev": true, - "peer": true - }, "node_modules/void-elements": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", @@ -8237,25 +5369,6 @@ "node": ">=0.10.0" } }, - "node_modules/watchify": { - "version": "3.11.1", - "resolved": "https://registry.npmjs.org/watchify/-/watchify-3.11.1.tgz", - "integrity": "sha512-WwnUClyFNRMB2NIiHgJU9RQPQNqVeFk7OmZaWf5dC5EnNa0Mgr7imBydbaJ7tGTuPM2hz1Cb4uiBvK9NVxMfog==", - "dev": true, - "peer": true, - "dependencies": { - "anymatch": "^2.0.0", - "browserify": "^16.1.0", - "chokidar": "^2.1.1", - "defined": "^1.0.0", - "outpipe": "^1.1.0", - "through2": "^2.0.0", - "xtend": "^4.0.0" - }, - "bin": { - "watchify": "bin/cmd.js" - } - }, "node_modules/watchpack": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", @@ -9657,41 +6770,6 @@ "negotiator": "0.6.3" } }, - "acorn": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.2.0.tgz", - "integrity": "sha512-apwXVmYVpQ34m/i71vrApRrRKCWQnZZF1+npOD0WV5xZFfwWOmKGQ2RWlfdy9vWITsenisM8M0Qeq8agcFHNiQ==", - "dev": true, - "peer": true - }, - "acorn-node": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.8.2.tgz", - "integrity": "sha512-8mt+fslDufLYntIoPAaIMUe/lrbrehIiwmR3t2k9LljIzoigEPF27eLk2hy8zSGzmR/ogr7zbRKINMo1u0yh5A==", - "dev": true, - "peer": true, - "requires": { - "acorn": "^7.0.0", - "acorn-walk": "^7.0.0", - "xtend": "^4.0.2" - }, - "dependencies": { - "xtend": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", - "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", - "dev": true, - "peer": true - } - } - }, - "acorn-walk": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.1.1.tgz", - "integrity": "sha512-wdlPY2tm/9XBr7QkKlq0WQVgiuGTX6YWPyRyBviSoScBuLfTVQhvwg6wJ369GJ/1nPfTLMfnrFIfjqVg6d+jQQ==", - "dev": true, - "peer": true - }, "aframe": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/aframe/-/aframe-1.1.0.tgz", @@ -9796,29 +6874,6 @@ "resolved": "https://registry.npmjs.org/ansi-html-community/-/ansi-html-community-0.0.8.tgz", "integrity": "sha512-1APHAyr3+PCamwNw3bXCPp4HFLONZt/yIH0sZp0/469KWNTEy+qN5jQ3GVX6DMZ1UXAi34yVwtTeaG/HpBuuzw==" }, - "anymatch": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", - "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", - "dev": true, - "peer": true, - "requires": { - "micromatch": "^3.1.4", - "normalize-path": "^2.1.1" - }, - "dependencies": { - "normalize-path": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", - "dev": true, - "peer": true, - "requires": { - "remove-trailing-separator": "^1.0.1" - } - } - } - }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -9828,27 +6883,6 @@ "sprintf-js": "~1.0.2" } }, - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true, - "peer": true - }, - "arr-flatten": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", - "dev": true, - "peer": true - }, - "arr-union": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", - "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", - "dev": true, - "peer": true - }, "array-flatten": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-2.1.2.tgz", @@ -9860,13 +6894,6 @@ "integrity": "sha512-PBqgo1Y2XWSksBzq3GFPEb798ZrW2snAcmr4drbVeF/6MT/5aBlkGJEvu5A/CzXHf4EjbHOj/ZowatjlIiVidA==", "dev": true }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true, - "peer": true - }, "arraybuffer.slice": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz", @@ -9879,70 +6906,12 @@ "integrity": "sha512-HkI/zLo2AbSRO4fqVkmyf3hms0bJDs3iboHqTrNuwTiCRvdYXM7HFhfhB6Dk51anV2LM/IMB83mtK9mHw4FlAg==", "dev": true }, - "asn1.js": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", - "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", - "dev": true, - "peer": true, - "requires": { - "bn.js": "^4.0.0", - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0" - }, - "dependencies": { - "bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true, - "peer": true - } - } - }, - "assert": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/assert/-/assert-1.5.0.tgz", - "integrity": "sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA==", - "dev": true, - "peer": true, - "requires": { - "object-assign": "^4.1.1", - "util": "0.10.3" - }, - "dependencies": { - "inherits": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", - "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", - "dev": true, - "peer": true - }, - "util": { - "version": "0.10.3", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", - "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", - "dev": true, - "peer": true, - "requires": { - "inherits": "2.0.1" - } - } - } - }, "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, - "assign-symbols": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", - "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", - "dev": true, - "peer": true - }, "async": { "version": "2.6.3", "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", @@ -9952,26 +6921,12 @@ "lodash": "^4.17.14" } }, - "async-each": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", - "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==", - "dev": true, - "peer": true - }, "async-limiter": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==", "dev": true }, - "atob": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", - "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", - "dev": true, - "peer": true - }, "backo2": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", @@ -9983,79 +6938,12 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, - "base": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", - "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", - "dev": true, - "peer": true, - "requires": { - "cache-base": "^1.0.1", - "class-utils": "^0.3.5", - "component-emitter": "^1.2.1", - "define-property": "^1.0.0", - "isobject": "^3.0.1", - "mixin-deep": "^1.2.0", - "pascalcase": "^0.1.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "peer": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "peer": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "peer": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "peer": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, "base64-arraybuffer": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz", "integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=", "dev": true }, - "base64-js": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", - "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==", - "dev": true, - "peer": true - }, "base64id": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/base64id/-/base64id-1.0.0.tgz", @@ -10067,31 +6955,13 @@ "resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz", "integrity": "sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw==" }, - "better-assert": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz", - "integrity": "sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI=", - "dev": true, - "requires": { - "callsite": "1.0.0" - } - }, - "binary-extensions": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", - "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", - "dev": true, - "peer": true - }, - "bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "better-assert": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz", + "integrity": "sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI=", "dev": true, - "optional": true, - "peer": true, "requires": { - "file-uri-to-path": "1.0.0" + "callsite": "1.0.0" } }, "blob": { @@ -10106,13 +6976,6 @@ "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", "dev": true }, - "bn.js": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.1.1.tgz", - "integrity": "sha512-IUTD/REb78Z2eodka1QZyyEk66pciRcP6Sroka0aI3tG/iwIdYLrBD62RsubR7vqdt3WyX8p4jxeatzmRSphtA==", - "dev": true, - "peer": true - }, "body-parser": { "version": "1.20.1", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", @@ -10162,258 +7025,12 @@ "concat-map": "0.0.1" } }, - "braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "dev": true, - "peer": true, - "requires": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "peer": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "brorand": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", - "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", - "dev": true, - "peer": true - }, - "browser-pack": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.1.0.tgz", - "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==", - "dev": true, - "peer": true, - "requires": { - "combine-source-map": "~0.8.0", - "defined": "^1.0.0", - "JSONStream": "^1.0.3", - "safe-buffer": "^5.1.1", - "through2": "^2.0.0", - "umd": "^3.0.0" - } - }, - "browser-resolve": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.3.tgz", - "integrity": "sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ==", - "dev": true, - "peer": true, - "requires": { - "resolve": "1.1.7" - }, - "dependencies": { - "resolve": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", - "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", - "dev": true, - "peer": true - } - } - }, "browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, - "browserify": { - "version": "16.5.1", - "resolved": "https://registry.npmjs.org/browserify/-/browserify-16.5.1.tgz", - "integrity": "sha512-EQX0h59Pp+0GtSRb5rL6OTfrttlzv+uyaUVlK6GX3w11SQ0jKPKyjC/54RhPR2ib2KmfcELM06e8FxcI5XNU2A==", - "dev": true, - "peer": true, - "requires": { - "assert": "^1.4.0", - "browser-pack": "^6.0.1", - "browser-resolve": "^1.11.0", - "browserify-zlib": "~0.2.0", - "buffer": "~5.2.1", - "cached-path-relative": "^1.0.0", - "concat-stream": "^1.6.0", - "console-browserify": "^1.1.0", - "constants-browserify": "~1.0.0", - "crypto-browserify": "^3.0.0", - "defined": "^1.0.0", - "deps-sort": "^2.0.0", - "domain-browser": "^1.2.0", - "duplexer2": "~0.1.2", - "events": "^2.0.0", - "glob": "^7.1.0", - "has": "^1.0.0", - "htmlescape": "^1.1.0", - "https-browserify": "^1.0.0", - "inherits": "~2.0.1", - "insert-module-globals": "^7.0.0", - "JSONStream": "^1.0.3", - "labeled-stream-splicer": "^2.0.0", - "mkdirp-classic": "^0.5.2", - "module-deps": "^6.0.0", - "os-browserify": "~0.3.0", - "parents": "^1.0.1", - "path-browserify": "~0.0.0", - "process": "~0.11.0", - "punycode": "^1.3.2", - "querystring-es3": "~0.2.0", - "read-only-stream": "^2.0.0", - "readable-stream": "^2.0.2", - "resolve": "^1.1.4", - "shasum": "^1.0.0", - "shell-quote": "^1.6.1", - "stream-browserify": "^2.0.0", - "stream-http": "^3.0.0", - "string_decoder": "^1.1.1", - "subarg": "^1.0.0", - "syntax-error": "^1.1.1", - "through2": "^2.0.0", - "timers-browserify": "^1.0.1", - "tty-browserify": "0.0.1", - "url": "~0.11.0", - "util": "~0.10.1", - "vm-browserify": "^1.0.0", - "xtend": "^4.0.0" - }, - "dependencies": { - "process": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", - "dev": true, - "peer": true - } - } - }, - "browserify-aes": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", - "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", - "dev": true, - "peer": true, - "requires": { - "buffer-xor": "^1.0.3", - "cipher-base": "^1.0.0", - "create-hash": "^1.1.0", - "evp_bytestokey": "^1.0.3", - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - } - }, - "browserify-cipher": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", - "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", - "dev": true, - "peer": true, - "requires": { - "browserify-aes": "^1.0.4", - "browserify-des": "^1.0.0", - "evp_bytestokey": "^1.0.0" - } - }, - "browserify-des": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", - "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", - "dev": true, - "peer": true, - "requires": { - "cipher-base": "^1.0.1", - "des.js": "^1.0.0", - "inherits": "^2.0.1", - "safe-buffer": "^5.1.2" - } - }, - "browserify-rsa": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", - "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", - "dev": true, - "peer": true, - "requires": { - "bn.js": "^4.1.0", - "randombytes": "^2.0.1" - }, - "dependencies": { - "bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true, - "peer": true - } - } - }, - "browserify-sign": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.1.0.tgz", - "integrity": "sha512-VYxo7cDCeYUoBZ0ZCy4UyEUCP3smyBd4DRQM5nrFS1jJjPJjX7rP3oLRpPoWfkhQfyJ0I9ZbHbKafrFD/SGlrg==", - "dev": true, - "peer": true, - "requires": { - "bn.js": "^5.1.1", - "browserify-rsa": "^4.0.1", - "create-hash": "^1.2.0", - "create-hmac": "^1.1.7", - "elliptic": "^6.5.2", - "inherits": "^2.0.4", - "parse-asn1": "^5.1.5", - "readable-stream": "^3.6.0" - }, - "dependencies": { - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true, - "peer": true - }, - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, - "peer": true, - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - } - } - }, - "browserify-zlib": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", - "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", - "dev": true, - "peer": true, - "requires": { - "pako": "~1.0.5" - } - }, "browserslist": { "version": "4.21.4", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.4.tgz", @@ -10425,17 +7042,6 @@ "update-browserslist-db": "^1.0.9" } }, - "buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", - "integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==", - "dev": true, - "peer": true, - "requires": { - "base64-js": "^1.0.2", - "ieee754": "^1.1.4" - } - }, "buffer-alloc": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", @@ -10475,50 +7081,11 @@ "integrity": "sha512-3dthu5CYiVB1DEJp61FtApNnNndTckcqe4pFcLdvHtrpG+kcyekCJKg4MRiDcFW7A6AODnXB9U4dwQiCW5kzJQ==", "dev": true }, - "buffer-xor": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", - "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", - "dev": true, - "peer": true - }, - "builtin-status-codes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", - "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", - "dev": true, - "peer": true - }, "bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==" }, - "cache-base": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", - "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", - "dev": true, - "peer": true, - "requires": { - "collection-visit": "^1.0.0", - "component-emitter": "^1.2.1", - "get-value": "^2.0.6", - "has-value": "^1.0.0", - "isobject": "^3.0.1", - "set-value": "^2.0.0", - "to-object-path": "^0.3.0", - "union-value": "^1.0.0", - "unset-value": "^1.0.0" - } - }, - "cached-path-relative": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.0.2.tgz", - "integrity": "sha512-5r2GqsoEb4qMTTN9J+WzXfjov+hjxT+j3u5K+kIVNIwAd99DLCJE9pBIMP1qVeybV6JiijL385Oz0DcYxfbOIg==", - "dev": true, - "peer": true - }, "call-bind": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", @@ -10579,82 +7146,11 @@ "dev": true, "requires": {} }, - "chokidar": { - "version": "2.1.8", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", - "integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==", - "dev": true, - "peer": true, - "requires": { - "anymatch": "^2.0.0", - "async-each": "^1.0.1", - "braces": "^2.3.2", - "fsevents": "^1.2.7", - "glob-parent": "^3.1.0", - "inherits": "^2.0.3", - "is-binary-path": "^1.0.0", - "is-glob": "^4.0.0", - "normalize-path": "^3.0.0", - "path-is-absolute": "^1.0.0", - "readdirp": "^2.2.1", - "upath": "^1.1.1" - }, - "dependencies": { - "fsevents": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", - "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", - "dev": true, - "optional": true, - "peer": true, - "requires": { - "bindings": "^1.5.0", - "nan": "^2.12.1" - } - } - } - }, "chrome-trace-event": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz", "integrity": "sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==" }, - "cipher-base": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", - "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", - "dev": true, - "peer": true, - "requires": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - } - }, - "class-utils": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", - "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", - "dev": true, - "peer": true, - "requires": { - "arr-union": "^3.1.0", - "define-property": "^0.2.5", - "isobject": "^3.0.0", - "static-extend": "^0.1.1" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "peer": true, - "requires": { - "is-descriptor": "^0.1.0" - } - } - } - }, "cliui": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", @@ -10705,17 +7201,6 @@ "shallow-clone": "^3.0.0" } }, - "collection-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", - "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", - "dev": true, - "peer": true, - "requires": { - "map-visit": "^1.0.0", - "object-visit": "^1.0.0" - } - }, "color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -10742,19 +7227,6 @@ "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", "dev": true }, - "combine-source-map": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.8.0.tgz", - "integrity": "sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos=", - "dev": true, - "peer": true, - "requires": { - "convert-source-map": "~1.1.0", - "inline-source-map": "~0.6.0", - "lodash.memoize": "~3.0.3", - "source-map": "~0.5.3" - } - }, "commander": { "version": "2.13.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.13.0.tgz", @@ -10767,13 +7239,6 @@ "integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E=", "dev": true }, - "component-emitter": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", - "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", - "dev": true, - "peer": true - }, "component-inherit": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz", @@ -10819,19 +7284,6 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, - "concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "dev": true, - "peer": true, - "requires": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^2.2.2", - "typedarray": "^0.0.6" - } - }, "connect": { "version": "3.7.0", "resolved": "https://registry.npmjs.org/connect/-/connect-3.7.0.tgz", @@ -10849,20 +7301,6 @@ "resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-2.0.0.tgz", "integrity": "sha512-U73+6lQFmfiNPrYbXqr6kZ1i1wiRqXnp2nhMsINseWXO8lDau0LGEffJ8kQi4EjLZympVgRdvqjAgiZ1tgzDDA==" }, - "console-browserify": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.2.0.tgz", - "integrity": "sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA==", - "dev": true, - "peer": true - }, - "constants-browserify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", - "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=", - "dev": true, - "peer": true - }, "content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", @@ -10876,12 +7314,6 @@ "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" }, - "convert-source-map": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz", - "integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=", - "dev": true - }, "cookie": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", @@ -10893,87 +7325,11 @@ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" }, - "copy-descriptor": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", - "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", - "dev": true, - "peer": true - }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, - "create-ecdh": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", - "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", - "dev": true, - "peer": true, - "requires": { - "bn.js": "^4.1.0", - "elliptic": "^6.0.0" - }, - "dependencies": { - "bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true, - "peer": true - } - } - }, - "create-hash": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", - "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", - "dev": true, - "peer": true, - "requires": { - "cipher-base": "^1.0.1", - "inherits": "^2.0.1", - "md5.js": "^1.3.4", - "ripemd160": "^2.0.1", - "sha.js": "^2.4.0" - } - }, - "create-hmac": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", - "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", - "dev": true, - "peer": true, - "requires": { - "cipher-base": "^1.0.3", - "create-hash": "^1.1.0", - "inherits": "^2.0.1", - "ripemd160": "^2.0.0", - "safe-buffer": "^5.0.1", - "sha.js": "^2.4.8" - } - }, - "crypto-browserify": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", - "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", - "dev": true, - "peer": true, - "requires": { - "browserify-cipher": "^1.0.0", - "browserify-sign": "^4.0.0", - "create-ecdh": "^4.0.0", - "create-hash": "^1.1.0", - "create-hmac": "^1.1.0", - "diffie-hellman": "^5.0.0", - "inherits": "^2.0.1", - "pbkdf2": "^3.0.3", - "public-encrypt": "^4.0.0", - "randombytes": "^2.0.0", - "randomfill": "^1.0.3" - } - }, "custom-event": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz", @@ -10986,13 +7342,6 @@ "integrity": "sha512-TDDkd5DkaZxZFM8p+1I3yAlvM3rSr1wbrOliG4yJiwinMZN8z/iGL7BTlDkrJcYTmgUSb4ywVCc3ZaUtOtC76w==", "dev": true }, - "dash-ast": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/dash-ast/-/dash-ast-1.0.0.tgz", - "integrity": "sha512-Vy4dx7gquTeMcQR/hDkYLGUnwVil6vk4FOOct+djUnHOUWt+zJPJAaRIXaAFkPXtJjvlY7o3rfRu0/3hpnwoUA==", - "dev": true, - "peer": true - }, "date-format": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/date-format/-/date-format-2.1.0.tgz", @@ -11068,87 +7417,11 @@ "object-keys": "^1.0.12" } }, - "define-property": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", - "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", - "dev": true, - "peer": true, - "requires": { - "is-descriptor": "^1.0.2", - "isobject": "^3.0.1" - }, - "dependencies": { - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "peer": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "peer": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "peer": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, - "defined": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", - "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", - "dev": true, - "peer": true - }, "depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==" }, - "deps-sort": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-2.0.1.tgz", - "integrity": "sha512-1orqXQr5po+3KI6kQb9A4jnXT1PBwggGl2d7Sq2xsnOeI9GPcE/tGcF9UiSZtZBM7MukY4cAh7MemS6tZYipfw==", - "dev": true, - "peer": true, - "requires": { - "JSONStream": "^1.0.3", - "shasum-object": "^1.0.0", - "subarg": "^1.0.0", - "through2": "^2.0.0" - } - }, - "des.js": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz", - "integrity": "sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA==", - "dev": true, - "peer": true, - "requires": { - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0" - } - }, "destroy": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", @@ -11159,18 +7432,6 @@ "resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.1.0.tgz", "integrity": "sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==" }, - "detective": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/detective/-/detective-5.2.0.tgz", - "integrity": "sha512-6SsIx+nUUbuK0EthKjv0zrdnajCCXVYGmbYYiYjFVpzcjwEs/JMDZ8tPRG29J/HhN56t3GJp2cGSWDRjjot8Pg==", - "dev": true, - "peer": true, - "requires": { - "acorn-node": "^1.6.1", - "defined": "^1.0.0", - "minimist": "^1.1.1" - } - }, "di": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/di/-/di-0.0.1.tgz", @@ -11180,29 +7441,8 @@ "diff": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", - "dev": true - }, - "diffie-hellman": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", - "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", - "dev": true, - "peer": true, - "requires": { - "bn.js": "^4.1.0", - "miller-rabin": "^4.0.0", - "randombytes": "^2.0.0" - }, - "dependencies": { - "bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true, - "peer": true - } - } + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true }, "dns-equal": { "version": "1.0.0", @@ -11241,29 +7481,12 @@ "integrity": "sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w==", "dev": true }, - "domain-browser": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", - "integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==", - "dev": true, - "peer": true - }, "dtype": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/dtype/-/dtype-2.0.0.tgz", "integrity": "sha512-s2YVcLKdFGS0hpFqJaTwscsyt0E8nNFdmo73Ocd81xNPj4URI4rj6D60A+vFMIw7BXWlb4yRkEwfBqcZzPGiZg==", "dev": true }, - "duplexer2": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", - "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", - "dev": true, - "peer": true, - "requires": { - "readable-stream": "^2.0.2" - } - }, "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -11274,31 +7497,6 @@ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.284.tgz", "integrity": "sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA==" }, - "elliptic": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz", - "integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==", - "dev": true, - "peer": true, - "requires": { - "bn.js": "^4.4.0", - "brorand": "^1.0.1", - "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.0", - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0", - "minimalistic-crypto-utils": "^1.0.0" - }, - "dependencies": { - "bn.js": { - "version": "4.11.9", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz", - "integrity": "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==", - "dev": true, - "peer": true - } - } - }, "emoji-regex": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", @@ -11547,62 +7745,6 @@ "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.0.tgz", "integrity": "sha512-qerSRB0p+UDEssxTtm6EDKcE7W4OaoisfIMl4CngyEhjpYglocpNg6UEqCvemdGhosAsg4sO2dXJOdyBifPGCg==" }, - "events": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/events/-/events-2.1.0.tgz", - "integrity": "sha512-3Zmiobend8P9DjmKAty0Era4jV8oJ0yGYe2nJJAxgymF9+N8F2m0hhZiMoWtcfepExzNKZumFU3ksdQbInGWCg==", - "dev": true, - "peer": true - }, - "evp_bytestokey": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", - "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", - "dev": true, - "peer": true, - "requires": { - "md5.js": "^1.3.4", - "safe-buffer": "^5.1.1" - } - }, - "expand-brackets": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "dev": true, - "peer": true, - "requires": { - "debug": "^2.3.3", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "posix-character-classes": "^0.1.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "peer": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "peer": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, "express": { "version": "4.18.2", "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", @@ -11691,100 +7833,6 @@ "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", "dev": true }, - "extend-shallow": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", - "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", - "dev": true, - "peer": true, - "requires": { - "assign-symbols": "^1.0.0", - "is-extendable": "^1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, - "peer": true, - "requires": { - "is-plain-object": "^2.0.4" - } - } - } - }, - "extglob": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", - "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "dev": true, - "peer": true, - "requires": { - "array-unique": "^0.3.2", - "define-property": "^1.0.0", - "expand-brackets": "^2.1.4", - "extend-shallow": "^2.0.1", - "fragment-cache": "^0.2.1", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "peer": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "peer": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "peer": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "peer": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "peer": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, "fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -11795,13 +7843,6 @@ "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" }, - "fast-safe-stringify": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz", - "integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==", - "dev": true, - "peer": true - }, "fastest-levenshtein": { "version": "1.0.16", "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz", @@ -11816,39 +7857,6 @@ "websocket-driver": ">=0.5.1" } }, - "file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", - "dev": true, - "optional": true, - "peer": true - }, - "fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "dev": true, - "peer": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-number": "^3.0.0", - "repeat-string": "^1.6.1", - "to-regex-range": "^2.1.0" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "peer": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, "finalhandler": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", @@ -11928,13 +7936,6 @@ } } }, - "for-in": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true, - "peer": true - }, "formatio": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/formatio/-/formatio-1.2.0.tgz", @@ -11949,16 +7950,6 @@ "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==" }, - "fragment-cache": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", - "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", - "dev": true, - "peer": true, - "requires": { - "map-cache": "^0.2.2" - } - }, "fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", @@ -12005,13 +7996,6 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, - "get-assigned-identifiers": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz", - "integrity": "sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ==", - "dev": true, - "peer": true - }, "get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -12028,13 +8012,6 @@ "has-symbols": "^1.0.3" } }, - "get-value": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", - "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", - "dev": true, - "peer": true - }, "gl-preserve-state": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/gl-preserve-state/-/gl-preserve-state-1.0.0.tgz", @@ -12054,29 +8031,6 @@ "path-is-absolute": "^1.0.0" } }, - "glob-parent": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", - "dev": true, - "peer": true, - "requires": { - "is-glob": "^3.1.0", - "path-dirname": "^1.0.0" - }, - "dependencies": { - "is-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "dev": true, - "peer": true, - "requires": { - "is-extglob": "^2.1.0" - } - } - } - }, "glob-to-regexp": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", @@ -12150,109 +8104,12 @@ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==" }, - "has-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", - "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", - "dev": true, - "peer": true, - "requires": { - "get-value": "^2.0.6", - "has-values": "^1.0.0", - "isobject": "^3.0.0" - } - }, - "has-values": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", - "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", - "dev": true, - "peer": true, - "requires": { - "is-number": "^3.0.0", - "kind-of": "^4.0.0" - }, - "dependencies": { - "kind-of": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", - "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", - "dev": true, - "peer": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "hash-base": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz", - "integrity": "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==", - "dev": true, - "peer": true, - "requires": { - "inherits": "^2.0.4", - "readable-stream": "^3.6.0", - "safe-buffer": "^5.2.0" - }, - "dependencies": { - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true, - "peer": true - }, - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, - "peer": true, - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - } - } - }, - "hash.js": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", - "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", - "dev": true, - "peer": true, - "requires": { - "inherits": "^2.0.3", - "minimalistic-assert": "^1.0.1" - } - }, - "hat": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/hat/-/hat-0.0.3.tgz", - "integrity": "sha1-uwFKnmSzeIrtgAWRdBPU/z1QLYo=", - "dev": true - }, "he": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true }, - "hmac-drbg": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", - "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", - "dev": true, - "peer": true, - "requires": { - "hash.js": "^1.0.3", - "minimalistic-assert": "^1.0.0", - "minimalistic-crypto-utils": "^1.0.1" - } - }, "hpack.js": { "version": "2.1.6", "resolved": "https://registry.npmjs.org/hpack.js/-/hpack.js-2.1.6.tgz", @@ -12269,13 +8126,6 @@ "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.3.3.tgz", "integrity": "sha512-DV5Ln36z34NNTDgnz0EWGBLZENelNAtkiFA4kyNOG2tDI6Mz1uSWiq1wAKdyjnJwyDiDO7Fa2SO1CTxPXL8VxA==" }, - "htmlescape": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz", - "integrity": "sha1-OgPtwiFLyjtmQko+eVk0lQnLA1E=", - "dev": true, - "peer": true - }, "http-deceiver": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/http-deceiver/-/http-deceiver-1.2.7.tgz", @@ -12372,13 +8222,6 @@ } } }, - "https-browserify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", - "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", - "dev": true, - "peer": true - }, "human-signals": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", @@ -12392,13 +8235,6 @@ "safer-buffer": ">= 2.1.2 < 3" } }, - "ieee754": { - "version": "1.1.13", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", - "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==", - "dev": true, - "peer": true - }, "import-local": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", @@ -12429,44 +8265,6 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, - "inline-source-map": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.6.2.tgz", - "integrity": "sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU=", - "dev": true, - "peer": true, - "requires": { - "source-map": "~0.5.3" - } - }, - "insert-module-globals": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.2.0.tgz", - "integrity": "sha512-VE6NlW+WGn2/AeOMd496AHFYmE7eLKkUY6Ty31k4og5vmA3Fjuwe9v6ifH6Xx/Hz27QvdoMoviw1/pqWRB09Sw==", - "dev": true, - "peer": true, - "requires": { - "acorn-node": "^1.5.2", - "combine-source-map": "^0.8.0", - "concat-stream": "^1.6.1", - "is-buffer": "^1.1.0", - "JSONStream": "^1.0.3", - "path-is-absolute": "^1.0.1", - "process": "~0.11.0", - "through2": "^2.0.0", - "undeclared-identifiers": "^1.1.2", - "xtend": "^4.0.0" - }, - "dependencies": { - "process": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", - "dev": true, - "peer": true - } - } - }, "interpret": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/interpret/-/interpret-3.1.1.tgz", @@ -12478,38 +8276,6 @@ "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==" }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "peer": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "peer": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-binary-path": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", - "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", - "dev": true, - "peer": true, - "requires": { - "binary-extensions": "^1.0.0" - } - }, "is-buffer": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", @@ -12531,67 +8297,17 @@ "has": "^1.0.3" } }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "peer": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "peer": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, "is-date-object": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", "dev": true }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "peer": true, - "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - }, - "dependencies": { - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true, - "peer": true - } - } - }, "is-docker": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==" }, - "is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "dev": true, - "peer": true - }, "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -12609,34 +8325,12 @@ "integrity": "sha512-lw7DUp0aWXYg+CBCN+JKkcE0Q2RayZnSvnZBlwgxHBQhqt5pZNVy4Ri7H9GmmXkdu7LUthszM+Tor1u/2iBcpQ==", "dev": true }, - "is-glob": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", - "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", - "requires": { - "is-extglob": "^2.1.1" - } - }, - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "peer": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "peer": true, - "requires": { - "is-buffer": "^1.1.5" - } - } + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "requires": { + "is-extglob": "^2.1.1" } }, "is-obj": { @@ -12677,13 +8371,6 @@ "has-symbols": "^1.0.1" } }, - "is-windows": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", - "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", - "dev": true, - "peer": true - }, "is-wsl": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", @@ -12742,12 +8429,6 @@ } } }, - "js-string-escape": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/js-string-escape/-/js-string-escape-1.0.1.tgz", - "integrity": "sha1-4mJbrbwNZ8dTPp7cEGjFh65BN+8=", - "dev": true - }, "js-yaml": { "version": "3.13.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", @@ -12768,16 +8449,6 @@ "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" }, - "json-stable-stringify": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz", - "integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=", - "dev": true, - "peer": true, - "requires": { - "jsonify": "~0.0.0" - } - }, "jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", @@ -12787,31 +8458,6 @@ "graceful-fs": "^4.1.6" } }, - "jsonify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", - "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", - "dev": true, - "peer": true - }, - "jsonparse": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", - "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", - "dev": true, - "peer": true - }, - "JSONStream": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", - "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", - "dev": true, - "peer": true, - "requires": { - "jsonparse": "^1.2.0", - "through": ">=2.2.7 <3" - } - }, "karma": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/karma/-/karma-4.4.1.tgz", @@ -12959,20 +8605,6 @@ } } }, - "karma-browserify": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/karma-browserify/-/karma-browserify-6.1.0.tgz", - "integrity": "sha512-FWOuATeil6dbm2nwWIbSFG0Ad8w3PcuBNs05zcqnMiuXEdwos/o6B26HF+NcYwTt3o7LTOGWiuXK9cuuhoPeaw==", - "dev": true, - "requires": { - "convert-source-map": "^1.1.3", - "hat": "^0.0.3", - "js-string-escape": "^1.0.0", - "lodash": "^4.17.14", - "minimatch": "^3.0.0", - "os-shim": "^0.1.3" - } - }, "karma-chai-shallow-deep-equal": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/karma-chai-shallow-deep-equal/-/karma-chai-shallow-deep-equal-0.0.4.tgz", @@ -13088,23 +8720,34 @@ "lolex": "^1.6.0" } }, + "karma-webpack": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/karma-webpack/-/karma-webpack-5.0.0.tgz", + "integrity": "sha512-+54i/cd3/piZuP3dr54+NcFeKOPnys5QeM1IY+0SPASwrtHsliXUiCL50iW+K9WWA7RvamC4macvvQ86l3KtaA==", + "dev": true, + "requires": { + "glob": "^7.1.3", + "minimatch": "^3.0.4", + "webpack-merge": "^4.1.5" + }, + "dependencies": { + "webpack-merge": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-4.2.2.tgz", + "integrity": "sha512-TUE1UGoTX2Cd42j3krGYqObZbOD+xF7u28WB7tfUordytSjbWTIjK/8V0amkBfTYN4/pB/GIDlJZZ657BGG19g==", + "dev": true, + "requires": { + "lodash": "^4.17.15" + } + } + } + }, "kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", "dev": true }, - "labeled-stream-splicer": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.2.tgz", - "integrity": "sha512-Ca4LSXFFZUjPScRaqOcFxneA0VpKZr4MMYCljyQr4LIewTLb3Y0IUTIsnBBsVubIeEfxeSZpSjSsRM8APEQaAw==", - "dev": true, - "peer": true, - "requires": { - "inherits": "^2.0.1", - "stream-splicer": "^2.0.0" - } - }, "layout-bmfont-text": { "version": "1.3.4", "resolved": "https://registry.npmjs.org/layout-bmfont-text/-/layout-bmfont-text-1.3.4.tgz", @@ -13153,13 +8796,6 @@ "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==", "dev": true }, - "lodash.memoize": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz", - "integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=", - "dev": true, - "peer": true - }, "log-symbols": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", @@ -13246,13 +8882,6 @@ "yallist": "^2.1.2" } }, - "map-cache": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", - "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "dev": true, - "peer": true - }, "map-limit": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/map-limit/-/map-limit-0.0.1.tgz", @@ -13273,28 +8902,6 @@ } } }, - "map-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", - "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", - "dev": true, - "peer": true, - "requires": { - "object-visit": "^1.0.0" - } - }, - "md5.js": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", - "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", - "dev": true, - "peer": true, - "requires": { - "hash-base": "^3.0.0", - "inherits": "^2.0.1", - "safe-buffer": "^5.1.2" - } - }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -13323,48 +8930,6 @@ "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==" }, - "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "dev": true, - "peer": true, - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" - } - }, - "miller-rabin": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", - "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", - "dev": true, - "peer": true, - "requires": { - "bn.js": "^4.0.0", - "brorand": "^1.0.1" - }, - "dependencies": { - "bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true, - "peer": true - } - } - }, "mime": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", @@ -13408,13 +8973,6 @@ "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" }, - "minimalistic-crypto-utils": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", - "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=", - "dev": true, - "peer": true - }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -13429,29 +8987,6 @@ "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "dev": true }, - "mixin-deep": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", - "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", - "dev": true, - "peer": true, - "requires": { - "for-in": "^1.0.2", - "is-extendable": "^1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, - "peer": true, - "requires": { - "is-plain-object": "^2.0.4" - } - } - } - }, "mkdirp": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.4.tgz", @@ -13461,13 +8996,6 @@ "minimist": "^1.2.5" } }, - "mkdirp-classic": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", - "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", - "dev": true, - "peer": true - }, "mocha": { "version": "6.2.3", "resolved": "https://registry.npmjs.org/mocha/-/mocha-6.2.3.tgz", @@ -13539,30 +9067,6 @@ } } }, - "module-deps": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-6.2.2.tgz", - "integrity": "sha512-a9y6yDv5u5I4A+IPHTnqFxcaKr4p50/zxTjcQJaX2ws9tN/W6J6YXnEKhqRyPhl494dkcxx951onSKVezmI+3w==", - "dev": true, - "peer": true, - "requires": { - "browser-resolve": "^1.7.0", - "cached-path-relative": "^1.0.2", - "concat-stream": "~1.6.0", - "defined": "^1.0.0", - "detective": "^5.2.0", - "duplexer2": "^0.1.2", - "inherits": "^2.0.1", - "JSONStream": "^1.0.3", - "parents": "^1.0.0", - "readable-stream": "^2.0.2", - "resolve": "^1.4.0", - "stream-combiner2": "^1.1.1", - "subarg": "^1.0.0", - "through2": "^2.0.0", - "xtend": "^4.0.0" - } - }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -13577,34 +9081,6 @@ "thunky": "^1.0.2" } }, - "nan": { - "version": "2.17.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz", - "integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==", - "dev": true, - "optional": true, - "peer": true - }, - "nanomatch": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", - "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", - "dev": true, - "peer": true, - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "fragment-cache": "^0.2.1", - "is-windows": "^1.0.2", - "kind-of": "^6.0.2", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - } - }, "native-promise-only": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/native-promise-only/-/native-promise-only-0.8.1.tgz", @@ -13688,40 +9164,6 @@ "integrity": "sha1-8MaapQ78lbhmwYb0AKM3acsvEpE=", "dev": true }, - "object-copy": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", - "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", - "dev": true, - "peer": true, - "requires": { - "copy-descriptor": "^0.1.0", - "define-property": "^0.2.5", - "kind-of": "^3.0.3" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "peer": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "peer": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, "object-inspect": { "version": "1.12.2", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz", @@ -13733,16 +9175,6 @@ "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", "dev": true }, - "object-visit": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", - "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", - "dev": true, - "peer": true, - "requires": { - "isobject": "^3.0.0" - } - }, "object.assign": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", @@ -13765,16 +9197,6 @@ "es-abstract": "^1.17.0-next.1" } }, - "object.pick": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", - "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", - "dev": true, - "peer": true, - "requires": { - "isobject": "^3.0.1" - } - }, "obuf": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/obuf/-/obuf-1.1.2.tgz", @@ -13838,35 +9260,12 @@ } } }, - "os-browserify": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", - "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=", - "dev": true, - "peer": true - }, - "os-shim": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/os-shim/-/os-shim-0.1.3.tgz", - "integrity": "sha1-a2LDeRz3kJ6jXtRuF2WLtBfLORc=", - "dev": true - }, "os-tmpdir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true }, - "outpipe": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/outpipe/-/outpipe-1.1.1.tgz", - "integrity": "sha1-UM+GFjZeh+Ax4ppeyTOaPaRyX6I=", - "dev": true, - "peer": true, - "requires": { - "shell-quote": "^1.4.2" - } - }, "p-limit": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", @@ -13900,38 +9299,6 @@ "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, - "pako": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", - "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", - "dev": true, - "peer": true - }, - "parents": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz", - "integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=", - "dev": true, - "peer": true, - "requires": { - "path-platform": "~0.11.15" - } - }, - "parse-asn1": { - "version": "5.1.5", - "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.5.tgz", - "integrity": "sha512-jkMYn1dcJqF6d5CpU689bq7w/b5ALS9ROVSpQDPrZsqqesUJii9qutvoT5ltGedNXMO2e16YUWIghG9KxaViTQ==", - "dev": true, - "peer": true, - "requires": { - "asn1.js": "^4.0.0", - "browserify-aes": "^1.0.0", - "create-hash": "^1.1.0", - "evp_bytestokey": "^1.0.0", - "pbkdf2": "^3.0.3", - "safe-buffer": "^5.1.1" - } - }, "parse-bmfont-ascii": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/parse-bmfont-ascii/-/parse-bmfont-ascii-1.0.6.tgz", @@ -13983,27 +9350,6 @@ "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" }, - "pascalcase": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", - "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", - "dev": true, - "peer": true - }, - "path-browserify": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", - "integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==", - "dev": true, - "peer": true - }, - "path-dirname": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", - "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", - "dev": true, - "peer": true - }, "path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", @@ -14021,13 +9367,6 @@ "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, - "path-platform": { - "version": "0.11.15", - "resolved": "https://registry.npmjs.org/path-platform/-/path-platform-0.11.15.tgz", - "integrity": "sha1-6GQhf3TDaFDwhSt43Hv31KVyG/I=", - "dev": true, - "peer": true - }, "path-to-regexp": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", @@ -14045,20 +9384,6 @@ } } }, - "pbkdf2": { - "version": "3.0.17", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", - "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", - "dev": true, - "peer": true, - "requires": { - "create-hash": "^1.1.2", - "create-hmac": "^1.1.4", - "ripemd160": "^2.0.1", - "safe-buffer": "^5.0.1", - "sha.js": "^2.4.8" - } - }, "phin": { "version": "2.9.3", "resolved": "https://registry.npmjs.org/phin/-/phin-2.9.3.tgz", @@ -14120,13 +9445,6 @@ } } }, - "posix-character-classes": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", - "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", - "dev": true, - "peer": true - }, "present": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/present/-/present-0.0.6.tgz", @@ -14165,37 +9483,6 @@ "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", "dev": true }, - "public-encrypt": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", - "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", - "dev": true, - "peer": true, - "requires": { - "bn.js": "^4.1.0", - "browserify-rsa": "^4.0.0", - "create-hash": "^1.1.0", - "parse-asn1": "^5.0.0", - "randombytes": "^2.0.1", - "safe-buffer": "^5.1.2" - }, - "dependencies": { - "bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true, - "peer": true - } - } - }, - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", - "dev": true, - "peer": true - }, "qjobs": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/qjobs/-/qjobs-1.2.0.tgz", @@ -14232,20 +9519,6 @@ "strict-uri-encode": "^1.0.0" } }, - "querystring": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", - "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", - "dev": true, - "peer": true - }, - "querystring-es3": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", - "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", - "dev": true, - "peer": true - }, "randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -14254,17 +9527,6 @@ "safe-buffer": "^5.1.0" } }, - "randomfill": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", - "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", - "dev": true, - "peer": true, - "requires": { - "randombytes": "^2.0.5", - "safe-buffer": "^5.1.0" - } - }, "range-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", @@ -14281,16 +9543,6 @@ "unpipe": "1.0.0" } }, - "read-only-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-2.0.0.tgz", - "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=", - "dev": true, - "peer": true, - "requires": { - "readable-stream": "^2.0.2" - } - }, "readable-stream": { "version": "2.3.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", @@ -14320,18 +9572,6 @@ } } }, - "readdirp": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", - "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", - "dev": true, - "peer": true, - "requires": { - "graceful-fs": "^4.1.11", - "micromatch": "^3.1.10", - "readable-stream": "^2.0.2" - } - }, "rechoir": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.8.0.tgz", @@ -14341,38 +9581,6 @@ "resolve": "^1.20.0" } }, - "regex-not": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", - "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", - "dev": true, - "peer": true, - "requires": { - "extend-shallow": "^3.0.2", - "safe-regex": "^1.1.0" - } - }, - "remove-trailing-separator": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", - "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", - "dev": true, - "peer": true - }, - "repeat-element": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", - "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", - "dev": true, - "peer": true - }, - "repeat-string": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true, - "peer": true - }, "replace": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/replace/-/replace-1.2.0.tgz", @@ -14613,20 +9821,6 @@ "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", "dev": true }, - "resolve-url": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", - "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", - "dev": true, - "peer": true - }, - "ret": { - "version": "0.1.15", - "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", - "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", - "dev": true, - "peer": true - }, "retry": { "version": "0.13.1", "resolved": "https://registry.npmjs.org/retry/-/retry-0.13.1.tgz", @@ -14647,32 +9841,11 @@ "glob": "^7.1.3" } }, - "ripemd160": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", - "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", - "dev": true, - "peer": true, - "requires": { - "hash-base": "^3.0.0", - "inherits": "^2.0.1" - } - }, "safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" }, - "safe-regex": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", - "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", - "dev": true, - "peer": true, - "requires": { - "ret": "~0.1.10" - } - }, "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", @@ -14810,58 +9983,22 @@ "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", "requires": { "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "parseurl": "~1.3.3", - "send": "0.18.0" - } - }, - "set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", - "dev": true - }, - "set-value": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", - "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", - "dev": true, - "peer": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.3", - "split-string": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "peer": true, - "requires": { - "is-extendable": "^0.1.0" - } - } + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.18.0" } }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, "setprototypeof": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, - "sha.js": { - "version": "2.4.11", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", - "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", - "dev": true, - "peer": true, - "requires": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - } - }, "shallow-clone": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz", @@ -14871,34 +10008,6 @@ "kind-of": "^6.0.2" } }, - "shasum": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/shasum/-/shasum-1.0.2.tgz", - "integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=", - "dev": true, - "peer": true, - "requires": { - "json-stable-stringify": "~0.0.0", - "sha.js": "~2.4.4" - } - }, - "shasum-object": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shasum-object/-/shasum-object-1.0.0.tgz", - "integrity": "sha512-Iqo5rp/3xVi6M4YheapzZhhGPVs0yZwHj7wvwQ1B9z8H6zk+FEnI7y3Teq7qwnekfEhu8WmG2z0z4iWZaxLWVg==", - "dev": true, - "peer": true, - "requires": { - "fast-safe-stringify": "^2.0.7" - } - }, - "shell-quote": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.2.tgz", - "integrity": "sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==", - "dev": true, - "peer": true - }, "side-channel": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", @@ -14962,123 +10071,6 @@ "dev": true, "requires": {} }, - "snapdragon": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", - "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", - "dev": true, - "peer": true, - "requires": { - "base": "^0.11.1", - "debug": "^2.2.0", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "map-cache": "^0.2.2", - "source-map": "^0.5.6", - "source-map-resolve": "^0.5.0", - "use": "^3.1.0" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "peer": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "peer": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "snapdragon-node": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", - "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", - "dev": true, - "peer": true, - "requires": { - "define-property": "^1.0.0", - "isobject": "^3.0.0", - "snapdragon-util": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "peer": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "peer": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "peer": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "peer": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, - "snapdragon-util": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", - "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", - "dev": true, - "peer": true, - "requires": { - "kind-of": "^3.2.0" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "peer": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, "socket.io": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.1.1.tgz", @@ -15193,27 +10185,6 @@ "websocket-driver": "^0.7.4" } }, - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true, - "peer": true - }, - "source-map-resolve": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz", - "integrity": "sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==", - "dev": true, - "peer": true, - "requires": { - "atob": "^2.1.2", - "decode-uri-component": "^0.2.0", - "resolve-url": "^0.2.1", - "source-map-url": "^0.4.0", - "urix": "^0.1.0" - } - }, "source-map-support": { "version": "0.5.21", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", @@ -15230,13 +10201,6 @@ } } }, - "source-map-url": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", - "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", - "dev": true, - "peer": true - }, "spdy": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/spdy/-/spdy-4.0.2.tgz", @@ -15302,124 +10266,17 @@ } } }, - "split-string": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", - "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", - "dev": true, - "peer": true, - "requires": { - "extend-shallow": "^3.0.0" - } - }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, - "static-extend": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", - "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", - "dev": true, - "peer": true, - "requires": { - "define-property": "^0.2.5", - "object-copy": "^0.1.0" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "peer": true, - "requires": { - "is-descriptor": "^0.1.0" - } - } - } - }, "statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" }, - "stream-browserify": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.2.tgz", - "integrity": "sha512-nX6hmklHs/gr2FuxYDltq8fJA1GDlxKQCz8O/IM4atRqBH8OORmBNgfvW5gG10GT/qQ9u0CzIvr2X5Pkt6ntqg==", - "dev": true, - "peer": true, - "requires": { - "inherits": "~2.0.1", - "readable-stream": "^2.0.2" - } - }, - "stream-combiner2": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", - "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", - "dev": true, - "peer": true, - "requires": { - "duplexer2": "~0.1.0", - "readable-stream": "^2.0.2" - } - }, - "stream-http": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-3.1.1.tgz", - "integrity": "sha512-S7OqaYu0EkFpgeGFb/NPOoPLxFko7TPqtEeFg5DXPB4v/KETHG0Ln6fRFrNezoelpaDKmycEmmZ81cC9DAwgYg==", - "dev": true, - "peer": true, - "requires": { - "builtin-status-codes": "^3.0.0", - "inherits": "^2.0.4", - "readable-stream": "^3.6.0", - "xtend": "^4.0.2" - }, - "dependencies": { - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true, - "peer": true - }, - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, - "peer": true, - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - }, - "xtend": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", - "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", - "dev": true, - "peer": true - } - } - }, - "stream-splicer": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.1.tgz", - "integrity": "sha512-Xizh4/NPuYSyAXyT7g8IvdJ9HJpxIGL9PjyhtywCZvvP0OPIdqyrr4dMikeuvY8xahpdKEBlBTySe583totajg==", - "dev": true, - "peer": true, - "requires": { - "inherits": "^2.0.1", - "readable-stream": "^2.0.2" - } - }, "streamroller": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-1.0.6.tgz", @@ -15544,16 +10401,6 @@ "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", "dev": true }, - "subarg": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz", - "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=", - "dev": true, - "peer": true, - "requires": { - "minimist": "^1.1.0" - } - }, "super-animejs": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/super-animejs/-/super-animejs-3.1.0.tgz", @@ -15572,16 +10419,6 @@ "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "dev": true }, - "syntax-error": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz", - "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==", - "dev": true, - "peer": true, - "requires": { - "acorn-node": "^1.2.0" - } - }, "tapable": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", @@ -15676,17 +10513,6 @@ "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, - "through2": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", - "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", - "dev": true, - "peer": true, - "requires": { - "readable-stream": "~2.3.6", - "xtend": "~4.0.1" - } - }, "thunky": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz", @@ -15698,25 +10524,6 @@ "integrity": "sha512-G7r3AhovYtr5YKOWQkta8RKAPb+J9IsO4uVmzjl8AZwfhs8UcUwTiD6gcJYSgOtzyjvQKrKYn41syHbUWMkafA==", "dev": true }, - "timers-browserify": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz", - "integrity": "sha1-ycWLV1voQHN1y14kYtrO50NZ9B0=", - "dev": true, - "peer": true, - "requires": { - "process": "~0.11.0" - }, - "dependencies": { - "process": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", - "dev": true, - "peer": true - } - } - }, "tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", @@ -15732,64 +10539,11 @@ "integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=", "dev": true }, - "to-object-path": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", - "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", - "dev": true, - "peer": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "peer": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "to-regex": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", - "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", - "dev": true, - "peer": true, - "requires": { - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "regex-not": "^1.0.2", - "safe-regex": "^1.1.0" - } - }, - "to-regex-range": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", - "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", - "dev": true, - "peer": true, - "requires": { - "is-number": "^3.0.0", - "repeat-string": "^1.6.1" - } - }, "toidentifier": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==" }, - "tty-browserify": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", - "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==", - "dev": true, - "peer": true - }, "type-detect": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-1.0.0.tgz", @@ -15805,13 +10559,6 @@ "mime-types": "~2.1.24" } }, - "typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", - "dev": true, - "peer": true - }, "uglify-es": { "version": "3.3.9", "resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.3.9.tgz", @@ -15836,40 +10583,6 @@ "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==", "dev": true }, - "umd": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz", - "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==", - "dev": true, - "peer": true - }, - "undeclared-identifiers": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/undeclared-identifiers/-/undeclared-identifiers-1.1.3.tgz", - "integrity": "sha512-pJOW4nxjlmfwKApE4zvxLScM/njmwj/DiUBv7EabwE4O8kRUy+HIwxQtZLBPll/jx1LJyBcqNfB3/cpv9EZwOw==", - "dev": true, - "peer": true, - "requires": { - "acorn-node": "^1.3.0", - "dash-ast": "^1.0.0", - "get-assigned-identifiers": "^1.2.0", - "simple-concat": "^1.0.0", - "xtend": "^4.0.1" - } - }, - "union-value": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", - "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", - "dev": true, - "peer": true, - "requires": { - "arr-union": "^3.1.0", - "get-value": "^2.0.6", - "is-extendable": "^0.1.1", - "set-value": "^2.0.1" - } - }, "universalify": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", @@ -15881,57 +10594,6 @@ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" }, - "unset-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", - "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", - "dev": true, - "peer": true, - "requires": { - "has-value": "^0.3.1", - "isobject": "^3.0.0" - }, - "dependencies": { - "has-value": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", - "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", - "dev": true, - "peer": true, - "requires": { - "get-value": "^2.0.3", - "has-values": "^0.1.4", - "isobject": "^2.0.0" - }, - "dependencies": { - "isobject": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true, - "peer": true, - "requires": { - "isarray": "1.0.0" - } - } - } - }, - "has-values": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", - "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", - "dev": true, - "peer": true - } - } - }, - "upath": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz", - "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==", - "dev": true, - "peer": true - }, "update-browserslist-db": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz", @@ -15956,46 +10618,12 @@ } } }, - "urix": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", - "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", - "dev": true, - "peer": true - }, - "url": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", - "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", - "dev": true, - "peer": true, - "requires": { - "punycode": "1.3.2", - "querystring": "0.2.0" - }, - "dependencies": { - "punycode": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", - "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", - "dev": true, - "peer": true - } - } - }, "url-set-query": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/url-set-query/-/url-set-query-1.0.0.tgz", "integrity": "sha512-3AChu4NiXquPfeckE5R5cGdiHCMWJx1dwCWOmWIL4KHAziJNOFIYJlpGFeKDvwLPHovZRCxK3cYlwzqI9Vp+Gg==", "dev": true }, - "use": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", - "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", - "dev": true, - "peer": true - }, "useragent": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/useragent/-/useragent-2.3.0.tgz", @@ -16006,16 +10634,6 @@ "tmp": "0.0.x" } }, - "util": { - "version": "0.10.4", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", - "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", - "dev": true, - "peer": true, - "requires": { - "inherits": "2.0.3" - } - }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -16036,35 +10654,12 @@ "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==" }, - "vm-browserify": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz", - "integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==", - "dev": true, - "peer": true - }, "void-elements": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=", "dev": true }, - "watchify": { - "version": "3.11.1", - "resolved": "https://registry.npmjs.org/watchify/-/watchify-3.11.1.tgz", - "integrity": "sha512-WwnUClyFNRMB2NIiHgJU9RQPQNqVeFk7OmZaWf5dC5EnNa0Mgr7imBydbaJ7tGTuPM2hz1Cb4uiBvK9NVxMfog==", - "dev": true, - "peer": true, - "requires": { - "anymatch": "^2.0.0", - "browserify": "^16.1.0", - "chokidar": "^2.1.1", - "defined": "^1.0.0", - "outpipe": "^1.1.0", - "through2": "^2.0.0", - "xtend": "^4.0.0" - } - }, "watchpack": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", diff --git a/package.json b/package.json index 540b7f92..b8a0557c 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,6 @@ "chai-shallow-deep-equal": "^1.4.6", "envify": "^4.1.0", "karma": "^4.4.1", - "karma-browserify": "^6.1.0", "karma-chai-shallow-deep-equal": "0.0.4", "karma-chrome-launcher": "^2.2.0", "karma-env-preprocessor": "^0.1.1", @@ -68,6 +67,7 @@ "karma-mocha": "^1.3.0", "karma-mocha-reporter": "^2.2.5", "karma-sinon-chai": "^1.3.4", + "karma-webpack": "^5.0.0", "mocha": "^6.2.3", "replace": "^1.2.0", "sinon": "^2.4.1", diff --git a/tests/karma.conf.js b/tests/karma.conf.js index 2fbef246..7f0d8872 100644 --- a/tests/karma.conf.js +++ b/tests/karma.conf.js @@ -1,10 +1,9 @@ +var webpackConfiguration = require("../webpack.config.js"); + module.exports = function (config) { config.set({ basePath: '../', - browserify: { - debug: true, - paths: ['src'] - }, + webpack: webpackConfiguration, browsers: ['Firefox', 'Chrome'], client: { captureConsole: true, @@ -14,8 +13,8 @@ module.exports = function (config) { files: [ {pattern: 'tests/**/*.test.js'} ], - frameworks: ['mocha', 'sinon-chai', 'chai-shallow-deep-equal', 'browserify'], - preprocessors: {'tests/**/*.js': ['browserify', 'env']}, + frameworks: ['mocha', 'sinon-chai', 'chai-shallow-deep-equal', 'webpack'], + preprocessors: {'tests/**/*.js': ['webpack', 'env']}, reporters: ['mocha'] }); };