Compare commits
8 Commits
fresh
...
b30a241d09
Author | SHA1 | Date | |
---|---|---|---|
b30a241d09 | |||
7914eb444a | |||
6009818d93 | |||
8bd2c30108 | |||
ffa2ef97e0 | |||
8d379461c3 | |||
9124abb749 | |||
8e6294c96f |
28
.gitignore
vendored
@@ -1,3 +1,25 @@
|
||||
bundle.js
|
||||
dist/
|
||||
temp.ts
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
.vite
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
3
.temp/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
bundle.js
|
||||
dist/
|
||||
temp.ts
|
18
.temp/deno.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": [
|
||||
"deno.ns",
|
||||
"deno.window",
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"ES2021",
|
||||
"ESNext"
|
||||
]
|
||||
},
|
||||
"tasks": {
|
||||
"dev": "deno run -RWEN --allow-run dev.ts dev"
|
||||
},
|
||||
"imports": {
|
||||
"@bearmetal/doodler": "jsr:@bearmetal/doodler@0.0.5"
|
||||
}
|
||||
}
|
238
.temp/deno.lock
generated
Normal file
@@ -0,0 +1,238 @@
|
||||
{
|
||||
"version": "4",
|
||||
"specifiers": {
|
||||
"jsr:@luca/esbuild-deno-loader@*": "0.11.0",
|
||||
"jsr:@luca/esbuild-deno-loader@0.11.1": "0.11.1",
|
||||
"jsr:@std/assert@*": "1.0.10",
|
||||
"jsr:@std/assert@^1.0.10": "1.0.10",
|
||||
"jsr:@std/bytes@^1.0.2": "1.0.2",
|
||||
"jsr:@std/cli@^1.0.8": "1.0.9",
|
||||
"jsr:@std/encoding@^1.0.5": "1.0.6",
|
||||
"jsr:@std/fmt@^1.0.3": "1.0.3",
|
||||
"jsr:@std/html@^1.0.3": "1.0.3",
|
||||
"jsr:@std/http@*": "1.0.12",
|
||||
"jsr:@std/internal@^1.0.5": "1.0.5",
|
||||
"jsr:@std/media-types@^1.1.0": "1.1.0",
|
||||
"jsr:@std/net@^1.0.4": "1.0.4",
|
||||
"jsr:@std/path@^1.0.6": "1.0.8",
|
||||
"jsr:@std/path@^1.0.8": "1.0.8",
|
||||
"jsr:@std/streams@^1.0.8": "1.0.8",
|
||||
"jsr:@std/testing@*": "1.0.8",
|
||||
"npm:esbuild@*": "0.24.2"
|
||||
},
|
||||
"jsr": {
|
||||
"@bearmetal/doodler@0.0.4": {
|
||||
"integrity": "b631083cff84994c513f70d1f09e6a9256edabcb224112c93a9ca6a87c88a389"
|
||||
},
|
||||
"@luca/esbuild-deno-loader@0.11.0": {
|
||||
"integrity": "c05a989aa7c4ee6992a27be5f15cfc5be12834cab7ff84cabb47313737c51a2c",
|
||||
"dependencies": [
|
||||
"jsr:@std/bytes",
|
||||
"jsr:@std/encoding",
|
||||
"jsr:@std/path@^1.0.6"
|
||||
]
|
||||
},
|
||||
"@luca/esbuild-deno-loader@0.11.1": {
|
||||
"integrity": "dc020d16d75b591f679f6b9288b10f38bdb4f24345edb2f5732affa1d9885267",
|
||||
"dependencies": [
|
||||
"jsr:@std/bytes",
|
||||
"jsr:@std/encoding",
|
||||
"jsr:@std/path@^1.0.6"
|
||||
]
|
||||
},
|
||||
"@std/assert@1.0.10": {
|
||||
"integrity": "59b5cbac5bd55459a19045d95cc7c2ff787b4f8527c0dd195078ff6f9481fbb3",
|
||||
"dependencies": [
|
||||
"jsr:@std/internal"
|
||||
]
|
||||
},
|
||||
"@std/bytes@1.0.2": {
|
||||
"integrity": "fbdee322bbd8c599a6af186a1603b3355e59a5fb1baa139f8f4c3c9a1b3e3d57"
|
||||
},
|
||||
"@std/cli@1.0.9": {
|
||||
"integrity": "557e5865af000efbf3f737dcfea5b8ab86453594f4a9cd8d08c9fa83d8e3f3bc"
|
||||
},
|
||||
"@std/encoding@1.0.6": {
|
||||
"integrity": "ca87122c196e8831737d9547acf001766618e78cd8c33920776c7f5885546069"
|
||||
},
|
||||
"@std/fmt@1.0.3": {
|
||||
"integrity": "97765c16aa32245ff4e2204ecf7d8562496a3cb8592340a80e7e554e0bb9149f"
|
||||
},
|
||||
"@std/html@1.0.3": {
|
||||
"integrity": "7a0ac35e050431fb49d44e61c8b8aac1ebd55937e0dc9ec6409aa4bab39a7988"
|
||||
},
|
||||
"@std/http@1.0.12": {
|
||||
"integrity": "85246d8bfe9c8e2538518725b158bdc31f616e0869255f4a8d9e3de919cab2aa",
|
||||
"dependencies": [
|
||||
"jsr:@std/cli",
|
||||
"jsr:@std/encoding",
|
||||
"jsr:@std/fmt",
|
||||
"jsr:@std/html",
|
||||
"jsr:@std/media-types",
|
||||
"jsr:@std/net",
|
||||
"jsr:@std/path@^1.0.8",
|
||||
"jsr:@std/streams"
|
||||
]
|
||||
},
|
||||
"@std/internal@1.0.5": {
|
||||
"integrity": "54a546004f769c1ac9e025abd15a76b6671ddc9687e2313b67376125650dc7ba"
|
||||
},
|
||||
"@std/media-types@1.1.0": {
|
||||
"integrity": "c9d093f0c05c3512932b330e3cc1fe1d627b301db33a4c2c2185c02471d6eaa4"
|
||||
},
|
||||
"@std/net@1.0.4": {
|
||||
"integrity": "2f403b455ebbccf83d8a027d29c5a9e3a2452fea39bb2da7f2c04af09c8bc852"
|
||||
},
|
||||
"@std/path@1.0.8": {
|
||||
"integrity": "548fa456bb6a04d3c1a1e7477986b6cffbce95102d0bb447c67c4ee70e0364be"
|
||||
},
|
||||
"@std/streams@1.0.8": {
|
||||
"integrity": "b41332d93d2cf6a82fe4ac2153b930adf1a859392931e2a19d9fabfb6f154fb3"
|
||||
},
|
||||
"@std/testing@1.0.8": {
|
||||
"integrity": "ceef535808fb7568e91b0f8263599bd29b1c5603ffb0377227f00a8ca9fe42a2",
|
||||
"dependencies": [
|
||||
"jsr:@std/assert@^1.0.10",
|
||||
"jsr:@std/internal"
|
||||
]
|
||||
}
|
||||
},
|
||||
"npm": {
|
||||
"@esbuild/aix-ppc64@0.24.2": {
|
||||
"integrity": "sha512-thpVCb/rhxE/BnMLQ7GReQLLN8q9qbHmI55F4489/ByVg2aQaQ6kbcLb6FHkocZzQhxc4gx0sCk0tJkKBFzDhA=="
|
||||
},
|
||||
"@esbuild/android-arm64@0.24.2": {
|
||||
"integrity": "sha512-cNLgeqCqV8WxfcTIOeL4OAtSmL8JjcN6m09XIgro1Wi7cF4t/THaWEa7eL5CMoMBdjoHOTh/vwTO/o2TRXIyzg=="
|
||||
},
|
||||
"@esbuild/android-arm@0.24.2": {
|
||||
"integrity": "sha512-tmwl4hJkCfNHwFB3nBa8z1Uy3ypZpxqxfTQOcHX+xRByyYgunVbZ9MzUUfb0RxaHIMnbHagwAxuTL+tnNM+1/Q=="
|
||||
},
|
||||
"@esbuild/android-x64@0.24.2": {
|
||||
"integrity": "sha512-B6Q0YQDqMx9D7rvIcsXfmJfvUYLoP722bgfBlO5cGvNVb5V/+Y7nhBE3mHV9OpxBf4eAS2S68KZztiPaWq4XYw=="
|
||||
},
|
||||
"@esbuild/darwin-arm64@0.24.2": {
|
||||
"integrity": "sha512-kj3AnYWc+CekmZnS5IPu9D+HWtUI49hbnyqk0FLEJDbzCIQt7hg7ucF1SQAilhtYpIujfaHr6O0UHlzzSPdOeA=="
|
||||
},
|
||||
"@esbuild/darwin-x64@0.24.2": {
|
||||
"integrity": "sha512-WeSrmwwHaPkNR5H3yYfowhZcbriGqooyu3zI/3GGpF8AyUdsrrP0X6KumITGA9WOyiJavnGZUwPGvxvwfWPHIA=="
|
||||
},
|
||||
"@esbuild/freebsd-arm64@0.24.2": {
|
||||
"integrity": "sha512-UN8HXjtJ0k/Mj6a9+5u6+2eZ2ERD7Edt1Q9IZiB5UZAIdPnVKDoG7mdTVGhHJIeEml60JteamR3qhsr1r8gXvg=="
|
||||
},
|
||||
"@esbuild/freebsd-x64@0.24.2": {
|
||||
"integrity": "sha512-TvW7wE/89PYW+IevEJXZ5sF6gJRDY/14hyIGFXdIucxCsbRmLUcjseQu1SyTko+2idmCw94TgyaEZi9HUSOe3Q=="
|
||||
},
|
||||
"@esbuild/linux-arm64@0.24.2": {
|
||||
"integrity": "sha512-7HnAD6074BW43YvvUmE/35Id9/NB7BeX5EoNkK9obndmZBUk8xmJJeU7DwmUeN7tkysslb2eSl6CTrYz6oEMQg=="
|
||||
},
|
||||
"@esbuild/linux-arm@0.24.2": {
|
||||
"integrity": "sha512-n0WRM/gWIdU29J57hJyUdIsk0WarGd6To0s+Y+LwvlC55wt+GT/OgkwoXCXvIue1i1sSNWblHEig00GBWiJgfA=="
|
||||
},
|
||||
"@esbuild/linux-ia32@0.24.2": {
|
||||
"integrity": "sha512-sfv0tGPQhcZOgTKO3oBE9xpHuUqguHvSo4jl+wjnKwFpapx+vUDcawbwPNuBIAYdRAvIDBfZVvXprIj3HA+Ugw=="
|
||||
},
|
||||
"@esbuild/linux-loong64@0.24.2": {
|
||||
"integrity": "sha512-CN9AZr8kEndGooS35ntToZLTQLHEjtVB5n7dl8ZcTZMonJ7CCfStrYhrzF97eAecqVbVJ7APOEe18RPI4KLhwQ=="
|
||||
},
|
||||
"@esbuild/linux-mips64el@0.24.2": {
|
||||
"integrity": "sha512-iMkk7qr/wl3exJATwkISxI7kTcmHKE+BlymIAbHO8xanq/TjHaaVThFF6ipWzPHryoFsesNQJPE/3wFJw4+huw=="
|
||||
},
|
||||
"@esbuild/linux-ppc64@0.24.2": {
|
||||
"integrity": "sha512-shsVrgCZ57Vr2L8mm39kO5PPIb+843FStGt7sGGoqiiWYconSxwTiuswC1VJZLCjNiMLAMh34jg4VSEQb+iEbw=="
|
||||
},
|
||||
"@esbuild/linux-riscv64@0.24.2": {
|
||||
"integrity": "sha512-4eSFWnU9Hhd68fW16GD0TINewo1L6dRrB+oLNNbYyMUAeOD2yCK5KXGK1GH4qD/kT+bTEXjsyTCiJGHPZ3eM9Q=="
|
||||
},
|
||||
"@esbuild/linux-s390x@0.24.2": {
|
||||
"integrity": "sha512-S0Bh0A53b0YHL2XEXC20bHLuGMOhFDO6GN4b3YjRLK//Ep3ql3erpNcPlEFed93hsQAjAQDNsvcK+hV90FubSw=="
|
||||
},
|
||||
"@esbuild/linux-x64@0.24.2": {
|
||||
"integrity": "sha512-8Qi4nQcCTbLnK9WoMjdC9NiTG6/E38RNICU6sUNqK0QFxCYgoARqVqxdFmWkdonVsvGqWhmm7MO0jyTqLqwj0Q=="
|
||||
},
|
||||
"@esbuild/netbsd-arm64@0.24.2": {
|
||||
"integrity": "sha512-wuLK/VztRRpMt9zyHSazyCVdCXlpHkKm34WUyinD2lzK07FAHTq0KQvZZlXikNWkDGoT6x3TD51jKQ7gMVpopw=="
|
||||
},
|
||||
"@esbuild/netbsd-x64@0.24.2": {
|
||||
"integrity": "sha512-VefFaQUc4FMmJuAxmIHgUmfNiLXY438XrL4GDNV1Y1H/RW3qow68xTwjZKfj/+Plp9NANmzbH5R40Meudu8mmw=="
|
||||
},
|
||||
"@esbuild/openbsd-arm64@0.24.2": {
|
||||
"integrity": "sha512-YQbi46SBct6iKnszhSvdluqDmxCJA+Pu280Av9WICNwQmMxV7nLRHZfjQzwbPs3jeWnuAhE9Jy0NrnJ12Oz+0A=="
|
||||
},
|
||||
"@esbuild/openbsd-x64@0.24.2": {
|
||||
"integrity": "sha512-+iDS6zpNM6EnJyWv0bMGLWSWeXGN/HTaF/LXHXHwejGsVi+ooqDfMCCTerNFxEkM3wYVcExkeGXNqshc9iMaOA=="
|
||||
},
|
||||
"@esbuild/sunos-x64@0.24.2": {
|
||||
"integrity": "sha512-hTdsW27jcktEvpwNHJU4ZwWFGkz2zRJUz8pvddmXPtXDzVKTTINmlmga3ZzwcuMpUvLw7JkLy9QLKyGpD2Yxig=="
|
||||
},
|
||||
"@esbuild/win32-arm64@0.24.2": {
|
||||
"integrity": "sha512-LihEQ2BBKVFLOC9ZItT9iFprsE9tqjDjnbulhHoFxYQtQfai7qfluVODIYxt1PgdoyQkz23+01rzwNwYfutxUQ=="
|
||||
},
|
||||
"@esbuild/win32-ia32@0.24.2": {
|
||||
"integrity": "sha512-q+iGUwfs8tncmFC9pcnD5IvRHAzmbwQ3GPS5/ceCyHdjXubwQWI12MKWSNSMYLJMq23/IUCvJMS76PDqXe1fxA=="
|
||||
},
|
||||
"@esbuild/win32-x64@0.24.2": {
|
||||
"integrity": "sha512-7VTgWzgMGvup6aSqDPLiW5zHaxYJGTO4OokMjIlrCtf+VpEL+cXKtCvg723iguPYI5oaUNdS+/V7OU2gvXVWEg=="
|
||||
},
|
||||
"esbuild@0.24.2": {
|
||||
"integrity": "sha512-+9egpBW8I3CD5XPe0n6BfT5fxLzxrlDzqydF3aviG+9ni1lDC/OvMHcxqEFV0+LANZG5R1bFMWfUrjVsdwxJvA==",
|
||||
"dependencies": [
|
||||
"@esbuild/aix-ppc64",
|
||||
"@esbuild/android-arm",
|
||||
"@esbuild/android-arm64",
|
||||
"@esbuild/android-x64",
|
||||
"@esbuild/darwin-arm64",
|
||||
"@esbuild/darwin-x64",
|
||||
"@esbuild/freebsd-arm64",
|
||||
"@esbuild/freebsd-x64",
|
||||
"@esbuild/linux-arm",
|
||||
"@esbuild/linux-arm64",
|
||||
"@esbuild/linux-ia32",
|
||||
"@esbuild/linux-loong64",
|
||||
"@esbuild/linux-mips64el",
|
||||
"@esbuild/linux-ppc64",
|
||||
"@esbuild/linux-riscv64",
|
||||
"@esbuild/linux-s390x",
|
||||
"@esbuild/linux-x64",
|
||||
"@esbuild/netbsd-arm64",
|
||||
"@esbuild/netbsd-x64",
|
||||
"@esbuild/openbsd-arm64",
|
||||
"@esbuild/openbsd-x64",
|
||||
"@esbuild/sunos-x64",
|
||||
"@esbuild/win32-arm64",
|
||||
"@esbuild/win32-ia32",
|
||||
"@esbuild/win32-x64"
|
||||
]
|
||||
}
|
||||
},
|
||||
"redirects": {
|
||||
"https://deno.land/x/clipboard/mod.ts": "https://deno.land/x/clipboard@v0.0.3/mod.ts"
|
||||
},
|
||||
"remote": {
|
||||
"https://deno.land/x/clipboard@v0.0.3/mod.ts": "5b68fe3b710b852de5273c135fc3c11b2b4050577401ee994161380bd8cab219",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.0.7a/canvas.ts": "aadfb4b2e9acce34d4a5da3f9027be642c93229bbfc2641cb55301542cbb87bf",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.0.7a/geometry/constants.ts": "4f4cf7bf49ac871d984e9b43896783b0cc8ab0ea60d0fc4c8c582f7e00c3df5a",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.0.7a/geometry/vector.ts": "a08ecff64c5436a28c6451a31c68fc912d25f941aabafb79418fa0a1aeffa9d2",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.0.7a/mod.ts": "766bdedc7e28b89d3cb3e83ee55c612bfaeabe252a14ff47e5e676535e033d88",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/animation/gif.ts": "6f8b77cb55b252bd7c18b04fa7ff4e88b4459cf1158d8daef538b2e471433420",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/animation/sprite.ts": "64adc3843b48a0d74ad96cbf4a4d26426c1e909a03ca935f73d5ec5545080f20",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/canvas.ts": "5af9d684e1144a374f0fbee46c710f9d493d5491e90b17356d910c6ade32bb50",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/collision/aa.ts": "c27a1deee0b2ed02e3a88e4e0b370ca2dfa0f57bf783724fa5c099e9eeabc5c9",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/collision/circular.ts": "962703eacb19cc849f3fb355815edfd71e12d06f8e72f517a7c038ff2d1c1729",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/collision/sat.ts": "f221540a984c908c96b4cc86a8eddacf3d3a5dfa5367ba538c02bcf7f7038247",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/geometry/constants.ts": "4f4cf7bf49ac871d984e9b43896783b0cc8ab0ea60d0fc4c8c582f7e00c3df5a",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/geometry/polygon.ts": "6c7edf576bebd7f24b1358ecba70d561d5905e0185701e12437ba7ccdacc66a9",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/geometry/spline.ts": "3521ea5b57902001fb9a248580bd66f12f563a581eff137f5c67e2edc0305ba0",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/geometry/vector.ts": "0143daf300032d6faf5a073fffa5c298fdcd74ba2d6bcd10a2d96ab54e55bc69",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/init.ts": "0e08fdf4c896f88308e6a6a2fb8842fe3a67a3a47a5ad722ecbce37737f8694d",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/mod.ts": "ffcbd74b612db108d50f5e2e1ba7425c7e6fac87f3fe7fb43c10a5283501513e",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/processing/gif.ts": "e97456fd55806086aa90d9bc46193d355c2f6093f376f4141ca959942193e4dc",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/timing/EaseInOut.ts": "9eba3d8f5bf5e03220c93916cff6f0bbc24ecdf7550f21fd99e3aaf310f625b0",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/timing/Map.ts": "3948648f8bdf8f1ecea83120c41211f5543c7933dbe3e49b367285a98ed50a9a",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/zoomableCanvas.ts": "395f80ddaef83e2b37a2884d7fffefae80c2bcecb72269405f53899d5dfc9956"
|
||||
},
|
||||
"workspace": {
|
||||
"dependencies": [
|
||||
"jsr:@bearmetal/doodler@0.0.5"
|
||||
]
|
||||
}
|
||||
}
|
46
.temp/index.html
Normal file
@@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>TRAINS!</title>
|
||||
<style>
|
||||
html, body {
|
||||
background-color: black;
|
||||
color: white;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
#context {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
color: white;
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
max-height: 50vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
#fps {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
color: white;
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
max-height: 50vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script src="bundle.js"></script>
|
||||
</body>
|
||||
</html>
|
1
.temp/temp.json
Normal file
@@ -0,0 +1 @@
|
||||
[{"p":[[200,24,0],[233,24,0],[264.87555226753926,32.541028488383176,0],[293.45439059242574,49.041028488383176,0]],"id":"11d7561a-3172-4ad7-9d53-6f65f49ce8c3","bNeighbors":["93e4d69d-10f2-4ecc-a4d0-560ee71708e8"],"fNeighbors":["e44c3a93-01f0-42f1-aee9-939cbde5903b"]},{"p":[[293.45439059242574,49.041028488383176,0],[322.0332289173122,65.54102848838318,0],[345.3677526964683,88.87555226753923,0],[361.8677526964683,117.45439059242571,0]],"id":"e44c3a93-01f0-42f1-aee9-939cbde5903b","bNeighbors":["11d7561a-3172-4ad7-9d53-6f65f49ce8c3"],"fNeighbors":["bf9833f2-fd66-45fb-924d-f40b7c863c26"]},{"p":[[361.8677526964683,117.45439059242571,0],[378.3677526964683,146.0332289173122,0],[386.9087811848515,177.90878118485145,0],[386.9087811848515,210.90878118485148,0]],"id":"bf9833f2-fd66-45fb-924d-f40b7c863c26","bNeighbors":["e44c3a93-01f0-42f1-aee9-939cbde5903b"],"fNeighbors":["081c81f3-8fe7-4c71-babd-1d02d52c3385"]},{"p":[[386.9087811848515,210.90878118485148,0],[386.9087811848515,243.90878118485148,0],[378.3677526964683,275.78433345239074,0],[361.8677526964683,304.3631717772772,0]],"id":"081c81f3-8fe7-4c71-babd-1d02d52c3385","bNeighbors":["bf9833f2-fd66-45fb-924d-f40b7c863c26"],"fNeighbors":["d1380635-1dba-4180-8038-931289a56d17"]},{"p":[[361.8677526964683,304.3631717772772,0],[345.3677526964683,332.9420101021637,0],[322.0332289173122,356.2765338813198,0],[293.45439059242574,372.7765338813198,0]],"id":"d1380635-1dba-4180-8038-931289a56d17","bNeighbors":["081c81f3-8fe7-4c71-babd-1d02d52c3385"],"fNeighbors":["8fe94c53-c0be-4f0d-986b-f37e143e62d7"]},{"p":[[293.45439059242574,372.7765338813198,0],[264.87555226753926,389.2765338813198,0],[233,397.81756236970296,0],[200,397.81756236970296,0]],"id":"8fe94c53-c0be-4f0d-986b-f37e143e62d7","bNeighbors":["d1380635-1dba-4180-8038-931289a56d17"],"fNeighbors":["1542c063-b548-4d27-9fd8-c7a8344b05cb"]},{"p":[[200,397.81756236970296,0],[167,397.81756236970296,0],[135.12444773246074,389.2765338813198,0],[106.54560940757426,372.7765338813198,0]],"id":"1542c063-b548-4d27-9fd8-c7a8344b05cb","bNeighbors":["8fe94c53-c0be-4f0d-986b-f37e143e62d7"],"fNeighbors":["9be20051-651f-4cca-b6f1-ca80d5db7635"]},{"p":[[106.54560940757426,372.7765338813198,0],[77.96677108268779,356.2765338813198,0],[54.6322473035317,332.94201010216375,0],[38.1322473035317,304.3631717772772,0]],"id":"9be20051-651f-4cca-b6f1-ca80d5db7635","bNeighbors":["1542c063-b548-4d27-9fd8-c7a8344b05cb"],"fNeighbors":["4b7ff960-9fe7-48b3-b64e-9e32f60b0d2f"]},{"p":[[38.1322473035317,304.3631717772772,0],[21.632247303531692,275.7843334523908,0],[13.091218815148487,243.9087811848515,0],[13.09121881514848,210.90878118485153,0]],"id":"4b7ff960-9fe7-48b3-b64e-9e32f60b0d2f","bNeighbors":["9be20051-651f-4cca-b6f1-ca80d5db7635"],"fNeighbors":["0c481aa2-92de-4517-8e76-6c3f163f3dde"]},{"p":[[13.09121881514848,210.90878118485153,0],[13.091218815148467,177.90878118485153,0],[21.632247303531646,146.03322891731227,0],[38.132247303531635,117.45439059242577,0]],"id":"0c481aa2-92de-4517-8e76-6c3f163f3dde","bNeighbors":["4b7ff960-9fe7-48b3-b64e-9e32f60b0d2f"],"fNeighbors":["c62384ad-3fec-4479-9596-1173a6e651bb"]},{"p":[[38.132247303531635,117.45439059242577,0],[54.63224730353162,88.87555226753928,0],[77.96677108268767,65.54102848838318,0],[106.54560940757415,49.041028488383176,0]],"id":"c62384ad-3fec-4479-9596-1173a6e651bb","bNeighbors":["0c481aa2-92de-4517-8e76-6c3f163f3dde"],"fNeighbors":["93e4d69d-10f2-4ecc-a4d0-560ee71708e8"]},{"p":[[106.54560940757415,49.041028488383176,0],[135.12444773246062,32.541028488383176,0],[166.9999999999999,23.99999999999997,0],[199.9999999999999,23.99999999999997,0]],"id":"93e4d69d-10f2-4ecc-a4d0-560ee71708e8","bNeighbors":["c62384ad-3fec-4479-9596-1173a6e651bb"],"fNeighbors":["11d7561a-3172-4ad7-9d53-6f65f49ce8c3"]}]
|
3
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"recommendations": ["denoland.vscode-deno"]
|
||||
}
|
22
deno.json
@@ -1,18 +1,20 @@
|
||||
{
|
||||
"tasks": {
|
||||
"dev": "deno run -A --node-modules-dir npm:vite",
|
||||
"build": "deno run -A --node-modules-dir npm:vite build",
|
||||
"preview": "deno run -A --node-modules-dir npm:vite preview",
|
||||
"serve": "deno run --allow-net --allow-read jsr:@std/http@1/file-server dist/"
|
||||
},
|
||||
"compilerOptions": {
|
||||
"lib": [
|
||||
"deno.ns",
|
||||
"deno.window",
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"ES2021",
|
||||
"ESNext"
|
||||
"ESNext",
|
||||
"DOM",
|
||||
"DOM.Iterable"
|
||||
]
|
||||
},
|
||||
"tasks": {
|
||||
"dev": "deno run -RWEN --allow-run dev.ts dev"
|
||||
},
|
||||
"imports": {
|
||||
"@bearmetal/doodler": "jsr:@bearmetal/doodler@0.0.5-b"
|
||||
"@bearmetal/doodler": "jsr:@bearmetal/doodler@0.0.5-b",
|
||||
"@deno/vite-plugin": "npm:@deno/vite-plugin@^1.0.4",
|
||||
"vite": "npm:vite@^6.0.1"
|
||||
}
|
||||
}
|
243
deno.lock
generated
@@ -2,106 +2,22 @@
|
||||
"version": "4",
|
||||
"specifiers": {
|
||||
"jsr:@bearmetal/doodler@0.0.5-b": "0.0.5-b",
|
||||
"jsr:@luca/esbuild-deno-loader@*": "0.11.0",
|
||||
"jsr:@luca/esbuild-deno-loader@0.11.1": "0.11.1",
|
||||
"jsr:@std/assert@*": "1.0.10",
|
||||
"jsr:@std/assert@^1.0.10": "1.0.10",
|
||||
"jsr:@std/bytes@^1.0.2": "1.0.2",
|
||||
"jsr:@std/cli@^1.0.8": "1.0.9",
|
||||
"jsr:@std/encoding@^1.0.5": "1.0.6",
|
||||
"jsr:@std/fmt@^1.0.3": "1.0.3",
|
||||
"jsr:@std/html@^1.0.3": "1.0.3",
|
||||
"jsr:@std/http@*": "1.0.12",
|
||||
"jsr:@std/internal@^1.0.5": "1.0.5",
|
||||
"jsr:@std/media-types@^1.1.0": "1.1.0",
|
||||
"jsr:@std/net@^1.0.4": "1.0.4",
|
||||
"jsr:@std/path@^1.0.6": "1.0.8",
|
||||
"jsr:@std/path@^1.0.8": "1.0.8",
|
||||
"jsr:@std/streams@^1.0.8": "1.0.8",
|
||||
"jsr:@std/testing@*": "1.0.8",
|
||||
"npm:esbuild@*": "0.24.2"
|
||||
"npm:@deno/vite-plugin@^1.0.4": "1.0.4_vite@6.1.0",
|
||||
"npm:vite@*": "6.1.0",
|
||||
"npm:vite@^6.0.1": "6.1.0"
|
||||
},
|
||||
"jsr": {
|
||||
"@bearmetal/doodler@0.0.4": {
|
||||
"integrity": "b631083cff84994c513f70d1f09e6a9256edabcb224112c93a9ca6a87c88a389"
|
||||
},
|
||||
"@bearmetal/doodler@0.0.5-b": {
|
||||
"integrity": "94f265ea21162f943291526800de7f3f6560634a4fe762a38cd73892685b6742"
|
||||
},
|
||||
"@luca/esbuild-deno-loader@0.11.0": {
|
||||
"integrity": "c05a989aa7c4ee6992a27be5f15cfc5be12834cab7ff84cabb47313737c51a2c",
|
||||
"dependencies": [
|
||||
"jsr:@std/bytes",
|
||||
"jsr:@std/encoding",
|
||||
"jsr:@std/path@^1.0.6"
|
||||
]
|
||||
},
|
||||
"@luca/esbuild-deno-loader@0.11.1": {
|
||||
"integrity": "dc020d16d75b591f679f6b9288b10f38bdb4f24345edb2f5732affa1d9885267",
|
||||
"dependencies": [
|
||||
"jsr:@std/bytes",
|
||||
"jsr:@std/encoding",
|
||||
"jsr:@std/path@^1.0.6"
|
||||
]
|
||||
},
|
||||
"@std/assert@1.0.10": {
|
||||
"integrity": "59b5cbac5bd55459a19045d95cc7c2ff787b4f8527c0dd195078ff6f9481fbb3",
|
||||
"dependencies": [
|
||||
"jsr:@std/internal"
|
||||
]
|
||||
},
|
||||
"@std/bytes@1.0.2": {
|
||||
"integrity": "fbdee322bbd8c599a6af186a1603b3355e59a5fb1baa139f8f4c3c9a1b3e3d57"
|
||||
},
|
||||
"@std/cli@1.0.9": {
|
||||
"integrity": "557e5865af000efbf3f737dcfea5b8ab86453594f4a9cd8d08c9fa83d8e3f3bc"
|
||||
},
|
||||
"@std/encoding@1.0.6": {
|
||||
"integrity": "ca87122c196e8831737d9547acf001766618e78cd8c33920776c7f5885546069"
|
||||
},
|
||||
"@std/fmt@1.0.3": {
|
||||
"integrity": "97765c16aa32245ff4e2204ecf7d8562496a3cb8592340a80e7e554e0bb9149f"
|
||||
},
|
||||
"@std/html@1.0.3": {
|
||||
"integrity": "7a0ac35e050431fb49d44e61c8b8aac1ebd55937e0dc9ec6409aa4bab39a7988"
|
||||
},
|
||||
"@std/http@1.0.12": {
|
||||
"integrity": "85246d8bfe9c8e2538518725b158bdc31f616e0869255f4a8d9e3de919cab2aa",
|
||||
"dependencies": [
|
||||
"jsr:@std/cli",
|
||||
"jsr:@std/encoding",
|
||||
"jsr:@std/fmt",
|
||||
"jsr:@std/html",
|
||||
"jsr:@std/media-types",
|
||||
"jsr:@std/net",
|
||||
"jsr:@std/path@^1.0.8",
|
||||
"jsr:@std/streams"
|
||||
]
|
||||
},
|
||||
"@std/internal@1.0.5": {
|
||||
"integrity": "54a546004f769c1ac9e025abd15a76b6671ddc9687e2313b67376125650dc7ba"
|
||||
},
|
||||
"@std/media-types@1.1.0": {
|
||||
"integrity": "c9d093f0c05c3512932b330e3cc1fe1d627b301db33a4c2c2185c02471d6eaa4"
|
||||
},
|
||||
"@std/net@1.0.4": {
|
||||
"integrity": "2f403b455ebbccf83d8a027d29c5a9e3a2452fea39bb2da7f2c04af09c8bc852"
|
||||
},
|
||||
"@std/path@1.0.8": {
|
||||
"integrity": "548fa456bb6a04d3c1a1e7477986b6cffbce95102d0bb447c67c4ee70e0364be"
|
||||
},
|
||||
"@std/streams@1.0.8": {
|
||||
"integrity": "b41332d93d2cf6a82fe4ac2153b930adf1a859392931e2a19d9fabfb6f154fb3"
|
||||
},
|
||||
"@std/testing@1.0.8": {
|
||||
"integrity": "ceef535808fb7568e91b0f8263599bd29b1c5603ffb0377227f00a8ca9fe42a2",
|
||||
"dependencies": [
|
||||
"jsr:@std/assert@^1.0.10",
|
||||
"jsr:@std/internal"
|
||||
]
|
||||
}
|
||||
},
|
||||
"npm": {
|
||||
"@deno/vite-plugin@1.0.4_vite@6.1.0": {
|
||||
"integrity": "sha512-xg8YT8Wn2sGXSnJgiGTpBGX1Dov0c6fd1rAp8VsfrCUtyBRRWzwVMAnd3fQ4yq8h7LSVvJUxEFN4U421k/DQLA==",
|
||||
"dependencies": [
|
||||
"vite"
|
||||
]
|
||||
},
|
||||
"@esbuild/aix-ppc64@0.24.2": {
|
||||
"integrity": "sha512-thpVCb/rhxE/BnMLQ7GReQLLN8q9qbHmI55F4489/ByVg2aQaQ6kbcLb6FHkocZzQhxc4gx0sCk0tJkKBFzDhA=="
|
||||
},
|
||||
@@ -177,6 +93,66 @@
|
||||
"@esbuild/win32-x64@0.24.2": {
|
||||
"integrity": "sha512-7VTgWzgMGvup6aSqDPLiW5zHaxYJGTO4OokMjIlrCtf+VpEL+cXKtCvg723iguPYI5oaUNdS+/V7OU2gvXVWEg=="
|
||||
},
|
||||
"@rollup/rollup-android-arm-eabi@4.34.7": {
|
||||
"integrity": "sha512-l6CtzHYo8D2TQ3J7qJNpp3Q1Iye56ssIAtqbM2H8axxCEEwvN7o8Ze9PuIapbxFL3OHrJU2JBX6FIIVnP/rYyw=="
|
||||
},
|
||||
"@rollup/rollup-android-arm64@4.34.7": {
|
||||
"integrity": "sha512-KvyJpFUueUnSp53zhAa293QBYqwm94TgYTIfXyOTtidhm5V0LbLCJQRGkQClYiX3FXDQGSvPxOTD/6rPStMMDg=="
|
||||
},
|
||||
"@rollup/rollup-darwin-arm64@4.34.7": {
|
||||
"integrity": "sha512-jq87CjmgL9YIKvs8ybtIC98s/M3HdbqXhllcy9EdLV0yMg1DpxES2gr65nNy7ObNo/vZ/MrOTxt0bE5LinL6mA=="
|
||||
},
|
||||
"@rollup/rollup-darwin-x64@4.34.7": {
|
||||
"integrity": "sha512-rSI/m8OxBjsdnMMg0WEetu/w+LhLAcCDEiL66lmMX4R3oaml3eXz3Dxfvrxs1FbzPbJMaItQiksyMfv1hoIxnA=="
|
||||
},
|
||||
"@rollup/rollup-freebsd-arm64@4.34.7": {
|
||||
"integrity": "sha512-oIoJRy3ZrdsXpFuWDtzsOOa/E/RbRWXVokpVrNnkS7npz8GEG++E1gYbzhYxhxHbO2om1T26BZjVmdIoyN2WtA=="
|
||||
},
|
||||
"@rollup/rollup-freebsd-x64@4.34.7": {
|
||||
"integrity": "sha512-X++QSLm4NZfZ3VXGVwyHdRf58IBbCu9ammgJxuWZYLX0du6kZvdNqPwrjvDfwmi6wFdvfZ/s6K7ia0E5kI7m8Q=="
|
||||
},
|
||||
"@rollup/rollup-linux-arm-gnueabihf@4.34.7": {
|
||||
"integrity": "sha512-Z0TzhrsNqukTz3ISzrvyshQpFnFRfLunYiXxlCRvcrb3nvC5rVKI+ZXPFG/Aa4jhQa1gHgH3A0exHaRRN4VmdQ=="
|
||||
},
|
||||
"@rollup/rollup-linux-arm-musleabihf@4.34.7": {
|
||||
"integrity": "sha512-nkznpyXekFAbvFBKBy4nNppSgneB1wwG1yx/hujN3wRnhnkrYVugMTCBXED4+Ni6thoWfQuHNYbFjgGH0MBXtw=="
|
||||
},
|
||||
"@rollup/rollup-linux-arm64-gnu@4.34.7": {
|
||||
"integrity": "sha512-KCjlUkcKs6PjOcxolqrXglBDcfCuUCTVlX5BgzgoJHw+1rWH1MCkETLkLe5iLLS9dP5gKC7mp3y6x8c1oGBUtA=="
|
||||
},
|
||||
"@rollup/rollup-linux-arm64-musl@4.34.7": {
|
||||
"integrity": "sha512-uFLJFz6+utmpbR313TTx+NpPuAXbPz4BhTQzgaP0tozlLnGnQ6rCo6tLwaSa6b7l6gRErjLicXQ1iPiXzYotjw=="
|
||||
},
|
||||
"@rollup/rollup-linux-loongarch64-gnu@4.34.7": {
|
||||
"integrity": "sha512-ws8pc68UcJJqCpneDFepnwlsMUFoWvPbWXT/XUrJ7rWUL9vLoIN3GAasgG+nCvq8xrE3pIrd+qLX/jotcLy0Qw=="
|
||||
},
|
||||
"@rollup/rollup-linux-powerpc64le-gnu@4.34.7": {
|
||||
"integrity": "sha512-vrDk9JDa/BFkxcS2PbWpr0C/LiiSLxFbNOBgfbW6P8TBe9PPHx9Wqbvx2xgNi1TOAyQHQJ7RZFqBiEohm79r0w=="
|
||||
},
|
||||
"@rollup/rollup-linux-riscv64-gnu@4.34.7": {
|
||||
"integrity": "sha512-rB+ejFyjtmSo+g/a4eovDD1lHWHVqizN8P0Hm0RElkINpS0XOdpaXloqM4FBkF9ZWEzg6bezymbpLmeMldfLTw=="
|
||||
},
|
||||
"@rollup/rollup-linux-s390x-gnu@4.34.7": {
|
||||
"integrity": "sha512-nNXNjo4As6dNqRn7OrsnHzwTgtypfRA3u3AKr0B3sOOo+HkedIbn8ZtFnB+4XyKJojIfqDKmbIzO1QydQ8c+Pw=="
|
||||
},
|
||||
"@rollup/rollup-linux-x64-gnu@4.34.7": {
|
||||
"integrity": "sha512-9kPVf9ahnpOMSGlCxXGv980wXD0zRR3wyk8+33/MXQIpQEOpaNe7dEHm5LMfyRZRNt9lMEQuH0jUKj15MkM7QA=="
|
||||
},
|
||||
"@rollup/rollup-linux-x64-musl@4.34.7": {
|
||||
"integrity": "sha512-7wJPXRWTTPtTFDFezA8sle/1sdgxDjuMoRXEKtx97ViRxGGkVQYovem+Q8Pr/2HxiHp74SSRG+o6R0Yq0shPwQ=="
|
||||
},
|
||||
"@rollup/rollup-win32-arm64-msvc@4.34.7": {
|
||||
"integrity": "sha512-MN7aaBC7mAjsiMEZcsJvwNsQVNZShgES/9SzWp1HC9Yjqb5OpexYnRjF7RmE4itbeesHMYYQiAtUAQaSKs2Rfw=="
|
||||
},
|
||||
"@rollup/rollup-win32-ia32-msvc@4.34.7": {
|
||||
"integrity": "sha512-aeawEKYswsFu1LhDM9RIgToobquzdtSc4jSVqHV8uApz4FVvhFl/mKh92wc8WpFc6aYCothV/03UjY6y7yLgbg=="
|
||||
},
|
||||
"@rollup/rollup-win32-x64-msvc@4.34.7": {
|
||||
"integrity": "sha512-4ZedScpxxIrVO7otcZ8kCX1mZArtH2Wfj3uFCxRJ9NO80gg1XV0U/b2f/MKaGwj2X3QopHfoWiDQ917FRpwY3w=="
|
||||
},
|
||||
"@types/estree@1.0.6": {
|
||||
"integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw=="
|
||||
},
|
||||
"esbuild@0.24.2": {
|
||||
"integrity": "sha512-+9egpBW8I3CD5XPe0n6BfT5fxLzxrlDzqydF3aviG+9ni1lDC/OvMHcxqEFV0+LANZG5R1bFMWfUrjVsdwxJvA==",
|
||||
"dependencies": [
|
||||
@@ -206,33 +182,68 @@
|
||||
"@esbuild/win32-ia32",
|
||||
"@esbuild/win32-x64"
|
||||
]
|
||||
},
|
||||
"fsevents@2.3.3": {
|
||||
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="
|
||||
},
|
||||
"nanoid@3.3.8": {
|
||||
"integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w=="
|
||||
},
|
||||
"picocolors@1.1.1": {
|
||||
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="
|
||||
},
|
||||
"postcss@8.5.2": {
|
||||
"integrity": "sha512-MjOadfU3Ys9KYoX0AdkBlFEF1Vx37uCCeN4ZHnmwm9FfpbsGWMZeBLMmmpY+6Ocqod7mkdZ0DT31OlbsFrLlkA==",
|
||||
"dependencies": [
|
||||
"nanoid",
|
||||
"picocolors",
|
||||
"source-map-js"
|
||||
]
|
||||
},
|
||||
"rollup@4.34.7": {
|
||||
"integrity": "sha512-8qhyN0oZ4x0H6wmBgfKxJtxM7qS98YJ0k0kNh5ECVtuchIJ7z9IVVvzpmtQyT10PXKMtBxYr1wQ5Apg8RS8kXQ==",
|
||||
"dependencies": [
|
||||
"@rollup/rollup-android-arm-eabi",
|
||||
"@rollup/rollup-android-arm64",
|
||||
"@rollup/rollup-darwin-arm64",
|
||||
"@rollup/rollup-darwin-x64",
|
||||
"@rollup/rollup-freebsd-arm64",
|
||||
"@rollup/rollup-freebsd-x64",
|
||||
"@rollup/rollup-linux-arm-gnueabihf",
|
||||
"@rollup/rollup-linux-arm-musleabihf",
|
||||
"@rollup/rollup-linux-arm64-gnu",
|
||||
"@rollup/rollup-linux-arm64-musl",
|
||||
"@rollup/rollup-linux-loongarch64-gnu",
|
||||
"@rollup/rollup-linux-powerpc64le-gnu",
|
||||
"@rollup/rollup-linux-riscv64-gnu",
|
||||
"@rollup/rollup-linux-s390x-gnu",
|
||||
"@rollup/rollup-linux-x64-gnu",
|
||||
"@rollup/rollup-linux-x64-musl",
|
||||
"@rollup/rollup-win32-arm64-msvc",
|
||||
"@rollup/rollup-win32-ia32-msvc",
|
||||
"@rollup/rollup-win32-x64-msvc",
|
||||
"@types/estree",
|
||||
"fsevents"
|
||||
]
|
||||
},
|
||||
"source-map-js@1.2.1": {
|
||||
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="
|
||||
},
|
||||
"vite@6.1.0": {
|
||||
"integrity": "sha512-RjjMipCKVoR4hVfPY6GQTgveinjNuyLw+qruksLDvA5ktI1150VmcMBKmQaEWJhg/j6Uaf6dNCNA0AfdzUb/hQ==",
|
||||
"dependencies": [
|
||||
"esbuild",
|
||||
"fsevents",
|
||||
"postcss",
|
||||
"rollup"
|
||||
]
|
||||
}
|
||||
},
|
||||
"remote": {
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.0.7a/canvas.ts": "aadfb4b2e9acce34d4a5da3f9027be642c93229bbfc2641cb55301542cbb87bf",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.0.7a/geometry/constants.ts": "4f4cf7bf49ac871d984e9b43896783b0cc8ab0ea60d0fc4c8c582f7e00c3df5a",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.0.7a/geometry/vector.ts": "a08ecff64c5436a28c6451a31c68fc912d25f941aabafb79418fa0a1aeffa9d2",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.0.7a/mod.ts": "766bdedc7e28b89d3cb3e83ee55c612bfaeabe252a14ff47e5e676535e033d88",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/animation/gif.ts": "6f8b77cb55b252bd7c18b04fa7ff4e88b4459cf1158d8daef538b2e471433420",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/animation/sprite.ts": "64adc3843b48a0d74ad96cbf4a4d26426c1e909a03ca935f73d5ec5545080f20",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/canvas.ts": "5af9d684e1144a374f0fbee46c710f9d493d5491e90b17356d910c6ade32bb50",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/collision/aa.ts": "c27a1deee0b2ed02e3a88e4e0b370ca2dfa0f57bf783724fa5c099e9eeabc5c9",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/collision/circular.ts": "962703eacb19cc849f3fb355815edfd71e12d06f8e72f517a7c038ff2d1c1729",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/collision/sat.ts": "f221540a984c908c96b4cc86a8eddacf3d3a5dfa5367ba538c02bcf7f7038247",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/geometry/constants.ts": "4f4cf7bf49ac871d984e9b43896783b0cc8ab0ea60d0fc4c8c582f7e00c3df5a",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/geometry/polygon.ts": "6c7edf576bebd7f24b1358ecba70d561d5905e0185701e12437ba7ccdacc66a9",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/geometry/spline.ts": "3521ea5b57902001fb9a248580bd66f12f563a581eff137f5c67e2edc0305ba0",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/geometry/vector.ts": "0143daf300032d6faf5a073fffa5c298fdcd74ba2d6bcd10a2d96ab54e55bc69",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/init.ts": "0e08fdf4c896f88308e6a6a2fb8842fe3a67a3a47a5ad722ecbce37737f8694d",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/mod.ts": "ffcbd74b612db108d50f5e2e1ba7425c7e6fac87f3fe7fb43c10a5283501513e",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/processing/gif.ts": "e97456fd55806086aa90d9bc46193d355c2f6093f376f4141ca959942193e4dc",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/timing/EaseInOut.ts": "9eba3d8f5bf5e03220c93916cff6f0bbc24ecdf7550f21fd99e3aaf310f625b0",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/timing/Map.ts": "3948648f8bdf8f1ecea83120c41211f5543c7933dbe3e49b367285a98ed50a9a",
|
||||
"https://git.cyborggrizzly.com/emma/doodler/raw/tag/0.1.1/zoomableCanvas.ts": "395f80ddaef83e2b37a2884d7fffefae80c2bcecb72269405f53899d5dfc9956"
|
||||
},
|
||||
"workspace": {
|
||||
"dependencies": [
|
||||
"jsr:@bearmetal/doodler@0.0.5-b"
|
||||
"jsr:@bearmetal/doodler@0.0.5-b",
|
||||
"npm:@deno/vite-plugin@^1.0.4",
|
||||
"npm:vite@^6.0.1"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
54
devtools/background.js
Normal file
@@ -0,0 +1,54 @@
|
||||
console.log("background.js loaded");
|
||||
|
||||
browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
||||
if (message.type === "GET_CONTEXT_STACK") {
|
||||
browser.tabs.sendMessage(message.tabId, message)
|
||||
.then((res) => {
|
||||
console.log("RESPONSE", res);
|
||||
sendResponse(res);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log("Error sending message to content script:", err);
|
||||
sendResponse({ error: err });
|
||||
});
|
||||
// browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
|
||||
// if (tabs.length) {
|
||||
// }
|
||||
// });
|
||||
return true;
|
||||
} else if (message.type === "UPDATE_CONTEXT_VALUE") {
|
||||
browser.tabs.sendMessage(message.tabId, message).then(sendResponse);
|
||||
// browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
|
||||
// if (tabs.length) {
|
||||
// }
|
||||
// });
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
let devtoolsPort = null;
|
||||
|
||||
browser.runtime.onConnect.addListener((port) => {
|
||||
if (port.name === "devtools") {
|
||||
devtoolsPort = port;
|
||||
console.log("Devtools panel connected.");
|
||||
|
||||
// port.onMessage.addListener((msg) => {
|
||||
// console.log("Received message from devtools panel:", msg);
|
||||
// });
|
||||
|
||||
port.onDisconnect.addListener(() => {
|
||||
devtoolsPort = null;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Relay messages from content scripts to the devtools panel.
|
||||
browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
||||
if (message.type === "PAGE_LOADED") {
|
||||
console.log("Background received PAGE_LOADED message from content script.");
|
||||
if (devtoolsPort) {
|
||||
devtoolsPort.postMessage({ type: "PAGE_LOADED" });
|
||||
}
|
||||
}
|
||||
});
|
20
devtools/content.js
Normal file
@@ -0,0 +1,20 @@
|
||||
browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
||||
if (message.type === "GET_CONTEXT_STACK") {
|
||||
const contextStack = window.wrappedJSObject.getContextStack();
|
||||
|
||||
sendResponse({ contextStack });
|
||||
} else if (message.type === "UPDATE_CONTEXT_VALUE") {
|
||||
const { key, value, depth } = message;
|
||||
if (window.wrappedJSObject.updateContextValue) {
|
||||
window.wrappedJSObject.updateContextValue(key, value, depth);
|
||||
sendResponse({ success: true });
|
||||
} else {
|
||||
sendResponse({
|
||||
success: false,
|
||||
error: "updateContextValue not defined",
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
browser.runtime.sendMessage({ type: "PAGE_LOADED" });
|
12
devtools/devtools.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script src="devtools.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body></body>
|
||||
|
||||
</html>
|
7
devtools/devtools.js
Normal file
@@ -0,0 +1,7 @@
|
||||
// Create a new devtools panel named "Context Stack"
|
||||
browser.devtools.panels.create(
|
||||
"Smoke and Rails", // Tab title
|
||||
"train icon.png", // Icon for your panel (optional)
|
||||
"panel.html", // HTML page for your panel content
|
||||
);
|
||||
console.log("devtools loaded");
|
28
devtools/manifest.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"manifest_version": 2,
|
||||
"name": "Context Stack DevTools",
|
||||
"version": "1.0",
|
||||
"description": "A devtools panel to view and edit context stack values.",
|
||||
"devtools_page": "devtools.html",
|
||||
"background": {
|
||||
"scripts": [
|
||||
"background.js"
|
||||
]
|
||||
},
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": [
|
||||
"<all_urls>"
|
||||
],
|
||||
"js": [
|
||||
"content.js"
|
||||
],
|
||||
"all_frames": true
|
||||
}
|
||||
],
|
||||
"permissions": [
|
||||
"devtools",
|
||||
"tabs",
|
||||
"*://*/*"
|
||||
]
|
||||
}
|
48
devtools/panel.html
Normal file
@@ -0,0 +1,48 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Smoke and Rails</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
/* margin: 10px; */
|
||||
/* width: 100%;
|
||||
height: 100%; */
|
||||
background-color: #302040;
|
||||
color: #fff;
|
||||
/* text-align: right; */
|
||||
}
|
||||
|
||||
.context-row {
|
||||
display: flex;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.context-key {
|
||||
width: 150px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.context-value input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
form {
|
||||
margin-left: 1rem;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
label {
|
||||
display: inline-block;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h2>Smoke and Rails Debugger</h2>
|
||||
<button id="refresh">Refresh</button>
|
||||
<div id="contextContainer"></div>
|
||||
<script src="panel.js"></script>
|
||||
</body>
|
||||
</html>
|
127
devtools/panel.js
Normal file
@@ -0,0 +1,127 @@
|
||||
const port = browser.runtime.connect({ name: "devtools" });
|
||||
port.onMessage.addListener((message) => {
|
||||
if (message.type === "PAGE_LOADED") {
|
||||
loadContextStack(); // Refresh your context stack here.
|
||||
}
|
||||
});
|
||||
|
||||
const tabId = browser.devtools.inspectedWindow.tabId;
|
||||
|
||||
document.getElementById("refresh").addEventListener("click", loadContextStack);
|
||||
|
||||
function loadContextStack() {
|
||||
const container = document.getElementById("contextContainer");
|
||||
container.innerHTML = "";
|
||||
|
||||
browser.runtime.sendMessage({ type: "GET_CONTEXT_STACK", tabId }).then(
|
||||
(response) => {
|
||||
if (response.error) {
|
||||
container.innerHTML = `<p>Error: ${response.error}</p>`;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!response || !response.contextStack) {
|
||||
container.innerHTML = "<p>No context stack found.</p>";
|
||||
return;
|
||||
}
|
||||
|
||||
const contextStack = coalesceContextStack(response.contextStack);
|
||||
const form = generateObjectForm(contextStack);
|
||||
container.appendChild(form);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function generateObjectForm(obj, path = "") {
|
||||
const detail = document.createElement("details");
|
||||
detail.open = path === "";
|
||||
const summary = document.createElement("summary");
|
||||
summary.textContent = path.split(".").at(-1);
|
||||
detail.appendChild(summary);
|
||||
const form = document.createElement("form");
|
||||
let count = 0;
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
if (value == undefined || value === "[Circular]") continue;
|
||||
const isObject = value.constructor === Object;
|
||||
const isArray = Array.isArray(value);
|
||||
if (isObject || isArray) {
|
||||
const nestedForm = generateObjectForm(
|
||||
value,
|
||||
path ? path + "." + key : key,
|
||||
);
|
||||
if (!nestedForm) {
|
||||
continue;
|
||||
}
|
||||
const div = document.createElement("div");
|
||||
div.appendChild(nestedForm);
|
||||
form.appendChild(div);
|
||||
count++;
|
||||
continue;
|
||||
}
|
||||
const div = document.createElement("div");
|
||||
const label = document.createElement("label");
|
||||
label.textContent = key;
|
||||
div.appendChild(label);
|
||||
const input = document.createElement("input");
|
||||
input.name = key;
|
||||
const isBoolean = typeof value === "boolean";
|
||||
if (isBoolean) {
|
||||
input.type = "checkbox";
|
||||
input.checked = value;
|
||||
input.addEventListener("change", () => {
|
||||
browser.runtime.sendMessage({
|
||||
type: "UPDATE_CONTEXT_VALUE",
|
||||
key: path ? path + "." + key : key,
|
||||
value: input.checked,
|
||||
tabId,
|
||||
}).then((updateResponse) => {
|
||||
if (updateResponse && updateResponse.success) {
|
||||
console.log(`Updated ${key} to ${input.checked}`);
|
||||
} else {
|
||||
console.error(`Failed to update ${key}:`, updateResponse.error);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
input.type = "text";
|
||||
input.value = value;
|
||||
input.addEventListener("change", () => {
|
||||
browser.runtime.sendMessage({
|
||||
type: "UPDATE_CONTEXT_VALUE",
|
||||
key: path ? path + "." + key : key,
|
||||
value: input.value,
|
||||
tabId,
|
||||
}).then((updateResponse) => {
|
||||
if (updateResponse && updateResponse.success) {
|
||||
console.log(`Updated ${key} to ${input.value}`);
|
||||
} else {
|
||||
console.error(`Failed to update ${key}:`, updateResponse.error);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
div.appendChild(input);
|
||||
form.appendChild(div);
|
||||
count++;
|
||||
}
|
||||
if (count === 0) {
|
||||
const pre = document.createElement("pre");
|
||||
pre.textContent = JSON.stringify(obj, null, 2);
|
||||
detail.appendChild(pre);
|
||||
} else {
|
||||
detail.appendChild(form);
|
||||
}
|
||||
return detail;
|
||||
}
|
||||
|
||||
function coalesceContextStack(contextStack) {
|
||||
const obj = {};
|
||||
for (const ctx of contextStack) {
|
||||
Object.assign(obj, ctx);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
loadContextStack();
|
||||
});
|
BIN
devtools/train icon.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
93
index.html
@@ -1,46 +1,51 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>TRAINS!</title>
|
||||
<style>
|
||||
html, body {
|
||||
background-color: black;
|
||||
color: white;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
#context {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
color: white;
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
max-height: 50vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
#fps {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
color: white;
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
max-height: 50vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script src="bundle.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>TRAINS!</title>
|
||||
<link rel="shortcut icon" href="train icon.png" type="image/x-icon">
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
background-color: black;
|
||||
color: white;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#context {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
color: white;
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
max-height: 50vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
#fps {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
color: white;
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
max-height: 50vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -1,94 +0,0 @@
|
||||
type ContextStore = Record<string, any>;
|
||||
|
||||
const defaultContext: ContextStore = {};
|
||||
const contextStack: ContextStore[] = [defaultContext];
|
||||
|
||||
const debug = JSON.parse(localStorage.getItem("debug") || "false");
|
||||
|
||||
export function setDefaultContext(context: ContextStore) {
|
||||
Object.assign(defaultContext, context);
|
||||
}
|
||||
|
||||
export function withContext<T>(context: ContextStore, fn: () => T): T {
|
||||
contextStack.push(context);
|
||||
try {
|
||||
return fn();
|
||||
} finally {
|
||||
contextStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
export const ctx = new Proxy(
|
||||
{},
|
||||
{
|
||||
get(_, prop: string) {
|
||||
for (let i = contextStack.length - 1; i >= 0; i--) {
|
||||
if (prop in contextStack[i]) return contextStack[i][prop];
|
||||
}
|
||||
if (prop in defaultContext) return defaultContext[prop];
|
||||
throw new Error(`Context variable '${prop}' is not defined.`);
|
||||
},
|
||||
},
|
||||
) as Record<string, unknown>;
|
||||
|
||||
export function getContext() {
|
||||
return ctx;
|
||||
}
|
||||
export function getContextItem<T>(prop: string): T {
|
||||
return ctx[prop] as T;
|
||||
}
|
||||
export function getContextItemOrDefault<T>(prop: string, defaultValue: T): T {
|
||||
try {
|
||||
return ctx[prop] as T;
|
||||
} catch {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
export function setContextItem<T>(prop: string, value: T) {
|
||||
Object.assign(contextStack[contextStack.length - 1] ?? defaultContext, {
|
||||
[prop]: value,
|
||||
});
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
setInterval(() => {
|
||||
let ctxEl = document.getElementById("context");
|
||||
if (!ctxEl) {
|
||||
ctxEl = document.createElement("div");
|
||||
ctxEl.id = "context";
|
||||
document.body.append(ctxEl);
|
||||
}
|
||||
ctxEl.innerHTML = "";
|
||||
const div = document.createElement("div");
|
||||
const pre = document.createElement("pre");
|
||||
const h3 = document.createElement("h3");
|
||||
h3.textContent = "Default";
|
||||
div.append(h3);
|
||||
pre.textContent = safeStringify(defaultContext);
|
||||
div.append(pre);
|
||||
ctxEl.append(div);
|
||||
for (const [idx, ctx] of contextStack.entries()) {
|
||||
const div = document.createElement("div");
|
||||
const pre = document.createElement("pre");
|
||||
const h3 = document.createElement("h3");
|
||||
h3.textContent = "CTX " + idx;
|
||||
div.append(h3);
|
||||
pre.textContent = safeStringify(ctx);
|
||||
div.append(pre);
|
||||
ctxEl.append(div);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function safeStringify(obj: any) {
|
||||
const seen = new WeakSet();
|
||||
return JSON.stringify(obj, (key, value) => {
|
||||
if (typeof value === "object" && value !== null) {
|
||||
if (seen.has(value)) {
|
||||
return "[Circular]"; // Replace circular references
|
||||
}
|
||||
seen.add(value);
|
||||
}
|
||||
return value;
|
||||
}, 2);
|
||||
}
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
BIN
public/train icon.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
147
src/lib/context.ts
Normal file
@@ -0,0 +1,147 @@
|
||||
import { TrackSegment } from "../track/system.ts";
|
||||
import { Train, TrainCar } from "../train/train.ts";
|
||||
import { InputManager } from "./input.ts";
|
||||
|
||||
type ContextStore = Record<string, any>;
|
||||
|
||||
const defaultContext: ContextStore = {};
|
||||
const contextStack: ContextStore[] = [defaultContext];
|
||||
|
||||
const debug = JSON.parse(localStorage.getItem("debug") || "false");
|
||||
|
||||
export function setDefaultContext(context: ContextStore) {
|
||||
Object.assign(defaultContext, context);
|
||||
}
|
||||
|
||||
export function withContext<T>(context: ContextStore, fn: () => T): T {
|
||||
contextStack.push(context);
|
||||
try {
|
||||
return fn();
|
||||
} finally {
|
||||
contextStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
export const ctx = new Proxy(
|
||||
{},
|
||||
{
|
||||
get(_, prop: string) {
|
||||
for (let i = contextStack.length - 1; i >= 0; i--) {
|
||||
if (prop in contextStack[i]) return contextStack[i][prop];
|
||||
}
|
||||
if (prop in defaultContext) return defaultContext[prop];
|
||||
throw new Error(`Context variable '${prop}' is not defined.`);
|
||||
},
|
||||
},
|
||||
) as Record<string, unknown>;
|
||||
|
||||
export function getContext() {
|
||||
return ctx;
|
||||
}
|
||||
export function getContextItem<T>(prop: string): T {
|
||||
return ctx[prop] as T;
|
||||
}
|
||||
export function getContextItemOrDefault<T>(prop: string, defaultValue: T): T {
|
||||
try {
|
||||
return ctx[prop] as T;
|
||||
} catch {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
export function setContextItem<T>(prop: string, value: T) {
|
||||
Object.assign(contextStack[contextStack.length - 1] ?? defaultContext, {
|
||||
[prop]: value,
|
||||
});
|
||||
}
|
||||
|
||||
function safeStringify(obj: any) {
|
||||
const seen = new WeakSet();
|
||||
return JSON.stringify(obj, (key, value) => {
|
||||
if (typeof value === "object" && value !== null) {
|
||||
if (seen.has(value)) {
|
||||
return "[Circular]"; // Replace circular references
|
||||
}
|
||||
seen.add(value);
|
||||
}
|
||||
if (value instanceof Map) {
|
||||
const val: Record<string, unknown> = {};
|
||||
for (const [k, v] of value) {
|
||||
if (typeof k !== "string") continue;
|
||||
val[k] = v;
|
||||
}
|
||||
seen.add(value);
|
||||
return val;
|
||||
}
|
||||
|
||||
if (value instanceof Set) {
|
||||
seen.add(value);
|
||||
value = Array.from(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
if (value instanceof TrackSegment) {
|
||||
seen.add(value);
|
||||
const val = { ...value };
|
||||
(val as any).frontNeighbours = value.frontNeighbours.map((n) => n.id);
|
||||
(val as any).backNeighbours = value.backNeighbours.map((n) => n.id);
|
||||
return val;
|
||||
}
|
||||
|
||||
// if (value instanceof Train) {
|
||||
// const val = { ...value };
|
||||
// // val.segments = value.segments.map((s) => s.id);
|
||||
// delete (val as any).path;
|
||||
// delete (val as any).nodes;
|
||||
// delete (val as any).cars;
|
||||
// delete (val as any).t;
|
||||
|
||||
// // val.t
|
||||
// // val.
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// if (value instanceof InputManager) {
|
||||
// return {};
|
||||
// }
|
||||
|
||||
// if (value instanceof TrainCar) {
|
||||
// const val = { ...value };
|
||||
|
||||
// return val;
|
||||
// }
|
||||
|
||||
return value;
|
||||
}, 2);
|
||||
}
|
||||
const getContextStack = () => JSON.parse(safeStringify(contextStack));
|
||||
const updateContextValue = (
|
||||
key: string,
|
||||
value: unknown,
|
||||
depth = contextStack.length - 1,
|
||||
) => {
|
||||
const keys = key.split(".");
|
||||
let context = contextStack[depth] ?? defaultContext;
|
||||
for (let i = 0; i < keys.length - 1; i++) {
|
||||
if (context instanceof Map) {
|
||||
context = context.get(keys[i]);
|
||||
} else {
|
||||
context = context[keys[i]];
|
||||
}
|
||||
}
|
||||
if (context instanceof Map) {
|
||||
context.set(keys.at(-1)!, value);
|
||||
} else {
|
||||
context[keys.at(-1)!] = value;
|
||||
}
|
||||
};
|
||||
if (location.hostname === "localhost") {
|
||||
globalThis.getContextStack = getContextStack;
|
||||
globalThis.updateContextValue = updateContextValue;
|
||||
globalThis.contextStack = contextStack;
|
||||
}
|
||||
|
||||
declare global {
|
||||
var getContextStack: () => ContextStore[];
|
||||
var updateContextValue: (key: string, value: unknown, depth?: number) => void;
|
||||
var contextStack: ContextStore[];
|
||||
}
|
35
src/lib/debuggable.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { getContextItem } from "./context.ts";
|
||||
|
||||
export abstract class Drawable {
|
||||
abstract draw(...args: unknown[]): void;
|
||||
}
|
||||
|
||||
export abstract class Debuggable extends Drawable {
|
||||
constructor(...debugKeys: [boolean | keyof Debug, ...(keyof Debug)[]]) {
|
||||
super();
|
||||
if (import.meta.env.DEV) {
|
||||
let drawFirst = false;
|
||||
if (typeof debugKeys[0] === "boolean") {
|
||||
drawFirst = debugKeys.shift() as boolean;
|
||||
}
|
||||
const draw = this.draw.bind(this);
|
||||
this.draw = drawFirst
|
||||
? (...args: unknown[]) => {
|
||||
draw(...args);
|
||||
const debug = getContextItem<Debug>("debug");
|
||||
if (debugKeys.some((k) => debug[k as keyof Debug])) {
|
||||
this.debugDraw();
|
||||
}
|
||||
}
|
||||
: (...args: unknown[]) => {
|
||||
const debug = getContextItem<Debug>("debug");
|
||||
if (debugKeys.some((k) => debug[k as keyof Debug])) {
|
||||
this.debugDraw();
|
||||
}
|
||||
draw(...args);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
abstract debugDraw(...args: unknown[]): void;
|
||||
}
|
@@ -24,7 +24,7 @@ const doodler = new ZoomableDoodler({
|
||||
(doodler as any as { ctx: CanvasRenderingContext2D }).ctx
|
||||
.imageSmoothingEnabled = false;
|
||||
// doodler.minScale = 0.1;
|
||||
// (doodler as any).scale = doodler.maxScale;
|
||||
(doodler as any).scale = 3.14;
|
||||
|
||||
const colors = [
|
||||
"red",
|
||||
@@ -37,12 +37,32 @@ const colors = [
|
||||
"violet",
|
||||
];
|
||||
|
||||
const _debug: Debug = JSON.parse(localStorage.getItem("debug") || "0") || {
|
||||
track: false,
|
||||
train: false,
|
||||
path: false,
|
||||
car: false,
|
||||
};
|
||||
|
||||
const debug = new Proxy(_debug, {
|
||||
get: (_, prop: string) => {
|
||||
// if (prop !in _debug) {
|
||||
// (_debug as any)[prop] = false;
|
||||
// }
|
||||
return prop in _debug ? (_debug as any)[prop] : false;
|
||||
},
|
||||
set: (_, prop: string, value: boolean) => {
|
||||
(_debug as any)[prop] = value;
|
||||
localStorage.setItem("debug", JSON.stringify(_debug));
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
||||
setDefaultContext({
|
||||
inputManager,
|
||||
doodler,
|
||||
resources,
|
||||
debug: true,
|
||||
showEnds: true,
|
||||
debug,
|
||||
colors,
|
||||
});
|
||||
|
||||
@@ -83,3 +103,7 @@ setInterval(() => {
|
||||
|
||||
const gameLoop = new GameLoop();
|
||||
gameLoop.start(state);
|
||||
|
||||
if (import.meta.env.DEV) {
|
||||
console.log("Running in development mode");
|
||||
}
|
@@ -1,34 +1,34 @@
|
||||
import { Constants } from "../math/constants.ts";
|
||||
import { map } from "../math/lerp.ts";
|
||||
import { ComplexPath, PathSegment } from "../math/path.ts";
|
||||
import { Vector } from "doodler";
|
||||
import { Vector } from "@bearmetal/doodler";
|
||||
import { Mover } from "./mover.ts";
|
||||
|
||||
export class
|
||||
Follower extends Mover {
|
||||
export class Follower extends Mover {
|
||||
debug = true;
|
||||
|
||||
follow(toFollow: ComplexPath | PathSegment) {
|
||||
follow(toFollow: ComplexPath | PathSegment) {
|
||||
if (toFollow instanceof ComplexPath) {
|
||||
const predict = this.velocity.copy();
|
||||
predict.normalize();
|
||||
predict.mult(25);
|
||||
const predictpos = Vector.add(this.position, predict)
|
||||
|
||||
if (this.ctx)
|
||||
Mover.edges(predict, this.ctx.canvas.width, this.ctx.canvas.height)
|
||||
const predictpos = Vector.add(this.position, predict);
|
||||
|
||||
if (this.ctx) {
|
||||
Mover.edges(predict, this.ctx.canvas.width, this.ctx.canvas.height);
|
||||
}
|
||||
let normal = null;
|
||||
let target = null;
|
||||
let worldRecord = 1000000;
|
||||
|
||||
|
||||
for (let i = 0; i < toFollow.points.length; i++) {
|
||||
// Look at a line segment
|
||||
let a = toFollow.points[i];
|
||||
let b = toFollow.points[(i + 1) % toFollow.points.length]; // Note Path has to wraparound
|
||||
|
||||
|
||||
// Get the normal point to that line
|
||||
let normalPoint = getNormalPoint(predictpos, a, b);
|
||||
|
||||
|
||||
// Check if normal is on line segment
|
||||
let dir = Vector.sub(b, a);
|
||||
// If it's not within the line segment, consider the normal to just be the end of the line segment (point b)
|
||||
@@ -45,14 +45,14 @@ export class
|
||||
b = toFollow.points[(i + 2) % toFollow.points.length]; // Path wraps around
|
||||
dir = Vector.sub(b, a);
|
||||
}
|
||||
|
||||
|
||||
// How far away are we from the path?
|
||||
const d = Vector.dist(predictpos, normalPoint);
|
||||
// Did we beat the worldRecord and find the closest line segment?
|
||||
if (d < worldRecord) {
|
||||
worldRecord = d;
|
||||
normal = normalPoint;
|
||||
|
||||
|
||||
// Look at the direction of the line segment so we can seek a little bit ahead of the normal
|
||||
dir.normalize();
|
||||
// This is an oversimplification
|
||||
@@ -61,47 +61,47 @@ export class
|
||||
target = normal.copy();
|
||||
target.add(dir);
|
||||
}
|
||||
|
||||
|
||||
if (worldRecord > toFollow.radius) {
|
||||
return this.seek(target!);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (this.debug && this.ctx) {
|
||||
// Draw predicted future position
|
||||
this.ctx.strokeStyle = 'red';
|
||||
this.ctx.fillStyle = 'pink';
|
||||
this.ctx.strokeStyle = "red";
|
||||
this.ctx.fillStyle = "pink";
|
||||
this.ctx.beginPath();
|
||||
this.ctx.moveTo(this.position.x, this.position.y)
|
||||
this.ctx.moveTo(this.position.x, this.position.y);
|
||||
this.ctx.lineTo(predictpos.x, predictpos.y);
|
||||
this.ctx.stroke();
|
||||
|
||||
|
||||
this.ctx.beginPath();
|
||||
this.ctx.arc(predictpos.x, predictpos.y, 4, 0, Constants.TWO_PI);
|
||||
this.ctx.fill();
|
||||
this.ctx.stroke();
|
||||
|
||||
|
||||
// Draw normal position
|
||||
this.ctx.beginPath();
|
||||
this.ctx.arc(normal!.x, normal!.y, 4, 0, Constants.TWO_PI);
|
||||
this.ctx.fill();
|
||||
this.ctx.stroke();
|
||||
|
||||
|
||||
// Draw actual target (red if steering towards it)
|
||||
this.ctx.beginPath();
|
||||
this.ctx.moveTo(predictpos.x, predictpos.y)
|
||||
this.ctx.moveTo(predictpos.x, predictpos.y);
|
||||
this.ctx.lineTo(target!.x, target!.y);
|
||||
this.ctx.stroke();
|
||||
|
||||
|
||||
// if (worldRecord > toFollow.radius) fill(255, 0, 0);
|
||||
// noStroke();
|
||||
|
||||
|
||||
this.ctx.beginPath();
|
||||
this.ctx.arc(target!.x, target!.y, 8, 0, Constants.TWO_PI);
|
||||
this.ctx.fill();
|
||||
this.ctx.stroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
seek(target: Vector, strength: number = 1) {
|
@@ -1,4 +1,5 @@
|
||||
import { Vector } from "doodler";
|
||||
import { Doodler, Vector } from "@bearmetal/doodler";
|
||||
import { getContextItem } from "../lib/context.ts";
|
||||
|
||||
export class Mover {
|
||||
position: Vector;
|
||||
@@ -29,25 +30,25 @@ export class Mover {
|
||||
boundingBox: {
|
||||
pos: Vector;
|
||||
size: Vector;
|
||||
}
|
||||
};
|
||||
|
||||
constructor();
|
||||
constructor(random: boolean);
|
||||
constructor(pos?: Vector, vel?: Vector, acc?: Vector);
|
||||
constructor(posOrRandom?: Vector | boolean, vel?: Vector, acc?: Vector) {
|
||||
if (typeof posOrRandom === 'boolean' && posOrRandom) {
|
||||
if (typeof posOrRandom === "boolean" && posOrRandom) {
|
||||
this.position = Vector.random2D(new Vector());
|
||||
this.velocity = Vector.random2D(new Vector());
|
||||
this.acceleration = new Vector()
|
||||
this.acceleration = new Vector();
|
||||
} else {
|
||||
this.position = posOrRandom || new Vector();
|
||||
this.velocity = vel || new Vector();
|
||||
this.acceleration = acc || new Vector()
|
||||
this.acceleration = acc || new Vector();
|
||||
}
|
||||
this.boundingBox = {
|
||||
size: new Vector(20, 10),
|
||||
pos: new Vector(this.position.x - 10, this.position.y - 5)
|
||||
}
|
||||
pos: new Vector(this.position.x - 10, this.position.y - 5),
|
||||
};
|
||||
|
||||
this.maxSpeed = 3;
|
||||
this.maxForce = .3;
|
||||
@@ -59,7 +60,7 @@ export class Mover {
|
||||
}
|
||||
|
||||
init() {
|
||||
//
|
||||
//
|
||||
}
|
||||
|
||||
move() {
|
||||
@@ -81,20 +82,34 @@ export class Mover {
|
||||
}
|
||||
|
||||
draw() {
|
||||
const doodler = getContextItem<Doodler>("doodler");
|
||||
doodler.drawRotated(this.position, this.velocity.heading() || 0, () => {
|
||||
doodler.fillCenteredRect(this.position, this.boundingBox.size.x, this.boundingBox.size.y, {fillColor: 'white'})
|
||||
doodler.fillCenteredRect(
|
||||
this.position,
|
||||
this.boundingBox.size.x,
|
||||
this.boundingBox.size.y,
|
||||
{ fillColor: "white" },
|
||||
);
|
||||
});
|
||||
if (!this.ctx) return;
|
||||
|
||||
this.ctx.fillStyle = 'white'
|
||||
this.ctx.fillStyle = "white";
|
||||
this.ctx.save();
|
||||
this.ctx.translate(this.position.x, this.position.y);
|
||||
this.ctx.rotate(this.velocity.heading() || 0);
|
||||
this.ctx.translate(-this.position.x, -this.position.y);
|
||||
// this.ctx.rotate(Math.PI)
|
||||
// this.ctx.rotate(.5);
|
||||
this.ctx.translate(-(this.boundingBox.size.x / 2), -(this.boundingBox.size.y / 2));
|
||||
this.ctx.fillRect(this.position.x, this.position.y, this.boundingBox.size.x, this.boundingBox.size.y);
|
||||
this.ctx.translate(
|
||||
-(this.boundingBox.size.x / 2),
|
||||
-(this.boundingBox.size.y / 2),
|
||||
);
|
||||
this.ctx.fillRect(
|
||||
this.position.x,
|
||||
this.position.y,
|
||||
this.boundingBox.size.x,
|
||||
this.boundingBox.size.y,
|
||||
);
|
||||
this.ctx.restore();
|
||||
}
|
||||
|
||||
@@ -112,4 +127,4 @@ export class Mover {
|
||||
if (point.x < 0) point.x = width;
|
||||
if (point.y < 0) point.y = height;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
import { getContext } from "../lib/context.ts";
|
||||
import { TrackSystem } from "../track/system.ts";
|
||||
import { Train } from "../train.old.ts";
|
||||
import { Train } from "../train/train.ts";
|
||||
|
||||
export class StateMachine<T> {
|
||||
private _states: Map<T, State<T>> = new Map();
|
@@ -42,12 +42,12 @@ export class LoadState extends State<States> {
|
||||
});
|
||||
|
||||
const doodler = getContextItem<Doodler>("doodler");
|
||||
this.layers.push(doodler.createLayer((_, __, dTime) => {
|
||||
doodler.clearRect(new Vector(0, 0), doodler.width, doodler.height);
|
||||
doodler.fillRect(new Vector(0, 0), doodler.width, doodler.height, {
|
||||
color: "#302040",
|
||||
});
|
||||
}));
|
||||
// this.layers.push(doodler.createLayer((_, __, dTime) => {
|
||||
// doodler.clearRect(new Vector(0, 0), doodler.width, doodler.height);
|
||||
// doodler.fillRect(new Vector(0, 0), doodler.width, doodler.height, {
|
||||
// color: "#302040",
|
||||
// });
|
||||
// }));
|
||||
}
|
||||
override stop(): void {
|
||||
// noop
|
||||
@@ -57,7 +57,7 @@ export class LoadState extends State<States> {
|
||||
const track = TrackSystem.deserialize(
|
||||
JSON.parse(localStorage.getItem("track") || "[]"),
|
||||
);
|
||||
return track;
|
||||
return track ?? new TrackSystem([new StraightTrack()]);
|
||||
}
|
||||
|
||||
private loadTrains() {
|
@@ -25,13 +25,13 @@ export class RunningState extends State<States> {
|
||||
// Update trains
|
||||
// Update world
|
||||
// Handle input
|
||||
// Draw (maybe via a layer system that syncs with doodler)
|
||||
// Monitor world events
|
||||
for (const train of ctx.trains) {
|
||||
train.move(dt);
|
||||
}
|
||||
}
|
||||
override start(): void {
|
||||
console.log("Starting running state");
|
||||
const doodler = getContextItem<Doodler>("doodler");
|
||||
this.layers.push(
|
||||
doodler.createLayer(() => {
|
||||
@@ -61,7 +61,7 @@ export class RunningState extends State<States> {
|
||||
const train = new Train(track.path, [new RedEngine(), new Tender()]);
|
||||
ctx.trains.push(train);
|
||||
});
|
||||
// const trainCount = 2000;
|
||||
// const trainCount = 1000;
|
||||
// for (let i = 0; i < trainCount; i++) {
|
||||
// const train = new Train(track.path, [new RedEngine(), new Tender()]);
|
||||
// ctx.trains.push(train);
|
||||
@@ -72,6 +72,9 @@ export class RunningState extends State<States> {
|
||||
for (const train of trains) {
|
||||
train.speed += 1;
|
||||
}
|
||||
// for (const [i, train] of trains.entries()) {
|
||||
// train.speed += .01 * i;
|
||||
// }
|
||||
});
|
||||
inputManager.onKey("ArrowDown", () => {
|
||||
const trains = getContextItem<Train[]>("trains");
|
@@ -1,5 +1,4 @@
|
||||
import { StateMachine } from "../machine.ts";
|
||||
import { Track } from "../../track.ts";
|
||||
import { EditTrainState } from "./EditTrainState.ts";
|
||||
import { EditTrackState } from "./EditTrackState.ts";
|
||||
import { PausedState } from "./PausedState.ts";
|
@@ -4,33 +4,37 @@ import { getContextItem, setDefaultContext } from "../lib/context.ts";
|
||||
import { clamp } from "../math/clamp.ts";
|
||||
|
||||
export class TrackSystem {
|
||||
private segments: Map<string, TrackSegment> = new Map();
|
||||
private _segments: Map<string, TrackSegment> = new Map();
|
||||
private doodler: Doodler;
|
||||
|
||||
constructor(segments: TrackSegment[]) {
|
||||
this.doodler = getContextItem<Doodler>("doodler");
|
||||
for (const segment of segments) {
|
||||
this.segments.set(segment.id, segment);
|
||||
this._segments.set(segment.id, segment);
|
||||
}
|
||||
}
|
||||
|
||||
getSegment(id: string) {
|
||||
return this._segments.get(id);
|
||||
}
|
||||
|
||||
get firstSegment() {
|
||||
return this.segments.values().next().value;
|
||||
return this._segments.values().next().value;
|
||||
}
|
||||
|
||||
get lastSegment() {
|
||||
return this.segments.values().toArray().pop();
|
||||
return this._segments.values().toArray().pop();
|
||||
}
|
||||
|
||||
optimize(percent: number) {
|
||||
console.log("Optimizing track", percent * 100 / 4);
|
||||
for (const segment of this.segments.values()) {
|
||||
for (const segment of this._segments.values()) {
|
||||
segment.recalculateRailPoints(Math.round(percent * 100 / 4));
|
||||
}
|
||||
}
|
||||
|
||||
recalculateAll() {
|
||||
for (const segment of this.segments.values()) {
|
||||
for (const segment of this._segments.values()) {
|
||||
segment.recalculateRailPoints();
|
||||
segment.length = segment.calculateApproxLength();
|
||||
}
|
||||
@@ -38,11 +42,11 @@ export class TrackSystem {
|
||||
|
||||
registerSegment(segment: TrackSegment) {
|
||||
segment.setTrack(this);
|
||||
this.segments.set(segment.id, segment);
|
||||
this._segments.set(segment.id, segment);
|
||||
}
|
||||
unregisterSegment(segment: TrackSegment) {
|
||||
this.segments.delete(segment.id);
|
||||
for (const s of this.segments.values()) {
|
||||
this._segments.delete(segment.id);
|
||||
for (const s of this._segments.values()) {
|
||||
s.backNeighbours = s.backNeighbours.filter((n) => n !== segment);
|
||||
s.frontNeighbours = s.frontNeighbours.filter((n) => n !== segment);
|
||||
}
|
||||
@@ -52,7 +56,7 @@ export class TrackSystem {
|
||||
}
|
||||
|
||||
draw(showControls = false) {
|
||||
for (const [i, segment] of this.segments.entries()) {
|
||||
for (const [i, segment] of this._segments.entries()) {
|
||||
segment.draw(showControls);
|
||||
}
|
||||
|
||||
@@ -85,7 +89,7 @@ export class TrackSystem {
|
||||
endArray: End[] = [];
|
||||
|
||||
findEnds() {
|
||||
for (const segment of this.segments.values()) {
|
||||
for (const segment of this._segments.values()) {
|
||||
if (this.ends.has(segment)) continue;
|
||||
const ends: [End, End] = [
|
||||
{
|
||||
@@ -109,37 +113,37 @@ export class TrackSystem {
|
||||
|
||||
serialize() {
|
||||
return JSON.stringify(
|
||||
this.segments.values().map((s) => s.serialize()).toArray(),
|
||||
this._segments.values().map((s) => s.serialize()).toArray(),
|
||||
);
|
||||
}
|
||||
|
||||
copy() {
|
||||
const track = new TrackSystem([]);
|
||||
for (const segment of this.segments.values()) {
|
||||
track.segments.set(segment.id, segment.copy());
|
||||
for (const segment of this._segments.values()) {
|
||||
track._segments.set(segment.id, segment.copy());
|
||||
}
|
||||
return track;
|
||||
}
|
||||
|
||||
static deserialize(data: SerializedTrackSegment[]) {
|
||||
if (data.length === 0) return undefined;
|
||||
if (data.length === 0) return new TrackSystem([]);
|
||||
const track = new TrackSystem([]);
|
||||
const neighborMap = new Map<string, [string[], string[]]>();
|
||||
|
||||
for (const segment of data) {
|
||||
track.segments.set(segment.id, TrackSegment.deserialize(segment));
|
||||
track._segments.set(segment.id, TrackSegment.deserialize(segment));
|
||||
neighborMap.set(segment.id, [segment.fNeighbors, segment.bNeighbors]);
|
||||
}
|
||||
|
||||
for (const segment of track.segments.values()) {
|
||||
for (const segment of track._segments.values()) {
|
||||
segment.setTrack(track);
|
||||
const neighbors = neighborMap.get(segment.id);
|
||||
if (neighbors) {
|
||||
segment.backNeighbours = neighbors[1].map((id) =>
|
||||
track.segments.get(id)
|
||||
track._segments.get(id)
|
||||
).filter((s) => s) as TrackSegment[];
|
||||
segment.frontNeighbours = neighbors[0].map((id) =>
|
||||
track.segments.get(id)
|
||||
track._segments.get(id)
|
||||
).filter((s) => s) as TrackSegment[];
|
||||
}
|
||||
}
|
||||
@@ -148,7 +152,7 @@ export class TrackSystem {
|
||||
}
|
||||
|
||||
translate(v: Vector) {
|
||||
for (const segment of this.segments.values()) {
|
||||
for (const segment of this._segments.values()) {
|
||||
segment.translate(v);
|
||||
}
|
||||
}
|
||||
@@ -164,7 +168,7 @@ export class TrackSystem {
|
||||
|
||||
generatePath() {
|
||||
if (!this.firstSegment) throw new Error("No first segment");
|
||||
const flags = { looping: true };
|
||||
const flags = { looping: false };
|
||||
const rightOnlyPath = [
|
||||
this.firstSegment.copy(),
|
||||
...this.findRightPath(
|
||||
@@ -276,15 +280,19 @@ export class TrackSegment extends PathSegment {
|
||||
doodler: Doodler;
|
||||
normalPoints: Vector[] = [];
|
||||
antiNormalPoints: Vector[] = [];
|
||||
evenPoints: [Vector, number][] = [];
|
||||
|
||||
constructor(p: VectorSet, id?: string) {
|
||||
super(p);
|
||||
this.doodler = getContextItem<Doodler>("doodler");
|
||||
this.id = id ?? crypto.randomUUID();
|
||||
this.recalculateRailPoints();
|
||||
|
||||
const spacing = Math.ceil(this.length / 10);
|
||||
this.evenPoints = this.calculateEvenlySpacedPoints(this.length / spacing);
|
||||
}
|
||||
|
||||
recalculateRailPoints(resolution = 100) {
|
||||
recalculateRailPoints(resolution = 60) {
|
||||
this.normalPoints = [];
|
||||
this.antiNormalPoints = [];
|
||||
for (let i = 0; i <= resolution; i++) {
|
||||
@@ -330,12 +338,12 @@ export class TrackSegment extends PathSegment {
|
||||
});
|
||||
}
|
||||
|
||||
const spacing = Math.ceil(this.length / 10);
|
||||
const points = this.calculateEvenlySpacedPoints(this.length / spacing);
|
||||
for (let i = 0; i < points.length - 1; i++) {
|
||||
// const spacing = Math.ceil(this.length / 10);
|
||||
// const points = this.calculateEvenlySpacedPoints(this.length / spacing);
|
||||
for (let i = 0; i < this.evenPoints.length - 1; i++) {
|
||||
// const t = i / ties;
|
||||
// const p = this.getPointAtT(t);
|
||||
const [p, t] = points[i];
|
||||
const [p, t] = this.evenPoints[i];
|
||||
// this.doodler.drawCircle(p, 2, {
|
||||
// color: "red",
|
||||
// weight: 3,
|
||||
@@ -480,11 +488,17 @@ export class TrackSegment extends PathSegment {
|
||||
}
|
||||
}
|
||||
|
||||
interface PathPoint {
|
||||
p: Vector;
|
||||
segmentId: string;
|
||||
tangent: Vector;
|
||||
}
|
||||
|
||||
export class Spline<T extends PathSegment = PathSegment> {
|
||||
segments: T[] = [];
|
||||
ctx?: CanvasRenderingContext2D;
|
||||
|
||||
evenPoints: Vector[];
|
||||
evenPoints: PathPoint[];
|
||||
pointSpacing: number;
|
||||
|
||||
get points() {
|
||||
@@ -534,13 +548,17 @@ export class Spline<T extends PathSegment = PathSegment> {
|
||||
}
|
||||
}
|
||||
|
||||
calculateEvenlySpacedPoints(spacing: number, resolution = 1) {
|
||||
calculateEvenlySpacedPoints(spacing: number, resolution = 1): PathPoint[] {
|
||||
this.pointSpacing = 1;
|
||||
// return this.segments.flatMap(s => s.calculateEvenlySpacedPoints(spacing, resolution));
|
||||
const points: Vector[] = [];
|
||||
const points: PathPoint[] = [];
|
||||
|
||||
points.push(this.segments[0].points[0]);
|
||||
let prev = points[0];
|
||||
points.push({
|
||||
p: this.segments[0].points[0],
|
||||
segmentId: this.segments[0].id,
|
||||
tangent: this.segments[0].tangent(0),
|
||||
});
|
||||
let prev = points[0].p;
|
||||
let distSinceLastEvenPoint = 0;
|
||||
for (const seg of this.segments) {
|
||||
let t = 0;
|
||||
@@ -558,8 +576,13 @@ export class Spline<T extends PathSegment = PathSegment> {
|
||||
Vector.sub(point, prev).normalize().mult(overshoot),
|
||||
);
|
||||
distSinceLastEvenPoint = overshoot;
|
||||
points.push(evenPoint);
|
||||
points.push({
|
||||
p: evenPoint,
|
||||
segmentId: seg.id,
|
||||
tangent: seg.tangent(t),
|
||||
});
|
||||
prev = evenPoint;
|
||||
continue;
|
||||
}
|
||||
|
||||
prev = point;
|
||||
@@ -571,13 +594,17 @@ export class Spline<T extends PathSegment = PathSegment> {
|
||||
return points;
|
||||
}
|
||||
|
||||
followEvenPoints(t: number) {
|
||||
followEvenPoints(t: number): PathPoint {
|
||||
if (this.looped) {
|
||||
if (t < 0) t += this.evenPoints.length;
|
||||
const i = Math.floor(t) % this.evenPoints.length;
|
||||
const a = this.evenPoints[i];
|
||||
const b = this.evenPoints[(i + 1) % this.evenPoints.length];
|
||||
return Vector.lerp(a, b, t % 1);
|
||||
return {
|
||||
p: Vector.lerp(a.p, b.p, t % 1),
|
||||
segmentId: b.segmentId,
|
||||
tangent: b.tangent,
|
||||
};
|
||||
}
|
||||
t = clamp(t, 0, this.evenPoints.length - 1);
|
||||
const i = clamp(Math.floor(t), 0, this.evenPoints.length - 1);
|
||||
@@ -586,7 +613,11 @@ export class Spline<T extends PathSegment = PathSegment> {
|
||||
.evenPoints[
|
||||
clamp((i + 1) % this.evenPoints.length, 0, this.evenPoints.length - 1)
|
||||
];
|
||||
return Vector.lerp(a, b, t % 1);
|
||||
return {
|
||||
p: Vector.lerp(a.p, b.p, t % 1),
|
||||
segmentId: b.segmentId,
|
||||
tangent: b.tangent,
|
||||
};
|
||||
}
|
||||
|
||||
calculateApproxLength() {
|
@@ -1,4 +1,4 @@
|
||||
import { Vector } from "https://jsr.io/@bearmetal/doodler/0.0.4/geometry/vector.ts";
|
||||
import { Vector } from "@bearmetal/doodler";
|
||||
import { TrainCar } from "./train.ts";
|
||||
import { ResourceManager } from "../lib/resources.ts";
|
||||
import { getContextItem } from "../lib/context.ts";
|
@@ -1,12 +1,10 @@
|
||||
import { ComplexPath, PathSegment } from "../math/path.ts";
|
||||
import { Follower } from "../physics/follower.ts";
|
||||
import { Mover } from "../physics/mover.ts";
|
||||
import { getContextItem } from "../lib/context.ts";
|
||||
import { Doodler, Vector } from "@bearmetal/doodler";
|
||||
import { Spline, TrackSegment } from "../track/system.ts";
|
||||
import { ResourceManager } from "../lib/resources.ts";
|
||||
import { Spline, TrackSegment, TrackSystem } from "../track/system.ts";
|
||||
import { Debuggable } from "../lib/debuggable.ts";
|
||||
import { map } from "../math/lerp.ts";
|
||||
|
||||
export class Train {
|
||||
export class Train extends Debuggable {
|
||||
nodes: Vector[] = [];
|
||||
|
||||
cars: TrainCar[] = [];
|
||||
@@ -14,32 +12,20 @@ export class Train {
|
||||
path: Spline<TrackSegment>;
|
||||
t: number;
|
||||
|
||||
engineLength = 40;
|
||||
spacing = 30;
|
||||
spacing = 20;
|
||||
|
||||
speed = 10;
|
||||
|
||||
get segments() {
|
||||
return Array.from(new Set(this.cars.flatMap((c) => c.segments)));
|
||||
}
|
||||
|
||||
constructor(track: Spline<TrackSegment>, cars: TrainCar[]) {
|
||||
super("train", "path");
|
||||
this.path = track;
|
||||
this.t = 0;
|
||||
const resources = getContextItem<ResourceManager>("resources");
|
||||
this.cars = cars;
|
||||
// this.cars.push(
|
||||
// new TrainCar(
|
||||
// 55,
|
||||
// engineSprites,
|
||||
// 80,
|
||||
// 20,
|
||||
// { at: new Vector(0, 60), width: 80, height: 20 },
|
||||
// ),
|
||||
// new TrainCar(
|
||||
// 25,
|
||||
// engineSprites,
|
||||
// 40,
|
||||
// 20,
|
||||
// { at: new Vector(80, 0), width: 40, height: 20 },
|
||||
// ),
|
||||
// );
|
||||
|
||||
let currentOffset = 0;
|
||||
try {
|
||||
for (const car of this.cars) {
|
||||
@@ -47,8 +33,9 @@ export class Train {
|
||||
const a = this.path.followEvenPoints(this.t - currentOffset);
|
||||
currentOffset += car.length;
|
||||
const b = this.path.followEvenPoints(this.t - currentOffset);
|
||||
car.points = [a, b];
|
||||
this.nodes.push(a, b);
|
||||
car.points = [a.p, b.p];
|
||||
this.nodes.push(a.p, b.p);
|
||||
car.segments = [a.segmentId, b.segmentId];
|
||||
}
|
||||
} catch {
|
||||
currentOffset = 0;
|
||||
@@ -57,24 +44,29 @@ export class Train {
|
||||
const a = this.path.followEvenPoints(this.t - currentOffset);
|
||||
currentOffset += car.length;
|
||||
const b = this.path.followEvenPoints(this.t - currentOffset);
|
||||
car.points = [a, b];
|
||||
this.nodes.push(a, b);
|
||||
car.points = [a.p, b.p];
|
||||
this.nodes.push(a.p, b.p);
|
||||
car.segments = [a.segmentId, b.segmentId];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
move(dTime: number) {
|
||||
if (!this.speed) return;
|
||||
this.t = this.t + this.speed * dTime * 10;
|
||||
// % this.path.evenPoints.length; // This should probably be on the track system
|
||||
// console.log(this.t);
|
||||
let currentOffset = 0;
|
||||
for (const car of this.cars) {
|
||||
// This needs to be moved to the car itself
|
||||
if (!car.points) return;
|
||||
const [a, b] = car.points;
|
||||
a.set(this.path.followEvenPoints(this.t - currentOffset));
|
||||
const nA = this.path.followEvenPoints(this.t - currentOffset);
|
||||
a.set(nA.p);
|
||||
currentOffset += car.length;
|
||||
b.set(this.path.followEvenPoints(this.t - currentOffset));
|
||||
const nB = this.path.followEvenPoints(this.t - currentOffset);
|
||||
b.set(nB.p);
|
||||
currentOffset += this.spacing;
|
||||
car.segments = [nA.segmentId, nB.segmentId];
|
||||
// car.draw();
|
||||
}
|
||||
// this.draw();
|
||||
@@ -101,20 +93,58 @@ export class Train {
|
||||
}
|
||||
}
|
||||
|
||||
override debugDraw(): void {
|
||||
const debug = getContextItem<Debug>("debug");
|
||||
const doodler = getContextItem<Doodler>("doodler");
|
||||
if (debug.path) {
|
||||
// doodler.drawLine(this.path.points, {
|
||||
// color: "red",
|
||||
// weight: 3,
|
||||
// });
|
||||
const colors = getContextItem<string[]>("colors");
|
||||
for (const [i, p] of this.path.evenPoints.entries()) {
|
||||
const color = colors[
|
||||
Math.floor(
|
||||
map(i, 0, this.path.evenPoints.length, 0, colors.length),
|
||||
)
|
||||
];
|
||||
doodler.drawCircle(p.p, 2, { color, weight: .5 });
|
||||
}
|
||||
}
|
||||
|
||||
if (debug.train) {
|
||||
const track = getContextItem<TrackSystem>("track");
|
||||
const colors = getContextItem<string[]>("colors").slice();
|
||||
colors.push(colors.shift()!);
|
||||
colors.push(colors.shift()!);
|
||||
colors.push(colors.shift()!);
|
||||
for (const [i, segmentId] of this.segments.entries()) {
|
||||
const segment = track.getSegment(segmentId);
|
||||
segment &&
|
||||
doodler.drawBezier(...segment.points, {
|
||||
color: colors[i % colors.length],
|
||||
weight: 3,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
real2Track(length: number) {
|
||||
return length / this.path.pointSpacing;
|
||||
}
|
||||
}
|
||||
|
||||
export class TrainCar {
|
||||
export class TrainCar extends Debuggable {
|
||||
img: HTMLImageElement;
|
||||
imgWidth: number;
|
||||
imgHeight: number;
|
||||
sprite?: ISprite;
|
||||
|
||||
points?: [Vector, Vector];
|
||||
points?: [Vector, Vector, ...Vector[]];
|
||||
length: number;
|
||||
|
||||
segments: string[] = [];
|
||||
|
||||
constructor(
|
||||
length: number,
|
||||
img: HTMLImageElement,
|
||||
@@ -122,6 +152,7 @@ export class TrainCar {
|
||||
h: number,
|
||||
sprite?: ISprite,
|
||||
) {
|
||||
super(true, "car");
|
||||
this.img = img;
|
||||
this.sprite = sprite;
|
||||
this.imgWidth = w;
|
||||
@@ -155,6 +186,14 @@ export class TrainCar {
|
||||
);
|
||||
});
|
||||
}
|
||||
override debugDraw(...args: unknown[]): void {
|
||||
if (!this.points) return;
|
||||
const doodler = getContextItem<Doodler>("doodler");
|
||||
doodler.drawLine(this.points, {
|
||||
color: "blue",
|
||||
weight: 3,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
interface ISprite {
|
@@ -15,4 +15,11 @@ declare global {
|
||||
bNeighbors: string[];
|
||||
fNeighbors: string[];
|
||||
};
|
||||
|
||||
type Debug = {
|
||||
track: boolean;
|
||||
train: boolean;
|
||||
car: boolean;
|
||||
path: boolean;
|
||||
};
|
||||
}
|
1
src/vite-env.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/// <reference types="vite/client" />
|
8
vite.config.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { defineConfig } from "vite";
|
||||
import deno from "@deno/vite-plugin";
|
||||
import { strip } from "./vite/plugins/strip.ts";
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [deno(), strip()],
|
||||
});
|
67
vite/plugins/strip.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import { Plugin } from "vite";
|
||||
|
||||
export function strip(): Plugin {
|
||||
const p: Plugin = {
|
||||
name: "debug-strip",
|
||||
enforce: "pre",
|
||||
apply: "build",
|
||||
transform(code: string, id: string) {
|
||||
if (!id.endsWith(".ts") || import.meta.env.DEV) {
|
||||
return code;
|
||||
}
|
||||
|
||||
const keyword = "override debugDraw";
|
||||
const results = [];
|
||||
let currentIndex = 0;
|
||||
|
||||
while (true) {
|
||||
// Find the next occurrence of the keyword starting from currentIndex.
|
||||
const startIndex = code.indexOf(keyword, currentIndex);
|
||||
if (startIndex === -1) {
|
||||
break; // No more occurrences.
|
||||
}
|
||||
|
||||
// Find the first opening brace '{' after the keyword.
|
||||
const braceStart = code.indexOf("{", startIndex);
|
||||
if (braceStart === -1) {
|
||||
// No opening brace found; skip this occurrence.
|
||||
currentIndex = startIndex + keyword.length;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Use a counter to find the matching closing brace.
|
||||
let openBraces = 0;
|
||||
let endIndex = -1;
|
||||
for (let i = braceStart; i < code.length; i++) {
|
||||
if (code[i] === "{") {
|
||||
openBraces++;
|
||||
} else if (code[i] === "}") {
|
||||
openBraces--;
|
||||
}
|
||||
|
||||
// When openBraces returns to 0, we found the matching closing brace.
|
||||
if (openBraces === 0) {
|
||||
endIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If a matching closing brace was found, extract the substring.
|
||||
if (endIndex !== -1) {
|
||||
results.push(code.substring(startIndex, endIndex + 1));
|
||||
// Move the currentIndex past the extracted block.
|
||||
currentIndex = endIndex + 1;
|
||||
} else {
|
||||
// If no matching closing brace is found, skip this occurrence.
|
||||
currentIndex = startIndex + keyword.length;
|
||||
}
|
||||
}
|
||||
|
||||
for (const result of results) {
|
||||
code = code.replace(result, "");
|
||||
}
|
||||
return code;
|
||||
},
|
||||
};
|
||||
return p;
|
||||
}
|