diff --git a/.gitignore b/.gitignore index 07e6e47..146078c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /node_modules +/public/build/ diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index bd82429..ebd1ecd 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,32 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -59,28 +95,32 @@ - + + + + + + + + + + diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..bdef820 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["svelte.svelte-vscode"] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..29bb3b1 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "svelte.enable-ts-plugin": true +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 2d14489..1957e6c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,49 +4,294 @@ "lockfileVersion": 1, "requires": true, "dependencies": { - "@haensl/log": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/@haensl/log/-/log-1.3.4.tgz", - "integrity": "sha512-6AZuT9NQVbl5Bh5FW31rN7IO7IctF4plPvENnUHFRCdBqPJ5+zJ3LzuXoRPy6ZHd4KSsbJP9sVU552BEppmIUg==", + "@babel/code-frame": { + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.13.tgz", + "integrity": "sha512-HV1Cm0Q3ZrpCR93tkWOYiuYIgLxZXZFVG2VgK+MBWjUqZTundupbfx2aXarXuw5Ko5aMcjtJgbSs4vUGBS5v6g==", + "dev": true, "requires": { - "chalk": "^4.1.0" + "@babel/highlight": "^7.12.13" } }, + "@babel/helper-validator-identifier": { + "version": "7.14.0", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.0.tgz", + "integrity": "sha512-V3ts7zMSu5lfiwWDVWzRDGIN+lnCEUdaXgtVHJgLb1rGaA6jMrtB9EmE7L18foXJIE8Un/A/h6NJfGQp/e1J4A==", + "dev": true + }, + "@babel/highlight": { + "version": "7.14.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.14.0.tgz", + "integrity": "sha512-YSCOwxvTYEIMSGaBQb5kDDsCopDdiUGsqpatp3fOlI4+2HQSkTmEVWnVuySdAC5EWCqSWWTv0ib63RjR7dTBdg==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.14.0", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "@polka/url": { + "version": "1.0.0-next.12", + "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.12.tgz", + "integrity": "sha512-6RglhutqrGFMO1MNUXp95RBuYIuc8wTnMAV5MUhLmjTOy78ncwOw7RgeQ/HeymkKXRhZd0s2DNrM1rL7unk3MQ==" + }, + "@rollup/plugin-commonjs": { + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-17.1.0.tgz", + "integrity": "sha512-PoMdXCw0ZyvjpCMT5aV4nkL0QywxP29sODQsSGeDpr/oI49Qq9tRtAsb/LbYbDzFlOydVEqHmmZWFtXJEAX9ew==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^3.1.0", + "commondir": "^1.0.1", + "estree-walker": "^2.0.1", + "glob": "^7.1.6", + "is-reference": "^1.2.1", + "magic-string": "^0.25.7", + "resolve": "^1.17.0" + } + }, + "@rollup/plugin-node-resolve": { + "version": "11.2.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.1.tgz", + "integrity": "sha512-yc2n43jcqVyGE2sqV5/YCmocy9ArjVAP/BeXyTtADTBBX6V0e5UMqwO8CdQ0kzjb6zu5P1qMzsScCMRvE9OlVg==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^3.1.0", + "@types/resolve": "1.17.1", + "builtin-modules": "^3.1.0", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.19.0" + } + }, + "@rollup/plugin-typescript": { + "version": "8.2.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-8.2.1.tgz", + "integrity": "sha512-Qd2E1pleDR4bwyFxqbjt4eJf+wB0UKVMLc7/BAFDGVdAXQMCsD4DUv5/7/ww47BZCYxWtJqe1Lo0KVNswBJlRw==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^3.1.0", + "resolve": "^1.17.0" + } + }, + "@rollup/pluginutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", + "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", + "dev": true, + "requires": { + "@types/estree": "0.0.39", + "estree-walker": "^1.0.1", + "picomatch": "^2.2.2" + }, + "dependencies": { + "estree-walker": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", + "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", + "dev": true + } + } + }, + "@tsconfig/svelte": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@tsconfig/svelte/-/svelte-1.0.10.tgz", + "integrity": "sha512-EBrpH2iXXfaf/9z81koiDYkp2mlwW2XzFcAqn6qh7VKyP8zBvHHAQzNhY+W9vH5arAjmGAm5g8ElWq6YmXm3ig==", + "dev": true + }, + "@types/estree": { + "version": "0.0.39", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", + "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", + "dev": true + }, + "@types/node": { + "version": "15.6.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-15.6.0.tgz", + "integrity": "sha512-gCYSfQpy+LYhOFTKAeE8BkyGqaxmlFxe+n4DKM6DR0wzw/HISUE/hAmkC/KT8Sw5PCJblqg062b3z9gucv3k0A==", + "dev": true + }, + "@types/pug": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@types/pug/-/pug-2.0.4.tgz", + "integrity": "sha1-h3L80EGOPNLMFxVV1zAHQVBR9LI=", + "dev": true + }, + "@types/resolve": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", + "integrity": "sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@types/sass": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/@types/sass/-/sass-1.16.0.tgz", + "integrity": "sha512-2XZovu4NwcqmtZtsBR5XYLw18T8cBCnU2USFHTnYLLHz9fkhnoEMoDsqShJIOFsFhn5aJHjweiUUdTrDGujegA==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@types/three": { + "version": "0.128.0", + "resolved": "https://registry.npmjs.org/@types/three/-/three-0.128.0.tgz", + "integrity": "sha512-Jwq5XYUkzAcPTo34hlGAQGUyAI0b2F3aCCFWG/v7ZhJBEG5HGcusMSr70GhDlT8Gs0f02QnSPZ2RCA1MrCOa/w==", + "dev": true + }, "ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, "requires": { "color-convert": "^2.0.1" } }, + "anymatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", + "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "dev": true, + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, "balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "dev": true }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "dev": true + }, + "builtin-modules": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.2.0.tgz", + "integrity": "sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==", + "dev": true + }, + "callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true + }, "chalk": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", + "dev": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" } }, + "chokidar": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.1.tgz", + "integrity": "sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw==", + "dev": true, + "requires": { + "anymatch": "~3.1.1", + "braces": "~3.0.2", + "fsevents": "~2.3.1", + "glob-parent": "~5.1.0", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.5.0" + } + }, "color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, "requires": { "color-name": "~1.1.4" } @@ -54,22 +299,94 @@ "color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, + "commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", + "dev": true }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "console-clear": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/console-clear/-/console-clear-1.1.1.tgz", + "integrity": "sha512-pMD+MVR538ipqkG5JXeOEbKWS5um1H4LUUccUQG68qpeqBYbzYy79Gh55jkd2TtPdRfUaLWdv6LPP//5Zt0aPQ==" + }, + "deepmerge": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", + "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", + "dev": true + }, + "detect-indent": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.0.0.tgz", + "integrity": "sha512-oSyFlqaTHCItVRGK5RmrmjB+CmaMOW7IaNA/kdxqhoa6d17j/5ce9O9eWXmV/KEdRwqpQA+Vqe8a8Bsybu4YnA==", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "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==", + "dev": true + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "optional": true + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "get-port": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/get-port/-/get-port-3.2.0.tgz", + "integrity": "sha1-3Xzn3hh8Bsi/NTeWrHHgmfCYDrw=" }, "glob": { "version": "7.1.7", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -79,15 +396,45 @@ "path-is-absolute": "^1.0.0" } }, + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, "has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + } }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, "requires": { "once": "^1.3.0", "wrappy": "1" @@ -96,62 +443,513 @@ "inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true }, - "js-profiler": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/js-profiler/-/js-profiler-2.4.2.tgz", - "integrity": "sha512-wbOwWUQKYjJJEym2z+OkpApFaIjUv9CKNPHGMTe/UkGz5lLYy1PrDCzH0goR0ocEWjFCew+nYgk9ioVHob9Bmw==", + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, "requires": { - "@haensl/log": "^1.2.2", - "chalk": "^4.1.0", - "glob": "^7.1.6", - "node-getopt": "^0.3.2" + "binary-extensions": "^2.0.0" } }, + "is-core-module": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.4.0.tgz", + "integrity": "sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", + "dev": true + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "is-reference": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", + "dev": true, + "requires": { + "@types/estree": "*" + } + }, + "jest-worker": { + "version": "26.6.2", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-26.6.2.tgz", + "integrity": "sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==", + "dev": true, + "requires": { + "@types/node": "*", + "merge-stream": "^2.0.0", + "supports-color": "^7.0.0" + } + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==" + }, + "livereload": { + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/livereload/-/livereload-0.9.3.tgz", + "integrity": "sha512-q7Z71n3i4X0R9xthAryBdNGVGAO2R5X+/xXpmKeuPMrteg+W2U8VusTKV3YiJbXZwKsOlFlHe+go6uSNjfxrZw==", + "dev": true, + "requires": { + "chokidar": "^3.5.0", + "livereload-js": "^3.3.1", + "opts": ">= 1.2.0", + "ws": "^7.4.3" + } + }, + "livereload-js": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/livereload-js/-/livereload-js-3.3.2.tgz", + "integrity": "sha512-w677WnINxFkuixAoUEXOStewzLYGI76XVag+0JWMMEyjJQKs0ibWZMxkTlB96Lm3EjZ7IeOxVziBEbtxVQqQZA==", + "dev": true + }, + "local-access": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/local-access/-/local-access-1.1.0.tgz", + "integrity": "sha512-XfegD5pyTAfb+GY6chk283Ox5z8WexG56OvM06RWLpAc/UHozO8X6xAxEkIitZOtsSMM1Yr3DkHgW5W+onLhCw==" + }, + "magic-string": { + "version": "0.25.7", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz", + "integrity": "sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==", + "dev": true, + "requires": { + "sourcemap-codec": "^1.4.4" + } + }, + "merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true + }, + "mime": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.5.2.tgz", + "integrity": "sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg==" + }, + "min-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", + "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", + "dev": true + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, "requires": { "brace-expansion": "^1.1.7" } }, - "node-getopt": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/node-getopt/-/node-getopt-0.3.2.tgz", - "integrity": "sha512-yqkmYrMbK1wPrfz7mgeYvA4tBperLg9FQ4S3Sau3nSAkpOA0x0zC8nQ1siBwozy1f4SE8vq2n1WKv99r+PCa1Q==" + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "mri": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/mri/-/mri-1.1.6.tgz", + "integrity": "sha512-oi1b3MfbyGa7FJMP9GmLTttni5JoICpYBRlq+x5V16fZbLsnL9N3wFqqIm/nIG43FjUFkFh9Epzp/kzUGUnJxQ==" + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, "requires": { "wrappy": "1" } }, + "opts": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/opts/-/opts-2.0.2.tgz", + "integrity": "sha512-k41FwbcLnlgnFh69f4qdUfvDQ+5vaSDnVPFI/y5XuhKRq97EnVVneO9F1ESVCdiVu4fCS2L8usX3mU331hB7pg==", + "dev": true + }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, + "picomatch": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", + "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", + "dev": true + }, + "randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "requires": { + "safe-buffer": "^5.1.0" + } + }, + "readdirp": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz", + "integrity": "sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ==", + "dev": true, + "requires": { + "picomatch": "^2.2.1" + } + }, + "require-relative": { + "version": "0.8.7", + "resolved": "https://registry.npmjs.org/require-relative/-/require-relative-0.8.7.tgz", + "integrity": "sha1-eZlTn8ngR6N5KPoZb44VY9q9Nt4=", + "dev": true + }, + "resolve": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", + "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "dev": true, + "requires": { + "is-core-module": "^2.2.0", + "path-parse": "^1.0.6" + } + }, + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true + }, + "rollup": { + "version": "2.49.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.49.0.tgz", + "integrity": "sha512-UnrCjMXICx9q0jF8L7OYs7LPk95dW0U5UYp/VANnWqfuhyr66FWi/YVlI34Oy8Tp4ZGLcaUDt4APJm80b9oPWQ==", + "dev": true, + "requires": { + "fsevents": "~2.3.1" + } + }, + "rollup-plugin-css-only": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-css-only/-/rollup-plugin-css-only-3.1.0.tgz", + "integrity": "sha512-TYMOE5uoD76vpj+RTkQLzC9cQtbnJNktHPB507FzRWBVaofg7KhIqq1kGbcVOadARSozWF883Ho9KpSPKH8gqA==", + "dev": true, + "requires": { + "@rollup/pluginutils": "4" + }, + "dependencies": { + "@rollup/pluginutils": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.1.0.tgz", + "integrity": "sha512-TrBhfJkFxA+ER+ew2U2/fHbebhLT/l/2pRk0hfj9KusXUuRXd2v0R58AfaZK9VXDQ4TogOSEmICVrQAA3zFnHQ==", + "dev": true, + "requires": { + "estree-walker": "^2.0.1", + "picomatch": "^2.2.2" + } + } + } + }, + "rollup-plugin-livereload": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-livereload/-/rollup-plugin-livereload-2.0.0.tgz", + "integrity": "sha512-oC/8NqumGYuphkqrfszOHUUIwzKsaHBICw6QRwT5uD07gvePTS+HW+GFwu6f9K8W02CUuTvtIM9AWJrbj4wE1A==", + "dev": true, + "requires": { + "livereload": "^0.9.1" + } + }, + "rollup-plugin-svelte": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-svelte/-/rollup-plugin-svelte-7.1.0.tgz", + "integrity": "sha512-vopCUq3G+25sKjwF5VilIbiY6KCuMNHP1PFvx2Vr3REBNMDllKHFZN2B9jwwC+MqNc3UPKkjXnceLPEjTjXGXg==", + "dev": true, + "requires": { + "require-relative": "^0.8.7", + "rollup-pluginutils": "^2.8.2" + } + }, + "rollup-plugin-terser": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz", + "integrity": "sha512-w3iIaU4OxcF52UUXiZNsNeuXIMDvFrr+ZXK6bFZ0Q60qyVfq4uLptoS4bbq3paG3x216eQllFZX7zt6TIImguQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.10.4", + "jest-worker": "^26.2.1", + "serialize-javascript": "^4.0.0", + "terser": "^5.0.0" + } + }, + "rollup-pluginutils": { + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", + "integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==", + "dev": true, + "requires": { + "estree-walker": "^0.6.1" + }, + "dependencies": { + "estree-walker": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", + "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", + "dev": true + } + } + }, + "sade": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/sade/-/sade-1.7.4.tgz", + "integrity": "sha512-y5yauMD93rX840MwUJr7C1ysLFBgMspsdTo4UVrDg3fXDvtwOyIqykhVAAm6fk/3au77773itJStObgK+LKaiA==", + "requires": { + "mri": "^1.1.0" + } + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true + }, + "semiver": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/semiver/-/semiver-1.1.0.tgz", + "integrity": "sha512-QNI2ChmuioGC1/xjyYwyZYADILWyW6AmS1UH6gDj/SFUUUS4MBAWs/7mxnkRPc/F4iHezDP+O8t0dO8WHiEOdg==" + }, + "serialize-javascript": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz", + "integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==", + "dev": true, + "requires": { + "randombytes": "^2.1.0" + } + }, + "sirv": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/sirv/-/sirv-1.0.11.tgz", + "integrity": "sha512-SR36i3/LSWja7AJNRBz4fF/Xjpn7lQFI30tZ434dIy+bitLYSP+ZEenHg36i23V2SGEz+kqjksg0uOGZ5LPiqg==", + "requires": { + "@polka/url": "^1.0.0-next.9", + "mime": "^2.3.1", + "totalist": "^1.0.0" + } + }, + "sirv-cli": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/sirv-cli/-/sirv-cli-1.0.11.tgz", + "integrity": "sha512-L8NILoRSBd38VcfFcERYCaVCnWPBLo9G6u/a37UJ8Ysv4DfjizMbFBcM+SswNnndJienhR6qy8KFuAEaeL4g8Q==", + "requires": { + "console-clear": "^1.1.0", + "get-port": "^3.2.0", + "kleur": "^3.0.0", + "local-access": "^1.0.1", + "sade": "^1.6.0", + "semiver": "^1.0.0", + "sirv": "^1.0.11", + "tinydate": "^1.0.0" + } + }, + "source-map": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", + "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", + "dev": true + }, + "source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, + "sourcemap-codec": { + "version": "1.4.8", + "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", + "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", + "dev": true + }, + "strip-indent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", + "integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==", + "dev": true, + "requires": { + "min-indent": "^1.0.0" + } }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, "requires": { "has-flag": "^4.0.0" } }, + "svelte": { + "version": "3.38.2", + "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.38.2.tgz", + "integrity": "sha512-q5Dq0/QHh4BLJyEVWGe7Cej5NWs040LWjMbicBGZ+3qpFWJ1YObRmUDZKbbovddLC9WW7THTj3kYbTOFmU9fbg==", + "dev": true + }, + "svelte-check": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-1.5.4.tgz", + "integrity": "sha512-0rnBT2uqgYQeVsLJYZqAjkZn0k2TiphbOv7p602QmRMPT5VqFrkAaomZm5l4K3coxGSJlC0tDEVCKCQJ6i2jqw==", + "dev": true, + "requires": { + "chalk": "^4.0.0", + "chokidar": "^3.4.1", + "glob": "^7.1.6", + "import-fresh": "^3.2.1", + "minimist": "^1.2.5", + "source-map": "^0.7.3", + "svelte-preprocess": "^4.0.0", + "typescript": "*" + } + }, + "svelte-preprocess": { + "version": "4.7.3", + "resolved": "https://registry.npmjs.org/svelte-preprocess/-/svelte-preprocess-4.7.3.tgz", + "integrity": "sha512-Zx1/xLeGOIBlZMGPRCaXtlMe4ZA0faato5Dc3CosEqwu75MIEPuOstdkH6cy+RYTUYynoxzNaDxkPX4DbrPwRA==", + "dev": true, + "requires": { + "@types/pug": "^2.0.4", + "@types/sass": "^1.16.0", + "detect-indent": "^6.0.0", + "strip-indent": "^3.0.0" + } + }, + "terser": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.7.0.tgz", + "integrity": "sha512-HP5/9hp2UaZt5fYkuhNBR8YyRcT8juw8+uFbAme53iN9hblvKnLUTKkmwJG6ocWpIKf8UK4DoeWG4ty0J6S6/g==", + "dev": true, + "requires": { + "commander": "^2.20.0", + "source-map": "~0.7.2", + "source-map-support": "~0.5.19" + } + }, + "three": { + "version": "0.128.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.128.0.tgz", + "integrity": "sha512-i0ap/E+OaSfzw7bD1TtYnPo3VEplkl70WX5fZqZnfZsE3k3aSFudqrrC9ldFZfYFkn1zwDmBcdGfiIm/hnbyZA==" + }, + "tinydate": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/tinydate/-/tinydate-1.3.0.tgz", + "integrity": "sha512-7cR8rLy2QhYHpsBDBVYnnWXm8uRTr38RoZakFSW7Bs7PzfMPNZthuMLkwqZv7MTu8lhQ91cOFYS5a7iFj2oR3w==" + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + }, + "totalist": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-1.1.0.tgz", + "integrity": "sha512-gduQwd1rOdDMGxFG1gEvhV88Oirdo2p+KjoYFU7k2g+i7n6AFFbDQ5kMPUsW0pNbfQsB/cwXvT1i4Bue0s9g5g==" + }, + "tslib": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.2.0.tgz", + "integrity": "sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w==", + "dev": true + }, "typescript": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz", - "integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==" + "integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==", + "dev": true }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "ws": { + "version": "7.4.5", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.5.tgz", + "integrity": "sha512-xzyu3hFvomRfXKH8vOFMU3OguG6oOvhXMo3xsGy3xWExqaM2dxBbVxuD99O7m3ZUFMvvscsZDqxfgMaRr/Nr1g==", + "dev": true } } } diff --git a/package.json b/package.json index c4b2445..49d35bd 100644 --- a/package.json +++ b/package.json @@ -3,13 +3,32 @@ "version": "1.0.0", "description": "Custom Somaesque cube solver webapp", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "start": "deno run ./src/main.ts" + "build": "rollup -c", + "dev": "rollup -c -w", + "start": "sirv public --no-clear", + "validate": "svelte-check" }, "author": "Daniel Ledda", "license": "ISC", + "devDependencies": { + "@rollup/plugin-commonjs": "^17.0.0", + "@rollup/plugin-node-resolve": "^11.0.0", + "@rollup/plugin-typescript": "^8.0.0", + "@tsconfig/svelte": "^1.0.0", + "@types/three": "^0.128.0", + "rollup": "^2.3.4", + "rollup-plugin-css-only": "^3.1.0", + "rollup-plugin-livereload": "^2.0.0", + "rollup-plugin-svelte": "^7.0.0", + "rollup-plugin-terser": "^7.0.0", + "svelte": "^3.0.0", + "svelte-check": "^1.0.0", + "svelte-preprocess": "^4.0.0", + "tslib": "^2.0.0", + "typescript": "^4.0.0" + }, "dependencies": { - "js-profiler": "^2.4.2", - "typescript": "^4.2.4" + "sirv-cli": "^1.0.0", + "three": "^0.128.0" } } diff --git a/public/favicon.png b/public/favicon.png new file mode 100644 index 0000000..7e6f5eb Binary files /dev/null and b/public/favicon.png differ diff --git a/public/global.css b/public/global.css new file mode 100644 index 0000000..76424a8 --- /dev/null +++ b/public/global.css @@ -0,0 +1,65 @@ +html, body { + position: relative; + width: 100%; + height: 100%; +} + +* { + box-sizing: border-box; +} + +body { + color: #333; + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; +} + +a { + color: rgb(0,100,200); + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +a:visited { + color: rgb(0,80,160); +} + +label { + display: block; +} + +input, button, select, textarea { + font-family: inherit; + font-size: inherit; + -webkit-padding: 0.4em 0; + padding: 0.4em; + margin: 0 0 0.5em 0; + box-sizing: border-box; + border: 1px solid #ccc; + border-radius: 2px; +} + +input:disabled { + color: #ccc; +} + +button { + color: #333; + background-color: #f4f4f4; + outline: none; +} + +button:disabled { + color: #999; +} + +button:not(:disabled):active { + background-color: #ddd; +} + +button:focus { + border-color: #666; +} diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..5da7ed3 --- /dev/null +++ b/public/index.html @@ -0,0 +1,18 @@ + + + + + + + Svelte app + + + + + + + + + + + diff --git a/report.20210524.173340.100206.0.001.json b/report.20210524.173340.100206.0.001.json new file mode 100644 index 0000000..54a64d6 --- /dev/null +++ b/report.20210524.173340.100206.0.001.json @@ -0,0 +1,571 @@ + +{ + "header": { + "reportVersion": 1, + "event": "Allocation failed - JavaScript heap out of memory", + "trigger": "FatalError", + "filename": "report.20210524.173340.100206.0.001.json", + "dumpEventTime": "2021-05-24T17:33:40Z", + "dumpEventTimeStamp": "1621870420290", + "processId": 100206, + "cwd": "/home/ledda/Documents/Projects/soma", + "commandLine": [ + "node", + "/home/ledda/Documents/Projects/soma/node_modules/.bin/rollup", + "-c", + "-w" + ], + "nodejsVersion": "v12.16.1", + "glibcVersionRuntime": "2.31", + "glibcVersionCompiler": "2.17", + "wordSize": 64, + "arch": "x64", + "platform": "linux", + "componentVersions": { + "node": "12.16.1", + "v8": "7.8.279.23-node.31", + "uv": "1.34.0", + "zlib": "1.2.11", + "brotli": "1.0.7", + "ares": "1.15.0", + "modules": "72", + "nghttp2": "1.40.0", + "napi": "5", + "llhttp": "2.0.4", + "http_parser": "2.9.3", + "openssl": "1.1.1d", + "cldr": "35.1", + "icu": "64.2", + "tz": "2019c", + "unicode": "12.1" + }, + "release": { + "name": "node", + "lts": "Erbium", + "headersUrl": "https://nodejs.org/download/release/v12.16.1/node-v12.16.1-headers.tar.gz", + "sourceUrl": "https://nodejs.org/download/release/v12.16.1/node-v12.16.1.tar.gz" + }, + "osName": "Linux", + "osRelease": "5.4.0-58-generic", + "osVersion": "#64-Ubuntu SMP Wed Dec 9 08:16:25 UTC 2020", + "osMachine": "x86_64", + "cpus": [ + { + "model": "Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz", + "speed": 2078, + "user": 31121700, + "nice": 170300, + "sys": 6123700, + "idle": 260424700, + "irq": 0 + }, + { + "model": "Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz", + "speed": 2259, + "user": 30777600, + "nice": 83200, + "sys": 6365600, + "idle": 259562600, + "irq": 0 + }, + { + "model": "Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz", + "speed": 1990, + "user": 30976500, + "nice": 135000, + "sys": 6095200, + "idle": 260493900, + "irq": 0 + }, + { + "model": "Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz", + "speed": 2104, + "user": 30991200, + "nice": 209800, + "sys": 6189800, + "idle": 260145300, + "irq": 0 + } + ], + "networkInterfaces": [ + { + "name": "lo", + "internal": true, + "mac": "00:00:00:00:00:00", + "address": "127.0.0.1", + "netmask": "255.0.0.0", + "family": "IPv4" + }, + { + "name": "usb0", + "internal": false, + "mac": "6a:e0:73:63:43:6d", + "address": "192.168.42.208", + "netmask": "255.255.255.0", + "family": "IPv4" + }, + { + "name": "lo", + "internal": true, + "mac": "00:00:00:00:00:00", + "address": "::1", + "netmask": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", + "family": "IPv6", + "scopeid": 0 + }, + { + "name": "usb0", + "internal": false, + "mac": "6a:e0:73:63:43:6d", + "address": "fe80::e4ee:20d6:a77d:7424", + "netmask": "ffff:ffff:ffff:ffff::", + "family": "IPv6", + "scopeid": 3 + }, + { + "name": "is0", + "internal": false, + "mac": "c0:a8:2a:d0:00:00", + "address": "fe80::5efe:c0a8:2ad0", + "netmask": "ffff:ffff:ffff:ffff::", + "family": "IPv6", + "scopeid": 5 + } + ], + "host": "ledda-desktop" + }, + "javascriptStack": { + "message": "No stack.", + "stack": [ + "Unavailable." + ] + }, + "nativeStack": [ + { + "pc": "0x0000000000b278f5", + "symbol": "report::TriggerNodeReport(v8::Isolate*, node::Environment*, char const*, char const*, std::string const&, v8::Local) [node]" + }, + { + "pc": "0x00000000009f13ec", + "symbol": "node::OnFatalError(char const*, char const*) [node]" + }, + { + "pc": "0x0000000000b5da9e", + "symbol": "v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]" + }, + { + "pc": "0x0000000000b5de19", + "symbol": "v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]" + }, + { + "pc": "0x0000000000d0a765", + "symbol": " [node]" + }, + { + "pc": "0x0000000000d0adf6", + "symbol": "v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]" + }, + { + "pc": "0x0000000000d1760a", + "symbol": "v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]" + }, + { + "pc": "0x0000000000d18515", + "symbol": "v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]" + }, + { + "pc": "0x0000000000d1afcc", + "symbol": "v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]" + }, + { + "pc": "0x0000000000ce19bb", + "symbol": "v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]" + }, + { + "pc": "0x000000000102482c", + "symbol": "v8::internal::Runtime_AllocateInOldGeneration(int, unsigned long*, v8::internal::Isolate*) [node]" + }, + { + "pc": "0x00000000013a71b9", + "symbol": " [node]" + } + ], + "javascriptHeap": { + "totalMemory": 2157666304, + "totalCommittedMemory": 2151878616, + "usedMemory": 2143893656, + "availableMemory": 47815288, + "memoryLimit": 2197815296, + "heapSpaces": { + "read_only_space": { + "memorySize": 262144, + "committedMemory": 33088, + "capacity": 32808, + "used": 32808, + "available": 0 + }, + "new_space": { + "memorySize": 6291456, + "committedMemory": 947440, + "capacity": 3142368, + "used": 90128, + "available": 3052240 + }, + "old_space": { + "memorySize": 2078425088, + "committedMemory": 2078270944, + "capacity": 2074173168, + "used": 2072701480, + "available": 1471688 + }, + "code_space": { + "memorySize": 2789376, + "committedMemory": 2732704, + "capacity": 2164608, + "used": 2164608, + "available": 0 + }, + "map_space": { + "memorySize": 1576960, + "committedMemory": 1573160, + "capacity": 1012000, + "used": 1012000, + "available": 0 + }, + "large_object_space": { + "memorySize": 68001792, + "committedMemory": 68001792, + "capacity": 67632216, + "used": 67632216, + "available": 0 + }, + "code_large_object_space": { + "memorySize": 319488, + "committedMemory": 319488, + "capacity": 260416, + "used": 260416, + "available": 0 + }, + "new_large_object_space": { + "memorySize": 0, + "committedMemory": 0, + "capacity": 3142368, + "used": 0, + "available": 3142368 + } + } + }, + "resourceUsage": { + "userCpuSeconds": 528.903, + "kernelCpuSeconds": 24.0468, + "cpuConsumptionPercent": 21.9512, + "maxRss": 2266980352, + "pageFaults": { + "IORequired": 22, + "IONotRequired": 2423406 + }, + "fsActivity": { + "reads": 3008, + "writes": 255304 + } + }, + "uvthreadResourceUsage": { + "userCpuSeconds": 213.2, + "kernelCpuSeconds": 7.85018, + "cpuConsumptionPercent": 8.7753, + "fsActivity": { + "reads": 3008, + "writes": 0 + } + }, + "libuv": [ + ], + "environmentVariables": { + "GJS_DEBUG_TOPICS": "JS ERROR;JS LOG", + "LESSOPEN": "| /usr/bin/lesspipe %s", + "npm_package_devDependencies_rollup": "^2.3.4", + "npm_config_cache_lock_stale": "60000", + "npm_config_ham_it_up": "", + "npm_config_legacy_bundling": "", + "npm_config_sign_git_tag": "", + "LANGUAGE": "en", + "USER": "ledda", + "LC_TIME": "de_DE.UTF-8", + "npm_package_devDependencies__rollup_plugin_node_resolve": "^11.0.0", + "npm_config_user_agent": "npm/6.14.5 node/v12.16.1 linux x64", + "npm_config_always_auth": "", + "npm_package_devDependencies_rollup_plugin_css_only": "^3.1.0", + "npm_config_bin_links": "true", + "npm_config_key": "", + "SSH_AGENT_PID": "3025", + "XDG_SESSION_TYPE": "x11", + "GIT_ASKPASS": "/usr/share/code/resources/app/extensions/git/dist/askpass.sh", + "npm_config_allow_same_version": "", + "npm_config_description": "true", + "npm_config_fetch_retries": "2", + "npm_config_heading": "npm", + "npm_config_if_present": "", + "npm_config_init_version": "1.0.0", + "npm_config_user": "1000", + "npm_node_execpath": "/home/ledda/.nvm/versions/node/v12.16.1/bin/node", + "SHLVL": "1", + "npm_config_prefer_online": "", + "npm_config_noproxy": "", + "HOME": "/home/ledda", + "CHROME_DESKTOP": "code-url-handler.desktop", + "npm_config_force": "", + "TERM_PROGRAM_VERSION": "1.52.0", + "DESKTOP_SESSION": "ubuntu", + "NVM_BIN": "/home/ledda/.nvm/versions/node/v12.16.1/bin", + "npm_config_only": "", + "npm_config_read_only": "", + "NVM_INC": "/home/ledda/.nvm/versions/node/v12.16.1/include/node", + "GIO_LAUNCHED_DESKTOP_FILE": "/usr/share/applications/code.desktop", + "npm_package_devDependencies_svelte_preprocess": "^4.0.0", + "npm_package_dependencies_three": "^0.128.0", + "npm_config_cache_min": "10", + "npm_config_init_license": "ISC", + "GNOME_SHELL_SESSION_MODE": "ubuntu", + "GTK_MODULES": "gail:atk-bridge", + "VSCODE_GIT_ASKPASS_MAIN": "/usr/share/code/resources/app/extensions/git/dist/askpass-main.js", + "npm_package_devDependencies_svelte_check": "^1.0.0", + "npm_config_editor": "vi", + "npm_config_rollback": "true", + "npm_config_tag_version_prefix": "v", + "LC_MONETARY": "de_DE.UTF-8", + "VSCODE_GIT_ASKPASS_NODE": "/usr/share/code/code", + "MANAGERPID": "2840", + "npm_config_cache_max": "Infinity", + "npm_config_timing": "", + "npm_config_userconfig": "/home/ledda/.npmrc", + "DBUS_SESSION_BUS_ADDRESS": "unix:path=/run/user/1000/bus", + "npm_config_engine_strict": "", + "npm_config_init_author_name": "", + "npm_config_init_author_url": "", + "npm_config_preid": "", + "npm_config_tmp": "/tmp", + "COLORTERM": "truecolor", + "GIO_LAUNCHED_DESKTOP_FILE_PID": "77123", + "npm_package_description": "Custom Somaesque cube solver webapp", + "npm_package_devDependencies_typescript": "^4.0.0", + "npm_config_depth": "Infinity", + "npm_config_package_lock_only": "", + "npm_config_save_dev": "", + "npm_config_usage": "", + "NVM_DIR": "/home/ledda/.nvm", + "npm_config_metrics_registry": "https://registry.npmjs.org/", + "npm_config_cafile": "", + "npm_config_otp": "", + "npm_config_package_lock": "true", + "npm_config_progress": "true", + "npm_config_https_proxy": "", + "npm_config_save_prod": "", + "MANDATORY_PATH": "/usr/share/gconf/ubuntu.mandatory.path", + "IM_CONFIG_PHASE": "1", + "npm_package_scripts_dev": "rollup -c -w", + "npm_config_audit": "true", + "npm_config_cidr": "", + "npm_config_onload_script": "", + "npm_config_sso_type": "oauth", + "LOGNAME": "ledda", + "npm_config_rebuild_bundle": "true", + "npm_config_save_bundle": "", + "npm_config_shell": "/bin/bash", + "JOURNAL_STREAM": "9:51482", + "_": "/home/ledda/.nvm/versions/node/v12.16.1/bin/npm", + "npm_package_devDependencies__rollup_plugin_commonjs": "^17.0.0", + "npm_config_dry_run": "", + "npm_config_format_package_lock": "true", + "npm_config_prefix": "/home/ledda/.nvm/versions/node/v12.16.1", + "XDG_SESSION_CLASS": "user", + "DEFAULTS_PATH": "/usr/share/gconf/ubuntu.default.path", + "npm_config_scope": "", + "npm_config_browser": "", + "npm_config_cache_lock_wait": "10000", + "npm_config_ignore_prepublish": "", + "npm_config_registry": "https://registry.npmjs.org/", + "npm_config_save_optional": "", + "npm_config_searchopts": "", + "npm_config_versions": "", + "USERNAME": "ledda", + "TERM": "xterm-256color", + "npm_config_cache": "/home/ledda/.npm", + "npm_config_proxy": "", + "npm_config_send_metrics": "", + "GNOME_DESKTOP_SESSION_ID": "this-is-deprecated", + "npm_package_scripts_start": "sirv public --no-clear", + "npm_package_dependencies_sirv_cli": "^1.0.0", + "npm_config_global_style": "", + "npm_config_ignore_scripts": "", + "npm_config_version": "", + "WINDOWPATH": "2", + "npm_config_local_address": "", + "npm_config_viewer": "man", + "npm_config_node_gyp": "/home/ledda/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js", + "PATH": "/home/ledda/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/ledda/Documents/Projects/soma/node_modules/.bin:/home/ledda/.local/bin:/home/ledda/.nvm/versions/node/v12.16.1/bin:/usr/lib/jvm/java-1.11.0-openjdk-amd64/bin:/home/ledda/.local/bin:/usr/lib/jvm/java-1.11.0-openjdk-amd64/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/texlive/2020/bin/x86_64-linux:/home/ledda/.local/bin:/usr/local/texlive/2020/bin/x86_64-linux:/home/ledda/.local/bin:/usr/local/texlive/2020/bin/i386-linux:/home/ledda/.local/bin:/home/ledda/.local/bin:/usr/local/texlive/2020/bin/i386-linux", + "SESSION_MANAGER": "local/ledda-desktop:@/tmp/.ICE-unix/3074,unix/ledda-desktop:/tmp/.ICE-unix/3074", + "INVOCATION_ID": "930ec6cef1e44490b3814c04c1c8d766", + "PAPERSIZE": "a4", + "npm_package_name": "soma", + "npm_config_audit_level": "low", + "npm_config_prefer_offline": "", + "NODE": "/home/ledda/.nvm/versions/node/v12.16.1/bin/node", + "XDG_MENU_PREFIX": "gnome-", + "LC_ADDRESS": "de_DE.UTF-8", + "XDG_RUNTIME_DIR": "/run/user/1000", + "npm_package_devDependencies_rollup_plugin_svelte": "^7.0.0", + "npm_config_color": "true", + "npm_config_sign_git_commit": "", + "DISPLAY": ":0", + "npm_package_devDependencies__rollup_plugin_typescript": "^8.0.0", + "npm_config_fetch_retry_mintimeout": "10000", + "npm_config_maxsockets": "50", + "npm_config_offline": "", + "npm_config_sso_poll_frequency": "500", + "LANG": "en_US.UTF-8", + "XDG_CURRENT_DESKTOP": "Unity", + "LC_TELEPHONE": "de_DE.UTF-8", + "npm_package_devDependencies_rollup_plugin_terser": "^7.0.0", + "npm_config_umask": "0002", + "XMODIFIERS": "@im=ibus", + "XDG_SESSION_DESKTOP": "ubuntu", + "XAUTHORITY": "/run/user/1000/gdm/Xauthority", + "LS_COLORS": "rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:", + "VSCODE_GIT_IPC_HANDLE": "/run/user/1000/vscode-git-06d741d5d2.sock", + "TERM_PROGRAM": "vscode", + "npm_package_gitHead": "1c60c4f0d48d9df6f9ba4cf9014dd437e2eb2ec5", + "npm_config_fund": "true", + "npm_config_fetch_retry_maxtimeout": "60000", + "npm_config_loglevel": "notice", + "npm_config_logs_max": "10", + "npm_config_message": "%s", + "npm_lifecycle_script": "rollup -c -w", + "SSH_AUTH_SOCK": "/run/user/1000/keyring/ssh", + "ORIGINAL_XDG_CURRENT_DESKTOP": "ubuntu:GNOME", + "npm_package_devDependencies__tsconfig_svelte": "^1.0.0", + "npm_config_ca": "", + "npm_config_cert": "", + "npm_config_global": "", + "npm_config_link": "", + "SHELL": "/bin/bash", + "LC_NAME": "de_DE.UTF-8", + "npm_package_version": "1.0.0", + "npm_config_access": "", + "npm_config_also": "", + "npm_config_save": "true", + "npm_config_unicode": "true", + "npm_lifecycle_event": "dev", + "QT_ACCESSIBILITY": "1", + "GDMSESSION": "ubuntu", + "npm_package_scripts_build": "rollup -c", + "npm_package_devDependencies_svelte": "^3.0.0", + "npm_package_devDependencies_tslib": "^2.0.0", + "npm_config_argv": "{\"remain\":[],\"cooked\":[\"run\",\"dev\"],\"original\":[\"run\",\"dev\"]}", + "npm_config_before": "", + "npm_config_long": "", + "npm_config_production": "", + "npm_config_searchlimit": "20", + "npm_config_unsafe_perm": "true", + "npm_config_update_notifier": "true", + "LESSCLOSE": "/usr/bin/lesspipe %s %s", + "npm_config_auth_type": "legacy", + "npm_config_node_version": "12.16.1", + "npm_config_tag": "latest", + "LC_MEASUREMENT": "de_DE.UTF-8", + "npm_package_scripts_validate": "svelte-check", + "npm_config_git_tag_version": "true", + "npm_config_commit_hooks": "true", + "npm_config_script_shell": "", + "npm_config_shrinkwrap": "true", + "GPG_AGENT_INFO": "/run/user/1000/gnupg/S.gpg-agent:0:1", + "GJS_DEBUG_OUTPUT": "stderr", + "LC_IDENTIFICATION": "de_DE.UTF-8", + "npm_package_license": "ISC", + "npm_config_fetch_retry_factor": "10", + "npm_config_save_exact": "", + "npm_config_strict_ssl": "true", + "QT_IM_MODULE": "ibus", + "npm_config_dev": "", + "npm_config_globalconfig": "/home/ledda/.nvm/versions/node/v12.16.1/etc/npmrc", + "npm_config_init_module": "/home/ledda/.npm-init.js", + "npm_config_parseable": "", + "JAVA_HOME": "/usr/lib/jvm/java-1.11.0-openjdk-amd64", + "PWD": "/home/ledda/Documents/Projects/soma", + "npm_config_globalignorefile": "/home/ledda/.nvm/versions/node/v12.16.1/etc/npmignore", + "npm_execpath": "/home/ledda/.nvm/versions/node/v12.16.1/lib/node_modules/npm/bin/npm-cli.js", + "XDG_CONFIG_DIRS": "/etc/xdg/xdg-ubuntu:/etc/xdg", + "NVM_CD_FLAGS": "", + "XDG_DATA_DIRS": "/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop", + "npm_package_author_name": "Daniel Ledda", + "npm_config_cache_lock_retries": "10", + "npm_config_searchstaleness": "900", + "LC_NUMERIC": "de_DE.UTF-8", + "npm_config_node_options": "", + "npm_config_save_prefix": "^", + "npm_config_scripts_prepend_node_path": "warn-only", + "BOOST_LIBRARYDIR": "/usr/lib", + "LC_PAPER": "de_DE.UTF-8", + "npm_package_devDependencies__types_three": "^0.128.0", + "npm_package_devDependencies_rollup_plugin_livereload": "^2.0.0", + "npm_config_group": "1000", + "npm_config_init_author_email": "", + "npm_config_searchexclude": "", + "npm_config_git": "git", + "npm_config_optional": "true", + "npm_config_json": "", + "INIT_CWD": "/home/ledda/Documents/Projects/soma", + "ROLLUP_WATCH": "true" + }, + "userLimits": { + "core_file_size_blocks": { + "soft": 0, + "hard": "unlimited" + }, + "data_seg_size_kbytes": { + "soft": "unlimited", + "hard": "unlimited" + }, + "file_size_blocks": { + "soft": "unlimited", + "hard": "unlimited" + }, + "max_locked_memory_bytes": { + "soft": 67108864, + "hard": 67108864 + }, + "max_memory_size_kbytes": { + "soft": "unlimited", + "hard": "unlimited" + }, + "open_files": { + "soft": 1048576, + "hard": 1048576 + }, + "stack_size_bytes": { + "soft": 8388608, + "hard": "unlimited" + }, + "cpu_time_seconds": { + "soft": "unlimited", + "hard": "unlimited" + }, + "max_user_processes": { + "soft": 47649, + "hard": 47649 + }, + "virtual_memory_kbytes": { + "soft": "unlimited", + "hard": "unlimited" + } + }, + "sharedObjects": [ + "linux-vdso.so.1", + "/lib/x86_64-linux-gnu/libdl.so.2", + "/usr/lib/x86_64-linux-gnu/libstdc++.so.6", + "/lib/x86_64-linux-gnu/libm.so.6", + "/lib/x86_64-linux-gnu/libgcc_s.so.1", + "/lib/x86_64-linux-gnu/libpthread.so.0", + "/lib/x86_64-linux-gnu/libc.so.6", + "/lib64/ld-linux-x86-64.so.2" + ] +} \ No newline at end of file diff --git a/report.20210524.182447.107803.0.001.json b/report.20210524.182447.107803.0.001.json new file mode 100644 index 0000000..8a872b0 --- /dev/null +++ b/report.20210524.182447.107803.0.001.json @@ -0,0 +1,571 @@ + +{ + "header": { + "reportVersion": 1, + "event": "Allocation failed - JavaScript heap out of memory", + "trigger": "FatalError", + "filename": "report.20210524.182447.107803.0.001.json", + "dumpEventTime": "2021-05-24T18:24:47Z", + "dumpEventTimeStamp": "1621873487421", + "processId": 107803, + "cwd": "/home/ledda/Documents/Projects/soma", + "commandLine": [ + "node", + "/home/ledda/Documents/Projects/soma/node_modules/.bin/rollup", + "-c", + "-w" + ], + "nodejsVersion": "v12.16.1", + "glibcVersionRuntime": "2.31", + "glibcVersionCompiler": "2.17", + "wordSize": 64, + "arch": "x64", + "platform": "linux", + "componentVersions": { + "node": "12.16.1", + "v8": "7.8.279.23-node.31", + "uv": "1.34.0", + "zlib": "1.2.11", + "brotli": "1.0.7", + "ares": "1.15.0", + "modules": "72", + "nghttp2": "1.40.0", + "napi": "5", + "llhttp": "2.0.4", + "http_parser": "2.9.3", + "openssl": "1.1.1d", + "cldr": "35.1", + "icu": "64.2", + "tz": "2019c", + "unicode": "12.1" + }, + "release": { + "name": "node", + "lts": "Erbium", + "headersUrl": "https://nodejs.org/download/release/v12.16.1/node-v12.16.1-headers.tar.gz", + "sourceUrl": "https://nodejs.org/download/release/v12.16.1/node-v12.16.1.tar.gz" + }, + "osName": "Linux", + "osRelease": "5.4.0-58-generic", + "osVersion": "#64-Ubuntu SMP Wed Dec 9 08:16:25 UTC 2020", + "osMachine": "x86_64", + "cpus": [ + { + "model": "Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz", + "speed": 798, + "user": 38624500, + "nice": 170400, + "sys": 7120900, + "idle": 282258500, + "irq": 0 + }, + { + "model": "Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz", + "speed": 799, + "user": 37865900, + "nice": 83200, + "sys": 7606700, + "idle": 281427700, + "irq": 0 + }, + { + "model": "Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz", + "speed": 799, + "user": 38413400, + "nice": 135100, + "sys": 7095900, + "idle": 282373500, + "irq": 0 + }, + { + "model": "Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz", + "speed": 799, + "user": 38396500, + "nice": 209800, + "sys": 7252000, + "idle": 281929200, + "irq": 0 + } + ], + "networkInterfaces": [ + { + "name": "lo", + "internal": true, + "mac": "00:00:00:00:00:00", + "address": "127.0.0.1", + "netmask": "255.0.0.0", + "family": "IPv4" + }, + { + "name": "usb0", + "internal": false, + "mac": "6a:e0:73:63:43:6d", + "address": "192.168.42.208", + "netmask": "255.255.255.0", + "family": "IPv4" + }, + { + "name": "lo", + "internal": true, + "mac": "00:00:00:00:00:00", + "address": "::1", + "netmask": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", + "family": "IPv6", + "scopeid": 0 + }, + { + "name": "usb0", + "internal": false, + "mac": "6a:e0:73:63:43:6d", + "address": "fe80::e4ee:20d6:a77d:7424", + "netmask": "ffff:ffff:ffff:ffff::", + "family": "IPv6", + "scopeid": 3 + }, + { + "name": "is0", + "internal": false, + "mac": "c0:a8:2a:d0:00:00", + "address": "fe80::5efe:c0a8:2ad0", + "netmask": "ffff:ffff:ffff:ffff::", + "family": "IPv6", + "scopeid": 5 + } + ], + "host": "ledda-desktop" + }, + "javascriptStack": { + "message": "No stack.", + "stack": [ + "Unavailable." + ] + }, + "nativeStack": [ + { + "pc": "0x0000000000b278f5", + "symbol": "report::TriggerNodeReport(v8::Isolate*, node::Environment*, char const*, char const*, std::string const&, v8::Local) [node]" + }, + { + "pc": "0x00000000009f13ec", + "symbol": "node::OnFatalError(char const*, char const*) [node]" + }, + { + "pc": "0x0000000000b5da9e", + "symbol": "v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]" + }, + { + "pc": "0x0000000000b5de19", + "symbol": "v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]" + }, + { + "pc": "0x0000000000d0a765", + "symbol": " [node]" + }, + { + "pc": "0x0000000000d0adf6", + "symbol": "v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]" + }, + { + "pc": "0x0000000000d1760a", + "symbol": "v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]" + }, + { + "pc": "0x0000000000d18515", + "symbol": "v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]" + }, + { + "pc": "0x0000000000d1afcc", + "symbol": "v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]" + }, + { + "pc": "0x0000000000ce19bb", + "symbol": "v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]" + }, + { + "pc": "0x00000000010246ce", + "symbol": "v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]" + }, + { + "pc": "0x00000000013a71b9", + "symbol": " [node]" + } + ], + "javascriptHeap": { + "totalMemory": 2157629440, + "totalCommittedMemory": 2151008656, + "usedMemory": 2141505488, + "availableMemory": 50475080, + "memoryLimit": 2197815296, + "heapSpaces": { + "read_only_space": { + "memorySize": 262144, + "committedMemory": 33088, + "capacity": 32808, + "used": 32808, + "available": 0 + }, + "new_space": { + "memorySize": 8388608, + "committedMemory": 2822400, + "capacity": 4189824, + "used": 946176, + "available": 3243648 + }, + "old_space": { + "memorySize": 2078949376, + "committedMemory": 2078195528, + "capacity": 2074693408, + "used": 2071837656, + "available": 2855752 + }, + "code_space": { + "memorySize": 2527232, + "committedMemory": 2459360, + "capacity": 2163968, + "used": 2163968, + "available": 0 + }, + "map_space": { + "memorySize": 1576960, + "committedMemory": 1573160, + "capacity": 1019840, + "used": 1019840, + "available": 0 + }, + "large_object_space": { + "memorySize": 65605632, + "committedMemory": 65605632, + "capacity": 65244624, + "used": 65244624, + "available": 0 + }, + "code_large_object_space": { + "memorySize": 319488, + "committedMemory": 319488, + "capacity": 260416, + "used": 260416, + "available": 0 + }, + "new_large_object_space": { + "memorySize": 0, + "committedMemory": 0, + "capacity": 4189824, + "used": 0, + "available": 4189824 + } + } + }, + "resourceUsage": { + "userCpuSeconds": 697.026, + "kernelCpuSeconds": 30.8195, + "cpuConsumptionPercent": 24.053, + "maxRss": 2264485888, + "pageFaults": { + "IORequired": 0, + "IONotRequired": 2769524 + }, + "fsActivity": { + "reads": 0, + "writes": 251088 + } + }, + "uvthreadResourceUsage": { + "userCpuSeconds": 279.526, + "kernelCpuSeconds": 11.6456, + "cpuConsumptionPercent": 9.62231, + "fsActivity": { + "reads": 0, + "writes": 0 + } + }, + "libuv": [ + ], + "environmentVariables": { + "GJS_DEBUG_TOPICS": "JS ERROR;JS LOG", + "LESSOPEN": "| /usr/bin/lesspipe %s", + "npm_package_devDependencies_rollup": "^2.3.4", + "npm_config_cache_lock_stale": "60000", + "npm_config_ham_it_up": "", + "npm_config_legacy_bundling": "", + "npm_config_sign_git_tag": "", + "LANGUAGE": "en", + "USER": "ledda", + "LC_TIME": "de_DE.UTF-8", + "npm_package_devDependencies__rollup_plugin_node_resolve": "^11.0.0", + "npm_config_user_agent": "npm/6.14.5 node/v12.16.1 linux x64", + "npm_config_always_auth": "", + "npm_package_devDependencies_rollup_plugin_css_only": "^3.1.0", + "npm_config_bin_links": "true", + "npm_config_key": "", + "SSH_AGENT_PID": "3025", + "XDG_SESSION_TYPE": "x11", + "GIT_ASKPASS": "/usr/share/code/resources/app/extensions/git/dist/askpass.sh", + "npm_config_allow_same_version": "", + "npm_config_description": "true", + "npm_config_fetch_retries": "2", + "npm_config_heading": "npm", + "npm_config_if_present": "", + "npm_config_init_version": "1.0.0", + "npm_config_user": "1000", + "npm_node_execpath": "/home/ledda/.nvm/versions/node/v12.16.1/bin/node", + "SHLVL": "1", + "npm_config_prefer_online": "", + "npm_config_noproxy": "", + "HOME": "/home/ledda", + "CHROME_DESKTOP": "code-url-handler.desktop", + "npm_config_force": "", + "TERM_PROGRAM_VERSION": "1.52.0", + "DESKTOP_SESSION": "ubuntu", + "NVM_BIN": "/home/ledda/.nvm/versions/node/v12.16.1/bin", + "npm_config_only": "", + "npm_config_read_only": "", + "NVM_INC": "/home/ledda/.nvm/versions/node/v12.16.1/include/node", + "GIO_LAUNCHED_DESKTOP_FILE": "/usr/share/applications/code.desktop", + "npm_package_devDependencies_svelte_preprocess": "^4.0.0", + "npm_package_dependencies_three": "^0.128.0", + "npm_config_cache_min": "10", + "npm_config_init_license": "ISC", + "GNOME_SHELL_SESSION_MODE": "ubuntu", + "GTK_MODULES": "gail:atk-bridge", + "VSCODE_GIT_ASKPASS_MAIN": "/usr/share/code/resources/app/extensions/git/dist/askpass-main.js", + "npm_package_devDependencies_svelte_check": "^1.0.0", + "npm_config_editor": "vi", + "npm_config_rollback": "true", + "npm_config_tag_version_prefix": "v", + "LC_MONETARY": "de_DE.UTF-8", + "VSCODE_GIT_ASKPASS_NODE": "/usr/share/code/code", + "MANAGERPID": "2840", + "npm_config_cache_max": "Infinity", + "npm_config_timing": "", + "npm_config_userconfig": "/home/ledda/.npmrc", + "DBUS_SESSION_BUS_ADDRESS": "unix:path=/run/user/1000/bus", + "npm_config_engine_strict": "", + "npm_config_init_author_name": "", + "npm_config_init_author_url": "", + "npm_config_preid": "", + "npm_config_tmp": "/tmp", + "COLORTERM": "truecolor", + "GIO_LAUNCHED_DESKTOP_FILE_PID": "77123", + "npm_package_description": "Custom Somaesque cube solver webapp", + "npm_package_devDependencies_typescript": "^4.0.0", + "npm_config_depth": "Infinity", + "npm_config_package_lock_only": "", + "npm_config_save_dev": "", + "npm_config_usage": "", + "NVM_DIR": "/home/ledda/.nvm", + "npm_config_metrics_registry": "https://registry.npmjs.org/", + "npm_config_cafile": "", + "npm_config_otp": "", + "npm_config_package_lock": "true", + "npm_config_progress": "true", + "npm_config_https_proxy": "", + "npm_config_save_prod": "", + "MANDATORY_PATH": "/usr/share/gconf/ubuntu.mandatory.path", + "IM_CONFIG_PHASE": "1", + "npm_package_scripts_dev": "rollup -c -w", + "npm_config_audit": "true", + "npm_config_cidr": "", + "npm_config_onload_script": "", + "npm_config_sso_type": "oauth", + "LOGNAME": "ledda", + "npm_config_rebuild_bundle": "true", + "npm_config_save_bundle": "", + "npm_config_shell": "/bin/bash", + "JOURNAL_STREAM": "9:51482", + "_": "/home/ledda/.nvm/versions/node/v12.16.1/bin/npm", + "npm_package_devDependencies__rollup_plugin_commonjs": "^17.0.0", + "npm_config_dry_run": "", + "npm_config_format_package_lock": "true", + "npm_config_prefix": "/home/ledda/.nvm/versions/node/v12.16.1", + "XDG_SESSION_CLASS": "user", + "DEFAULTS_PATH": "/usr/share/gconf/ubuntu.default.path", + "npm_config_scope": "", + "npm_config_browser": "", + "npm_config_cache_lock_wait": "10000", + "npm_config_ignore_prepublish": "", + "npm_config_registry": "https://registry.npmjs.org/", + "npm_config_save_optional": "", + "npm_config_searchopts": "", + "npm_config_versions": "", + "USERNAME": "ledda", + "TERM": "xterm-256color", + "npm_config_cache": "/home/ledda/.npm", + "npm_config_proxy": "", + "npm_config_send_metrics": "", + "GNOME_DESKTOP_SESSION_ID": "this-is-deprecated", + "npm_package_scripts_start": "sirv public --no-clear", + "npm_package_dependencies_sirv_cli": "^1.0.0", + "npm_config_global_style": "", + "npm_config_ignore_scripts": "", + "npm_config_version": "", + "WINDOWPATH": "2", + "npm_config_local_address": "", + "npm_config_viewer": "man", + "npm_config_node_gyp": "/home/ledda/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js", + "PATH": "/home/ledda/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/ledda/Documents/Projects/soma/node_modules/.bin:/home/ledda/.local/bin:/home/ledda/.nvm/versions/node/v12.16.1/bin:/usr/lib/jvm/java-1.11.0-openjdk-amd64/bin:/home/ledda/.local/bin:/usr/lib/jvm/java-1.11.0-openjdk-amd64/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/texlive/2020/bin/x86_64-linux:/home/ledda/.local/bin:/usr/local/texlive/2020/bin/x86_64-linux:/home/ledda/.local/bin:/usr/local/texlive/2020/bin/i386-linux:/home/ledda/.local/bin:/home/ledda/.local/bin:/usr/local/texlive/2020/bin/i386-linux", + "SESSION_MANAGER": "local/ledda-desktop:@/tmp/.ICE-unix/3074,unix/ledda-desktop:/tmp/.ICE-unix/3074", + "INVOCATION_ID": "930ec6cef1e44490b3814c04c1c8d766", + "PAPERSIZE": "a4", + "npm_package_name": "soma", + "npm_config_audit_level": "low", + "npm_config_prefer_offline": "", + "NODE": "/home/ledda/.nvm/versions/node/v12.16.1/bin/node", + "XDG_MENU_PREFIX": "gnome-", + "LC_ADDRESS": "de_DE.UTF-8", + "XDG_RUNTIME_DIR": "/run/user/1000", + "npm_package_devDependencies_rollup_plugin_svelte": "^7.0.0", + "npm_config_color": "true", + "npm_config_sign_git_commit": "", + "DISPLAY": ":0", + "npm_package_devDependencies__rollup_plugin_typescript": "^8.0.0", + "npm_config_fetch_retry_mintimeout": "10000", + "npm_config_maxsockets": "50", + "npm_config_offline": "", + "npm_config_sso_poll_frequency": "500", + "LANG": "en_US.UTF-8", + "XDG_CURRENT_DESKTOP": "Unity", + "LC_TELEPHONE": "de_DE.UTF-8", + "npm_package_devDependencies_rollup_plugin_terser": "^7.0.0", + "npm_config_umask": "0002", + "XMODIFIERS": "@im=ibus", + "XDG_SESSION_DESKTOP": "ubuntu", + "XAUTHORITY": "/run/user/1000/gdm/Xauthority", + "LS_COLORS": "rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:", + "VSCODE_GIT_IPC_HANDLE": "/run/user/1000/vscode-git-06d741d5d2.sock", + "TERM_PROGRAM": "vscode", + "npm_package_gitHead": "1c60c4f0d48d9df6f9ba4cf9014dd437e2eb2ec5", + "npm_config_fund": "true", + "npm_config_fetch_retry_maxtimeout": "60000", + "npm_config_loglevel": "notice", + "npm_config_logs_max": "10", + "npm_config_message": "%s", + "npm_lifecycle_script": "rollup -c -w", + "SSH_AUTH_SOCK": "/run/user/1000/keyring/ssh", + "ORIGINAL_XDG_CURRENT_DESKTOP": "ubuntu:GNOME", + "npm_package_devDependencies__tsconfig_svelte": "^1.0.0", + "npm_config_ca": "", + "npm_config_cert": "", + "npm_config_global": "", + "npm_config_link": "", + "SHELL": "/bin/bash", + "LC_NAME": "de_DE.UTF-8", + "npm_package_version": "1.0.0", + "npm_config_access": "", + "npm_config_also": "", + "npm_config_save": "true", + "npm_config_unicode": "true", + "npm_lifecycle_event": "dev", + "QT_ACCESSIBILITY": "1", + "GDMSESSION": "ubuntu", + "npm_package_scripts_build": "rollup -c", + "npm_package_devDependencies_svelte": "^3.0.0", + "npm_package_devDependencies_tslib": "^2.0.0", + "npm_config_argv": "{\"remain\":[],\"cooked\":[\"run\",\"dev\"],\"original\":[\"run\",\"dev\"]}", + "npm_config_before": "", + "npm_config_long": "", + "npm_config_production": "", + "npm_config_searchlimit": "20", + "npm_config_unsafe_perm": "true", + "npm_config_update_notifier": "true", + "LESSCLOSE": "/usr/bin/lesspipe %s %s", + "npm_config_auth_type": "legacy", + "npm_config_node_version": "12.16.1", + "npm_config_tag": "latest", + "LC_MEASUREMENT": "de_DE.UTF-8", + "npm_package_scripts_validate": "svelte-check", + "npm_config_git_tag_version": "true", + "npm_config_commit_hooks": "true", + "npm_config_script_shell": "", + "npm_config_shrinkwrap": "true", + "GPG_AGENT_INFO": "/run/user/1000/gnupg/S.gpg-agent:0:1", + "GJS_DEBUG_OUTPUT": "stderr", + "LC_IDENTIFICATION": "de_DE.UTF-8", + "npm_package_license": "ISC", + "npm_config_fetch_retry_factor": "10", + "npm_config_save_exact": "", + "npm_config_strict_ssl": "true", + "QT_IM_MODULE": "ibus", + "npm_config_dev": "", + "npm_config_globalconfig": "/home/ledda/.nvm/versions/node/v12.16.1/etc/npmrc", + "npm_config_init_module": "/home/ledda/.npm-init.js", + "npm_config_parseable": "", + "JAVA_HOME": "/usr/lib/jvm/java-1.11.0-openjdk-amd64", + "PWD": "/home/ledda/Documents/Projects/soma", + "npm_config_globalignorefile": "/home/ledda/.nvm/versions/node/v12.16.1/etc/npmignore", + "npm_execpath": "/home/ledda/.nvm/versions/node/v12.16.1/lib/node_modules/npm/bin/npm-cli.js", + "XDG_CONFIG_DIRS": "/etc/xdg/xdg-ubuntu:/etc/xdg", + "NVM_CD_FLAGS": "", + "XDG_DATA_DIRS": "/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop", + "npm_package_author_name": "Daniel Ledda", + "npm_config_cache_lock_retries": "10", + "npm_config_searchstaleness": "900", + "LC_NUMERIC": "de_DE.UTF-8", + "npm_config_node_options": "", + "npm_config_save_prefix": "^", + "npm_config_scripts_prepend_node_path": "warn-only", + "BOOST_LIBRARYDIR": "/usr/lib", + "LC_PAPER": "de_DE.UTF-8", + "npm_package_devDependencies__types_three": "^0.128.0", + "npm_package_devDependencies_rollup_plugin_livereload": "^2.0.0", + "npm_config_group": "1000", + "npm_config_init_author_email": "", + "npm_config_searchexclude": "", + "npm_config_git": "git", + "npm_config_optional": "true", + "npm_config_json": "", + "INIT_CWD": "/home/ledda/Documents/Projects/soma", + "ROLLUP_WATCH": "true" + }, + "userLimits": { + "core_file_size_blocks": { + "soft": 0, + "hard": "unlimited" + }, + "data_seg_size_kbytes": { + "soft": "unlimited", + "hard": "unlimited" + }, + "file_size_blocks": { + "soft": "unlimited", + "hard": "unlimited" + }, + "max_locked_memory_bytes": { + "soft": 67108864, + "hard": 67108864 + }, + "max_memory_size_kbytes": { + "soft": "unlimited", + "hard": "unlimited" + }, + "open_files": { + "soft": 1048576, + "hard": 1048576 + }, + "stack_size_bytes": { + "soft": 8388608, + "hard": "unlimited" + }, + "cpu_time_seconds": { + "soft": "unlimited", + "hard": "unlimited" + }, + "max_user_processes": { + "soft": 47649, + "hard": 47649 + }, + "virtual_memory_kbytes": { + "soft": "unlimited", + "hard": "unlimited" + } + }, + "sharedObjects": [ + "linux-vdso.so.1", + "/lib/x86_64-linux-gnu/libdl.so.2", + "/usr/lib/x86_64-linux-gnu/libstdc++.so.6", + "/lib/x86_64-linux-gnu/libm.so.6", + "/lib/x86_64-linux-gnu/libgcc_s.so.1", + "/lib/x86_64-linux-gnu/libpthread.so.0", + "/lib/x86_64-linux-gnu/libc.so.6", + "/lib64/ld-linux-x86-64.so.2" + ] +} \ No newline at end of file diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..04e2b68 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,83 @@ +import svelte from 'rollup-plugin-svelte'; +import commonjs from '@rollup/plugin-commonjs'; +import resolve from '@rollup/plugin-node-resolve'; +import livereload from 'rollup-plugin-livereload'; +import { terser } from 'rollup-plugin-terser'; +import sveltePreprocess from 'svelte-preprocess'; +import typescript from '@rollup/plugin-typescript'; +import css from 'rollup-plugin-css-only'; + +const production = !process.env.ROLLUP_WATCH; + +function serve() { + let server; + + function toExit() { + if (server) server.kill(0); + } + + return { + writeBundle() { + if (server) return; + server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], { + stdio: ['ignore', 'inherit', 'inherit'], + shell: true + }); + + process.on('SIGTERM', toExit); + process.on('exit', toExit); + } + }; +} + +export default { + input: 'src/main.ts', + output: { + sourcemap: true, + format: 'iife', + name: 'app', + file: 'public/build/bundle.js' + }, + plugins: [ + svelte({ + preprocess: sveltePreprocess({ sourceMap: !production }), + compilerOptions: { + // enable run-time checks when not in production + dev: !production + } + }), + // we'll extract any component CSS out into + // a separate file - better for performance + css({ output: 'bundle.css' }), + + // If you have external dependencies installed from + // npm, you'll most likely need these plugins. In + // some cases you'll need additional configuration - + // consult the documentation for details: + // https://github.com/rollup/plugins/tree/master/packages/commonjs + resolve({ + browser: true, + dedupe: ['svelte'] + }), + commonjs(), + typescript({ + sourceMap: !production, + inlineSources: !production + }), + + // In dev mode, call `npm run start` once + // the bundle has been generated + !production && serve(), + + // Watch the `public` directory and refresh the + // browser on changes when not in production + !production && livereload('public'), + + // If we're building for production (npm run build + // instead of npm run dev), minify + production && terser() + ], + watch: { + clearScreen: false + } +}; diff --git a/src/App.svelte b/src/App.svelte new file mode 100644 index 0000000..4b85a7a --- /dev/null +++ b/src/App.svelte @@ -0,0 +1,57 @@ + + + + +
+
+ +
+
+ +
+
diff --git a/src/CubeInput.svelte b/src/CubeInput.svelte new file mode 100644 index 0000000..43e8dd1 --- /dev/null +++ b/src/CubeInput.svelte @@ -0,0 +1,121 @@ + + +
selectedCube.set(cubeNo)} +> +

Cube: {cubeNo + 1}

+ {#each {length: dimension} as _, x} +
+ {#each {length: dimension} as _, y} +
+ {#each {length: dimension} as _, z} +
onMouseOverCell(event, x, y, z)} + on:mousedown={(event) => onMouseDownCell(event, x, y, z)} + on:mouseup={(event) => onMouseUpCell(event, x, y, z)} + /> + {/each} +
+ {/each} +
+ {/each} +
+ + \ No newline at end of file diff --git a/src/OrbitControls.js b/src/OrbitControls.js new file mode 100644 index 0000000..5c4f668 --- /dev/null +++ b/src/OrbitControls.js @@ -0,0 +1,795 @@ +import { + EventDispatcher, + MOUSE, + Quaternion, + Spherical, + TOUCH, + Vector2, + Vector3 +} from 'three'; + +// This set of controls performs orbiting, dollying (zooming), and panning. +// Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default). +// +// Orbit - left mouse / touch: one-finger move +// Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish +// Pan - right mouse, or left mouse + ctrl/meta/shiftKey, or arrow keys / touch: two-finger move + +const _changeEvent = { type: 'change' }; +const _startEvent = { type: 'start' }; +const _endEvent = { type: 'end' }; + +class OrbitControls extends EventDispatcher { + constructor( object, domElement ) { + super(); + if ( domElement === undefined ) console.warn( 'THREE.OrbitControls: The second parameter "domElement" is now mandatory.' ); + if ( domElement === document ) console.error( 'THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.' ); + this.object = object; + this.domElement = domElement; + + // Set to false to disable this control + this.enabled = true; + + // "target" sets the location of focus, where the object orbits around + this.target = new Vector3(); + + // How far you can dolly in and out ( PerspectiveCamera only ) + this.minDistance = 0; + this.maxDistance = Infinity; + + // How far you can zoom in and out ( OrthographicCamera only ) + this.minZoom = 0; + this.maxZoom = Infinity; + + // How far you can orbit vertically, upper and lower limits. + // Range is 0 to Math.PI radians. + this.minPolarAngle = 0; // radians + this.maxPolarAngle = Math.PI; // radians + + // How far you can orbit horizontally, upper and lower limits. + // If set, the interval [ min, max ] must be a sub-interval of [ - 2 PI, 2 PI ], with ( max - min < 2 PI ) + this.minAzimuthAngle = - Infinity; // radians + this.maxAzimuthAngle = Infinity; // radians + + // Set to true to enable damping (inertia) + // If damping is enabled, you must call controls.update() in your animation loop + this.enableDamping = false; + this.dampingFactor = 0.05; + + // This option actually enables dollying in and out; left as "zoom" for backwards compatibility. + // Set to false to disable zooming + this.enableZoom = true; + this.zoomSpeed = 1.0; + + // Set to false to disable rotating + this.enableRotate = true; + this.rotateSpeed = 1.0; + + // Set to false to disable panning + this.enablePan = true; + this.panSpeed = 1.0; + this.screenSpacePanning = true; // if false, pan orthogonal to world-space direction camera.up + this.keyPanSpeed = 7.0; // pixels moved per arrow key push + + // Set to true to automatically rotate around the target + // If auto-rotate is enabled, you must call controls.update() in your animation loop + this.autoRotate = false; + this.autoRotateSpeed = 2.0; // 30 seconds per orbit when fps is 60 + + // The four arrow keys + this.keys = { LEFT: 'ArrowLeft', UP: 'ArrowUp', RIGHT: 'ArrowRight', BOTTOM: 'ArrowDown' }; + + // Mouse buttons + this.mouseButtons = { LEFT: MOUSE.ROTATE, MIDDLE: MOUSE.DOLLY, RIGHT: MOUSE.PAN }; + + // Touch fingers + this.touches = { ONE: TOUCH.ROTATE, TWO: TOUCH.DOLLY_PAN }; + + // for reset + this.target0 = this.target.clone(); + this.position0 = this.object.position.clone(); + this.zoom0 = this.object.zoom; + + // the target DOM element for key events + this._domElementKeyEvents = null; + + // + // public methods + // + + this.getPolarAngle = function () { + return spherical.phi; + }; + + this.getAzimuthalAngle = function () { + return spherical.theta; + }; + + this.listenToKeyEvents = function ( domElement ) { + domElement.addEventListener( 'keydown', onKeyDown ); + this._domElementKeyEvents = domElement; + }; + + this.saveState = function () { + scope.target0.copy( scope.target ); + scope.position0.copy( scope.object.position ); + scope.zoom0 = scope.object.zoom; + }; + + this.reset = function () { + scope.target.copy( scope.target0 ); + scope.object.position.copy( scope.position0 ); + scope.object.zoom = scope.zoom0; + scope.object.updateProjectionMatrix(); + scope.dispatchEvent( _changeEvent ); + scope.update(); + state = STATE.NONE; + }; + + // this method is exposed, but perhaps it would be better if we can make it private... + this.update = function () { + const offset = new Vector3(); + // so camera.up is the orbit axis + const quat = new Quaternion().setFromUnitVectors( object.up, new Vector3( 0, 1, 0 ) ); + const quatInverse = quat.clone().invert(); + const lastPosition = new Vector3(); + const lastQuaternion = new Quaternion(); + const twoPI = 2 * Math.PI; + return function update() { + const position = scope.object.position; + offset.copy( position ).sub( scope.target ); + // rotate offset to "y-axis-is-up" space + offset.applyQuaternion( quat ); + // angle from z-axis around y-axis + spherical.setFromVector3( offset ); + if ( scope.autoRotate && state === STATE.NONE ) { + rotateLeft( getAutoRotationAngle() ); + } + if ( scope.enableDamping ) { + spherical.theta += sphericalDelta.theta * scope.dampingFactor; + spherical.phi += sphericalDelta.phi * scope.dampingFactor; + } else { + spherical.theta += sphericalDelta.theta; + spherical.phi += sphericalDelta.phi; + } + + // restrict theta to be between desired limits + let min = scope.minAzimuthAngle; + let max = scope.maxAzimuthAngle; + if ( isFinite( min ) && isFinite( max ) ) { + if ( min < - Math.PI ) min += twoPI; else if ( min > Math.PI ) min -= twoPI; + if ( max < - Math.PI ) max += twoPI; else if ( max > Math.PI ) max -= twoPI; + if ( min <= max ) { + spherical.theta = Math.max( min, Math.min( max, spherical.theta ) ); + } else { + spherical.theta = ( spherical.theta > ( min + max ) / 2 ) ? + Math.max( min, spherical.theta ) : + Math.min( max, spherical.theta ); + } + } + + // restrict phi to be between desired limits + spherical.phi = Math.max( scope.minPolarAngle, Math.min( scope.maxPolarAngle, spherical.phi ) ); + spherical.makeSafe(); + spherical.radius *= scale; + + // restrict radius to be between desired limits + spherical.radius = Math.max( scope.minDistance, Math.min( scope.maxDistance, spherical.radius ) ); + + // move target to panned location + if ( scope.enableDamping === true ) { + scope.target.addScaledVector( panOffset, scope.dampingFactor ); + } else { + scope.target.add( panOffset ); + } + offset.setFromSpherical( spherical ); + // rotate offset back to "camera-up-vector-is-up" space + offset.applyQuaternion( quatInverse ); + position.copy( scope.target ).add( offset ); + scope.object.lookAt( scope.target ); + if ( scope.enableDamping === true ) { + sphericalDelta.theta *= ( 1 - scope.dampingFactor ); + sphericalDelta.phi *= ( 1 - scope.dampingFactor ); + panOffset.multiplyScalar( 1 - scope.dampingFactor ); + } else { + sphericalDelta.set( 0, 0, 0 ); + panOffset.set( 0, 0, 0 ); + } + scale = 1; + + // update condition is: + // min(camera displacement, camera rotation in radians)^2 > EPS + // using small-angle approximation cos(x/2) = 1 - x^2 / 8 + + if ( zoomChanged || + lastPosition.distanceToSquared( scope.object.position ) > EPS || + 8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) { + scope.dispatchEvent( _changeEvent ); + lastPosition.copy( scope.object.position ); + lastQuaternion.copy( scope.object.quaternion ); + zoomChanged = false; + return true; + } + return false; + }; + }(); + + this.dispose = function () { + scope.domElement.removeEventListener( 'contextmenu', onContextMenu ); + scope.domElement.removeEventListener( 'pointerdown', onPointerDown ); + scope.domElement.removeEventListener( 'wheel', onMouseWheel ); + scope.domElement.removeEventListener( 'touchstart', onTouchStart ); + scope.domElement.removeEventListener( 'touchend', onTouchEnd ); + scope.domElement.removeEventListener( 'touchmove', onTouchMove ); + scope.domElement.ownerDocument.removeEventListener( 'pointermove', onPointerMove ); + scope.domElement.ownerDocument.removeEventListener( 'pointerup', onPointerUp ); + if ( scope._domElementKeyEvents !== null ) { + scope._domElementKeyEvents.removeEventListener( 'keydown', onKeyDown ); + } + //scope.dispatchEvent( { type: 'dispose' } ); // should this be added here? + }; + + // + // internals + // + + const scope = this; + + const STATE = { + NONE: - 1, + ROTATE: 0, + DOLLY: 1, + PAN: 2, + TOUCH_ROTATE: 3, + TOUCH_PAN: 4, + TOUCH_DOLLY_PAN: 5, + TOUCH_DOLLY_ROTATE: 6 + }; + + let state = STATE.NONE; + + const EPS = 0.000001; + + // current position in spherical coordinates + const spherical = new Spherical(); + const sphericalDelta = new Spherical(); + + let scale = 1; + const panOffset = new Vector3(); + let zoomChanged = false; + + const rotateStart = new Vector2(); + const rotateEnd = new Vector2(); + const rotateDelta = new Vector2(); + + const panStart = new Vector2(); + const panEnd = new Vector2(); + const panDelta = new Vector2(); + + const dollyStart = new Vector2(); + const dollyEnd = new Vector2(); + const dollyDelta = new Vector2(); + + function getAutoRotationAngle() { + return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed; + } + + function getZoomScale() { + return Math.pow( 0.95, scope.zoomSpeed ); + } + + function rotateLeft( angle ) { + sphericalDelta.theta -= angle; + } + + function rotateUp( angle ) { + sphericalDelta.phi -= angle; + } + + const panLeft = function () { + const v = new Vector3(); + return function panLeft( distance, objectMatrix ) { + v.setFromMatrixColumn( objectMatrix, 0 ); // get X column of objectMatrix + v.multiplyScalar( - distance ); + panOffset.add( v ); + }; + }(); + + const panUp = function () { + const v = new Vector3(); + return function panUp( distance, objectMatrix ) { + if ( scope.screenSpacePanning === true ) { + v.setFromMatrixColumn( objectMatrix, 1 ); + } else { + v.setFromMatrixColumn( objectMatrix, 0 ); + v.crossVectors( scope.object.up, v ); + } + v.multiplyScalar( distance ); + panOffset.add( v ); + }; + }(); + + // deltaX and deltaY are in pixels; right and down are positive + const pan = function () { + const offset = new Vector3(); + return function pan( deltaX, deltaY ) { + const element = scope.domElement; + if ( scope.object.isPerspectiveCamera ) { + // perspective + const position = scope.object.position; + offset.copy( position ).sub( scope.target ); + let targetDistance = offset.length(); + // half of the fov is center to top of screen + targetDistance *= Math.tan( ( scope.object.fov / 2 ) * Math.PI / 180.0 ); + // we use only clientHeight here so aspect ratio does not distort speed + panLeft( 2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix ); + panUp( 2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix ); + } else if ( scope.object.isOrthographicCamera ) { + // orthographic + panLeft( deltaX * ( scope.object.right - scope.object.left ) / scope.object.zoom / element.clientWidth, scope.object.matrix ); + panUp( deltaY * ( scope.object.top - scope.object.bottom ) / scope.object.zoom / element.clientHeight, scope.object.matrix ); + } else { + // camera neither orthographic nor perspective + console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.' ); + scope.enablePan = false; + } + }; + }(); + + function dollyOut( dollyScale ) { + if ( scope.object.isPerspectiveCamera ) { + scale /= dollyScale; + } else if ( scope.object.isOrthographicCamera ) { + scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom * dollyScale ) ); + scope.object.updateProjectionMatrix(); + zoomChanged = true; + } else { + console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' ); + scope.enableZoom = false; + } + + } + + function dollyIn( dollyScale ) { + if ( scope.object.isPerspectiveCamera ) { + scale *= dollyScale; + } else if ( scope.object.isOrthographicCamera ) { + scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / dollyScale ) ); + scope.object.updateProjectionMatrix(); + zoomChanged = true; + } else { + console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' ); + scope.enableZoom = false; + } + + } + + // + // event callbacks - update the object state + // + function handleMouseDownRotate( event ) { + rotateStart.set( event.clientX, event.clientY ); + } + + function handleMouseDownDolly( event ) { + dollyStart.set( event.clientX, event.clientY ); + } + + function handleMouseDownPan( event ) { + panStart.set( event.clientX, event.clientY ); + } + + function handleMouseMoveRotate( event ) { + rotateEnd.set( event.clientX, event.clientY ); + rotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed ); + const element = scope.domElement; + rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientHeight ); // yes, height + rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight ); + rotateStart.copy( rotateEnd ); + scope.update(); + } + + function handleMouseMoveDolly( event ) { + dollyEnd.set( event.clientX, event.clientY ); + dollyDelta.subVectors( dollyEnd, dollyStart ); + if ( dollyDelta.y > 0 ) { + dollyOut( getZoomScale() ); + } else if ( dollyDelta.y < 0 ) { + dollyIn( getZoomScale() ); + } + dollyStart.copy( dollyEnd ); + scope.update(); + } + + function handleMouseMovePan( event ) { + panEnd.set( event.clientX, event.clientY ); + panDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed ); + pan( panDelta.x, panDelta.y ); + panStart.copy( panEnd ); + scope.update(); + } + + function handleMouseUp( /*event*/ ) { + // no-op + } + + function handleMouseWheel( event ) { + if ( event.deltaY < 0 ) { + dollyIn( getZoomScale() ); + } else if ( event.deltaY > 0 ) { + dollyOut( getZoomScale() ); + } + scope.update(); + } + + function handleKeyDown( event ) { + let needsUpdate = false; + switch ( event.code ) { + case scope.keys.UP: + pan( 0, scope.keyPanSpeed ); + needsUpdate = true; + break; + case scope.keys.BOTTOM: + pan( 0, - scope.keyPanSpeed ); + needsUpdate = true; + break; + case scope.keys.LEFT: + pan( scope.keyPanSpeed, 0 ); + needsUpdate = true; + break; + case scope.keys.RIGHT: + pan( - scope.keyPanSpeed, 0 ); + needsUpdate = true; + break; + } + if ( needsUpdate ) { + // prevent the browser from scrolling on cursor keys + event.preventDefault(); + scope.update(); + } + } + + function handleTouchStartRotate( event ) { + if ( event.touches.length == 1 ) { + rotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); + } else { + const x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ); + const y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ); + rotateStart.set( x, y ); + } + + } + + function handleTouchStartPan( event ) { + if ( event.touches.length == 1 ) { + panStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); + } else { + const x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ); + const y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ); + panStart.set( x, y ); + } + + } + + function handleTouchStartDolly( event ) { + const dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX; + const dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY; + const distance = Math.sqrt( dx * dx + dy * dy ); + dollyStart.set( 0, distance ); + } + + function handleTouchStartDollyPan( event ) { + if ( scope.enableZoom ) handleTouchStartDolly( event ); + if ( scope.enablePan ) handleTouchStartPan( event ); + } + + function handleTouchStartDollyRotate( event ) { + if ( scope.enableZoom ) handleTouchStartDolly( event ); + if ( scope.enableRotate ) handleTouchStartRotate( event ); + } + + function handleTouchMoveRotate( event ) { + if ( event.touches.length == 1 ) { + rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); + } else { + const x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ); + const y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ); + rotateEnd.set( x, y ); + } + rotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed ); + const element = scope.domElement; + rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientHeight ); // yes, height + rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight ); + rotateStart.copy( rotateEnd ); + } + + function handleTouchMovePan( event ) { + if ( event.touches.length == 1 ) { + panEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); + } else { + const x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ); + const y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ); + panEnd.set( x, y ); + } + panDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed ); + pan( panDelta.x, panDelta.y ); + panStart.copy( panEnd ); + } + + function handleTouchMoveDolly( event ) { + const dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX; + const dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY; + const distance = Math.sqrt( dx * dx + dy * dy ); + dollyEnd.set( 0, distance ); + dollyDelta.set( 0, Math.pow( dollyEnd.y / dollyStart.y, scope.zoomSpeed ) ); + dollyOut( dollyDelta.y ); + dollyStart.copy( dollyEnd ); + } + + function handleTouchMoveDollyPan( event ) { + if ( scope.enableZoom ) handleTouchMoveDolly( event ); + if ( scope.enablePan ) handleTouchMovePan( event ); + } + + function handleTouchMoveDollyRotate( event ) { + if ( scope.enableZoom ) handleTouchMoveDolly( event ); + if ( scope.enableRotate ) handleTouchMoveRotate( event ); + } + + function handleTouchEnd( /*event*/ ) { + // no-op + } + + // + // event handlers - FSM: listen for events and reset state + // + + function onPointerDown( event ) { + if ( scope.enabled === false ) return; + switch ( event.pointerType ) { + case 'mouse': + case 'pen': + onMouseDown( event ); + break; + // TODO touch + } + } + + function onPointerMove( event ) { + if ( scope.enabled === false ) return; + switch ( event.pointerType ) { + case 'mouse': + case 'pen': + onMouseMove( event ); + break; + // TODO touch + } + + } + + function onPointerUp( event ) { + switch ( event.pointerType ) { + case 'mouse': + case 'pen': + onMouseUp( event ); + break; + // TODO touch + } + } + + function onMouseDown( event ) { + // Prevent the browser from scrolling. + event.preventDefault(); + // Manually set the focus since calling preventDefault above + // prevents the browser from setting it automatically. + scope.domElement.focus ? scope.domElement.focus() : window.focus(); + let mouseAction; + switch ( event.button ) { + case 0: + mouseAction = scope.mouseButtons.LEFT; + break; + case 1: + mouseAction = scope.mouseButtons.MIDDLE; + break; + case 2: + mouseAction = scope.mouseButtons.RIGHT; + break; + default: + mouseAction = - 1; + } + + switch ( mouseAction ) { + case MOUSE.DOLLY: + if ( scope.enableZoom === false ) return; + handleMouseDownDolly( event ); + state = STATE.DOLLY; + break; + case MOUSE.ROTATE: + if ( event.ctrlKey || event.metaKey || event.shiftKey ) { + if ( scope.enablePan === false ) return; + handleMouseDownPan( event ); + state = STATE.PAN; + } else { + if ( scope.enableRotate === false ) return; + handleMouseDownRotate( event ); + state = STATE.ROTATE; + } + break; + case MOUSE.PAN: + if ( event.ctrlKey || event.metaKey || event.shiftKey ) { + if ( scope.enableRotate === false ) return; + handleMouseDownRotate( event ); + state = STATE.ROTATE; + } else { + if ( scope.enablePan === false ) return; + handleMouseDownPan( event ); + state = STATE.PAN; + } + break; + default: + state = STATE.NONE; + } + + if ( state !== STATE.NONE ) { + scope.domElement.ownerDocument.addEventListener( 'pointermove', onPointerMove ); + scope.domElement.ownerDocument.addEventListener( 'pointerup', onPointerUp ); + scope.dispatchEvent( _startEvent ); + } + } + + function onMouseMove( event ) { + if ( scope.enabled === false ) return; + event.preventDefault(); + switch ( state ) { + case STATE.ROTATE: + if ( scope.enableRotate === false ) return; + handleMouseMoveRotate( event ); + break; + case STATE.DOLLY: + if ( scope.enableZoom === false ) return; + handleMouseMoveDolly( event ); + break; + case STATE.PAN: + if ( scope.enablePan === false ) return; + handleMouseMovePan( event ); + break; + } + } + + function onMouseUp( event ) { + scope.domElement.ownerDocument.removeEventListener( 'pointermove', onPointerMove ); + scope.domElement.ownerDocument.removeEventListener( 'pointerup', onPointerUp ); + if ( scope.enabled === false ) return; + handleMouseUp( event ); + scope.dispatchEvent( _endEvent ); + state = STATE.NONE; + } + + function onMouseWheel( event ) { + if ( scope.enabled === false || scope.enableZoom === false || ( state !== STATE.NONE && state !== STATE.ROTATE ) ) return; + event.preventDefault(); + scope.dispatchEvent( _startEvent ); + handleMouseWheel( event ); + scope.dispatchEvent( _endEvent ); + } + + function onKeyDown( event ) { + if ( scope.enabled === false || scope.enablePan === false ) return; + handleKeyDown( event ); + } + + function onTouchStart( event ) { + if ( scope.enabled === false ) return; + event.preventDefault(); // prevent scrolling + switch ( event.touches.length ) { + case 1: + switch ( scope.touches.ONE ) { + case TOUCH.ROTATE: + if ( scope.enableRotate === false ) return; + handleTouchStartRotate( event ); + state = STATE.TOUCH_ROTATE; + break; + case TOUCH.PAN: + if ( scope.enablePan === false ) return; + handleTouchStartPan( event ); + state = STATE.TOUCH_PAN; + break; + default: + state = STATE.NONE; + } + break; + case 2: + switch ( scope.touches.TWO ) { + case TOUCH.DOLLY_PAN: + if ( scope.enableZoom === false && scope.enablePan === false ) return; + handleTouchStartDollyPan( event ); + state = STATE.TOUCH_DOLLY_PAN; + break; + case TOUCH.DOLLY_ROTATE: + if ( scope.enableZoom === false && scope.enableRotate === false ) return; + handleTouchStartDollyRotate( event ); + state = STATE.TOUCH_DOLLY_ROTATE; + break; + default: + state = STATE.NONE; + } + break; + default: + state = STATE.NONE; + } + if ( state !== STATE.NONE ) { + scope.dispatchEvent( _startEvent ); + } + } + + function onTouchMove( event ) { + if ( scope.enabled === false ) return; + event.preventDefault(); // prevent scrolling + switch ( state ) { + case STATE.TOUCH_ROTATE: + if ( scope.enableRotate === false ) return; + handleTouchMoveRotate( event ); + scope.update(); + break; + case STATE.TOUCH_PAN: + if ( scope.enablePan === false ) return; + handleTouchMovePan( event ); + scope.update(); + break; + case STATE.TOUCH_DOLLY_PAN: + if ( scope.enableZoom === false && scope.enablePan === false ) return; + handleTouchMoveDollyPan( event ); + scope.update(); + break; + case STATE.TOUCH_DOLLY_ROTATE: + if ( scope.enableZoom === false && scope.enableRotate === false ) return; + handleTouchMoveDollyRotate( event ); + scope.update(); + break; + default: + state = STATE.NONE; + } + } + + function onTouchEnd( event ) { + if ( scope.enabled === false ) return; + handleTouchEnd( event ); + scope.dispatchEvent( _endEvent ); + state = STATE.NONE; + } + + function onContextMenu( event ) { + if ( scope.enabled === false ) return; + event.preventDefault(); + } + + scope.domElement.addEventListener( 'contextmenu', onContextMenu ); + scope.domElement.addEventListener( 'pointerdown', onPointerDown ); + scope.domElement.addEventListener( 'wheel', onMouseWheel, { passive: false } ); + scope.domElement.addEventListener( 'touchstart', onTouchStart, { passive: false } ); + scope.domElement.addEventListener( 'touchend', onTouchEnd ); + scope.domElement.addEventListener( 'touchmove', onTouchMove, { passive: false } ); + // force an update at start + this.update(); + } +} + + +// This set of controls performs orbiting, dollying (zooming), and panning. +// Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default). +// This is very similar to OrbitControls, another set of touch behavior +// +// Orbit - right mouse, or left mouse + ctrl/meta/shiftKey / touch: two-finger rotate +// Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish +// Pan - left mouse, or arrow keys / touch: one-finger move + +class MapControls extends OrbitControls { + constructor( object, domElement ) { + super( object, domElement ); + this.mouseButtons.LEFT = MOUSE.ROTATE; + this.mouseButtons.RIGHT = null; + this.mouseButtons.MIDDLE = null; + } +} + +export { OrbitControls, MapControls }; \ No newline at end of file diff --git a/src/Polycube.js b/src/Polycube.js deleted file mode 100644 index ac41718..0000000 --- a/src/Polycube.js +++ /dev/null @@ -1,84 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var VoxelSpace_1 = __importDefault(require("./VoxelSpace")); -var Polycube = /** @class */ (function (_super) { - __extends(Polycube, _super); - function Polycube(dims, vals, id) { - var _this = _super.call(this, dims, vals.map(function (val) { return val ? id : 0; }), true) || this; - _this.id = id; - return _this; - } - Polycube.prototype.getId = function () { - return this.id; - }; - Polycube.prototype.print = function () { - var accum = ""; - console.log("---"); - for (var i = 0; i < this.dims[0]; i++) { - for (var j = 0; j < this.dims[1]; j++) { - for (var k = 0; k < this.dims[2]; k++) { - accum += this.at(i, j, k) === 0 ? "O" : "#"; - } - console.log(accum); - accum = ""; - } - if (i !== this.dims[0] - 1) { - console.log("-"); - } - } - console.log("---"); - }; - Polycube.prototype.matches = function (cube) { - var otherDims = cube.getDims(); - for (var i = 0; i < this.dims.length; i++) { - if (otherDims[i] !== this.dims[i]) { - return false; - } - } - var otherVals = cube.getVals(); - for (var i = 0; i < this.vals.length; i++) { - if (Number(this.vals[i]) !== Number(otherVals[i])) { - return false; - } - } - return true; - }; - Polycube.prototype.size = function () { - var size = 0; - this.forEachCell(function (val) { - if (val) { - size++; - } - }); - return size; - }; - Polycube.prototype.rotated90 = function (dim) { - var rotated = _super.prototype.rotated90.call(this, dim); - return new Polycube(rotated.getDims(), rotated.getVals(), this.id); - }; - Polycube.prototype.clone = function () { - return new Polycube(this.getDims(), this.getVals(), this.id); - }; - Polycube.prototype.getUniqueRotations = function () { - var _this = this; - return _super.prototype.getUniqueRotations.call(this).map(function (rot) { return new Polycube(rot.getDims(), rot.getVals(), _this.id); }); - }; - return Polycube; -}(VoxelSpace_1.default)); -exports.default = Polycube; diff --git a/src/Polycube.ts b/src/Polycube.ts deleted file mode 100644 index df81443..0000000 --- a/src/Polycube.ts +++ /dev/null @@ -1,70 +0,0 @@ -import VoxelSpace, {DimensionDef} from "./VoxelSpace"; - -export default class Polycube extends VoxelSpace { - private id: number; - constructor(dims: DimensionDef, vals: boolean[], id: number) { - super(dims, vals.map(val => val ? id : 0), true); - this.id = id; - } - - getId() { - return this.id; - } - - print() { - let accum = ""; - console.log("---"); - for (let i = 0; i < this.dims[0]; i++) { - for (let j = 0; j < this.dims[1]; j++) { - for (let k = 0; k < this.dims[2]; k++) { - accum += this.at(i, j, k) === 0 ? "O" : "#"; - } - console.log(accum); - accum = ""; - } - if (i !== this.dims[0] - 1) { - console.log("-"); - } - } - console.log("---"); - } - - matches(cube: VoxelSpace) { - const otherDims = cube.getDims(); - for (let i = 0; i < this.dims.length; i++) { - if (otherDims[i] !== this.dims[i]) { - return false; - } - } - const otherVals = cube.getVals(); - for (let i = 0; i < this.vals.length; i++) { - if (Number(this.vals[i]) !== Number(otherVals[i])) { - return false; - } - } - return true; - } - - size() { - let size = 0; - this.forEachCell((val) => { - if (val) { - size++; - } - }); - return size; - } - - rotated90(dim: "x" | "y" | "z"): Polycube { - const rotated = super.rotated90(dim); - return new Polycube(rotated.getDims(), rotated.getVals() as unknown as boolean[], this.id); - } - - clone(): Polycube { - return new Polycube(this.getDims(), this.getVals() as unknown as boolean[], this.id); - } - - getUniqueRotations(): Polycube[] { - return super.getUniqueRotations().map(rot => new Polycube(rot.getDims(), rot.getVals() as unknown as boolean[], this.id)); - } -} \ No newline at end of file diff --git a/src/Polycube3D.svelte b/src/Polycube3D.svelte new file mode 100644 index 0000000..2eda31a --- /dev/null +++ b/src/Polycube3D.svelte @@ -0,0 +1,22 @@ + + + \ No newline at end of file diff --git a/src/Sidebar.svelte b/src/Sidebar.svelte new file mode 100644 index 0000000..3d64697 --- /dev/null +++ b/src/Sidebar.svelte @@ -0,0 +1,50 @@ + + +
+

Somaesque

+

Settings

+ +
+

Cube Dimension: {$somaDimension}

+ + +
+ +
+

Cubes: {numCubes}

+ + +
+ +
+ +
+
+ + \ No newline at end of file diff --git a/src/SolutionInteractor.svelte b/src/SolutionInteractor.svelte new file mode 100644 index 0000000..10ddbff --- /dev/null +++ b/src/SolutionInteractor.svelte @@ -0,0 +1,27 @@ + + +
+ {#each {length: numCubes} as _, cubeNo} +
+ +
+ {/each} +
+ + + \ No newline at end of file diff --git a/src/SomaSolver.js b/src/SomaSolver.js deleted file mode 100644 index fda6de3..0000000 --- a/src/SomaSolver.js +++ /dev/null @@ -1,58 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var VoxelSpace_1 = __importDefault(require("./VoxelSpace")); -var SomaSolver = /** @class */ (function () { - function SomaSolver(dimension) { - this.solutions = []; - this.iterations = 0; - if (dimension % 1 !== 0 || dimension < 0) { - throw new Error("The argument 'dimension' must be a positive whole number"); - } - this.dim = dimension; - this.solutionCube = new VoxelSpace_1.default([dimension, dimension, dimension], Array(Math.pow(dimension, 3)).fill(0)); - } - SomaSolver.prototype.solve = function (polycubes) { - if (polycubes.length === 0) { - throw new Error("You must pass at least one polycube to solve the puzzle."); - } - var cumulativeSize = polycubes.reduce(function (prev, curr) { return prev + curr.size(); }, 0); - if (cumulativeSize !== Math.pow(this.dim, 3)) { - throw new Error("The polycubes passed do not add up to exactly enough units to form a cube of dimension " + this.dim + "! Got: " + cumulativeSize + ", need: " + Math.pow(this.dim, 3)); - } - this.iterations = 0; - this.backtrackSolve(this.solutionCube, polycubes); - this.solutions = VoxelSpace_1.default.filterUnique(this.solutions); - this.solutions.forEach(function (sol) { return sol.print(); }); - console.log(this.solutions.length); - }; - SomaSolver.prototype.backtrackSolve = function (workingSolution, polycubes, depth) { - if (depth === void 0) { depth = 0; } - var nextCube = polycubes[0]; - var rots = depth === 0 ? [nextCube] : nextCube.getUniqueRotations(); - for (var i = 0; i < rots.length; i++) { - var polyCubeDims = rots[i].getDims(); - for (var x = 0; x < this.dim - polyCubeDims[0] + 1; x++) { - for (var y = 0; y < this.dim - polyCubeDims[1] + 1; y++) { - for (var z = 0; z < this.dim - polyCubeDims[2] + 1; z++) { - var successfulFusion = workingSolution.plus(rots[i], x, y, z); - if (successfulFusion) { - if (polycubes.length === 1) { - console.log("soln", this.iterations++); - this.solutions.push(successfulFusion); - return; - } - else { - this.backtrackSolve(successfulFusion, polycubes.slice(1), depth + 1); - } - } - } - } - } - } - }; - return SomaSolver; -}()); -exports.default = SomaSolver; diff --git a/src/SomaSolver.ts b/src/SomaSolver.ts deleted file mode 100644 index 1a24af7..0000000 --- a/src/SomaSolver.ts +++ /dev/null @@ -1,55 +0,0 @@ -import Polycube from "./Polycube"; -import VoxelSpace from "./VoxelSpace"; - -export default class SomaSolver { - private solutionCube: VoxelSpace; - private dim: number; - private solutions: VoxelSpace[] = []; - private iterations: number = 0; - constructor(dimension: number) { - if (dimension % 1 !== 0 || dimension < 0) { - throw new Error("The argument 'dimension' must be a positive whole number"); - } - this.dim = dimension; - this.solutionCube = new VoxelSpace([dimension, dimension, dimension], Array(dimension**3).fill(0)); - } - - solve(polycubes: Polycube[]) { - if (polycubes.length === 0) { - throw new Error("You must pass at least one polycube to solve the puzzle."); - } - let cumulativeSize = polycubes.reduce((prev, curr) => prev + curr.size(), 0); - if (cumulativeSize !== this.dim**3) { - throw new Error(`The polycubes passed do not add up to exactly enough units to form a cube of dimension ${this.dim}! Got: ${cumulativeSize}, need: ${this.dim**3}`); - } - this.iterations = 0; - this.backtrackSolve(this.solutionCube, polycubes); - this.solutions = VoxelSpace.filterUnique(this.solutions); - this.solutions.forEach(sol => sol.print()); - console.log(this.solutions.length); - } - - private backtrackSolve(workingSolution: VoxelSpace, polycubes: Polycube[], depth = 0) { - const nextCube = polycubes[0]; - const rots = depth === 0 ? [nextCube] : nextCube.getUniqueRotations(); - for (let i = 0; i < rots.length; i++) { - const polyCubeDims = rots[i].getDims(); - for (let x = 0; x < this.dim - polyCubeDims[0] + 1; x++) { - for (let y = 0; y < this.dim - polyCubeDims[1] + 1; y++) { - for (let z = 0; z < this.dim - polyCubeDims[2] + 1; z++) { - const successfulFusion = workingSolution.plus(rots[i], x, y, z); - if (successfulFusion) { - if (polycubes.length === 1) { - console.log("soln", this.iterations++); - this.solutions.push(successfulFusion); - return; - } else { - this.backtrackSolve(successfulFusion, polycubes.slice(1), depth + 1); - } - } - } - } - } - } - } -} \ No newline at end of file diff --git a/src/VoxelSpace.js b/src/VoxelSpace.js deleted file mode 100644 index 023a4b4..0000000 --- a/src/VoxelSpace.js +++ /dev/null @@ -1,239 +0,0 @@ -"use strict"; -var __spreadArrays = (this && this.__spreadArrays) || function () { - for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; - for (var r = Array(s), k = 0, i = 0; i < il; i++) - for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) - r[k] = a[j]; - return r; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var VoxelSpace = /** @class */ (function () { - function VoxelSpace(dims, vals, cullEmpty) { - if (vals.length !== dims[0] * dims[1] * dims[2]) { - throw new Error("Vals don't fit in given dimensions."); - } - this.dims = dims; - this.vals = vals; - if (cullEmpty) { - this.cullEmptySpace(); - } - } - VoxelSpace.prototype.cullEmptySpace = function () { - var extrema = { - xMax: -Infinity, - xMin: Infinity, - yMax: -Infinity, - yMin: Infinity, - zMax: -Infinity, - zMin: Infinity, - }; - var newVals = []; - this.forEachCell(function (val, i, j, k) { - if (val !== 0) { - extrema.xMax = Math.max(extrema.xMax, i); - extrema.xMin = Math.min(extrema.xMin, i); - extrema.yMax = Math.max(extrema.yMax, j); - extrema.yMin = Math.min(extrema.yMin, j); - extrema.zMax = Math.max(extrema.zMax, k); - extrema.zMin = Math.min(extrema.zMin, k); - } - }); - for (var i = extrema.xMin; i <= extrema.xMax; i++) { - for (var j = extrema.yMin; j <= extrema.yMax; j++) { - for (var k = extrema.zMin; k <= extrema.zMax; k++) { - newVals.push(this.at(i, j, k)); - } - } - } - this.dims[0] = extrema.xMax - extrema.xMin + 1; - this.dims[1] = extrema.yMax - extrema.yMin + 1; - this.dims[2] = extrema.zMax - extrema.zMin + 1; - this.vals = newVals; - }; - VoxelSpace.prototype.forEachCell = function (cb) { - loopStart: for (var x = 0; x < this.dims[0]; x++) { - for (var y = 0; y < this.dims[1]; y++) { - for (var z = 0; z < this.dims[2]; z++) { - if (cb(this.at(x, y, z), x, y, z) === 0) { - break loopStart; - } - } - } - } - }; - VoxelSpace.prototype.print = function () { - var accum = ""; - console.log("---"); - for (var i = 0; i < this.dims[0]; i++) { - for (var j = 0; j < this.dims[1]; j++) { - for (var k = 0; k < this.dims[2]; k++) { - accum += this.at(i, j, k); - } - console.log(accum); - accum = ""; - } - if (i !== this.dims[0] - 1) { - console.log("-"); - } - } - console.log("---"); - }; - VoxelSpace.prototype.getUniqueRotations = function () { - var rotations = []; - var refSpace = this.clone(); - VoxelSpace.pushNewUniqueSpaces(rotations, refSpace.getAxisSpins('x')); - refSpace.rot90('y'); - VoxelSpace.pushNewUniqueSpaces(rotations, refSpace.getAxisSpins('x')); - refSpace.rot90('y'); - VoxelSpace.pushNewUniqueSpaces(rotations, refSpace.getAxisSpins('x')); - refSpace.rot90('y'); - VoxelSpace.pushNewUniqueSpaces(rotations, refSpace.getAxisSpins('x')); - refSpace.rot90('z'); - VoxelSpace.pushNewUniqueSpaces(rotations, refSpace.getAxisSpins('x')); - refSpace.rot90('z'); - refSpace.rot90('z'); - VoxelSpace.pushNewUniqueSpaces(rotations, refSpace.getAxisSpins('x')); - return rotations; - }; - VoxelSpace.filterUnique = function (spaces) { - if (spaces.length === 0) { - return []; - } - var uniqueSpaces = [spaces[0]]; - for (var _i = 0, spaces_1 = spaces; _i < spaces_1.length; _i++) { - var space = spaces_1[_i]; - var foundMatch = false; - for (var _a = 0, _b = space.getUniqueRotations(); _a < _b.length; _a++) { - var rotation = _b[_a]; - var end = uniqueSpaces.length; - for (var i = 0; i < end; i++) { - if (rotation.matches(uniqueSpaces[i])) { - foundMatch = true; - } - } - } - if (!foundMatch) { - uniqueSpaces.push(space); - } - } - return uniqueSpaces; - }; - VoxelSpace.pushNewUniqueSpaces = function (existingSpaces, newSpaces) { - for (var _i = 0, newSpaces_1 = newSpaces; _i < newSpaces_1.length; _i++) { - var newSpace = newSpaces_1[_i]; - var matchFound = false; - for (var _a = 0, existingSpaces_1 = existingSpaces; _a < existingSpaces_1.length; _a++) { - var existingSpace = existingSpaces_1[_a]; - if (newSpace.matches(existingSpace)) { - matchFound = true; - break; - } - } - if (!matchFound) { - existingSpaces.push(newSpace); - } - } - }; - VoxelSpace.prototype.matches = function (space) { - var otherDims = space.getDims(); - for (var i = 0; i < this.dims.length; i++) { - if (otherDims[i] !== this.dims[i]) { - return false; - } - } - var otherVals = space.getVals(); - for (var i = 0; i < this.vals.length; i++) { - if (this.vals[i] !== otherVals[i]) { - return false; - } - } - return true; - }; - VoxelSpace.prototype.clone = function () { - return new VoxelSpace(this.getDims(), this.getVals()); - }; - VoxelSpace.prototype.getAxisSpins = function (axis) { - var rotations = [this.clone()]; - for (var i = 0; i < 3; i++) { - rotations.push(rotations[i].rotated90(axis)); - } - return rotations; - }; - VoxelSpace.prototype.getDims = function () { - return this.dims.slice(); - }; - VoxelSpace.prototype.getVals = function () { - return this.vals.slice(); - }; - // [1, 0, 0] [x] [ x] - // [0, 0, -1] * [y] = [-z] - // [0, 1, 0] [z] [ y] - VoxelSpace.prototype.newIndexRotX = function (x, y, z) { - return this.dims[2] * this.dims[1] * x + this.dims[1] * (this.dims[2] - 1 - z) + y; - }; - // [ 0, 0, 1] [x] [ z] - // [ 0, 1, 0] * [y] = [ y] - // [-1, 0, 0] [z] [-x] - VoxelSpace.prototype.newIndexRotY = function (x, y, z) { - return this.dims[1] * this.dims[0] * z + this.dims[0] * y + (this.dims[0] - 1 - x); - }; - // [0, -1, 0] [x] [-y] - // [1, 0, 0] * [y] = [ x] - // [0, 0, 1] [z] [ z] - VoxelSpace.prototype.newIndexRotZ = function (x, y, z) { - return this.dims[0] * this.dims[2] * (this.dims[1] - 1 - y) + this.dims[2] * x + z; - }; - VoxelSpace.prototype.at = function (x, y, z) { - return this.vals[this.dims[1] * this.dims[2] * x + this.dims[2] * y + z]; - }; - VoxelSpace.prototype.set = function (x, y, z, val) { - this.vals[this.dims[1] * this.dims[2] * x + this.dims[2] * y + z] = val; - }; - VoxelSpace.prototype.rotated90 = function (dim) { - var newVals = __spreadArrays(this.vals); - var newDims; - var rotIndex; - if (dim === 'x') { - newDims = [this.dims[0], this.dims[2], this.dims[1]]; - rotIndex = this.newIndexRotX.bind(this); - } - else if (dim === 'y') { - newDims = [this.dims[2], this.dims[1], this.dims[0]]; - rotIndex = this.newIndexRotY.bind(this); - } - else { - newDims = [this.dims[1], this.dims[0], this.dims[2]]; - rotIndex = this.newIndexRotZ.bind(this); - } - this.forEachCell(function (val, i, j, k) { - newVals[rotIndex(i, j, k)] = val; - }); - return new VoxelSpace(newDims, newVals); - }; - VoxelSpace.prototype.rot90 = function (dim) { - var rot = this.rotated90(dim); - this.vals = rot.getVals(); - this.dims = rot.getDims(); - }; - VoxelSpace.prototype.plus = function (space, startX, startY, startZ) { - var result = this.clone(); - var spaceDims = space.getDims(); - for (var i = 0; i < spaceDims[0]; i++) { - for (var j = 0; j < spaceDims[1]; j++) { - for (var k = 0; k < spaceDims[2]; k++) { - var sourceVal = space.at(i, j, k); - var targetEmpty = result.at(startX + i, startY + j, startZ + k) === 0; - if (sourceVal !== 0 && targetEmpty) { - result.set(startX + i, startY + j, startZ + k, sourceVal); - } - else if (sourceVal !== 0 && !targetEmpty) { - return null; - } - } - } - } - return result; - }; - return VoxelSpace; -}()); -exports.default = VoxelSpace; diff --git a/src/main.js b/src/main.js deleted file mode 100644 index 5291352..0000000 --- a/src/main.js +++ /dev/null @@ -1,139 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var Polycube_1 = __importDefault(require("./Polycube")); -var SomaSolver_1 = __importDefault(require("./SomaSolver")); -// const testCube = new Cube([4, 2, 5], [ -// "000", "001", "002", "003", "004", -// "010", "011", "012", "013", "014", -// "100", "101", "102", "103", "104", -// "110", "111", "112", "113", "114", -// "200", "201", "202", "203", "204", -// "210", "211", "212", "213", "214", -// "300", "301", "302", "303", "304", -// "310", "311", "312", "313", "314", -// ]); -// const somaCube = new Polycube([3, 3, 3], [ -// false, false, false, -// false, false, false, -// false, false, false, -// -// true, true, true, -// true, true, true, -// false, false, false, -// -// false, false, false, -// false, false, false, -// false, false, false, -// ], 1); -var unitCube1 = new Polycube_1.default([1, 1, 1], [true], 1); -var unitCube2 = new Polycube_1.default([1, 1, 1], [true], 2); -var unitCube3 = new Polycube_1.default([1, 1, 1], [true], 3); -var unitCube4 = new Polycube_1.default([1, 1, 1], [true], 4); -var unitCube5 = new Polycube_1.default([1, 1, 1], [true], 5); -var unitCube6 = new Polycube_1.default([1, 1, 1], [true], 6); -var unitCube7 = new Polycube_1.default([1, 1, 1], [true], 7); -var unitCube8 = new Polycube_1.default([1, 1, 1], [true], 8); -var unitCube9 = new Polycube_1.default([1, 1, 1], [true], 9); -var unitCube10 = new Polycube_1.default([1, 1, 1], [true], 10); -var unitCube11 = new Polycube_1.default([1, 1, 1], [true], 11); -var unitCube12 = new Polycube_1.default([1, 1, 1], [true], 12); -var unitCube13 = new Polycube_1.default([1, 1, 1], [true], 13); -var unitCube14 = new Polycube_1.default([1, 1, 1], [true], 14); -var unitCube15 = new Polycube_1.default([1, 1, 1], [true], 15); -var unitCube16 = new Polycube_1.default([1, 1, 1], [true], 16); -var unitCube17 = new Polycube_1.default([1, 1, 1], [true], 17); -var unitCube18 = new Polycube_1.default([1, 1, 1], [true], 18); -var unitCube19 = new Polycube_1.default([1, 1, 1], [true], 19); -var unitCube20 = new Polycube_1.default([1, 1, 1], [true], 20); -var unitCube21 = new Polycube_1.default([1, 1, 1], [true], 21); -var unitCube22 = new Polycube_1.default([1, 1, 1], [true], 22); -var unitCube23 = new Polycube_1.default([1, 1, 1], [true], 23); -var unitCube24 = new Polycube_1.default([1, 1, 1], [true], 24); -var unitCube25 = new Polycube_1.default([1, 1, 1], [true], 25); -var unitCube26 = new Polycube_1.default([1, 1, 1], [true], 26); -var unitCube27 = new Polycube_1.default([1, 1, 1], [true], 27); -var tetromino1 = new Polycube_1.default([3, 3, 3], [ - true, true, true, - false, true, false, - false, false, false, - false, false, false, - false, false, false, - false, false, false, - false, false, false, - false, false, false, - false, false, false, -], 1); -var tetromino2 = new Polycube_1.default([3, 3, 3], [ - false, false, false, - false, false, false, - false, true, false, - false, true, false, - false, true, false, - false, true, false, - false, false, false, - false, false, false, - false, false, false, -], 2); -var tetromino3 = new Polycube_1.default([3, 3, 3], [ - true, false, false, - true, true, false, - false, true, false, - false, false, false, - false, false, false, - false, false, false, - false, false, false, - false, false, false, - false, false, false, -], 3); -var tetromino4 = new Polycube_1.default([3, 3, 3], [ - true, true, false, - false, false, false, - false, false, false, - true, false, false, - true, false, false, - false, false, false, - false, false, false, - false, false, false, - false, false, false, -], 4); -var tetromino5 = new Polycube_1.default([3, 3, 3], [ - true, true, false, - false, false, false, - false, false, false, - false, true, false, - false, true, false, - false, false, false, - false, false, false, - false, false, false, - false, false, false, -], 5); -var tetromino6 = new Polycube_1.default([3, 3, 3], [ - false, false, false, - false, false, false, - false, true, false, - false, false, false, - false, true, false, - false, true, true, - false, false, false, - false, false, false, - false, false, false, -], 6); -var triomino1 = new Polycube_1.default([3, 3, 3], [ - false, false, false, - false, false, false, - false, true, false, - false, false, false, - false, true, false, - false, true, false, - false, false, false, - false, false, false, - false, false, false, -], 7); -// const cube = new VoxelSpace([3, 3, 3], Array(3**3).fill(0)); -// cube.plus(triomino1)?.plus(tetromino2, {x: 1, y: 0, z: 1})?.print(); -var solver = new SomaSolver_1.default(3); -console.log("solving"); -solver.solve([triomino1, tetromino2, tetromino3, tetromino1, tetromino4, tetromino5, tetromino6]); diff --git a/src/main.ts b/src/main.ts index aa2c480..d6cacbb 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,158 +1,10 @@ -import Polycube from "./Polycube"; -import SomaSolver from "./SomaSolver"; +import App from './App.svelte'; -// const testCube = new Cube([4, 2, 5], [ -// "000", "001", "002", "003", "004", -// "010", "011", "012", "013", "014", -// "100", "101", "102", "103", "104", -// "110", "111", "112", "113", "114", -// "200", "201", "202", "203", "204", -// "210", "211", "212", "213", "214", -// "300", "301", "302", "303", "304", -// "310", "311", "312", "313", "314", -// ]); -// const somaCube = new Polycube([3, 3, 3], [ -// false, false, false, -// false, false, false, -// false, false, false, -// -// true, true, true, -// true, true, true, -// false, false, false, -// -// false, false, false, -// false, false, false, -// false, false, false, -// ], 1); -const unitCube1 = new Polycube([1, 1, 1], [true], 1); -const unitCube2 = new Polycube([1, 1, 1], [true], 2); -const unitCube3 = new Polycube([1, 1, 1], [true], 3); -const unitCube4 = new Polycube([1, 1, 1], [true], 4); -const unitCube5 = new Polycube([1, 1, 1], [true], 5); -const unitCube6 = new Polycube([1, 1, 1], [true], 6); -const unitCube7 = new Polycube([1, 1, 1], [true], 7); -const unitCube8 = new Polycube([1, 1, 1], [true], 8); -const unitCube9 = new Polycube([1, 1, 1], [true], 9); -const unitCube10 = new Polycube([1, 1, 1], [true], 10); -const unitCube11 = new Polycube([1, 1, 1], [true], 11); -const unitCube12 = new Polycube([1, 1, 1], [true], 12); -const unitCube13 = new Polycube([1, 1, 1], [true], 13); -const unitCube14 = new Polycube([1, 1, 1], [true], 14); -const unitCube15 = new Polycube([1, 1, 1], [true], 15); -const unitCube16 = new Polycube([1, 1, 1], [true], 16); -const unitCube17 = new Polycube([1, 1, 1], [true], 17); -const unitCube18 = new Polycube([1, 1, 1], [true], 18); -const unitCube19 = new Polycube([1, 1, 1], [true], 19); -const unitCube20 = new Polycube([1, 1, 1], [true], 20); -const unitCube21 = new Polycube([1, 1, 1], [true], 21); -const unitCube22 = new Polycube([1, 1, 1], [true], 22); -const unitCube23 = new Polycube([1, 1, 1], [true], 23); -const unitCube24 = new Polycube([1, 1, 1], [true], 24); -const unitCube25 = new Polycube([1, 1, 1], [true], 25); -const unitCube26 = new Polycube([1, 1, 1], [true], 26); -const unitCube27 = new Polycube([1, 1, 1], [true], 27); +const app = new App({ + target: document.body, + props: { + name: 'world' + } +}); -const tetromino1 = new Polycube([3, 3, 3], [ - true, true, true, - false, true, false, - false, false, false, - - false, false, false, - false, false, false, - false, false, false, - - false, false, false, - false, false, false, - false, false, false, -], 1); - -const tetromino2 = new Polycube([3, 3, 3], [ - false, false, false, - false, false, false, - false, true, false, - - false, true, false, - false, true, false, - false, true, false, - - false, false, false, - false, false, false, - false, false, false, -], 2); - -const tetromino3 = new Polycube([3, 3, 3], [ - true, false, false, - true, true, false, - false, true, false, - - false, false, false, - false, false, false, - false, false, false, - - false, false, false, - false, false, false, - false, false, false, -], 3); - -const tetromino4 = new Polycube([3, 3, 3], [ - true, true, false, - false, false, false, - false, false, false, - - true, false, false, - true, false, false, - false, false, false, - - false, false, false, - false, false, false, - false, false, false, -], 4); - -const tetromino5 = new Polycube([3, 3, 3], [ - true, true, false, - false, false, false, - false, false, false, - - false, true, false, - false, true, false, - false, false, false, - - false, false, false, - false, false, false, - false, false, false, -], 5); - -const tetromino6 = new Polycube([3, 3, 3], [ - false, false, false, - false, false, false, - false, true, false, - - false, false, false, - false, true, false, - false, true, true, - - false, false, false, - false, false, false, - false, false, false, -], 6); - -const triomino1 = new Polycube([3, 3, 3], [ - false, false, false, - false, false, false, - false, true, false, - - false, false, false, - false, true, false, - false, true, false, - - false, false, false, - false, false, false, - false, false, false, -], 7); - -// const cube = new VoxelSpace([3, 3, 3], Array(3**3).fill(0)); -// cube.plus(triomino1)?.plus(tetromino2, {x: 1, y: 0, z: 1})?.print(); - -const solver = new SomaSolver(3); -console.log("solving"); -solver.solve([triomino1, tetromino2, tetromino3, tetromino1, tetromino4, tetromino5, tetromino6]); +export default app; \ No newline at end of file diff --git a/src/solver/SomaSolution.ts b/src/solver/SomaSolution.ts new file mode 100644 index 0000000..f53edac --- /dev/null +++ b/src/solver/SomaSolution.ts @@ -0,0 +1,99 @@ +import type VoxelSpace from "./VoxelSpace"; + +export default class SomaSolution { + private solutionSpaces: VoxelSpace[]; + private dim: number; + constructor(dim: number) { + if (dim < 0 || dim % 1 !== 0) { + throw new Error("Dimension must be a whole positive integer!"); + } + this.dim = dim; + this.solutionSpaces = []; + } + + static filterUnique(solutions: SomaSolution[]): SomaSolution[] { + if (solutions.length === 0) { + return []; + } + const uniqueSolns = [solutions[0]]; + for (const solution of solutions) { + let foundMatch = false; + for (const rotation of solution.getUniqueRotations()) { + let end = uniqueSolns.length; + for (let i = 0; i < end; i++) { + if (rotation.matches(uniqueSolns[i])) { + foundMatch = true; + } + } + } + if (!foundMatch) { + uniqueSolns.push(solution); + } + } + return uniqueSolns; + } + + getUniqueRotations(): SomaSolution[] { + if (this.solutionSpaces.length === 0) { + return []; + } + const result: SomaSolution[] = []; + const allRots = this.solutionSpaces.map(space => space.getAllRotations()); + for (let i = 0; i < allRots[0].length; i++) { + const solnRot = new SomaSolution(this.dim); + allRots.forEach(rotGroup => solnRot.addSpace(rotGroup[i])); + result.push(solnRot); + } + return result; + } + + matches(solution: SomaSolution) { + for (let i = 0; i < this.solutionSpaces.length; i++) { + if (!this.solutionSpaces[i].matches(solution.solutionSpaces[i])) { + return false; + } + } + return true; + } + + addSpace(space: VoxelSpace) { + this.solutionSpaces.push(space); + } + + print() { + let accum = ""; + console.log("---"); + for (let x = 0; x < this.dim; x++) { + for (let y = 0; y < this.dim; y++) { + for (let z = 0; z < this.dim; z++) { + for (const space of this.solutionSpaces) { + if (space.at(x, y, z)) { + accum += space.getId(); + } + } + } + console.log(accum); + accum = ""; + } + if (x !== this.dim - 1) { + console.log("-"); + } + } + console.log("---"); + } + + at(x: number, y: number, z: number) { + for (const space of this.solutionSpaces) { + if (space.at(x, y, z)) { + return space.getId(); + } + } + return 0; + } + + clone() { + const clone = new SomaSolution(this.dim); + clone.solutionSpaces = this.solutionSpaces.slice(); + return clone; + } +} \ No newline at end of file diff --git a/src/solver/SomaSolver.ts b/src/solver/SomaSolver.ts new file mode 100644 index 0000000..953926d --- /dev/null +++ b/src/solver/SomaSolver.ts @@ -0,0 +1,49 @@ +import VoxelSpace from "./VoxelSpace"; +import SomaSolution from "./SomaSolution"; + +export default class SomaSolver { + private solutionCube: VoxelSpace; + private dim: number; + private solutions: SomaSolution[] = []; + private iterations: number = 0; + constructor(dimension: number) { + if (dimension % 1 !== 0 || dimension < 0) { + throw new Error("The argument 'dimension' must be a positive whole number"); + } + this.dim = dimension; + this.solutionCube = new VoxelSpace(0, [dimension, dimension, dimension], Array(dimension**3).fill(0)); + } + + solve(polycubes: VoxelSpace[]) { + if (polycubes.length === 0) { + throw new Error("You must pass at least one polycube to solve the puzzle."); + } + let cumulativeSize = polycubes.reduce((prev, curr) => prev + curr.size(), 0); + if (cumulativeSize !== this.dim**3) { + throw new Error(`The polycubes passed do not add up to exactly enough units to form a cube of dimension ${this.dim}! Got: ${cumulativeSize}, need: ${this.dim**3}`); + } + const combosWithRots = polycubes.slice(1).map(polycube => polycube.getUniqueRotations().map(rot => rot.getAllPositionsInCube(this.dim)).flat()); + const combos = [polycubes[0].getAllPositionsInCube(this.dim), ...combosWithRots]; + this.backtrackSolve(this.solutionCube, combos, new SomaSolution(this.dim)); + this.solutions = SomaSolution.filterUnique(this.solutions); + this.solutions.forEach(sol => sol.print()); + } + + private backtrackSolve(workingSolution: VoxelSpace, polycubes: VoxelSpace[][], currentSoln: SomaSolution, depth = 0) { + const nextCubeGroup = polycubes[0]; + for (let i = 0; i < nextCubeGroup.length; i++) { + const fusionAttempt = workingSolution.plus(nextCubeGroup[i]); + if (fusionAttempt) { + const nextSoln = currentSoln.clone(); + nextSoln.addSpace(nextCubeGroup[i]); + if (polycubes.length === 1) { + this.solutions.push(nextSoln); + currentSoln = new SomaSolution(this.dim); + return; + } else { + this.backtrackSolve(fusionAttempt, polycubes.slice(1), nextSoln, depth + 1); + } + } + } + } +} \ No newline at end of file diff --git a/src/VoxelSpace.ts b/src/solver/VoxelSpace.ts similarity index 52% rename from src/VoxelSpace.ts rename to src/solver/VoxelSpace.ts index 1f0a573..5bf241b 100644 --- a/src/VoxelSpace.ts +++ b/src/solver/VoxelSpace.ts @@ -1,21 +1,42 @@ -import Polycube from "./Polycube"; - export type DimensionDef = [number, number, number]; export default class VoxelSpace { - protected vals: number[]; - protected dims: DimensionDef; - constructor(dims: DimensionDef, vals: number[], cullEmpty?: boolean) { - if (vals.length !== dims[0] * dims[1] * dims[2]) { - throw new Error("Vals don't fit in given dimensions."); + private dims: DimensionDef; + private length: number; + private space: bigint; + private id: number; + constructor(id: number, dims: DimensionDef, space?: boolean[] | bigint, cullEmpty?: boolean) { + if (!space) { + space = 0n; + } else if (Array.isArray(space)) { + if (space.length !== dims[0] * dims[1] * dims[2]) { + throw new Error("Vals don't fit in given dimensions."); + } + space = VoxelSpace.boolArrayToBigInt(space) } + this.id = id; + this.length = dims[0] * dims[1] * dims[2]; this.dims = dims; - this.vals = vals; + this.space = space; if (cullEmpty) { this.cullEmptySpace(); } } + private static boolArrayToBigInt(boolArray: boolean[]): bigint { + let result = 0n; + for (let i = 0; i < boolArray.length; i++) { + if (boolArray[i]) { + result |= BigInt(1 << i); + } + } + return result; + } + + binaryRep() { + return this.space.toString(2); + } + private cullEmptySpace() { const extrema = { xMax: -Infinity, @@ -25,31 +46,35 @@ export default class VoxelSpace { zMax: -Infinity, zMin: Infinity, }; - const newVals: number[] = []; - this.forEachCell((val, i, j, k) => { - if (val !== 0) { - extrema.xMax = Math.max(extrema.xMax, i); - extrema.xMin = Math.min(extrema.xMin, i); - extrema.yMax = Math.max(extrema.yMax, j); - extrema.yMin = Math.min(extrema.yMin, j); - extrema.zMax = Math.max(extrema.zMax, k); - extrema.zMin = Math.min(extrema.zMin, k); + let newSpace = 0n; + this.forEachCell((val, x, y, z) => { + if (val) { + extrema.xMax = Math.max(extrema.xMax, x); + extrema.xMin = Math.min(extrema.xMin, x); + extrema.yMax = Math.max(extrema.yMax, y); + extrema.yMin = Math.min(extrema.yMin, y); + extrema.zMax = Math.max(extrema.zMax, z); + extrema.zMin = Math.min(extrema.zMin, z); } }); - for (let i = extrema.xMin; i <= extrema.xMax; i++) { - for (let j = extrema.yMin; j <= extrema.yMax; j++) { - for (let k = extrema.zMin; k <= extrema.zMax; k++) { - newVals.push(this.at(i, j, k)); + let index = 0n; + for (let x = extrema.xMin; x <= extrema.xMax; x++) { + for (let y = extrema.yMin; y <= extrema.yMax; y++) { + for (let z = extrema.zMin; z <= extrema.zMax; z++) { + if (this.at(x, y, z)) { + newSpace |= 1n << index; + } + index++; } } } this.dims[0] = extrema.xMax - extrema.xMin + 1; this.dims[1] = extrema.yMax - extrema.yMin + 1; this.dims[2] = extrema.zMax - extrema.zMin + 1; - this.vals = newVals; + this.space = newSpace; } - forEachCell(cb: (val: number, x: number, y: number, z: number) => any) { + forEachCell(cb: (val: boolean, x: number, y: number, z: number) => any) { loopStart: for (let x = 0; x < this.dims[0]; x++) { for (let y = 0; y < this.dims[1]; y++) { for (let z = 0; z < this.dims[2]; z++) { @@ -61,13 +86,17 @@ export default class VoxelSpace { } } + getId() { + return this.id; + } + print() { let accum = ""; console.log("---"); for (let i = 0; i < this.dims[0]; i++) { for (let j = 0; j < this.dims[1]; j++) { for (let k = 0; k < this.dims[2]; k++) { - accum += this.at(i, j, k); + accum += this.at(i, j, k) ? '#' : 'O'; } console.log(accum); accum = ""; @@ -97,26 +126,22 @@ export default class VoxelSpace { return rotations; } - static filterUnique(spaces: T[]): T[] { - if (spaces.length === 0) { - return []; - } - const uniqueSpaces = [spaces[0]]; - for (const space of spaces) { - let foundMatch = false; - for (const rotation of space.getUniqueRotations()) { - let end = uniqueSpaces.length; - for (let i = 0; i < end; i++) { - if (rotation.matches(uniqueSpaces[i])) { - foundMatch = true; - } - } - } - if (!foundMatch) { - uniqueSpaces.push(space); - } - } - return uniqueSpaces; + getAllRotations() { + const rotations: VoxelSpace[] = []; + const refSpace = this.clone(); + rotations.push(...refSpace.getAxisSpins('x')); + refSpace.rot90('y'); + rotations.push(...refSpace.getAxisSpins('x')); + refSpace.rot90('y'); + rotations.push(...refSpace.getAxisSpins('x')); + refSpace.rot90('y'); + rotations.push(...refSpace.getAxisSpins('x')); + refSpace.rot90('z'); + rotations.push(...refSpace.getAxisSpins('x')); + refSpace.rot90('z'); + refSpace.rot90('z'); + rotations.push(...refSpace.getAxisSpins('x')); + return rotations; } protected static pushNewUniqueSpaces(existingSpaces: VoxelSpace[], newSpaces: VoxelSpace[]) { @@ -134,6 +159,26 @@ export default class VoxelSpace { } } + getAllPositionsInCube(cubeDim: number): VoxelSpace[] { + if ((cubeDim > 0) && (cubeDim % 1 === 0)) { + const cubePositions: VoxelSpace[] = []; + for (let x = 0; x < cubeDim - this.dims[0] + 1; x++) { + for (let y = 0; y < cubeDim - this.dims[1] + 1; y++) { + for (let z = 0; z < cubeDim - this.dims[2] + 1; z++) { + const cubePos = new VoxelSpace(this.id, [cubeDim, cubeDim, cubeDim]); + this.forEachCell((val, rotX, rotY, rotZ) => { + cubePos.set(x + rotX, y + rotY, z + rotZ, val); + }); + cubePositions.push(cubePos); + } + } + } + return cubePositions; + } else { + throw new Error("cubeDim must be a positive integer."); + } + } + matches(space: VoxelSpace) { const otherDims = space.getDims(); for (let i = 0; i < this.dims.length; i++) { @@ -141,17 +186,11 @@ export default class VoxelSpace { return false; } } - const otherVals = space.getVals(); - for (let i = 0; i < this.vals.length; i++) { - if (this.vals[i] !== otherVals[i]) { - return false; - } - } - return true; + return this.space === space.getRaw(); } clone() { - return new VoxelSpace(this.getDims(), this.getVals()); + return new VoxelSpace(this.id, this.getDims(), this.getRaw()); } private getAxisSpins(axis: 'x' | 'y' | 'z'): VoxelSpace[] { @@ -166,8 +205,8 @@ export default class VoxelSpace { return this.dims.slice() as DimensionDef; } - getVals() { - return this.vals.slice(); + getRaw() { + return this.space; } // [1, 0, 0] [x] [ x] @@ -192,15 +231,26 @@ export default class VoxelSpace { } at(x: number, y: number, z: number) { - return this.vals[this.dims[1] * this.dims[2] * x + this.dims[2] * y + z]; + const mask = 1n << BigInt(this.dims[1] * this.dims[2] * x + this.dims[2] * y + z); + return (this.space & mask) !== 0n; } - set(x: number, y: number, z: number, val: number) { - this.vals[this.dims[1] * this.dims[2] * x + this.dims[2] * y + z] = val; + toggle(x: number, y: number, z: number) { + const mask = BigInt(1 << this.dims[1] * this.dims[2] * x + this.dims[2] * y + z); + this.space ^= mask; + } + + set(x: number, y: number, z: number, val: boolean) { + const mask = BigInt(1 << this.dims[1] * this.dims[2] * x + this.dims[2] * y + z); + if (val) { + this.space |= mask; + } else { + this.space &= ~mask; + } } rotated90(dim: 'x' | 'y' | 'z') { - const newVals = [...this.vals]; + let newSpace = 0n; let newDims: DimensionDef; let rotIndex: (i: number, j: number, k: number) => number; if (dim === 'x') { @@ -214,33 +264,34 @@ export default class VoxelSpace { rotIndex = this.newIndexRotZ.bind(this); } this.forEachCell((val, i, j, k) => { - newVals[rotIndex(i, j, k)] = val; + if (val) { + newSpace |= BigInt(1 << rotIndex(i, j, k)); + } }) - return new VoxelSpace(newDims, newVals); + return new VoxelSpace(this.id, newDims, newSpace); } rot90(dim: 'x' | 'y' | 'z') { const rot = this.rotated90(dim); - this.vals = rot.getVals(); + this.space = rot.getRaw(); this.dims = rot.getDims(); } - plus(space: VoxelSpace, startX: number, startY: number, startZ: number): VoxelSpace | null { - let result: VoxelSpace = this.clone(); - const spaceDims = space.getDims(); - for (let i = 0; i < spaceDims[0]; i++) { - for (let j = 0; j < spaceDims[1]; j++) { - for (let k = 0; k < spaceDims[2]; k++) { - const sourceVal = space.at(i, j, k); - const targetEmpty = result.at(startX + i, startY + j, startZ + k) === 0; - if (sourceVal !== 0 && targetEmpty) { - result.set(startX + i, startY + j, startZ + k, sourceVal); - } else if (sourceVal !== 0 && !targetEmpty) { - return null; - } - } - } + plus(space: VoxelSpace): VoxelSpace | null { + const otherSpace = space.getRaw(); + if ((this.space | otherSpace) === (this.space ^ otherSpace)) { + return new VoxelSpace(this.id, this.dims, otherSpace | this.space); } - return result; + return null; + } + + size() { + let size = 0; + this.forEachCell((val) => { + if (val) { + size++; + } + }); + return size; } } \ No newline at end of file diff --git a/src/solver/main.js b/src/solver/main.js new file mode 100644 index 0000000..d6cacbb --- /dev/null +++ b/src/solver/main.js @@ -0,0 +1,10 @@ +import App from './App.svelte'; + +const app = new App({ + target: document.body, + props: { + name: 'world' + } +}); + +export default app; \ No newline at end of file diff --git a/src/solver/main.ts b/src/solver/main.ts new file mode 100644 index 0000000..7fbe282 --- /dev/null +++ b/src/solver/main.ts @@ -0,0 +1,109 @@ +import SomaSolver from "./SomaSolver"; +import VoxelSpace from "./VoxelSpace"; + +const tetromino1 = new VoxelSpace(1, [3, 3, 3], [ + true, true, true, + false, true, false, + false, false, false, + + false, false, false, + false, false, false, + false, false, false, + + false, false, false, + false, false, false, + false, false, false, +], true); + +const tetromino2 = new VoxelSpace(2, [3, 3, 3], [ + false, false, false, + false, false, false, + false, true, false, + + false, true, false, + false, true, false, + false, true, false, + + false, false, false, + false, false, false, + false, false, false, +], true); + +const tetromino3 = new VoxelSpace(3, [3, 3, 3], [ + true, false, false, + true, true, false, + false, true, false, + + false, false, false, + false, false, false, + false, false, false, + + false, false, false, + false, false, false, + false, false, false, +], true); + +const tetromino4 = new VoxelSpace(4, [3, 3, 3], [ + true, true, false, + false, false, false, + false, false, false, + + true, false, false, + true, false, false, + false, false, false, + + false, false, false, + false, false, false, + false, false, false, +], true); + +const tetromino5 = new VoxelSpace(5, [3, 3, 3], [ + true, true, false, + false, false, false, + false, false, false, + + false, true, false, + false, true, false, + false, false, false, + + false, false, false, + false, false, false, + false, false, false, +], true); + +const tetromino6 = new VoxelSpace(6, [3, 3, 3], [ + false, false, false, + false, false, false, + false, true, false, + + false, false, false, + false, true, false, + false, true, true, + + false, false, false, + false, false, false, + false, false, false, +], true); + +const triomino1 = new VoxelSpace(7, [3, 3, 3], [ + false, false, false, + false, false, false, + false, true, false, + + false, false, false, + false, true, false, + false, true, false, + + false, false, false, + false, false, false, + false, false, false, +], true); + + + +// const cube = new VoxelSpace([3, 3, 3], Array(3**3).fill(0)); +// cube.plus(triomino1)?.plus(tetromino2, {x: 1, y: 0, z: 1})?.print(); + +const solver = new SomaSolver(3); +console.log("solving"); +solver.solve([triomino1, tetromino2, tetromino3, tetromino1, tetromino4, tetromino5, tetromino6]); diff --git a/src/store.ts b/src/store.ts new file mode 100644 index 0000000..ed7255f --- /dev/null +++ b/src/store.ts @@ -0,0 +1,101 @@ +import { derived, writable } from 'svelte/store'; +import { get } from 'svelte/store'; + +type PolycubeInput = { + color: string, + rep: bigint, +} + +const MAX_DIMS = 5; +const MIN_DIMS = 2; + +const store = { + polycubes: writable([{rep: BigInt(0), color: colorFromIndex(0)}]), + somaDimension: writable(3), +}; + +export const selectedCube = writable(0); +export const isMaxDimension = derived(store.somaDimension, $somaDimension => $somaDimension >= MAX_DIMS); +export const isMinDimension = derived(store.somaDimension, $somaDimension => $somaDimension <= MIN_DIMS); +export const isMaxPolycubes = derived([store.polycubes, store.somaDimension], ([$polycubes, $somaDimension]) => $polycubes.length >= $somaDimension ** 3); +export const isMinPolycubes = derived(store.polycubes, ($polycubes) => $polycubes.length <= 1); + +export const somaDimension = { + subscribe: store.somaDimension.subscribe, + inc() { + if (!get(isMaxDimension)) { + store.somaDimension.update(dims => { + polycubes.reset(dims + 1); + return dims + 1; + }); + } + }, + dec() { + if (!get(isMinDimension)) { + store.somaDimension.update(dims => { + polycubes.reset(dims - 1); + return dims - 1; + }); + } + } +}; + +export const polycubes = { + subscribe: store.polycubes.subscribe, + addCube() { + const isMaxPolycubes = get(store.polycubes).length >= get(store.somaDimension) ** 3; + if (!isMaxPolycubes) { + store.polycubes.update(polycubes => polycubes.concat({ + rep: BigInt(0), + color: colorFromIndex(polycubes.length), + })); + } + }, + removeCube() { + const isMinPolycubes = get(store.polycubes).length <= 1; + if (!isMinPolycubes) { + store.polycubes.update(polycubes => polycubes.splice(0, polycubes.length - 1)); + } + }, + toggle(cubeIndex: number, x: number, y: number, z: number) { + const dims = get(store.somaDimension); + const mask = BigInt(1) << BigInt(dims ** 2 * x + dims * y + z); + const cubes = get(store.polycubes); + cubes[cubeIndex].rep ^= mask; + store.polycubes.set(cubes); + }, + set(cubeIndex: number, val: boolean, x: number, y: number, z: number) { + const dims = get(store.somaDimension); + const mask = BigInt(1) << BigInt(dims ** 2 * x + dims * y + z); + const cubes = get(store.polycubes); + if (val) { + cubes[cubeIndex].rep |= mask + } else { + cubes[cubeIndex].rep &= ~mask + } + store.polycubes.set(cubes); + }, + reset(dims: number) { + store.polycubes.update(polycubes => { + const result: PolycubeInput[] = []; + for (let i = 0; i < Math.min(polycubes.length, dims**3); i++) { + result.push({ + rep: BigInt(0), + color: colorFromIndex(i), + }); + } + return result; + }); + } +}; + +function colorFromIndex(index: number) { + const colorWheelCycle = Math.floor(index / 6); + const darknessCycle = Math.floor(index / 12); + const spacing = (360 / 6); + const offset = colorWheelCycle === 0 ? 0 : spacing / (colorWheelCycle + 2); + let hue = spacing * (index % 6) + offset; + const saturation = 100; + const lightness = 1 / (2 + darknessCycle) * 100; + return `hsl(${hue},${saturation}%,${lightness}%)`; +} \ No newline at end of file diff --git a/src/test.html b/src/test.html deleted file mode 100644 index f1d4c75..0000000 --- a/src/test.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - Title - - - - -Start - - - \ No newline at end of file diff --git a/src/test.js b/src/test.js deleted file mode 100644 index 47e8bd4..0000000 --- a/src/test.js +++ /dev/null @@ -1,499 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __spreadArrays = (this && this.__spreadArrays) || function () { - for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; - for (var r = Array(s), k = 0, i = 0; i < il; i++) - for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) - r[k] = a[j]; - return r; -}; -var SomaSolver = /** @class */ (function () { - function SomaSolver(dimension) { - this.solutions = []; - this.iterations = 0; - if (dimension % 1 !== 0 || dimension < 0) { - throw new Error("The argument 'dimension' must be a positive whole number"); - } - this.dim = dimension; - this.solutionCube = new VoxelSpace([dimension, dimension, dimension], Array(Math.pow(dimension, 3)).fill(0)); - } - SomaSolver.prototype.solve = function (polycubes) { - if (polycubes.length === 0) { - throw new Error("You must pass at least one polycube to solve the puzzle."); - } - var cumulativeSize = polycubes.reduce(function (prev, curr) { return prev + curr.size(); }, 0); - if (cumulativeSize !== Math.pow(this.dim, 3)) { - throw new Error("The polycubes passed do not add up to exactly enough units to form a cube of dimension " + this.dim + "! Got: " + cumulativeSize + ", need: " + Math.pow(this.dim, 3)); - } - this.iterations = 0; - this.backtrackSolve(this.solutionCube, polycubes); - this.solutions = VoxelSpace.filterUnique(this.solutions); - this.solutions.forEach(function (sol) { return sol.print(); }); - console.log(this.solutions.length); - }; - SomaSolver.prototype.backtrackSolve = function (workingSolution, polycubes, depth) { - if (depth === void 0) { depth = 0; } - var nextCube = polycubes[0]; - var rots = depth === 0 ? [nextCube] : nextCube.getUniqueRotations(); - for (var i = 0; i < rots.length; i++) { - var polyCubeDims = rots[i].getDims(); - for (var x = 0; x < this.dim - polyCubeDims[0] + 1; x++) { - for (var y = 0; y < this.dim - polyCubeDims[1] + 1; y++) { - for (var z = 0; z < this.dim - polyCubeDims[2] + 1; z++) { - var successfulFusion = workingSolution.plus(rots[i], x, y, z); - if (successfulFusion) { - if (polycubes.length === 1) { - console.log("soln", this.iterations++); - this.solutions.push(successfulFusion); - return; - } - else { - this.backtrackSolve(successfulFusion, polycubes.slice(1), depth + 1); - } - } - } - } - } - } - }; - return SomaSolver; -}()); -var VoxelSpace = /** @class */ (function () { - function VoxelSpace(dims, vals, cullEmpty) { - if (vals.length !== dims[0] * dims[1] * dims[2]) { - throw new Error("Vals don't fit in given dimensions."); - } - this.dims = dims; - this.vals = vals; - if (cullEmpty) { - this.cullEmptySpace(); - } - } - VoxelSpace.prototype.cullEmptySpace = function () { - var extrema = { - xMax: -Infinity, - xMin: Infinity, - yMax: -Infinity, - yMin: Infinity, - zMax: -Infinity, - zMin: Infinity, - }; - var newVals = []; - this.forEachCell(function (val, i, j, k) { - if (val !== 0) { - extrema.xMax = Math.max(extrema.xMax, i); - extrema.xMin = Math.min(extrema.xMin, i); - extrema.yMax = Math.max(extrema.yMax, j); - extrema.yMin = Math.min(extrema.yMin, j); - extrema.zMax = Math.max(extrema.zMax, k); - extrema.zMin = Math.min(extrema.zMin, k); - } - }); - for (var i = extrema.xMin; i <= extrema.xMax; i++) { - for (var j = extrema.yMin; j <= extrema.yMax; j++) { - for (var k = extrema.zMin; k <= extrema.zMax; k++) { - newVals.push(this.at(i, j, k)); - } - } - } - this.dims[0] = extrema.xMax - extrema.xMin + 1; - this.dims[1] = extrema.yMax - extrema.yMin + 1; - this.dims[2] = extrema.zMax - extrema.zMin + 1; - this.vals = newVals; - }; - VoxelSpace.prototype.forEachCell = function (cb) { - loopStart: for (var x = 0; x < this.dims[0]; x++) { - for (var y = 0; y < this.dims[1]; y++) { - for (var z = 0; z < this.dims[2]; z++) { - if (cb(this.at(x, y, z), x, y, z) === 0) { - break loopStart; - } - } - } - } - }; - VoxelSpace.prototype.print = function () { - var accum = ""; - console.log("---"); - for (var i = 0; i < this.dims[0]; i++) { - for (var j = 0; j < this.dims[1]; j++) { - for (var k = 0; k < this.dims[2]; k++) { - accum += this.at(i, j, k); - } - console.log(accum); - accum = ""; - } - if (i !== this.dims[0] - 1) { - console.log("-"); - } - } - console.log("---"); - }; - VoxelSpace.prototype.getUniqueRotations = function () { - var rotations = []; - var refSpace = this.clone(); - VoxelSpace.pushNewUniqueSpaces(rotations, refSpace.getAxisSpins('x')); - refSpace.rot90('y'); - VoxelSpace.pushNewUniqueSpaces(rotations, refSpace.getAxisSpins('x')); - refSpace.rot90('y'); - VoxelSpace.pushNewUniqueSpaces(rotations, refSpace.getAxisSpins('x')); - refSpace.rot90('y'); - VoxelSpace.pushNewUniqueSpaces(rotations, refSpace.getAxisSpins('x')); - refSpace.rot90('z'); - VoxelSpace.pushNewUniqueSpaces(rotations, refSpace.getAxisSpins('x')); - refSpace.rot90('z'); - refSpace.rot90('z'); - VoxelSpace.pushNewUniqueSpaces(rotations, refSpace.getAxisSpins('x')); - return rotations; - }; - VoxelSpace.filterUnique = function (spaces) { - if (spaces.length === 0) { - return []; - } - var uniqueSpaces = [spaces[0]]; - for (var _i = 0, spaces_1 = spaces; _i < spaces_1.length; _i++) { - var space = spaces_1[_i]; - var foundMatch = false; - for (var _a = 0, _b = space.getUniqueRotations(); _a < _b.length; _a++) { - var rotation = _b[_a]; - var end = uniqueSpaces.length; - for (var i = 0; i < end; i++) { - if (rotation.matches(uniqueSpaces[i])) { - foundMatch = true; - } - } - } - if (!foundMatch) { - uniqueSpaces.push(space); - } - } - return uniqueSpaces; - }; - VoxelSpace.pushNewUniqueSpaces = function (existingSpaces, newSpaces) { - for (var _i = 0, newSpaces_1 = newSpaces; _i < newSpaces_1.length; _i++) { - var newSpace = newSpaces_1[_i]; - var matchFound = false; - for (var _a = 0, existingSpaces_1 = existingSpaces; _a < existingSpaces_1.length; _a++) { - var existingSpace = existingSpaces_1[_a]; - if (newSpace.matches(existingSpace)) { - matchFound = true; - break; - } - } - if (!matchFound) { - existingSpaces.push(newSpace); - } - } - }; - VoxelSpace.prototype.matches = function (space) { - var otherDims = space.getDims(); - for (var i = 0; i < this.dims.length; i++) { - if (otherDims[i] !== this.dims[i]) { - return false; - } - } - var otherVals = space.getVals(); - for (var i = 0; i < this.vals.length; i++) { - if (this.vals[i] !== otherVals[i]) { - return false; - } - } - return true; - }; - VoxelSpace.prototype.clone = function () { - return new VoxelSpace(this.getDims(), this.getVals()); - }; - VoxelSpace.prototype.getAxisSpins = function (axis) { - var rotations = [this.clone()]; - for (var i = 0; i < 3; i++) { - rotations.push(rotations[i].rotated90(axis)); - } - return rotations; - }; - VoxelSpace.prototype.getDims = function () { - return this.dims.slice(); - }; - VoxelSpace.prototype.getVals = function () { - return this.vals.slice(); - }; - // [1, 0, 0] [x] [ x] - // [0, 0, -1] * [y] = [-z] - // [0, 1, 0] [z] [ y] - VoxelSpace.prototype.newIndexRotX = function (x, y, z) { - return this.dims[2] * this.dims[1] * x + this.dims[1] * (this.dims[2] - 1 - z) + y; - }; - // [ 0, 0, 1] [x] [ z] - // [ 0, 1, 0] * [y] = [ y] - // [-1, 0, 0] [z] [-x] - VoxelSpace.prototype.newIndexRotY = function (x, y, z) { - return this.dims[1] * this.dims[0] * z + this.dims[0] * y + (this.dims[0] - 1 - x); - }; - // [0, -1, 0] [x] [-y] - // [1, 0, 0] * [y] = [ x] - // [0, 0, 1] [z] [ z] - VoxelSpace.prototype.newIndexRotZ = function (x, y, z) { - return this.dims[0] * this.dims[2] * (this.dims[1] - 1 - y) + this.dims[2] * x + z; - }; - VoxelSpace.prototype.at = function (x, y, z) { - return this.vals[this.dims[1] * this.dims[2] * x + this.dims[2] * y + z]; - }; - VoxelSpace.prototype.set = function (x, y, z, val) { - this.vals[this.dims[1] * this.dims[2] * x + this.dims[2] * y + z] = val; - }; - VoxelSpace.prototype.rotated90 = function (dim) { - var newVals = __spreadArrays(this.vals); - var newDims; - var rotIndex; - if (dim === 'x') { - newDims = [this.dims[0], this.dims[2], this.dims[1]]; - rotIndex = this.newIndexRotX.bind(this); - } - else if (dim === 'y') { - newDims = [this.dims[2], this.dims[1], this.dims[0]]; - rotIndex = this.newIndexRotY.bind(this); - } - else { - newDims = [this.dims[1], this.dims[0], this.dims[2]]; - rotIndex = this.newIndexRotZ.bind(this); - } - this.forEachCell(function (val, i, j, k) { - newVals[rotIndex(i, j, k)] = val; - }); - return new VoxelSpace(newDims, newVals); - }; - VoxelSpace.prototype.rot90 = function (dim) { - var rot = this.rotated90(dim); - this.vals = rot.getVals(); - this.dims = rot.getDims(); - }; - VoxelSpace.prototype.plus = function (space, startX, startY, startZ) { - var result = this.clone(); - var spaceDims = space.getDims(); - for (var i = 0; i < spaceDims[0]; i++) { - for (var j = 0; j < spaceDims[1]; j++) { - for (var k = 0; k < spaceDims[2]; k++) { - var sourceVal = space.at(i, j, k); - var targetEmpty = result.at(startX + i, startY + j, startZ + k) === 0; - if (sourceVal !== 0 && targetEmpty) { - result.set(startX + i, startY + j, startZ + k, sourceVal); - } - else if (sourceVal !== 0 && !targetEmpty) { - return null; - } - } - } - } - return result; - }; - return VoxelSpace; -}()); -var Polycube = /** @class */ (function (_super) { - __extends(Polycube, _super); - function Polycube(dims, vals, id) { - var _this = _super.call(this, dims, vals.map(function (val) { return val ? id : 0; }), true) || this; - _this.id = id; - return _this; - } - Polycube.prototype.getId = function () { - return this.id; - }; - Polycube.prototype.print = function () { - var accum = ""; - console.log("---"); - for (var i = 0; i < this.dims[0]; i++) { - for (var j = 0; j < this.dims[1]; j++) { - for (var k = 0; k < this.dims[2]; k++) { - accum += this.at(i, j, k) === 0 ? "O" : "#"; - } - console.log(accum); - accum = ""; - } - if (i !== this.dims[0] - 1) { - console.log("-"); - } - } - console.log("---"); - }; - Polycube.prototype.matches = function (cube) { - var otherDims = cube.getDims(); - for (var i = 0; i < this.dims.length; i++) { - if (otherDims[i] !== this.dims[i]) { - return false; - } - } - var otherVals = cube.getVals(); - for (var i = 0; i < this.vals.length; i++) { - if (Number(this.vals[i]) !== Number(otherVals[i])) { - return false; - } - } - return true; - }; - Polycube.prototype.size = function () { - var size = 0; - this.forEachCell(function (val) { - if (val) { - size++; - } - }); - return size; - }; - Polycube.prototype.rotated90 = function (dim) { - var rotated = _super.prototype.rotated90.call(this, dim); - return new Polycube(rotated.getDims(), rotated.getVals(), this.id); - }; - Polycube.prototype.clone = function () { - return new Polycube(this.getDims(), this.getVals(), this.id); - }; - Polycube.prototype.getUniqueRotations = function () { - var _this = this; - return _super.prototype.getUniqueRotations.call(this).map(function (rot) { return new Polycube(rot.getDims(), rot.getVals(), _this.id); }); - }; - return Polycube; -}(VoxelSpace)); -// const testCube = new Cube([4, 2, 5], [ -// "000", "001", "002", "003", "004", -// "010", "011", "012", "013", "014", -// "100", "101", "102", "103", "104", -// "110", "111", "112", "113", "114", -// "200", "201", "202", "203", "204", -// "210", "211", "212", "213", "214", -// "300", "301", "302", "303", "304", -// "310", "311", "312", "313", "314", -// ]); -// const somaCube = new Polycube([3, 3, 3], [ -// false, false, false, -// false, false, false, -// false, false, false, -// -// true, true, true, -// true, true, true, -// false, false, false, -// -// false, false, false, -// false, false, false, -// false, false, false, -// ], 1); -var unitCube1 = new Polycube([1, 1, 1], [true], 1); -var unitCube2 = new Polycube([1, 1, 1], [true], 2); -var unitCube3 = new Polycube([1, 1, 1], [true], 3); -var unitCube4 = new Polycube([1, 1, 1], [true], 4); -var unitCube5 = new Polycube([1, 1, 1], [true], 5); -var unitCube6 = new Polycube([1, 1, 1], [true], 6); -var unitCube7 = new Polycube([1, 1, 1], [true], 7); -var unitCube8 = new Polycube([1, 1, 1], [true], 8); -var unitCube9 = new Polycube([1, 1, 1], [true], 9); -var unitCube10 = new Polycube([1, 1, 1], [true], 10); -var unitCube11 = new Polycube([1, 1, 1], [true], 11); -var unitCube12 = new Polycube([1, 1, 1], [true], 12); -var unitCube13 = new Polycube([1, 1, 1], [true], 13); -var unitCube14 = new Polycube([1, 1, 1], [true], 14); -var unitCube15 = new Polycube([1, 1, 1], [true], 15); -var unitCube16 = new Polycube([1, 1, 1], [true], 16); -var unitCube17 = new Polycube([1, 1, 1], [true], 17); -var unitCube18 = new Polycube([1, 1, 1], [true], 18); -var unitCube19 = new Polycube([1, 1, 1], [true], 19); -var unitCube20 = new Polycube([1, 1, 1], [true], 20); -var unitCube21 = new Polycube([1, 1, 1], [true], 21); -var unitCube22 = new Polycube([1, 1, 1], [true], 22); -var unitCube23 = new Polycube([1, 1, 1], [true], 23); -var unitCube24 = new Polycube([1, 1, 1], [true], 24); -var unitCube25 = new Polycube([1, 1, 1], [true], 25); -var unitCube26 = new Polycube([1, 1, 1], [true], 26); -var unitCube27 = new Polycube([1, 1, 1], [true], 27); -var tetromino1 = new Polycube([3, 3, 3], [ - true, true, true, - false, true, false, - false, false, false, - false, false, false, - false, false, false, - false, false, false, - false, false, false, - false, false, false, - false, false, false, -], 1); -var tetromino2 = new Polycube([3, 3, 3], [ - false, false, false, - false, false, false, - false, true, false, - false, true, false, - false, true, false, - false, true, false, - false, false, false, - false, false, false, - false, false, false, -], 2); -var tetromino3 = new Polycube([3, 3, 3], [ - true, false, false, - true, true, false, - false, true, false, - false, false, false, - false, false, false, - false, false, false, - false, false, false, - false, false, false, - false, false, false, -], 3); -var tetromino4 = new Polycube([3, 3, 3], [ - true, true, false, - false, false, false, - false, false, false, - true, false, false, - true, false, false, - false, false, false, - false, false, false, - false, false, false, - false, false, false, -], 4); -var tetromino5 = new Polycube([3, 3, 3], [ - true, true, false, - false, false, false, - false, false, false, - false, true, false, - false, true, false, - false, false, false, - false, false, false, - false, false, false, - false, false, false, -], 5); -var tetromino6 = new Polycube([3, 3, 3], [ - false, false, false, - false, false, false, - false, true, false, - false, false, false, - false, true, false, - false, true, true, - false, false, false, - false, false, false, - false, false, false, -], 6); -var triomino1 = new Polycube([3, 3, 3], [ - false, false, false, - false, false, false, - false, true, false, - false, false, false, - false, true, false, - false, true, false, - false, false, false, - false, false, false, - false, false, false, -], 7); -// const cube = new VoxelSpace([3, 3, 3], Array(3**3).fill(0)); -// cube.plus(triomino1)?.plus(tetromino2, {x: 1, y: 0, z: 1})?.print(); -function start() { - var solver = new SomaSolver(3); - console.log("solving"); - solver.solve([triomino1, tetromino2, tetromino3, tetromino1, tetromino4, tetromino5, tetromino6]); -} diff --git a/src/test.ts b/src/test.ts deleted file mode 100644 index 305a0ba..0000000 --- a/src/test.ts +++ /dev/null @@ -1,524 +0,0 @@ -class SomaSolver { - private solutionCube: VoxelSpace; - private dim: number; - private solutions: VoxelSpace[] = []; - private iterations: number = 0; - constructor(dimension: number) { - if (dimension % 1 !== 0 || dimension < 0) { - throw new Error("The argument 'dimension' must be a positive whole number"); - } - this.dim = dimension; - this.solutionCube = new VoxelSpace([dimension, dimension, dimension], Array(dimension**3).fill(0)); - } - - solve(polycubes: Polycube[]) { - if (polycubes.length === 0) { - throw new Error("You must pass at least one polycube to solve the puzzle."); - } - let cumulativeSize = polycubes.reduce((prev, curr) => prev + curr.size(), 0); - if (cumulativeSize !== this.dim**3) { - throw new Error(`The polycubes passed do not add up to exactly enough units to form a cube of dimension ${this.dim}! Got: ${cumulativeSize}, need: ${this.dim**3}`); - } - this.iterations = 0; - this.backtrackSolve(this.solutionCube, polycubes); - this.solutions = VoxelSpace.filterUnique(this.solutions); - this.solutions.forEach(sol => sol.print()); - console.log(this.solutions.length); - } - - private backtrackSolve(workingSolution: VoxelSpace, polycubes: Polycube[], depth = 0) { - const nextCube = polycubes[0]; - const rots = depth === 0 ? [nextCube] : nextCube.getUniqueRotations(); - for (let i = 0; i < rots.length; i++) { - const polyCubeDims = rots[i].getDims(); - for (let x = 0; x < this.dim - polyCubeDims[0] + 1; x++) { - for (let y = 0; y < this.dim - polyCubeDims[1] + 1; y++) { - for (let z = 0; z < this.dim - polyCubeDims[2] + 1; z++) { - const successfulFusion = workingSolution.plus(rots[i], x, y, z); - if (successfulFusion) { - if (polycubes.length === 1) { - console.log("soln", this.iterations++); - this.solutions.push(successfulFusion); - return; - } else { - this.backtrackSolve(successfulFusion, polycubes.slice(1), depth + 1); - } - } - } - } - } - } - } -} - -class VoxelSpace { - protected vals: number[]; - protected dims: DimensionDef; - constructor(dims: DimensionDef, vals: number[], cullEmpty?: boolean) { - if (vals.length !== dims[0] * dims[1] * dims[2]) { - throw new Error("Vals don't fit in given dimensions."); - } - this.dims = dims; - this.vals = vals; - if (cullEmpty) { - this.cullEmptySpace(); - } - } - - private cullEmptySpace() { - const extrema = { - xMax: -Infinity, - xMin: Infinity, - yMax: -Infinity, - yMin: Infinity, - zMax: -Infinity, - zMin: Infinity, - }; - const newVals: number[] = []; - this.forEachCell((val, i, j, k) => { - if (val !== 0) { - extrema.xMax = Math.max(extrema.xMax, i); - extrema.xMin = Math.min(extrema.xMin, i); - extrema.yMax = Math.max(extrema.yMax, j); - extrema.yMin = Math.min(extrema.yMin, j); - extrema.zMax = Math.max(extrema.zMax, k); - extrema.zMin = Math.min(extrema.zMin, k); - } - }); - for (let i = extrema.xMin; i <= extrema.xMax; i++) { - for (let j = extrema.yMin; j <= extrema.yMax; j++) { - for (let k = extrema.zMin; k <= extrema.zMax; k++) { - newVals.push(this.at(i, j, k)); - } - } - } - this.dims[0] = extrema.xMax - extrema.xMin + 1; - this.dims[1] = extrema.yMax - extrema.yMin + 1; - this.dims[2] = extrema.zMax - extrema.zMin + 1; - this.vals = newVals; - } - - forEachCell(cb: (val: number, x: number, y: number, z: number) => any) { - loopStart: for (let x = 0; x < this.dims[0]; x++) { - for (let y = 0; y < this.dims[1]; y++) { - for (let z = 0; z < this.dims[2]; z++) { - if (cb(this.at(x, y, z), x, y, z) === 0) { - break loopStart; - } - } - } - } - } - - print() { - let accum = ""; - console.log("---"); - for (let i = 0; i < this.dims[0]; i++) { - for (let j = 0; j < this.dims[1]; j++) { - for (let k = 0; k < this.dims[2]; k++) { - accum += this.at(i, j, k); - } - console.log(accum); - accum = ""; - } - if (i !== this.dims[0] - 1) { - console.log("-"); - } - } - console.log("---"); - } - - getUniqueRotations() { - const rotations: VoxelSpace[] = []; - const refSpace = this.clone(); - VoxelSpace.pushNewUniqueSpaces(rotations, refSpace.getAxisSpins('x')); - refSpace.rot90('y'); - VoxelSpace.pushNewUniqueSpaces(rotations, refSpace.getAxisSpins('x')); - refSpace.rot90('y'); - VoxelSpace.pushNewUniqueSpaces(rotations, refSpace.getAxisSpins('x')); - refSpace.rot90('y'); - VoxelSpace.pushNewUniqueSpaces(rotations, refSpace.getAxisSpins('x')); - refSpace.rot90('z'); - VoxelSpace.pushNewUniqueSpaces(rotations, refSpace.getAxisSpins('x')); - refSpace.rot90('z'); - refSpace.rot90('z'); - VoxelSpace.pushNewUniqueSpaces(rotations, refSpace.getAxisSpins('x')); - return rotations; - } - - static filterUnique(spaces: T[]): T[] { - if (spaces.length === 0) { - return []; - } - const uniqueSpaces = [spaces[0]]; - for (const space of spaces) { - let foundMatch = false; - for (const rotation of space.getUniqueRotations()) { - let end = uniqueSpaces.length; - for (let i = 0; i < end; i++) { - if (rotation.matches(uniqueSpaces[i])) { - foundMatch = true; - } - } - } - if (!foundMatch) { - uniqueSpaces.push(space); - } - } - return uniqueSpaces; - } - - protected static pushNewUniqueSpaces(existingSpaces: VoxelSpace[], newSpaces: VoxelSpace[]) { - for (const newSpace of newSpaces) { - let matchFound = false; - for (const existingSpace of existingSpaces) { - if (newSpace.matches(existingSpace)) { - matchFound = true; - break; - } - } - if (!matchFound) { - existingSpaces.push(newSpace); - } - } - } - - matches(space: VoxelSpace) { - const otherDims = space.getDims(); - for (let i = 0; i < this.dims.length; i++) { - if (otherDims[i] !== this.dims[i]) { - return false; - } - } - const otherVals = space.getVals(); - for (let i = 0; i < this.vals.length; i++) { - if (this.vals[i] !== otherVals[i]) { - return false; - } - } - return true; - } - - clone() { - return new VoxelSpace(this.getDims(), this.getVals()); - } - - private getAxisSpins(axis: 'x' | 'y' | 'z'): VoxelSpace[] { - const rotations = [this.clone()]; - for (let i = 0; i < 3; i++) { - rotations.push(rotations[i].rotated90(axis)); - } - return rotations; - } - - getDims(): DimensionDef { - return this.dims.slice() as DimensionDef; - } - - getVals() { - return this.vals.slice(); - } - - // [1, 0, 0] [x] [ x] - // [0, 0, -1] * [y] = [-z] - // [0, 1, 0] [z] [ y] - private newIndexRotX(x: number, y: number, z: number) { - return this.dims[2] * this.dims[1] * x + this.dims[1] * (this.dims[2] - 1 - z) + y; - } - - // [ 0, 0, 1] [x] [ z] - // [ 0, 1, 0] * [y] = [ y] - // [-1, 0, 0] [z] [-x] - private newIndexRotY(x: number, y: number, z: number) { - return this.dims[1] * this.dims[0] * z + this.dims[0] * y + (this.dims[0] - 1 - x); - } - - // [0, -1, 0] [x] [-y] - // [1, 0, 0] * [y] = [ x] - // [0, 0, 1] [z] [ z] - private newIndexRotZ(x: number, y: number, z: number) { - return this.dims[0] * this.dims[2] * (this.dims[1] - 1 - y) + this.dims[2] * x + z; - } - - at(x: number, y: number, z: number) { - return this.vals[this.dims[1] * this.dims[2] * x + this.dims[2] * y + z]; - } - - set(x: number, y: number, z: number, val: number) { - this.vals[this.dims[1] * this.dims[2] * x + this.dims[2] * y + z] = val; - } - - rotated90(dim: 'x' | 'y' | 'z') { - const newVals = [...this.vals]; - let newDims: DimensionDef; - let rotIndex: (i: number, j: number, k: number) => number; - if (dim === 'x') { - newDims = [this.dims[0], this.dims[2], this.dims[1]]; - rotIndex = this.newIndexRotX.bind(this); - } else if (dim === 'y') { - newDims = [this.dims[2], this.dims[1], this.dims[0]]; - rotIndex = this.newIndexRotY.bind(this); - } else { - newDims = [this.dims[1], this.dims[0], this.dims[2]]; - rotIndex = this.newIndexRotZ.bind(this); - } - this.forEachCell((val, i, j, k) => { - newVals[rotIndex(i, j, k)] = val; - }) - return new VoxelSpace(newDims, newVals); - } - - rot90(dim: 'x' | 'y' | 'z') { - const rot = this.rotated90(dim); - this.vals = rot.getVals(); - this.dims = rot.getDims(); - } - - plus(space: VoxelSpace, startX: number, startY: number, startZ: number): VoxelSpace | null { - let result: VoxelSpace = this.clone(); - const spaceDims = space.getDims(); - for (let i = 0; i < spaceDims[0]; i++) { - for (let j = 0; j < spaceDims[1]; j++) { - for (let k = 0; k < spaceDims[2]; k++) { - const sourceVal = space.at(i, j, k); - const targetEmpty = result.at(startX + i, startY + j, startZ + k) === 0; - if (sourceVal !== 0 && targetEmpty) { - result.set(startX + i, startY + j, startZ + k, sourceVal); - } else if (sourceVal !== 0 && !targetEmpty) { - return null; - } - } - } - } - return result; - } -} - -class Polycube extends VoxelSpace { - private id: number; - constructor(dims: DimensionDef, vals: boolean[], id: number) { - super(dims, vals.map(val => val ? id : 0), true); - this.id = id; - } - - getId() { - return this.id; - } - - print() { - let accum = ""; - console.log("---"); - for (let i = 0; i < this.dims[0]; i++) { - for (let j = 0; j < this.dims[1]; j++) { - for (let k = 0; k < this.dims[2]; k++) { - accum += this.at(i, j, k) === 0 ? "O" : "#"; - } - console.log(accum); - accum = ""; - } - if (i !== this.dims[0] - 1) { - console.log("-"); - } - } - console.log("---"); - } - - matches(cube: VoxelSpace) { - const otherDims = cube.getDims(); - for (let i = 0; i < this.dims.length; i++) { - if (otherDims[i] !== this.dims[i]) { - return false; - } - } - const otherVals = cube.getVals(); - for (let i = 0; i < this.vals.length; i++) { - if (Number(this.vals[i]) !== Number(otherVals[i])) { - return false; - } - } - return true; - } - - size() { - let size = 0; - this.forEachCell((val) => { - if (val) { - size++; - } - }); - return size; - } - - rotated90(dim: "x" | "y" | "z"): Polycube { - const rotated = super.rotated90(dim); - return new Polycube(rotated.getDims(), rotated.getVals() as unknown as boolean[], this.id); - } - - clone(): Polycube { - return new Polycube(this.getDims(), this.getVals() as unknown as boolean[], this.id); - } - - getUniqueRotations(): Polycube[] { - return super.getUniqueRotations().map(rot => new Polycube(rot.getDims(), rot.getVals() as unknown as boolean[], this.id)); - } -} - -type DimensionDef = [number, number, number]; - -// const testCube = new Cube([4, 2, 5], [ -// "000", "001", "002", "003", "004", -// "010", "011", "012", "013", "014", -// "100", "101", "102", "103", "104", -// "110", "111", "112", "113", "114", -// "200", "201", "202", "203", "204", -// "210", "211", "212", "213", "214", -// "300", "301", "302", "303", "304", -// "310", "311", "312", "313", "314", -// ]); -// const somaCube = new Polycube([3, 3, 3], [ -// false, false, false, -// false, false, false, -// false, false, false, -// -// true, true, true, -// true, true, true, -// false, false, false, -// -// false, false, false, -// false, false, false, -// false, false, false, -// ], 1); -const unitCube1 = new Polycube([1, 1, 1], [true], 1); -const unitCube2 = new Polycube([1, 1, 1], [true], 2); -const unitCube3 = new Polycube([1, 1, 1], [true], 3); -const unitCube4 = new Polycube([1, 1, 1], [true], 4); -const unitCube5 = new Polycube([1, 1, 1], [true], 5); -const unitCube6 = new Polycube([1, 1, 1], [true], 6); -const unitCube7 = new Polycube([1, 1, 1], [true], 7); -const unitCube8 = new Polycube([1, 1, 1], [true], 8); -const unitCube9 = new Polycube([1, 1, 1], [true], 9); -const unitCube10 = new Polycube([1, 1, 1], [true], 10); -const unitCube11 = new Polycube([1, 1, 1], [true], 11); -const unitCube12 = new Polycube([1, 1, 1], [true], 12); -const unitCube13 = new Polycube([1, 1, 1], [true], 13); -const unitCube14 = new Polycube([1, 1, 1], [true], 14); -const unitCube15 = new Polycube([1, 1, 1], [true], 15); -const unitCube16 = new Polycube([1, 1, 1], [true], 16); -const unitCube17 = new Polycube([1, 1, 1], [true], 17); -const unitCube18 = new Polycube([1, 1, 1], [true], 18); -const unitCube19 = new Polycube([1, 1, 1], [true], 19); -const unitCube20 = new Polycube([1, 1, 1], [true], 20); -const unitCube21 = new Polycube([1, 1, 1], [true], 21); -const unitCube22 = new Polycube([1, 1, 1], [true], 22); -const unitCube23 = new Polycube([1, 1, 1], [true], 23); -const unitCube24 = new Polycube([1, 1, 1], [true], 24); -const unitCube25 = new Polycube([1, 1, 1], [true], 25); -const unitCube26 = new Polycube([1, 1, 1], [true], 26); -const unitCube27 = new Polycube([1, 1, 1], [true], 27); - -const tetromino1 = new Polycube([3, 3, 3], [ - true, true, true, - false, true, false, - false, false, false, - - false, false, false, - false, false, false, - false, false, false, - - false, false, false, - false, false, false, - false, false, false, -], 1); - -const tetromino2 = new Polycube([3, 3, 3], [ - false, false, false, - false, false, false, - false, true, false, - - false, true, false, - false, true, false, - false, true, false, - - false, false, false, - false, false, false, - false, false, false, -], 2); - -const tetromino3 = new Polycube([3, 3, 3], [ - true, false, false, - true, true, false, - false, true, false, - - false, false, false, - false, false, false, - false, false, false, - - false, false, false, - false, false, false, - false, false, false, -], 3); - -const tetromino4 = new Polycube([3, 3, 3], [ - true, true, false, - false, false, false, - false, false, false, - - true, false, false, - true, false, false, - false, false, false, - - false, false, false, - false, false, false, - false, false, false, -], 4); - -const tetromino5 = new Polycube([3, 3, 3], [ - true, true, false, - false, false, false, - false, false, false, - - false, true, false, - false, true, false, - false, false, false, - - false, false, false, - false, false, false, - false, false, false, -], 5); - -const tetromino6 = new Polycube([3, 3, 3], [ - false, false, false, - false, false, false, - false, true, false, - - false, false, false, - false, true, false, - false, true, true, - - false, false, false, - false, false, false, - false, false, false, -], 6); - -const triomino1 = new Polycube([3, 3, 3], [ - false, false, false, - false, false, false, - false, true, false, - - false, false, false, - false, true, false, - false, true, false, - - false, false, false, - false, false, false, - false, false, false, -], 7); - -// const cube = new VoxelSpace([3, 3, 3], Array(3**3).fill(0)); -// cube.plus(triomino1)?.plus(tetromino2, {x: 1, y: 0, z: 1})?.print(); - -function start() { - const solver = new SomaSolver(3); - console.log("solving"); - solver.solve([triomino1, tetromino2, tetromino3, tetromino1, tetromino4, tetromino5, tetromino6]); -} diff --git a/src/threeTest.ts b/src/threeTest.ts new file mode 100644 index 0000000..0383207 --- /dev/null +++ b/src/threeTest.ts @@ -0,0 +1,134 @@ +import * as THREE from 'three'; +import { MapControls } from './OrbitControls.js'; +import VoxelSpace from './solver/VoxelSpace.js'; +import {somaDimension, polycubes} from './store'; +import {get} from 'svelte/store'; +import type { MeshPhongMaterial } from 'three'; + +export default class PolycubeScene { + private renderer: THREE.WebGLRenderer; + private camera: THREE.Camera; + private mainScene: THREE.Scene; + private polycubeMeshes: THREE.Mesh[] = []; + private controls: typeof MapControls; + private light: THREE.Light; + private cameraLightScene: THREE.Group; + private lastDims: number = 0; + private currentPolycubeId: number = 0; + private lastColor: string = "#FF0000"; + private lastPolycube: bigint = 0n; + + constructor(el: HTMLCanvasElement) { + this.renderer = new THREE.WebGLRenderer({canvas: el}); + const fov = 75; + const aspect = el.clientWidth / el.clientHeight; + const near = 0.1; + const far = 10; + this.camera = new THREE.PerspectiveCamera(fov, aspect, near, far); + this.camera.position.z = 5; + this.camera.lookAt(0, 0, 0); + this.mainScene = new THREE.Scene(); + this.light = this.setupLight(); + this.mainScene.add(this.light); + this.mainScene.rotateX(Math.PI/4); + this.mainScene.rotateY(Math.PI/4); + this.cameraLightScene = new THREE.Group(); + this.controls = new MapControls(this.camera, el); + requestAnimationFrame((timestamp) => this.render(timestamp)); + } + + private setPolycube(polycube: bigint, dims: number, color: string) { + if (dims !== this.lastDims) { + this.mainScene.remove(...this.polycubeMeshes); + this.polycubeMeshes = []; + this.polycubeMeshes = Array.from(Array(dims ** 3).keys()).map(() => { + const cube = this.newRoundedCube(0.2, 3, color); + cube.position.set(1000, 1000, 1000); + this.mainScene.add(cube); + return cube; + }); + this.lastDims = dims; + } + + if (polycube !== this.lastPolycube) { + let i = 0; + const voxelSpace = new VoxelSpace(0, [dims, dims, dims], polycube); + voxelSpace.forEachCell((val, x, y, z) => { + if (val) { + this.polycubeMeshes[i].position.set( + -((dims - 1)/2) + z, + ((dims - 1)/2) - y, + -((dims - 1)/2) + x, + ); + } else { + this.polycubeMeshes[i].position.set(1000, 1000, 1000); + } + i++; + }); + this.lastPolycube = polycube; + } + + if (color !== this.lastColor) { + this.polycubeMeshes.forEach(mesh => (mesh.material as MeshPhongMaterial).color.set(color)); + this.lastColor = color; + } + } + + private updateFromCurrentPolycube() { + const {color: cubeColor, rep: cubeRep} = get(polycubes)[this.currentPolycubeId]; + const dims = get(somaDimension); + const voxelSpace = new VoxelSpace(this.currentPolycubeId, [dims, dims, dims], cubeRep); + this.mainScene.remove(...this.polycubeMeshes); + voxelSpace.forEachCell((val, x, y, z) => { + if (val) { + const cube = this.newRoundedCube(0.2, 3, cubeColor); + cube.position.set( + -((dims - 1)/2) + z, + ((dims - 1)/2) - y, + -((dims - 1)/2) + x, + ); + this.mainScene.add(cube); + this.polycubeMeshes.push(cube); + } + }); + } + + private setupLight() { + const color = 0xFFFFFF; + const intensity = 1; + const light = new THREE.DirectionalLight(color, intensity); + light.position.set(-1, 2, 4); + return light; + } + + private render(time: number) { + this.renderer.render(this.mainScene, this.camera); + requestAnimationFrame((timestamp) => this.render(timestamp)); + } + + private newRoundedCube(radius: number, smoothness: number, color: string) { + const width = 1; + const height = 1; + const depth = 1; + const shape = new THREE.Shape(); + const eps = 0.00001; + const radius0 = radius - eps; + shape.absarc(eps, eps, eps, -Math.PI / 2, -Math.PI, true); + shape.absarc(eps, height - radius0 * 2, eps, Math.PI, Math.PI / 2, true); + shape.absarc(width - radius0 * 2, height - radius0 * 2, eps, Math.PI / 2, 0, true); + shape.absarc(width - radius0 * 2, eps, eps, 0, -Math.PI / 2, true ); + const geometry = new THREE.ExtrudeBufferGeometry(shape, { + depth: depth - radius0 * 2, + bevelEnabled: true, + bevelSegments: smoothness * 2, + steps: 1, + bevelSize: radius0, + bevelThickness: radius0, + curveSegments: smoothness + }); + geometry.center(); + const material = new THREE.MeshPhongMaterial({color}); + const cube = new THREE.Mesh(geometry, material); + return cube; + } +} diff --git a/tsconfig.json b/tsconfig.json index 9545063..29f6d75 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,66 +1,9 @@ { + "extends": "@tsconfig/svelte/tsconfig.json", "compilerOptions": { - /* Basic Options */ - // "incremental": true, /* Enable incremental compilation */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ - "lib": ["dom", "ES6"], /* Specify library files to be included in the compilation. */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "checkJs": true, /* Report errors in .js files. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - // "outDir": "./", /* Redirect output structure to the directory. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "composite": true, /* Enable project compilation */ - // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - - /* Strict Type-Checking Options */ - "strict": true, /* Enable all strict type-checking options. */ - // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "strictFunctionTypes": true, /* Enable strict checking of function types. */ - // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ - // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ - // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - - /* Source Map Options */ - // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - - /* Advanced Options */ - "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ - } -} + "lib": ["es2020", "dom"], + "target": "ES2020" + }, + "include": ["src/**/*"], + "exclude": ["node_modules/*", "__sapper__/*", "public/*"] +} \ No newline at end of file