Import a 3D Model and automatically assign and export animations
TypeScript
Initial adding current WIP to repository
Scott Petrovicb9b74998ca3a
diff --git a/.gitignore b/.gitignorenew file mode 100644index 0000000..0d70a28--- /dev/null+++ b/.gitignore@@ -0,0 +1 @@+**/node_modules/**diff --git a/package-lock.json b/package-lock.jsonnew file mode 100644index 0000000..5d8e707--- /dev/null+++ b/package-lock.json@@ -0,0 +1,600 @@+{+ "name": "model-motionizer",+ "version": "0.0.0",+ "lockfileVersion": 3,+ "requires": true,+ "packages": {+ "": {+ "name": "model-motionizer",+ "version": "0.0.0",+ "dependencies": {+ "three": "^0.157.0",+ "vite-plugin-glsl": "^1.1.2"+ },+ "devDependencies": {+ "typescript": "^5.2.2",+ "vite": "^4.5.0"+ }+ },+ "node_modules/@esbuild/android-arm": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.18.20.tgz",+ "integrity": "sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw==",+ "cpu": [+ "arm"+ ],+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/android-arm64": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.18.20.tgz",+ "integrity": "sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==",+ "cpu": [+ "arm64"+ ],+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/android-x64": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.18.20.tgz",+ "integrity": "sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg==",+ "cpu": [+ "x64"+ ],+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/darwin-arm64": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.18.20.tgz",+ "integrity": "sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA==",+ "cpu": [+ "arm64"+ ],+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/darwin-x64": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.18.20.tgz",+ "integrity": "sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ==",+ "cpu": [+ "x64"+ ],+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/freebsd-arm64": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.18.20.tgz",+ "integrity": "sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw==",+ "cpu": [+ "arm64"+ ],+ "optional": true,+ "os": [+ "freebsd"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/freebsd-x64": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.18.20.tgz",+ "integrity": "sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ==",+ "cpu": [+ "x64"+ ],+ "optional": true,+ "os": [+ "freebsd"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/linux-arm": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.18.20.tgz",+ "integrity": "sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg==",+ "cpu": [+ "arm"+ ],+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/linux-arm64": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.18.20.tgz",+ "integrity": "sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA==",+ "cpu": [+ "arm64"+ ],+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/linux-ia32": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.18.20.tgz",+ "integrity": "sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA==",+ "cpu": [+ "ia32"+ ],+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/linux-loong64": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.18.20.tgz",+ "integrity": "sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg==",+ "cpu": [+ "loong64"+ ],+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/linux-mips64el": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.18.20.tgz",+ "integrity": "sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ==",+ "cpu": [+ "mips64el"+ ],+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/linux-ppc64": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.18.20.tgz",+ "integrity": "sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA==",+ "cpu": [+ "ppc64"+ ],+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/linux-riscv64": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.18.20.tgz",+ "integrity": "sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A==",+ "cpu": [+ "riscv64"+ ],+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/linux-s390x": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.18.20.tgz",+ "integrity": "sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ==",+ "cpu": [+ "s390x"+ ],+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/linux-x64": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.18.20.tgz",+ "integrity": "sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w==",+ "cpu": [+ "x64"+ ],+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/netbsd-x64": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.18.20.tgz",+ "integrity": "sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A==",+ "cpu": [+ "x64"+ ],+ "optional": true,+ "os": [+ "netbsd"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/openbsd-x64": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.18.20.tgz",+ "integrity": "sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg==",+ "cpu": [+ "x64"+ ],+ "optional": true,+ "os": [+ "openbsd"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/sunos-x64": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.18.20.tgz",+ "integrity": "sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ==",+ "cpu": [+ "x64"+ ],+ "optional": true,+ "os": [+ "sunos"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/win32-arm64": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.18.20.tgz",+ "integrity": "sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg==",+ "cpu": [+ "arm64"+ ],+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/win32-ia32": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.18.20.tgz",+ "integrity": "sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g==",+ "cpu": [+ "ia32"+ ],+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@esbuild/win32-x64": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.18.20.tgz",+ "integrity": "sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ==",+ "cpu": [+ "x64"+ ],+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/@rollup/pluginutils": {+ "version": "5.0.5",+ "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.0.5.tgz",+ "integrity": "sha512-6aEYR910NyP73oHiJglti74iRyOwgFU4x3meH/H8OJx6Ry0j6cOVZ5X/wTvub7G7Ao6qaHBEaNsV3GLJkSsF+Q==",+ "dependencies": {+ "@types/estree": "^1.0.0",+ "estree-walker": "^2.0.2",+ "picomatch": "^2.3.1"+ },+ "engines": {+ "node": ">=14.0.0"+ },+ "peerDependencies": {+ "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0"+ },+ "peerDependenciesMeta": {+ "rollup": {+ "optional": true+ }+ }+ },+ "node_modules/@types/estree": {+ "version": "1.0.5",+ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz",+ "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw=="+ },+ "node_modules/esbuild": {+ "version": "0.18.20",+ "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.18.20.tgz",+ "integrity": "sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==",+ "hasInstallScript": true,+ "bin": {+ "esbuild": "bin/esbuild"+ },+ "engines": {+ "node": ">=12"+ },+ "optionalDependencies": {+ "@esbuild/android-arm": "0.18.20",+ "@esbuild/android-arm64": "0.18.20",+ "@esbuild/android-x64": "0.18.20",+ "@esbuild/darwin-arm64": "0.18.20",+ "@esbuild/darwin-x64": "0.18.20",+ "@esbuild/freebsd-arm64": "0.18.20",+ "@esbuild/freebsd-x64": "0.18.20",+ "@esbuild/linux-arm": "0.18.20",+ "@esbuild/linux-arm64": "0.18.20",+ "@esbuild/linux-ia32": "0.18.20",+ "@esbuild/linux-loong64": "0.18.20",+ "@esbuild/linux-mips64el": "0.18.20",+ "@esbuild/linux-ppc64": "0.18.20",+ "@esbuild/linux-riscv64": "0.18.20",+ "@esbuild/linux-s390x": "0.18.20",+ "@esbuild/linux-x64": "0.18.20",+ "@esbuild/netbsd-x64": "0.18.20",+ "@esbuild/openbsd-x64": "0.18.20",+ "@esbuild/sunos-x64": "0.18.20",+ "@esbuild/win32-arm64": "0.18.20",+ "@esbuild/win32-ia32": "0.18.20",+ "@esbuild/win32-x64": "0.18.20"+ }+ },+ "node_modules/estree-walker": {+ "version": "2.0.2",+ "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",+ "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w=="+ },+ "node_modules/fsevents": {+ "version": "2.3.3",+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",+ "hasInstallScript": true,+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"+ }+ },+ "node_modules/nanoid": {+ "version": "3.3.6",+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz",+ "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==",+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/ai"+ }+ ],+ "bin": {+ "nanoid": "bin/nanoid.cjs"+ },+ "engines": {+ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"+ }+ },+ "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/postcss": {+ "version": "8.4.31",+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz",+ "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==",+ "funding": [+ {+ "type": "opencollective",+ "url": "https://opencollective.com/postcss/"+ },+ {+ "type": "tidelift",+ "url": "https://tidelift.com/funding/github/npm/postcss"+ },+ {+ "type": "github",+ "url": "https://github.com/sponsors/ai"+ }+ ],+ "dependencies": {+ "nanoid": "^3.3.6",+ "picocolors": "^1.0.0",+ "source-map-js": "^1.0.2"+ },+ "engines": {+ "node": "^10 || ^12 || >=14"+ }+ },+ "node_modules/rollup": {+ "version": "3.29.4",+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.29.4.tgz",+ "integrity": "sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==",+ "bin": {+ "rollup": "dist/bin/rollup"+ },+ "engines": {+ "node": ">=14.18.0",+ "npm": ">=8.0.0"+ },+ "optionalDependencies": {+ "fsevents": "~2.3.2"+ }+ },+ "node_modules/source-map-js": {+ "version": "1.0.2",+ "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz",+ "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==",+ "engines": {+ "node": ">=0.10.0"+ }+ },+ "node_modules/three": {+ "version": "0.157.0",+ "resolved": "https://registry.npmjs.org/three/-/three-0.157.0.tgz",+ "integrity": "sha512-CeAwQrf4x3z0/e+MC4F+nXLW5t0gh3pw+L6CCBqpHvOq3bGYIgRYub7Pv0j/9wR+d++OiEglyZzWyuSYbwWGOA=="+ },+ "node_modules/typescript": {+ "version": "5.2.2",+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",+ "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",+ "dev": true,+ "bin": {+ "tsc": "bin/tsc",+ "tsserver": "bin/tsserver"+ },+ "engines": {+ "node": ">=14.17"+ }+ },+ "node_modules/vite": {+ "version": "4.5.0",+ "resolved": "https://registry.npmjs.org/vite/-/vite-4.5.0.tgz",+ "integrity": "sha512-ulr8rNLA6rkyFAlVWw2q5YJ91v098AFQ2R0PRFwPzREXOUJQPtFUG0t+/ZikhaOCDqFoDhN6/v8Sq0o4araFAw==",+ "dependencies": {+ "esbuild": "^0.18.10",+ "postcss": "^8.4.27",+ "rollup": "^3.27.1"+ },+ "bin": {+ "vite": "bin/vite.js"+ },+ "engines": {+ "node": "^14.18.0 || >=16.0.0"+ },+ "funding": {+ "url": "https://github.com/vitejs/vite?sponsor=1"+ },+ "optionalDependencies": {+ "fsevents": "~2.3.2"+ },+ "peerDependencies": {+ "@types/node": ">= 14",+ "less": "*",+ "lightningcss": "^1.21.0",+ "sass": "*",+ "stylus": "*",+ "sugarss": "*",+ "terser": "^5.4.0"+ },+ "peerDependenciesMeta": {+ "@types/node": {+ "optional": true+ },+ "less": {+ "optional": true+ },+ "lightningcss": {+ "optional": true+ },+ "sass": {+ "optional": true+ },+ "stylus": {+ "optional": true+ },+ "sugarss": {+ "optional": true+ },+ "terser": {+ "optional": true+ }+ }+ },+ "node_modules/vite-plugin-glsl": {+ "version": "1.1.2",+ "resolved": "https://registry.npmjs.org/vite-plugin-glsl/-/vite-plugin-glsl-1.1.2.tgz",+ "integrity": "sha512-zmXsfc1vn2MlYve9t3FAoWuhLyoCkNS1TuQL+TkXZL7tGmBjRErp10eNYxcse5tK9oUC5MyJpNc4ElpQnx8DoA==",+ "dependencies": {+ "@rollup/pluginutils": "^5.0.2"+ },+ "engines": {+ "node": ">= 16.15.1",+ "npm": ">= 8.11.0"+ },+ "peerDependencies": {+ "vite": "^3.0.0 || ^4.0.0"+ }+ }+ }+}diff --git a/package.json b/package.jsonnew file mode 100644index 0000000..a895613--- /dev/null+++ b/package.json@@ -0,0 +1,18 @@+{+ "name": "model-motionizer",+ "private": true,+ "version": "0.0.0",+ "type": "module",+ "scripts": {+ "dev": "vite",+ "build": "vite build"+ },+ "devDependencies": {+ "typescript": "^5.2.2",+ "vite": "^4.5.0"+ },+ "dependencies": {+ "three": "^0.157.0",+ "vite-plugin-glsl": "^1.1.2"+ }+}diff --git a/src/index.html b/src/index.htmlnew file mode 100644index 0000000..34ca716--- /dev/null+++ b/src/index.html@@ -0,0 +1,159 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <title style="display: none">Model Motionizer</title>+</head>+<body style="margin: 0">+ <script type="module" src="./script.js"></script>+ <link href="./styles.css" rel="stylesheet" crossorigin="anonymous" />++ <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" />++ <div id="tool-panel">+ <!-- create a radio button group. There are two options. Move Skeleton, Rotate Mesh -->+ <div id="tool-selection-group">++ <div style="margin-bottom: 1rem;">+ <div id="current-step-index"></div>+ <div id="current-step-label"></div>+ </div>++ <div id="load-model-tools">++ <select id="model-selection">+ <option value="models/human-simple.glb">Human Cartoon</option>+ <option value="models/fox.glb">Fox</option>+ <option value="models/mesh-x-bot.glb">X Bot</option>+ </select>+ <button id="load-model-button">Load</button>++ <div style="text-align: center">or</div>++ <label for="model-upload" class="button" >+ <span class="button-icon-group">+ <span class="material-symbols-outlined" >upload</span>+ Upload+ </span>+ </label>+ <input id="model-upload" type="file" name="file-upload" accept=".glb, .gltf" />++ </div>++ <div id="load-skeleton-tools">+ <select id="skeleton-selection">+ <option value="bipedal-simple">Simplified Human</option>+ <option value="quadraped">4 leg creature</option>+ <option value="bipedal-full">Mixamo human</option>+ </select>+ <button id="load-skeleton-button">Load</button>+ </div>++ <!-- radio buttons to toggle between rotation and translate -->+ <div id="transform-controls">+ <div style="display: flex; flex-direction: row; align-items: center; column-gap: 5px; ">+ <span>Bone Controls:</span>++ <input type="radio" id="translate-mode" name="tool-selection" value="translation" checked style="display: none">+ <label for="translate-mode">+ <span class="material-symbols-outlined transform-icons">open_with</span>+ </label>++ <input type="radio" id="rotation-mode" name="tool-selection" value="rotation" style="display: none">+ <label for="rotation-mode">+ <span class="material-symbols-outlined transform-icons" >refresh</span>+ </label>+ </div>++++ <div style="display: flex; flex-direction: row">+ <input type="checkbox" id="mirror-skeleton" name="mirror-skeleton" value="mirror" checked>+ <label for="mirror-skeleton">Mirror</label>+ </div>++ <hr />++ </div>+++ <span id="skeleton-step-actions">++ <!-- add number input for changing scale of skeleton-->+ <div style="display: flex; flex-direction: row; justify-content: space-evenly; align-items: center;">+ <input type="number" id="scale-input" name="scale-input" value="-1" min="-90" max="90" step="1.0">+ <span class="suffix-unit">%</span>+ <button id="scale-skeleton-button" class="secondary-button" >Scale</button>+ </div>++ <button id="action_move_to_origin" class="secondary-button" >Move to origin</button>++ <hr />++ <!-- option to change out skinning algorithm -->+ <label for="skinning-algorithm-options">Skinning algorithm:</label>+ <select id="skinning-algorithm-options">+ <option value="bone-envelope">Bone Envelope</option>+ <option value="closest-bone">Closest Bone</option>+ <option value="closest-bone-middle">Closest Middle Bone</option>+ </select>++ <hr />++ <!-- checkbox for enabling weight skin debug mode -->+ <div style="display: flex; flex-direction: row">+ <input type="checkbox" id="debug-skinning-checkbox" checked >+ <label for="debug-skinning-checkbox">Debug Skinning</label>+ </div>++ <button id="action_bind_pose" >Bind pose</button>+ </span>++ <span id="skinned-step-tools">+ <button id="action_back_to_edit_skeleton" >Edit skeleton</button>++ <!-- checkbox option to show skeleton -->+ <div style="display: flex; flex-direction: row">+ <input type="checkbox" id="show-skeleton-checkbox" name="show-skeleton" value="show" checked>+ <label for="show-skeleton-checkbox">Show skeleton</label>+ </div>++ </span>++ </div>++ </div> <!-- end tool-panel-->+++ <span id="skinned-step-animation-export-options">++ <div id="animations-listing">+ <div id="animations-listing-header">+ <div>Animations</div>+ <div>Export</div>+ </div>++ <hr />++ <!-- javascript will populate this item with animations+ that we get from the animations file(s) -->+ <div id="animations-items"> </div>++++ <button id="export-button">Export to GLB</button>+ <a id="download-hidden-link" href="#" style="display:none"></a>+ </div>+++ </span>++ <!-- info panel for messages and information-->+ <div id="info-panel">+ <div id="info-messaging"> </div>++ </div>++</body>+</html>\ No newline at end of filediff --git a/src/lib/Generators.ts b/src/lib/Generators.tsnew file mode 100644index 0000000..d9dec1a--- /dev/null+++ b/src/lib/Generators.ts@@ -0,0 +1,229 @@+import { PerspectiveCamera, MeshStandardMaterial, DoubleSide, DirectionalLight, GridHelper,+ Bone, Skeleton, DirectionalLightHelper, AmbientLight, PlaneGeometry, Mesh,+ SphereGeometry, SkeletonHelper, MeshBasicMaterial, MeshPhongMaterial, AxesHelper,+ Vector3, PointsMaterial, BufferGeometry, Points } from 'three';++import { Utility } from './Utilities';+++export class Generators+{+ static create_material( wireframeValue = true, colorHex = 0x00ff00): MeshPhongMaterial+ {+ const material = new MeshPhongMaterial({ color: colorHex, wireframe: wireframeValue });+ material.side = DoubleSide;+ return material;+ }++ static create_grid_helper(color = 0x111155): any[]+ {+ // create floor mesh and add to scene to help with shadows+ const floor_geometry = new PlaneGeometry(100, 100, 10, 10);+ const floor_material = Generators.create_material(false, 0x4e4e7a);+ const floor_mesh = new Mesh(floor_geometry, floor_material);+ floor_mesh.name = 'Floor Mesh';+ floor_mesh.rotation.x = -Math.PI / 2;+ floor_mesh.position.y = -.01;+ floor_mesh.receiveShadow = true;++ // xyz axes helper display+ const axesHelper = new AxesHelper(0.15);+ axesHelper.name = 'Axes Helper';+ axesHelper.position.copy(new Vector3(0, 0.002, 0)); // offset a bit to avoid z-fighting++ // grid display on floor+ const size: number = 10;+ const divisions: number = 10;+ const gridHelper: GridHelper = new GridHelper(size, divisions, color, color);+++ return [gridHelper, floor_mesh, axesHelper];+ }++ static create_bone_hierarchy()+ {+ // offset root bone down to move entire bone structure+ const bone0 = new Bone();+ bone0.name = 'rootBone';++ const bone1 = new Bone();+ bone1.name = 'childBone';++ const bone2 = new Bone();+ bone2.name = 'grandchildBone';++ const bone3 = new Bone();+ bone3.name = 'greatGrandchildBone';++ bone0.add(bone1);+ bone1.add(bone2);+ bone2.add(bone3);++ // this is the local position...relative to the parent+ // @ts-ignore+ bone0.position.y = -0.8;++ // @ts-ignore+ bone1.position.y = 0.5;++ // @ts-ignore+ bone2.position.y = 0.5;+ // bone2.position.x = 0.5; // temporarily to test cylinder++ // @ts-ignore+ bone3.position.y = 0.5;++ return bone0;+ }++ static create_skeleton(bone_hierarchy): Skeleton+ {+ const bone_list = Utility.bone_list_from_hierarchy(bone_hierarchy);+ const skeleton = new Skeleton(bone_list);+ return skeleton;+ }++ static create_skeleton_helper(skeleton): SkeletonHelper+ {+ const skeletonHelper = new SkeletonHelper(skeleton.bones[0]);+ return skeletonHelper;+ }++ static create_spheres_for_points(points, sphere_size = 0.01, color = 0x00ffff, name = '' ): Points+ {+ let points_material = new PointsMaterial({ size: sphere_size, color: color });+ const points_geometry = new BufferGeometry().setFromPoints(points);+ const point_objects: Points = new Points(points_geometry, points_material);+ point_objects.name = `Point display: ${name} `;++ return point_objects;+ }++ static create_test_plane_mesh(size: number = 0.08, color: number = 0x0000ff): Mesh+ {+ const plane_width = size;+ const plane_height = size;+ const plane_width_segments = 2;+ const plane_height_segments = 2;+ const plane_geometry = new PlaneGeometry( plane_width, plane_height, plane_width_segments, plane_height_segments );+ const plane_material: MeshBasicMaterial = Generators.create_material(false, color);+ const mesh_object = new Mesh(plane_geometry, plane_material);+ mesh_object.name = 'Plane Intersection Mesh'+ return mesh_object+ }++ static create_default_lights()+ {+ const light_1 = new DirectionalLight(0x777777, 7);+ light_1.castShadow = true;++ // @ts-ignore+ light_1.position.set(-2, 2, 2);++ //const light_1_helper = new DirectionalLightHelper(light_1, 1, 0x333333);+ const light_2 = new AmbientLight(0xffffff, 0.3);++ // backfill light+ const backfill_light = new DirectionalLight(0x777777, 3);+ backfill_light.castShadow = false; // one shadow is enough++ // @ts-ignore+ backfill_light.position.set(2, 2, -2);++ return [light_1, light_2, backfill_light]+ }++ static create_camera()+ {+ const fieldOfView = 10; // in millimeters. Lower makes the camera more isometric+ const camera = new PerspectiveCamera(fieldOfView, window.innerWidth / window.innerHeight, 0.1, 1000);++ // @ts-ignore+ camera.position.z = 10;++ // @ts-ignore+ camera.position.y = 10;++ // @ts-ignore+ camera.position.x = 10;++ return camera;+ }++ static create_equidistant_spheres_around_circle(sphere_count = 6, color = 0x00ff00, distance = 0.3)+ {+ const plane_points: Array<Mesh> = [];+ const plane_point_geometry = new SphereGeometry(0.03, 12, 12)+ const plane_point_material: MeshBasicMaterial = Generators.create_material(true, color);+ for (let i = 0; i < sphere_count; i++)+ {+ // have the points go around the plane in an even circle increments+ const angle = (i/sphere_count) * (Math.PI*2)+ const x = Math.cos(angle) * distance+ const y = Math.sin(angle) * distance+ const z = 0+ const point_mesh: Mesh = new Mesh(plane_point_geometry, plane_point_material)++ // @ts-ignore+ point_mesh.position.set(x, y, z)+++ plane_points.push(point_mesh)+ }++ return plane_points+ }++ static create_window_resize_listener(renderer, camera): void+ {+ // there was a bit of horizontal and vertical scrollbars+ // I tried doing overflow: none, but that wasn't working for some reason+ const contraction_size = 2;++ window.addEventListener('resize', () => {+ renderer.setSize(window.innerWidth-contraction_size, window.innerHeight-contraction_size);+ camera.aspect = window.innerWidth / window.innerHeight;+ camera.updateProjectionMatrix(); // update camera+ })+ }++ static create_bone_plane_mesh(bone_start, bone_end, rays_to_cast): Mesh+ {+ // create plane mesh to do the ray casting+ // we also want to offset it it half the bone distance up the bone+ // for a better approximation with what counts+ const plane_mesh: Mesh = Generators.create_test_plane_mesh(0.02)++ // @ts-ignore+ plane_mesh.position.copy(Utility.world_position_from_object(bone_start))++ plane_mesh.lookAt(Utility.world_position_from_object(bone_end))+ plane_mesh.translateZ(Utility.distance_between_objects(bone_start, bone_end)*0.5)++ // create 4 reference points around the plane that will be used for raycasting+ const plane_point_geometry = new SphereGeometry(0.002, 3, 3)+ const plane_point_material: MeshBasicMaterial = Generators.create_material(true, 0x00ffff);++ for (let i = 0; i < rays_to_cast; i++)+ {+ // have the points go around the plane in an even circle increments+ const distance: number = 0.005; // set radial distance from origin close to help with close vertices+ const angle: number = (i/rays_to_cast) * (Math.PI*2)+ const x = Math.cos(angle) * distance+ const y = Math.sin(angle) * distance+ const z = 0+ const point_mesh = new Mesh(plane_point_geometry, plane_point_material)+ point_mesh.name = 'Point mesh PLANE';++ // @ts-ignore+ point_mesh.position.set(x, y, z)+ plane_mesh.add(point_mesh)+ }++ return plane_mesh++ }++}++diff --git a/src/lib/UI.js b/src/lib/UI.jsnew file mode 100644index 0000000..3f1860e--- /dev/null+++ b/src/lib/UI.js@@ -0,0 +1,82 @@+export class UI {+ constructor()+ {+ this._initializeDOMElements()+ }++ _initializeDOMElements()+ {+ // grab all UI Elements from page that we need to interact with+ this.dom_current_step_index = document.querySelector('#current-step-index')+ this.dom_current_step_element = document.querySelector('#current-step-label')+ this.dom_transform_controls_switch = document.querySelector('#transform-controls')++ // UI controls for loading the model+ this.dom_load_model_tools = document.querySelector('#load-model-tools')+ this.dom_upload_model_button = document.querySelector('#model-upload')+ this.dom_load_model_button = document.querySelector('#load-model-button')++ // UI controls for loading/working with skeleton+ this.dom_load_skeleton_tools = document.querySelector('#load-skeleton-tools')+ this.dom_load_skeleton_button = document.querySelector('#load-skeleton-button')+ this.dom_skeleton_edit_tools = document.querySelector('#skeleton-step-actions')+ this.dom_skeleton_drop_type = document.querySelector('#skeleton-selection')+ this.dom_mirror_skeleton_checkbox = document.querySelector('#mirror-skeleton')+ this.dom_scale_skeleton_button = document.querySelector('#scale-skeleton-button')++ this.dom_bind_pose_button = document.querySelector('#action_bind_pose')+ this.dom_scale_skeleton_input_box = document.querySelector('#scale-input')+ this.dom_move_to_origin_button = document.querySelector('#action_move_to_origin')+ this.dom_skinning_algorithm_selection = document.querySelector('#skinning-algorithm-options')+++ // UI controls for working with skinned mesh+ this.dom_skinned_mesh_tools = document.querySelector('#skinned-step-tools')+ this.dom_skinned_mesh_animation_tools = document.querySelector('#skinned-step-animation-export-options')+ this.dom_show_skeleton_checkbox = document.querySelector('#show-skeleton-checkbox')+ this.dom_back_to_edit_skeleton_button = document.querySelector('#action_back_to_edit_skeleton')+ this.dom_enable_skin_debugging = document.querySelector('#debug-skinning-checkbox')++ // UI Controls for working with animation list/selection and export+ this.dom_animation_clip_list = document.querySelector('#animations-items')+ this.dom_export_button = document.querySelector('#export-button')+ this.dom_info_panel = document.querySelector('#info-messaging')++ // UI for exporting the animation+ this.dom_export_button_hidden_link = document.querySelector('#download-hidden-link')+ }++ get_animated_selected_elements()+ {+ // this needs to be called ad-hoc as selections might change+ return document.querySelectorAll('#animations-items input[type="checkbox"]')+ }++ hideAllElements()+ {+ this.dom_transform_controls_switch.style.display = 'none';+ this.dom_load_model_tools.style.display = 'none';+ this.dom_load_skeleton_tools.style.display = 'none';+ this.dom_skeleton_edit_tools.style.display = 'none';+ this.dom_skinned_mesh_tools.style.display = 'none';+ this.dom_skinned_mesh_animation_tools.style.display = 'none';+ }++ build_animation_clip_ui(animation_clips_to_load)+ {+ /// take the animation_clips_loaded, loop through them, and build out the UI+ this.dom_animation_clip_list.innerHTML = '';+ animation_clips_to_load.forEach((animation_clip, index) => {+ this.dom_animation_clip_list.innerHTML +=+ `<div class="anim-item">+ <div>+ <button class="secondary-button" data-index="${index}">►</button>+ <span style="align-self: center">${animation_clip.name}</span>+ </div>+ <div>+ <input type="checkbox" name="${animation_clip.name}" value="${index}">+ </div>+ </div>`+ });+ }+}\ No newline at end of filediff --git a/src/lib/Utilities.ts b/src/lib/Utilities.tsnew file mode 100644index 0000000..1f1b7ad--- /dev/null+++ b/src/lib/Utilities.ts@@ -0,0 +1,244 @@+import { Vector3, Vector2, Object3D, Mesh, Group, Bone, Skeleton, Euler, Raycaster} from 'three';+import BoneTransformState from './models/BoneTransformState';++export class Utility {+ static distance_between_objects(+ object_1: Object3D,+ object_2: Object3D+ ): number {+ const object_1_position = new Vector3();+ const object_2_position = new Vector3();+ object_1.getWorldPosition(object_1_position);+ object_2.getWorldPosition(object_2_position);+ return object_1_position.distanceTo(object_2_position);+ }++ /**+ * Converts an object's local position to world position+ * This is similar to "localToWorld()", but makes sure the object's world matrix is up to date+ * https://stackoverflow.com/questions/70016922/three-js-getworldposition-localtoworld-position-not-correct+ * (see Mugen87's comment at the bottom)+ * @param {*} object+ * @returns local position for object in a Vector3 object+ */+ static world_position_from_object(object: Object3D): Vector3 {+ const position: Vector3 = new Vector3();+ return object.getWorldPosition(position);+ }++ static direction_between_points(point_1: Vector3, point_2: Vector3): Vector3 {+ let direction: Vector3 = new Vector3();+ direction.subVectors(point_2, point_1).normalize();+ return direction;+ }++ static is_point_in_box(point: Vector3, box_mesh: Mesh): boolean {+ //Transform the point from world space into the objects space+ box_mesh.updateMatrixWorld();+ let localPt: Vector3 = box_mesh.worldToLocal(point.clone());+ return box_mesh.geometry.boundingBox.containsPoint(localPt);+ }++ static remove_object_array(obj: Object3D): void {+ obj.traverse((child: any) => {+ if (child instanceof Mesh) {+ child.geometry.dispose();++ for (const key in child.material) {+ const value = child.material[key];+ if (value && typeof value.dispose === "function") {+ value.dispose();+ }+ }++ obj.remove(obj);+ }+ });+ }++ static remove_object_with_children(obj: Object3D): void {+ if (obj.children.length > 0) {+ obj.children.forEach((child) => {+ this.remove_object_with_children(child);+ });+ }++ if (obj instanceof Mesh) {+ if (obj.geometry) {+ obj.geometry.dispose();+ }++ if (obj.material) {+ if (obj.material.map) {+ obj.material.map.dispose();+ }++ obj.material.dispose();+ }+ }++ if (obj.parent) {+ obj.parent.remove(obj);+ }++ obj.removeFromParent();+ }++ static bone_list_from_hierarchy(bone_hierarchy: Object3D): Array<Bone> {+ if (bone_hierarchy === undefined || bone_hierarchy === null) {+ throw new Error(+ "bone_list_from_hierarchy() - bone_hierarchy parameter is undefined or null"+ );+ }++ const bone_list: Array<Bone> = [];+ bone_hierarchy.traverse((bone) => {+ if (bone instanceof Bone) {+ bone_list.push(bone);+ }+ });+ return bone_list;+ }++ static intersection_points_between_positions_and_mesh(positions, envelope_mesh) {+ const vertex_positions_inside_bone_envelope: Array<Vector3> = [];+ const vertex_indexes_inside_bone_evelope: Array<number> = [];+ const vertex_count: number = positions.array.length / 3;++ for( let i = 0; i < vertex_count; i++)+ {+ const vertexPosition: Vector3 = new Vector3().fromBufferAttribute(positions, i);+ const is_intersecting: boolean = Utility.is_point_in_box(vertexPosition, envelope_mesh)++ if(is_intersecting)+ {+ vertex_positions_inside_bone_envelope.push(vertexPosition)+ vertex_indexes_inside_bone_evelope.push(i)+ }+ }++ return { vertex_positions_inside_bone_envelope, vertex_indexes_inside_bone_evelope };+ }++ /**+ * From a mouse event, return a normalized vector2 for screen space between -1 and 1 (0 being center of screen)+ * This is used for turning a mouse event into a raycaster when determining screen space intersections+ * Top right of screen would return 1, 1. Bottom left would return -1, -1+ * @param {*} mouse_event+ * @returns x and y coordinates normalized between -1 and 1+ */+ static normalized_mouse_position(mouse_event): Vector2 {+ let mouse: Vector2 = new Vector2();+ mouse.x = (mouse_event.clientX / window.innerWidth) * 2 - 1;+ mouse.y = -(mouse_event.clientY / window.innerHeight) * 2 + 1;+ return mouse;+ }++ /**+ * Store all the debugging objects in a separate group so they can be easily organized+ * and removed when needed+ * @param {*} scene+ * @returns+ */+ static regenerate_debugging_scene(scene): Group {+ const debugging_object_name: string = "Skinning Debug Container";++ // clear out debugging container if it exists+ const existing_debugging_container: Object3D = scene.getObjectByName(+ debugging_object_name+ );+ if (existing_debugging_container) {+ this.remove_object_array(existing_debugging_container);+ existing_debugging_container.clear();+ scene.remove(existing_debugging_container);+ }++ // add a reusable container for debugging+ const debugging_scene_object: Group = new Group();+ debugging_scene_object.name = debugging_object_name;+ scene.add(debugging_scene_object);+ return debugging_scene_object;+ }++ static store_bone_transforms(skeleton: Skeleton): Array<BoneTransformState> {+ const bone_transforms: Array<BoneTransformState> = [];+ skeleton.bones.forEach((bone) => {+ const new_transform_state = new BoneTransformState(+ bone.name,+ bone.position.clone(),+ bone.rotation.clone(),+ bone.scale.clone()+ );+ bone_transforms.push(new_transform_state);+ });++ return bone_transforms;+ }++ static restore_bone_transforms(+ skeleton: Skeleton,+ original_bone_transforms: Array<BoneTransformState>+ ) {+ original_bone_transforms.forEach((bone_transform) => {+ const bone: Bone | null =+ skeleton.bones.find((bone) => bone.name === bone_transform.name) ??+ null;++ if (bone !== null) {+ bone.position.copy(bone_transform.position);+ let euler = new Euler();+ euler.setFromVector3(bone_transform.rotation);+ bone.rotation.copy(euler);+ bone.scale.copy(bone_transform.scale);+ }+ });+ }++ static calculate_bone_base_name(bone_name) {+ return bone_name+ .replace("mixamorig_", "")+ .replace(/(Right|Right_|R_|_Right|_R|Left|Left_|_Left|L_)/g, "");+ }++ static raycast_closest_bone_test(camera, mouse_event, skeleton)+ {+ // Find the closest bone for raycaster. Select that+ let raycaster = new Raycaster();+ raycaster.setFromCamera(Utility.normalized_mouse_position(mouse_event), camera);+ let closestBone = null;+ let closestBoneIndex = 0;+ let closestDistance = Infinity;++ skeleton.bones.forEach((bone, bone_index) => {+ let worldPosition = Utility.world_position_from_object(bone);+ let target = new Vector3();+ let point = raycaster.ray.closestPointToPoint(worldPosition, target);+ let distance = point.distanceTo(worldPosition);++ if (distance < closestDistance) {+ closestBone = bone;+ closestDistance = distance;+ closestBoneIndex = bone_index;+ }+ });++ return [closestBone, closestBoneIndex, closestDistance]+ }++ static scale_armature_by_scalar(armature, scalar)+ {+ armature.traverse((bone) => {+ if(bone.type === 'Bone')+ {+ bone.position.multiplyScalar(scalar);+ }+ });++ }++ static clean_bone_name_for_messaging(bone_name: string): string+ {+ return bone_name.replace('mixamorig_', '')+ }++}diff --git a/src/lib/data/StepData.js b/src/lib/data/StepData.jsnew file mode 100644index 0000000..cb47d6a--- /dev/null+++ b/src/lib/data/StepData.js@@ -0,0 +1,46 @@+// helps populate information about the current step along with instructions+export const STEPDATA = [+ {+ name: ProcessStep.LoadModel,+ index: 0,+ title: 'Load Model',+ description: 'Load a model to edit',+ instructions: 'Upload your own model, or choose from a pre-existing model.',+ },+ {+ name: ProcessStep.LoadSkeleton,+ index: 1,+ title: 'Load Skeleton',+ description: 'Load a skeleton to edit',+ instructions: 'Choose what type of skeleton to use.',+ },+ {+ name: ProcessStep.EditSkeleton,+ index: 2,+ title: 'Edit Skeleton',+ description: 'Edit the skeleton',+ instructions: 'Right click by a bone and translate or rotate it. Try to fit the bones evenly inside the mesh.',+ },+ {+ name: ProcessStep.WeightSkin,+ index: 3,+ title: 'Weight Skin',+ description: 'Weight the skin',+ instructions: 'See the bounding boxes that were created from bones. Red circles mean that there are no boxes that contain the vertex. They will use a shortest distance formular for this calculation',+ },+ {+ name: ProcessStep.AnimationsListing,+ index: 4,+ title: 'Animations Listing',+ description: 'Test out animations',+ instructions: 'Play animations and see if the results are good. If not, go back to the edit skeleton step and make modifications to get better results. After you are happy with the animations, select which animations you want to include with the final export.',+ },+ {+ name: ProcessStep.StepExportToFile,+ index: 5,+ title: 'Export to GLB',+ description: 'Export to File',+ instructions: 'GLB is the only available file export format. ',+ },++ ]\ No newline at end of filediff --git a/src/lib/enums/ProcessStep.js b/src/lib/enums/ProcessStep.jsnew file mode 100644index 0000000..d3dd738--- /dev/null+++ b/src/lib/enums/ProcessStep.js@@ -0,0 +1,55 @@+export const ProcessStep = {+ LoadModel: 'load-model',+ LoadSkeleton: 'load-skeleton',+ EditSkeleton: 'edit-skeleton',+ WeightSkin: 'weight-skin',+ AnimationsListing: 'animations-export',+ StepExportToFile: 'export-to-file'+};++export const step_data = [++ {+ name: ProcessStep.LoadModel,+ index: 0,+ title: 'Load Model',+ description: 'Load a model to edit',+ instructions: 'Upload your own model, or choose from a pre-existing model.',+ },+ {+ name: ProcessStep.LoadSkeleton,+ index: 1,+ title: 'Load Skeleton',+ description: 'Load a skeleton to edit',+ instructions: 'Upload your own skeleton, or choose from a pre-existing skeleton.',+ },+ {+ name: ProcessStep.EditSkeleton,+ index: 2,+ title: 'Edit Skeleton',+ description: 'Edit the skeleton',+ instructions: 'Edit the skeleton',+ },+ {+ name: ProcessStep.WeightSkin,+ index: 3,+ title: 'Weight Skin',+ description: 'Weight the skin',+ instructions: 'Weight the skin',+ },+ {+ name: ProcessStep.AnimationsListing,+ index: 4,+ title: 'Animations Listing',+ description: 'Load and edit animations',+ instructions: 'Load and edit animations',+ },+ {+ name: ProcessStep.StepExportToFile,+ index: 5,+ title: 'Export to File',+ description: 'Export to File',+ instructions: 'Export to File',+ },++]\ No newline at end of filediff --git a/src/lib/enums/SkeletonType.js b/src/lib/enums/SkeletonType.jsnew file mode 100644index 0000000..43f292e--- /dev/null+++ b/src/lib/enums/SkeletonType.js@@ -0,0 +1,7 @@+// Supported skeleton types+// the file names for the skeleton types are associated with the const+export const SkeletonType = {+ Quadraped: 'skeletons/skeleton-quadraped.glb',+ BipedalSimple: 'skeletons/skeleton-bipedal-simple.glb',+ BipedalFull: 'skeletons/skeleton-mecanim-full.glb',+};\ No newline at end of filediff --git a/src/lib/enums/SkinningFormula.js b/src/lib/enums/SkinningFormula.jsnew file mode 100644index 0000000..d8c885f--- /dev/null+++ b/src/lib/enums/SkinningFormula.js@@ -0,0 +1,5 @@+export const SkinningFormula = {+ Distance: 'distance',+ MedianDistance: 'median-distance',+ Envelope: 'envelope'+ };\ No newline at end of filediff --git a/src/lib/geometry/BoneEnvelopeGeometry.js b/src/lib/geometry/BoneEnvelopeGeometry.jsnew file mode 100644index 0000000..9d1302c--- /dev/null+++ b/src/lib/geometry/BoneEnvelopeGeometry.js@@ -0,0 +1,152 @@+import { BufferGeometry } from 'three/src/core/BufferGeometry.js';+import { BufferAttribute } from 'three/src/core/BufferAttribute.js';+import * as BufferGeometryUtils from 'three/addons/utils/BufferGeometryUtils.js';++class BoneEnvelopeGeometry {++ constructor( )+ {++ let geometry = new BufferGeometry();+ geometry.type = 'BoneEnvelopeGeometry'++ // points for a 0.01x0.01x0.01 cube+ const box_vertice_data = new Float32Array([+ 0.01,0.01,0.01,-0.01,0.01,0.01,-0.01,-0.01,0.01,0.01,0.01,0.01,-0.01,-0.01,0.01,0.01,-0.01,0.01,0.01,-0.01,-0.01,0.01,-0.01,0.01,-0.01,-0.01,0.01,0.01,-0.01,-0.01,-0.01,-0.01,0.01,-0.01,-0.01,-0.01,-0.01,-0.01,-0.01,-0.01,-0.01,0.01,-0.01,0.01,0.01,-0.01,-0.01,-0.01,-0.01,0.01,0.01,-0.01,0.01,-0.01,-0.01,0.01,-0.01,0.01,0.01,-0.01,0.01,-0.01,-0.01,-0.01,0.01,-0.01,0.01,-0.01,-0.01,-0.01,-0.01,-0.01,0.01,0.01,-0.01,0.01,0.01,0.01,0.01,-0.01,0.01,0.01,0.01,-0.01,0.01,-0.01,0.01,0.01,-0.01,-0.01,-0.01,0.01,-0.01,-0.01,0.01,0.01,0.01,0.01,0.01,-0.01,0.01,-0.01,0.01,0.01,0.01,0.01,0.01,-0.01+ ]);+ geometry.setAttribute( "position", new BufferAttribute( box_vertice_data, 3 ) );+ geometry.getAttribute("position").needsUpdate = true;++ // create indexed vertex positions for easier manipulation later+ geometry = BufferGeometryUtils.mergeVertices( geometry );+ geometry.computeVertexNormals(); // required after setting new position attributes++ return geometry;+ }+}+++class BoneEnvelopeGeometryUtils+{+ static expand_x_positive_face(geometry,x)+ {+ this.move_x_pos_top_left(geometry, x, 0, 0)+ this.move_x_pos_top_right(geometry, x, 0, 0)+ this.move_x_pos_bottom_left(geometry, x,0,0)+ this.move_x_pos_bottom_right(geometry, x,0,0)+ }++ static expand_x_negative_face(geometry, x)+ {+ this.move_x_neg_top_left(geometry, -x, 0, 0)+ this.move_x_neg_top_right(geometry, -x, 0, 0)+ this.move_x_neg_bottom_left(geometry, -x,0,0)+ this.move_x_neg_bottom_right(geometry, -x,0,0)+ }++ static expand_z_negative_face(geometry, z)+ {+ this.move_x_pos_top_right(geometry, 0, 0, -z)+ this.move_x_pos_bottom_right(geometry, 0,0,-z)+ this.move_x_neg_bottom_left(geometry, 0,0,-z)+ this.move_x_neg_top_right(geometry, 0, 0, -z)++ }++ static expand_z_positive_face(geometry, z)+ {+ this.move_x_pos_top_left(geometry, 0, 0, z)+ this.move_x_pos_bottom_left(geometry, 0,0,z)+ this.move_x_neg_bottom_right(geometry, 0,0,z)+ this.move_x_neg_top_left(geometry, 0, 0,z)+ }+++ static expand_y_positive_face(geometry, y)+ {+ this.move_x_pos_top_left(geometry, 0, y, 0)+ this.move_x_neg_top_left(geometry, 0, y,0)+ this.move_x_pos_top_right(geometry, 0, y,0)+ this.move_x_neg_top_right(geometry, 0, y,0)+ }++ static expand_y_negative_face(geometry, y)+ {+ this.move_x_pos_bottom_left(geometry, 0, -y, 0)+ this.move_x_neg_bottom_left(geometry, 0, -y,0)+ this.move_x_pos_bottom_right(geometry, 0, -y,0)+ this.move_x_neg_bottom_right(geometry, 0, -y,0)+ }+++ static move_x_neg_top_left(geometry, x,y,z)+ {+ // X-Negative Top Right indexed vertex+ geometry.attributes.position.array[3] += x+ geometry.attributes.position.array[4] += y+ geometry.attributes.position.array[5] += z+ }++ static move_x_neg_bottom_right(geometry, x,y,z)+ {+ // X-Negative Bottom Right indexed vertex+ geometry.attributes.position.array[6] += x+ geometry.attributes.position.array[7] += y+ geometry.attributes.position.array[8] += z++ }++ static move_x_neg_bottom_left(geometry, x,y,z)+ {+ // X-Negative Bottom Left indexed vertex+ geometry.attributes.position.array[15] += x+ geometry.attributes.position.array[16] += y+ geometry.attributes.position.array[17] += z+ }++ static move_x_neg_top_right(geometry, x,y,z)+ {+ // X-Negative Top Left indexed vertex+ geometry.attributes.position.array[18] += x+ geometry.attributes.position.array[19] += y+ geometry.attributes.position.array[20] += z+ }+++ static move_x_pos_top_left(geometry, x, y, z)+ {+ // X-Positive Top Left indexed vertex+ geometry.attributes.position.array[0] += x;+ geometry.attributes.position.array[1] += y;+ geometry.attributes.position.array[2] += z;+ }++ static move_x_pos_bottom_left(geometry, x,y,z)+ {+ // X-Positive Bottom Left indexed vertex+ geometry.attributes.position.array[9] += x+ geometry.attributes.position.array[10] += y+ geometry.attributes.position.array[11] += z+ }++ static move_x_pos_bottom_right(geometry, x,y,z)+ {+ // X-Positive Bottom Right indexed vertex+ geometry.attributes.position.array[12] += x+ geometry.attributes.position.array[13] += y+ geometry.attributes.position.array[14] += z+ }++ static move_x_pos_top_right(geometry, x,y,z)+ {+ // X-Positive Top Right indexed vertex+ geometry.attributes.position.array[21] += x+ geometry.attributes.position.array[22] += y+ geometry.attributes.position.array[23] += z+ }++++}++export { BoneEnvelopeGeometry, BoneEnvelopeGeometryUtils };\ No newline at end of filediff --git a/src/lib/geometry/BoxGeometry.js b/src/lib/geometry/BoxGeometry.jsnew file mode 100644index 0000000..99053dc--- /dev/null+++ b/src/lib/geometry/BoxGeometry.js@@ -0,0 +1,11 @@+export function create_box_geometry()+{+ const geometry = new BufferGeometry();+ const box_vertice_data = new Float32Array([+ 1.0,1.0,1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,-1.0,-1.0,1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,1.0,-1.0,-1.0,-1.0,1.0,-1.0,1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0,1.0,1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,-1.0,-1.0,1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,1.0,1.0,-1.0+ ]);+ geometry.setAttribute('position', new BufferAttribute( box_vertice_data, 3 ) );+ geometry.getAttribute('position').needsUpdate = true;+ geometry.computeVertexNormals(); // required after setting new position attributes+ return geometry;+}diff --git a/src/lib/geometry/ComplexBoxGeometry.js b/src/lib/geometry/ComplexBoxGeometry.jsnew file mode 100644index 0000000..5d206c5--- /dev/null+++ b/src/lib/geometry/ComplexBoxGeometry.js@@ -0,0 +1,12 @@+export function create_complex_box_geometry() {++ const geometry = new BufferGeometry();++ const box_vertice_data = new Float32Array([0.28999996185302734,-0.28999999165534973,-1.0,0.8700000047683716,-0.28999996185302734,-1.0,0.8700000047683716,-0.8700000047683716,-1.0,0.28999996185302734,-0.28999999165534973,-1.0,0.8700000047683716,-0.8700000047683716,-1.0,0.2900000214576721,-0.8700000047683716,-1.0,-1.0,0.28999999165534973,0.28999996185302734,-1.0,0.28999996185302734,0.8700000047683716,-1.0,0.8700000047683716,0.8700000047683716,-1.0,0.28999999165534973,0.28999996185302734,-1.0,0.8700000047683716,0.8700000047683716,-1.0,0.8700000047683716,0.2900000214576721,-0.28999999165534973,-1.0,0.28999996185302734,-0.28999996185302734,-1.0,0.8700000047683716,-0.8700000047683716,-1.0,0.8700000047683716,-0.28999999165534973,-1.0,0.28999996185302734,-0.8700000047683716,-1.0,0.8700000047683716,-0.8700000047683716,-1.0,0.2900000214576721,-0.28999996185302734,-0.28999999165534973,1.0,-0.8700000047683716,-0.28999996185302734,1.0,-0.8700000047683716,-0.8700000047683716,1.0,-0.28999996185302734,-0.28999999165534973,1.0,-0.8700000047683716,-0.8700000047683716,1.0,-0.2900000214576721,-0.8700000047683716,1.0,1.0,-0.28999999165534973,0.28999996185302734,1.0,-0.28999996185302734,0.8700000047683716,1.0,-0.8700000047683716,0.8700000047683716,1.0,-0.28999999165534973,0.28999996185302734,1.0,-0.8700000047683716,0.8700000047683716,1.0,-0.8700000047683716,0.2900000214576721,0.8700000047683716,1.0,0.8700000047683716,0.8700000047683716,0.9619238972663879,0.9619238972663879,0.9450555443763733,0.9450555443763733,0.9450555443763733,0.8700000047683716,1.0,0.8700000047683716,0.9450555443763733,0.9450555443763733,0.9450555443763733,0.9619238972663879,0.9619238972663879,0.8700000047683716,0.8700000047683716,0.8700000047683716,1.0,0.9619238972663879,0.8700000047683716,0.9619238972663879,0.9450555443763733,0.9450555443763733,0.9450555443763733,0.8700000047683716,0.8700000047683716,1.0,0.9450555443763733,0.9450555443763733,0.9450555443763733,0.8700000047683716,0.9619238972663879,0.9619238972663879,1.0,0.8700000047683716,0.8700000047683716,0.9619238972663879,0.9619238972663879,0.8700000047683716,0.9450555443763733,0.9450555443763733,0.9450555443763733,1.0,0.8700000047683716,0.8700000047683716,0.9450555443763733,0.9450555443763733,0.9450555443763733,0.9619238972663879,0.8700000047683716,0.9619238972663879,0.8700000047683716,0.8700000047683716,-1.0,0.8700000047683716,0.9619238972663879,-0.9619238972663879,0.9450555443763733,0.9450555443763733,-0.9450555443763733,0.8700000047683716,0.8700000047683716,-1.0,0.9450555443763733,0.9450555443763733,-0.9450555443763733,0.9619238972663879,0.8700000047683716,-0.9619238972663879,0.8700000047683716,1.0,-0.8700000047683716,0.9619238972663879,0.9619238972663879,-0.8700000047683716,0.9450555443763733,0.9450555443763733,-0.9450555443763733,0.8700000047683716,1.0,-0.8700000047683716,0.9450555443763733,0.9450555443763733,-0.9450555443763733,0.8700000047683716,0.9619238972663879,-0.9619238972663879,1.0,0.8700000047683716,-0.8700000047683716,0.9619238972663879,0.8700000047683716,-0.9619238972663879,0.9450555443763733,0.9450555443763733,-0.9450555443763733,1.0,0.8700000047683716,-0.8700000047683716,0.9450555443763733,0.9450555443763733,-0.9450555443763733,0.9619238972663879,0.9619238972663879,-0.8700000047683716,1.0,-0.8700000047683716,0.8700000047683716,0.9619238972663879,-0.8700000047683716,0.9619238972663879,0.9450555443763733,-0.9450555443763733,0.9450555443763733,1.0,-0.8700000047683716,0.8700000047683716,0.9450555443763733,-0.9450555443763733,0.9450555443763733,0.9619238972663879,-0.9619238972663879,0.8700000047683716,0.8700000047683716,-0.8700000047683716,1.0,0.8700000047683716,-0.9619238972663879,0.9619238972663879,0.9450555443763733,-0.9450555443763733,0.9450555443763733,0.8700000047683716,-0.8700000047683716,1.0,0.9450555443763733,-0.9450555443763733,0.9450555443763733,0.9619238972663879,-0.8700000047683716,0.9619238972663879,0.8700000047683716,-1.0,0.8700000047683716,0.9619238972663879,-0.9619238972663879,0.8700000047683716,0.9450555443763733,-0.9450555443763733,0.9450555443763733,0.8700000047683716,-1.0,0.8700000047683716,0.9450555443763733,-0.9450555443763733,0.9450555443763733,0.8700000047683716,-0.9619238972663879,0.9619238972663879,1.0,-0.8700000047683716,-0.8700000047683716,0.9619238972663879,-0.9619238972663879,-0.8700000047683716,0.9450555443763733,-0.9450555443763733,-0.9450555443763733,1.0,-0.8700000047683716,-0.8700000047683716,0.9450555443763733,-0.9450555443763733,-0.9450555443763733,0.9619238972663879,-0.8700000047683716,-0.9619238972663879,0.8700000047683716,-1.0,-0.8700000047683716,0.8700000047683716,-0.9619238972663879,-0.9619238972663879,0.9450555443763733,-0.9450555443763733,-0.9450555443763733,0.8700000047683716,-1.0,-0.8700000047683716,0.9450555443763733,-0.9450555443763733,-0.9450555443763733,0.9619238972663879,-0.9619238972663879,-0.8700000047683716,0.8700000047683716,-0.8700000047683716,-1.0,0.9619238972663879,-0.8700000047683716,-0.9619238972663879,0.9450555443763733,-0.9450555443763733,-0.9450555443763733,0.8700000047683716,-0.8700000047683716,-1.0,0.9450555443763733,-0.9450555443763733,-0.9450555443763733,0.8700000047683716,-0.9619238972663879,-0.9619238972663879,-0.8700000047683716,1.0,0.8700000047683716,-0.9619238972663879,0.9619238972663879,0.8700000047683716,-0.9450555443763733,0.9450555443763733,0.9450555443763733,-0.8700000047683716,1.0,0.8700000047683716,-0.9450555443763733,0.9450555443763733,0.9450555443763733,-0.8700000047683716,0.9619238972663879,0.9619238972663879,-1.0,0.8700000047683716,0.8700000047683716,-0.9619238972663879,0.8700000047683716,0.9619238972663879,-0.9450555443763733,0.9450555443763733,0.9450555443763733,-1.0,0.8700000047683716,0.8700000047683716,-0.9450555443763733,0.9450555443763733,0.9450555443763733,-0.9619238972663879,0.9619238972663879,0.8700000047683716,-0.8700000047683716,0.8700000047683716,1.0,-0.8700000047683716,0.9619238972663879,0.9619238972663879,-0.9450555443763733,0.9450555443763733,0.9450555443763733,-0.8700000047683716,0.8700000047683716,1.0,-0.9450555443763733,0.9450555443763733,0.9450555443763733,-0.9619238972663879,0.8700000047683716,0.9619238972663879,-1.0,0.8700000047683716,-0.8700000047683716,-0.9619238972663879,0.9619238972663879,-0.8700000047683716,-0.9450555443763733,0.9450555443763733,-0.9450555443763733,-1.0,0.8700000047683716,-0.8700000047683716,-0.9450555443763733,0.9450555443763733,-0.9450555443763733,-0.9619238972663879,0.8700000047683716,-0.9619238972663879,-0.8700000047683716,1.0,-0.8700000047683716,-0.8700000047683716,0.9619238972663879,-0.9619238972663879,-0.9450555443763733,0.9450555443763733,-0.9450555443763733,-0.8700000047683716,1.0,-0.8700000047683716,-0.9450555443763733,0.9450555443763733,-0.9450555443763733,-0.9619238972663879,0.9619238972663879,-0.8700000047683716,-0.8700000047683716,0.8700000047683716,-1.0,-0.9619238972663879,0.8700000047683716,-0.9619238972663879,-0.9450555443763733,0.9450555443763733,-0.9450555443763733,-0.8700000047683716,0.8700000047683716,-1.0,-0.9450555443763733,0.9450555443763733,-0.9450555443763733,-0.8700000047683716,0.9619238972663879,-0.9619238972663879,-1.0,-0.8700000047683716,0.8700000047683716,-0.9619238972663879,-0.9619238972663879,0.8700000047683716,-0.9450555443763733,-0.9450555443763733,0.9450555443763733,-1.0,-0.8700000047683716,0.8700000047683716,-0.9450555443763733,-0.9450555443763733,0.9450555443763733,-0.9619238972663879,-0.8700000047683716,0.9619238972663879,-0.8700000047683716,-1.0,0.8700000047683716,-0.8700000047683716,-0.9619238972663879,0.9619238972663879,-0.9450555443763733,-0.9450555443763733,0.9450555443763733,-0.8700000047683716,-1.0,0.8700000047683716,-0.9450555443763733,-0.9450555443763733,0.9450555443763733,-0.9619238972663879,-0.9619238972663879,0.8700000047683716,-0.8700000047683716,-0.8700000047683716,1.0,-0.9619238972663879,-0.8700000047683716,0.9619238972663879,-0.9450555443763733,-0.9450555443763733,0.9450555443763733,-0.8700000047683716,-0.8700000047683716,1.0,-0.9450555443763733,-0.9450555443763733,0.9450555443763733,-0.8700000047683716,-0.9619238972663879,0.9619238972663879,-0.8700000047683716,-0.8700000047683716,-1.0,-0.8700000047683716,-0.9619238972663879,-0.9619238972663879,-0.9450555443763733,-0.9450555443763733,-0.9450555443763733,-0.8700000047683716,-0.8700000047683716,-1.0,-0.9450555443763733,-0.9450555443763733,-0.9450555443763733,-0.9619238972663879,-0.8700000047683716,-0.9619238972663879,-0.8700000047683716,-1.0,-0.8700000047683716,-0.9619238972663879,-0.9619238972663879,-0.8700000047683716,-0.9450555443763733,-0.9450555443763733,-0.9450555443763733,-0.8700000047683716,-1.0,-0.8700000047683716,-0.9450555443763733,-0.9450555443763733,-0.9450555443763733,-0.8700000047683716,-0.9619238972663879,-0.9619238972663879,-1.0,-0.8700000047683716,-0.8700000047683716,-0.9619238972663879,-0.8700000047683716,-0.9619238972663879,-0.9450555443763733,-0.9450555443763733,-0.9450555443763733,-1.0,-0.8700000047683716,-0.8700000047683716,-0.9450555443763733,-0.9450555443763733,-0.9450555443763733,-0.9619238972663879,-0.9619238972663879,-0.8700000047683716,-0.8700000047683716,-0.2900000214576721,-1.0,-0.8700000047683716,-0.8700000047683716,-1.0,-0.9619238972663879,-0.8700000047683716,-0.9619238972663879,-0.8700000047683716,-0.2900000214576721,-1.0,-0.9619238972663879,-0.8700000047683716,-0.9619238972663879,-0.9619238972663879,-0.28999996185302734,-0.9619238972663879,-0.9619238972663879,-0.28999996185302734,-0.9619238972663879,-0.9619238972663879,-0.8700000047683716,-0.9619238972663879,-1.0,-0.8700000047683716,-0.8700000047683716,-0.9619238972663879,-0.28999996185302734,-0.9619238972663879,-1.0,-0.8700000047683716,-0.8700000047683716,-1.0,-0.28999996185302734,-0.8700000047683716,-0.2900000214576721,0.8700000047683716,-1.0,-0.8700000047683716,0.8700000047683716,-1.0,-0.8700000047683716,0.9619238972663879,-0.9619238972663879,-0.2900000214576721,0.8700000047683716,-1.0,-0.8700000047683716,0.9619238972663879,-0.9619238972663879,-0.28999996185302734,0.9619238972663879,-0.9619238972663879,-0.28999996185302734,0.9619238972663879,-0.9619238972663879,-0.8700000047683716,0.9619238972663879,-0.9619238972663879,-0.8700000047683716,1.0,-0.8700000047683716,-0.28999996185302734,0.9619238972663879,-0.9619238972663879,-0.8700000047683716,1.0,-0.8700000047683716,-0.28999996185302734,1.0,-0.8700000047683716,1.0,0.8700000047683716,-0.2900000214576721,1.0,0.8700000047683716,-0.8700000047683716,0.9619238972663879,0.9619238972663879,-0.8700000047683716,1.0,0.8700000047683716,-0.2900000214576721,0.9619238972663879,0.9619238972663879,-0.8700000047683716,0.9619238972663879,0.9619238972663879,-0.28999996185302734,0.9619238972663879,0.9619238972663879,-0.28999996185302734,0.9619238972663879,0.9619238972663879,-0.8700000047683716,0.8700000047683716,1.0,-0.8700000047683716,0.9619238972663879,0.9619238972663879,-0.28999996185302734,0.8700000047683716,1.0,-0.8700000047683716,0.8700000047683716,1.0,-0.28999996185302734,-0.8700000047683716,-1.0,0.2900000214576721,-0.8700000047683716,-1.0,0.8700000047683716,-0.9619238972663879,-0.9619238972663879,0.8700000047683716,-0.8700000047683716,-1.0,0.2900000214576721,-0.9619238972663879,-0.9619238972663879,0.8700000047683716,-0.9619238972663879,-0.9619238972663879,0.28999996185302734,-0.9619238972663879,-0.9619238972663879,0.28999996185302734,-0.9619238972663879,-0.9619238972663879,0.8700000047683716,-1.0,-0.8700000047683716,0.8700000047683716,-0.9619238972663879,-0.9619238972663879,0.28999996185302734,-1.0,-0.8700000047683716,0.8700000047683716,-1.0,-0.8700000047683716,0.28999996185302734,0.8700000047683716,-1.0,-0.2900000214576721,0.8700000047683716,-1.0,-0.8700000047683716,0.9619238972663879,-0.9619238972663879,-0.8700000047683716,0.8700000047683716,-1.0,-0.2900000214576721,0.9619238972663879,-0.9619238972663879,-0.8700000047683716,0.9619238972663879,-0.9619238972663879,-0.28999996185302734,0.9619238972663879,-0.9619238972663879,-0.28999996185302734,0.9619238972663879,-0.9619238972663879,-0.8700000047683716,1.0,-0.8700000047683716,-0.8700000047683716,0.9619238972663879,-0.9619238972663879,-0.28999996185302734,1.0,-0.8700000047683716,-0.8700000047683716,1.0,-0.8700000047683716,-0.28999996185302734,-0.8700000047683716,1.0,-0.2900000214576721,-0.8700000047683716,1.0,-0.8700000047683716,-0.9619238972663879,0.9619238972663879,-0.8700000047683716,-0.8700000047683716,1.0,-0.2900000214576721,-0.9619238972663879,0.9619238972663879,-0.8700000047683716,-0.9619238972663879,0.9619238972663879,-0.28999996185302734,-0.9619238972663879,0.9619238972663879,-0.28999996185302734,-0.9619238972663879,0.9619238972663879,-0.8700000047683716,-1.0,0.8700000047683716,-0.8700000047683716,-0.9619238972663879,0.9619238972663879,-0.28999996185302734,-1.0,0.8700000047683716,-0.8700000047683716,-1.0,0.8700000047683716,-0.28999996185302734,-0.2900000214576721,-0.8700000047683716,1.0,-0.8700000047683716,-0.8700000047683716,1.0,-0.8700000047683716,-0.9619238972663879,0.9619238972663879,-0.2900000214576721,-0.8700000047683716,1.0,-0.8700000047683716,-0.9619238972663879,0.9619238972663879,-0.28999996185302734,-0.9619238972663879,0.9619238972663879,-0.28999996185302734,-0.9619238972663879,0.9619238972663879,-0.8700000047683716,-0.9619238972663879,0.9619238972663879,-0.8700000047683716,-1.0,0.8700000047683716,-0.28999996185302734,-0.9619238972663879,0.9619238972663879,-0.8700000047683716,-1.0,0.8700000047683716,-0.28999996185302734,-1.0,0.8700000047683716,0.8700000047683716,-0.2900000214576721,1.0,0.8700000047683716,-0.8700000047683716,1.0,0.9619238972663879,-0.8700000047683716,0.9619238972663879,0.8700000047683716,-0.2900000214576721,1.0,0.9619238972663879,-0.8700000047683716,0.9619238972663879,0.9619238972663879,-0.28999996185302734,0.9619238972663879,0.9619238972663879,-0.28999996185302734,0.9619238972663879,0.9619238972663879,-0.8700000047683716,0.9619238972663879,1.0,-0.8700000047683716,0.8700000047683716,0.9619238972663879,-0.28999996185302734,0.9619238972663879,1.0,-0.8700000047683716,0.8700000047683716,1.0,-0.28999996185302734,0.8700000047683716,0.2900000214576721,-0.8700000047683716,-1.0,0.8700000047683716,-0.8700000047683716,-1.0,0.8700000047683716,-0.9619238972663879,-0.9619238972663879,0.2900000214576721,-0.8700000047683716,-1.0,0.8700000047683716,-0.9619238972663879,-0.9619238972663879,0.28999996185302734,-0.9619238972663879,-0.9619238972663879,0.28999996185302734,-0.9619238972663879,-0.9619238972663879,0.8700000047683716,-0.9619238972663879,-0.9619238972663879,0.8700000047683716,-1.0,-0.8700000047683716,0.28999996185302734,-0.9619238972663879,-0.9619238972663879,0.8700000047683716,-1.0,-0.8700000047683716,0.28999996185302734,-1.0,-0.8700000047683716,-0.8700000047683716,0.2900000214576721,1.0,-0.8700000047683716,0.8700000047683716,1.0,-0.9619238972663879,0.8700000047683716,0.9619238972663879,-0.8700000047683716,0.2900000214576721,1.0,-0.9619238972663879,0.8700000047683716,0.9619238972663879,-0.9619238972663879,0.28999996185302734,0.9619238972663879,-0.9619238972663879,0.28999996185302734,0.9619238972663879,-0.9619238972663879,0.8700000047683716,0.9619238972663879,-1.0,0.8700000047683716,0.8700000047683716,-0.9619238972663879,0.28999996185302734,0.9619238972663879,-1.0,0.8700000047683716,0.8700000047683716,-1.0,0.28999996185302734,0.8700000047683716,0.2900000214576721,0.8700000047683716,1.0,0.8700000047683716,0.8700000047683716,1.0,0.8700000047683716,0.9619238972663879,0.9619238972663879,0.2900000214576721,0.8700000047683716,1.0,0.8700000047683716,0.9619238972663879,0.9619238972663879,0.28999996185302734,0.9619238972663879,0.9619238972663879,0.28999996185302734,0.9619238972663879,0.9619238972663879,0.8700000047683716,0.9619238972663879,0.9619238972663879,0.8700000047683716,1.0,0.8700000047683716,0.28999996185302734,0.9619238972663879,0.9619238972663879,0.8700000047683716,1.0,0.8700000047683716,0.28999996185302734,1.0,0.8700000047683716,0.8700000047683716,0.2900000214576721,-1.0,0.8700000047683716,0.8700000047683716,-1.0,0.9619238972663879,0.8700000047683716,-0.9619238972663879,0.8700000047683716,0.2900000214576721,-1.0,0.9619238972663879,0.8700000047683716,-0.9619238972663879,0.9619238972663879,0.28999996185302734,-0.9619238972663879,0.9619238972663879,0.28999996185302734,-0.9619238972663879,0.9619238972663879,0.8700000047683716,-0.9619238972663879,1.0,0.8700000047683716,-0.8700000047683716,0.9619238972663879,0.28999996185302734,-0.9619238972663879,1.0,0.8700000047683716,-0.8700000047683716,1.0,0.28999996185302734,-0.8700000047683716,0.28999999165534973,1.0,0.28999996185302734,0.28999996185302734,1.0,0.8700000047683716,0.8700000047683716,1.0,0.8700000047683716,0.28999999165534973,1.0,0.28999996185302734,0.8700000047683716,1.0,0.8700000047683716,0.8700000047683716,1.0,0.2900000214576721,0.9619238972663879,-0.8700000047683716,-0.9619238972663879,0.9619238972663879,-0.2900000214576721,-0.9619238972663879,1.0,-0.2900000214576721,-0.8700000047683716,0.9619238972663879,-0.8700000047683716,-0.9619238972663879,1.0,-0.2900000214576721,-0.8700000047683716,1.0,-0.8700000047683716,-0.8700000047683716,0.9619238972663879,-0.2900000214576721,-0.9619238972663879,0.9619238972663879,0.28999996185302734,-0.9619238972663879,1.0,0.28999996185302734,-0.8700000047683716,0.9619238972663879,-0.2900000214576721,-0.9619238972663879,1.0,0.28999996185302734,-0.8700000047683716,1.0,-0.2900000214576721,-0.8700000047683716,0.8700000047683716,-0.8700000047683716,-1.0,0.8700000047683716,-0.28999996185302734,-1.0,0.9619238972663879,-0.2900000214576721,-0.9619238972663879,0.8700000047683716,-0.8700000047683716,-1.0,0.9619238972663879,-0.2900000214576721,-0.9619238972663879,0.9619238972663879,-0.8700000047683716,-0.9619238972663879,0.8700000047683716,-0.28999996185302734,-1.0,0.8700000047683716,0.2900000214576721,-1.0,0.9619238972663879,0.28999996185302734,-0.9619238972663879,0.8700000047683716,-0.28999996185302734,-1.0,0.9619238972663879,0.28999996185302734,-0.9619238972663879,0.9619238972663879,-0.2900000214576721,-0.9619238972663879,-0.9619238972663879,-0.8700000047683716,0.9619238972663879,-0.9619238972663879,-0.2900000214576721,0.9619238972663879,-1.0,-0.2900000214576721,0.8700000047683716,-0.9619238972663879,-0.8700000047683716,0.9619238972663879,-1.0,-0.2900000214576721,0.8700000047683716,-1.0,-0.8700000047683716,0.8700000047683716,-0.9619238972663879,-0.2900000214576721,0.9619238972663879,-0.9619238972663879,0.28999996185302734,0.9619238972663879,-1.0,0.28999996185302734,0.8700000047683716,-0.9619238972663879,-0.2900000214576721,0.9619238972663879,-1.0,0.28999996185302734,0.8700000047683716,-1.0,-0.2900000214576721,0.8700000047683716,-0.8700000047683716,-0.8700000047683716,1.0,-0.8700000047683716,-0.28999996185302734,1.0,-0.9619238972663879,-0.2900000214576721,0.9619238972663879,-0.8700000047683716,-0.8700000047683716,1.0,-0.9619238972663879,-0.2900000214576721,0.9619238972663879,-0.9619238972663879,-0.8700000047683716,0.9619238972663879,-0.8700000047683716,-0.28999996185302734,1.0,-0.8700000047683716,0.2900000214576721,1.0,-0.9619238972663879,0.28999996185302734,0.9619238972663879,-0.8700000047683716,-0.28999996185302734,1.0,-0.9619238972663879,0.28999996185302734,0.9619238972663879,-0.9619238972663879,-0.2900000214576721,0.9619238972663879,0.9619238972663879,0.8700000047683716,0.9619238972663879,0.9619238972663879,0.2900000214576721,0.9619238972663879,1.0,0.2900000214576721,0.8700000047683716,0.9619238972663879,0.8700000047683716,0.9619238972663879,1.0,0.2900000214576721,0.8700000047683716,1.0,0.8700000047683716,0.8700000047683716,0.9619238972663879,0.2900000214576721,0.9619238972663879,0.9619238972663879,-0.28999996185302734,0.9619238972663879,1.0,-0.28999996185302734,0.8700000047683716,0.9619238972663879,0.2900000214576721,0.9619238972663879,1.0,-0.28999996185302734,0.8700000047683716,1.0,0.2900000214576721,0.8700000047683716,0.8700000047683716,0.8700000047683716,1.0,0.8700000047683716,0.28999996185302734,1.0,0.9619238972663879,0.2900000214576721,0.9619238972663879,0.8700000047683716,0.8700000047683716,1.0,0.9619238972663879,0.2900000214576721,0.9619238972663879,0.9619238972663879,0.8700000047683716,0.9619238972663879,0.8700000047683716,0.28999996185302734,1.0,0.8700000047683716,-0.2900000214576721,1.0,0.9619238972663879,-0.28999996185302734,0.9619238972663879,0.8700000047683716,0.28999996185302734,1.0,0.9619238972663879,-0.28999996185302734,0.9619238972663879,0.9619238972663879,0.2900000214576721,0.9619238972663879,-0.9619238972663879,0.8700000047683716,-0.9619238972663879,-0.9619238972663879,0.2900000214576721,-0.9619238972663879,-1.0,0.2900000214576721,-0.8700000047683716,-0.9619238972663879,0.8700000047683716,-0.9619238972663879,-1.0,0.2900000214576721,-0.8700000047683716,-1.0,0.8700000047683716,-0.8700000047683716,-0.9619238972663879,0.2900000214576721,-0.9619238972663879,-0.9619238972663879,-0.28999996185302734,-0.9619238972663879,-1.0,-0.28999996185302734,-0.8700000047683716,-0.9619238972663879,0.2900000214576721,-0.9619238972663879,-1.0,-0.28999996185302734,-0.8700000047683716,-1.0,0.2900000214576721,-0.8700000047683716,-0.8700000047683716,0.8700000047683716,-1.0,-0.8700000047683716,0.28999996185302734,-1.0,-0.9619238972663879,0.2900000214576721,-0.9619238972663879,-0.8700000047683716,0.8700000047683716,-1.0,-0.9619238972663879,0.2900000214576721,-0.9619238972663879,-0.9619238972663879,0.8700000047683716,-0.9619238972663879,-0.8700000047683716,0.28999996185302734,-1.0,-0.8700000047683716,-0.2900000214576721,-1.0,-0.9619238972663879,-0.28999996185302734,-0.9619238972663879,-0.8700000047683716,0.28999996185302734,-1.0,-0.9619238972663879,-0.28999996185302734,-0.9619238972663879,-0.9619238972663879,0.2900000214576721,-0.9619238972663879,1.0,0.8700000047683716,0.28999996185302734,1.0,0.8700000047683716,0.8700000047683716,1.0,0.2900000214576721,0.8700000047683716,1.0,0.8700000047683716,0.28999996185302734,1.0,0.2900000214576721,0.8700000047683716,1.0,0.28999999165534973,0.28999996185302734,1.0,0.28999999165534973,0.28999996185302734,1.0,0.2900000214576721,0.8700000047683716,1.0,-0.28999996185302734,0.8700000047683716,1.0,0.28999999165534973,0.28999996185302734,1.0,-0.28999996185302734,0.8700000047683716,1.0,-0.28999999165534973,0.28999996185302734,-0.28999996185302734,0.8700000047683716,1.0,-0.8700000047683716,0.8700000047683716,1.0,-0.8700000047683716,0.2900000214576721,1.0,-0.28999996185302734,0.8700000047683716,1.0,-0.8700000047683716,0.2900000214576721,1.0,-0.28999996185302734,0.28999999165534973,1.0,-0.28999996185302734,0.28999999165534973,1.0,-0.8700000047683716,0.2900000214576721,1.0,-0.8700000047683716,-0.28999996185302734,1.0,-0.28999996185302734,0.28999999165534973,1.0,-0.8700000047683716,-0.28999996185302734,1.0,-0.28999996185302734,-0.28999999165534973,1.0,-1.0,-0.8700000047683716,0.28999996185302734,-1.0,-0.8700000047683716,0.8700000047683716,-1.0,-0.2900000214576721,0.8700000047683716,-1.0,-0.8700000047683716,0.28999996185302734,-1.0,-0.2900000214576721,0.8700000047683716,-1.0,-0.28999999165534973,0.28999996185302734,-1.0,-0.28999999165534973,0.28999996185302734,-1.0,-0.2900000214576721,0.8700000047683716,-1.0,0.28999996185302734,0.8700000047683716,-1.0,-0.28999999165534973,0.28999996185302734,-1.0,0.28999996185302734,0.8700000047683716,-1.0,0.28999999165534973,0.28999996185302734,0.28999996185302734,0.8700000047683716,-1.0,0.8700000047683716,0.8700000047683716,-1.0,0.8700000047683716,0.2900000214576721,-1.0,0.28999996185302734,0.8700000047683716,-1.0,0.8700000047683716,0.2900000214576721,-1.0,0.28999996185302734,0.28999999165534973,-1.0,0.28999996185302734,0.28999999165534973,-1.0,0.8700000047683716,0.2900000214576721,-1.0,0.8700000047683716,-0.28999996185302734,-1.0,0.28999996185302734,0.28999999165534973,-1.0,0.8700000047683716,-0.28999996185302734,-1.0,0.28999996185302734,-0.28999999165534973,-1.0,-0.8700000047683716,0.28999996185302734,-1.0,-0.2900000214576721,0.28999996185302734,-1.0,-0.2900000214576721,-0.2900000214576721,-1.0,-0.8700000047683716,0.28999996185302734,-1.0,-0.2900000214576721,-0.2900000214576721,-1.0,-0.8700000047683716,-0.2900000214576721,-1.0,-0.2900000214576721,0.28999996185302734,-1.0,0.28999996185302734,0.28999999165534973,-1.0,0.28999996185302734,-0.28999999165534973,-1.0,-0.2900000214576721,0.28999996185302734,-1.0,0.28999996185302734,-0.28999999165534973,-1.0,-0.2900000214576721,-0.2900000214576721,-1.0,-0.8700000047683716,0.8700000047683716,-1.0,-0.2900000214576721,0.8700000047683716,-1.0,-0.2900000214576721,0.28999996185302734,-1.0,-0.8700000047683716,0.8700000047683716,-1.0,-0.2900000214576721,0.28999996185302734,-1.0,-0.8700000047683716,0.28999996185302734,-1.0,-0.2900000214576721,0.8700000047683716,-1.0,0.28999996185302734,0.8700000047683716,-1.0,0.28999996185302734,0.28999999165534973,-1.0,-0.2900000214576721,0.8700000047683716,-1.0,0.28999996185302734,0.28999999165534973,-1.0,-0.2900000214576721,0.28999996185302734,-1.0,0.8700000047683716,0.28999996185302734,1.0,0.2900000214576721,0.28999996185302734,1.0,0.2900000214576721,-0.2900000214576721,1.0,0.8700000047683716,0.28999996185302734,1.0,0.2900000214576721,-0.2900000214576721,1.0,0.8700000047683716,-0.2900000214576721,1.0,0.2900000214576721,0.28999996185302734,1.0,-0.28999996185302734,0.28999999165534973,1.0,-0.28999996185302734,-0.28999999165534973,1.0,0.2900000214576721,0.28999996185302734,1.0,-0.28999996185302734,-0.28999999165534973,1.0,0.2900000214576721,-0.2900000214576721,1.0,0.8700000047683716,0.8700000047683716,1.0,0.2900000214576721,0.8700000047683716,1.0,0.2900000214576721,0.28999996185302734,1.0,0.8700000047683716,0.8700000047683716,1.0,0.2900000214576721,0.28999996185302734,1.0,0.8700000047683716,0.28999996185302734,1.0,0.2900000214576721,0.8700000047683716,1.0,-0.28999996185302734,0.8700000047683716,1.0,-0.28999996185302734,0.28999999165534973,1.0,0.2900000214576721,0.8700000047683716,1.0,-0.28999996185302734,0.28999999165534973,1.0,0.2900000214576721,0.28999996185302734,1.0,-0.8700000047683716,1.0,0.28999996185302734,-0.8700000047683716,1.0,0.8700000047683716,-0.2900000214576721,1.0,0.8700000047683716,-0.8700000047683716,1.0,0.28999996185302734,-0.2900000214576721,1.0,0.8700000047683716,-0.28999999165534973,1.0,0.28999996185302734,-0.28999999165534973,1.0,0.28999996185302734,-0.2900000214576721,1.0,0.8700000047683716,0.28999996185302734,1.0,0.8700000047683716,-0.28999999165534973,1.0,0.28999996185302734,0.28999996185302734,1.0,0.8700000047683716,0.28999999165534973,1.0,0.28999996185302734,-0.8700000047683716,0.9619238972663879,0.9619238972663879,-0.2900000214576721,0.9619238972663879,0.9619238972663879,-0.2900000214576721,1.0,0.8700000047683716,-0.8700000047683716,0.9619238972663879,0.9619238972663879,-0.2900000214576721,1.0,0.8700000047683716,-0.8700000047683716,1.0,0.8700000047683716,-0.2900000214576721,0.9619238972663879,0.9619238972663879,0.28999996185302734,0.9619238972663879,0.9619238972663879,0.28999996185302734,1.0,0.8700000047683716,-0.2900000214576721,0.9619238972663879,0.9619238972663879,0.28999996185302734,1.0,0.8700000047683716,-0.2900000214576721,1.0,0.8700000047683716,-0.8700000047683716,0.8700000047683716,1.0,-0.28999996185302734,0.8700000047683716,1.0,-0.2900000214576721,0.9619238972663879,0.9619238972663879,-0.8700000047683716,0.8700000047683716,1.0,-0.2900000214576721,0.9619238972663879,0.9619238972663879,-0.8700000047683716,0.9619238972663879,0.9619238972663879,-0.28999996185302734,0.8700000047683716,1.0,0.2900000214576721,0.8700000047683716,1.0,0.28999996185302734,0.9619238972663879,0.9619238972663879,-0.28999996185302734,0.8700000047683716,1.0,0.28999996185302734,0.9619238972663879,0.9619238972663879,-0.2900000214576721,0.9619238972663879,0.9619238972663879,-0.8700000047683716,-0.9619238972663879,-0.9619238972663879,-0.2900000214576721,-0.9619238972663879,-0.9619238972663879,-0.2900000214576721,-1.0,-0.8700000047683716,-0.8700000047683716,-0.9619238972663879,-0.9619238972663879,-0.2900000214576721,-1.0,-0.8700000047683716,-0.8700000047683716,-1.0,-0.8700000047683716,-0.2900000214576721,-0.9619238972663879,-0.9619238972663879,0.28999996185302734,-0.9619238972663879,-0.9619238972663879,0.28999996185302734,-1.0,-0.8700000047683716,-0.2900000214576721,-0.9619238972663879,-0.9619238972663879,0.28999996185302734,-1.0,-0.8700000047683716,-0.2900000214576721,-1.0,-0.8700000047683716,-0.8700000047683716,-0.8700000047683716,-1.0,-0.28999996185302734,-0.8700000047683716,-1.0,-0.2900000214576721,-0.9619238972663879,-0.9619238972663879,-0.8700000047683716,-0.8700000047683716,-1.0,-0.2900000214576721,-0.9619238972663879,-0.9619238972663879,-0.8700000047683716,-0.9619238972663879,-0.9619238972663879,-0.28999996185302734,-0.8700000047683716,-1.0,0.2900000214576721,-0.8700000047683716,-1.0,0.28999996185302734,-0.9619238972663879,-0.9619238972663879,-0.28999996185302734,-0.8700000047683716,-1.0,0.28999996185302734,-0.9619238972663879,-0.9619238972663879,-0.2900000214576721,-0.9619238972663879,-0.9619238972663879,0.8700000047683716,-0.9619238972663879,0.9619238972663879,0.2900000214576721,-0.9619238972663879,0.9619238972663879,0.2900000214576721,-1.0,0.8700000047683716,0.8700000047683716,-0.9619238972663879,0.9619238972663879,0.2900000214576721,-1.0,0.8700000047683716,0.8700000047683716,-1.0,0.8700000047683716,0.2900000214576721,-0.9619238972663879,0.9619238972663879,-0.28999996185302734,-0.9619238972663879,0.9619238972663879,-0.28999996185302734,-1.0,0.8700000047683716,0.2900000214576721,-0.9619238972663879,0.9619238972663879,-0.28999996185302734,-1.0,0.8700000047683716,0.2900000214576721,-1.0,0.8700000047683716,0.8700000047683716,-0.8700000047683716,1.0,0.28999996185302734,-0.8700000047683716,1.0,0.2900000214576721,-0.9619238972663879,0.9619238972663879,0.8700000047683716,-0.8700000047683716,1.0,0.2900000214576721,-0.9619238972663879,0.9619238972663879,0.8700000047683716,-0.9619238972663879,0.9619238972663879,0.28999996185302734,-0.8700000047683716,1.0,-0.2900000214576721,-0.8700000047683716,1.0,-0.28999996185302734,-0.9619238972663879,0.9619238972663879,0.28999996185302734,-0.8700000047683716,1.0,-0.28999996185302734,-0.9619238972663879,0.9619238972663879,0.2900000214576721,-0.9619238972663879,0.9619238972663879,0.8700000047683716,0.9619238972663879,-0.9619238972663879,0.2900000214576721,0.9619238972663879,-0.9619238972663879,0.2900000214576721,1.0,-0.8700000047683716,0.8700000047683716,0.9619238972663879,-0.9619238972663879,0.2900000214576721,1.0,-0.8700000047683716,0.8700000047683716,1.0,-0.8700000047683716,0.2900000214576721,0.9619238972663879,-0.9619238972663879,-0.28999996185302734,0.9619238972663879,-0.9619238972663879,-0.28999996185302734,1.0,-0.8700000047683716,0.2900000214576721,0.9619238972663879,-0.9619238972663879,-0.28999996185302734,1.0,-0.8700000047683716,0.2900000214576721,1.0,-0.8700000047683716,0.8700000047683716,0.8700000047683716,-1.0,0.28999996185302734,0.8700000047683716,-1.0,0.2900000214576721,0.9619238972663879,-0.9619238972663879,0.8700000047683716,0.8700000047683716,-1.0,0.2900000214576721,0.9619238972663879,-0.9619238972663879,0.8700000047683716,0.9619238972663879,-0.9619238972663879,0.28999996185302734,0.8700000047683716,-1.0,-0.2900000214576721,0.8700000047683716,-1.0,-0.28999996185302734,0.9619238972663879,-0.9619238972663879,0.28999996185302734,0.8700000047683716,-1.0,-0.28999996185302734,0.9619238972663879,-0.9619238972663879,0.2900000214576721,0.9619238972663879,-0.9619238972663879,0.8700000047683716,-0.2900000214576721,1.0,0.2900000214576721,-0.2900000214576721,1.0,0.28999996185302734,-0.8700000047683716,1.0,0.8700000047683716,-0.2900000214576721,1.0,0.28999996185302734,-0.8700000047683716,1.0,0.8700000047683716,-0.8700000047683716,1.0,0.2900000214576721,-0.2900000214576721,1.0,-0.28999996185302734,-0.28999999165534973,1.0,-0.2900000214576721,-0.8700000047683716,1.0,0.2900000214576721,-0.2900000214576721,1.0,-0.2900000214576721,-0.8700000047683716,1.0,0.28999996185302734,-0.8700000047683716,1.0,0.8700000047683716,-1.0,0.28999996185302734,0.8700000047683716,-1.0,0.8700000047683716,0.2900000214576721,-1.0,0.8700000047683716,0.8700000047683716,-1.0,0.28999996185302734,0.2900000214576721,-1.0,0.8700000047683716,0.28999999165534973,-1.0,0.28999996185302734,0.28999999165534973,-1.0,0.28999996185302734,0.2900000214576721,-1.0,0.8700000047683716,-0.28999996185302734,-1.0,0.8700000047683716,0.28999999165534973,-1.0,0.28999996185302734,-0.28999996185302734,-1.0,0.8700000047683716,-0.28999999165534973,-1.0,0.28999996185302734,-0.8700000047683716,-0.2900000214576721,-1.0,-0.2900000214576721,-0.2900000214576721,-1.0,-0.28999996185302734,-0.8700000047683716,-1.0,-0.8700000047683716,-0.2900000214576721,-1.0,-0.28999996185302734,-0.8700000047683716,-1.0,-0.8700000047683716,-0.8700000047683716,-1.0,-0.2900000214576721,-0.2900000214576721,-1.0,0.28999996185302734,-0.28999999165534973,-1.0,0.2900000214576721,-0.8700000047683716,-1.0,-0.2900000214576721,-0.2900000214576721,-1.0,0.2900000214576721,-0.8700000047683716,-1.0,-0.28999996185302734,-0.8700000047683716,-1.0,0.28999996185302734,-1.0,-0.8700000047683716,0.28999996185302734,-1.0,-0.2900000214576721,-0.2900000214576721,-1.0,-0.2900000214576721,0.28999996185302734,-1.0,-0.8700000047683716,-0.2900000214576721,-1.0,-0.2900000214576721,-0.2900000214576721,-1.0,-0.8700000047683716,0.28999996185302734,-1.0,-0.2900000214576721,0.28999999165534973,-1.0,0.28999996185302734,-0.28999999165534973,-1.0,0.28999996185302734,0.28999996185302734,-1.0,-0.2900000214576721,-0.28999999165534973,-1.0,0.28999996185302734,-0.2900000214576721,-1.0,-0.2900000214576721,0.8700000047683716,-1.0,-0.8700000047683716,0.8700000047683716,-1.0,-0.2900000214576721,0.28999996185302734,-1.0,-0.2900000214576721,0.8700000047683716,-1.0,-0.8700000047683716,0.28999996185302734,-1.0,-0.2900000214576721,0.28999996185302734,-1.0,-0.8700000047683716,0.8700000047683716,-1.0,-0.2900000214576721,0.8700000047683716,-1.0,0.28999996185302734,0.28999999165534973,-1.0,0.28999996185302734,0.8700000047683716,-1.0,-0.2900000214576721,0.28999999165534973,-1.0,0.28999996185302734,0.28999996185302734,-1.0,-0.2900000214576721,-0.28999996185302734,1.0,-0.8700000047683716,-0.28999996185302734,1.0,-0.2900000214576721,0.2900000214576721,1.0,-0.2900000214576721,-0.28999996185302734,1.0,-0.8700000047683716,0.2900000214576721,1.0,-0.2900000214576721,0.2900000214576721,1.0,-0.8700000047683716,-0.28999996185302734,1.0,-0.2900000214576721,-0.28999999165534973,1.0,0.28999996185302734,0.28999999165534973,1.0,0.28999996185302734,-0.28999996185302734,1.0,-0.2900000214576721,0.28999999165534973,1.0,0.28999996185302734,0.2900000214576721,1.0,-0.2900000214576721,-0.8700000047683716,1.0,-0.8700000047683716,-0.8700000047683716,1.0,-0.2900000214576721,-0.28999996185302734,1.0,-0.2900000214576721,-0.8700000047683716,1.0,-0.8700000047683716,-0.28999996185302734,1.0,-0.2900000214576721,-0.28999996185302734,1.0,-0.8700000047683716,-0.8700000047683716,1.0,-0.2900000214576721,-0.8700000047683716,1.0,0.28999996185302734,-0.28999999165534973,1.0,0.28999996185302734,-0.8700000047683716,1.0,-0.2900000214576721,-0.28999999165534973,1.0,0.28999996185302734,-0.28999996185302734,1.0,-0.2900000214576721,-1.0,-0.28999996185302734,-0.8700000047683716,-1.0,-0.28999996185302734,-0.2900000214576721,-1.0,0.2900000214576721,-0.2900000214576721,-1.0,-0.28999996185302734,-0.8700000047683716,-1.0,0.2900000214576721,-0.2900000214576721,-1.0,0.2900000214576721,-0.8700000047683716,-1.0,-0.28999996185302734,-0.2900000214576721,-1.0,-0.28999999165534973,0.28999996185302734,-1.0,0.28999999165534973,0.28999996185302734,-1.0,-0.28999996185302734,-0.2900000214576721,-1.0,0.28999999165534973,0.28999996185302734,-1.0,0.2900000214576721,-0.2900000214576721,-1.0,-0.8700000047683716,-0.8700000047683716,-1.0,-0.8700000047683716,-0.2900000214576721,-1.0,-0.28999996185302734,-0.2900000214576721,-1.0,-0.8700000047683716,-0.8700000047683716,-1.0,-0.28999996185302734,-0.2900000214576721,-1.0,-0.28999996185302734,-0.8700000047683716,-1.0,-0.8700000047683716,-0.2900000214576721,-1.0,-0.8700000047683716,0.28999996185302734,-1.0,-0.28999999165534973,0.28999996185302734,-1.0,-0.8700000047683716,-0.2900000214576721,-1.0,-0.28999999165534973,0.28999996185302734,-1.0,-0.28999996185302734,-0.2900000214576721,1.0,0.28999996185302734,-0.8700000047683716,1.0,0.28999996185302734,-0.2900000214576721,1.0,-0.2900000214576721,-0.2900000214576721,1.0,0.28999996185302734,-0.8700000047683716,1.0,-0.2900000214576721,-0.2900000214576721,1.0,-0.2900000214576721,-0.8700000047683716,1.0,0.28999996185302734,-0.2900000214576721,1.0,0.28999999165534973,0.28999996185302734,1.0,-0.28999999165534973,0.28999996185302734,1.0,0.28999996185302734,-0.2900000214576721,1.0,-0.28999999165534973,0.28999996185302734,1.0,-0.2900000214576721,-0.2900000214576721,1.0,0.8700000047683716,-0.8700000047683716,1.0,0.8700000047683716,-0.2900000214576721,1.0,0.28999996185302734,-0.2900000214576721,1.0,0.8700000047683716,-0.8700000047683716,1.0,0.28999996185302734,-0.2900000214576721,1.0,0.28999996185302734,-0.8700000047683716,1.0,0.8700000047683716,-0.2900000214576721,1.0,0.8700000047683716,0.28999996185302734,1.0,0.28999999165534973,0.28999996185302734,1.0,0.8700000047683716,-0.2900000214576721,1.0,0.28999999165534973,0.28999996185302734,1.0,0.28999996185302734,-0.2900000214576721,0.2900000214576721,1.0,-0.8700000047683716,0.2900000214576721,1.0,-0.2900000214576721,0.8700000047683716,1.0,-0.28999996185302734,0.2900000214576721,1.0,-0.8700000047683716,0.8700000047683716,1.0,-0.28999996185302734,0.8700000047683716,1.0,-0.8700000047683716,0.2900000214576721,1.0,-0.2900000214576721,0.28999999165534973,1.0,0.28999996185302734,0.8700000047683716,1.0,0.2900000214576721,0.2900000214576721,1.0,-0.2900000214576721,0.8700000047683716,1.0,0.2900000214576721,0.8700000047683716,1.0,-0.28999996185302734,-0.9619238972663879,0.9619238972663879,0.8700000047683716,-0.9619238972663879,0.9619238972663879,0.2900000214576721,-1.0,0.8700000047683716,0.2900000214576721,-0.9619238972663879,0.9619238972663879,0.8700000047683716,-1.0,0.8700000047683716,0.2900000214576721,-1.0,0.8700000047683716,0.8700000047683716,-0.9619238972663879,0.9619238972663879,0.2900000214576721,-0.9619238972663879,0.9619238972663879,-0.28999996185302734,-1.0,0.8700000047683716,-0.28999996185302734,-0.9619238972663879,0.9619238972663879,0.2900000214576721,-1.0,0.8700000047683716,-0.28999996185302734,-1.0,0.8700000047683716,0.2900000214576721,-0.8700000047683716,1.0,0.8700000047683716,-0.8700000047683716,1.0,0.28999996185302734,-0.9619238972663879,0.9619238972663879,0.2900000214576721,-0.8700000047683716,1.0,0.8700000047683716,-0.9619238972663879,0.9619238972663879,0.2900000214576721,-0.9619238972663879,0.9619238972663879,0.8700000047683716,-0.8700000047683716,1.0,0.28999996185302734,-0.8700000047683716,1.0,-0.2900000214576721,-0.9619238972663879,0.9619238972663879,-0.28999996185302734,-0.8700000047683716,1.0,0.28999996185302734,-0.9619238972663879,0.9619238972663879,-0.28999996185302734,-0.9619238972663879,0.9619238972663879,0.2900000214576721,0.9619238972663879,-0.9619238972663879,0.8700000047683716,0.9619238972663879,-0.9619238972663879,0.2900000214576721,1.0,-0.8700000047683716,0.2900000214576721,0.9619238972663879,-0.9619238972663879,0.8700000047683716,1.0,-0.8700000047683716,0.2900000214576721,1.0,-0.8700000047683716,0.8700000047683716,0.9619238972663879,-0.9619238972663879,0.2900000214576721,0.9619238972663879,-0.9619238972663879,-0.28999996185302734,1.0,-0.8700000047683716,-0.28999996185302734,0.9619238972663879,-0.9619238972663879,0.2900000214576721,1.0,-0.8700000047683716,-0.28999996185302734,1.0,-0.8700000047683716,0.2900000214576721,0.8700000047683716,-1.0,0.8700000047683716,0.8700000047683716,-1.0,0.28999996185302734,0.9619238972663879,-0.9619238972663879,0.2900000214576721,0.8700000047683716,-1.0,0.8700000047683716,0.9619238972663879,-0.9619238972663879,0.2900000214576721,0.9619238972663879,-0.9619238972663879,0.8700000047683716,0.8700000047683716,-1.0,0.28999996185302734,0.8700000047683716,-1.0,-0.2900000214576721,0.9619238972663879,-0.9619238972663879,-0.28999996185302734,0.8700000047683716,-1.0,0.28999996185302734,0.9619238972663879,-0.9619238972663879,-0.28999996185302734,0.9619238972663879,-0.9619238972663879,0.2900000214576721,-0.9619238972663879,-0.9619238972663879,-0.8700000047683716,-0.9619238972663879,-0.9619238972663879,-0.2900000214576721,-1.0,-0.8700000047683716,-0.2900000214576721,-0.9619238972663879,-0.9619238972663879,-0.8700000047683716,-1.0,-0.8700000047683716,-0.2900000214576721,-1.0,-0.8700000047683716,-0.8700000047683716,-0.9619238972663879,-0.9619238972663879,-0.2900000214576721,-0.9619238972663879,-0.9619238972663879,0.28999996185302734,-1.0,-0.8700000047683716,0.28999996185302734,-0.9619238972663879,-0.9619238972663879,-0.2900000214576721,-1.0,-0.8700000047683716,0.28999996185302734,-1.0,-0.8700000047683716,-0.2900000214576721,-0.8700000047683716,-1.0,-0.8700000047683716,-0.8700000047683716,-1.0,-0.28999996185302734,-0.9619238972663879,-0.9619238972663879,-0.2900000214576721,-0.8700000047683716,-1.0,-0.8700000047683716,-0.9619238972663879,-0.9619238972663879,-0.2900000214576721,-0.9619238972663879,-0.9619238972663879,-0.8700000047683716,-0.8700000047683716,-1.0,-0.28999996185302734,-0.8700000047683716,-1.0,0.2900000214576721,-0.9619238972663879,-0.9619238972663879,0.28999996185302734,-0.8700000047683716,-1.0,-0.28999996185302734,-0.9619238972663879,-0.9619238972663879,0.28999996185302734,-0.9619238972663879,-0.9619238972663879,-0.2900000214576721,0.9619238972663879,0.9619238972663879,0.8700000047683716,0.9619238972663879,0.9619238972663879,0.2900000214576721,0.8700000047683716,1.0,0.2900000214576721,0.9619238972663879,0.9619238972663879,0.8700000047683716,0.8700000047683716,1.0,0.2900000214576721,0.8700000047683716,1.0,0.8700000047683716,0.9619238972663879,0.9619238972663879,0.2900000214576721,0.9619238972663879,0.9619238972663879,-0.28999996185302734,0.8700000047683716,1.0,-0.28999996185302734,0.9619238972663879,0.9619238972663879,0.2900000214576721,0.8700000047683716,1.0,-0.28999996185302734,0.8700000047683716,1.0,0.2900000214576721,1.0,0.8700000047683716,0.8700000047683716,1.0,0.8700000047683716,0.28999996185302734,0.9619238972663879,0.9619238972663879,0.2900000214576721,1.0,0.8700000047683716,0.8700000047683716,0.9619238972663879,0.9619238972663879,0.2900000214576721,0.9619238972663879,0.9619238972663879,0.8700000047683716,1.0,0.8700000047683716,0.28999996185302734,1.0,0.8700000047683716,-0.2900000214576721,0.9619238972663879,0.9619238972663879,-0.28999996185302734,1.0,0.8700000047683716,0.28999996185302734,0.9619238972663879,0.9619238972663879,-0.28999996185302734,0.9619238972663879,0.9619238972663879,0.2900000214576721,1.0,-0.2900000214576721,-0.8700000047683716,1.0,-0.2900000214576721,-0.2900000214576721,1.0,-0.8700000047683716,-0.28999996185302734,1.0,-0.2900000214576721,-0.8700000047683716,1.0,-0.8700000047683716,-0.28999996185302734,1.0,-0.8700000047683716,-0.8700000047683716,1.0,-0.2900000214576721,-0.2900000214576721,1.0,-0.28999999165534973,0.28999996185302734,1.0,-0.8700000047683716,0.2900000214576721,1.0,-0.2900000214576721,-0.2900000214576721,1.0,-0.8700000047683716,0.2900000214576721,1.0,-0.8700000047683716,-0.28999996185302734,-0.2900000214576721,-1.0,-0.8700000047683716,-0.2900000214576721,-1.0,-0.2900000214576721,-0.8700000047683716,-1.0,-0.28999996185302734,-0.2900000214576721,-1.0,-0.8700000047683716,-0.8700000047683716,-1.0,-0.28999996185302734,-0.8700000047683716,-1.0,-0.8700000047683716,-0.2900000214576721,-1.0,-0.2900000214576721,-0.28999999165534973,-1.0,0.28999996185302734,-0.8700000047683716,-1.0,0.2900000214576721,-0.2900000214576721,-1.0,-0.2900000214576721,-0.8700000047683716,-1.0,0.2900000214576721,-0.8700000047683716,-1.0,-0.28999996185302734,-1.0,0.2900000214576721,-0.8700000047683716,-1.0,0.2900000214576721,-0.2900000214576721,-1.0,0.8700000047683716,-0.28999996185302734,-1.0,0.2900000214576721,-0.8700000047683716,-1.0,0.8700000047683716,-0.28999996185302734,-1.0,0.8700000047683716,-0.8700000047683716,-1.0,0.2900000214576721,-0.2900000214576721,-1.0,0.28999999165534973,0.28999996185302734,-1.0,0.8700000047683716,0.2900000214576721,-1.0,0.2900000214576721,-0.2900000214576721,-1.0,0.8700000047683716,0.2900000214576721,-1.0,0.8700000047683716,-0.28999996185302734]);+++ geometry.setAttribute( 'position', new BufferAttribute( box_vertice_data, 3 ) );+ geometry.getAttribute("position").needsUpdate = true;+ geometry.computeVertexNormals(); // required after setting new position attributes+ return geometry;+}diff --git a/src/lib/geometry/PlaneGeometry.js b/src/lib/geometry/PlaneGeometry.jsnew file mode 100644index 0000000..cf39b23--- /dev/null+++ b/src/lib/geometry/PlaneGeometry.js@@ -0,0 +1,16 @@+export function create_plane_geometry()+{+ const geometry = new BufferGeometry();+ const plane_vertice_data = new Float32Array( [+ -1.0, -1.0, 1.0, // v0+ 1.0, -1.0, 1.0, // v1+ 1.0, 1.0, 1.0, // v2++ 1.0, 1.0, 1.0, // v3+ -1.0, 1.0, 1.0, // v4+ -1.0, -1.0, 1.0 // v5+ ]);++ geometry.setAttribute( 'position', new BufferAttribute( plane_vertice_data, 3 ) );+ return geometry;+}\ No newline at end of filediff --git a/src/lib/math/QuaternionUtils.ts b/src/lib/math/QuaternionUtils.tsnew file mode 100644index 0000000..16c0536--- /dev/null+++ b/src/lib/math/QuaternionUtils.ts@@ -0,0 +1,145 @@+import { quat as Quaternion } from 'gl-matrix'++/* Three.js doesn't have many Quaternion functions for calculations, so this is a collection of useful functions+ will fill in that void */+class QuatUtil+{++ /** Used to get data from a flat buffer */+ static fromBuf( out: Quaternion, ary : Array<number> | Float32Array, idx: number ) : Quaternion+ {+ out[ 0 ] = ary[ idx ];+ out[ 1 ] = ary[ idx + 1 ];+ out[ 2 ] = ary[ idx + 2 ];+ out[ 3 ] = ary[ idx + 3 ];+ return out;+ }++ /** Put data into a flat buffer */+ static toBuf( q: Quaternion, ary : Array<number> | Float32Array, idx: number ) : QuatUtil+ {+ ary[ idx ] = q[ 0 ];+ ary[ idx + 1 ] = q[ 1 ];+ ary[ idx + 2 ] = q[ 2 ];+ ary[ idx + 3 ] = q[ 3 ];+ return this;+ }+++ static lenSqr( a: Quaternion, b: Quaternion ): number+ {+ return (a[ 0 ]-b[ 0 ]) ** 2 ++ (a[ 1 ]-b[ 1 ]) ** 2 ++ (a[ 2 ]-b[ 2 ]) ** 2 ++ (a[ 3 ]-b[ 3 ]) ** 2 ;+ }++ static isZero( q: Quaternion ): boolean+ {+ return ( q[0] == 0 && q[1] == 0 && q[2] == 0 && q[3] == 0 );+ }++ static negate( out: Quaternion, q?: Quaternion ): Quaternion+ {+ if( !q ) q = out;+ out[ 0 ] = -q[ 0 ];+ out[ 1 ] = -q[ 1 ];+ out[ 2 ] = -q[ 2 ];+ out[ 3 ] = -q[ 3 ];+ return out;+ }++ /** Checks if on opposite hemisphere, if so, negate change Quaternion */+ static dotNegate( out: Quaternion, chg: Quaternion, chk: Quaternion ): Quaternion+ {+ if( Quaternion.dot( chg, chk ) < 0 ) this.negate( out, chg );+ return out;+ }++ /** PreMultiple an Axis Angle to this quaternions */+ static pmulAxisAngle( out: Quaternion, axis: Quaternion, angle: number, q: Quaternion ) : Quaternion+ {+ const half = angle * .5,+ s = Math.sin( half ),+ ax = axis[0] * s, // A Quat based on Axis Angle+ ay = axis[1] * s,+ az = axis[2] * s,+ aw = Math.cos( half ),++ bx = q[0], // B of mul+ by = q[1],+ bz = q[2],+ bw = q[3];+ // Quat.mul( a, b );+ out[ 0 ] = ax * bw + aw * bx + ay * bz - az * by;+ out[ 1 ] = ay * bw + aw * by + az * bx - ax * bz;+ out[ 2 ] = az * bw + aw * bz + ax * by - ay * bx;+ out[ 3 ] = aw * bw - ax * bx - ay * by - az * bz;+ return out;+ }++ /** Inverts the quaternion passed in, then pre multiplies to this quaternion. */+ static pmulInvert( out: Quaternion, q: Quaternion, qinv: Quaternion ): Quaternion+ {+ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ // q.invert()+ let ax = qinv[ 0 ],+ ay = qinv[ 1 ],+ az = qinv[ 2 ],+ aw = qinv[ 3 ];++ const dot = ax*ax + ay*ay + az*az + aw*aw;++ if( dot == 0 ){+ ax = ay = az = aw = 0;+ }else{+ const dot_inv = 1.0 / dot;+ ax = -ax * dot_inv;+ ay = -ay * dot_inv;+ az = -az * dot_inv;+ aw = aw * dot_inv;+ }++ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ // Quaternion.mul( a, b );+ const bx = q[ 0 ],+ by = q[ 1 ],+ bz = q[ 2 ],+ bw = q[ 3 ];+ out[ 0 ] = ax * bw + aw * bx + ay * bz - az * by;+ out[ 1 ] = ay * bw + aw * by + az * bx - ax * bz;+ out[ 2 ] = az * bw + aw * bz + ax * by - ay * bx;+ out[ 3 ] = aw * bw - ax * bx - ay * by - az * bz;++ return out;+ }++ static nblend( out: Quaternion, a: Quaternion, b: Quaternion, t: number ) : Quaternion+ {+ // https://physicsforgames.blogspot.com/2010/02/quaternions.html+ const a_x = a[ 0 ], // Quaternion From+ a_y = a[ 1 ],+ a_z = a[ 2 ],+ a_w = a[ 3 ],+ b_x = b[ 0 ], // Quaternion To+ b_y = b[ 1 ],+ b_z = b[ 2 ],+ b_w = b[ +3 ],+ dot = a_x*b_x + a_y*b_y + a_z*b_z + a_w*b_w,+ ti = 1 - t;+ let s = 1;++ // if Rotations with a dot less then 0 causes artifacts when lerping,+ // Can fix this by switching the sign of the To Quaternion.+ if( dot < 0 ) s = -1;++ out[ 0 ] = ti * a_x + t * b_x * s;+ out[ 1 ] = ti * a_y + t * b_y * s;+ out[ 2 ] = ti * a_z + t * b_z * s;+ out[ 3 ] = ti * a_w + t * b_w * s;++ return Quaternion.normalize( out, out );+ }+}++export default QuatUtil;\ No newline at end of filediff --git a/src/lib/math/Vector3Utils.ts b/src/lib/math/Vector3Utils.tsnew file mode 100644index 0000000..8c077de--- /dev/null+++ b/src/lib/math/Vector3Utils.ts@@ -0,0 +1,78 @@+import type { vec3 as Vector3 } from 'gl-matrix'++export type ThreeJSVector3 = { x: number, y: number, z: number }; // Handle Data form ThreeJS++class Vector3Utils{++ static len( a: Vector3, b: Vector3 ): number+ {+ return Math.sqrt(+ (a[ 0 ]-b[ 0 ]) ** 2 ++ (a[ 1 ]-b[ 1 ]) ** 2 ++ (a[ 2 ]-b[ 2 ]) ** 2+ );+ }++ static lenSqr( a: Vector3, b: Vector3 ): number+ {+ return (a[ 0 ]-b[ 0 ]) ** 2 ++ (a[ 1 ]-b[ 1 ]) ** 2 ++ (a[ 2 ]-b[ 2 ]) ** 2 ;+ }++ static isZero( v: Vector3 ): boolean+ {+ return ( v[0] == 0 && v[1] == 0 && v[2] == 0 );+ }++ /** When values are very small, like less then 0.000001, just make it zero */+ static nearZero( out: Vector3, v: Vector3 ) : Vector3+ {+ out[ 0 ] = ( Math.abs( v[ 0 ] ) <= 1e-6 )? 0 : v[ 0 ];+ out[ 1 ] = ( Math.abs( v[ 1 ] ) <= 1e-6 )? 0 : v[ 1 ];+ out[ 2 ] = ( Math.abs( v[ 2 ] ) <= 1e-6 )? 0 : v[ 2 ];+ return out;+ }++ //#region LOADING / CONVERSION+ /** Used to get data from a flat buffer */+ static fromBuf( out: Vector3, ary : Array<number> | Float32Array, idx: number ) : Vector3+ {+ out[ 0 ] = ary[ idx ];+ out[ 1 ] = ary[ idx + 1 ];+ out[ 2 ] = ary[ idx + 2 ];+ return out;+ }++ /** Put data into a flat buffer */+ static toBuf( v: Vector3, ary : Array<number> | Float32Array, idx: number ) : Vector3Utils+ {+ ary[ idx ] = v[ 0 ];+ ary[ idx + 1 ] = v[ 1 ];+ ary[ idx + 2 ] = v[ 2 ];+ return this;+ }++ static toStruct( v: Vector3, o ?: ThreeJSVector3 ): ThreeJSVector3{+ o ??= { x:0, y:0, z:0 };+ o.x = v[ 0 ];+ o.y = v[ 1 ];+ o.z = v[ 2 ];+ return o;+ }++ static fromStruct( v: Vector3, o: ThreeJSVector3 ): Vector3{+ v[ 0 ] = o.x;+ v[ 1 ] = o.y;+ v[ 2 ] = o.z;+ return v;+ }++ static toArray( v: Vector3 ): number[]+ {+ return [ v[0], v[1], v[2] ];+ }++}++export default Vector3Utils;\ No newline at end of filediff --git a/src/lib/models/BoneCalculationData.ts b/src/lib/models/BoneCalculationData.tsnew file mode 100644index 0000000..e785c66--- /dev/null+++ b/src/lib/models/BoneCalculationData.ts@@ -0,0 +1,21 @@+import { Bone } from 'three';++export default class BoneCalculationData+{+ public name: string;+ public bone_object: Bone;+ public supports_envelope_calculation: boolean;+ public has_child_bone: boolean;+ public assigned_vertices: Array<number>;+ public use_minimum_envelope_expand: boolean;++ constructor(name = '', bone , supports_envelope = false, has_child_bone = false, assigned_vertices = [], use_minimum_distance = false)+ {+ this.name = name;+ this.bone_object = bone;+ this.supports_envelope_calculation = supports_envelope;+ this.has_child_bone = has_child_bone;+ this.assigned_vertices = assigned_vertices;+ this.use_minimum_envelope_expand = use_minimum_distance;+ }+}\ No newline at end of filediff --git a/src/lib/models/BoneTransformState.ts b/src/lib/models/BoneTransformState.tsnew file mode 100644index 0000000..8f74d0c--- /dev/null+++ b/src/lib/models/BoneTransformState.ts@@ -0,0 +1,17 @@+import { Vector3 } from 'three';++export default class BoneTransformState+{+ public name: string;+ public position: Vector3;+ public rotation: Vector3; // Not sure if this is right+ public scale: Vector3;++ constructor(name = '', position, rotation, scale)+ {+ this.name = name;+ this.position = position;+ this.rotation = rotation;+ this.scale = scale;+ }+}\ No newline at end of filediff --git a/src/lib/processes/StepAnimationsListing.js b/src/lib/processes/StepAnimationsListing.jsnew file mode 100644index 0000000..31564f5--- /dev/null+++ b/src/lib/processes/StepAnimationsListing.js@@ -0,0 +1,137 @@+import { UI } from '../UI.js';++import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';++import { AnimationClip, AnimationMixer } from 'three';+import { SkeletonType } from '../enums/SkeletonType.js';++// Note: EventTarget is a built-ininterface and do not need to import it+export class StepAnimationsListing extends EventTarget+{+ ui = null;+ animation_clips_loaded = []+ animation_loader = null+ animation_mixer = null+ skinned_meshes_to_animate = []++ constructor()+ {+ super();+ this.ui = new UI();+ }++ begin()+ {+ this.ui.dom_current_step_index.innerHTML = '4'+ this.ui.dom_current_step_element.innerHTML = 'Test animations'+ this.ui.dom_skinned_mesh_tools.style.display = 'flex';+ this.ui.dom_skinned_mesh_animation_tools.style.display = 'flex';++ this.addEventListeners()+ }++ addEventListeners()+ {+ // event listener for animation clip list with changing the current animation+ this.ui.dom_animation_clip_list.addEventListener('click', (event) => {+ if (event.target.tagName === 'BUTTON')+ {+ let animation_index = event.target.getAttribute('data-index');+ this._play_animation(animation_index);+ }+ });+ }++ _play_animation(index = 0)+ {+ this.animation_mixer.stopAllAction();++ this.skinned_meshes_to_animate.forEach((skinned_mesh) => {+ let anim_clip = this.animation_mixer.clipAction(this.animation_clips_loaded[index], skinned_mesh);+ anim_clip.play();+ });+ }++ removeEventListeners()+ {+ this.ui.dom_animation_clip_list.removeEventListener('click', () => {});+ }+++ mixer()+ {+ return this.animation_mixer+ }++ animation_clips()+ {+ return this.animation_clips_loaded+ }++ load_animation_clips(animation_clips)+ {+ this.animation_clips_loaded = this._remove_position_keyframes_from_animations(animation_clips)+ }++ _remove_position_keyframes_from_animations(animation_clip_list)+ {+ let animation_clips = this._deep_clone_animation_clips(animation_clip_list)++ let filtered_tracks = animation_clips.map((animation_clip) => {+ const filteredTracks = animation_clip.tracks.filter((track) => {+ return track.name.indexOf('position') === -1;+ });+ return new AnimationClip(animation_clip.name, animation_clip.duration, filteredTracks);+ });++ return filtered_tracks+ }++ _deep_clone_animation_clips(animation_clips)+ {+ return animation_clips.map(clip => {+ let tracks = clip.tracks.map(track => track.clone());+ return new AnimationClip(clip.name, clip.duration, tracks);+ });+ }++ load_and_apply_default_animation_to_skinned_mesh(final_skinned_meshes, skeleton_type)+ {+ this.animation_loader = new GLTFLoader();+ this.skinned_meshes_to_animate = final_skinned_meshes++ let animations_to_load_filepath = null+ switch(skeleton_type)+ {+ case SkeletonType.BipedalSimple:+ animations_to_load_filepath = 'animations/character-simple-multiple.glb'+ break;+ case SkeletonType.Quadraped:+ animations_to_load_filepath = 'animations/quad-creature-animations.glb'+ break;+ case SkeletonType.BipedalFull:+ // TODO: This file doesn't actually exist+ console.log('NOT IMPLENTENTED YET. NEED TO MAKE ANIMATIONS FOR THIS')+ animations_to_load_filepath = 'animations/character-full-multiple.glb'+ break;+ }++ this.animation_loader.load(animations_to_load_filepath, (gltf) => {++ // remove the animation position keyframes. That will mess up the skinning+ // process since we will be offsetting and moving the bone root positions+ this.load_animation_clips(gltf.animations)++ // create user interface with all available animation clips+ this.ui.build_animation_clip_ui(this.animation_clips_loaded);++ // create an animation mixer to do the playback. play the first by by default+ this.animation_mixer = new AnimationMixer();++ this._play_animation(0);+ });+ }++++}\ No newline at end of filediff --git a/src/lib/processes/StepEditSkeleton.js b/src/lib/processes/StepEditSkeleton.jsnew file mode 100644index 0000000..643dd1d--- /dev/null+++ b/src/lib/processes/StepEditSkeleton.js@@ -0,0 +1,218 @@+import { UI } from '../UI.js';++import { Generators } from '../Generators.ts'++import { Utility } from '../Utilities.ts'++import { Vector3, Euler } from 'three';+import { SkinningFormula } from '../enums/SkinningFormula.js';++export class StepEditSkeleton extends EventTarget {++ ui = null;+ edited_armature = null;+ edited_skeleton = null;+ mirror_mode_enabled = true+ skinning_algorithm = SkinningFormula.Envelope+ show_debug = true++ constructor()+ {+ super();+ this.ui = new UI();+ }++ begin()+ {+ // show UI elemnents for editing mesh+ this.ui.dom_current_step_index.innerHTML = '3'+ this.ui.dom_current_step_element.innerHTML = 'Move Skeleton'+ this.ui.dom_transform_controls_switch.style.display = 'flex';+ this.ui.dom_skeleton_edit_tools.style.display = 'flex';+++ // get initial state for the show_debug checkbox+ this.show_debug = this.ui.dom_enable_skin_debugging.checked+ this._update_bind_button_text()+++ this.addEventListeners();+ }++ _update_bind_button_text()+ {+ if(this.show_debug)+ {+ this.ui.dom_bind_pose_button.innerHTML = 'Test Skinning'+ return+ }++ this.ui.dom_bind_pose_button.innerHTML = 'Skin Model'+ }++ show_debugging()+ {+ return this.show_debug+ }+++ set_mirror_mode_enabled(value)+ {+ this.mirror_mode_enabled = value+ }++ is_mirror_mode_enabled()+ {+ return this.mirror_mode_enabled+ }++ algorithm()+ {+ return this.skinning_algorithm+ }++ addEventListeners()+ {+ this.ui.dom_move_to_origin_button.addEventListener('click', () =>+ {+ // the base bone itself is not at the origin, but the parent is the armature object+ this.edited_skeleton.bones[0].position.set(0, 0, 0);+ this.edited_skeleton.bones[0].updateWorldMatrix(true, true); // update on renderer+ });++ this.ui.dom_scale_skeleton_button.addEventListener('click', () =>+ {+ const modify_scale = 1.0 + (this.ui.dom_scale_skeleton_input_box.value/100.0);+ Utility.scale_armature_by_scalar(this.edited_armature, modify_scale)+ this.edited_armature.updateWorldMatrix(true, true);+ });++ this.ui.dom_mirror_skeleton_checkbox.addEventListener('change', (event) => {+ // mirror skeleton movements along the X axis+ this.set_mirror_mode_enabled(event.target.checked)+ });++ this.ui.dom_skinning_algorithm_selection.addEventListener('change', (event) => {+ const selection = event.target.value;++ if(selection === 'bone-envelope')+ {+ this.skinning_algorithm = SkinningFormula.Envelope+ }+ else if(selection === 'closest-bone')+ {+ this.skinning_algorithm = SkinningFormula.Distance+ }+ else if(selection === 'closest-bone-middle')+ {+ this.skinning_algorithm = SkinningFormula.MedianDistance+ }+ });++ this.ui.dom_enable_skin_debugging.addEventListener('change', (event) => {+ this.show_debug = event.target.checked+ this._update_bind_button_text()+ });+ }++ removeEventListeners()+ {+ this.ui.dom_move_to_origin_button.removeEventListener('click', () => {});+ this.ui.dom_scale_skeleton_button.removeEventListener('click', () => {});+ this.ui.dom_mirror_skeleton_checkbox.removeEventListener('change', () => {});+ this.ui.dom_skinning_algorithm_selection.removeEventListener('change', () => {});+ this.ui.dom_enable_skin_debugging.removeEventListener('change', () => {});+ }++ set_armature(armature)+ {+ if(this.edited_armature !== null)+ {+ return this.edited_armature+ }++ this.edited_armature = armature.clone();++ this._create_skeleton()+ }++ _create_skeleton()+ {+ // create skeleton and helper to visualize+ this.edited_skeleton = Generators.create_skeleton(this.edited_armature.children[0]);+ this.edited_skeleton.name = 'Editing Skeleton';++ // update the world matrix for the skeleton+ // without this the skeleton helper won't appear when the bones are first loaded+ this.edited_skeleton.bones[0].updateWorldMatrix( true, true );++ return this.edited_skeleton+ }++ armature()+ {+ return this.edited_armature+ }++ skeleton()+ {+ return this.edited_skeleton+ }++ apply_mirror_mode(selected_bone, transform_type)+ {+ // if we are on the positive side mirror mode is enabled+ // we need to change the position of the bone on the other side of the mirror++ // first step is to find the base bone name+ // strip out the left/right and _L/_R from the name+ // mixamo is a common skeleton that prefixes everything with mixamorig_, so remove that+ const base_bone_name = Utility.calculate_bone_base_name(selected_bone.name)++ // Find another bone that has the same base name+ // that should be the mirror+ let mirror_bone = null;++ this.edited_skeleton.bones.forEach((bone) =>+ {+ const bone_name_to_compare = Utility.calculate_bone_base_name(bone.name)+ if(bone_name_to_compare === base_bone_name && bone.name !== selected_bone.name)+ {+ mirror_bone = bone;+ }++ });++ if(mirror_bone === null)+ {+ return; // we probably something along the axis (head, neck, spine)+ }++++ if(transform_type === 'translate')+ {+ // move the mirror bone in the -X value of the transform control+ // this will mirror the movement of the bone+ mirror_bone.position.copy(+ new Vector3(+ -selected_bone.position.x,+ selected_bone.position.y,+ selected_bone.position.z,+ ))+ }++ if (transform_type === 'rotate') {+ const euler = new Euler(+ selected_bone.rotation.x,+ -selected_bone.rotation.y,+ -selected_bone.rotation.z,+ );+ mirror_bone.quaternion.setFromEuler(euler);+ }++ mirror_bone.updateWorldMatrix(true, true);+ }+++}diff --git a/src/lib/processes/StepExportToFile.js b/src/lib/processes/StepExportToFile.jsnew file mode 100644index 0000000..8ab2e21--- /dev/null+++ b/src/lib/processes/StepExportToFile.js@@ -0,0 +1,97 @@+import { UI } from '../UI.js';+import { GLTFExporter } from 'three/examples/jsm/exporters/GLTFExporter.js';+import * as SkeletonUtils from 'three/addons/utils/SkeletonUtils.js';++// import scene from three.js+import { Scene } from 'three';++// Note: EventTarget is a built-ininterface and do not need to import it+export class StepExportToFile extends EventTarget+{+ ui = null;+ animation_clips_to_export = []++ constructor()+ {+ super();+ this.ui = new UI();+ }++ set_animation_clips_to_export(all_animations_clips)+ {+ this.animation_clips_to_export = [];+ const animation_checkboxes = this.ui.get_animated_selected_elements()+ animation_checkboxes.forEach((checkbox) => {+ if(checkbox.checked)+ {+ const animation_index = checkbox.getAttribute('value');+ let originalClip = all_animations_clips[animation_index];+ let clonedClip = originalClip.clone();+ this.animation_clips_to_export.push(clonedClip);+ }+ })+ }++ export(skinned_meshes, filename = 'exported_model')+ {+ if(this.animation_clips_to_export.length == 0)+ {+ console.log('ERROR: No animation clips added to export')+ return+ }++ const export_scene = new Scene();++ skinned_meshes.forEach((final_skinned_mesh) => {+ export_scene.add( SkeletonUtils.clone(final_skinned_mesh) );+ });++ this.export_GLB(export_scene, this.animation_clips_to_export, filename);+ }++ export_GLB(exported_scene, animations_to_export, file_name)+ {+ const gltf_exporter = new GLTFExporter();++ let export_options =+ {+ binary: true,+ onlyVisible: false,+ embedImages: true,+ animations: animations_to_export,+ };++ gltf_exporter.parse(exported_scene, (result) =>+ {+ if ( result instanceof ArrayBuffer )+ {+ this._save_array_buffer( result, `${file_name}.glb` );+ }+ else+ {+ console.log('ERROR: result is not an instance of ArrayBuffer')+ }+ },+ (error) =>+ {+ console.log( 'An error happened during parsing', error );+ },+ export_options+ )+ };++ _save_file(blob, filename)+ {+ this.ui.dom_export_button_hidden_link.href = URL.createObjectURL(blob);+ this.ui.dom_export_button_hidden_link.download = filename;+ this.ui.dom_export_button_hidden_link.click();+ }++ // used for GLB to turn content into a byte array for saving+ _save_array_buffer( buffer, filename ) {+ this._save_file( new Blob( [ buffer ], { type: 'application/octet-stream' } ), filename );+ }++++}\ No newline at end of filediff --git a/src/lib/processes/StepLoadModel.js b/src/lib/processes/StepLoadModel.jsnew file mode 100644index 0000000..a304864--- /dev/null+++ b/src/lib/processes/StepLoadModel.js@@ -0,0 +1,162 @@+import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';+import { UI } from '../UI.js';++import { Box3 } from 'three/src/math/Box3.js';+++// Note: EventTarget is a built-ininterface and do not need to import it+export class StepLoadModel extends EventTarget+{+ loader = null+ ui = null+ original_model_data = null++ // there can be multiple objects in a model, so store them in a list+ geometry_list = []+ material_list = []++ constructor()+ {+ super();+ }++ begin()+ {+ this.ui = new UI();+ this.ui.dom_current_step_index.innerHTML = '1'+ this.ui.dom_current_step_element.innerHTML = 'Load Model'+ this.ui.dom_load_model_tools.style.display = 'flex';++ this.addEventListeners();+ }++ addEventListeners()+ {+ this.ui.dom_upload_model_button.addEventListener('change', (event) => {+ const file = event.target.files[0];+ const reader = new FileReader();+ reader.readAsDataURL(file);++ reader.onload = () => {+ this._load_model_file(reader.result)+ };++ });++ this.ui.dom_load_model_button.addEventListener('click', () => {++ // get currently selected option out of the model-selection drop-down+ const model_selection = document.querySelector('#model-selection');+ const selected_model = model_selection.options[model_selection.selectedIndex].value;++ this._load_model_file(selected_model)+ });+ }++ _load_model_file(model_file)+ {+ this.loader = new GLTFLoader();++ this.loader.load(model_file, (gltf) => {+ const model = gltf.scene;++ this.original_model_data = model.clone()+ this.original_model_data.name = 'Unskinned Mesh';+ this.original_model_data.traverse((child) => {+ child.castShadow = true;+ })++ const max_height = 1.5; // have 3d model scaled to be 1.5 units tall. helps normalize the models to work with+ this._scale_model_on_import(this.original_model_data, max_height); // if we have multiple objects, we want to scale them all the same++ this.dispatchEvent(new CustomEvent('modelLoaded'));+ });++ }++ _scale_model_on_import(mesh, max_height = 1.0)+ {+ let scale_factor = null;++ // need to get the Box3 from everthing.. not just an individual child object+ console.log(mesh)++ // calculate all the meshes to find out the max height+ let bounding_box = this._calculate_bounding_box(mesh)+ const height = bounding_box.max.y - bounding_box.min.y;+ scale_factor = max_height / height;++ // scale all the meshes down by the calculated amount+ mesh.traverse((child) =>+ {+ if(child.type === 'Mesh')+ {+ child.geometry.scale(scale_factor, scale_factor, scale_factor);+ }++ })++ }++ _calculate_bounding_box(mesh)+ {+ // calculate all the meshes to find out the max height+ let found_mesh = false;+ let bounding_box = null++ mesh.traverse((child) => {+ if(child.type === 'Mesh' && found_mesh === false)+ {+ found_mesh = true;+ bounding_box = new Box3().setFromObject(child.parent);+ }+ })++ return bounding_box+ }++ model_mesh()+ {+ return this.original_model_data+ }++ models_geometry_list()+ {+ if(this.geometry_list.length > 0)+ {+ return this.geometry_list;+ }++ this.original_model_data.traverse((child) => {+ if(child.type === 'Mesh')+ {+ let geometry_to_add = child.geometry.clone();+ geometry_to_add.name = child.name;+ this.geometry_list.push(geometry_to_add)+ }+ })++ console.log(this.geometry_list)++ return this.geometry_list;+ }++ models_material_list()+ {++ if(this.material_list.length > 0)+ {+ return this.material_list;+ }++ this.original_model_data.traverse((child) => {+ if(child.type === 'Mesh')+ {+ this.material_list.push(child.material.clone())+ }+ })++ return this.material_list;+ }++}\ No newline at end of filediff --git a/src/lib/processes/StepLoadSkeleton.js b/src/lib/processes/StepLoadSkeleton.jsnew file mode 100644index 0000000..950d460--- /dev/null+++ b/src/lib/processes/StepLoadSkeleton.js@@ -0,0 +1,150 @@+import { UI } from '../UI.js';+import { Generators } from '../Generators.ts'+import { BufferGeometry, Float32BufferAttribute, Mesh, Box3, MeshBasicMaterial, SkeletonHelper } from 'three'+import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';+import { Utility } from '../Utilities.ts';+import { SkeletonType } from '../enums/SkeletonType.js';++// Note: EventTarget is a built-ininterface and do not need to import it+export class StepLoadSkeleton extends EventTarget+{+ loader = null;+ ui = null+ loaded_armature = null+ loaded_skeleton = null+ _skeleton_type = null++ constructor()+ {+ super()+ }++ skeleton_type()+ {+ return this._skeleton_type+ }++ begin()+ {+ this.ui = new UI()++ this.ui.dom_current_step_index.innerHTML = '2'+ this.ui.dom_current_step_element.innerHTML = 'Load Skeleton'+ this.ui.dom_load_skeleton_tools.style.display = 'flex'++ this.addEventListeners()+ }++ addEventListeners()+ {+ this.ui.dom_load_skeleton_button.addEventListener('click', () => {++ // get currently selected option out of the model-selection drop-down+ const skeleton_selection = this.ui.dom_skeleton_drop_type.options+ let skeleton_file = skeleton_selection[skeleton_selection.selectedIndex].value+++ // set the skeleton type. This will be used for the animations listing later+ // so it knows what animations to load+ switch(skeleton_file)+ {+ case 'quadraped':+ this._skeleton_type = SkeletonType.Quadraped+ break;+ case 'bipedal-simple':+ this._skeleton_type = SkeletonType.BipedalSimple+ break;+ case 'bipedal-full':+ this._skeleton_type = SkeletonType.BipedalFull+ break;+ }++ // load skeleton from GLB file+ this.loader = new GLTFLoader()+ this.loader.load( this._skeleton_type, (gltf) => {++ // traverse scene and find first bone object+ // we will go to the parent and mark that as the original armature+ let armature_found = false+ let original_armature = null++ gltf.scene.traverse((child) => {+ if(child.type === 'Bone' && armature_found === false)+ {+ armature_found = true;+ original_armature = child.parent;+ }+ });++ this.loaded_armature = original_armature.clone();+ this.loaded_armature.name = 'Loaded Armature';++ // scale geometry for skeleton+ let skeleton_geometry = this._buffer_geometry_from_armature(this.loaded_armature);+ let temp_skeleton_mesh = new Mesh(skeleton_geometry, new MeshBasicMaterial({color: 0x00ff00}));+ let bounding_box = new Box3().setFromObject(temp_skeleton_mesh);+ const height = bounding_box.max.y - bounding_box.min.y;+ const max_height = 1.5;+ const scale_factor = max_height / height;++ // try to scale each bone down instead of the whole armature object+ Utility.scale_armature_by_scalar(this.loaded_armature, scale_factor)++ // reset the armature to 0,0,0 in case it is off for some reason+ this.loaded_armature.position.set(0, 0, 0);+ this.loaded_armature.updateWorldMatrix(true, true);++ this.dispatchEvent(new CustomEvent('skeletonLoaded', { detail: this.loaded_armature } ) );+ })++ });+ }++ armature()+ {+ return this.loaded_armature+ }++ skeleton()+ {+ if(loaded_skeleton !== null)+ {+ this.loaded_skeleton+ }++ // create skeleton and helper to visualize+ this.loaded_skeleton = Generators.create_skeleton(this.loaded_armature.children[0]);+ this.loaded_skeleton.name = 'Mesh Editing Skeleton';++ // update the world matrix for the skeleton+ // without this the skeleton helper won't appear when the bones are first loaded+ skeleton.bones[0].updateWorldMatrix( true, true );++ return skeleton+ }+++ _buffer_geometry_from_armature(armature)+ {+ // create a geometry object from the skeleton+ // we will use this to calculate the bone weights+ const geometry = new BufferGeometry();+ const vertices = [];++ armature.traverse((bone) => {+ if(bone.type === 'Bone')+ {+ let bone_world_pos = Utility.world_position_from_object(bone);+ vertices.push(bone_world_pos.x);+ vertices.push(bone_world_pos.y);+ vertices.push(bone_world_pos.z);+ }+ });++ // add the vertices to the geometry+ geometry.setAttribute('position', new Float32BufferAttribute(vertices, 3));++ return geometry;+ }++}\ No newline at end of filediff --git a/src/lib/processes/StepWeightSkin.js b/src/lib/processes/StepWeightSkin.jsnew file mode 100644index 0000000..17a9fc0--- /dev/null+++ b/src/lib/processes/StepWeightSkin.js@@ -0,0 +1,142 @@+import { UI } from '../UI.js';++import { BoneWeightsByEnvelope } from '../solvers/BoneWeightsByEnvelope.ts';+import BoneWeightsByDistance from '../solvers/BoneWeightsByDistance.ts';+import BoneWeightsByMedianDistance from '../solvers/BoneWeightsByMedianDistance.ts';++import { SkinningFormula } from '../enums/SkinningFormula.js';++import { Generators } from '../Generators.ts';++import { SkinnedMesh } from 'three';++// Note: EventTarget is a built-ininterface and do not need to import it+export class StepWeightSkin extends EventTarget+{+ ui = null;+ skinning_armature = null+ bone_skinning_formula = null+ binding_skeleton = null+ skinned_meshes = []++ // debug options for bone skinning formula+ enable_debugging = false+ show_debug = false+ debug_scene_object = null+ bone_index_to_test = -1++ constructor()+ {+ super();+ this.ui = new UI();+ }++ begin()+ {+ this.ui.dom_current_step_index.innerHTML = '3.5'+ this.ui.dom_current_step_element.innerHTML = 'Skin Debug'+ this.ui.dom_skinned_mesh_tools.style.display = 'flex';+ }+++++ create_bone_formula_object(editable_armature, skinning_formula)+ {++ this.skinning_armature = editable_armature.clone()+ this.skinning_armature.name = 'Armature for skinning';++ // Swap out formulas to see different results+ if(skinning_formula === SkinningFormula.Envelope)+ {+ this.bone_skinning_formula = new BoneWeightsByEnvelope(this.skinning_armature.children[0]);+ }+ else if(skinning_formula === SkinningFormula.Distance)+ {+ this.bone_skinning_formula = new BoneWeightsByDistance(this.skinning_armature.children[0]);+ }+ else if(skinning_formula === SkinningFormula.MedianDistance)+ {+ this.bone_skinning_formula = new BoneWeightsByMedianDistance(this.skinning_armature.children[0]);+ }++ return this.bone_skinning_formula+ }++ skeleton()+ {+ // gets bone hierarchy from the armature+ return this.binding_skeleton+ }++ set_mesh_geometry(geometry)+ {+ this.bone_skinning_formula.set_geometry(geometry)+ }++ test_geometry()+ {+ if(this.show_debug)+ {+ this.bone_skinning_formula.set_show_debug(this.show_debug)+ this.bone_skinning_formula.set_debugging_scene_object(this.debug_scene_object)+ this.bone_skinning_formula.set_bone_index_to_test(this.bone_index_to_test)+ }++ return this.bone_skinning_formula.test_bones_outside_in_mesh()+ }++ create_binding_skeleton()+ {+ // when we copy over the armature with the bind, we will lose the reference in the variable+ this.binding_skeleton = Generators.create_skeleton(this.skinning_armature.children[0]);+ this.binding_skeleton.name = 'Mesh Binding Skeleton';+ }++ clear_skinned_meshes()+ {+ this.skinned_meshes = []+ }++ create_skinned_mesh(geometry, material)+ {+ // create skinned mesh+ let skinned_mesh = new SkinnedMesh(geometry, material);+ skinned_mesh.name = 'Skinned Mesh';+ skinned_mesh.castShadow = true; // skinned mesh won't update right if this is false++ // do the binding for the mesh to the skelleton+ skinned_mesh.add(this.binding_skeleton.bones[0]);+ skinned_mesh.bind(this.binding_skeleton);++ // keep track of all the skinned meshes we create to access later+ this.skinned_meshes.push(skinned_mesh)+ }++ final_skinned_meshes()+ {+ return this.skinned_meshes+ }++ set_show_debug(value)+ {+ this.show_debug = value+ }++ set_debug_scene_object(scene)+ {+ this.debug_scene_object = scene+ }++ set_bone_index_to_test(index)+ {+ this.bone_index_to_test = index+ }++ calculate_weights()+ {+ return this.bone_skinning_formula.calculate_indexes_and_weights()+ }++}\ No newline at end of filediff --git a/src/lib/solvers/BoneWeightsByDistance.ts b/src/lib/solvers/BoneWeightsByDistance.tsnew file mode 100644index 0000000..ec3aa28--- /dev/null+++ b/src/lib/solvers/BoneWeightsByDistance.ts@@ -0,0 +1,110 @@+import { Bone, BufferGeometry, Scene, Vector3 } from 'three';+import { Utility } from '../Utilities.js';+import BoneCalculationData from '../models/BoneCalculationData.js';+++export default class BoneWeightsByDistance+{+ private bones_master_data: Array<BoneCalculationData> = [];+ private geometry: BufferGeometry;+ private show_debug: boolean = false;+ private bone_idx_test: number = -1;+ private debugging_scene_object: Scene;++ constructor(bone_hier)+ {+ this.init_bone_weights_data_structure(bone_hier)+ }++ public set_debugging_scene_object(scene_object): void+ {+ this.debugging_scene_object = scene_object;+ }++ public set_geometry(geom: BufferGeometry): void+ {+ this.geometry = geom;+ }++ private get_vertex_count(): number+ {+ if(this.geometry === null) {+ return -1;+ }++ return this.geometry.attributes.position.array.length / 3+ }++ public set_show_debug(debug_value: boolean): void+ {+ this.show_debug = debug_value;+ }++ public set_bone_index_to_test(bone_idx: number): void+ {+ this.bone_idx_test = bone_idx;+ }++ private init_bone_weights_data_structure(bone_hier): void+ {+ const bones_list: Bone[] = Utility.bone_list_from_hierarchy(bone_hier)+ bones_list.forEach( (bone) => {+ const has_child_bone: boolean = bone.children.length > 0+ const supports_envelope: boolean = false+ const new_bone_object: BoneCalculationData =+ new BoneCalculationData(bone.name, bone, supports_envelope, has_child_bone)+ this.bones_master_data.push( new_bone_object)+ });+ }++ public calculate_indexes_and_weights(): number[][]+ {+ const skinIndices: Array<number> = [];+ const skinWeights: Array<number> = [];++ // loop through each vertex and find the closest bone+ // then assign the closest vertices to that bone in the assigned_vertices property+ for( let i = 0; i < this.get_vertex_count(); i++)+ {+ const vertex_position: Vector3 = new Vector3().fromBufferAttribute(this.geometry.attributes.position, i);+ let closest_bone: Bone = this.bones_master_data[0].bone_object;+ let closest_bone_distance: number = 10000;+ let closest_bone_index: number = 0;++ this.bones_master_data.forEach( (bone, idx) => {+ const distance: number = Utility.world_position_from_object(bone.bone_object).distanceTo(vertex_position);++ if(distance < closest_bone_distance)+ {+ closest_bone = bone.bone_object;+ closest_bone_distance = distance;+ closest_bone_index = idx;+ }+ })++ this.bones_master_data[closest_bone_index].assigned_vertices.push(i);++ // assign to final weights. closest bone is always 100% weight+ skinIndices.push(closest_bone_index, 0, 0, 0);+ skinWeights.push(1.0, 0, 0, 0);+ }++ if(this.show_debug)+ {+ console.log('Assigned all the bones to vertices: ', this.bones_master_data)+ }++ return [skinIndices, skinWeights]++ }+++ public test_bones_outside_in_mesh()+ {+ // don't do test for now and just return success+ return [[],[]];+ }++}++diff --git a/src/lib/solvers/BoneWeightsByEnvelope.ts b/src/lib/solvers/BoneWeightsByEnvelope.tsnew file mode 100644index 0000000..4e81bac--- /dev/null+++ b/src/lib/solvers/BoneWeightsByEnvelope.ts@@ -0,0 +1,475 @@+import { BoneEnvelopeGeometry, BoneEnvelopeGeometryUtils } from '../geometry/BoneEnvelopeGeometry.js';+import { Generators } from '../Generators.js';+import { Utility } from '../Utilities.ts';+import BoneCalculationData from '../models/BoneCalculationData.ts';+import { BufferGeometry, Scene, Bone, Object3D, Mesh, Vector3, Raycaster, Intersection } from 'three';++export class BoneWeightsByEnvelope+{+ private bones_master_data: Array<BoneCalculationData> = [];+ private geometry: BufferGeometry;+ private show_debug: boolean = false;+ private bone_idx_test: number = -1;+++ private debugging_scene_object: Object3D;+ private debug_sphere_size = 0.06;+ private debug_sphere_color_success = 0x00ff00; // vertices that are part of envelope+ private debug_sphere_color_failure = 0xff0000; // vertices that will have to use closest bone+++ // two variables used for testing to see if we have an ok bone envelope to bind+ private bone_names_with_errors: Array<string> = [];+ private bone_vertices_with_errors: Array<Vector3> = [];++ constructor(bone_hier)+ {+ this.init_bone_weights_data_structure(bone_hier)+ }++ public set_geometry(geom: BufferGeometry): void+ {+ this.geometry = geom;+ }++ private init_bone_weights_data_structure(bone_hier)+ {+ const bones: Bone[] = Utility.bone_list_from_hierarchy(bone_hier)+ this.bones_master_data = [];+ bones.forEach( (bone) => {+ const has_child_bone: boolean = bone.children.length > 0+ const supports_envelope: boolean = is_bone_valid_for_envelope_calculation(bone)++ // used for 4 legged creatures now to prevent expanding too far+ let use_minimum_expand_distance: boolean = false;+ if(bone.name === 'Right_Front_Leg_Upper'+ || bone.name === 'Left_Front_Leg_Upper'+ || bone.name === 'Right_Back_Leg_Upper'+ || bone.name === 'Left_Back_Leg_Upper' )+ {+ use_minimum_expand_distance = true+ }++ const new_bone_object: BoneCalculationData = new BoneCalculationData(bone.name, bone, supports_envelope, has_child_bone, [], use_minimum_expand_distance)++ this.bones_master_data.push( new_bone_object)+ });+++ }++ public set_show_debug(debug_value: boolean): void+ {+ this.show_debug = debug_value;+ }++ public set_bone_index_to_test(bone_idx: number): void+ {+ this.bone_idx_test = bone_idx;+ }++ public set_debugging_scene_object(scene_object: Object3D): void+ {+ this.debugging_scene_object = scene_object;+ }++ private geometry_vertex_count(): number+ {+ return this.geometry?.attributes?.position.array.length / 3;+ }+++ public test_bones_outside_in_mesh(): [string[], Vector3[]]+ {+ this.bones_master_data.forEach( (bone: BoneCalculationData, bone_index: number) => {+ if (bone.supports_envelope_calculation)+ {+ const rays_to_cast: number = 4;+ let bone_start: Bone = bone.bone_object+ let bone_end: Bone = bone.bone_object.children[0] as Bone+ const intersection_plane_mesh = Generators.create_bone_plane_mesh(bone_start, bone_end, rays_to_cast)+ const [intersection_distances, intersection_vertexes] = this.intersections_for_geometry(rays_to_cast, intersection_plane_mesh);+ const envelope_mesh = this.create_envelope_mesh_for_bone(bone)+ this.expand_envelope_mesh_to_fit_bone(envelope_mesh, intersection_distances, bone)+ }+ });++ // there are some errors in bone positions being outside of the mesh.+ // avoid future calculations and eventually exit out+ if(this.bone_names_with_errors.length > 0)+ {+ return [this.bone_names_with_errors, this.bone_vertices_with_errors];+ }++ return [[],[]];+ }++ public calculate_indexes_and_weights()+ {+ // go through each bone, build a bone envelope, see which vertices intersect it,+ // then assign it to the bone+ const vertex_points_that_passed: Vector3[] = [];+ const envelope_shapes_to_show: Mesh[] = [];++ this.bones_master_data.forEach( (bone: BoneCalculationData, bone_index: number) => {+ if (bone.supports_envelope_calculation)+ {+ const rays_to_cast: number = 4;+ let bone_start: Bone = bone.bone_object+ let bone_end: Bone = bone.bone_object.children[0] as Bone+ const intersection_plane_mesh = Generators.create_bone_plane_mesh(bone_start, bone_end, rays_to_cast)+ const [intersection_distances, intersection_vertexes] = this.intersections_for_geometry(rays_to_cast, intersection_plane_mesh);+ const envelope_mesh = this.create_envelope_mesh_for_bone(bone)++ this.expand_envelope_mesh_to_fit_bone(envelope_mesh, intersection_distances, bone)++ const { vertex_positions_inside_bone_envelope, vertex_indexes_inside_bone_evelope } =+ Utility.intersection_points_between_positions_and_mesh(this.geometry.attributes.position, envelope_mesh);++ bone.assigned_vertices.push(...vertex_indexes_inside_bone_evelope)++ // show all of these visually when we are done with checks+ vertex_points_that_passed.push(...vertex_positions_inside_bone_envelope)+ envelope_shapes_to_show.push(envelope_mesh)+ }+ });+++ // display all the points that passed the bone envelope test+ if(this.show_debug)+ {+ const debug_assigned_points = Generators.create_spheres_for_points(vertex_points_that_passed,+ this.debug_sphere_size, this.debug_sphere_color_success, 'Vertices assigned to bone')+ this.debugging_scene_object.add(debug_assigned_points)++ envelope_shapes_to_show.forEach( (envelope_mesh) => {+ this.debugging_scene_object.add(envelope_mesh)+ //this.debugging_scene_object.add(intersection_plane_mesh)+ });+ }++ // There could be some bones that aren't inside the mesh from the last calculation. This will mess up the bone envelope calculations+ // and need to be fixed. We need to abort the calculations+ if(this.bone_names_with_errors.length > 0)+ {+ throw new Error(`ERROR: Some bones are outside the mesh. Need to fix this. Bones: ${this.bone_names_with_errors}`);+ }+++ if (this.show_debug)+ {+ console.log('Part A: Done finding vertices for bone envelopes', this.bones_master_data)+ }++ // B.+ // find out if there are any vertices that are not assigned to a bone+ // loop through the vertices without bones and find out what their position is... show that in the debugger+ const vertex_indexes_without_bones = vertices_not_assigned_to_bone(this.geometry_vertex_count(), this.bones_master_data);+ const vertex_positions_without_bones: Vector3[] = [];+ vertex_indexes_without_bones.forEach( (vertex_index) => {+ const vertex_position = new Vector3().fromBufferAttribute(this.geometry.attributes.position, vertex_index);+ vertex_positions_without_bones.push(vertex_position)+ })+++ const debug_vertices_without_points = Generators.create_spheres_for_points(vertex_positions_without_bones,+ this.debug_sphere_size, this.debug_sphere_color_failure, 'Vertices unassigned to bone')+ this.debugging_scene_object.add(debug_vertices_without_points)++ console.log(this.debugging_scene_object)++ console.log('Part B: Finding vertices that are not assigned to any bones', vertex_indexes_without_bones)+++ // C. go through each vertex that has no bone and find the closest bone+ // loop through all bones and find out which one is the closest+ const closest_vertex_list: Array<number> = [] // vertex index linked list+ const closest_bone_list: Array<number> = []; // bone index linked list++ vertex_indexes_without_bones.forEach( (vertex_index, idx) => {+ let closest_bone_index: number = find_closest_bone_index_from_vertex_index(vertex_index, this.geometry, this.bones_master_data)+ closest_vertex_list.push(vertex_indexes_without_bones[idx])+ closest_bone_list.push(closest_bone_index)+ })++ // combine closest vertex bone calculation results with the bone envelope results+ // the bones_vertex_list is the master list+ closest_bone_list.forEach( (bone_index, iter_idx) => {+ this.bones_master_data[bone_index].assigned_vertices.push(closest_vertex_list[iter_idx])+ })++ if (this.show_debug)+ {+ const left_over_after_all_assigned = vertices_not_assigned_to_bone(this.geometry_vertex_count(), this.bones_master_data);+ console.log('Part C: Seeing if anything is leftover after assignment', left_over_after_all_assigned)+ }+++ // D. Map all weights for each bone to the final skin indices and weights+ // that the buffer attribute needs for the skinning process+ const { final_skin_indices, final_skin_weights } = this.calculate_final_weights(this.bones_master_data, this.geometry_vertex_count());++ if(this.show_debug)+ {+ console.log('Assigned all the bones to vertices: ', this.bones_master_data)+ }++ return [ final_skin_indices, final_skin_weights ]+ }++ private create_envelope_mesh_for_bone(bone)+ {+ let envelope_color = 0xaaaaff++ let envelope_geometry: BoneEnvelopeGeometry = new BoneEnvelopeGeometry()+ const envelope_mesh = new Mesh(envelope_geometry as BufferGeometry, Generators.create_material(true, envelope_color));+ envelope_mesh.name = `Envelope Box Mesh: ${bone.name}`+ const padding_multiplier: number = 1.2 // scale the box to help with overlap and points just outside box+ envelope_mesh.scale.set(padding_multiplier, padding_multiplier, padding_multiplier)++ let bone_start: Bone = bone.bone_object+ let bone_end: Bone = bone_start.children[0] as Bone++ // reposition/rotate cylinder to be by the bone+ // to get the right orientation of the cylinder, we need to rotateOnAxis+ // last to make it face the right direction+ const height: number = Utility.distance_between_objects(bone_start, bone_end);+ const bone_direction = Utility.direction_between_points(Utility.world_position_from_object(bone_start), Utility.world_position_from_object(bone_end));+ const facing_direction = Utility.world_position_from_object(bone_end)+ envelope_mesh.position.copy(Utility.world_position_from_object(bone_start));+ envelope_mesh.translateOnAxis(bone_direction, height*0.5);+ envelope_mesh.lookAt(facing_direction)+ envelope_mesh.rotateOnAxis(new Vector3(1,0,0), Math.PI * 0.5)++ return envelope_mesh+ }++ private expand_envelope_mesh_to_fit_bone(envelope_mesh: Mesh, intersections, bone: BoneCalculationData)+ {+ let bone_start = bone.bone_object+ let bone_end = bone_start.children[0]++ // Grow bone envelope to fix space+ const height = Utility.distance_between_objects(bone_start, bone_end);+ const left_ray_distance: number = intersections[0]+ const back_ray_distance: number = intersections[1]+ const right_ray_distance: number = intersections[2]+ const forward_ray_distance: number = intersections[3]++ if(bone.use_minimum_envelope_expand)+ {+ const min_x_side = Math.min(right_ray_distance, left_ray_distance);+ const min_z_side = Math.min(forward_ray_distance, back_ray_distance);++ BoneEnvelopeGeometryUtils.expand_x_positive_face(envelope_mesh.geometry, min_x_side)+ BoneEnvelopeGeometryUtils.expand_x_negative_face(envelope_mesh.geometry, min_x_side)+ BoneEnvelopeGeometryUtils.expand_z_positive_face(envelope_mesh.geometry, min_z_side)+ BoneEnvelopeGeometryUtils.expand_z_negative_face(envelope_mesh.geometry, min_z_side)+ BoneEnvelopeGeometryUtils.expand_y_positive_face(envelope_mesh.geometry, height*0.5)+ BoneEnvelopeGeometryUtils.expand_y_negative_face(envelope_mesh.geometry, height*0.5)+ }+ else+ {+ BoneEnvelopeGeometryUtils.expand_x_positive_face(envelope_mesh.geometry, right_ray_distance)+ BoneEnvelopeGeometryUtils.expand_x_negative_face(envelope_mesh.geometry, left_ray_distance)+ BoneEnvelopeGeometryUtils.expand_z_positive_face(envelope_mesh.geometry, forward_ray_distance)+ BoneEnvelopeGeometryUtils.expand_z_negative_face(envelope_mesh.geometry, back_ray_distance)+ BoneEnvelopeGeometryUtils.expand_y_positive_face(envelope_mesh.geometry, height*0.5)+ BoneEnvelopeGeometryUtils.expand_y_negative_face(envelope_mesh.geometry, height*0.5)+ }++++ // if a bone goes outside a mesh, the intersection will be undefined. keep track of what bones do this and+ if(left_ray_distance === undefined || right_ray_distance === undefined || back_ray_distance === undefined || forward_ray_distance === undefined)+ {+ this.bone_names_with_errors.push(bone.name);+ this.bone_vertices_with_errors.push( Utility.world_position_from_object(bone_start) )+ return;+ }++ // updating scene and skeleton allows to correctly calculate the bone envelope positions+ envelope_mesh.geometry.computeBoundingBox(); // need to recompute for collision next+ }++ private intersections_for_geometry(rays_to_cast, debug_bone_plane_mesh) {+ const intersection_distances: Array<number> = []; // ray cast around the object and find how far out the mesh goes+ const intersection_vertexes: Array<Vector3> = []; // output for potentially showing in debugger+ const normal_mesh: Mesh = new Mesh(this.geometry, Generators.create_material(true));+ normal_mesh.name = 'Normal mesh used for intersection';+ for (let j = 0; j < rays_to_cast; j++) {+ const point_2: Vector3 = Utility.world_position_from_object(debug_bone_plane_mesh.children[j]);+ const ray_origin: Vector3 = Utility.world_position_from_object(debug_bone_plane_mesh);+ const ray_direction: Vector3 = Utility.direction_between_points(ray_origin, point_2);++ const raycaster: Raycaster = new Raycaster(ray_origin, ray_direction);+ //const ray_helper = new THREE.ArrowHelper(ray_direction, ray_origin, 100, 0xffffff,1,1)+ //this.debugging_scene_object.add(ray_helper)+ // calculate where closest intersection happens+ const intersects: Intersection[] = raycaster.intersectObject(normal_mesh);+ if (intersects && intersects[0]) {+ intersection_distances.push(intersects[0].distance);+ intersection_vertexes.push(intersects[0].point)+ }++ } // end for loop through rays+ return [intersection_distances, intersection_vertexes];+ }++ /**+ * Three.js needs the bone indexes and weights stored as an index and weight pair+ * Three.js also needs 4 bones per vertex, so we need to manipulate the data to fit that shape+ * @param {*} bones_master_data+ * @param {*} geometry_vertex_count+ * @returns+ */+ private calculate_final_weights(bones_master_data, geometry_vertex_count)+ {+ const final_skin_indices: Array<number> = [];+ const final_skin_weights: Array<number> = [];++ // some debug info variables if I want to print with them+ let vertices_with_1_bone: number = 0;+ let vertices_with_2_bones: number = 0;+ let vertices_with_3_bones: number = 0;+ let vertices_with_4_bones: number = 0;+ let vertices_with_too_many_bones: number = 0;++ for (let i = 0; i < geometry_vertex_count; i++) {+ // find out which bones this vertex is assigned to+ const bones_for_vertex: Array<number> = [];+ const weights_for_vertex: Array<number> = [];+ bones_master_data.forEach((bone, bone_index) => {++ // bone includes vertex index+ if (bone.assigned_vertices.includes(i)) {+ bones_for_vertex.push(bone_index);+ weights_for_vertex.push(1);+ }+ });++ // we might have 1, 2, 3, or 4 bones. Need to morph+ // the results to always be an array of length 4+ if (bones_for_vertex.length === 1) {+ final_skin_indices.push(bones_for_vertex[0], 0, 0, 0);+ final_skin_weights.push(1, 0, 0, 0);+ vertices_with_1_bone++;+ }+ else if (bones_for_vertex.length === 2) {+ final_skin_indices.push(bones_for_vertex[0], bones_for_vertex[1], 0, 0);+ final_skin_weights.push(0.5, 0.5, 0.0, 0);+ vertices_with_2_bones++;+ }+ else if (bones_for_vertex.length === 3) {+ final_skin_indices.push(bones_for_vertex[0], bones_for_vertex[1], bones_for_vertex[2], 0);+ final_skin_weights.push(0.6, 0.3, 0.1, 0);+ vertices_with_3_bones++;+ }+ else if (bones_for_vertex.length === 4) {+ final_skin_indices.push(...bones_for_vertex); // everything+ final_skin_weights.push(0.7, 0.2, 0.05, 0.25);+ vertices_with_4_bones++;+ }+ else if (bones_for_vertex.length > 4) {+ final_skin_indices.push(bones_for_vertex[0], bones_for_vertex[1], bones_for_vertex[2], bones_for_vertex[3]);+ final_skin_weights.push(0.25, 0.25, 0.25, 0.25);++ vertices_with_too_many_bones++;+ console.log('ERROR: vertex is assigned to more than 4 bones. need to figure out what to do');+ }+ }++ if (this.show_debug)+ {+ console.log(`Part D: Finalizing bone weights. How many bones is each vertex assigned to: 1)${vertices_with_1_bone} 2)${vertices_with_2_bones} 3)${vertices_with_3_bones}+ 4)${vertices_with_4_bones} 5+)${vertices_with_too_many_bones}`)+ }++ return { final_skin_indices, final_skin_weights };+ }++} // end Class BoneWeightsByEnvelope+++function is_bone_valid_for_envelope_calculation(bone: Bone): boolean+{+ // if our bone doesn't have any children, that means it is the final tip+ // and not a bone we want to use for envelope calculations+ if(bone.children.length === 0)+ {+ return false;+ }++ // we are going to ignore certain bones for the bone as they+ // have odd angles and create bad envelopes+ if(+ bone.name.includes('Fingers') ||+ bone.name.includes('HandBase') ||+ bone.name === 'SpineUp' )+ {+ return false;+ }++ return true; // bone is ok to do envelope calculations+}++function vertices_not_assigned_to_bone(geometry_vertex_count: number, bones_master_data: Array<BoneCalculationData>)+{+ const vertex_indexes_without_bones: Array<number> = [];++ for (let i = 0; i < geometry_vertex_count; i++)+ {+ let does_vertex_exist_in_bones: boolean = false;+ bones_master_data.forEach((bone) =>+ {+ if (bone.assigned_vertices.includes(i))+ {+ does_vertex_exist_in_bones = true;+ }+ });++ if (does_vertex_exist_in_bones === false)+ {+ vertex_indexes_without_bones.push(i)+ }+ }++ return vertex_indexes_without_bones;+}++function find_closest_bone_index_from_vertex_index(vertex_index, geometry, bones: Array<BoneCalculationData> )+{+ const vertex_position: Vector3 = new Vector3().fromBufferAttribute(geometry.attributes.position, vertex_index);+ let closest_bone: Bone = bones[0].bone_object;+ let closest_bone_distance: number = 10000;+ let closest_bone_index: number = 0;++ bones.forEach((bone: BoneCalculationData, idx: number) => {+ let distance: number = Utility.world_position_from_object(bone.bone_object).distanceTo(vertex_position);++ // if bone has a child, we are going to calculate the distance by getting the half way+ // point between bone and child bone...to hopefully yield better results+ if (bone.has_child_bone) {+ const child_bone: Bone = bone.bone_object.children[0] as Bone;+ const child_bone_position: Vector3 = Utility.world_position_from_object(child_bone);+ const bone_position: Vector3 = Utility.world_position_from_object(bone.bone_object);+ const half_way_point: Vector3 = bone_position.add(child_bone_position).divideScalar(2);+ const distance_to_half_way_point: number = half_way_point.distanceTo(vertex_position);++ if (distance_to_half_way_point < closest_bone_distance) {+ distance = distance_to_half_way_point;+ }+ }++ if (distance < closest_bone_distance) {+ closest_bone = bone.bone_object;+ closest_bone_distance = distance;+ closest_bone_index = idx;+ }+ });++ bones[closest_bone_index].assigned_vertices.push(vertex_index);+ return closest_bone_index;+}++diff --git a/src/lib/solvers/BoneWeightsByMedianDistance.ts b/src/lib/solvers/BoneWeightsByMedianDistance.tsnew file mode 100644index 0000000..6a08bd3--- /dev/null+++ b/src/lib/solvers/BoneWeightsByMedianDistance.ts@@ -0,0 +1,135 @@+import { Utility } from '../Utilities.js';+import { Bone, BufferGeometry, Scene, Vector3 } from 'three';+import BoneCalculationData from '../models/BoneCalculationData.js';+++/**+ * This calculation is similar to the normal bone weights by distance, but uses the+ * location half way between the bone and the child's bone. This gives better results with the joints+ * If there is no child bone, it just uses the bone's position for the distance calculation+ */+export default class BoneWeightsByMedianDistance+{+ private geometry: BufferGeometry;+ private skinIndices: Array<number> = [];+ private skinWeights: Array<number> = [];+ private show_debug: boolean = false;+ private bone_idx_test: number = -1;+ private bones_master_data: Array<BoneCalculationData> = [];+ private debugging_scene_object: Scene;++ constructor(bone_hier)+ {+ this.init_bone_weights_data_structure(bone_hier)+ }++ private get_vertex_count()+ {+ if(this.geometry === null) {+ return -1;+ }++ return this.geometry.attributes.position.array.length / 3+ }++ public set_show_debug(debug_value)+ {+ this.show_debug = debug_value;+ }++ public set_bone_index_to_test(bone_idx)+ {+ this.bone_idx_test = bone_idx;+ }++ public set_debugging_scene_object(scene_object)+ {+ this.debugging_scene_object = scene_object;+ }++ public set_geometry(geom: BufferGeometry): void+ {+ this.geometry = geom;+ }+++ private init_bone_weights_data_structure(bone_hier)+ {+ const bones_list = Utility.bone_list_from_hierarchy(bone_hier)+ bones_list.forEach( (bone) => {+ const has_child_bone = bone.children.length > 0+ const supports_envelope = false+ const new_bone_object = new BoneCalculationData(bone.name, bone, supports_envelope, has_child_bone)+ this.bones_master_data.push( new_bone_object)+ });+ }++ public calculate_indexes_and_weights()+ {+ // loop through each vertex and find the closest bone+ // then assign the closest vertices to that bone in the assigned_vertices property+ for( let i = 0; i < this.get_vertex_count(); i++)+ {+ let closest_bone_index: number =+ this.find_closest_bone_index_from_vertex_index(i, this.geometry, this.bones_master_data)++ // assign to final weights. closest bone is always 100% weight+ this.skinIndices.push(closest_bone_index, 0, 0, 0);+ this.skinWeights.push(1.0, 0, 0, 0);+ }++ if(this.show_debug)+ {+ console.log('Assigned all the bones to vertices: ', this.bones_master_data)+ }++ return [this.skinIndices, this.skinWeights]+ }++ private find_closest_bone_index_from_vertex_index(vertex_index: number,+ geometry: BufferGeometry, bones: Array<BoneCalculationData>) : number+ {+ const vertex_position: Vector3 = new Vector3().fromBufferAttribute(geometry.attributes.position, vertex_index);+ let closest_bone: Bone = bones[0].bone_object;+ let closest_bone_distance: number = 10000;+ let closest_bone_index: number = 0;++ bones.forEach((bone: BoneCalculationData, idx: number) => {+ let distance: number = Utility.world_position_from_object(bone.bone_object).distanceTo(vertex_position);++ // if bone has a child, we are going to calculate the distance by getting the half way+ // point between bone and child bone...to hopefully yield better results+ if (bone.has_child_bone) {+ const child_bone: Bone = bone.bone_object.children[0];+ const child_bone_position: Vector3 = Utility.world_position_from_object(child_bone);+ const bone_position: Vector3 = Utility.world_position_from_object(bone.bone_object);+ const half_way_point: Vector3 = bone_position.add(child_bone_position).divideScalar(2);+ const distance_to_half_way_point: number = half_way_point.distanceTo(vertex_position);++ if (distance_to_half_way_point < closest_bone_distance) {+ distance = distance_to_half_way_point;+ }+ }++ if (distance < closest_bone_distance) {+ closest_bone = bone.bone_object;+ closest_bone_distance = distance;+ closest_bone_index = idx;+ }+ });++ bones[closest_bone_index].assigned_vertices.push(vertex_index);+ return closest_bone_index;+ }++ public test_bones_outside_in_mesh()+ {+ // don't do test for now and just return success+ return [[],[]];+ }+++} // end class+++diff --git a/src/script.js b/src/script.jsnew file mode 100644index 0000000..15d73bb--- /dev/null+++ b/src/script.js@@ -0,0 +1,415 @@+import * as THREE from 'three';+import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';++import { Utility } from './lib/Utilities.ts';+import { Generators } from './lib/Generators.ts';++import { TransformControls } from 'three/examples/jsm/controls/TransformControls.js';++import { UI } from './lib/UI.js';++import { StepLoadModel } from './lib/processes/StepLoadModel.js';+import { StepLoadSkeleton } from './lib/processes/StepLoadSkeleton.js';+import { StepEditSkeleton } from './lib/processes/StepEditSkeleton.js';+import { StepAnimationsListing } from './lib/processes/StepAnimationsListing.js';+import { StepExportToFile } from './lib/processes/StepExportToFile.js';+import { StepWeightSkin } from './lib/processes/StepWeightSkin.js';++import { ProcessStep } from './lib/enums/ProcessStep.js';++// Initialize basic sene things that are not related to the main work that is being tested+const camera = Generators.create_camera();++const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });+renderer.setSize(window.innerWidth, window.innerHeight);+renderer.shadowMap.enabled = true;++Generators.create_window_resize_listener(renderer, camera);+document.body.appendChild(renderer.domElement);++// center orbit controls around mid-section area with target change+const controls = new OrbitControls(camera, renderer.domElement);+controls.target.set(0, 0.75, 0);+controls.update();++// setup transform controls to eventually test out differnt bone rotations+let transformControls = new TransformControls(camera, renderer.domElement);+let is_transform_controls_dragging = false;++// has UI elements on the HTML page that we will reference/use+let ui = new UI();+let load_model_step = new StepLoadModel()+let load_skeleton_step = new StepLoadSkeleton()+let edit_skeleton_step = new StepEditSkeleton()+let weight_skin_step = new StepWeightSkin()+let animations_listing_step = new StepAnimationsListing()+let file_export_step = new StepExportToFile()++const scene = new THREE.Scene();+scene.add(transformControls);++// basic things in another group, to better isolate what we are working on+const environment_container = new THREE.Group();+environment_container.name = 'Setup objects';+environment_container.add(...Generators.create_default_lights());+environment_container.add(...Generators.create_grid_helper())+scene.add(environment_container);+++const fog_near = 0+const fog_far = 80+const fog_color = 0x0d2525+scene.fog = new THREE.Fog(fog_color, fog_near, fog_far);++// for looking at specific bones+let skeleton_helper;+let debugging_visual_object = null;+let process_step = null;++let clock = new THREE.Clock();++process_step = process_step_changed(ProcessStep.LoadModel)++function regenerate_skeleton_helper(new_skeleton, helper_name = 'Skeleton Helper')+{+ // if skeleton helper exists...remove it+ if(skeleton_helper)+ {+ scene.remove(skeleton_helper);+ }++ skeleton_helper = new THREE.SkeletonHelper(new_skeleton.bones[0]);+ skeleton_helper.name = helper_name;+ scene.add(skeleton_helper)+}++function handle_transform_controls_moving()+{+ if(edit_skeleton_step.is_mirror_mode_enabled())+ {+ const selected_bone = transformControls.object+ edit_skeleton_step.apply_mirror_mode(selected_bone, transformControls.getMode())+ }+}++function clear_info_panel_message()+{+ ui.dom_info_panel.innerHTML = 'Everything ok';+}++function show_skin_failure_message(bones_with_errors)+{+ // add the bone vertices as sphere to debugging object+ const sphere_failures = Generators.create_spheres_for_points(bones_with_errors, 0.02, 0xff0000)+ debugging_visual_object.add(sphere_failures)++ // add information to the info panel+ ui.dom_info_panel.innerHTML = 'Some bones are outside the mesh. Fix them up and try to bind again';+ ui.dom_info_panel.innerHTML += '<br>';++ // display the bones names in an HTML list+ let bones_error_list = '<ol id="bone-list">'+ bones_with_errors.forEach((bone) => {+ bones_error_list += `<li>${ Utility.clean_bone_name_for_messaging(bone) }</li>`+ });++ bones_error_list += '</ol>'+ ui.dom_info_panel.innerHTML += bones_error_list+}++function test_bone_weighting_success()+{+ debugging_visual_object = Utility.regenerate_debugging_scene(scene); // clear out the debugging scene++ weight_skin_step.create_bone_formula_object(edit_skeleton_step.armature(), edit_skeleton_step.algorithm())++ if(edit_skeleton_step.show_debugging())+ {+ weight_skin_step.set_show_debug(edit_skeleton_step.show_debugging());+ weight_skin_step.set_debug_scene_object(debugging_visual_object);+ weight_skin_step.set_bone_index_to_test(-1);+ }++ // Don't do skinning operation if there are bones outside of the mesh+ // that messes up the bone envelope calculation+ let testing_geometry_success = true;+ load_model_step.models_geometry_list().forEach((mesh_geometry, index) => {++ weight_skin_step.set_mesh_geometry(mesh_geometry)+ const [bone_names_failing_skin_test, bone_positions_failing_skin_test] = weight_skin_step.test_geometry()++ if(bone_names_failing_skin_test.length > 0)+ {+ let names_with_object_index = bone_names_failing_skin_test.map((bone_name) => bone_name + ` (${mesh_geometry.name})` );+ show_skin_failure_message(names_with_object_index)+ testing_geometry_success = false;+ }+ });++ if(testing_geometry_success === false)+ {+ return false+ }++ return true+}++function start_skin_weighting_step()+{++ // we only need one binding skeleton. All skinned meshes will use this.+ weight_skin_step.create_binding_skeleton()++ weight_skin_step.clear_skinned_meshes() // clear out any existing skinned meshes in storage+ load_model_step.models_geometry_list().forEach((mesh_geometry, index) => {++ // we passed the bone test, so we can do the skinning process+ weight_skin_step.set_mesh_geometry(mesh_geometry)+ const [final_skin_indices, final_skin_weights] = weight_skin_step.calculate_weights()++ mesh_geometry.setAttribute( 'skinIndex', new THREE.Uint16BufferAttribute( final_skin_indices, 4 ) );+ mesh_geometry.setAttribute( 'skinWeight', new THREE.Float32BufferAttribute(final_skin_weights, 4 ) );++ // create a separate skinned skeleton and helper for the binding pose+ // having a separate one will help us if we want to go back and edit the original skeleton+ const mesh_material = load_model_step.models_material_list()[index]+ weight_skin_step.create_skinned_mesh(mesh_geometry, mesh_material)++ scene.add(...weight_skin_step.final_skinned_meshes())+ });+++++ // remember our skeleton position before we do the skinning process+ // that way if we revert to try again...we will have the original positions/rotations+ load_model_step.model_mesh().visible = false; // hide our unskinned mesh after we have done the skinning process++ // re-define skeleton helper to use the skinned mesh)+ regenerate_skeleton_helper(weight_skin_step.skeleton())+ clear_info_panel_message()++ // we might want to test out the binding algorithm to see various hitboxes+ // if we are doing debugging, go to that view, if no debugging, go straight to thd animation listing step+ if(edit_skeleton_step.show_debugging())+ {+ return+ }++ process_step_changed(ProcessStep.AnimationsListing)++}++function process_step_changed(process_step)+{+ // we will have the current step turn on the UI elements it needs+ ui.hideAllElements();++ // clean up any event listeners from the previous steps+ edit_skeleton_step.removeEventListeners()+ animations_listing_step.removeEventListeners()++ switch(process_step)+ {+ case ProcessStep.LoadModel:+ process_step = ProcessStep.LoadModel+ load_model_step.begin()+ break;+ case ProcessStep.LoadSkeleton:+ process_step = ProcessStep.LoadSkeleton+ load_skeleton_step.begin()+ break;+ case ProcessStep.EditSkeleton:+ process_step = ProcessStep.EditSkeleton+ edit_skeleton_step.begin()+ transformControls.enabled = true;+ transformControls.setMode("translate");+ ui.dom_transform_controls_switch.style.display = 'none'; // hide the UI control until we have a bone selected+ break;+ case ProcessStep.BindPose:+ process_step = ProcessStep.BindPose+ weight_skin_step.begin()+ transformControls.enabled = false; // shouldn't be editing bones+ start_skin_weighting_step()+ break;+ case ProcessStep.AnimationsListing:+ process_step = ProcessStep.AnimationsListing+ animations_listing_step.begin()+ transformControls.setMode("rotate");+ animations_listing_step.load_and_apply_default_animation_to_skinned_mesh(weight_skin_step.final_skinned_meshes(),+ load_skeleton_step.skeleton_type() )+ break;+ }++ // when we change steps, we are re-creating the skeleeton and helper+ // so the current transform control reference will be lost/give an error+ transformControls.detach();++ return process_step;+}++const animate = () => {+ requestAnimationFrame(animate);++ if(animations_listing_step?.mixer())+ {+ const deltaTime = clock.getDelta();+ animations_listing_step.mixer().update(deltaTime);+ }++ renderer.render(scene, camera);+};+animate();+clear_info_panel_message()++//////////////////////////////////+// EVENT LISTENERS+//////////////////////////////////++renderer.domElement.addEventListener('mousemove', (event) => {+ if(is_transform_controls_dragging)+ {+ handle_transform_controls_moving()+ }+});++renderer.domElement.addEventListener('mousedown', (event) => {++ // primary click is made for rotating around 3d scene+ const is_primary_button_click = event.button === 0;++ if(is_primary_button_click) { return; }+ if(edit_skeleton_step.skeleton()?.bones === undefined) { return }+++ // when we are done with skinned mesh, we shouldn't be editing transforms+ if(transformControls.enabled === false)+ {+ return+ }+++ // we will change which skeleton we do an intersection test with+ // depending on what step we are on. We are either moving the setup skeleton+ // or moving the bind pose skeleton+ let skeleton_to_test = null+ if ( process_step === ProcessStep.EditSkeleton)+ {+ skeleton_to_test = edit_skeleton_step.skeleton()+ }+ else if ( process_step === ProcessStep.AnimationsListing)+ {+ skeleton_to_test = weight_skin_step.skeleton()+ }++ const [closestBone, closestBoneIndex, closestDistance] = Utility.raycast_closest_bone_test(camera, event, skeleton_to_test)++ // only do selection if we are close+ // the orbit controls also have panning with alt-click, so we don't want to interfere with that+ if(closestDistance > 0.1)+ {+ return;+ }++ if (closestBone !== null)+ {+ transformControls.attach(closestBone);+ weight_skin_step.set_bone_index_to_test(closestBoneIndex);+ ui.dom_transform_controls_switch.style.display = 'flex';+ }+++ }, false);++transformControls.addEventListener('dragging-changed', function(event) {+ is_transform_controls_dragging = event.value; // monitor the dragging state for transform control+});++transformControls.addEventListener('dragging-changed', function (event) {+ controls.enabled = !event.value;+});++load_model_step.addEventListener('modelLoaded', (event) => {+ scene.add(load_model_step.model_mesh())+ process_step = process_step_changed(ProcessStep.LoadSkeleton)+})++load_skeleton_step.addEventListener('skeletonLoaded', (event) => {++ // pass in our loaded armature to the edit skeleton for further editing+ // keep a reference to our initial skeleton data in case we want to revert+ edit_skeleton_step.set_armature(load_skeleton_step.armature())++ regenerate_skeleton_helper(edit_skeleton_step.skeleton())++ process_step = process_step_changed(ProcessStep.EditSkeleton)+})+++//////////////////////////////////+// EVENT LISTENERS FOR UI ELEMENTS+//////////////////////////////////++ui.dom_bind_pose_button.addEventListener('click', () => {++ // make sure we have a valid bone position before we try to do any weighting+ // this test validates that bones are inside the mesh+ const passed_bone_skinning_test = test_bone_weighting_success()+ if(passed_bone_skinning_test)+ {+ process_step_changed(ProcessStep.BindPose)+ }++});++ui.dom_back_to_edit_skeleton_button.addEventListener('click', () => {++ // clear existing skinned mesh if it exists+ const existing_skinned_meshes = scene.children.filter((child) => child.name === 'Skinned Mesh');++ existing_skinned_meshes.forEach((existing_skinned_mesh) => {+ Utility.remove_object_with_children(existing_skinned_mesh);+ })++ debugging_visual_object = Utility.regenerate_debugging_scene(scene); // clear out the debugging scene++ process_step = process_step_changed(ProcessStep.EditSkeleton)++ regenerate_skeleton_helper(edit_skeleton_step.skeleton())++ load_model_step.model_mesh().visible = true; // show the unskinned mesh again++});+++ui.dom_transform_controls_switch.addEventListener('click', function(event)+{+ const targetElement = event.target;++ if(targetElement.value === undefined)+ {+ return; // half of events for this are returning null for some reason+ }++ if(targetElement.value === 'translation')+ {+ transformControls.setMode("translate");+ }+ else if(targetElement.value === 'rotation')+ {+ transformControls.setMode("rotate");+ }++});++// this is mostly useful after we bind the mesh so we can just see the final mesh+ui.dom_show_skeleton_checkbox.addEventListener('click', (event) => {+ skeleton_helper.visible = event.target.checked;+});++ui.dom_export_button.addEventListener('click', () => {++ const all_clips = animations_listing_step.animation_clips()+ file_export_step.set_animation_clips_to_export(all_clips)+ file_export_step.export(weight_skin_step.final_skinned_meshes(), 'exported-model');+});diff --git a/src/styles.css b/src/styles.cssnew file mode 100644index 0000000..dc50fac--- /dev/null+++ b/src/styles.css@@ -0,0 +1,227 @@+@import url('https://fonts.googleapis.com/css2?family=Jost&display=swap');++* {+ color: white;+ font-family: 'Jost', sans-serif;+ font-size: 15px;+ display: inline-block;+}+++#skinned-step-animation-export-options {+ position: fixed;+ top: 20px;+ right: 20px;+ background: #0b1822;+ padding: 1rem;+ width: 20rem;+ box-shadow: 1px 1px 8px 0px #000000bf;+ border: 1px dotted #5b8792;+}++#skinned-step-tools+{+ flex-direction: column;+ row-gap: 1rem;+}++++hr {+ border:1px solid #1f405a;+ width: 100%;+ margin: 0.3rem 0rem;+}++li{+ display: list-item;+ line-height: 135%;+ color: #c4c4c4;+ font-size: 13px;+}++body {+ background: #0d2525;+}++#tool-selection-group {++}++div {++ padding: 0.25rem;+}++input[type="number"] {+ padding: 0.5rem;+ border: 1px solid #878787;+ border-radius: 3px;+ background: none;+ width: 40px;+}++/* used for animation play options */+button.secondary-button {+ background: #657a7638;+ border-radius: 3px;+ border-width: 2px;+ cursor: pointer;+ transition: all 0.2s ease-in-out;+}+button.secondary-button:hover {+ background: #657a7638;+ transform: scale(1.02);+}+++button, .button {+ background: linear-gradient(0deg, rgba(87,119,119,1) 0%, rgba(32,105,99,1) 98%);+ padding: 0.5rem 1.0rem;+ margin-right: 0.5rem;+ border: 1px solid #85c4a3;+ border-radius: 0.25rem;+ cursor: pointer;+ text-align: center; /* useful for custom file upload label */+}+button:hover, .button:hover {+ background: linear-gradient(0deg, rgba(32,105,99,1) 0%, rgba(87,119,119,1) 98%);+ transform: scale(1.02);+}+++.button-icon-group {+ display: flex;+ align-items: end;+ justify-content: center;+ column-gap: 6px;+}++.transform-icons {+ width: 25px;+ height: 25px;+ padding: 0.4rem;+ border-radius: 4px;+ border: 1px solid #d3d6d6;+ cursor: pointer;+}++.transform-icons:hover {+ background: #408b7c3b;+}++canvas {+ /* take up entire screen */+ position: fixed;+ top: 0;+ left: 0;+ right: 0;+ bottom: 0;+ z-index: -1;+}++select {+ padding: 0.5rem;+ background: none;++ border: 1px solid #315978;+ border-radius: 4px;+}++option {+ background: rgb(25, 47, 54);++ border: none;+ border-radius: 0;+}++#current-step-index {+ font-size: 15px;+ background: white;+ background: linear-gradient(150deg, rgba(235,255,255,1) 3%, rgba(164,215,233,1) 100%);+ padding: 0.7rem;+ border-radius: 39px;+ color: black;+ width: 16px;+ text-align: center;+ font-weight: 700;+}++#current-step-label {+ font-size: 20px;+}++#info-panel+{+ background: #0000003d;+ overflow-y: auto;+ height: fit-content;+ bottom: 20px;+ position: absolute;+ display: flex;+ width: 300px;+ right: 20px;+ border-radius: 3px;+ border: 1px solid #3e4e51;+ max-height: calc(100% - 50px);+}+#info-messaging {+ padding: 0.5rem;+ font-size: 13px;+ color: #d0c8c8;+}++#load-model-tools, #load-skeleton-tools, #transform-controls, #skeleton-step-actions {+ display: flex;+ flex-direction: column;+ row-gap: 0.7rem;+}++#tool-panel {+ position: fixed;+ height: fit-content;+ background: #0b1822;+ box-shadow: 1px 1px 8px 0px #000000bf;+ top: 20px;+ left: 20px;+ bottom: 0;+ border: 1px dotted #5b8792;+ padding: 1rem;+}++#animations-listing {+ display: flex;+ flex-direction: column;+ width: 100%;+}++#animations-listing-header {+ justify-content: space-between;+ display: flex;+}+++++++#animations-items div {+ display: flex;+ justify-content: space-between;+}+/* have every other div child be a different background color */+#animations-items > div:nth-child(odd) {+ background: #32546f26;+}+++++.anim-item {+ display: flex;+ justify-content: space-between;+}++input[type="file"] {+ display: none;+}\ No newline at end of filediff --git a/static/.gitkeep b/static/.gitkeepnew file mode 100644index 0000000..e69de29diff --git a/static/animations/character-simple-multiple.glb b/static/animations/character-simple-multiple.glbnew file mode 100644index 0000000..5d92690Binary files /dev/null and b/static/animations/character-simple-multiple.glb differdiff --git a/static/animations/quad-creature-animations.glb b/static/animations/quad-creature-animations.glbnew file mode 100644index 0000000..d6b86f8Binary files /dev/null and b/static/animations/quad-creature-animations.glb differdiff --git a/static/blender/character.blend b/static/blender/character.blendnew file mode 100644index 0000000..249dc84Binary files /dev/null and b/static/blender/character.blend differdiff --git a/static/blender/fox.blend b/static/blender/fox.blendnew file mode 100644index 0000000..0d85704Binary files /dev/null and b/static/blender/fox.blend differdiff --git a/static/blender/mesh-x-bot.blend b/static/blender/mesh-x-bot.blendnew file mode 100644index 0000000..33655fbBinary files /dev/null and b/static/blender/mesh-x-bot.blend differdiff --git a/static/blender/multi-mesh-man.blend b/static/blender/multi-mesh-man.blendnew file mode 100644index 0000000..f4c64edBinary files /dev/null and b/static/blender/multi-mesh-man.blend differdiff --git a/static/blender/skeleton-mecanim-full.blend b/static/blender/skeleton-mecanim-full.blendnew file mode 100644index 0000000..3031baaBinary files /dev/null and b/static/blender/skeleton-mecanim-full.blend differdiff --git a/static/blender/skeleton-quad.blend b/static/blender/skeleton-quad.blendnew file mode 100644index 0000000..82d172eBinary files /dev/null and b/static/blender/skeleton-quad.blend differdiff --git a/static/gui-icons.svg b/static/gui-icons.svgnew file mode 100644index 0000000..4f82b71--- /dev/null+++ b/static/gui-icons.svg@@ -0,0 +1,139 @@+<?xml version="1.0" encoding="UTF-8" standalone="no"?>+<!-- Created with Inkscape (http://www.inkscape.org/) -->++<svg+ width="70mm"+ height="70mm"+ viewBox="0 0 70 70"+ version="1.1"+ id="svg5"+ xml:space="preserve"+ inkscape:version="1.2.2 (732a01da63, 2022-12-09)"+ sodipodi:docname="gui-icons.svg"+ inkscape:export-filename="icons\icon-scale.svg"+ inkscape:export-xdpi="96"+ inkscape:export-ydpi="96"+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"+ xmlns="http://www.w3.org/2000/svg"+ xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview+ id="namedview7"+ pagecolor="#505050"+ bordercolor="#eeeeee"+ borderopacity="1"+ inkscape:showpageshadow="0"+ inkscape:pageopacity="0"+ inkscape:pagecheckerboard="0"+ inkscape:deskcolor="#505050"+ inkscape:document-units="mm"+ showgrid="false"+ inkscape:zoom="0.53858859"+ inkscape:cx="218.16281"+ inkscape:cy="224.66128"+ inkscape:window-width="1920"+ inkscape:window-height="1009"+ inkscape:window-x="-8"+ inkscape:window-y="-8"+ inkscape:window-maximized="1"+ inkscape:current-layer="layer1" /><defs+ id="defs2" /><g+ inkscape:label="Layer 1"+ inkscape:groupmode="layer"+ id="layer1"><path+ style="fill:#3f3f3f;stroke:#898989;stroke-width:4.328;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"+ d="m 121.08744,-40.37624 20.62118,-20.32468"+ id="path380"+ sodipodi:nodetypes="cc" /><path+ style="fill:#3f3f3f;stroke:#898989;stroke-width:4.328;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"+ d="m 141.59042,-49.77887 0.20965,-10.28548"+ id="path380-5"+ sodipodi:nodetypes="cc" /><path+ style="fill:#3f3f3f;stroke:#898989;stroke-width:4.328;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"+ d="m 130.78029,-60.92147 10.28547,0.20965"+ id="path380-5-3"+ sodipodi:nodetypes="cc" /><path+ style="fill:#3f3f3f;stroke:#898989;stroke-width:4.328;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"+ d="m 125.08714,89.005193 10.26583,-0.66924"+ id="path380-5-0"+ sodipodi:nodetypes="cc" /><path+ style="fill:#3f3f3f;stroke:#898989;stroke-width:4.328;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"+ d="m 135.26614,77.283223 0.66924,10.26582"+ id="path380-5-3-0"+ sodipodi:nodetypes="cc" /><path+ style="fill:#3f3f3f;stroke:#898989;stroke-width:4.328;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"+ d="M 119.29714,19.159355 119.50681,1.9505812"+ id="path380-7"+ sodipodi:nodetypes="cc"+ inkscape:export-filename="icons\icon-transform.svg"+ inkscape:export-xdpi="96"+ inkscape:export-ydpi="96" /><path+ style="fill:#3f3f3f;stroke:#898989;stroke-width:4.328;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"+ d="m 127.14628,9.7572072 -7.12469,-7.421168"+ id="path380-5-38"+ sodipodi:nodetypes="cc" /><path+ style="fill:#3f3f3f;stroke:#898989;stroke-width:4.328;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"+ d="m 111.62336,9.5221272 7.42117,-7.124683"+ id="path380-5-3-2"+ sodipodi:nodetypes="cc" /><path+ style="fill:#3f3f3f;stroke:#898989;stroke-width:4.328;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"+ d="m 118.78718,45.942682 -0.20967,17.20877"+ id="path380-7-5"+ sodipodi:nodetypes="cc" /><path+ style="fill:#3f3f3f;stroke:#898989;stroke-width:4.328;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"+ d="m 110.93804,55.344822 7.12468,7.42117"+ id="path380-5-38-6"+ sodipodi:nodetypes="cc" /><path+ style="fill:#3f3f3f;stroke:#898989;stroke-width:4.328;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"+ d="m 126.46096,55.579902 -7.42117,7.12469"+ id="path380-5-3-2-88"+ sodipodi:nodetypes="cc" /><path+ style="fill:#3f3f3f;stroke:#898989;stroke-width:4.328;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"+ d="m 132.15301,32.575182 17.20877,0.20967"+ id="path380-7-3"+ sodipodi:nodetypes="cc" /><path+ style="fill:#3f3f3f;stroke:#898989;stroke-width:4.328;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"+ d="m 141.55516,40.424312 7.42116,-7.12468"+ id="path380-5-38-4"+ sodipodi:nodetypes="cc" /><path+ style="fill:#3f3f3f;stroke:#898989;stroke-width:4.328;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"+ d="m 141.79024,24.901402 7.12468,7.42117"+ id="path380-5-3-2-8"+ sodipodi:nodetypes="cc" /><path+ style="fill:#3f3f3f;stroke:#898989;stroke-width:4.328;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"+ d="M 104.55125,32.750522 87.34248,32.540852"+ id="path380-7-3-2"+ sodipodi:nodetypes="cc" /><path+ style="fill:#3f3f3f;stroke:#898989;stroke-width:4.328;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"+ d="m 95.149097,24.901392 -7.421157,7.12468"+ id="path380-5-38-4-9"+ sodipodi:nodetypes="cc" /><path+ style="fill:#3f3f3f;stroke:#898989;stroke-width:4.328;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"+ d="M 94.914017,40.424302 87.78934,33.003132"+ id="path380-5-3-2-8-2"+ sodipodi:nodetypes="cc" /><rect+ style="fill:none;stroke:#898989;stroke-width:4.3;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"+ id="rect1856"+ width="57.967869"+ height="58.090675"+ x="92.569916"+ y="-70.150459"+ ry="1.4933659" /><circle+ style="fill:none;stroke:#898989;stroke-width:3.228;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"+ id="path1910"+ cx="107.86018"+ cy="-26.244696"+ r="7.5530167" /><circle+ style="fill:none;stroke:#898989;stroke-width:3.228;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"+ id="path1910-8"+ cx="118.37503"+ cy="102.00654"+ r="7.5530167" /><circle+ style="fill:none;stroke:#898989;stroke-width:3.228;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"+ id="path1910-7"+ cx="118.86504"+ cy="31.791296"+ r="7.5530167" /><path+ style="fill:none;stroke:#898989;stroke-width:4.3;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"+ d="m 130.93203,118.64516 c 0,0 -5.36212,4.11511 -12.22066,4.11511 -12.84413,0 -21.82255,-9.10313 -21.82255,-22.820173 0,-9.227824 9.10312,-20.076764 22.57076,-20.076764 9.22784,0 13.46765,5.86092 15.71226,7.85613"+ id="path3592"+ sodipodi:nodetypes="csssc" /></g></svg>diff --git a/static/models/character.glb b/static/models/character.glbnew file mode 100644index 0000000..ad9f1c5Binary files /dev/null and b/static/models/character.glb differdiff --git a/static/models/character.png b/static/models/character.pngnew file mode 100644index 0000000..d58986eBinary files /dev/null and b/static/models/character.png differdiff --git a/static/models/fox.glb b/static/models/fox.glbnew file mode 100644index 0000000..9b9ad30Binary files /dev/null and b/static/models/fox.glb differdiff --git a/static/models/human-simple.glb b/static/models/human-simple.glbnew file mode 100644index 0000000..e44b560Binary files /dev/null and b/static/models/human-simple.glb differdiff --git a/static/models/mesh-x-bot.glb b/static/models/mesh-x-bot.glbnew file mode 100644index 0000000..afb2b35Binary files /dev/null and b/static/models/mesh-x-bot.glb differdiff --git a/static/models/multi-mesh-man.glb b/static/models/multi-mesh-man.glbnew file mode 100644index 0000000..517fd4dBinary files /dev/null and b/static/models/multi-mesh-man.glb differdiff --git a/static/models/sample-multi-mesh-skin.glb b/static/models/sample-multi-mesh-skin.glbnew file mode 100644index 0000000..6d45589Binary files /dev/null and b/static/models/sample-multi-mesh-skin.glb differdiff --git a/static/skeletons/skeleton-bipedal-simple.glb b/static/skeletons/skeleton-bipedal-simple.glbnew file mode 100644index 0000000..a2d2c40Binary files /dev/null and b/static/skeletons/skeleton-bipedal-simple.glb differdiff --git a/static/skeletons/skeleton-mecanim-full.glb b/static/skeletons/skeleton-mecanim-full.glbnew file mode 100644index 0000000..bd7aee5Binary files /dev/null and b/static/skeletons/skeleton-mecanim-full.glb differdiff --git a/static/skeletons/skeleton-quadraped.glb b/static/skeletons/skeleton-quadraped.glbnew file mode 100644index 0000000..da81305Binary files /dev/null and b/static/skeletons/skeleton-quadraped.glb differdiff --git a/vite.config.js b/vite.config.jsnew file mode 100644index 0000000..7e92244--- /dev/null+++ b/vite.config.js@@ -0,0 +1,25 @@+const isCodeSandbox = 'SANDBOX_URL' in process.env || 'CODESANDBOX_HOST' in process.env++// allows us to use external shaders files to be imported into our materials+import glsl from 'vite-plugin-glsl'++export default {+ root: 'src/',+ publicDir: '../static/',+ base: './',+ server:+ {+ host: true,+ open: !isCodeSandbox // Open if it's not a CodeSandbox+ },+ build:+ {+ outDir: '../dist',+ emptyOutDir: true,+ sourcemap: true+ },+ plugins:+ [+ glsl()+ ]+}\ No newline at end of file